1.0.3 • Published 6 years ago

matrix-screen v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

matrix-screen

install

npm i --save matrix-screen

Usage

import MatrixIndicator, { martixScreen, dataFactory } from 'matrix-screen';

const df = dataFactory(32, 16);
const matrix = new martixScreen(canvas, {
  x: 32,
  y: 16,
  // other options...
});
matrix.setData(df.getMatrix());
matrix.render();

use react

  • MatrixIndicator
import  from 'matrix-screen';

<MatrixIndicator text="0123456789" />
  • MatrixTime
import { MatrixTime } from 'matrix-screen';

<MatrixTime />

Options

{
  x: number;
  y: number;
  pixelWidth: number;
  pixelHeight: number;
  margin: number;
  shadow: boolean;
  animated: boolean;
}

dataFactory Methods

  • dataFactory.write(text, font, color)
  • dataFactory.fill(x, y, r, g, b, a)

props

MatrixIndicator Props

paramstypedefaultdescription
widthnumber32matrix width
heightnumber16matrix height
textnumber-content text
fontstringdigitdisplay font, 'digit', 'm38gorilla', 'bulge' .
pixelWidthnumber10one pixel width.
pixelHeightnumber10one pixel height.
marginnumber4grid space.
shadowbooleanfalsetext shadow.
animatedbooleanfalseenable animate.
shapestring-cusstom shapes, 'cross', 'warning', 'alert', 'arrowUp', 'arrowRight', 'arrowDown', 'arrowLeft', 'info', 'wifi'.
backgroundstring-matrix background.

注意,当对包裹 MatrixIndicator 的容器进行设置 widht/height 时,则需要采用 calcScreenSize 进行计算 widthheight,并设置为结果的一半(或将width和height转化为对应的x和y也可,采用 sizeToXy)。即:

import MatrixIndicator, { calcScreenSize } from 'matrix-screen';

// render
const { width, height } = calcScreenSize(this.props);
const style = {
  width,
  height
};

<div style={style}>
  <MatrixIndicator {...this.props} />
</div>

MatrixTime Props

paramstypedefaultdescription
widthnumber32matrix time width
heightnumber16matrix time height
radiusnumber3radius or rect * 2.
marginTopnumber10margin top.
marginLeftboolean10margin left.
isRectbooleanfalseenable rect.
backgroundstring-matrix background.
colorstring-matrix time color.

Lecense

MIT

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago