Created
December 22, 2017 05:20
-
-
Save ulrichzwingli/2d25996b88698c1ab082f1c2ce5a0dbf to your computer and use it in GitHub Desktop.
FYF processing 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
PImage shadow; | |
PImage user; | |
PImage shoe; | |
PVector a = new PVector(150, 0); | |
PVector b = new PVector(0, 150); | |
float angle; | |
PVector v1; | |
PVector v2; | |
float q; | |
float len; | |
float root; | |
void setup() { | |
// size(600, 400); | |
fullScreen(); | |
shadow = loadImage("shadow.png"); | |
user = loadImage("user.png"); | |
shoe = loadImage("shoe.png"); | |
} | |
void draw() { | |
background(0); | |
pushMatrix(); | |
translate(width/2, height/2); | |
fill(0); | |
//line(0, 0, a.x, a.y); | |
//line(0, 0, b.x, b.y); | |
b.set(mouseX-width/2, mouseY-height/2, 0); | |
angle = angle(a, b); | |
text(int(degrees(angle)), 0, 0); | |
q = degrees(angle); | |
println(int(q)); | |
//text(int(q), 50, 50); | |
rotate(radians(q+90)); | |
len = sq(mouseX-width/2) + sq(mouseY-height/2); | |
root = sqrt(len); | |
//println(root); | |
image(shadow, -22, 0, 50, root); | |
image(shoe, -20, -15, 50, 50); | |
popMatrix(); | |
pushMatrix(); | |
translate(width/2, height/2); | |
//rotate(-radians(q)); | |
image(user, (mouseX- width/2)-50, (mouseY-height/2)-50, 100, 100); | |
popMatrix(); | |
} | |
float angle(PVector v1, PVector v2) { | |
float 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