float x = 10;
float prevMouseX = 0;
float prevMouseY = 0;
PFont F;
int index = 0; // = int(random(words.length))
int timer;
final String[] words = {
"amused",
"joyful, cheerful",
"energized, pumped up",
"annoyed",
"excited",
"anxious, tense", "dreamy",
"creeped out, scared", "disgusted, revolted", "angry", "amazed, fascinated", "calm, realxed", "bored", "sad",
"flirty", "proud, couragous", "romantic, loving", "confrontational, argumentative", "tender, longing",
"triumphant, heroic", "bittersweet, melancholic", "euphoric, ecstatic", "disappointed",
"confused", "remorseful, sorry", "silly, goofy", "jealous", "sympathetic, pitiful"
};
void setup() {
size(500, 500);
background(255);
surface.setTitle("Emotive Drawing");
surface.setResizable(true);
surface.setLocation(100, 100);
F = createFont("GTFAdieuTRIAL-Regular-48.vlw", 40);
timer = millis();
}
void draw(){
if (x<11){ellipser();}
if (x>10){run();}
println(x);
}
void ellipser(){
background(255);
fill(0, 0, 255);
ellipse(mouseX, mouseY, 160,160);
filter(BLUR, 4);
PFont f = createFont("GTFAdieuTRIAL-Regular-48.vlw", 40);
fill(0);
textSize (50);
textFont(f);
String w = "emotive drawing";
text(w, 250, 20);
line(10,60,490,60);
textAlign(LEFT);
textSize (12);
String s = "Can we express emotions without words - only by drawing lines? \nLet's teach a neural network, and find out it can learn to detect emotions in handwriting, drawings or font.";
text(s, 15, 430, 485, 80); // Text wraps within text box
fill(255);
textSize (20);
textAlign(CENTER,CENTER);
String t = "start";
text(t,mouseX,mouseY);
}
void mousePressed(){
x = 15;
background(255);
}
void run(){
fill(255);
rect(0,0,500,60);
rect(0,450,500,50);
fill(0);
textSize (12);
textAlign(LEFT);
String p = "category:";
text(p + words[index] , 15, 13, 60, 40);
String o = "starting with your first line, you have 15 sec. \nto draw - or press enter if you're done!";
text(o, 200, 25); //to do: create text box aligned RIGHT but text in it aligned LEFT
//line(10,60,490,60);
String j = "1/28"; //to do: create variable / counter for categories submitted
text(j, 15, 480);
String k = "00.15";
text(k, 450, 480); //to do: create counter for time left
x =12;
}
void mouseDragged(){
if (x>10){
fill(0);
stroke(0);
float distanceX;
float distanceY;
distanceX = abs(mouseX - prevMouseX);
distanceY = abs(mouseY - prevMouseY);
float avDistance;
avDistance = (distanceX + distanceY)/2;
//set range for strokeWeight: squash 0-200 (input range) into 2-10 (output range)
avDistance = map(avDistance, 0, 150, 1, 50);
//ellipse(mouseX, mouseY, 10, 10);
//ellipse(mouseX, mouseY, avDistance, avDistance);
prevMouseX = mouseX;
prevMouseY = mouseY;
//line(pmouseX,pmouseY,mouseX,mouseY);
//strokeWeight(avDistance);
line(pmouseX, pmouseY, prevMouseX, prevMouseY);}
}
void keyPressed() {
if (index>=words.length) {
return; // LEAVE
}
SaveAndPrepareNextWord();
}
void SaveAndPrepareNextWord() {
// remove text !!!!!!!
fill(250);
noStroke();
rect( 0, 0, width, 60);
// save now !!!!!
String newName="drawings\\"
+words[index]
+ ".png";
if (fileExists(sketchPath("")+""+newName)) {
//!!problem
int i=0;
while (fileExists(sketchPath("")+""+newName)) {
newName="drawings\\"
+words[index]
+trim(str(i))
+ ".png";
i++;
}
save(newName);
} else {
save(newName);
}
// prepare next word !!!!
index++;
background(250);
textSize (40);
textFont(F);
fill(0);
stroke(0);
timer=millis();
}
boolean fileExists(String fileName) {
File file=new File(fileName);
boolean exists = file.exists();
if (!exists) {
println(fileName);
return false;
} else {
return true;
}
}
Update - I tried to implement my GUI layout, and realized I have no clue what I am doing haha. But I’ve come this far. The images are still saved in the wrong folder though, also the font I picked stopped working, so I think I have to look into folder structure again?