0.0.3 • Published 3 years ago

ngx-display v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

NgxDisplay

This library renders seven and sixteen segments displays according to the input parameters. Live Demo It exports four components:

  • SevenSegmentComponent <seven-segment>: Renders a seven segments display according to a bitmap, following the standard below:

  • SevenSegmentDigitComponent <seven-segment-digit>: Renders a digit in a seven segments display, according to the table below:

digitbitMask (decimal)digitbitMask (decimal)
0126j60
148k47
2109l14
3121m21
451n118
591o29
695p103
7112q115
8127r5
9123s91
a119t15
b31u62
c78v62
d61w28
e79x55
f71y59
g95z109
h550
i6-1
  • SixteenSegmentComponent <sixteen-segment>: Renders a sixteen segments display according to a bitmap, following the standard below:

  • SixteenSegmentDigitComponent <sixteen-segment-digit>: Renders a digit in a sixteen segments display, according to the table below:

digitbitMask (decimal)digitbitMask (decimal)
075687W9780
138X17426
270541Y12716
365965Z66947
412332a7040
578225b15104
678761c4864
765573d2220
878765e5888
978253f38921
A78381g112896
B100781h14848
C74625i2048
D100773j35584
E78721k34834
F78337l8704
G74665m6696
H12844n6656
I100737o6912
J932p111104
K12818q112640
L9088r4608
M25126s80128
N25140t13056
O74661u2816
P78349v1536
Q74677w1584
R78365x17426
S78249y32940
T100353z5376
U91240
V9730,1024
.64-4104
"40960

Usage

First of all, import the NgxDisplayModule in your AppModule :

import { NgModule } from '@angular/core';
import { NgxDisplayModule } from 'NgxDisplayModule';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    NgxDisplayModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Seven Segment

<seven-segment
    [randomNoise]="randomNoise"
    [width]="width"
    [height]="height"
    [glowColor]="glowColor"
    [glowBlur]="glowBlur"
    [backgroundColor]="backgroundColor"
    [colorOn]="colorOn"
    [colorOff]="colorOff"
    [bitMask]="bitMask"
></seven-segment>

Where:

  • randomNoise (boolean) = defines if there's or if there's not a random glow
  • width (number) = width of the display
  • height (number)= height of the display
  • glowColor (string) = string containing the color of the glow. Tested with be RGB, HEX, RGBA.
  • glowBlur (number) = length of glow's blur
  • backgroundColor (string) = string containing the display's background color. Tested with be RGB, HEX, RGBA.
  • colorOn (string) = string containing the color of display's segments when they are turned on. Tested with be RGB, HEX, RGBA.
  • colorOff (string) = string containing the color of display's segments when they are turned off. Tested with be RGB, HEX, RGBA.
  • bitMask (number) = bitMask representing the state of the display

Seven Segment Digit

Same as above, except instead of passing a bitmask you pass a character to be drawn in the display:

<seven-segment-digit
    [randomNoise]="randomNoise"
    [width]="width"
    [height]="height"
    [glowColor]="glowColor"
    [glowBlur]="glowBlur"
    [backgroundColor]="backgroundColor"
    [colorOn]="colorOn"
    [colorOff]="colorOff"
    [character]="character"
></seven-segment-digit>

Where:

  • randomNoise (boolean) = defines if there's or if there's not a random glow
  • width (number) = width of the display
  • height (number)= height of the display
  • glowColor (string) = string containing the color of the glow. Tested with be RGB, HEX, RGBA.
  • glowBlur (number) = length of glow's blur
  • backgroundColor (string) = string containing the display's background color. Tested with be RGB, HEX, RGBA.
  • colorOn (string) = string containing the color of display's segments when they are turned on. Tested with be RGB, HEX, RGBA.
  • colorOff (string) = string containing the color of display's segments when they are turned off. Tested with be RGB, HEX, RGBA.
  • character (string) = one of the characters below (it can be either lower case characters or upper case ones. They will be converted to lower case before rendering.):
digitdigitdigitdigit
0123
4567
89ab
cdef
ghij
klmn
opqr
stuv
wxyz
<space>-

Sixteen Segment

<sixteen-segment
    [randomNoise]="randomNoise"
    [width]="width"
    [height]="height"
    [glowColor]="glowColor"
    [glowBlur]="glowBlur"
    [backgroundColor]="backgroundColor"
    [colorOn]="colorOn"
    [colorOff]="colorOff"
    [bitMask]="bitMask"
></sixteen-segment>

Where:

  • randomNoise (boolean) = defines if there's or if there's not a random glow
  • width (number) = width of the display
  • height (number)= height of the display
  • glowColor (string) = string containing the color of the glow. Tested with be RGB, HEX, RGBA.
  • glowBlur (number) = length of glow's blur
  • backgroundColor (string) = string containing the display's background color. Tested with be RGB, HEX, RGBA.
  • colorOn (string) = string containing the color of display's segments when they are turned on. Tested with be RGB, HEX, RGBA.
  • colorOff (string) = string containing the color of display's segments when they are turned off. Tested with be RGB, HEX, RGBA.
  • bitMask (number) = bitMask representing the state of the display

Sixteen Segment Digit

Same as above, except instead of passing a bitmask you pass a character to be drawn in the display:

<sixteen-segment-digit
    [randomNoise]="randomNoise"
    [width]="width"
    [height]="height"
    [glowColor]="glowColor"
    [glowBlur]="glowBlur"
    [backgroundColor]="backgroundColor"
    [colorOn]="colorOn"
    [colorOff]="colorOff"
    [character]="character"
></sixteen-segment-digit>

Where:

  • randomNoise (boolean) = defines if there's or if there's not a random glow
  • width (number) = width of the display
  • height (number)= height of the display
  • glowColor (string) = string containing the color of the glow. Tested with be RGB, HEX, RGBA.
  • glowBlur (number) = length of glow's blur
  • backgroundColor (string) = string containing the display's background color. Tested with be RGB, HEX, RGBA.
  • colorOn (string) = string containing the color of display's segments when they are turned on. Tested with be RGB, HEX, RGBA.
  • colorOff (string) = string containing the color of display's segments when they are turned off. Tested with be RGB, HEX, RGBA.
  • character (string) = one of the characters below:
digitdigitdigitdigitdigitdigitdigitdigit
01234567
89abcdef
ghijklmn
opqrstuv
wxyzABCD
EFGHIJKL
MNOPQRST
UVWXYZ<space>,
.-"

Examples

Example 1: Seven Segment Display alphabet

app.component.html:

<seven-segment-digit 
    [height]="150" 
    [width]="108" 
    [randomNoise]="true" 
    [character]="'0'"  
    [glowBlur]="30" 
    [colorOn]="'#ffdd8f'" 
    [colorOff]="'rgba(255, 255, 255, 0.1)'" 
    [glowColor]="'#ff9a1f'" 
    [backgroundColor]="'#16161a'"
></seven-segment-digit>
<seven-segment-digit 
    [height]="150" 
    [width]="108" 
    [randomNoise]="true" 
    [character]="'1'"  
    [glowBlur]="30" 
    [colorOn]="'#ffdd8f'" 
    [colorOff]="'rgba(255, 255, 255, 0.1)'" 
    [glowColor]="'#ff9a1f'" 
    [backgroundColor]="'#16161a'"
></seven-segment-digit>
...
<seven-segment-digit 
    [height]="150" 
    [width]="108" 
    [randomNoise]="true" 
    [character]="' '"  
    [glowBlur]="30" 
    [colorOn]="'#ffdd8f'" 
    [colorOff]="'rgba(255, 255, 255, 0.1)'" 
    [glowColor]="'#ff9a1f'" 
    [backgroundColor]="'#16161a'"
></seven-segment-digit>

Result (some adicional css were added only for alignment and general background color):

Example 2: Sixteen Segment Display alphabet

app.component.html:

<sixteen-segment-digit 
    [height]="150" 
    [width]="108" 
    [randomNoise]="true" 
    [character]="'0'"  
    [glowBlur]="30" 
    [colorOn]="'#ffdd8f'" 
    [colorOff]="'rgba(255, 255, 255, 0.1)'" 
    [glowColor]="'#ff9a1f'" 
    [backgroundColor]="'#16161a'"
></sixteen-segment-digit>
<sixteen-segment-digit 
    [height]="150" 
    [width]="108" 
    [randomNoise]="true" 
    [character]="'1'"  
    [glowBlur]="30" 
    [colorOn]="'#ffdd8f'" 
    [colorOff]="'rgba(255, 255, 255, 0.1)'" 
    [glowColor]="'#ff9a1f'" 
    [backgroundColor]="'#16161a'"
></sixteen-segment-digit>
...
<sixteen-segment-digit 
    [height]="150" 
    [width]="108" 
    [randomNoise]="true" 
    [character]="' '"  [glowBlu
    r]="30" 
    [colorOn]="'#ffdd8f'" 
    [colorOff]="'rgba(255, 255, 255, 0.1)'" 
    [glowColor]="'#ff9a1f'" 
    [backgroundColor]="'#16161a'"
></sixteen-segment-digit>

Result (some adicional css were added only for alignment and general background color):