So I am new to HTML and Javscript, and I 'm trying to setup p5.js in VSC. I’ve installed the p5 snippets extension and my index.html file looks like this:
I’ve created a basic sketch.js file that looks like this:
function setup () {
createCanvas(400, 600);
background(0);
}
function draw () {
}
The problem is that it says that createCanvas is not defined, which means that the library doesn’t load. However, the 3 p5 file paths are correct (Ctrl + click opens the correct file). I’m not sure why this is happening… Any help would be appreciated!
I seem to be having a similar problem but with SublimeText 3. I am using Browser sync to test the code in the browser, the main.js script is appearing in the insepctor and I can open the code however its not displaying in my index.html test window.
Thanks so much!
Seems to work now so maybe i’ll ditch Sublime Text and Opera, would you say firefox and notepad++ is an optimal workflow for developing graphical applications or could you give some advice on workflow too?
Notepad++ and other similar frugal text editors are more geared towards small projects like Processing sketches and quick file edits.
IDEs like Sublime, Atom, Brackets, Eclipse, etc., are more appropriate for bigger projects.
Firefox and its derivatives browsers can run “.js” code directly under the file:// scheme.
Chromium-based browsers can do it too, though w/ some limitations, if we run it w/ a modified shortcut w/ an “–allow-file-access-from-files” argument: Chrome-allow-file-access-from-file.com/