How to draw h2d rectangle with gradient

Hi all -

The docs mention “shapes can be filled with […] gradients”. How can I do this (using h2d) without using a bitmap/texture which contains the gradient? E.g. can I draw a rectangle with two tri’s and specify the color at each point? If so, how? :slight_smile:

Thanks!

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

This should do the work:

        var customGraphics = new h2d.Graphics(s2d);

        // color of the top left corner
        customGraphics.beginFill(0xEA8220);

        customGraphics.moveTo(10, 10);

        // color of the top right corner
        customGraphics.setColor(0xABCDEF);
        customGraphics.lineTo(10, 300);

        // color of bottom right corner
        customGraphics.setColor(0x122345);
        customGraphics.lineTo(300, 300);

        // color of the bottom left corner
        customGraphics.setColor(0xCCDDEE);
        customGraphics.lineTo(300, 10);

        customGraphics.lineTo(10, 10);
1 Like