Advertisement
Guest User

Disappearing canvas paths

a guest
Mar 16th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. var window = canvas.Window.new([256, 512], "dialog");
  2. var mcanvas = window.createCanvas();
  3. var root = mcanvas.createGroup();
  4. var grp = root.createChild("group");
  5.  
  6. mcanvas.setColorBackground(1, 1, 1, 1);
  7. var path = grp.createChild("path")
  8. .setColor(0, 0, 0)
  9. .setStrokeLineWidth(3)
  10. .show();
  11.  
  12. var grpMove = grp.createChild("group")
  13. .setTranslation(128, 384);
  14. var grpPath = grpMove.createChild("path")
  15. .setColor(0, 0, 0)
  16. .setStrokeLineWidth(3)
  17. .moveTo(0, 50)
  18. .lineTo(0, -50)
  19. .show();
  20.  
  21. var update = func() {
  22. var time = getprop("sim/time/mp-clock-sec")*2 or 0;
  23.  
  24. path.reset()
  25. .moveTo(128 + math.sin(time) * 50, 128 + math.cos(time) * 50)
  26. .lineTo(128 + math.sin(time + 3.1415) * 50, 128 + math.cos(time + 3.1415) * 50);
  27.  
  28. grpMove.setRotation(-time);
  29.  
  30. settimer(func update(), 0.03);
  31. }
  32.  
  33. update();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement