Defines how many colors a gradient has and how they are located on the axis defined by coords
Defines how the gradient is located in space and spread
Optional excludeIf true, this object will not be exported during the serialization of a canvas
Optional gradientA transform matrix to apply to the gradient before painting. Imported from svg gradients, is not applied with the current transform in the center. Before this transform is applied, the origin point is at the top left corner of the object plus the addition of offsetY and offsetX.
null
coordinates units for coords.
If pixels, the number of coords are in the same unit of width / height.
If set as percentage the coords are still a number, but 1 means 100% of width
for the X and 100% of the height for the y. It can be bigger than 1 and negative.
allowed values pixels or percentage.
'pixels'
Readonly idID used for SVG export functionalities
Horizontal offset for aligning gradients coming from SVG when outside pathgroups
0
Vertical offset for aligning gradients coming from SVG when outside pathgroups
0
Gradient type linear or radial
'linear'
Static typeReturns object representation of a gradient
Optional propertiesToInclude: string[]Any properties that you might want to additionally include in the output
Returns SVG representation of an gradient
Object to create a gradient for
Optional additionalSVG representation of an gradient (linear/radial)
Static fromReturns Gradient instance from an SVG element
SVG gradient element
an object containing the size of the SVG in order to parse correctly gradients that uses gradientUnits as 'userSpaceOnUse' and percentages.
Gradient instance
Gradient
<linearGradient id="linearGrad1">
<stop offset="0%" stop-color="white"/>
<stop offset="100%" stop-color="black"/>
</linearGradient>
OR
<linearGradient id="linearGrad2">
<stop offset="0" style="stop-color:rgb(255,255,255)"/>
<stop offset="1" style="stop-color:rgb(0,0,0)"/>
</linearGradient>
OR
<radialGradient id="radialGrad1">
<stop offset="0%" stop-color="white" stop-opacity="1" />
<stop offset="50%" stop-color="black" stop-opacity="0.5" />
<stop offset="100%" stop-color="white" stop-opacity="1" />
</radialGradient>
OR
<radialGradient id="radialGrad2">
<stop offset="0" stop-color="rgb(255,255,255)" />
<stop offset="0.5" stop-color="rgb(0,0,0)" />
<stop offset="1" stop-color="rgb(255,255,255)" />
</radialGradient>
Generated using TypeDoc
Gradient class
Tutorial
http://fabricjs.com/fabric-intro-part-2#gradients