Skip to content

0I Drawing gradients to the canvas

Luis Murillo Baltodano edited this page Sep 4, 2020 · 6 revisions

Need an object like

gradient {
    x Number
    y Number
    radious Number > 0
    colors []CanvasColorString
}

Use the render function

render(myGradientObject).gradient()

Example

preset(({size, draw, clear, c, render}) => {
    size()
    const myGradientObject = {
        x: c.width / 2,
        y: c.height / 2,
        radious: c.width / 2,
        colors: ['#cc2b5e', '#753a88']
    }
    draw(() => {
        clear()
        render(myGradientObject).gradient()
    })
})
Clone this wiki locally