2.0.3 • Published 2 days ago

@antv/g-pattern v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

g-pattern

Refer to nivo patterns, we provide some built-in patterns, and you can adjust the appearance through more friendly parameters. Currently we support the following three patterns:

  • dots Pattern with dots.
  • lines Pattern with lines.
  • squares Pattern with squares.

The method signatures of these three patterns are as follows, the first parameter is Canvas, and the second parameter is the style configuration of the pattern:

dots(canvas: Canvas, cfg?: DotPatternCfg): HTMLCanvasElement;
lines(canvas: Canvas, cfg?: LinePatternCfg): HTMLCanvasElement;
squares(canvas: Canvas, cfg?: SquarePatternCfg): HTMLCanvasElement;

In the following example, we choose dots and use transform to rotate and scale it:

import { dots } from '@antv/g-pattern';

rect.style.fill = {
    image: dots(canvas, {
        size: 6,
        padding: 2,
        fill: '#ff0000',
        isStagger: true,
    }),
    repetition: 'repeat',
    transform: `rotate(30deg) scale(1.2)`,
};

Common configuration for all types of pattern:

AttributeTypeDescription
backgroundColorstringBackground color of the pattern, default to 'none'
fillstringFill color of the symbol in pattern, dots and squares default to '#fff'
fillOpacitynumberTransparency of the symbol in pattern, default to 1
strokestringStroke color of the symbol in pattern, dots and squares default to 'none', lines default to '#fff'
strokeOpacitynumberStroke opacity of the symbol in pattern, default to 1
lineWidthnumberThe thickness of the symbol's stroke, dots and squares default to 0, lines default to 2
opacitynumberOverall transparency of the pattern, default to 1

Additional configuration for dots, example

AttributeTypeDescription
sizenumberThe size of the dot, default to 6
paddingnumberThe distance between dots, default to 2
isStaggerbooleanStaggered dots. default to true

Additional configuration for lines, example

AttributeTypeDescription
spacingnumberThe distance between the two lines, default to 5

Additional configuration for squares, example:

AttributeTypeDescription
sizenumberThe size of the square, default to 6
paddingnumberThe distance between squares, default to 1
isStaggerbooleanStaggered squares. default to true
2.0.3

2 days ago

2.0.2

14 days ago

2.0.1

1 month ago

2.0.0

2 months ago

1.2.24

2 months ago

1.2.23

2 months ago

1.2.22-next.18

2 months ago

1.2.22-next.19

2 months ago

1.2.22-next.20

2 months ago

1.2.22-next.17

2 months ago

1.2.22-next.16

2 months ago

1.2.22-next.15

2 months ago

1.2.22-next.14

2 months ago

1.2.22-next.13

3 months ago

1.2.22

3 months ago

1.2.22-next.11

3 months ago

1.2.22-next.12

3 months ago

1.2.22-next.10

3 months ago

1.2.22-next.9

3 months ago

1.2.22-next.8

3 months ago

1.2.22-next.7

4 months ago

1.2.22-next.4

4 months ago

1.2.22-next.3

4 months ago

1.2.22-next.6

4 months ago

1.2.22-next.2

4 months ago

1.2.22-next.1

4 months ago

1.2.22-next.0

4 months ago

1.2.21

4 months ago

1.2.20

5 months ago

1.2.18

6 months ago

1.2.19

6 months ago

1.2.16

6 months ago

1.2.17

6 months ago

1.2.8

9 months ago

1.2.7

10 months ago

1.2.6

10 months ago

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.12

9 months ago

1.2.13

8 months ago

1.2.10

9 months ago

1.2.11

9 months ago

1.2.14

7 months ago

1.2.15

7 months ago

1.2.0

11 months ago

1.1.0

11 months ago

1.2.1

10 months ago

1.1.0-alpha.1

11 months ago

1.1.0-beta.1

11 months ago

1.0.19

12 months ago

1.0.18

12 months ago

1.0.17

12 months ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago