LinearGradient
The LinearGradient class represents a linear color gradient to be used for the stroke or fill color property. To create a LinearGradient object, use the linearGradient function:
let lg = msc.linearGradient({x1: 0, y1: 0, x2: 100, y2: 0});
Properties
property | explanation | type | default value |
---|---|---|---|
x1 | the x coordinate of the start of the gradient, between 0 and 100 | Number | 0 |
y1 | the y coordinate of the start of the gradient, between 0 and 100 | Number | 0 |
x2 | the x coordinate of the end of the gradient, between 0 and 100 | Number | 100 |
y2 | the y coordinate of the end of the gradient, between 0 and 100 | Number | 0 |
stops | the color stops along the gradient | Array | [] |
Methods
method | explanation | return type |
---|---|---|
addStop(offset, color, opacity) | adds a color stop to the gradient offset (Number): the position of the stop as a number between 0 and 100 color (String): the color of the stop opacity (Number): the opacity of the stop as a number between 0 and 1 | void |