Search code examples
colorsrectkonvajs

KonvaJS Fill Rect with two colors?


It is possible? If yes how? One example please.

var example = new Konva.Rect({
    x: 10,
    y: 10,
    width: 500,
    height: 20,
    fillLinearGradientStartPoint: [0, 0],
    fillLinearGradientEndPoint: [400, 0],
    fillLinearGradientColorStops: [0, 'red', 1, 'yellow']
});

Solution

  • API for fillLinearGradientStartPoint and fillLinearGradientEndPoint is not correct. A correct example:

    fillLinearGradientStartPoint: { x : -50, y : -50},

    fillLinearGradientEndPoint: { x : 50, y : 50}

    Question

    Why I received two negative votes?