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

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

On behalf of 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.
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

2 Comments

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 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.