Gradient API Reference


b5.Gradient

A gradient represents a range of colours that can be displayed by Actors. Generally a Gradient should be added to either a scene or the global app’s resources so that it can be managed by them.

Each colour stop is an object of {c, offs}, where c is the colour and offs is the offset the colour should appear down the gradient

Public properties

  • name – The name of this object
  • parent – The parent container scene or app
  • stops – An array of colour stops

Methods

Gradient(name, colour_stops) – Creates an instance of a Gradient object

  • name – The name of the gradient
  • colour_stops – An array of colour stops

addColourStop(colour, offset) – Adds a gradient stop to the gradient

  • colour – Colour of gradient stop
  • offset – Offset of gradient stop

getColourStop(index) – Returns the colour stop at the specified index

getMaxStops() – Returns the total number of colour stops in the gradient

destroy() – Removes the gradient from the scene / app and destroys it

createStyle(w, h, start, end) – Creates a style from this gradient that can be used by fills and strokes

  • w – Width of the gradient area (usually width of fill area)
  • h – Height of the gradient area (usually height of fill area)
  • start – Start point of gradient {x, y}
  • end – End point of gradient {x, y}

561 total views, 1 views today