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

propertyexplanationtypedefault value
x1the x coordinate of the start of the gradient, between 0 and 100Number0
y1the y coordinate of the start of the gradient, between 0 and 100Number0
x2the x coordinate of the end of the gradient, between 0 and 100Number100
y2the y coordinate of the end of the gradient, between 0 and 100Number0
stopsthe color stops along the gradientArray[]

Methods

methodexplanationreturn 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