4

I am using konvajs for drawing on canvas. I just found a opacity property, where I can set the opacity of the whole shape (in my case a closed line) to the alpha value, but that also includes the border and not just the filling opacity.

  new Konva.Line({
    points: [30, 20, 49, 54, 100, 220],
    fill: 'red',  // put an opacity just on this color
    stroke: 'black',
    strokeWidth: 2,
    closed : true,
    opacity: 0.4
  });

Is there a possibility to just make the filling with some opacity and keep the border totally visible?

Safari
  • 3,302
  • 9
  • 45
  • 64

1 Answers1

3

Just use rgba for fill:

new Konva.Line({
  points: [30, 20, 49, 54, 100, 220],
  fill: 'rgba(255,0,0,0.4)',
  stroke: 'black',
  strokeWidth: 2,
  closed : true
});
lavrton
  • 18,973
  • 4
  • 30
  • 63