Advertisement
JoshuaDavis

HYPE multi HCanvas with HDrawablePool

Feb 11th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. HCanvas c1, c2, c3;
  2. HDrawablePool p1, p2, p3;
  3.  
  4. void setup() {
  5. size(640,640);
  6. H.init(this).background(#202020);
  7. smooth();
  8.  
  9. c1 = new HCanvas().autoClear(false).fade(15);
  10. c2 = new HCanvas().autoClear(false).fade(10);
  11. c3 = new HCanvas().autoClear(false).fade(5);
  12.  
  13. H.add(c3);
  14. H.add(c2);
  15. H.add(c1);
  16.  
  17. p1 = new HDrawablePool(10);
  18. p1.autoParent(c1)
  19. .add( new HRect(40).rounding(10) )
  20. .onCreate(
  21. new HCallback() {
  22. public void run(Object obj) {
  23. HDrawable d = (HDrawable) obj;
  24. d.stroke(#000000,50).fill(#FF3300).anchor(20,-20).loc( (int)random(width), (int)random(height) );
  25. new HRotate(d, 2);
  26. }
  27. }
  28. )
  29. .requestAll()
  30. ;
  31.  
  32. p2 = new HDrawablePool(10);
  33. p2.autoParent(c2)
  34. .add( new HRect(60).rounding(10) )
  35. .onCreate(
  36. new HCallback() {
  37. public void run(Object obj) {
  38. HDrawable d = (HDrawable) obj;
  39. d.stroke(#000000,50).fill(#FF6600).anchor(30,-30).loc( (int)random(width), (int)random(height) );
  40. new HRotate(d, 3);
  41. }
  42. }
  43. )
  44. .requestAll()
  45. ;
  46.  
  47. p3 = new HDrawablePool(10);
  48. p3.autoParent(c3)
  49. .add( new HRect(80).rounding(10) )
  50. .onCreate(
  51. new HCallback() {
  52. public void run(Object obj) {
  53. HDrawable d = (HDrawable) obj;
  54. d.stroke(#000000,50).fill(#0095a8).anchor(40,-40).loc( (int)random(width), (int)random(height) );
  55. new HRotate(d, 3);
  56. }
  57. }
  58. )
  59. .requestAll()
  60. ;
  61. }
  62.  
  63. void draw() {
  64. H.drawStage();
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement