> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.SlRZXaQZMpR/rev.121
 * 
 * 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, "autistic-emotions.ipadFit", created by Anna Nawrocka
// http://studio.sketchpad.cc/sp/pad/view/ro.9PXuZYfxmmIL9/rev.554



// This sketch builds on a prior work, "tryout math.random()", created by Anna Nawrocka
// http://studio.sketchpad.cc/sp/pad/view/ro.9lyEvPAiv-aMk/rev.119



// 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/refresh1.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","ANGRY","PLAYFUL","CALM","CONFIDENT","FRUSTRATED",
"PEACEFUL","JOYOUS","ENERGETIC","EASY","COMFORTABLE","AMAZED","IMPULSIVE","INTERESTED","FREE","SURPRISED","QUIET","ECSTATIC","THRILLED","RELAXED","ANXIOUS","INSPIRED","ANGRY","DEPRESSED","CONFUSED","HELPLESS","UPSET","ANNOYED","BITTER","GUILTY","MISERABLE","LOST","TENSE","INDIFFERENT","BORED","AFRAID","WORRIED","NERVOUS","ALIENATED","HURT"};
    String word = (wordList[Math.floor(Math.random() * wordList.length)]);


float radius = 55.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(768,1024);
  smooth();
  value = 0;
  strokeJoin(ROUND);
  background(234, 255, 255);
  //f = loadFont("FFScala.ttf");
  f1 = createFont("Optima",25,true);
  f2 = createFont("Helvetica",40,true);
  frameRate( 15 );
  X = 90;
  Y = 90;
  nX = X;
  nY = Y;  
  //PImage img = loadImage("/static/uploaded_resources/p.16863/refresh.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/refresh1.png");
  image(img,66,66);
  
  textFont(f1);
  fill(0);
  textAlign(RIGHT);

  text("PLEASE DRAW: ",width/2-20,100);
  textFont(f2);
  fill(0);
  textAlign(RIGHT);
  //text("FRUSTRATED",width-60,95);
  //String word = (wordList[Math.floor(Math.random() * wordList.length)]);
  text(word,width-80,100);

  
  
  stroke(148,189,209);
  fill (148,189,209);
  rect(0,874,768,150);
  stroke(B1);
  fill(B1);
  rect(184,904,80,80); //black button
  stroke(B2);
  fill(B2);
  rect(264,904,80,80); //white button
  stroke(B3);
  fill(B3);
  rect(344,904,80,80); //red button
  stroke(B4);
  fill(B4);
  rect(424,904,80,80); //orange button
  stroke(B5);
  fill(B5);
  rect(504,904,80,80); //yellow button
  
  
 if(mousePressed) {
   if(mouseY > 65 && mouseY < 115 && mouseX > 65 && mouseX < 115) {
     //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 > 904 && mouseY < 984) {
      if(mouseX > 184 && mouseX < 264){
        penColor = B1;
        thick = 2;
      }
      else if(mouseX > 264 && mouseX < 344) {
        penColor = B2;
        thick = 2; 
      }
      else if(mouseX > 344 &&  mouseX < 424){
        penColor = B3;
        thick = 2;
      }
      else if(mouseX > 424 &&  mouseX < 504){
        penColor = B4;
        thick = 2;
      }
      else if(mouseX > 504 &&  mouseX < 584){
        penColor = B5;
        thick = 2;
      }
      
    }
    
     //if (mouseY > 120 && mouseY < 800) {    
    //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++){
        if (mouseY > 120 && mouseY < 800) {
        mx = append(mx,lerp(pmouseX,mouseX,j/db));
        my = append(my,lerp(pmouseY,mouseY,j/db));
    }
    }
            if (mouseY > 120 && mouseY < 800) {
            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) {
                    if (mouseY > 120 && mouseY < 800) {
                    continue;
                    }
                } else {
                    if (mouseY > 120 && mouseY < 800) {
                    stroke(penColor,dg/20);
                    //stroke(penColor);
                    line(mx[mx.length-k], my[my.length-k], mx[i], my[i]);
                   //image(colorchooser,0,0) 
                   }
                }
                }
            }
                            //println(lerp(pmouseX,mouseX,k/db));
                 
            }

    //}
  }
  oldX = mouseX;
  oldY = mouseY;  
}