Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. const square = new Konva.Shape({
  2. x: 50,
  3. y: 30,
  4. stroke: 'rgba(0,0,0,0.5)',
  5. strokeWidth: 20,
  6. fill: 'green',
  7. draggable: true,
  8. width: 100,
  9. height: 100,
  10. sceneFunc: (ctx, shape) => {
  11. ctx.rect(0, 0, shape.width(), shape.height());
  12. // first stroke
  13. ctx.strokeShape(shape);
  14. // then fill
  15. ctx.fillShape(shape);
  16. }
  17. });
  18. layer.add(square);
  19.  
  20. const triangle = new Konva.Shape({
  21. x: 250,
  22. y: 30,
  23. stroke: 'rgba(0,0,0,0.5)',
  24. strokeWidth: 20,
  25. fill: 'green',
  26. draggable: true,
  27. sceneFunc: (ctx, shape) => {
  28. ctx.beginPath();
  29. ctx.moveTo(0, 0);
  30. ctx.lineTo(50, 100);
  31. ctx.lineTo(-50, 100);
  32. ctx.closePath();
  33. // first stroke
  34. ctx.strokeShape(shape);
  35. // then fill
  36. ctx.fillShape(shape);
  37. }
  38. });
  39. layer.add(triangle);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement