Created
December 22, 2017 05:20
-
-
Save ulrichzwingli/fede6ee637a128c67089331957f8de5c to your computer and use it in GitHub Desktop.
FYF P5 sketch for portfolio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shadow; | |
var user; | |
var shoe; | |
var a1; | |
var b1; | |
var angle; | |
var v1; | |
var v2; | |
var q; | |
var len; | |
var root; | |
function setup() { | |
createCanvas(windowWidth,windowHeight); | |
a1 = createVector(150, 0); | |
b1 = createVector(0, 150); | |
//fullScreen(); | |
shadow = loadImage("http://res.cloudinary.com/abhinav21/image/upload/v1513914508/shadow_qbw9tf.png"); | |
user = loadImage("http://res.cloudinary.com/abhinav21/image/upload/v1513914646/user_rlfoxr.png"); | |
shoe = loadImage("http://res.cloudinary.com/abhinav21/image/upload/v1513914641/shoe_bkvlvw.png"); | |
angleMode(DEGREES); | |
} | |
function draw() { | |
background(0); | |
push(); | |
translate(width/2, height/2); | |
fill(0); | |
//line(0, 0, a.x, a.y); | |
//line(0, 0, b.x, b.y); | |
b1.set(mouseX-width/2, mouseY-height/2, 0); | |
var angle1 = angle(a1, b1); | |
//text(var(degrees(angle)), 0, 0); | |
//q = degrees(angle1); | |
//prvarln(var(q)); | |
//text(var(q), 50, 50); | |
rotate((angle1+90)); | |
len = sq(mouseX-width/2) + sq(mouseY-height/2); | |
root = sqrt(len); | |
//prvarln(root); | |
image(shadow, -22, 0, 50, root); | |
image(shoe, -20, -15, 50, 50); | |
pop(); | |
push(); | |
translate(width/2, height/2); | |
//rotate(angle1); | |
image(user, (mouseX- width/2)-50, (mouseY-height/2)-50, 100, 100); | |
pop(); | |
} | |
function angle(v1, v2) { | |
var a = atan2(v2.y, v2.x) - atan2(v1.y, v1.x); | |
if (a < 0) a += TWO_PI; | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment