import processing.opengl.*;
/**
Strip
Auther: hTaka
mouse move and draw strips!
Made for Processing 118
*/
float worldRotY = 0;
Strip s;
float targetX,targetY;
PFont font;
boolean pointIndex = false;
boolean polyFill = true;
static public void main(String args[]) {
PApplet.main(new String[] { "--present", "--display=1", "strip_OPENGL" });
}
void setup(){
size(screen.width,(screen.width)*9/16,OPENGL);
//size(800,450,OPENGL);
background(255);
frameRate(60);
textMode(MODEL);
textAlign(LEFT);
font = loadFont("Georgia-24.vlw");
textFont(font,5);
camera(0,0,500,0,0,0,0,1,0);
s = new Strip(1500);
}
void draw(){
background(255);
rotateX(PI/180*(targetY-height/2)*0.1);
rotateZ(PI/180*(targetX-width/2)*0.05);
rotateY(PI/180*worldRotY);
stroke(128);
line(0,100,0,0,-100,0);
worldRotY +=2;
if(worldRotY >= 360){
worldRotY = 0;
}
targetX += (mouseX - targetX)/10;
targetY += (mouseY - targetY)/10;
s.update();
s.draw();
}
void keyPressed(){
if(!online){
if(key == ' '){
String outTifName ="strip"+"_"+nf(year(),4)+nf(month(),2)+nf(day(),2)+"_"+nf(hour(),2)+nf(minute(),2)+nf(second(),2)+".tif";
save(outTifName);
}
}
if(key == 'p'){
if(pointIndex){
pointIndex = false;
}else{
pointIndex = true;
}
}
if(key == 'f'){
if(polyFill){
polyFill = false;
}else{
polyFill = true;
}
}
}
class Strip{
int numOfParticles;
ArrayList particles;
Strip(int num){
this.numOfParticles = num;
particles = new ArrayList();
}
void update(){
if(particles.size()