Skip to content

#448 a first quick proof-of-concept implementation of static mode support #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

francisli
Copy link
Contributor

I, too, am interested in having the equivalent of Processing's "static mode" for a workshop geared towards elementary school students. Although it seems like a minor and limited feature, I've always felt that it was a keen insight of the original Processing- to completely remove any distractions from the first interaction, giving students that blank slate/sheet of paper to draw upon incrementally.

This is obviously a somewhat frail implementation of it, but it does work, and it would probably work in the majority of workshop/classroom settings. If you rename the initial js file from sketch.js to something else it will break (of course, it will break your project regardless unless you know how to also modify the html file script reference). Having multiple files can also break, depending on how they are used (this is why the original Processing PDE concatenates the content from all of its .pde file "tabs" into a single source file before pre-processing).

So, I think by the time you're ready to let students open up the side tab, and start manipulating the project files, you've probably gotten far enough that they've learned function declarations and started using setup() and draw()...

@francisli francisli mentioned this pull request Dec 4, 2017
@francisli
Copy link
Contributor Author

@catarak per the comments in #448 this is PR is now up to date with the latest from master, and is enabled only with an environment variable switch...

@catarak
Copy link
Member

catarak commented Nov 12, 2018

thanks for updating this! sorry for the extremely long delay in looking at this. i'm going to put some of my thoughts on the issue itself.

@catarak
Copy link
Member

catarak commented Nov 29, 2018

@francisli i really appreciate your work and thoughts about this. i'm hesitantly okay with the idea of enabling static mode via an environment variable. i'm not sure it's a good software development practice to enable features of a web app via environment variable, but it also seems like the side-effects would be small.

however, i don't think it's a good idea to enable static mode implicitly like this—could you instead add <script>new p5();</script> to the index.html with static mode enabled?

@francisli
Copy link
Contributor Author

@catarak hi Cassie, I'm trying to address your latest feedback, but I'm not exactly sure what you're asking. I've been experimenting, but even if I add the script tag you specify to the index.html, I'd still need to wrap the code in a setup() function for it to work. At which point adding an the script with an explicit new p5() is redundant, since the library will already do this when it observes a window.setup function has been defined...?

@catarak
Copy link
Member

catarak commented Dec 11, 2018

@francisli i mean doing something like this: https://editor.p5js.org/cassie/sketches/rk4L89ay4

in this case, i'm able to call p5 functions outside of setup.

@francisli
Copy link
Contributor Author

@catarak as I tried to explain, I've been doing some experimentation, and although simple utility functions like random will work outside of setup with this approach, functions that draw to the screen will not. This is probably because p5js is waiting for the DOM ready event before initializing its reference to the canvas object- which means drawing code must be in setup() so that they can be called after everything is ready...

If you're uncomfortable with these changes, I'd recommend just rejecting this PR and closing it- I'll just maintain it in my fork!

@catarak
Copy link
Member

catarak commented Dec 11, 2018

ahhh okay, got it! that's unfortunate. since there doesn't seem to be a way to make this work, except by secretly wrapping everything in a setup function, i don't think it makes sense to merge this.

@catarak catarak closed this Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants