Convert an HTML sketch to a JavaScript-only sketch (by removing the HTML file), or a JavaScript sketch to an HTML sketch (by adding the HTML file).
Before modifying the file system, this method verifies that the set of libraries will remain the same. Before removing an HTML file, it also verifies that the file included only the single script file, and no other non-library files.
Create a sketch from a directory. This method throws an exception if the directory does not contain a sketch index.html file, or contains multiple sketch files.
Create a sketch from an HTML file.
Create a sketch from a JavaScript file.
Analyze the directory for sketch files. Returns a list of sketches, and files that aren't associated with any sketch.
Create a sketch from a file. filePath
should be path to an HTML sketch
file, a JavaScript sketch file, or a directory that contains exactly one
sketch file.
Tests whether the directory is a sketch directory. It is a sketch
directory if it contains a single JavaScript sketch file, or a single HTML
sketch file named index.html
that includes this file.
Tests whether a file is an HTML or JavaScript sketch file.
Tests whether a file is an HTML sketch file. It is a sketch file if it
includes the p5.min.js
or p5.js
script.
Tests whether a file is a JavaScript sketch file. It is recognized as a
sketch file if it includes a definition of the setup()
function and a
call to the p5.js createCanvas()
.
Create and save the files for this sketch. This includes the script file; for an HTML sketch, this also includes the HTML file.
The directory that contains the sketch files. Other xxxFile properties are relative to this.
For an HTML sketch, the pathname of the HTML file, relative to dir.
The main script file, relative to dir.
The list of libraries. For a JavaScript sketch, this is the list of libraries inferred from the undefined global variables that it references. For an HTML sketch, this is the list of libraries named in the HTML file.
The HTML file (for an HTML sketch); any JavaScript files; any files that the HTML file includes; and any files that the JavaScript files include, to the extent that this can be determined by static inspection.
File names are relative to sketch.dirPath.
For an HTML sketch, this is the HTML file. For a JavaScript sketch, this is the JavaScript file. In either case, it is relative to dir.
The file structure of the sketch.
For an HTML sketch, this is the
Generated using TypeDoc
Sketch represents a p5.js Sketch. Is an interface to generate sketch files, find associated files, infer libraries, and scan directories for sketches that they contain.
A sketch can be an HTML sketch, or a script sketch.