Haven't yet figured out how to make an applet work, but here is an image of a cubic bezier curve.The linear and quadratics also work, but I don't have an image, if you want to play with it to make sure, the code is below.
void setup()
{
size (400, 400);
background (0,0,0);
stroke (255);
}
void draw()
{
saveFrame("bezier.jpeg");
}
int count = 0;
int x0=0,x1=0,x2=0,x3=0,y0=0,y1=0,y2=0,y3=0;
void mousePressed()
{
if (count == 0)
{
x0 = mouseX;
y0 = mouseY;
ellipse(x0, y0, 5, 5);
count++;
}
else if (count == 1)
{
x1 = mouseX;
y1 = mouseY;
ellipse(x1, y1, 5, 5);
linearB(x0, y0, x1, y1);
count++;
}
else if (count == 2)
{
x2 = mouseX;
y2 = mouseY;
background(0,0,0);
ellipse(x0, y0, 5, 5);
ellipse(x1, y1, 5, 5);
ellipse(x2, y2, 5, 5);
quadB(x0, y0, x1, y1, x2, y2);
count++;
}
else if (count == 3)
{
x3 = mouseX;
y3 = mouseY;
background(0,0,0);
ellipse(x0, y0, 5, 5);
ellipse(x1, y1, 5, 5);
ellipse(x2, y2, 5, 5);
ellipse(x3, y3, 5, 5);
cubicB(x0, y0, x1, y1, x2, y2, x3, y3);
count++;
}
else if (count >= 4)
{
background(0,0,0);
count = 0;
}
}
void linearB (int x0, int y0, int x1, int y1)
{
for (float t=0; t<1; t+=.001)
{
point ((1-t)*x0 + (t*x1), (1-t)*y0 + (t*y1));
}
}
void quadB (int x0, int y0, int x1, int y1, int x2, int y2)
{
for (float t=0; t<1; t+=.001)
{
point ((sq(1-t)*x0 + 2*(1-t)*t*x1 + sq(t)*x2),
(sq(1-t)*y0 + 2*(1-t)*t*y1 + sq(t)*y2));
}
}
void cubicB (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
{
for (float t=0; t<1; t+=.001)
{
point ((pow((1-t),3)*x0 + 3*sq(1-t)*t*x1 + 3*(1-t)*sq(t)*x2 + pow(t,3)*x3),
(pow((1-t),3)*y0 + 3*sq(1-t)*t*y1 + 3*(1-t)*sq(t)*y2 + pow(t,3)*y3));
}
}
