Advertisement
JoshuaDavis

HCanvas reflection

May 3rd, 2021
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import hype.*;
  2. import hype.extended.behavior.HFollow;
  3.  
  4. HFollow mf;
  5. HRect rect;
  6. HCanvas canvas;
  7.  
  8. int stageW = 640;
  9. int stageH = 640;
  10.  
  11. PImage canvasFlip;
  12.  
  13. void settings() {
  14. size(stageW,stageH, P3D);
  15. }
  16.  
  17. void setup() {
  18. H.init(this).background(#242424).use3D(true);
  19.  
  20. canvas = new HCanvas(P3D).autoClear(false).fade(5);
  21. canvas.loc(stageW/2, 0);
  22. H.add(canvas);
  23.  
  24. rect = new HRect(100);
  25. rect.rounding(40).noStroke().fill(#ECECEC).loc(width/2,height/2).anchorAt(H.CENTER).rotation(45);
  26. canvas.add(rect);
  27.  
  28. mf = new HFollow().target(rect);
  29.  
  30. canvasFlip = canvas.graphics();
  31. }
  32.  
  33. void draw() {
  34. H.drawStage();
  35.  
  36. // flipped copy of HCanvas
  37. pushMatrix();
  38. scale(-1,1); // flip PImage on the x axis
  39. translate(-(stageW/2), 0, 0);
  40. image(canvasFlip, 0, 0);
  41. popMatrix();
  42.  
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement