Skip to content

Instantly share code, notes, and snippets.

@echophon
Created July 23, 2014 05:28
Show Gist options
  • Save echophon/9c67fd99c548c45d303d to your computer and use it in GitHub Desktop.
Save echophon/9c67fd99c548c45d303d to your computer and use it in GitHub Desktop.
/*
* Hex Melange
* by Yancy Way (Echophon) - twitter.com/echophons - echophon.tumblr.com
*/
//requires HYPE.pde (staging)
HDrawablePool pool;
HColorPool colors;
int rotation =0;
void setup(){
size(500,500,P3D);
H.init(this).background(#000000).use3D(true).autoClear(true);
smooth();
colors = new HColorPool(#FFFFFF);
pool = new HDrawablePool(168); //168 1027
pool.autoAddToStage()
.add( new HPath() )
.layout(
new HHexLayout()
.spacing(80)
.offsetX(0)
.offsetY(0)
)
//.colorist(colors)
.onCreate (
new HCallback() {
public void run(Object obj) {
int i = pool.currentIndex();
HPath d = (HPath) obj;
d
.polygon( 6 )
.anchorAt(H.CENTER)
.noStroke()
.fill(colors.getColor( i * 90) )
.size(40)
;
float j = dist(d.x(), d.y(), width/2, height/2);
new HOscillator()
.target(d)
.property(H.SCALE)
.range(-2 , 2 )
.waveform(H.SINE)
.freq(1)
.speed(2)
.currentStep( j)
;
new HOscillator()
.target(d)
.property(H.DY)
.range(-4.5 , 4.5 )
.waveform(H.SINE)
.freq(1)
.speed(2)
.currentStep( j)
;
new HOscillator()
.target(d)
.property(H.Z)
.range(300 , -300 )
.waveform(H.SINE)
.freq(1)
.speed(2)
.currentStep( j)
;
new HOscillator()
.target(d)
.property(H.DROTATIONX)
.range(-1.5 , 1.5 )
.waveform(H.SINE)
.freq(1)
.speed(2)
.currentStep( j)
;
}
}
)
.requestAll()
;
}
void draw(){
float orbitRadius= 550;
float xpos= cos(radians(rotation))*orbitRadius;
float zpos= sin(radians(rotation))*orbitRadius;
camera(
xpos, 0, zpos,
width/2, height/2, 0,
0, -1, 0
);
rotation++;
directionalLight(157, 56, 49, 0, 0, -1);
directionalLight(68, 85, 122, 1, 1, 0);
H.drawStage();
if(frameCount % 3 == 0 && frameCount < 361){
saveFrame("image-#####.gif");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment