Arashjot Kaur
Arashjot Kaur

Reputation: 51

Something is wrong with my code in processing

I used codepen to write my code in and then I took it into processing and now there are many errors. it was alright in codepen but something happened in processing. This is my first time using processing so the language reference is a bit different. Could someone gear me in the right direction?

void draw() {
  // Call the variableEllipse() method and send it the
  // parameters for the current mouse position
  // and the previous mouse position
  ellipse(mouseX, mouseY, pmouseX, pmouseY);
  }

  // The simple method variableEllipse() was created specifically
  // for this program. It calculates the speed of the mouse
  // and draws a small ellipse if the mouse is moving slowly
  // and draws a large ellipse if the mouse is moving quickly

 void ellipse(x, y, px, py) {
 let speed = abs(x - px) + abs(y - py);
 stroke(speed);
  ellipse(x, y, speed, speed);
 }
  //https://p5js.org/examples/drawing-patterns.html

 void setup() {
  size(500, 500);
  background(50);

 let num = 20;
 let spanx = width / num;
 let spany = height / num;

 for (let i = 1; i < num; i++) {
for (let j = 1; j < num; j++) {
  stroke(255, 255, 255);
  if (random(1) < 0.8) {
    line(width / 2, height/2, i * spanx, j * spany);
    frameRate(35);
  }

  stroke(255, 0, 0);
  if (random(1) < 0.3) {
    line(width / 1, height, i * spanx, j * spany);
  }
  //red line
  stroke(0, 0, 255);
  if (random(1) < 0.5) {
    line(6, height, i * spanx, j * spany);
    //line(1, height / 2, i * spanx, j * spany);
  }
  stroke(0, 128, 0);
  strokeWeight(1);
  if (random(1) < 0.5) {
    line(7, 3, i * spanx, j * spany);
  }
  stroke(255, 255, 0);
  if (random(1) < 0.9) {
    line(width, 9, i * spanx, i * spany);
    //line(width / 2, height, i * spanx, i * spany);
    //line(width, height / 2, i * spanx, i * spany);
    //line(width / 2, 1, i * spanx, i * spany);
  }
  }
  }
  }

Upvotes: 0

Views: 77

Answers (1)

Cadin
Cadin

Reputation: 4649

On CodePen you would have been using a JavaScript flavor of Processing (probably p5.js). The desktop editor defaults to Java.

Your code looks like a mix of the two.

You can add a mode for p5.js to the desktop editor if you want to continue working in JavaScript. Otherwise, you'll need to finish converting the rest of your syntax to Java.

Upvotes: 1

Related Questions