Skip to content

Instantly share code, notes, and snippets.

@echophon
Created February 19, 2024 19:35
Show Gist options
  • Select an option

  • Save echophon/2ebd0598f137ea02b82637d3fb583a4b to your computer and use it in GitHub Desktop.

Select an option

Save echophon/2ebd0598f137ea02b82637d3fb583a4b to your computer and use it in GitHub Desktop.

Revisions

  1. echophon created this gist Feb 19, 2024.
    47 changes: 47 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    import hype.*;

    int numAssets = 120;

    HDrawablePool pool;
    HRect base;

    void setup(){
    size(640,640,P3D);
    background(#242424);
    H.init(this).use3D(true);

    base = new HRect(0,0);
    base.loc(width/2, height/2);

    pool = new HDrawablePool(numAssets);
    pool.autoParent(base)
    .add(new HBox().size(10))
    .onCreate(
    new HCallback() {
    public void run(Object obj) {
    HDrawable d = (HDrawable) obj;
    d
    .strokeWeight(1)
    .stroke(#999999)
    .fill(#202020)
    .loc( (int)random(-100,100), (int)random(-100,100), (int)random(-100,100) )
    .anchor(random(-50,50), random(-50,50))
    ;
    }
    }
    )
    .requestAll();

    }

    void draw() {
    background(#242424);
    for (HDrawable d : pool){
    d.rotateX(frameCount*0.001);
    d.rotateY(frameCount*-0.001);
    }

    base.rotateY(frameCount*0.0001);
    base.rotateX(frameCount*-0.0001);
    base.draw(this.g);
    }