Advertisement
xeromino

handRect

Nov 12th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. HDrawablePool pool, pool2;
  2. HColorPool colors;
  3. float theta;
  4. float sz, _sz;
  5. int _cols, _rows;
  6. int numElem;
  7.  
  8. void setup() {
  9.   size(1136, 640);
  10.   H.init(this).background(#ffffff).autoClear(true);
  11.   smooth();
  12.  
  13.   colors = new HColorPool()
  14.     .add(#F1B710,9)
  15.     .add(#F28F15,9)
  16.     .add(#F25C0A,9)
  17.     .add(#BF2705,3)
  18.     .add(#730502,2)
  19.   ;
  20.  
  21.  
  22.   sz = 50;
  23.   //float cell = sz + 10;
  24.   float cell = sz*1.25;
  25.   float _startX = cell;
  26.   float _startY = cell;
  27.   _cols = int(width/cell)-1;
  28.   _rows = int(height/cell)-1;
  29.   numElem = int(_cols*_rows);
  30.  
  31.   pool = new HDrawablePool(numElem);
  32.   pool.autoAddToStage()
  33.     .add (
  34.     new HRect()
  35.       .rounding(3)
  36.       )
  37.  
  38.       .layout (
  39.       new HGridLayout()
  40.         .startX(cell)
  41.         .startY(cell)
  42.         .spacing(cell, cell)
  43.         .cols(_cols)
  44.         )
  45.  
  46.         .onCreate (
  47.         new HCallback() {
  48.           public void run(Object obj) {
  49.             _sz = sz;
  50.             HDrawable d = (HDrawable) obj;
  51.             d
  52.               //.noStroke()
  53.               .strokeWeight(2)
  54.               .stroke(#000000,100 )
  55.               .noFill()
  56.               //.fill( #ECECEC )
  57.               .anchorAt(H.CENTER)
  58.               .size( _sz )
  59.               ;
  60.           }
  61.         }
  62.   )
  63.     .requestAll()
  64.       ;
  65.  
  66.   pool2 = new HDrawablePool(numElem);
  67.   pool2.autoAddToStage()
  68.     .add (
  69.     new HRect()
  70.       .rounding(5)
  71.       )
  72.  
  73.       .layout (
  74.       new HGridLayout()
  75.         .startX(cell)
  76.         .startY(cell)
  77.         .spacing(cell, cell)
  78.         .cols(_cols)
  79.         )
  80.  
  81.         .onCreate (
  82.         new HCallback() {
  83.           public void run(Object obj) {
  84.             _sz = sz ;
  85.             HDrawable d = (HDrawable) obj;
  86.             d
  87.               .noStroke()
  88.               .fill( colors.getColor(),200)
  89.               .anchorAt(H.CENTER)
  90.               .size(_sz+ random(-10,10), _sz+ random(-10,10))
  91.               ;
  92.           }
  93.         }
  94.   )
  95.  
  96.     .requestAll()
  97.       ;
  98.  
  99.     H.drawStage();
  100.   //noLoop();
  101. }
  102.  
  103. void draw() {
  104.  
  105. }
  106.  
  107. void mouseClicked() {
  108.   setup();
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement