Advertisement
JoshuaDavis

HYPE + Gradients

Aug 1st, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. import hype.*;
  2. import hype.extended.behavior.HRotate;
  3. import hype.extended.layout.HGridLayout;
  4.  
  5. int stageW = 900;
  6. int stageH = 900;
  7. int bgClr  = #242424;
  8.  
  9. HDrawablePool pool;
  10.  
  11. PImage gradTex1, gradTex2, gradTex3;
  12.  
  13. void settings() {
  14.     size(stageW, stageH, P3D);
  15.     fullScreen(1);
  16. }
  17.  
  18. void setup() {
  19.     H.init(this).background(bgClr).use3D(true);
  20.  
  21.     gradTex1 = loadImage("grad_001.png");
  22.     gradTex2 = loadImage("grad_002.png");
  23.     gradTex3 = loadImage("tex3b.png");
  24.  
  25.     pool = new HDrawablePool(100);
  26.     pool.autoAddToStage()
  27.         .add(new HBox().texture(gradTex1))
  28.         .add(new HBox().texture(gradTex2))
  29.         .add(new HBox().texture(gradTex3))
  30.  
  31.         // .add(new HSprite().texture(gradTex1))
  32.         // .add(new HSprite().texture(gradTex2))
  33.  
  34.         .layout(new HGridLayout().startX(44.5).startY(44.5).spacing(90,90).cols(10))
  35.         .onCreate(
  36.              new HCallback() {
  37.                 public void run(Object obj) {
  38.                     HDrawable d = (HDrawable) obj;
  39.  
  40.                     int ranRot = 90 + ( (int)random(4)*90 );
  41.  
  42.                     // d.noStroke().fill(255, 225).size(178).anchorAt(H.CENTER).rotation(ranRot);
  43.                     d.noStroke().fill(255, 225).size(178).rotation(ranRot).z( (int)random(-100,100) );
  44.  
  45.                     float ranX = random(-1.0, 1.0);
  46.                     float ranY = random(-1.0, 1.0);
  47.                     float ranZ = random(-1.0, 1.0);
  48.  
  49.                     new HRotate().target(d).speedX(ranX).speedY(ranY).speedZ(ranZ);
  50.                 }
  51.             }
  52.         )
  53.         // .requestAll()
  54.         .shuffleRequestAll()
  55.     ;
  56. }
  57.  
  58. void draw() {
  59.     pushMatrix();
  60.         translate( (width/2)-(stageW/2), (height/2)-(stageH/2) );
  61.         H.drawStage();
  62.     popMatrix();
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement