Using toxiclibs in processing js

edited December 2014 in JavaScript Mode

Hi there, as title says I'm trying to use toxiclibs in JavaScript mode. I've downloaded the library and copied to "Processing\libraries" folder. It works fine in Java mode but it doesn't in JavaScript. I've copied the example found here but nothing is happening in my browser, and I'm getting the following error:

processing.app.SketchException: Badly formed character constant (expecting quote, got x)
    at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:478)
    at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:515)
    at de.bezier.mode.javascript.JavaScriptBuild.preprocess(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptBuild.build(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptBuild.export(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptMode.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleStartServer(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleSave(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExportCheckModified(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptToolbar.handlePressed(Unknown Source)
    at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:474)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
processing.app.SketchException: Badly formed character constant (expecting quote, got x)
    at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:478)
    at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:515)
    at de.bezier.mode.javascript.JavaScriptBuild.preprocess(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptBuild.build(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptBuild.export(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptMode.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptToolbar.handlePressed(Unknown Source)
    at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:474)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
processing.app.SketchException: Badly formed character constant (expecting quote, got x)
    at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:478)
    at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:515)
    at de.bezier.mode.javascript.JavaScriptBuild.preprocess(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptBuild.build(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptBuild.export(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptMode.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.serverStarted(Unknown Source)
    at de.bezier.mode.javascript.BasicServer.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

any ideas?

Answers

  • edited December 2014

    Unless it's cross-ported to JS Mode too, any Java library is outta reach for JS!
    You should look for JS libs similar to "toxiclibs" instead! :-S

  • I'm reading here that toxiclibs is been ported to Js

  • Interesting. But your description is unclear. Have you installed the Java version or the JavaScript version? You need the latter, of course, to work in PJS.

  • I've installed both and they're both in the same folder. here's where I've downloaded toxiclibs.js from

  • The example you copied is JavaScript code, it won't work in JavaScript mode, it might work with P5.js, though.

  • But is there a way to use toxiclibs in processingjs?

  • Probably, but I am not savvy enough in PJS to tell you how. But I stumbled upon tutorial (probably from the famous Pomax) explaining how to call JS functions from PJS.

  • Solved it. Just needed to manually move toxiclibs.js to the project folder

  • edited December 2014 Answer ✓

    An interesting approach was taken by @fjenett and his GuiDo cross-mode library:
    https://github.com/fjenett/Guido

    He embeds his "Guido.js" file inside the root of "Guido.jar". And it doesn't matter which mode we are, be it Java, JS or CS Mode, the import keyword seeks & finds the correct lib to use! \m/
    It'd be nice if other cross-mode libraries did the same... 8->

  • Thanks, but where do I need to copy the GuiDo library? in Processing/Libraries?

  • edited December 2014 Answer ✓
    • "Guido" lib can be installed like any other library from Sketch -> Import Library... -> Add Library... :)
    • Once Guido is installed, from Java Mode go to File -> Examples or CTRL+SHIFT+O.
    • From there choose "Contributed Libraries", then "Guido".
    • There are many examples there using that library. Choose 1.
    • You'll notice that those transparently work in both Java & JS modes w/o any modifications! :-bd
    • Also they can be ported to CS mode easily as well! :bz
  • You're a star! Thanks a lot!

Sign In or Register to comment.