3

I've got a Processing sketch that I'd like to display on my site with Processing.js rather than as a Java applet, however I'm not sure it supports tabs - or classes. Does it need to be written as procedural script, or is there an <include> I can use - or another option?

Thanks

logic-unit
  • 4,195
  • 12
  • 47
  • 72

2 Answers2

7

You can also include multiple .pde files in the html canvas tag separated by spaces

<canvas data-processing-sources="hello-web.pde class.pde"></canvas>

mentioned near the top of this page: http://processingjs.org/reference/articles/jsQuickStart

Anthony Mattox
  • 7,048
  • 6
  • 43
  • 59
  • 2
    On behalf of [cjlmia](http://stackoverflow.com/users/728077/cjlmia): One caveat: be careful to put the file that contains your setup() and draw() methods as the last item in the list. I have seen inconsistent loading of the sketches when the dependent classes are contained in pde files listed after the pde file that contains your main setup() and draw() methods. – jcsanyi Jun 28 '13 at 04:06
3

I've answered a Processing related question and used classes, but I simply pasted the class after the rest of the program. I don't know if this fully answer your question, but here's an example

Processing sketch preview

Community
  • 1
  • 1
George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • Ah yes! That was quite straightforward. Thanks! Also nice processing work. Not sure if you know that Chrome and Firefox have a little console that pops up at the bottom of the viewport when you use println(). So I can see the creatures: 75, or whatever number being printed. Not sure if you want to comment that out of your work. Thanks again. – logic-unit Jan 09 '11 at 22:10
  • @logic-unit I didn't know it was a Chrome/Firefox thing, I thought it was part of the hascanvas site. I left the println() there because it was part of the answer I gave for a question, I didn't write the program (@Miles did),I just refactored it :) Thanks for the println() tip. – George Profenza Jan 09 '11 at 22:18