Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p5.js sketch breaks when I save it #18

Closed
chris-relaxing opened this issue Dec 21, 2017 · 3 comments
Closed

p5.js sketch breaks when I save it #18

chris-relaxing opened this issue Dec 21, 2017 · 3 comments

Comments

@chris-relaxing
Copy link

chris-relaxing commented Dec 21, 2017

If I start up a new sketch in p5.js mode and paste in this code, it works fine. I click run and it shows the output in my browser window with no errors (correctly showing a square spinning on the Y axis)

let angle = 0;

function setup() {
createCanvas(400, 300, WEBGL);
}

function draw() {
background(175);
rectMode(CENTER);
//noStroke();
//fill(0, 0, 255);
//rotateZ(angle);
rotateY(angle);
rect(0, 0, 150, 150);
angle += 0.03;

}

However, if I then save this file, it no longer works when I try to run it. I get an error message:
SyntaxError: Expected ; but found angle
And this generally highlights the first line in the code.

I am using Processing IDE 3.3.6. Windows 10. Firefox for output.

Processing environment.
image

p5.js mode:
image

error message:
image

index.html:
image

@schellenberg
Copy link

I was able to replicate this error, as well as find a partial solution. I was guessing the error was occurring due to some kind of syntax checking that p5js-mode was using. On a hunch, I changed the let to var, saved the file again, and it executed just fine.

Poking around the source of p5js-mode, I'm wondering if it is the public HtmlTokenMarker(boolean js) function in the HTMLTokenMarker.java file. I can see var in there, but the more recent let and const ES6 style variable declarations are not. Perhaps it is as simple as adding those?

@benfry
Copy link
Contributor

benfry commented Jan 28, 2019

Should be fixed for the next release (1.1) along with #20.

@benfry benfry closed this as completed Jan 28, 2019
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants