/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.6UDGGJktKIe/rev.119
*
* authors:
* Anna Nawrocka
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "Modified clone of 'bestworkingfornow'", created by Anna Nawrocka
// http://studio.sketchpad.cc/sp/pad/view/ro.9IQRz37Q8QgYq/rev.417
// This sketch builds on a prior work, "bestworkingfornow", created by Anna Nawrocka
// http://studio.sketchpad.cc/sp/pad/view/ro.9ZHPlW-WY3KqR/rev.49
// This sketch builds on a prior work, "Untitled Sketch", created by Anna Nawrocka
// http://studio.sketchpad.cc/sp/pad/view/ro.9$M4yGos9qBUw/rev.97
/* @pjs preload="/static/uploaded_resources/p.16863/refresh2.png"; */
/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/26573*@* */
/* !do not delete the line above, required for linking your tweak if you upload again */
import java.util.Random;
color B1 = color(0,0,27);//black
color B2 = color(38,50,72);//white
color B3 = color(126,138,162);//red
color B4 = color(255,255,255);//orange
color B5 = color(255,152,0);//yellow
color penColor = color(0,0,0);
float oldX, oldY;
int thick = 1;
PFont f1;
PFont f2;
String[] wordList = {"OPEN","HAPPY","ALIVE","SAD","UNDERSTANDING","ANGRY","PLAYFUL","CALM","CONFIDENT","FRUSTRATED","PEACEFUL"};
String word = (wordList[Math.floor(Math.random() * wordList.length)]);
float radius = 40.0;
int X, Y;
int nX, nY;
int delay = 16;
int count;
int num = 60;
float[] mx = new float[0];
float[] my = new float[0];
int value;
void setup(){
size(550,700);
smooth();
value = 0;
strokeJoin(ROUND);
background(234, 255, 255);
//f = loadFont("FFScala.ttf");
f1 = createFont("Optima",20,true);
f2 = createFont("Helvetica",30,true);
frameRate( 15 );
X = 50;
Y = 50;
nX = X;
nY = Y;
//PImage img = loadImage("/static/uploaded_resources/p.16863/refresh2.png");
//image(img,50,50);
}
void draw(){
radius = radius + sin( frameCount / 16 );
// Track circle to new destination
X+=(nX-X)/delay;
Y+=(nY-Y)/delay;
// Set fill-color
fill(38,50,72);
// Set stroke-color
stroke(148,189,209);
strokeWeight(1);
// Draw circle
ellipse( X, Y, radius, radius );
// Draw refresh icon
//image(img,100,100);
PImage img = loadImage("/static/uploaded_resources/p.16863/refresh2.png");
image(img,34,34);
textFont(f1);
fill(0);
textAlign(RIGHT);
text("PLEASE DRAW: ",width/2-10,60);
textFont(f2);
fill(0);
textAlign(RIGHT);
//text("FRUSTRATED",width-40,60);
//String word = (wordList[Math.floor(Math.random() * wordList.length)]);
text(word,width-40,60);
stroke(148,189,209);
fill (148,189,209);
rect(0,590,550,110);
stroke(B1);
fill(B1);
rect(125,610,60,60); //black button
stroke(B2);
fill(B2);
rect(185,610,60,60); //white button
stroke(B3);
fill(B3);
rect(245,610,60,60); //red button
stroke(B4);
fill(B4);
rect(305,610,60,60); //orange button
stroke(B5);
fill(B5);
rect(365,610,60,60); //yellow button
if(mousePressed) {
if(mouseY > 10 && mouseY < 60 && mouseX > 10 && mouseX < 60) {
//noStroke();
//fill(191,190,189);
// rect(0,70,550,530);
//background(191, 190, 189);
//textFont(f2);
//fill(0);
//textAlign(RIGHT);
// int idx = new Random().nextInt(wordList.length);
// String word = (wordList[idx]);
// String word = (wordList[]);
//text(word,width-20,40);
window.location.reload();
}
}
if(mousePressed) {
if(mouseY > 620 && mouseY < 680) {
if(mouseX > 125 && mouseX < 185){
penColor = B1;
thick = 2;
}
else if(mouseX > 185 && mouseX < 245) {
penColor = B2;
thick = 2;
}
else if(mouseX > 245 && mouseX < 305){
penColor = B3;
thick = 2;
}
else if(mouseX > 305 && mouseX < 365){
penColor = B4;
thick = 2;
}
else if(mouseX > 365 && mouseX < 425){
penColor = B5;
thick = 2;
}
}
//stroke(penColor);
//strokeWeight(thick);
//line(oldX, oldY, mouseX, mouseY);
float dy, dx,db;
db = dist(pmouseX,pmouseY,mouseX,mouseY);
for (int j = 0;j<=db;j++){
mx = append(mx,lerp(pmouseX,mouseX,j/db));
my = append(my,lerp(pmouseY,mouseY,j/db));
}
mx = append(mx,mouseX);
my = append(my,mouseY);
//println(mx+"|"+my+" | "+mx.length+"|"+count);
//println(my);
for (int k = 0;k<=db;k++)
{
for (int i = mx.length-1; i >= 0; i--) {
float dg = dist(mx[mx.length-k], my[mx.length-k], mx[i], my[i]);
//println(mx[mx.length-1]);
if (dg > 50 || dg < 20) {
continue;
} else {
stroke(penColor, dg/20);
//stroke(penColor);
line(mx[mx.length-k], my[mx.length-k], mx[i], my[i]);
//image(colorchooser,0,0)
}
}
//println(lerp(pmouseX,mouseX,k/db));
}
}
oldX = mouseX;
oldY = mouseY;
}