Constructs a new builder.
Sets the background color.
Note that the background color will only be applied when the BACKGROUND
pattern
is set on this builder.
The background color specified as a CSS string
this builder instance
Builds the pattern with the current settings of this builder instance.
An Image based on the current settings.
Sets the line color
The line color specified as a CSS string
this builder instance
Sets the line width.
Note that increasing the line width might require to increase HatchedImageBuilder.patternSize as well to obtain the desired result.
The line width in pixels
this builder instance
Sets the pixel size of the filling pattern. The pattern is created by drawing one line in every necessary direction (horizontal, vertical, slash or backslash). This pattern is then tiled to fill the required area. Changing the size of this pattern allows to define the spacing between adjacent lines. Defining a non-square pattern size for slanted patterns (slash and backslash) allows to change the angle of the slanted lines. For example a slash pattern with a pattern size of 20x10 results in 26.6 degree lines (Math.atan(10/20)).
Width and height must be strictly larger than twice (line width + 2). The values should be small for performance reasons, for example 10x10 or 20x10 pixels.
The width in pixels
The height in pixels
this builder instance
Specifies which patterns should be used. This can be any combination of the constants defined in Pattern.
An array containing Pattern
instances
this builder instance
Builder for creating a hatched image with a given line width and color. A typical use case of such a hatched image is as image in a FillStyle.
The generated image will only contain one line in every necessary direction (horizontal, vertical, slash or backslash) on top of the background color (if background is enabled). When used in a
FillStyle
, this image will be tiled to the required area, resulting in a hatched fill.Example code:
An example use case of such a pattern is as fill for a shape, for example: