Charlie Middleton
Charlie Middleton

Reputation: 63

Processing code works locally but not in javascript

I need to upload my processing sketch to my website in order for it to be assessed as part for my mark. But the code doesn't work when I use it online.

It can be found at: http://sketchpad.cc/16tzxgxy6w (not working) but if you copy that code to Processing and run it, works perfectly.

this is the main bit if anyone can recosnise an issue - basically drawing a random shape w/ points based on simple math.

for(int i = 0; i < points; i++)
  {
     stroke(strokeCol); 
     fill(backgroundCol); 
     float startX = sin(radians(startDot * dotDegree)) * radius;
     float startY = cos(radians(startDot * dotDegree)) * radius;

     float endX = sin(radians(endDot * dotDegree)) * radius;
     float endY = cos(radians(endDot * dotDegree)) * radius;


     line(startX, startY, endX, endY);
     ellipse(startX, startY, eSize, eSize);

     startDot = endDot;
     endDot = int(random(points));

  }       

Thank a lot for any suggestions.

Upvotes: 0

Views: 48

Answers (1)

Lex Lustor
Lex Lustor

Reputation: 1615

Basically, in the Sketchpad provided, you override the Processing stroke function with a variable, storing a number in it (that's why you got the error James Thorpe commented on).

I changed a bit your Sketchpad, changing this lines

int strokeValue = 7; // instead of stroke
int eSize = strokeValue*3;

and later

strokeWeight(strokeValue);

Then, stroke is still a function when you use it in the script and it finally renders something.

I'm sorry I don't know how to 'fork' a Sketchpad...

Upvotes: 1

Related Questions