Advertisement
xeromino

Frost

Nov 12th, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. HDrawablePool pool;
  2. HColorPool colors;
  3. float sz;
  4. int _cols, _rows;
  5. int numElem;
  6.  
  7. void setup(){
  8.     size(900,600);
  9.     smooth();
  10.  
  11.     colors = new HColorPool(#D1DBBD, #91AA9D, #3E606F, #193441);
  12.     //colors = new HColorPool(#F28F15, #F25C0A, #BF2705, #730502);
  13.  
  14.     draw_grid();
  15.    
  16. }
  17.  
  18. void draw() {
  19.    
  20. }
  21.  
  22. void draw_grid() {
  23.  
  24.     H.init(this).background(#FFFFFF).autoClear(true);
  25.     sz = 50;
  26.     //float cell = sz + 10;
  27.     float cell = 40;
  28.     float _startX = cell;
  29.     float _startY = cell;
  30.     _cols = int(width/cell)-1;
  31.     _rows = int(height/cell)-1;
  32.     numElem = int(_cols*_rows);
  33.  
  34.     pool = new HDrawablePool(numElem);
  35.     pool.autoAddToStage()
  36.         .add(new HRect())
  37.         .layout(
  38.             new HGridLayout()
  39.             .startX(_startX)
  40.             .startY(_startY)
  41.             .spacing(cell,cell)
  42.             .cols(_cols)
  43.         )
  44.  
  45.         .onCreate(
  46.             new HCallback() {
  47.                 public void run(Object obj) {
  48.                     HRect d = (HRect) obj;
  49.                     d
  50.                         .rounding(5)
  51.                         .anchorAt(H.CENTER)
  52.                         .strokeWeight(1)
  53.                         .stroke(0,150)
  54.                         .fill(colors.getColor(),150)
  55.                         .size(sz)
  56.                         .rotate( 45 )
  57.                     ;
  58.                    
  59.                 }
  60.             }
  61.         )
  62.         .requestAll()
  63.     ;
  64.  
  65.     H.drawStage();
  66. }
  67.  
  68. void mouseClicked() {
  69.     draw_grid();
  70.     //save(random(1234)+".png");
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement