Skip to content

Instantly share code, notes, and snippets.

@0V
Last active October 18, 2015 08:54
Show Gist options
  • Save 0V/7a87d4e717ad9021f727 to your computer and use it in GitHub Desktop.
Save 0V/7a87d4e717ad9021f727 to your computer and use it in GitHub Desktop.
Processing入門したので対称定規を作ってみた。Processing強力すぎました。協力してくれた @8q に感謝です。
void setup(){
size(640,360);
background(0);
frameRate(60);
stroke(120,100,210);
}
void draw(){
if(mouseButton == LEFT){
int px1 = pmouseX - width / 2;
int py = pmouseY - height / 2;
int px2 = width/2 - pmouseX;
int x1 = mouseX - width / 2;
int y = mouseY - height / 2;
int x2 = width/2 - mouseX;
translate(width/2,height/2);
for(int i = 0;i<6;i++){
rotate(60 * PI / 180);
line(px1,py,x1,y);
line(px2,py,x2,y);
}
}
else if(mouseButton == RIGHT){
clear();
}
}
int count = 0;
void setup(){
size(640,360);
background(0);
frameRate(60);
}
void draw(){
if(mouseButton == LEFT){
int px1 = pmouseX - width / 2;
int py = pmouseY - height / 2;
int px2 = width/2 - pmouseX;
int x1 = mouseX - width / 2;
int y = mouseY - height / 2;
int x2 = width/2 - mouseX;
translate(width/2,height/2);
for(int i = 0;i<6;i++){
rotate(60 * PI / 180);
line(px1,py,x1,y);
line(px2,py,x2,y);
}
count++;
stroke(255 * abs(cos((float)count/200)), 255 * abs(cos((float)count/100)), 255 * abs(sin((float)count/300)));
}
else if(mouseButton == RIGHT){
clear();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment