> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://dflab.sketchpad.cc/sp/pad/view/ro.l3ZhAnb8R4A/rev.252
 * 
 * authors: 
 *   Tania Ferrão

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



/* @pjs preload="/static/uploaded_resources/p.10107/4.jpg"; */
/* @pjs preload="/static/uploaded_resources/p.10107/bicho1.jpg"; */

 
float theta;   
float x;
float y;
float easing = 0.1;

PImage im2;
PImage bicho1;

void setup() {
  size(500, 500);
  noStroke();  
  im2 = loadImage("/static/uploaded_resources/p.10107/4.jpg");
  bicho1 = loadImage("/static/uploaded_resources/p.10107/bicho1.jpg");
  
  
}
 
 
void draw() {
  background();
  image(im2,0,0);
  frameRate(30);
  stroke(0);
  float a = (mouseX / (float) width) * 25f;
  theta = radians(a);
  translate(width/2,height);
  line(0,0,0,-120);
  translate(-0,-120);
  branch(120);
  
      
float targetX = mouseX;
  float dx = targetX - x;
  if(abs(dx) > 0.1) {
    x += dx  * easing;
  }
  
  float targetY = mouseY;
  float dy = targetY - y;
  if(abs(dy) > 0.1) {
    y += dy  * easing;
  }
  image(bicho1, x - 290,y - 400);
  
fill(0,0,0);
triangle ( 0, 120, 100, 120, 0,40);
triangle ( 0, 120, -100, 120, 0,40);
noStroke ();
 
}
 
void branch(float h) {
  h *= 0.66;
  
    if (h > 8) {
        pushMatrix();    
        rotate(theta);   
        line(0, 0, 0, -h);  
        translate(0, -h); 
        branch(h);      
        popMatrix();     
    
 
        pushMatrix();
        rotate(-theta);
        line(0, 0, 0, -h);
        translate(0, -h);
    branch(h);
    popMatrix();
    
    }
}