"Rainbow" line; Running through colors

I recently created a double pendulum and wanted to make the tracing line run through all the colors, I looked around and couldn’t find anything that did what I wanted so I made my own.

float h = 0;
float x = 0;

void setup(){
  size(500, 500);
  colorMode(HSB, 360, 360, 360);

void draw(){
  if (h > 360){
    h = 0;
  h += 2;
  stroke(h, 360, 360);
  point(x, height/2);
  x += 1;

This is what I came up with, hope this helps anyone looking for a similar thing.

Archie Wright.


Could you format your code with the </> button please, and make sure it is properly indented by pressing ctrl + T in the processing editor?

Done, thanks for the heads up.