Código:
void setup() {
size(600, 600);
}
void draw() {
int r = 100;
int x = mouseX;
int y = mouseY;
background(0);
fill(255);
ellipse(width/2, height/2, 3*r, 3*r);
fill(0);
if (mouseX < 140) {
x = 140;
}
if (mouseX > 260) {
x = 260;
}
if (mouseY < 140) {
y = 140;
}
if (mouseY > 260) {
y = 260;
}
float cat_Oposto = height/2-mouseY;
float cat_Adjacente = width/2 - mouseX;
float passe_Hipotenusa = sq(cat_Oposto)+sq(cat_Adjacente);
float hipotenusa = sqrt(passe_Hipotenusa);
println(hipotenusa, mouseX, mouseY);
float SENO = (mouseY - height/2)/ hipotenusa;
float COSSENO = (mouseX - width/2)/ hipotenusa;
float distanciaY =(mouseY - height/2)*SENO;
float distanciaX =(mouseX - width/2)*COSSENO;
float distanciaX1 = COSSENO*r ;
float distanciaY1 = SENO*r ;
float distanciaD = hipotenusa - 100;
float AREA = 2*PI*sq(r);
float calculoX = distanciaX1+width/2;
float calculoY = distanciaY1+height/2;
if (hipotenusa < 100) {
calculoX = mouseX;
calculoY = mouseY;
}
ellipse(calculoX, calculoY, 80, 80);
}
Resultado:
Nenhum comentário:
Postar um comentário