Skip to content

Instantly share code, notes, and snippets.

@EnsekiTT
Created June 27, 2013 07:24
Show Gist options
  • Select an option

  • Save EnsekiTT/5874587 to your computer and use it in GitHub Desktop.

Select an option

Save EnsekiTT/5874587 to your computer and use it in GitHub Desktop.
クリックした場所の座標とその時のクラス(テンキーで入力)をdata.csv保存する。 座標点は0-640,0-480というかなり雑な状態。 Processing2.0b9で作った
/***
Plot to Data (EnsekiTT)
x: exit
mouse_click + 0~9: plot + class(1~9)
output: data.csv
***/
int temp_key;
PrintWriter writer;
void setup() {
size(640, 480);
background(0);
writer = createWriter("data.csv");
}
void draw() {
}
void keyPressed(){
if(key == 'x'){
writer.close();
exit();
}
}
void mousePressed() {
if ((keyPressed == true) && ('9' >= key) && (key >= '0')) {
temp_key = int(key)-48;
}else{
temp_key = 0;
}
/** Log **/
writer.println(mouseX + "," + mouseY + "," + temp_key);
writer.flush();
/** Plot **/
colorMode(HSB,256);
stroke(temp_key*20,200,200);
strokeWeight(2);
noFill();
switch(temp_key % 3){
case 0:
ellipse(mouseX, mouseY, 6, 6);
break;
case 1:
rect(mouseX, mouseY, 6, 6);
break;
case 2:
triangle(mouseX - 3, mouseY - 3, mouseX + 3, mouseY - 3, mouseX, mouseY + 3);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment