fathominfo / processing-p5js-mode Goto Github PK
View Code? Open in Web Editor NEWA simple editor for p5.js code that runs inside the PDE
A simple editor for p5.js code that runs inside the PDE
moving post from @jeremydouglass processing/p5.js#1600:
I'm using Processing PDE 3.2.1 on OS X 10.10.5.
...resulting in the same version of the sketch reloading in the browser. Hitting the Run button a second time will make things show up properly.
I tried manually moving an example to a different folder by:
I then opened the project in Processing, clicked "Run", and got this:
When I tried running it a second time it eventually worked.
It's properly putting up the "create the folder, move the sketch, and continue?" message but there seems to be something wrong with the renaming.
The tutorials page:
...lists a "Debugging" tutorial ("Field Guide to Debugging for Everyone") -- however it is a dead link:
Or only as manual download and install? I'm in a similar position as you. I need something to teach P5.js with but the official P5.app is not reliable.
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.
Just random number collisions?
Or at least make this an option...
Installing p5.js
mode on Procesing 3.5.4
fails with error, This item needs to be recompiled for Java 8
This is really hokey and needs to be fixed.
In the initial release, the code from the current tab was not properly stored if there were modifications. Fixed for the 1.0.1 release.
cleanTempFiles()
is failing on some Windows machines. Also appears to be locking up the PDE (even though the exception is caught/printed/ignored).
I am failing to create a .json-tab in Processing 3.3 with "p5.js"-mode and get the error '".json" is not a valid extension', but I do not have a problem with loading a .json-file created elsewhere.
Steps to reproduce:
Open Processing
Start Tool/Mode/Library/Example Manager
Press Modes
Press p5js Mode
Press Install
Could not download https://github.com/fathominfo/processing-p5js-mode/releases/download/latest/p5jsMode.zip to /tmp/download3432778025560692869p5jsMode.zip : Error during download and install of p5.js Mode.
This is the error, if I try and download the above link with wget, I get a 404 Error.
Processing 3.5.4-1 install with pacman (Arch Linux)
Seen in class this morning; seems to be a problem with Big Sur and old JNA releases.
Updating to JNA 5.7.0 in the hope that fixes it.
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Unable to load library 'CoreServices': Native library (darwin/libCoreServices.dylib) not found in resource path ([file:/Applications/Processing.app/Contents/Java/, file:/Applications/Processing.app/Contents/Java/ant.jar, file:/Applications/Processing.app/Contents/Java/ant-launcher.jar, file:/Applications/Processing.app/Contents/Java/core.jar, file:/Applications/Processing.app/Contents/Java/jna.jar, file:/Applications/Processing.app/Contents/Java/pde.jar, file:/Applications/Processing.app/Contents/Java/jna-platform.jar])
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:277)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)
at com.sun.jna.Library$Handler.<init>(Library.java:147)
at com.sun.jna.Native.loadLibrary(Native.java:502)
at com.sun.jna.Native.loadLibrary(Native.java:481)
at com.sun.jna.platform.mac.MacFileUtils$FileManager.<clinit>(MacFileUtils.java:35)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
at java.lang.reflect.Field.get(Field.java:393)
at com.sun.jna.Native.loadLibraryInstance(Native.java:527)
at com.sun.jna.Native.getLibraryOptions(Native.java:588)
at com.sun.jna.Native.getStructureAlignment(Native.java:676)
at com.sun.jna.Structure.setAlignType(Structure.java:259)
at com.sun.jna.Structure.<init>(Structure.java:176)
at com.sun.jna.Structure.<init>(Structure.java:172)
at com.sun.jna.Structure.<init>(Structure.java:159)
at com.sun.jna.Structure.<init>(Structure.java:151)
at com.sun.jna.platform.mac.MacFileUtils$FileManager$FSRef.<init>(MacFileUtils.java:46)
at com.sun.jna.platform.mac.MacFileUtils.moveToTrash(MacFileUtils.java:69)
at processing.app.Platform.deleteFile(Platform.java:378)
at processing.mode.p5js.p5jsBuild.cleanTempFiles(p5jsBuild.java:246)
at processing.mode.p5js.p5jsEditor.handleStop(p5jsEditor.java:372)
at processing.mode.p5js.p5jsEditor.internalCloseRunner(p5jsEditor.java:306)
at processing.app.ui.Editor.prepareRun(Editor.java:2809)
at processing.mode.p5js.p5jsEditor.handleRun(p5jsEditor.java:337)
at processing.mode.p5js.p5jsToolbar.handleRun(p5jsToolbar.java:32)
at processing.app.ui.EditorToolbar$1.actionPerformed(EditorToolbar.java:157)
at processing.app.ui.EditorButton.mousePressed(EditorButton.java:190)
at java.awt.Component.processMouseEvent(Component.java:6536)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Seems that the properties file is getting removed (or never written?) somehow, resulting in Cannot invoke "processing.app.SketchCode.isModified()" because "this.current" is null
when opening a sketch: benfry/processing4#719
Seen in class this morning. First thought it was a broken OS install or needed a reboot. Now thinking it might be an i18n/l10n issue.
java.io.IOException: Failed to mail or browse http://127.0.0.1:8473/. Error code: -600
at sun.lwawt.macosx.CDesktopPeer.lsOpen(CDesktopPeer.java:72)
at sun.lwawt.macosx.CDesktopPeer.browse(CDesktopPeer.java:65)
at java.awt.Desktop.browse(Desktop.java:386)
at processing.app.platform.DefaultPlatform.openURL(DefaultPlatform.java:114)
at processing.app.Platform.openURL(Platform.java:149)
at processing.app.ui.EditorStatus$1.mousePressed(EditorStatus.java:109)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)
Probably just need to suppress these, but would like to verify their circumstances.
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.readLine(BufferedReader.java:324)
at java.io.BufferedReader.readLine(BufferedReader.java:389)
at processing.mode.p5js.server.HttpWorker.handleClient(HttpWorker.java:70)
at processing.mode.p5js.server.HttpWorker.run(HttpWorker.java:40)
at java.lang.Thread.run(Thread.java:745)
The current release of p5jsMode doesn't properly handled sketches created with other editors (i.e. most p5.js sketches, which use sketch.js
as their main file).
This will be fixed as soon as possible, but for the time being, code has been added to prevent opening those sketches to avoid any chance of sketches getting destroyed.
Sorry!
I'm running arch linux and a lightweight non-desktop window manager.
When attempting to run a sketch from Processing 3 (0263) in p5.js mode I get the following error:
java.lang.UnsupportedOperationException:
The BROWSE action is not supported on the current platform!
The error suppresses the "Server running at [port]" status message. It appears everything has failed when in fact the server is running and serving your sketch, you're just missing the convenience of a browser automatically opening the sketch at the url it's served at.
I was in the Information Design workshop (which was great) at the recent Processing Community Day and was distracted while trying to figure out what was wrong.
I suspect that wrapping the call to Desktop.getDesktop.browse() in a test for Desktop API support
if(Desktop.isDesktopSupported()){
Desktop.getDesktop().browse(new URI(server.getAddress()));
} else {
... tell user to navigate browser to server's address ...
}
would be enough, as no error would be triggered and you'd see the status message telling you which port to navigate your browser to.
I'm not familiar enough with the build process here to test this myself, though if pointed in the right direction I'd be happy to.
p5js mode seems to be making unsolicited changes to my index.html file. Please see this commit as an example of this behaviour - I'd only intended to change a src attribute, but rather a lot else seems to have been changed on my behalf.
I think part of the problem is that JSoup's "prettyPrint" mode is on by default. It's much like PDE's very nice Edit->Auto Format, menu-item, but mandatory, and every time you save.
However, all that extra vertical whitespace in the <style> tag is possibly because I'm running Windows, which uses carriage-return-line-feed (\r\n) instead of the otherwise universal line-feed (\n)? :-(
In which case, and very tentatively, a fix might look something like this? d303a5a but without in-depth knowledge of the code, all I can say is it works for me.
The “Nashorn” engine that's built into JDK 8 and 11 will soon no longer be available.
The recommendation is to use GraalVM/GraalJS:
…though it's not clear how to do this w/o platform-specific binaries or with minimal impact. This solution is pretty excessive just for parsing/linting the JS code.
Methods for getting rid of the deprecation warning:
When I create a class and run it (without saving) the sketch works fine, but when I save it and try to run the sketch again it throws the follow error on the js file with the class:
SyntaxError: Expected an operand but found class
Hi everyone. I know that p5.js mode for PDE is not a developping tools. But even with this in mind, I think that solving what seems to be a minor bug could provide additionnal motivation to students or people discovering interactive visual programming with web programming using Javascript, HMTL and CSS, To be short, there is apparently a bug in p5.js PDE editor when editing a simpe .css file. See issue reported to
Ben Fry suggested to report this issue here and closed the #5628 issue.
If a fix could be found without too much work, it would be great!
Thanks a lot for great development work. Processing is really a great tool for programming learning!
Laurent
As I was investigating using p5js-mode, I noticed that I could not use let
or const
without obtaining an error after saving the code. For example, this works fine:
function setup() {
createCanvas(1000, 700);
}
function draw() {
var someColor = random(255);
fill(someColor, random(255), random(255), random(255));
rect(random(width), random(height), 30, 30);
}
But if the var
is replaced by let
, like this:
function setup() {
createCanvas(1000, 700);
}
function draw() {
var someColor = random(255);
fill(someColor, random(255), random(255), random(255));
rect(random(width), random(height), 30, 30);
}
then an error of SyntaxError: Expected ; but found someColor
is thrown.
This seems to be the same problem that occurred in #18. As I stated there, I poked around the source of p5js-mode, and I'm wondering if the issue lies in 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?
Oops.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.