OptionalalignmentThe alignment of the stroke relative to the path.
OptionalalphaThe alpha value to use for the fill. This value should be between 0 (fully transparent) and 1 (fully opaque).
OptionalcapThe style to use for the ends of open paths.
OptionalcolorThe color to use for the fill. This can be any valid color source, such as a hex value, a Color object, or a string.
// Using a hex color
const fillStyle = { color: 0xff0000 }; // Red
// Using a Color object
const fillStyle = { color: new Color(1, 0, 0) }; // Red
// Using a string color
const fillStyle = { color: 'red' }; // Red
// Using object string
const fillStyle = { color: 'rgb(255, 0, 0)' }; // Red
ColorSource For more details on color sources
OptionalfillThe fill pattern or gradient to use. This can be either a FillPattern for repeating textures or a FillGradient for color transitions.
// Using a gradient
const gradient = new FillGradient({
end: { x: 1, y: 0 },
stops: [
{ color: 0xff0000, offset: 0 }, // Red at start
{ color: 0x0000ff, offset: 1 }, // Blue at end
]
});
const fillStyle = {
fill: gradient,
alpha: 0.8
};
// Using a pattern
const pattern = new FillPattern(
Texture.from('pattern.png'),
'repeat' // or 'no-repeat', 'repeat-x', 'repeat-y'
);
const fillStyle = {
fill: pattern
};
OptionaljoinThe style to use where paths connect.
OptionalmatrixThe transformation matrix to apply to the fill pattern or texture. Used to scale, rotate, translate, or skew the fill.
OptionalmiterControls how far miter joins can extend. Only applies when join is 'miter'. Higher values allow sharper corners.
OptionalpixelWhen true, ensures crisp 1px lines by aligning to pixel boundaries.
Only available for Graphics fills.
OptionaltextureThe texture to use for the fill.
Texture For more details on textures
OptionaltextureDetermines how texture coordinates are calculated across shapes.
// Local space - texture fits each shape independently
const fillStyle = {
texture: Texture.from('myImage.png'),
textureSpace: 'local'
};
// Global space - texture continues across shapes
const fillStyle = {
texture: Texture.from('myImage.png'),
textureSpace: 'global'
};
TextureSpace For more details on texture spaces
OptionalwidthThe width of the stroke in pixels.
A stroke style object that combines fill properties with stroke attributes to define both the visual style and stroke behavior of lines, shape outlines, and text strokes.
Example
See