Skip to content
GiorginoSerbuciano edited this page Nov 29, 2021 · 4 revisions

Dealing with cross-origin errros

If you get an error like this, p5.js says: It looks like there was a problem loading your JSON file... Uncaught TypeError: Failed to fetch, you are dealing with a cross-origin error. It is likely that you are running the sketch from file rather than through a local server. You can check if this is the case in your current debug session: If the address looks something like file:///home/giorginoserbuciano/p5aiui/index.html, then you'll need to set up a local server. Follow these instructions; once you're done, your address should read something like http://localhost:5500/:

https://github.com/processing/p5.js/wiki/Local-server#vs-code-live-server

This file contains the VS Code launch configuration that accompanies the setup -- it should already be on your computer if you have pulled main:

https://github.com/GiorginoSerbuciano/p5aiui/blob/5aab84e89226bda55af8cfafd4f53949863ad202/.vscode/launch.json

Styleguide

A space in the following cases:

  • between parameters or arguments
  • around operators (=, <, >, etc.)
  • before opening a curly bracket {
  • around nested calls, like: call( var(x, y) );

Function placement: I suggest re-organizing the code to collect all "helper" functions at the end of the code and ordering them in a consistent manner

Naming: camelCase within the code naming_with_underscores for the file names (--> re-name them?)

'Zoom' effect

This effect is produced by blowing up the x- and y-mouse coordinates up 20 times; drawing is only possible in the upper right corner and is very "coarse".

Sample of current drawing style

Find our style guide @ https://javascript.info/coding-style

Clone this wiki locally