toolness / p5.js-widget

A reusable widget for embedding editable p5 sketches in web pages.
https://toolness.github.io/p5.js-widget/
GNU Lesser General Public License v2.1
161 stars 44 forks source link

Add support for implicit setup(). #35

Closed toolness closed 8 years ago

toolness commented 8 years ago

This fixes #31.

Note that it only includes functionality to detect standard idiomatic function declarations (FunctionDeclaration in the parser API) of setup/draw. This means that the following sketch will be unmodified and work as intended:

function setup() { createCanvas(200, 200); }

However, the following will be wrapped in an implicit setup() function, and the user's setup() function will actually never be called:

var setup = function() { createCanvas(200, 200); };

I think this is OK for now, since all the p5 examples out there (and the p5 community in general) do things the idiomatic way. But we should probably file a bug for this limitation just in case. Filed as #36.