Using sin() function

cosine is just the sin() function shifted by 90° or PI/2.

float ofSet = 0.05;
void setup() {
  size(600,400);
}

void draw() {
  background(0);
  fill(255,0,0);
  text("Cosine",40,50);
  fill(0,0,255);
  text("Sine",20,350);
  for(int i = 0; i < width; i++) {
    stroke(255,0,0);
    point(i,cos(i*ofSet)*100+height/2);
    line(i,cos(i*ofSet)*100+height/2,i+1,cos( (i+1)*ofSet)*100+height/2);
    
    stroke(0,0,255);
    point(i,sin(i*ofSet)*100+height/2);
    line(i,sin(i*ofSet)*100+height/2,i+1,sin( (i+1)*ofSet)*100+height/2);
  }
}

image