Kod:
float beginX = 20.0; // başlangıç x-koordinatı
float beginY = 10.0; // başlangıç y-koordinatı
float endX = 570.0; //son x-coordinate
float endY = 320.0; // son y-coordinate
float distX; // X-ekseninde hareket ediyor
float distY; // Y-ekseninde hareket ediyor
float exponent = 4; // eğriyi tanımlıyoruz
float x = 0.0; // x koordinatının başlangıcı
float y = 0.0; // y-kooridnatının başlangıç değeri
float step = 0.01; // uzunluk değerimiz
float pct = 0.0; // yüzdelik değeri
**** setup()
{
size(640, 360);//genişliğini belirliyoruz
noStroke();
smooth();
distX = endX - beginX;
distY = endY - beginY;
}
//asıl eğrimizi çizen fonksiyon
**** draw()
{
fill(0, 2);
rect(0, 0, width, height);
pct += step;
if (pct < 1.0) {
x = beginX + (pct * distX);
y = beginY + (pow(pct, exponent) * distY);
}
fill(255);
ellipse(x, y, 20, 20);
}
//mouse'a dokunduğumuzda yönünü değiştiren fonksiyon
**** mousePressed() {
pct = 0.0;
beginX = x;
beginY = y;
endX = mou***;
endY = mouseY;
distX = endX - beginX;
distY = endY - beginY;
}