Code: Continuous bezier joins

For two joined bezier curves to be continuous (i.e. no corners or abrupt slope changes), the control points on each side of the joining point must be colinear. This behavior is default in vector editing programs like Adobe Illustrator.

An example in Processing:

void setup() {
  size(400,400);
}
 
void draw() {
  background(200);
  noFill();
 
  float xD=width/2-mouseX;
  float yD=height/2-mouseY;  

  bezier(0,0,
    300,100,
    width/2-xD,height/2-yD,
    width/2,height/2);
 
  bezier(width/2,height/2,
    width/2+xD,height/2+yD,
    400,300,
    400,400);
}