0

You can use variables and functions that are directly or indirectly accessible from the global scope, from within a processing.js sketch. Is there a way to give it a different object as the global scope to look stuff up in?

3
  • Are these functions already in memory when you want to change their scope? If they are, you would have to re-declare them with the scope you wanted, or if just changing this is enough, invoke with call or apply. Commented Jun 28, 2013 at 0:21
  • Well, that depends on the answer. Processing.js translates code from a language called Processing into javascript, but because the execution happens in a javascript environment, the Processing program has access to anything accessible from the global javascript scope. However, I was wondering wether there's a setting in processing.js to modify the javascript output, so it looks up variables in a different scope. Commented Jun 28, 2013 at 0:23
  • You can't whitelist but you can blacklist with the much hated with, if their code gets declared/defined within it's code block. Commented Jun 28, 2013 at 0:25

1 Answer 1

1

You're not being very specific so I'm just going to point you to the article that explains this on processingjs.org: http://processingjs.org/articles/PomaxGuide.html#interface

That explains how to make your sketch use JavaScript functions (don't access raw variables), and how to make JavaScript call your sketch functions (again, don't access raw variables, write a getter function and call that).

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

1 Comment

What I was looking for, was how to limit the javascript functions a sketch can call, but I already found a different solution to my problem. Thank you for your help.

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.