Skip to content

Instantly share code, notes, and snippets.

@echophon
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save echophon/3d657d305d3cac4bbaa1 to your computer and use it in GitHub Desktop.
Save echophon/3d657d305d3cac4bbaa1 to your computer and use it in GitHub Desktop.
/*
* Probably Dots
* by Yancy Way (Echophon) - twitter.com/echophons - echophon.tumblr.com
*/
//requires HYPE.pde (staging)
HDrawablePool pool;
void probSize(HDrawable d, float x, float y){
// skip x, for now
float mapX = map(x, 0.0, width, 0.0, 1.0);
float mapY = map(y, 0.0, height, 0.0, 1.0);
// probability 2 in 10 = 0.2 / 1.0
// get a random number and check if greater than map
if (random(0.0,1.0) > mapY){
d.size(0);
}
else{
d.size(mapY * 5);
}
}
void setup() {
size(800,800);
H.init(this).background(#202020).use3D(false);
smooth();
HEllipse hitObj = new HEllipse();
hitObj.size(10);
H.add(hitObj).width(700).height(700).noStroke().fill(#237D26).anchorAt(H.CENTER).loc(width/2,height/2).visibility(false);
HShapeLayout hsl = new HShapeLayout().target(hitObj);
pool = new HDrawablePool(20000);
pool.autoAddToStage()
.add (
new HEllipse()
)
.layout(hsl)
.onCreate (
new HCallback() {
public void run(Object obj) {
int i = pool.currentIndex();
HDrawable d = (HDrawable) obj;
d.noStroke().size(2)
;
probSize(d, d.x(), d.y() );
}
}
)
.requestAll()
;
}
void draw() {
H.drawStage();
if(frameCount % 2 == 0 && frameCount < 3){
saveFrame("image-#####.png");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment