Object follows mouse :: Processing
Object follows mouse :: Processing
Out of context: Reply #2
- Started
- Last post
- 9 Responses
- acescence0
the math to constrain it to a circle is beyond me, but if you take out the check if d1<30 it sort of works
void setup() {
size(400, 400);
smooth();
}void draw() {
background(27);
noStroke();
eye(200, 200, 50, 50);
}void eye( float posX, float posY, int x, int y) {
float d1 = dist(posX, posY, 15, 15);
float mx = constrain(mouseX, posX - 15, posX + 15);
float my = constrain(mouseY, posY - 15, posY + 15);
fill(13);
ellipse(posX, posY, x * 2, y * 2);
fill(255);
ellipse(posX, posY, x * 2 - 10, y * 2 - 10);strokeWeight(2);
stroke(0, 255, 255);
fill(20, 200, 175);
ellipse(mx, my, x, y);
fill(0);
stroke(10, 100, 205);
ellipse(mx, my, x/2, y/2);
fill(255, 90);
noStroke();
ellipse(mx - (x/4), my - (y/4), x/3, y/3);}