diff --git a/.eslintrc.json b/.eslintrc.json index 06589c1db7..41070379ad 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,7 @@ "node": true, "browser": true, "amd": true, - "es6": true + "es2022": true }, "globals": { "p5": true @@ -11,9 +11,9 @@ "root": true, "extends": ["eslint:recommended"], "parserOptions": { - "ecmaVersion": 2017, "sourceType": "module" }, + "ignorePatterns": ["node_modules/**/*", "test/js/*", "lib/**/*", "contributor_docs/**/*"], "rules": { "no-cond-assign": [2, "except-parens"], "eqeqeq": ["error", "smart"], diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index ebf61a1d3f..bd3ca55ba0 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - dev-2.0 pull_request: branches: - '*' diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 2a3ca4e40d..d407e9ddf6 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -41,11 +41,12 @@ jobs: run: npm ci env: CI: true - - name: Run build + - name: Run test run: npm test env: CI: true - - run: rm ./lib/p5-test.js ./lib/p5.pre-min.js + - name: Run build + run: npm run build # 2. Prepare release files - run: mkdir release && mkdir p5 && cp -r ./lib/* p5/ diff --git a/.gitignore b/.gitignore index 88d97958df..42f1e447dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,25 @@ -*.DS_Store -.project -node_modules/* -experiments/* -lib_old/* -lib/p5.* -lib/modules -docs/reference/* -!*.gitkeep -examples/3d/ -.idea -dist/ -p5.zip -bower-repo/ -p5-website/ -.vscode/settings.json -.nyc_output/* -coverage/ -lib/p5-test.js -release/ -parameterData.json -yarn.lock \ No newline at end of file +*.DS_Store +.project +node_modules/* +experiments/* +lib_old/* +lib/p5.* +lib/modules +docs/reference/* +!*.gitkeep +examples/3d/ +.idea +dist/ +p5.zip +bower-repo/ +p5-website/ +.vscode/settings.json +.nyc_output/* +coverage/ +lib/p5-test.js +release/ +yarn.lock +docs/data.json +analyzer/ +preview/ +__screenshots__/ \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index b7c30d3f0b..0000000000 --- a/Gruntfile.js +++ /dev/null @@ -1,345 +0,0 @@ -// these requires allow us to use es6 features such as -// `import`/`export` and `async`/`await` in the Grunt tasks -// we load from other files (`tasks/`) -require('regenerator-runtime/runtime'); -require('@babel/register'); - -module.exports = grunt => { - const connectConfig = open => { - return { - options: { - directory: { - path: './', - options: { - icons: true - } - }, - port: 9001, - open, - middleware: function(connect, options, middlewares) { - middlewares.unshift( - require('connect-modrewrite')([ - '^/assets/js/p5(\\.min)?\\.js(.*) /lib/p5$1.js$2 [L]', - '^/assets/js/p5\\.(sound)(\\.min)?\\.js(.*) /lib/addons/p5.$1$2.js$3 [L]' - ]), - function(req, res, next) { - res.setHeader('Access-Control-Allow-Origin', '*'); - res.setHeader('Access-Control-Allow-Methods', '*'); - return next(); - } - ); - return middlewares; - } - } - }; - }; - - const gruntConfig = { - // read in the package, used for knowing the current version, et al. - pkg: grunt.file.readJSON('package.json'), - - // Configure style consistency checking for this file, the source, and the tests. - eslint: { - options: { - format: 'unix' - }, - build: { - src: [ - 'Gruntfile.js', - 'docs/preprocessor.js', - 'utils/**/*.js', - 'tasks/**/*.js' - ] - }, - source: { - src: ['src/**/*.js'] - }, - test: { - src: ['test/**/*.js', '!test/js/*.js'] - }, - fix: { - // src: is calculated below... - options: { - rules: { - 'no-undef': 0, - 'no-unused-vars': 0 - }, - fix: true - } - } - }, - - 'eslint-samples': { - options: { - parserOptions: { - ecmaVersion: 8 - }, - format: 'unix' - }, - source: { - src: ['src/**/*.js'] - }, - fix: { - options: { - fix: true - } - } - }, - - // Set up the watch task, used for live-reloading during development. - // This watches both the codebase and the yuidoc theme. Changing the - // code touches files within the theme, so it will also recompile the - // documentation. - watch: { - quick: { - files: [ - 'src/**/*.js', - 'src/**/*.frag', - 'src/**/*.vert', - 'src/**/*.glsl' - ], - tasks: ['browserify:dev'], - options: { - livereload: true - } - }, - // Watch the codebase for changes - main: { - files: ['src/**/*.js'], - tasks: ['newer:eslint:source', 'test'], - options: { - livereload: true - } - }, - // watch the theme for changes - reference_build: { - files: ['docs/yuidoc-p5-theme/**/*'], - tasks: ['yuidoc'], - options: { - livereload: true, - interrupt: true - } - }, - // Watch the codebase for doc updates - // launch with 'grunt yui connect:yui watch:yui' - yui: { - files: [ - 'src/**/*.js', - 'lib/addons/*.js', - 'src/**/*.frag', - 'src/**/*.vert', - 'src/**/*.glsl' - ], - tasks: [ - 'browserify', - 'browserify:min', - 'yuidoc:prod', - 'clean:reference', - 'minjson', - 'uglify' - ], - options: { - livereload: true - } - } - }, - - // Set up node-side (non-browser) mocha tests. - mochaTest: { - test: { - src: ['test/node/**/*.js'], - options: { - reporter: 'spec', - require: '@babel/register', - ui: 'tdd' - } - } - }, - - // Set up the mocha task, used for running the automated tests. - mochaChrome: { - yui: { - options: { - urls: ['http://localhost:9001/test/test-reference.html'] - } - }, - test: { - options: { - urls: [ - 'http://localhost:9001/test/test.html', - 'http://localhost:9001/test/test-minified.html' - ] - } - } - }, - - nyc: { - report: { - options: { - reporter: ['text-summary', 'html', 'json'] - } - } - }, - babel: { - options: { - presets: ['@babel/preset-env'] - }, - dist: { - files: { - 'lib/p5.pre-min.js': 'lib/p5.js' - } - } - }, - - // This minifies the javascript into a single file and adds a banner to the - // front of the file. - uglify: { - options: { - compress: { - global_defs: { - IS_MINIFIED: true - } - }, - banner: - '/*! p5.js v<%= pkg.version %> <%= grunt.template.today("mmmm dd, yyyy") %> */ ' - }, - dist: { - files: { - 'lib/p5.min.js': ['lib/p5.pre-min.js'], - 'lib/modules/p5Custom.min.js': ['lib/modules/p5Custom.pre-min.js'] - } - } - }, - - // this builds the documentation for the codebase. - yuidoc: { - prod: { - name: '<%= pkg.name %>', - description: '<%= pkg.description %>', - version: '<%= pkg.version %>', - url: '<%= pkg.homepage %>', - options: { - paths: ['src/', 'lib/addons/'], - themedir: 'docs/yuidoc-p5-theme/', - helpers: ['docs/yuidoc-p5-theme/helpers/helpers_prod.js'], - preprocessor: './docs/preprocessor.js', - outdir: 'docs/reference/' - } - } - }, - - clean: { - // Clean up unused files generated by yuidoc - reference: { - src: [ - 'docs/reference/classes/', - 'docs/reference/elements/', - 'docs/reference/files/', - 'docs/reference/modules/', - 'docs/reference/api.js' - ] - } - }, - - // This is a static server which is used when testing connectivity for the - // p5 library. This avoids needing an internet connection to run the tests. - // It serves all the files in the test directory at http://localhost:9001/ - connect: { - server: connectConfig(), - yui: connectConfig('http://127.0.0.1:9001/docs/reference/') - }, - - // This minifies the data.json file created from the inline reference - minjson: { - compile: { - files: { - './docs/reference/data.min.json': './docs/reference/data.json' - } - } - } - }; - - // eslint fixes everything it checks: - gruntConfig.eslint.fix.src = Object.keys(gruntConfig.eslint).reduce( - (acc, key) => { - if (gruntConfig.eslint[key].src) { - acc.push(...gruntConfig.eslint[key].src); - } - return acc; - }, - [] - ); - - /* not yet - gruntConfig['eslint-samples'].fix.src = Object.keys( - gruntConfig['eslint-samples'] - ) - .map(s => gruntConfig['eslint-samples'][s].src) - .reduce((a, b) => a.concat(b), []) - .filter(a => a); - */ - - grunt.initConfig(gruntConfig); - - // Load build tasks. - // This contains the complete build task ("browserify") - // and the task to generate user select modules of p5 - // ("combineModules") which can be invoked directly by - // `grunt combineModules:module_1:module_2` where core - // is included by default in all combinations always. - // NOTE: "module_x" is the name of it's folder in /src. - grunt.loadTasks('tasks/build'); - - // Load tasks for testing - grunt.loadTasks('tasks/test'); - - // Load the external libraries used. - grunt.loadNpmTasks('grunt-contrib-connect'); - grunt.loadNpmTasks('grunt-eslint'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-contrib-yuidoc'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-minjson'); - grunt.loadNpmTasks('grunt-mocha-test'); - grunt.loadNpmTasks('grunt-newer'); - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-simple-nyc'); - - // Create the multitasks. - grunt.registerTask('build', [ - 'yui', - 'browserify', - 'browserify:min', - 'uglify', - 'browserify:test' - ]); - grunt.registerTask('lint', ['lint:source', 'lint:samples']); - grunt.registerTask('lint:source', [ - 'eslint:build', - 'eslint:source', - 'eslint:test' - ]); - grunt.registerTask('lint:samples', [ - 'yui', // required for eslint-samples - 'eslint-samples:source' - ]); - grunt.registerTask('lint-fix', ['eslint:fix']); - grunt.registerTask('test', [ - 'build', - 'connect:server', - 'mochaChrome', - 'mochaTest', - 'nyc:report' - ]); - grunt.registerTask('test:nobuild', [ - 'eslint:test', - 'connect:server', - 'mochaChrome', - 'mochaTest', - 'nyc:report' - ]); - grunt.registerTask('yui', ['yuidoc:prod', 'clean:reference', 'minjson']); - grunt.registerTask('yui:test', ['yui', 'connect:yui', 'mochaChrome:yui']); - grunt.registerTask('yui:dev', ['yui', 'build', 'connect:yui', 'watch:yui']); - grunt.registerTask('default', ['lint', 'test']); -}; diff --git a/docs/converted.json b/docs/converted.json new file mode 100644 index 0000000000..c5b5010368 --- /dev/null +++ b/docs/converted.json @@ -0,0 +1,27999 @@ +{ + "project": {}, + "files": {}, + "modules": { + "Environment": { + "name": "Environment", + "submodules": { + "Environment": 1 + }, + "classes": {} + }, + "Color": { + "name": "Color", + "submodules": { + "Color Conversion": 1, + "Creating & Reading": 1, + "Setting": 1 + }, + "classes": {} + }, + "Constants": { + "name": "Constants", + "submodules": { + "Constants": 1 + }, + "classes": {} + }, + "Structure": { + "name": "Structure", + "submodules": { + "Structure": 1 + }, + "classes": {} + }, + "DOM": { + "name": "DOM", + "submodules": { + "DOM": 1 + }, + "classes": {} + }, + "Rendering": { + "name": "Rendering", + "submodules": { + "Rendering": 1 + }, + "classes": {} + }, + "Foundation": { + "name": "Foundation", + "submodules": { + "Foundation": 1 + }, + "classes": {} + }, + "Shape": { + "name": "Shape", + "submodules": { + "2D Primitives": 1, + "Attributes": 1, + "Curves": 1, + "Vertex": 1, + "3D Primitives": 1, + "3D Models": 1 + }, + "classes": {} + }, + "Transform": { + "name": "Transform", + "submodules": { + "Transform": 1 + }, + "classes": {} + }, + "Data": { + "name": "Data", + "submodules": { + "LocalStorage": 1, + "Dictionary": 1, + "Array Functions": 1, + "Conversion": 1, + "String Functions": 1 + }, + "classes": {} + }, + "Events": { + "name": "Events", + "submodules": { + "Acceleration": 1, + "Keyboard": 1, + "Mouse": 1, + "Touch": 1 + }, + "classes": {} + }, + "Image": { + "name": "Image", + "submodules": { + "Image": 1, + "Loading & Displaying": 1, + "Pixels": 1 + }, + "classes": {} + }, + "IO": { + "name": "IO", + "submodules": { + "Input": 1, + "Output": 1, + "Table": 1, + "Time & Date": 1 + }, + "classes": {} + }, + "Math": { + "name": "Math", + "submodules": { + "Calculation": 1, + "Vector": 1, + "Noise": 1, + "Random": 1, + "Trigonometry": 1 + }, + "classes": {} + }, + "Typography": { + "name": "Typography", + "submodules": { + "Attributes": 1, + "Loading & Displaying": 1 + }, + "classes": {} + }, + "3D": { + "name": "3D", + "submodules": { + "Interaction": 1, + "Lights": 1, + "Material": 1, + "Camera": 1 + }, + "classes": {} + }, + "Color Conversion": { + "name": "Color Conversion", + "module": "Color", + "is_submodule": 1 + }, + "Creating & Reading": { + "name": "Creating & Reading", + "module": "Color", + "is_submodule": 1 + }, + "Setting": { + "name": "Setting", + "module": "Color", + "is_submodule": 1 + }, + "2D Primitives": { + "name": "2D Primitives", + "module": "Shape", + "is_submodule": 1 + }, + "Attributes": { + "name": "Attributes", + "module": "Shape", + "is_submodule": 1 + }, + "Curves": { + "name": "Curves", + "module": "Shape", + "is_submodule": 1 + }, + "Vertex": { + "name": "Vertex", + "module": "Shape", + "is_submodule": 1 + }, + "3D Primitives": { + "name": "3D Primitives", + "module": "Shape", + "is_submodule": 1 + }, + "3D Models": { + "name": "3D Models", + "module": "Shape", + "is_submodule": 1 + }, + "LocalStorage": { + "name": "LocalStorage", + "module": "Data", + "is_submodule": 1 + }, + "Dictionary": { + "name": "Dictionary", + "module": "Data", + "is_submodule": 1 + }, + "Array Functions": { + "name": "Array Functions", + "module": "Data", + "is_submodule": 1 + }, + "Conversion": { + "name": "Conversion", + "module": "Data", + "is_submodule": 1 + }, + "String Functions": { + "name": "String Functions", + "module": "Data", + "is_submodule": 1 + }, + "Acceleration": { + "name": "Acceleration", + "module": "Events", + "is_submodule": 1 + }, + "Keyboard": { + "name": "Keyboard", + "module": "Events", + "is_submodule": 1 + }, + "Mouse": { + "name": "Mouse", + "module": "Events", + "is_submodule": 1 + }, + "Touch": { + "name": "Touch", + "module": "Events", + "is_submodule": 1 + }, + "Loading & Displaying": { + "name": "Loading & Displaying", + "module": "Image", + "is_submodule": 1 + }, + "Pixels": { + "name": "Pixels", + "module": "Image", + "is_submodule": 1 + }, + "Input": { + "name": "Input", + "module": "IO", + "is_submodule": 1 + }, + "Output": { + "name": "Output", + "module": "IO", + "is_submodule": 1 + }, + "Table": { + "name": "Table", + "module": "IO", + "is_submodule": 1 + }, + "Time & Date": { + "name": "Time & Date", + "module": "IO", + "is_submodule": 1 + }, + "Calculation": { + "name": "Calculation", + "module": "Math", + "is_submodule": 1 + }, + "Vector": { + "name": "Vector", + "module": "Math", + "is_submodule": 1 + }, + "Noise": { + "name": "Noise", + "module": "Math", + "is_submodule": 1 + }, + "Random": { + "name": "Random", + "module": "Math", + "is_submodule": 1 + }, + "Trigonometry": { + "name": "Trigonometry", + "module": "Math", + "is_submodule": 1 + }, + "Interaction": { + "name": "Interaction", + "module": "3D", + "is_submodule": 1 + }, + "Lights": { + "name": "Lights", + "module": "3D", + "is_submodule": 1 + }, + "Material": { + "name": "Material", + "module": "3D", + "is_submodule": 1 + }, + "Camera": { + "name": "Camera", + "module": "3D", + "is_submodule": 1 + } + }, + "classes": { + "p5": { + "name": "p5", + "file": "src/core/main.js", + "line": 32, + "description": "
This is the p5 instance constructor.
\nA p5 instance holds all the properties and methods related to\na p5 sketch. It expects an incoming sketch closure and it can also\ntake an optional node parameter for attaching the generated p5 canvas\nto a node. The sketch closure takes the newly created p5 instance as\nits sole argument and may optionally set preload(),\nsetup(), and/or\ndraw() properties on it for running a sketch.
\nA p5 sketch can run in \"global\" or \"instance\" mode:\n\"global\" - all properties and methods are attached to the window\n\"instance\" - all properties and methods are bound to this p5 object
\n", + "example": [], + "params": [ + { + "name": "sketch", + "description": "a closure that can set optional preload(),\nsetup(), and/or draw() properties on the\ngiven p5 instance" + }, + { + "name": "node", + "description": "element to attach canvas to", + "optional": 1, + "type": "HTMLElement" + } + ], + "return": { + "description": "a p5 instance", + "type": "p5" + }, + "is_constructor": 1, + "module": "Structure", + "submodule": "Structure" + }, + "p5.Color": { + "name": "p5.Color", + "file": "src/color/p5.Color.js", + "line": 343, + "description": "A class to describe a color. Each p5.Color
object stores the color mode\nand level maxes that were active during its construction. These values are\nused to interpret the arguments passed to the object's constructor. They\nalso determine output formatting such as when\nsaturation() is called.
Color is stored internally as an array of ideal RGBA values in floating\npoint form, normalized from 0 to 1. These values are used to calculate the\nclosest screen colors, which are RGBA levels from 0 to 255. Screen colors\nare sent to the renderer.
\nWhen different color representations are calculated, the results are cached\nfor performance. These values are normalized, floating-point numbers.
\ncolor() is the recommended way to create an instance\nof this class.
\n", + "example": [], + "params": [ + { + "name": "pInst", + "description": "pointer to p5 instance.", + "optional": 1, + "type": "p5" + }, + { + "name": "vals", + "description": "an array containing the color values\nfor red, green, blue and alpha channel\nor CSS color.", + "type": "Number[]|String" + } + ], + "is_constructor": 1, + "module": "Color", + "submodule": "Creating & Reading" + }, + "FetchResources": { + "name": "FetchResources", + "file": "src/core/internationalization.js", + "line": 30, + "description": "This is our i18next \"backend\" plugin. It tries to fetch languages\nfrom a CDN.", + "example": [], + "params": [], + "is_constructor": 1 + }, + "p5.Element": { + "name": "p5.Element", + "file": "src/core/p5.Element.js", + "line": 53, + "description": "A class to describe an\nHTML element.\nSketches can use many elements. Common elements include the drawing canvas,\nbuttons, sliders, webcam feeds, and so on.
\nAll elements share the methods of the p5.Element
class. They're created\nwith functions such as createCanvas() and\ncreateButton().
\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Create a button element and\n // place it beneath the canvas.\n let btn = createButton('change');\n btn.position(0, 100);\n\n // Call randomColor() when\n // the button is pressed.\n btn.mousePressed(randomColor);\n\n describe('A gray square with a button that says \"change\" beneath it. The square changes color when the user presses the button.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\nA class to handle audio and video.
\np5.MediaElement
extends p5.Element with\nmethods to handle audio and video. p5.MediaElement
objects are created by\ncalling createVideo,\ncreateAudio, and\ncreateCapture.
\nlet capture;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Create a p5.MediaElement using createCapture().\n capture = createCapture(VIDEO);\n capture.hide();\n}\n\nfunction draw() {\n // Display the video stream and invert the colors.\n image(capture, 0, 0, width, width * capture.height / capture.width);\n filter(INVERT);\n}\n
\nA class to describe a file.
\np5.File
objects are used by\nmyElement.drop() and\ncreated by\ncreateFileInput.
\n// Use the file input to load a\n// file and display its info.\n\nfunction setup() {\n background(200);\n\n // Create a file input and place it beneath\n // the canvas. Call displayInfo() when\n // the file loads.\n let input = createFileInput(displayInfo);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.');\n}\n\n// Display the p5.File's info\n// once it loads.\nfunction displayInfo(file) {\n background(200);\n\n // Display the p5.File's name.\n text(file.name, 10, 10, 80, 40);\n // Display the p5.File's type and subtype.\n text(`${file.type}/${file.subtype}`, 10, 70);\n // Display the p5.File's size in bytes.\n text(file.size, 10, 90);\n}\n
\n\n// Use the file input to select an image to\n// load and display.\nlet img;\n\nfunction setup() {\n // Create a file input and place it beneath\n // the canvas. Call handleImage() when\n // the file image loads.\n let input = createFileInput(handleImage);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.');\n}\n\nfunction draw() {\n background(200);\n\n // Draw the image if it's ready.\n if (img) {\n image(img, 0, 0, width, height);\n }\n}\n\n// Use the p5.File's data once\n// it loads.\nfunction handleImage(file) {\n // Check the p5.File's type.\n if (file.type === 'image') {\n // Create an image using using\n // the p5.File's data.\n img = createImg(file.data, '');\n\n // Hide the image element so it\n // doesn't appear twice.\n img.hide();\n } else {\n img = null;\n }\n}\n
\nA class to describe an image. Images are rectangular grids of pixels that\ncan be displayed and modified.
\nExisting images can be loaded by calling\nloadImage(). Blank images can be created by\ncalling createImage(). p5.Image
objects\nhave methods for common tasks such as applying filters and modifying\npixel values.
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n\n describe('An image of a brick wall.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(GRAY);\n image(img, 0, 0);\n\n describe('A grayscale image of a brick wall.');\n}\n
\n\nbackground(200);\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let x = 0; x < img.width; x += 1) {\n for (let y = 0; y < img.height; y += 1) {\n img.set(x, y, 0);\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\nA TableRow object represents a single row of data values,\nstored in columns, from a table.
\nA Table Row contains both an ordered array, and an unordered\nJSON object.
\n", + "example": [], + "params": [ + { + "name": "str", + "description": "optional: populate the row with a\nstring of values, separated by the\nseparator", + "optional": 1, + "type": "String" + }, + { + "name": "separator", + "description": "comma separated values (csv) by default", + "optional": 1, + "type": "String" + } + ], + "is_constructor": 1, + "module": "IO", + "submodule": "Table" + }, + "p5.XML": { + "name": "p5.XML", + "file": "src/io/p5.XML.js", + "line": 51, + "description": "XML is a representation of an XML object, able to parse XML code. Use\nloadXML() to load external XML files and create XML objects.", + "example": [ + "\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let children = xml.getChildren('animal');\n\n for (let i = 0; i < children.length; i++) {\n let id = children[i].getNum('id');\n let coloring = children[i].getString('species');\n let name = children[i].getContent();\n print(id + ', ' + coloring + ', ' + name);\n }\n\n describe('no image displayed');\n}\n\n// Sketch prints:\n// 0, Capra hircus, Goat\n// 1, Panthera pardus, Leopard\n// 2, Equus zebra, Zebra\n
A class to describe a two or three-dimensional vector. A vector is like an\narrow pointing in space. Vectors have both magnitude (length) and\ndirection.
\np5.Vector
objects are often used to program motion because they simplify\nthe math. For example, a moving ball has a position and a velocity.\nPosition describes where the ball is in space. The ball's position vector\nextends from the origin to the ball's center. Velocity describes the ball's\nspeed and the direction it's moving. If the ball is moving straight up, its\nvelocity vector points straight up. Adding the ball's velocity vector to\nits position vector moves it, as in pos.add(vel)
. Vector math relies on\nmethods inside the p5.Vector
class.
\nlet p1 = createVector(25, 25);\nlet p2 = createVector(75, 75);\n\nstrokeWeight(5);\npoint(p1);\npoint(p2.x, p2.y);\n\ndescribe('Two black dots on a gray square, one at the top left and the other at the bottom right.');\n
\n\nlet pos;\nlet vel;\n\nfunction setup() {\n createCanvas(100, 100);\n pos = createVector(width / 2, height);\n vel = createVector(0, -1);\n}\n\nfunction draw() {\n background(200);\n\n pos.add(vel);\n\n if (pos.y < 0) {\n pos.y = height;\n }\n\n strokeWeight(5);\n point(pos);\n\n describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.');\n}\n
\n\nlet font;\n\nfunction preload() {\n // Creates a p5.Font object.\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n fill('deeppink');\n textFont(font);\n textSize(36);\n text('p5*js', 10, 50);\n\n describe('The text \"p5*js\" written in pink on a white background.');\n}\n
\nThis class describes a camera for use in p5's\n\nWebGL mode. It contains camera position, orientation, and projection\ninformation necessary for rendering a 3D scene.
\nNew p5.Camera objects can be made through the\ncreateCamera() function and controlled through\nthe methods described below. A camera created in this way will use a default\nposition in the scene and a default perspective projection until these\nproperties are changed through the various methods available. It is possible\nto create multiple cameras, in which case the current camera\ncan be set through the setCamera() method.
\nNote:\nThe methods below operate in two coordinate systems: the 'world' coordinate\nsystem describe positions in terms of their relationship to the origin along\nthe X, Y and Z axes whereas the camera's 'local' coordinate system\ndescribes positions from the camera's point of view: left-right, up-down,\nand forward-backward. The move() method,\nfor instance, moves the camera along its own axes, whereas the\nsetPosition()\nmethod sets the camera's position in world-space.
\nThe camera object properties\neyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ
\nwhich describes camera position, orientation, and projection\nare also accessible via the camera object generated using\ncreateCamera()
\nlet cam;\nlet delta = 0.01;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // set initial pan angle\n cam.pan(-0.8);\n describe(\n 'camera view pans left and right across a series of rotating 3D boxes.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // pan camera according to angle 'delta'\n cam.pan(delta);\n\n // every 160 frames, switch direction\n if (frameCount % 160 === 0) {\n delta *= -1;\n }\n\n rotateX(frameCount * 0.01);\n translate(-100, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n}\n
\nThese regular expressions are used to build up the patterns for matching\nviable CSS color strings: fragmenting the regexes in this way increases the\nlegibility and comprehensibility of the code.
\nNote that RGB values of .9 are not parsed by IE, but are supported here for\ncolor string consistency.
\n", + "module": "Color", + "submodule": "Creating & Reading", + "class": "p5" + }, + { + "itemtype": "property", + "name": "colorPatterns", + "file": "src/color/p5.Color.js", + "line": 184, + "description": "Full color string patterns. The capture groups are necessary.", + "module": "Color", + "submodule": "Creating & Reading", + "class": "p5" + }, + { + "itemtype": "property", + "name": "VERSION", + "file": "src/core/constants.js", + "line": 14, + "type": "string", + "description": "Version of this p5.js.", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "P2D", + "file": "src/core/constants.js", + "line": 23, + "description": "The default, two-dimensional renderer.", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "WEBGL", + "file": "src/core/constants.js", + "line": 44, + "description": "One of the two render modes in p5.js, used for computationally intensive tasks like 3D rendering and shaders.
\nWEBGL
differs from the default P2D
renderer in the following ways:
WEBGL
mode, the origin point (0,0,0) is located at the center of the screen, not the top-left corner. See the learn page about coordinates and transformations.WEBGL
mode can be used to draw 3-dimensional shapes like box(), sphere(), cone(), and more. See the learn page about custom geometry to make more complex objects.WEBGL
mode, you can specify how smooth curves should be drawn by using a detail
parameter. See the wiki section about shapes for a more information and an example.WEBGL
offers different types of lights like ambientLight() to place around a scene. Materials like specularMaterial() reflect the lighting to convey shape and depth. See the learn page for styling and appearance to experiment with different combinations.WEBGL
sketch can be adjusted by changing camera attributes. See the learn page section about cameras for an explanation of camera controls.WEBGL
requires opentype/truetype font files to be preloaded using loadFont(). See the wiki section about text for details, along with a workaround.WEBGL
mode uses the graphics card instead of the CPU, so it may help boost the performance of your sketch (example: drawing more shapes on the screen at once).To learn more about WEBGL mode, check out all the interactive WEBGL tutorials in the \"Learn\" section of this website, or read the wiki article \"Getting started with WebGL in p5\".
\n", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "WEBGL2", + "file": "src/core/constants.js", + "line": 52, + "description": "One of the two possible values of a WebGL canvas (either WEBGL or WEBGL2),\nwhich can be used to determine what capabilities the rendering environment\nhas.", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ARROW", + "file": "src/core/constants.js", + "line": 59, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CROSS", + "file": "src/core/constants.js", + "line": 64, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "HAND", + "file": "src/core/constants.js", + "line": 69, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "MOVE", + "file": "src/core/constants.js", + "line": 74, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TEXT", + "file": "src/core/constants.js", + "line": 79, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "WAIT", + "file": "src/core/constants.js", + "line": 84, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "HALF_PI", + "file": "src/core/constants.js", + "line": 105, + "description": "HALF_PI is a mathematical constant with the value\n1.57079632679489661923. It is half the ratio of the\ncircumference of a circle to its diameter. It is useful in\ncombination with the trigonometric functions sin() and cos().", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "PI", + "file": "src/core/constants.js", + "line": 123, + "description": "PI is a mathematical constant with the value\n3.14159265358979323846. It is the ratio of the circumference\nof a circle to its diameter. It is useful in combination with\nthe trigonometric functions sin() and cos().", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "QUARTER_PI", + "file": "src/core/constants.js", + "line": 141, + "description": "QUARTER_PI is a mathematical constant with the value 0.7853982.\nIt is one quarter the ratio of the circumference of a circle to\nits diameter. It is useful in combination with the trigonometric\nfunctions sin() and cos().", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TAU", + "file": "src/core/constants.js", + "line": 159, + "description": "TAU is an alias for TWO_PI, a mathematical constant with the\nvalue 6.28318530717958647693. It is twice the ratio of the\ncircumference of a circle to its diameter. It is useful in\ncombination with the trigonometric functions sin() and cos().", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TWO_PI", + "file": "src/core/constants.js", + "line": 177, + "description": "TWO_PI is a mathematical constant with the value\n6.28318530717958647693. It is twice the ratio of the\ncircumference of a circle to its diameter. It is useful in\ncombination with the trigonometric functions sin() and cos().", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "DEGREES", + "file": "src/core/constants.js", + "line": 191, + "description": "Constant to be used with the angleMode() function, to set the mode in\nwhich p5.js interprets and calculates angles (either DEGREES or RADIANS).", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "RADIANS", + "file": "src/core/constants.js", + "line": 205, + "description": "Constant to be used with the angleMode() function, to set the mode\nin which p5.js interprets and calculates angles (either RADIANS or DEGREES).", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CORNER", + "file": "src/core/constants.js", + "line": 214, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CORNERS", + "file": "src/core/constants.js", + "line": 219, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "RADIUS", + "file": "src/core/constants.js", + "line": 224, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "RIGHT", + "file": "src/core/constants.js", + "line": 229, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LEFT", + "file": "src/core/constants.js", + "line": 234, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CENTER", + "file": "src/core/constants.js", + "line": 239, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TOP", + "file": "src/core/constants.js", + "line": 244, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BOTTOM", + "file": "src/core/constants.js", + "line": 249, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BASELINE", + "file": "src/core/constants.js", + "line": 255, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "POINTS", + "file": "src/core/constants.js", + "line": 261, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LINES", + "file": "src/core/constants.js", + "line": 267, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LINE_STRIP", + "file": "src/core/constants.js", + "line": 273, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LINE_LOOP", + "file": "src/core/constants.js", + "line": 279, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TRIANGLES", + "file": "src/core/constants.js", + "line": 285, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TRIANGLE_FAN", + "file": "src/core/constants.js", + "line": 291, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TRIANGLE_STRIP", + "file": "src/core/constants.js", + "line": 297, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "QUADS", + "file": "src/core/constants.js", + "line": 302, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "QUAD_STRIP", + "file": "src/core/constants.js", + "line": 308, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TESS", + "file": "src/core/constants.js", + "line": 314, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CLOSE", + "file": "src/core/constants.js", + "line": 319, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "OPEN", + "file": "src/core/constants.js", + "line": 324, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CHORD", + "file": "src/core/constants.js", + "line": 329, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "PIE", + "file": "src/core/constants.js", + "line": 334, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "PROJECT", + "file": "src/core/constants.js", + "line": 340, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "SQUARE", + "file": "src/core/constants.js", + "line": 346, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ROUND", + "file": "src/core/constants.js", + "line": 351, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BEVEL", + "file": "src/core/constants.js", + "line": 356, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "MITER", + "file": "src/core/constants.js", + "line": 361, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "RGB", + "file": "src/core/constants.js", + "line": 368, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "HSB", + "file": "src/core/constants.js", + "line": 377, + "type": "string", + "description": "HSB (hue, saturation, brightness) is a type of color model.\nYou can learn more about it at\nHSB.", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "HSL", + "file": "src/core/constants.js", + "line": 382, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "AUTO", + "file": "src/core/constants.js", + "line": 393, + "type": "string", + "description": "AUTO allows us to automatically set the width or height of an element (but not both),\nbased on the current height and width of the element. Only one parameter can\nbe passed to the size function as AUTO, at a time.", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ALT", + "file": "src/core/constants.js", + "line": 400, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BACKSPACE", + "file": "src/core/constants.js", + "line": 405, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CONTROL", + "file": "src/core/constants.js", + "line": 410, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "DELETE", + "file": "src/core/constants.js", + "line": 415, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "DOWN_ARROW", + "file": "src/core/constants.js", + "line": 420, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ENTER", + "file": "src/core/constants.js", + "line": 425, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ESCAPE", + "file": "src/core/constants.js", + "line": 430, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LEFT_ARROW", + "file": "src/core/constants.js", + "line": 435, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "OPTION", + "file": "src/core/constants.js", + "line": 440, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "RETURN", + "file": "src/core/constants.js", + "line": 445, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "RIGHT_ARROW", + "file": "src/core/constants.js", + "line": 450, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "SHIFT", + "file": "src/core/constants.js", + "line": 455, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TAB", + "file": "src/core/constants.js", + "line": 460, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "UP_ARROW", + "file": "src/core/constants.js", + "line": 465, + "type": "number", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BLEND", + "file": "src/core/constants.js", + "line": 473, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "REMOVE", + "file": "src/core/constants.js", + "line": 479, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ADD", + "file": "src/core/constants.js", + "line": 485, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "DARKEST", + "file": "src/core/constants.js", + "line": 492, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LIGHTEST", + "file": "src/core/constants.js", + "line": 498, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "DIFFERENCE", + "file": "src/core/constants.js", + "line": 503, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "SUBTRACT", + "file": "src/core/constants.js", + "line": 508, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "EXCLUSION", + "file": "src/core/constants.js", + "line": 513, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "MULTIPLY", + "file": "src/core/constants.js", + "line": 518, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "SCREEN", + "file": "src/core/constants.js", + "line": 523, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "REPLACE", + "file": "src/core/constants.js", + "line": 529, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "OVERLAY", + "file": "src/core/constants.js", + "line": 534, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "HARD_LIGHT", + "file": "src/core/constants.js", + "line": 539, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "SOFT_LIGHT", + "file": "src/core/constants.js", + "line": 544, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "DODGE", + "file": "src/core/constants.js", + "line": 550, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BURN", + "file": "src/core/constants.js", + "line": 556, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "THRESHOLD", + "file": "src/core/constants.js", + "line": 563, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "GRAY", + "file": "src/core/constants.js", + "line": 568, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "OPAQUE", + "file": "src/core/constants.js", + "line": 573, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "INVERT", + "file": "src/core/constants.js", + "line": 578, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "POSTERIZE", + "file": "src/core/constants.js", + "line": 583, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "DILATE", + "file": "src/core/constants.js", + "line": 588, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ERODE", + "file": "src/core/constants.js", + "line": 593, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BLUR", + "file": "src/core/constants.js", + "line": 598, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "NORMAL", + "file": "src/core/constants.js", + "line": 605, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "ITALIC", + "file": "src/core/constants.js", + "line": 610, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BOLD", + "file": "src/core/constants.js", + "line": 615, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BOLDITALIC", + "file": "src/core/constants.js", + "line": 620, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CHAR", + "file": "src/core/constants.js", + "line": 625, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "WORD", + "file": "src/core/constants.js", + "line": 630, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LINEAR", + "file": "src/core/constants.js", + "line": 642, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "QUADRATIC", + "file": "src/core/constants.js", + "line": 647, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "BEZIER", + "file": "src/core/constants.js", + "line": 652, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CURVE", + "file": "src/core/constants.js", + "line": 657, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "STROKE", + "file": "src/core/constants.js", + "line": 664, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "FILL", + "file": "src/core/constants.js", + "line": 669, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "TEXTURE", + "file": "src/core/constants.js", + "line": 674, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "IMMEDIATE", + "file": "src/core/constants.js", + "line": 679, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "IMAGE", + "file": "src/core/constants.js", + "line": 687, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "NEAREST", + "file": "src/core/constants.js", + "line": 695, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "REPEAT", + "file": "src/core/constants.js", + "line": 700, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CLAMP", + "file": "src/core/constants.js", + "line": 705, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "MIRROR", + "file": "src/core/constants.js", + "line": 710, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "FLAT", + "file": "src/core/constants.js", + "line": 717, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "SMOOTH", + "file": "src/core/constants.js", + "line": 722, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LANDSCAPE", + "file": "src/core/constants.js", + "line": 729, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "PORTRAIT", + "file": "src/core/constants.js", + "line": 734, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "GRID", + "file": "src/core/constants.js", + "line": 744, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "AXES", + "file": "src/core/constants.js", + "line": 750, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "LABEL", + "file": "src/core/constants.js", + "line": 756, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "FALLBACK", + "file": "src/core/constants.js", + "line": 761, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "CONTAIN", + "file": "src/core/constants.js", + "line": 767, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "COVER", + "file": "src/core/constants.js", + "line": 773, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "UNSIGNED_BYTE", + "file": "src/core/constants.js", + "line": 779, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "UNSIGNED_INT", + "file": "src/core/constants.js", + "line": 785, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "FLOAT", + "file": "src/core/constants.js", + "line": 791, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "HALF_FLOAT", + "file": "src/core/constants.js", + "line": 797, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "RGBA", + "file": "src/core/constants.js", + "line": 803, + "type": "string", + "description": "", + "module": "Constants", + "submodule": "Constants", + "class": "p5" + }, + { + "itemtype": "property", + "name": "initialize", + "file": "src/core/internationalization.js", + "line": 125, + "description": "Set up our translation function, with loaded languages", + "class": "p5" + }, + { + "itemtype": "property", + "name": "availableTranslatorLanguages", + "file": "src/core/internationalization.js", + "line": 170, + "description": "Returns a list of languages we have translations loaded for", + "class": "p5" + }, + { + "itemtype": "property", + "name": "currentTranslatorLanguage", + "file": "src/core/internationalization.js", + "line": 177, + "description": "Returns the current language selected for translation", + "class": "p5" + }, + { + "itemtype": "property", + "name": "setTranslatorLanguage", + "file": "src/core/internationalization.js", + "line": 186, + "description": "Sets the current language for translation\nReturns a promise that resolved when loading is finished,\nor rejects if it fails.", + "class": "p5" + }, + { + "itemtype": "property", + "name": "languages", + "file": "s", + "line": 24, + "description": "This is a list of languages that we have added so far.\nIf you have just added a new language (yay!), add its key to the list below\n(en
is english, es
es español). Also add its export to\ndev.js, which is another file in this folder.",
+ "class": "p5"
+ },
+ {
+ "itemtype": "property",
+ "name": "styleEmpty",
+ "file": "src/core/p5.Renderer2D.js",
+ "line": 11,
+ "type": "string",
+ "description": "p5.Renderer2D\nThe 2D graphics canvas renderer class.\nextends p5.Renderer",
+ "class": "p5"
+ },
+ {
+ "itemtype": "property",
+ "name": "Filters",
+ "file": "src/image/filters.js",
+ "line": 16,
+ "description": "This module defines the filters for use with image buffers.
\nThis module is basically a collection of functions stored in an object\nas opposed to modules. The functions are destructive, modifying\nthe passed in canvas rather than creating a copy.
\nGenerally speaking users of this module will use the Filters.apply method\non a canvas to create an effect.
\nA number of functions are borrowed/adapted from\nhttp://www.html5rocks.com/en/tutorials/canvas/imagefilters/\nor the java processing implementation.
\n", + "class": "p5" + }, + { + "itemtype": "property", + "name": "frameCount", + "file": "src/core/environment.js", + "line": 117, + "type": "Integer", + "module": "Environment", + "submodule": "Environment", + "class": "p5", + "example": [ + "\nfunction setup() {\n background(200);\n\n // Display the value of\n // frameCount.\n textSize(30);\n textAlign(CENTER, CENTER);\n text(frameCount, 50, 50);\n\n describe('The number 0 written in black in the middle of a gray square.');\n}\n
\n\nfunction setup() {\n // Set the frameRate to 30.\n frameRate(30);\n\n textSize(30);\n textAlign(CENTER, CENTER);\n}\n\nfunction draw() {\n background(200);\n\n // Display the value of\n // frameCount.\n text(frameCount, 50, 50);\n\n describe('A number written in black in the middle of a gray square. Its value increases rapidly.');\n}\n
\nTracks the number of frames drawn since the sketch started.
\nframeCount
's value is 0 inside setup(). It\nincrements by 1 each time the code in draw()\nfinishes executing.
\nlet x = 0;\nlet speed = 0.05;\n\nfunction setup() {\n // Set the frameRate to 30.\n frameRate(30);\n}\n\nfunction draw() {\n background(200);\n\n // Use deltaTime to calculate\n // a change in position.\n let deltaX = speed * deltaTime;\n\n // Update the x variable.\n x += deltaX;\n\n // Reset x to 0 if it's\n // greater than 100.\n if (x > 100) {\n x = 0;\n }\n\n // Use x to set the circle's\n // position.\n circle(x, 50, 20);\n\n describe('A white circle moves from left to right on a gray background. It reappears on the left side when it reaches the right side.');\n}\n
\ndeltaTime
is\nuseful for simulating physics."
+ },
+ {
+ "itemtype": "property",
+ "name": "focused",
+ "file": "src/core/environment.js",
+ "line": 191,
+ "type": "Boolean",
+ "module": "Environment",
+ "submodule": "Environment",
+ "class": "p5",
+ "example": [
+ "\n// Open this example in two separate browser\n// windows placed side-by-side to demonstrate.\n\nfunction draw() {\n // Change the background color\n // when the browser window\n // goes in/out of focus.\n if (focused === true) {\n background(0, 255, 0);\n } else {\n background(255, 0, 0);\n }\n\n describe('A square changes color from green to red when the browser window is out of focus.');\n}\n
\nfocused
is true
if the window if focused and false
if not."
+ },
+ {
+ "itemtype": "property",
+ "name": "webglVersion",
+ "file": "src/core/environment.js",
+ "line": 545,
+ "type": "String",
+ "module": "Environment",
+ "submodule": "Environment",
+ "class": "p5",
+ "example": [
+ "\nfunction setup() {\n background(200);\n\n // Display the current WebGL version.\n text(webglVersion, 42, 54);\n\n describe('The text \"p2d\" written in black on a gray background.');\n}\n
\n\nlet font;\n\nfunction preload() {\n // Load a font to use.\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n // Create a canvas using WEBGL mode.\n createCanvas(100, 50, WEBGL);\n background(200);\n\n // Display the current WebGL version.\n fill(0);\n textFont(font);\n text(webglVersion, -15, 5);\n\n describe('The text \"webgl2\" written in black on a gray background.');\n}\n
\n\nlet font;\n\nfunction preload() {\n // Load a font to use.\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n // Create a canvas using WEBGL mode.\n createCanvas(100, 50, WEBGL);\n\n // Set WebGL to version 1.\n setAttributes({ version: 1 });\n\n background(200);\n\n // Display the current WebGL version.\n fill(0);\n textFont(font);\n text(webglVersion, -14, 5);\n\n describe('The text \"webgl\" written in black on a gray background.');\n}\n
\nA string variable with the WebGL version in use. Its value equals one of\nthe followin string constants:
\nWEBGL2
whose value is 'webgl2'
,WEBGL
whose value is 'webgl'
, orP2D
whose value is 'p2d'
. This is the default for 2D sketches.See setAttributes() for ways to set the\nWebGL version.
\n" + }, + { + "itemtype": "property", + "name": "displayWidth", + "file": "src/core/environment.js", + "line": 575, + "type": "Number", + "module": "Environment", + "submodule": "Environment", + "class": "p5", + "example": [ + "\nfunction setup() {\n // Set the canvas' width and height\n // using the display's dimensions.\n createCanvas(displayWidth, displayHeight);\n\n background(200);\n\n describe('A gray canvas that is the same size as the display.');\n}\n
\nA numeric variable that stores the width of the screen display. Its value\ndepends on the current pixelDensity().\ndisplayWidth
is useful for running full-screen programs.
Note: The actual screen width can be computed as\ndisplayWidth * pixelDensity()
.
\nfunction setup() {\n // Set the canvas' width and height\n // using the display's dimensions.\n createCanvas(displayWidth, displayHeight);\n\n background(200);\n\n describe('A gray canvas that is the same size as the display.');\n}\n
\nA numeric variable that stores the height of the screen display. Its value\ndepends on the current pixelDensity().\ndisplayHeight
is useful for running full-screen programs.
Note: The actual screen height can be computed as\ndisplayHeight * pixelDensity()
.
\nfunction setup() {\n // Set the canvas' width and height\n // using the browser's dimensions.\n createCanvas(windowWidth, windowHeight);\n\n background(200);\n\n describe('A gray canvas that takes up the entire browser window.');\n}\n
\n\nfunction setup() {\n // Set the canvas' width and height\n // using the browser's dimensions.\n createCanvas(windowWidth, windowHeight);\n\n background(200);\n\n describe('A gray canvas that takes up the entire browser window.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Display the canvas' width.\n text(width, 42, 54);\n\n describe('The number 100 written in black on a gray square.');\n}\n
\n\nfunction setup() {\n createCanvas(50, 100);\n\n background(200);\n\n // Display the canvas' width.\n text(width, 21, 54);\n\n describe('The number 50 written in black on a gray rectangle.');\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Display the canvas' width.\n text(width, 42, 54);\n\n describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.');\n}\n\n// If the mouse is pressed, reisze\n// the canvas and display its new\n// width.\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n resizeCanvas(50, 100);\n background(200);\n text(width, 21, 54);\n }\n}\n
\nA numeric variable that stores the width of the drawing canvas. Its\ndefault value is 100.
\nCalling createCanvas() or\nresizeCanvas() changes the value of\nwidth
. Calling noCanvas() sets its value to\n0.
\nfunction setup() {\n background(200);\n\n // Display the canvas' height.\n text(height, 42, 54);\n\n describe('The number 100 written in black on a gray square.');\n}\n
\n\nfunction setup() {\n createCanvas(100, 50);\n\n background(200);\n\n // Display the canvas' height.\n text(height, 42, 27);\n\n describe('The number 50 written in black on a gray rectangle.');\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Display the canvas' height.\n text(height, 42, 54);\n\n describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.');\n}\n\n// If the mouse is pressed, reisze\n// the canvas and display its new\n// height.\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n resizeCanvas(100, 50);\n background(200);\n text(height, 42, 27);\n }\n}\n
\nA numeric variable that stores the height of the drawing canvas. Its\ndefault value is 100.
\nCalling createCanvas() or\nresizeCanvas() changes the value of\nheight
. Calling noCanvas() sets its value to\n0.
\n// Move a touchscreen device to register\n// acceleration changes.\nfunction draw() {\n background(220, 50);\n fill('magenta');\n ellipse(width / 2, height / 2, accelerationX);\n describe('Magnitude of device acceleration is displayed as ellipse size.');\n}\n
\n\n// Move a touchscreen device to register\n// acceleration changes.\nfunction draw() {\n background(220, 50);\n fill('magenta');\n ellipse(width / 2, height / 2, accelerationY);\n describe('Magnitude of device acceleration is displayed as ellipse size');\n}\n
\n\n// Move a touchscreen device to register\n// acceleration changes.\nfunction draw() {\n background(220, 50);\n fill('magenta');\n ellipse(width / 2, height / 2, accelerationZ);\n describe('Magnitude of device acceleration is displayed as ellipse size');\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n //rotateZ(radians(rotationZ));\n rotateX(radians(rotationX));\n //rotateY(radians(rotationY));\n box(200, 200, 200);\n describe(`red horizontal line right, green vertical line bottom.\n black background.`);\n}\n
\nThe system variable rotationX always contains the rotation of the\ndevice along the x axis. If the sketch \nangleMode() is set to DEGREES, the value will be -180 to 180. If\nit is set to RADIANS, the value will be -PI to PI.
\nNote: The order the rotations are called is important, ie. if used\ntogether, it must be called in the order Z-X-Y or there might be\nunexpected behaviour.
\n" + }, + { + "itemtype": "property", + "name": "rotationY", + "file": "src/events/acceleration.js", + "line": 196, + "type": "Number", + "module": "Events", + "submodule": "Acceleration", + "class": "p5", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n //rotateZ(radians(rotationZ));\n //rotateX(radians(rotationX));\n rotateY(radians(rotationY));\n box(200, 200, 200);\n describe(`red horizontal line right, green vertical line bottom.\n black background.`);\n}\n
\nThe system variable rotationY always contains the rotation of the\ndevice along the y axis. If the sketch \nangleMode() is set to DEGREES, the value will be -90 to 90. If\nit is set to RADIANS, the value will be -PI/2 to PI/2.
\nNote: The order the rotations are called is important, ie. if used\ntogether, it must be called in the order Z-X-Y or there might be\nunexpected behaviour.
\n" + }, + { + "itemtype": "property", + "name": "rotationZ", + "file": "src/events/acceleration.js", + "line": 233, + "type": "Number", + "module": "Events", + "submodule": "Acceleration", + "class": "p5", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n rotateZ(radians(rotationZ));\n //rotateX(radians(rotationX));\n //rotateY(radians(rotationY));\n box(200, 200, 200);\n describe(`red horizontal line right, green vertical line bottom.\n black background.`);\n}\n
\nThe system variable rotationZ always contains the rotation of the\ndevice along the z axis. If the sketch \nangleMode() is set to DEGREES, the value will be 0 to 360. If\nit is set to RADIANS, the value will be 0 to 2*PI.
\nUnlike rotationX and rotationY, this variable is available for devices\nwith a built-in compass only.
\nNote: The order the rotations are called is important, ie. if used\ntogether, it must be called in the order Z-X-Y or there might be\nunexpected behaviour.
\n" + }, + { + "itemtype": "property", + "name": "pRotationX", + "file": "src/events/acceleration.js", + "line": 277, + "type": "Number", + "module": "Events", + "submodule": "Acceleration", + "class": "p5", + "example": [ + "\n// A simple if statement looking at whether\n// rotationX - pRotationX < 0 is true or not will be\n// sufficient for determining the rotate direction\n// in most cases.\n\n// Some extra logic is needed to account for cases where\n// the angles wrap around.\nlet rotateDirection = 'clockwise';\n\n// Simple range conversion to make things simpler.\n// This is not absolutely necessary but the logic\n// will be different in that case.\n\nlet rX = rotationX + 180;\nlet pRX = pRotationX + 180;\n\nif ((rX - pRX > 0 && rX - pRX < 270) || rX - pRX < -270) {\n rotateDirection = 'clockwise';\n} else if (rX - pRX < 0 || rX - pRX > 270) {\n rotateDirection = 'counter-clockwise';\n}\n\nprint(rotateDirection);\ndescribe('no image to display.');\n
\nThe system variable pRotationX always contains the rotation of the\ndevice along the x axis in the frame previous to the current frame.\nIf the sketch angleMode() is set to DEGREES,\nthe value will be -180 to 180. If it is set to RADIANS, the value will\nbe -PI to PI.
\npRotationX can also be used with rotationX to determine the rotate\ndirection of the device along the X-axis.
\n" + }, + { + "itemtype": "property", + "name": "pRotationY", + "file": "src/events/acceleration.js", + "line": 320, + "type": "Number", + "module": "Events", + "submodule": "Acceleration", + "class": "p5", + "example": [ + "\n// A simple if statement looking at whether\n// rotationY - pRotationY < 0 is true or not will be\n// sufficient for determining the rotate direction\n// in most cases.\n\n// Some extra logic is needed to account for cases where\n// the angles wrap around.\nlet rotateDirection = 'clockwise';\n\n// Simple range conversion to make things simpler.\n// This is not absolutely necessary but the logic\n// will be different in that case.\n\nlet rY = rotationY + 180;\nlet pRY = pRotationY + 180;\n\nif ((rY - pRY > 0 && rY - pRY < 270) || rY - pRY < -270) {\n rotateDirection = 'clockwise';\n} else if (rY - pRY < 0 || rY - pRY > 270) {\n rotateDirection = 'counter-clockwise';\n}\nprint(rotateDirection);\ndescribe('no image to display.');\n
\nThe system variable pRotationY always contains the rotation of the\ndevice along the y axis in the frame previous to the current frame.\nIf the sketch angleMode() is set to DEGREES,\nthe value will be -90 to 90. If it is set to RADIANS, the value will\nbe -PI/2 to PI/2.
\npRotationY can also be used with rotationY to determine the rotate\ndirection of the device along the Y-axis.
\n" + }, + { + "itemtype": "property", + "name": "pRotationZ", + "file": "src/events/acceleration.js", + "line": 359, + "type": "Number", + "module": "Events", + "submodule": "Acceleration", + "class": "p5", + "example": [ + "\n// A simple if statement looking at whether\n// rotationZ - pRotationZ < 0 is true or not will be\n// sufficient for determining the rotate direction\n// in most cases.\n\n// Some extra logic is needed to account for cases where\n// the angles wrap around.\nlet rotateDirection = 'clockwise';\n\nif (\n (rotationZ - pRotationZ > 0 && rotationZ - pRotationZ < 270) ||\n rotationZ - pRotationZ < -270\n) {\n rotateDirection = 'clockwise';\n} else if (rotationZ - pRotationZ < 0 || rotationZ - pRotationZ > 270) {\n rotateDirection = 'counter-clockwise';\n}\nprint(rotateDirection);\ndescribe('no image to display.');\n
\nThe system variable pRotationZ always contains the rotation of the\ndevice along the z axis in the frame previous to the current frame.\nIf the sketch angleMode() is set to DEGREES,\nthe value will be 0 to 360. If it is set to RADIANS, the value will\nbe 0 to 2*PI.
\npRotationZ can also be used with rotationZ to determine the rotate\ndirection of the device along the Z-axis.
\n" + }, + { + "itemtype": "property", + "name": "turnAxis", + "file": "src/events/acceleration.js", + "line": 413, + "type": "String", + "module": "Events", + "submodule": "Acceleration", + "class": "p5", + "example": [ + "\n// Run this example on a mobile device\n// Rotate the device by 90 degrees in the\n// X-axis to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when device turns`);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when x-axis turns`);\n}\nfunction deviceTurned() {\n if (turnAxis === 'X') {\n if (value === 0) {\n value = 255;\n } else if (value === 255) {\n value = 0;\n }\n }\n}\n
\n\nfunction draw() {\n if (keyIsPressed === true) {\n fill(0);\n } else {\n fill(255);\n }\n rect(25, 25, 50, 50);\n describe('50-by-50 white rect that turns black on keypress.');\n}\n
\n\n// Click any key to display it!\n// (Not Guaranteed to be Case Sensitive)\nfunction setup() {\n fill(245, 123, 158);\n textSize(50);\n}\n\nfunction draw() {\n background(200);\n text(key, 33, 65); // Display last key pressed.\n describe('canvas displays any key value that is pressed in pink font.');\n}\n
\nlet fillVal = 126;\nfunction draw() {\n fill(fillVal);\n rect(25, 25, 50, 50);\n describe(`Grey rect center. turns white when up arrow pressed and black when down.\n Display key pressed and its keyCode in a yellow box.`);\n}\n\nfunction keyPressed() {\n if (keyCode === UP_ARROW) {\n fillVal = 255;\n } else if (keyCode === DOWN_ARROW) {\n fillVal = 0;\n }\n}\n
\nfunction draw() {}\nfunction keyPressed() {\n background('yellow');\n text(`${key} ${keyCode}`, 10, 40);\n print(key, ' ', keyCode);\n}\n
\nlet x = 50;\nfunction setup() {\n rectMode(CENTER);\n}\n\nfunction draw() {\n if (x > 48) {\n x -= 2;\n } else if (x < 48) {\n x += 2;\n }\n x += floor(movedX / 5);\n background(237, 34, 93);\n fill(0);\n rect(x, 50, 50, 50);\n describe(`box moves left and right according to mouse movement\n then slowly back towards the center`);\n}\n
\n\nlet y = 50;\nfunction setup() {\n rectMode(CENTER);\n}\n\nfunction draw() {\n if (y > 48) {\n y -= 2;\n } else if (y < 48) {\n y += 2;\n }\n y += floor(movedY / 5);\n background(237, 34, 93);\n fill(0);\n rect(50, y, 50, 50);\n describe(`box moves up and down according to mouse movement then\n slowly back towards the center`);\n}\n
\n\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(mouseX, 0, mouseX, 100);\n describe('horizontal black line moves left and right with mouse x-position');\n}\n
\n\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(0, mouseY, 100, mouseY);\n describe('vertical black line moves up and down with mouse y-position');\n}\n
\n\n// Move the mouse across the canvas to leave a trail\nfunction setup() {\n //slow down the frameRate to make it more visible\n frameRate(10);\n}\n\nfunction draw() {\n background(244, 248, 252);\n line(mouseX, mouseY, pmouseX, pmouseY);\n print(pmouseX + ' -> ' + mouseX);\n describe(`line trail is created from cursor movements.\n faster movement make longer line.`);\n}\n
\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n //draw a square only if the mouse is not moving\n if (mouseY === pmouseY && mouseX === pmouseX) {\n rect(20, 20, 60, 60);\n }\n\n print(pmouseY + ' -> ' + mouseY);\n describe(`60-by-60 black rect center, fuchsia background.\n rect flickers on mouse movement`);\n}\n
\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n let body = document.getElementsByTagName('body')[0];\n myCanvas.parent(body);\n}\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n //move the canvas to the horizontal mouse position\n //relative to the window\n myCanvas.position(winMouseX + 1, windowHeight / 2);\n\n //the y of the square is relative to the canvas\n rect(20, mouseY, 60, 60);\n describe(`60-by-60 black rect y moves with mouse y and fuchsia\n canvas moves with mouse x`);\n}\n
\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n let body = document.getElementsByTagName('body')[0];\n myCanvas.parent(body);\n}\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n //move the canvas to the vertical mouse position\n //relative to the window\n myCanvas.position(windowWidth / 2, winMouseY + 1);\n\n //the x of the square is relative to the canvas\n rect(mouseX, 20, 60, 60);\n describe(`60-by-60 black rect x moves with mouse x and\n fuchsia canvas y moves with mouse y`);\n}\n
\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n noStroke();\n fill(237, 34, 93);\n}\n\nfunction draw() {\n clear();\n //the difference between previous and\n //current x position is the horizontal mouse speed\n let speed = abs(winMouseX - pwinMouseX);\n //change the size of the circle\n //according to the horizontal speed\n ellipse(50, 50, 10 + speed * 5, 10 + speed * 5);\n //move the canvas to the mouse position\n myCanvas.position(winMouseX + 1, winMouseY + 1);\n describe(`fuchsia ellipse moves with mouse x and y.\n Grows and shrinks with mouse speed`);\n}\n
\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n noStroke();\n fill(237, 34, 93);\n}\n\nfunction draw() {\n clear();\n //the difference between previous and\n //current y position is the vertical mouse speed\n let speed = abs(winMouseY - pwinMouseY);\n //change the size of the circle\n //according to the vertical speed\n ellipse(50, 50, 10 + speed * 5, 10 + speed * 5);\n //move the canvas to the mouse position\n myCanvas.position(winMouseX + 1, winMouseY + 1);\n describe(`fuchsia ellipse moves with mouse x and y.\n Grows and shrinks with mouse speed`);\n}\n
\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n if (mouseIsPressed === true) {\n if (mouseButton === LEFT) {\n ellipse(50, 50, 50, 50);\n }\n if (mouseButton === RIGHT) {\n rect(25, 25, 50, 50);\n }\n if (mouseButton === CENTER) {\n triangle(23, 75, 50, 20, 78, 75);\n }\n }\n\n print(mouseButton);\n describe(`50-by-50 black ellipse appears on center of fuchsia\n canvas on mouse click/press.`);\n}\n
\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n if (mouseIsPressed === true) {\n ellipse(50, 50, 50, 50);\n } else {\n rect(25, 25, 50, 50);\n }\n\n print(mouseIsPressed);\n describe(`black 50-by-50 rect becomes ellipse with mouse click/press.\n fuchsia background.`);\n}\n
\n\n// On a touchscreen device, touch\n// the canvas using one or more fingers\n// at the same time\nfunction draw() {\n clear();\n let display = touches.length + ' touches';\n text(display, 5, 10);\n describe(`Number of touches currently registered are displayed\n on the canvas`);\n}\n
\nThe system variable touches[] contains an array of the positions of all\ncurrent touch points, relative to (0, 0) of the canvas, and IDs identifying a\nunique touch as it moves. Each element in the array is an object with x, y,\nand id properties.
\nThe touches[] array is not supported on Safari and IE on touch-based\ndesktops (laptops).
\n" + }, + { + "itemtype": "property", + "name": "pixels", + "file": "src/image/pixels.js", + "line": 104, + "type": "Number[]", + "module": "Image", + "submodule": "Pixels", + "class": "p5", + "example": [ + "\nloadPixels();\nlet x = 50;\nlet y = 50;\nlet d = pixelDensity();\nfor (let i = 0; i < d; i += 1) {\n for (let j = 0; j < d; j += 1) {\n let index = 4 * ((y * d + j) * width * d + (x * d + i));\n // Red.\n pixels[index] = 0;\n // Green.\n pixels[index + 1] = 0;\n // Blue.\n pixels[index + 2] = 0;\n // Alpha.\n pixels[index + 3] = 255;\n }\n}\nupdatePixels();\n\ndescribe('A black dot in the middle of a gray rectangle.');\n
\n\nloadPixels();\nlet d = pixelDensity();\nlet halfImage = 4 * (d * width) * (d * height / 2);\nfor (let i = 0; i < halfImage; i += 4) {\n // Red.\n pixels[i] = 255;\n // Green.\n pixels[i + 1] = 0;\n // Blue.\n pixels[i + 2] = 0;\n // Alpha.\n pixels[i + 3] = 255;\n}\nupdatePixels();\n\ndescribe('A red rectangle drawn above a gray rectangle.');\n
\n\nlet pink = color(255, 102, 204);\nloadPixels();\nlet d = pixelDensity();\nlet halfImage = 4 * (d * width) * (d * height / 2);\nfor (let i = 0; i < halfImage; i += 4) {\n pixels[i] = red(pink);\n pixels[i + 1] = green(pink);\n pixels[i + 2] = blue(pink);\n pixels[i + 3] = alpha(pink);\n}\nupdatePixels();\n\ndescribe('A pink rectangle drawn above a gray rectangle.');\n
\nAn array containing the color of each pixel on the canvas. Colors are\nstored as numbers representing red, green, blue, and alpha (RGBA) values.\npixels
is a one-dimensional array for performance reasons.
Each pixel occupies four elements in the pixels
array, one for each RGBA\nvalue. For example, the pixel at coordinates (0, 0) stores its RGBA values\nat pixels[0]
, pixels[1]
, pixels[2]
, and pixels[3]
, respectively.\nThe next pixel at coordinates (1, 0) stores its RGBA values at pixels[4]
,\npixels[5]
, pixels[6]
, and pixels[7]
. And so on. The pixels
array\nfor a 100×100 canvas has 100 × 100 × 4 = 40,000 elements.
Some displays use several smaller pixels to set the color at a single\npoint. The pixelDensity() function returns\nthe pixel density of the canvas. High density displays often have a\npixelDensity() of 2. On such a display, the\npixels
array for a 100×100 canvas has 200 × 200 × 4 =\n160,000 elements.
Accessing the RGBA values for a point on the canvas requires a little math\nas shown below. The loadPixels() function\nmust be called before accessing the pixels
array. The\nupdatePixels() function must be called\nafter any changes are made.
\np5.disableFriendlyErrors = true;\n\nfunction setup() {\n createCanvas(100, 50);\n}\n
Turn off some features of the friendly error system (FES), which can give\na significant boost to performance when needed.
\nNote that this will disable the parts of the FES that cause performance\nslowdown (like argument checking). Friendly errors that have no performance\ncost (like giving a descriptive error if a file load fails, or warning you\nif you try to override p5.js functions in the global space),\nwill remain in place.
\nSee \ndisabling the friendly error system.
\n" + }, + { + "itemtype": "property", + "name": "src", + "file": "src/dom/dom.js", + "line": 4958, + "module": "DOM", + "submodule": "DOM", + "class": "p5", + "example": [ + "\nlet beat;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n beat = createAudio('assets/beat.mp3');\n\n describe('The text \"https://p5js.org/reference/assets/beat.mp3\" written in black on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n textWrap(CHAR);\n text(beat.src, 10, 10, 80, 80);\n}\n
\n\nlet x = 2;\nconsole.log(x); // prints 2 to the console\nx = 1;\nconsole.log(x); // prints 1 to the console\n
\nCreates and names a new variable. A variable is a container for a value.
\nVariables that are declared with let will have block-scope.\nThis means that the variable only exists within the\n\nblock that it is created within.
\nFrom the MDN entry:\nDeclares a block scope local variable, optionally initializing it to a value.
\n" + }, + { + "itemtype": "property", + "name": "const", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\n// define myFavNumber as a constant and give it the value 7\nconst myFavNumber = 7;\nconsole.log('my favorite number is: ' + myFavNumber);\n
\n\nconst bigCats = ['lion', 'tiger', 'panther'];\nbigCats.push('leopard');\nconsole.log(bigCats);\n// bigCats = ['cat']; // throws error as re-assigning not allowed for const\n
\n\nconst wordFrequency = {};\nwordFrequency['hello'] = 2;\nwordFrequency['bye'] = 1;\nconsole.log(wordFrequency);\n// wordFrequency = { 'a': 2, 'b': 3}; // throws error here\n
\nCreates and names a new constant. Like a variable created with let,\na constant that is created with const is a container for a value,\nhowever constants cannot be reassigned once they are declared. Although it is\nnoteworthy that for non-primitive data types like objects & arrays, their\nelements can still be changeable. So if a variable is assigned an array, you\ncan still add or remove elements from the array but cannot reassign another\narray to it. Also unlike let
, you cannot declare variables without value\nusing const.
Constants have block-scope. This means that the constant only exists within\nthe \nblock that it is created within. A constant cannot be redeclared within a scope in which it\nalready exists.
\nFrom the MDN entry:\nDeclares a read-only named constant.\nConstants are block-scoped, much like variables defined using the 'let' statement.\nThe value of a constant can't be changed through reassignment, and it can't be redeclared.
\n" + }, + { + "itemtype": "property", + "name": "null", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nconsole.log(100 <= 100); // prints true to the console\nconsole.log(99 <= 100); // prints true to the console\n
\nThe less than or equal to operator <=\nevaluates to true if the left value is less than or equal to\nthe right value.
\nThere is more info on comparison operators on MDN.
\n" + }, + { + "itemtype": "property", + "name": "if-else", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nlet a = 4;\nif (a > 0) {\n console.log('positive');\n} else {\n console.log('negative');\n}\n
\nThe if-else statement helps control the flow of your code.
\nA condition is placed between the parenthesis following 'if',\nwhen that condition evalues to truthy,\nthe code between the following curly braces is run.\nAlternatively, when the condition evaluates to falsy,\nthe code between the curly braces of 'else' block is run instead. Writing an\nelse block is optional.
\nFrom the MDN entry:\nThe 'if' statement executes a statement if a specified condition is truthy.\nIf the condition is falsy, another statement can be executed
\n" + }, + { + "itemtype": "property", + "name": "function", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nlet myName = 'Hridi';\nfunction sayHello(name) {\n console.log('Hello ' + name + '!');\n}\nsayHello(myName); // calling the function, prints \"Hello Hridi!\" to console.\n
\n\nlet square = number => number * number;\nconsole.log(square(5));\n
\nCreates and names a function.\nA function is a set of statements that perform a task.
\nOptionally, functions can have parameters. Parameters\nare variables that are scoped to the function, that can be assigned a value\nwhen calling the function.Multiple parameters can be given by seperating them\nwith commmas.
\nFrom the MDN entry:\nDeclares a function with the specified parameters.
\n" + }, + { + "itemtype": "property", + "name": "return", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nfunction calculateSquare(x) {\n return x * x;\n}\nconst result = calculateSquare(4); // returns 16\nconsole.log(result); // prints '16' to the console\n
\n\nlet myBoolean = false;\nconsole.log(typeof myBoolean); // prints 'boolean' to the console\n
\nA boolean is one of the 7 primitive data types in Javascript.\nA boolean can only be true
or false
.
From the MDN entry:\nBoolean represents a logical entity and can have two values: true, and false.
\n" + }, + { + "itemtype": "property", + "name": "string", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nlet mood = 'chill';\nconsole.log(typeof mood); // prints 'string' to the console\n
\nA string is one of the 7 primitive data types in Javascript.\nA string is a series of text characters. In Javascript, a string value must\nbe surrounded by either single-quotation marks(') or double-quotation marks(\").
\nFrom the MDN entry:\nA string is a sequence of characters used to represent text.
\n" + }, + { + "itemtype": "property", + "name": "number", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nlet num = 46.5;\nconsole.log(typeof num); // prints 'number' to the console\n
\nA number is one of the 7 primitive data types in Javascript.\nA number can be a whole number or a decimal number.
\n\n" + }, + { + "itemtype": "property", + "name": "object", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nlet author = {\n name: 'Ursula K Le Guin',\n books: [\n 'The Left Hand of Darkness',\n 'The Dispossessed',\n 'A Wizard of Earthsea'\n ]\n};\nconsole.log(author.name); // prints 'Ursula K Le Guin' to the console\n
\n\nclass Rectangle {\n constructor(name, height, width) {\n this.name = name;\n this.height = height;\n this.width = width;\n }\n}\nlet square = new Rectangle('square', 1, 1); // creating new instance of Polygon Class.\nconsole.log(square.width); // prints '1' to the console\n
\nCreates and names a class which is a template for\nthe creation of objects.
\nFrom the MDN entry:\nThe class declaration creates a new Class with a given name using\nprototype-based inheritance.
\n" + }, + { + "itemtype": "property", + "name": "for", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\nfor (let i = 0; i < 9; i++) {\n console.log(i);\n}\n
\nfor creates a loop that is useful for executing one\nsection of code multiple times.
\nA 'for loop' consists of three different expressions inside of a parenthesis,\nall of which are optional.These expressions are used to control the number of\ntimes the loop is run.The first expression is a statement that is used to set\nthe initial state for the loop.The second expression is a condition that you\nwould like to check before each loop. If this expression returns false then\nthe loop will exit.The third expression is executed at the end of each loop.\nThese expression are separated by ; (semi-colon).In case of an empty expression,\nonly a semi-colon is written.
\nThe code inside of the loop body (in between the curly braces) is executed between the evaluation of the second\nand third expression.
\nAs with any loop, it is important to ensure that the loop can 'exit', or that\nthe test condition will eventually evaluate to false. The test condition with a for loop\nis the second expression detailed above. Ensuring that this expression can eventually\nbecome false ensures that your loop doesn't attempt to run an infinite amount of times,\nwhich can crash your browser.
\nFrom the MDN entry:\nCreates a loop that executes a specified statement until the test condition evaluates to false.\nThe condition is evaluated after executing the statement, resulting in the specified statement executing at least once.
\n" + }, + { + "itemtype": "property", + "name": "while", + "file": "src/core/reference.js", + "line": 1, + "module": "Foundation", + "submodule": "Foundation", + "class": "p5", + "example": [ + "\n// This example logs the lines below to the console\n// 4\n// 3\n// 2\n// 1\n// 0\nlet num = 5;\nwhile (num > 0) {\n num = num - 1;\n console.log(num);\n}\n
\nwhile creates a loop that is useful for executing\none section of code multiple times.
\nWith a 'while loop', the code inside of the loop body (between the curly\nbraces) is run repeatedly until the test condition (inside of the parenthesis)\nevaluates to false. The condition is tested before executing the code body\nwith while, so if the condition is initially false\nthe loop body, or statement, will never execute.
\nAs with any loop, it is important to ensure that the loop can 'exit', or that\nthe test condition will eventually evaluate to false. This is to keep your loop\nfrom trying to run an infinite amount of times, which can crash your browser.
\nFrom the MDN entry:\nThe while statement creates a loop that executes a specified statement as long\nas the test condition evaluates to true.The condition is evaluated before\nexecuting the statement.
\n" + }, + { + "itemtype": "property", + "name": "drawingContext", + "file": "src/core/rendering.js", + "line": 573, + "module": "Rendering", + "submodule": "Rendering", + "class": "p5", + "example": [ + "\nfunction setup() {\n drawingContext.shadowOffsetX = 5;\n drawingContext.shadowOffsetY = -5;\n drawingContext.shadowBlur = 10;\n drawingContext.shadowColor = 'black';\n background(200);\n ellipse(width / 2, height / 2, 50, 50);\n}\n
\ndrawingContext
, as in the example shown. This is\nthe equivalent of calling canvas.getContext('2d');
or canvas.getContext('webgl');
.\nSee this\n\nreference for the native canvas API for possible drawing functions you can call."
+ },
+ {
+ "itemtype": "property",
+ "name": "elt",
+ "file": "src/core/p5.Element.js",
+ "line": 83,
+ "module": "DOM",
+ "submodule": "DOM",
+ "class": "p5.Element",
+ "example": [
+ "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Set the border style for the\n // canvas.\n cnv.elt.style.border = '5px dashed deeppink';\n\n describe('A gray square with a pink border drawn with dashed lines.');\n}\n
\n\n// Use the file input to load a\n// file and display its info.\n\nfunction setup() {\n background(200);\n\n // Create a file input and place it beneath\n // the canvas. Call displayInfo() when\n // the file loads.\n let input = createFileInput(displayInfo);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.');\n}\n\n// Use the p5.File once\n// it loads.\nfunction displayInfo(file) {\n background(200);\n\n // Display the p5.File's name.\n text(file.name, 10, 10, 80, 40);\n // Display the p5.File's type and subtype.\n text(`${file.type}/${file.subtype}`, 10, 70);\n // Display the p5.File's size in bytes.\n text(file.size, 10, 90);\n}\n
\nFile
properties and methods are accessible."
+ },
+ {
+ "itemtype": "property",
+ "name": "type",
+ "file": "src/dom/dom.js",
+ "line": 5235,
+ "module": "DOM",
+ "submodule": "DOM",
+ "class": "p5.File",
+ "example": [
+ "\n// Use the file input to load a\n// file and display its info.\n\nfunction setup() {\n background(200);\n\n // Create a file input and place it beneath\n // the canvas. Call displayType() when\n // the file loads.\n let input = createFileInput(displayType);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user loads a file, its type is written in black.');\n}\n\n// Display the p5.File's type\n// once it loads.\nfunction displayType(file) {\n background(200);\n\n // Display the p5.File's type.\n text(`This is file's type is: ${file.type}`, 10, 10, 80, 80);\n}\n
\n'image'
, 'text'
, and so on."
+ },
+ {
+ "itemtype": "property",
+ "name": "subtype",
+ "file": "src/dom/dom.js",
+ "line": 5235,
+ "module": "DOM",
+ "submodule": "DOM",
+ "class": "p5.File",
+ "example": [
+ "\n// Use the file input to load a\n// file and display its info.\n\nfunction setup() {\n background(200);\n\n // Create a file input and place it beneath\n // the canvas. Call displaySubtype() when\n // the file loads.\n let input = createFileInput(displaySubtype);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user loads a file, its subtype is written in black.');\n}\n\n// Display the p5.File's type\n// once it loads.\nfunction displaySubtype(file) {\n background(200);\n\n // Display the p5.File's subtype.\n text(`This is file's subtype is: ${file.subtype}`, 10, 10, 80, 80);\n}\n
\n'image'
\nMIME type\nmay have a subtype such as png
or jpeg
."
+ },
+ {
+ "itemtype": "property",
+ "name": "name",
+ "file": "src/dom/dom.js",
+ "line": 5235,
+ "module": "DOM",
+ "submodule": "DOM",
+ "class": "p5.File",
+ "example": [
+ "\n// Use the file input to load a\n// file and display its info.\n\nfunction setup() {\n background(200);\n\n // Create a file input and place it beneath\n // the canvas. Call displayName() when\n // the file loads.\n let input = createFileInput(displayName);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user loads a file, its name is written in black.');\n}\n\n// Display the p5.File's name\n// once it loads.\nfunction displayName(file) {\n background(200);\n\n // Display the p5.File's name.\n text(`This is file's name is: ${file.name}`, 10, 10, 80, 80);\n}\n
\n\n// Use the file input to load a\n// file and display its info.\n\nfunction setup() {\n background(200);\n\n // Create a file input and place it beneath\n // the canvas. Call displaySize() when\n // the file loads.\n let input = createFileInput(displaySize);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user loads a file, its size in bytes is written in black.');\n}\n\n// Display the p5.File's size\n// in bytes once it loads.\nfunction displaySize(file) {\n background(200);\n\n // Display the p5.File's size.\n text(`This is file has ${file.size} bytes.`, 10, 10, 80, 80);\n}\n
\n\n// Use the file input to load a\n// file and display its info.\n\nfunction setup() {\n background(200);\n\n // Create a file input and place it beneath\n // the canvas. Call displayData() when\n // the file loads.\n let input = createFileInput(displayData);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user loads a file, its data is written in black.');\n}\n\n// Display the p5.File's data\n// once it loads.\nfunction displayData(file) {\n background(200);\n\n // Display the p5.File's data,\n // which looks like a random\n // string of characters.\n text(file.data, 10, 10, 80, 80);\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let x = img.width / 2;\n let y = img.height / 2;\n let d = 20;\n circle(x, y, d);\n\n describe('An image of a mountain landscape with a white circle drawn in the middle.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let x = img.width / 2;\n let y = img.height / 2;\n let d = 20;\n circle(x, y, d);\n\n describe('An image of a mountain landscape with a white circle drawn in the middle.');\n}\n
\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nlet numPixels = 4 * img.width * img.height;\nfor (let i = 0; i < numPixels; i += 4) {\n // Red.\n img.pixels[i] = 0;\n // Green.\n img.pixels[i + 1] = 0;\n // Blue.\n img.pixels[i + 2] = 0;\n // Alpha.\n img.pixels[i + 3] = 255;\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nlet numPixels = 4 * img.width * img.height;\nfor (let i = 0; i < numPixels; i += 4) {\n // Red.\n img.pixels[i] = 255;\n // Green.\n img.pixels[i + 1] = 0;\n // Blue.\n img.pixels[i + 2] = 0;\n // Alpha.\n img.pixels[i + 3] = 255;\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A red square drawn in the middle of a gray square.');\n
\nAn array containing the color of each pixel in the\np5.Image object. Colors are stored as numbers\nrepresenting red, green, blue, and alpha (RGBA) values. img.pixels
is a\none-dimensional array for performance reasons.
Each pixel occupies four elements in the pixels array, one for each\nRGBA value. For example, the pixel at coordinates (0, 0) stores its\nRGBA values at img.pixels[0]
, img.pixels[1]
, img.pixels[2]
,\nand img.pixels[3]
, respectively. The next pixel at coordinates (1, 0)\nstores its RGBA values at img.pixels[4]
, img.pixels[5]
,\nimg.pixels[6]
, and img.pixels[7]
. And so on. The img.pixels
array\nfor a 100×100 p5.Image object has\n100 × 100 × 4 = 40,000 elements.
Accessing the RGBA values for a pixel in the\np5.Image object requires a little math as\nshown below. The img.loadPixels()\nmethod must be called before accessing the img.pixels
array. The\nimg.updatePixels() method must be\ncalled after any changes are made.
\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //print the column names\n for (let c = 0; c < table.getColumnCount(); c++) {\n print('column ' + c + ' is named ' + table.columns[c]);\n }\n}\n
\n\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(0);\n cam = createCamera();\n div = createDiv();\n div.position(0, 0);\n describe('An example showing the use of camera object properties');\n}\n\nfunction draw() {\n orbitControl();\n box(10);\n div.html('eyeX = ' + cam.eyeX);\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(0);\n cam = createCamera();\n div = createDiv();\n div.position(0, 0);\n describe('An example showing the use of camera object properties');\n}\n\nfunction draw() {\n orbitControl();\n box(10);\n div.html('eyeY = ' + cam.eyeY);\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(0);\n cam = createCamera();\n div = createDiv();\n div.position(0, 0);\n describe('An example showing the use of camera object properties');\n}\n\nfunction draw() {\n orbitControl();\n box(10);\n div.html('eyeZ = ' + cam.eyeZ);\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(255);\n cam = createCamera();\n cam.lookAt(1, 0, 0);\n div = createDiv('centerX = ' + cam.centerX);\n div.position(0, 0);\n div.style('color', 'white');\n describe('An example showing the use of camera object properties');\n}\n\nfunction draw() {\n orbitControl();\n box(10);\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(255);\n cam = createCamera();\n cam.lookAt(0, 1, 0);\n div = createDiv('centerY = ' + cam.centerY);\n div.position(0, 0);\n div.style('color', 'white');\n describe('An example showing the use of camera object properties');\n}\n\nfunction draw() {\n orbitControl();\n box(10);\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(255);\n cam = createCamera();\n cam.lookAt(0, 0, 1);\n div = createDiv('centerZ = ' + cam.centerZ);\n div.position(0, 0);\n div.style('color', 'white');\n describe('An example showing the use of camera object properties');\n}\n\nfunction draw() {\n orbitControl();\n box(10);\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(255);\n cam = createCamera();\n div = createDiv('upX = ' + cam.upX);\n div.position(0, 0);\n div.style('color', 'blue');\n div.style('font-size', '18px');\n describe('An example showing the use of camera object properties');\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(255);\n cam = createCamera();\n div = createDiv('upY = ' + cam.upY);\n div.position(0, 0);\n div.style('color', 'blue');\n div.style('font-size', '18px');\n describe('An example showing the use of camera object properties');\n}\n
\nlet cam, div;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(255);\n cam = createCamera();\n div = createDiv('upZ = ' + cam.upZ);\n div.position(0, 0);\n div.style('color', 'blue');\n div.style('font-size', '18px');\n describe('An example showing the use of camera object properties');\n}\n
\nlet framebuffer;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n framebuffer = createFramebuffer();\n noStroke();\n}\n\nfunction draw() {\n // Draw to the framebuffer\n framebuffer.begin();\n background(255);\n normalMaterial();\n sphere(20);\n framebuffer.end();\n\n // Draw the framebuffer to the main canvas\n image(framebuffer.color, -width/2, -height/2);\n}\n
\nA texture with the color information of the framebuffer. Pass this (or the\nframebuffer itself) to texture() to draw it to\nthe canvas, or pass it to a shader with\nsetUniform() to read its data.
\nSince Framebuffers are controlled by WebGL, their y coordinates are stored\nflipped compared to images and videos. When texturing with a framebuffer\ntexture, you may want to flip vertically, e.g. with\nplane(framebuffer.width, -framebuffer.height)
.
\nlet framebuffer;\nlet depthShader;\n\nconst vert = `\nprecision highp float;\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nvarying vec2 vTexCoord;\nvoid main() {\n vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * viewModelPosition;\n vTexCoord = aTexCoord;\n}\n`;\n\nconst frag = `\nprecision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D depth;\nvoid main() {\n float depthVal = texture2D(depth, vTexCoord).r;\n gl_FragColor = mix(\n vec4(1., 1., 0., 1.), // yellow\n vec4(0., 0., 1., 1.), // blue\n pow(depthVal, 6.)\n );\n}\n`;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n framebuffer = createFramebuffer();\n depthShader = createShader(vert, frag);\n noStroke();\n}\n\nfunction draw() {\n // Draw to the framebuffer\n framebuffer.begin();\n background(255);\n rotateX(frameCount * 0.01);\n box(20, 20, 100);\n framebuffer.end();\n\n push();\n shader(depthShader);\n depthShader.setUniform('depth', framebuffer.depth);\n plane(framebuffer.width, framebuffer.height);\n pop();\n}\n
\nA texture with the depth information of the framebuffer. If the framebuffer\nwas created with { depth: false }
in its settings, then this property will\nbe undefined. Pass this to texture() to draw it to\nthe canvas, or pass it to a shader with\nsetUniform() to read its data.
Since Framebuffers are controlled by WebGL, their y coordinates are stored\nflipped compared to images and videos. When texturing with a framebuffer\ntexture, you may want to flip vertically, e.g. with\nplane(framebuffer.width, -framebuffer.height)
.
A Uint8ClampedArray\ncontaining the values for all the pixels in the Framebuffer.
\nLike the main canvas pixels property, call\nloadPixels() before reading\nit, and call updatePixels()\nafterwards to update its data.
\nNote that updating pixels via this property will be slower than\ndrawing to the framebuffer directly.\nConsider using a shader instead of looping over pixels.
\n" + }, + { + "name": "describe", + "file": "src/accessibility/describe.js", + "line": 120, + "itemtype": "method", + "description": "Creates a screen reader-accessible description for the canvas.
\nThe first parameter, text
, is the description of the canvas.
The second parameter, display
, is optional. It determines how the\ndescription is displayed. If LABEL
is passed, as in\ndescribe('A description.', LABEL)
, the description will be visible in\na div element next to the canvas. If FALLBACK
is passed, as in\ndescribe('A description.', FALLBACK)
, the description will only be\nvisible to screen readers. This is the default mode.
Read\nHow to label your p5.js code to\nlearn more about making sketches accessible.
\n", + "example": [ + "\nfunction setup() {\n background('pink');\n\n // Draw a heart.\n fill('red');\n noStroke();\n circle(67, 67, 20);\n circle(83, 67, 20);\n triangle(91, 73, 75, 95, 59, 73);\n\n // Add a general description of the canvas.\n describe('A pink square with a red heart in the bottom-right corner.');\n}\n
\n\nfunction setup() {\n background('pink');\n\n // Draw a heart.\n fill('red');\n noStroke();\n circle(67, 67, 20);\n circle(83, 67, 20);\n triangle(91, 73, 75, 95, 59, 73);\n\n // Add a general description of the canvas\n // and display it for debugging.\n describe('A pink square with a red heart in the bottom-right corner.', LABEL);\n}\n
\n\nfunction draw() {\n background(200);\n\n // The expression\n // frameCount % 100\n // causes x to increase from 0\n // to 99, then restart from 0.\n let x = frameCount % 100;\n\n // Draw the circle.\n fill(0, 255, 0);\n circle(x, 50, 40);\n\n // Add a general description of the canvas.\n describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`);\n}\n
\n\nfunction draw() {\n background(200);\n\n // The expression\n // frameCount % 100\n // causes x to increase from 0\n // to 99, then restart from 0.\n let x = frameCount % 100;\n\n // Draw the circle.\n fill(0, 255, 0);\n circle(x, 50, 40);\n\n // Add a general description of the canvas\n // and display it for debugging.\n describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`, LABEL);\n}\n
\nCreates a screen reader-accessible description for elements in the canvas.\nElements are shapes or groups of shapes that create meaning together.
\nThe first parameter, name
, is the name of the element.
The second parameter, text
, is the description of the element.
The third parameter, display
, is optional. It determines how the\ndescription is displayed. If LABEL
is passed, as in\ndescribe('A description.', LABEL)
, the description will be visible in\na div element next to the canvas. Using LABEL
creates unhelpful\nduplicates for screen readers. Only use LABEL
during development. If\nFALLBACK
is passed, as in describe('A description.', FALLBACK)
, the\ndescription will only be visible to screen readers. This is the default\nmode.
Read\nHow to label your p5.js code to\nlearn more about making sketches accessible.
\n", + "example": [ + "\nfunction setup() {\n background('pink');\n\n // Describe the first element\n // and draw it.\n describeElement('Circle', 'A yellow circle in the top-left corner.');\n noStroke();\n fill('yellow');\n circle(25, 25, 40);\n\n // Describe the second element\n // and draw it.\n describeElement('Heart', 'A red heart in the bottom-right corner.');\n fill('red');\n circle(66.6, 66.6, 20);\n circle(83.2, 66.6, 20);\n triangle(91.2, 72.6, 75, 95, 58.6, 72.6);\n\n // Add a general description of the canvas.\n describe('A red heart and yellow circle over a pink background.');\n}\n
\n\nfunction setup() {\n background('pink');\n\n // Describe the first element\n // and draw it. Display the\n // description for debugging.\n describeElement('Circle', 'A yellow circle in the top-left corner.', LABEL);\n noStroke();\n fill('yellow');\n circle(25, 25, 40);\n\n // Describe the second element\n // and draw it. Display the\n // description for debugging.\n describeElement('Heart', 'A red heart in the bottom-right corner.', LABEL);\n fill('red');\n circle(66.6, 66.6, 20);\n circle(83.2, 66.6, 20);\n triangle(91.2, 72.6, 75, 95, 58.6, 72.6);\n\n // Add a general description of the canvas.\n describe('A red heart and yellow circle over a pink background.');\n}\n
\nCreates a screen reader-accessible description for shapes on the canvas.\ntextOutput()
adds a general description, list of shapes, and\ntable of shapes to the web page.
The general description includes the canvas size, canvas color, and number\nof shapes. For example,\nYour output is a, 100 by 100 pixels, gray canvas containing the following 2 shapes:
.
A list of shapes follows the general description. The list describes the\ncolor, location, and area of each shape. For example,\na red circle at middle covering 3% of the canvas
. Each shape can be\nselected to get more details.
textOutput()
uses its table of shapes as a list. The table describes the\nshape, color, location, coordinates and area. For example,\nred circle location = middle area = 3%
. This is different from\ngridOutput(), which uses its table as a grid.
The display
parameter is optional. It determines how the description is\ndisplayed. If LABEL
is passed, as in textOutput(LABEL)
, the description\nwill be visible in a div element next to the canvas. Using LABEL
creates\nunhelpful duplicates for screen readers. Only use LABEL
during\ndevelopment. If FALLBACK
is passed, as in textOutput(FALLBACK)
, the\ndescription will only be visible to screen readers. This is the default\nmode.
Read\nHow to label your p5.js code to\nlearn more about making sketches accessible.
\n", + "example": [ + "\nfunction setup() {\n // Add the text description.\n textOutput();\n\n // Draw a couple of shapes.\n background(200);\n fill(255, 0, 0);\n circle(20, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle and a blue square on a gray background.');\n}\n
\n\nfunction setup() {\n // Add the text description and\n // display it for debugging.\n textOutput(LABEL);\n\n // Draw a couple of shapes.\n background(200);\n fill(255, 0, 0);\n circle(20, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle and a blue square on a gray background.');\n}\n
\n\nfunction draw() {\n // Add the text description.\n textOutput();\n\n // Draw a moving circle.\n background(200);\n let x = frameCount * 0.1;\n fill(255, 0, 0);\n circle(x, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle moves from left to right above a blue square.');\n}\n
\n\nfunction draw() {\n // Add the text description and\n // display it for debugging.\n textOutput(LABEL);\n\n // Draw a moving circle.\n background(200);\n let x = frameCount * 0.1;\n fill(255, 0, 0);\n circle(x, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle moves from left to right above a blue square.');\n}\n
\nCreates a screen reader-accessible description for shapes on the canvas.\ngridOutput()
adds a general description, table of shapes, and list of\nshapes to the web page.
The general description includes the canvas size, canvas color, and number of\nshapes. For example,\ngray canvas, 100 by 100 pixels, contains 2 shapes: 1 circle 1 square
.
gridOutput()
uses its table of shapes as a grid. Each shape in the grid\nis placed in a cell whose row and column correspond to the shape's location\non the canvas. The grid cells describe the color and type of shape at that\nlocation. For example, red circle
. These descriptions can be selected\nindividually to get more details. This is different from\ntextOutput(), which uses its table as a list.
A list of shapes follows the table. The list describes the color, type,\nlocation, and area of each shape. For example,\nred circle, location = middle, area = 3 %
.
The display
parameter is optional. It determines how the description is\ndisplayed. If LABEL
is passed, as in gridOutput(LABEL)
, the description\nwill be visible in a div element next to the canvas. Using LABEL
creates\nunhelpful duplicates for screen readers. Only use LABEL
during\ndevelopment. If FALLBACK
is passed, as in gridOutput(FALLBACK)
, the\ndescription will only be visible to screen readers. This is the default\nmode.
Read\nHow to label your p5.js code to\nlearn more about making sketches accessible.
\n", + "example": [ + "\nfunction setup() {\n // Add the grid description.\n gridOutput();\n\n // Draw a couple of shapes.\n background(200);\n fill(255, 0, 0);\n circle(20, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle and a blue square on a gray background.');\n}\n
\n\nfunction setup() {\n // Add the grid description and\n // display it for debugging.\n gridOutput(LABEL);\n\n // Draw a couple of shapes.\n background(200);\n fill(255, 0, 0);\n circle(20, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle and a blue square on a gray background.');\n}\n
\n\nfunction draw() {\n // Add the grid description.\n gridOutput();\n\n // Draw a moving circle.\n background(200);\n let x = frameCount * 0.1;\n fill(255, 0, 0);\n circle(x, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle moves from left to right above a blue square.');\n}\n
\n\nfunction draw() {\n // Add the grid description and\n // display it for debugging.\n gridOutput(LABEL);\n\n // Draw a moving circle.\n background(200);\n let x = frameCount * 0.1;\n fill(255, 0, 0);\n circle(x, 20, 20);\n fill(0, 0, 255);\n square(50, 50, 50);\n\n // Add a general description of the canvas.\n describe('A red circle moves from left to right above a blue square.');\n}\n
\nThe p5()
constructor enables you to activate \"instance mode\" instead of normal\n\"global mode\". This is an advanced topic. A short description and example is\nincluded below. Please see\n\nDan Shiffman's Coding Train video tutorial or this\ntutorial page\nfor more info.
By default, all p5.js functions are in the global namespace (i.e. bound to the window\nobject), meaning you can call them simply ellipse()
, fill()
, etc. However, this\nmight be inconvenient if you are mixing with other JS libraries (synchronously or\nasynchronously) or writing long programs of your own. p5.js currently supports a\nway around this problem called \"instance mode\". In instance mode, all p5 functions\nare bound up in a single variable instead of polluting your global namespace.
Optionally, you can specify a default container for the canvas and any other elements\nto append to with a second argument. You can give the ID of an element in your html,\nor an html node itself.
\nNote that creating instances like this also allows you to have more than one p5 sketch on\na single web page, as they will each be wrapped up with their own set up variables. Of\ncourse, you could also use iframes to have multiple sketches in global mode.
\n", + "example": [ + "\nconst s = p => {\n let x = 100;\n let y = 100;\n\n p.setup = function() {\n p.createCanvas(700, 410);\n };\n\n p.draw = function() {\n p.background(0);\n p.fill(255);\n p.rect(x, y, 50, 50);\n };\n};\n\nnew p5(s); // invoke p5\n
\nnoStroke();\nconst c = color(0, 126, 255, 102);\nfill(c);\nrect(15, 15, 35, 70);\n// Sets 'alphaValue' to 102.\nconst alphaValue = alpha(c);\nfill(alphaValue);\nrect(50, 15, 35, 70);\ndescribe('Two rectangles. The left one is light blue and the right one is charcoal gray.');\n
\n\nconst c = color(175, 100, 220);\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'blueValue' to 220.\nconst blueValue = blue(c);\nfill(0, 0, blueValue);\nrect(50, 20, 35, 60);\ndescribe('Two rectangles. The left one is light purple and the right one is royal blue.');\n
\n\nnoStroke();\ncolorMode(HSB, 255);\nconst c = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'brightValue' to 255.\nconst brightValue = brightness(c);\nfill(brightValue);\nrect(50, 20, 35, 60);\ndescribe('Two rectangles. The left one is salmon pink and the right one is white.');\n
\n\nnoStroke();\ncolorMode(HSB, 255);\nconst c = color('hsb(60, 100%, 50%)');\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'brightValue' to 127.5 (50% of 255)\nconst brightValue = brightness(c);\nfill(brightValue);\nrect(50, 20, 35, 60);\ndescribe('Two rectangles. The left one is olive and the right one is gray.');\n
\nCreates a p5.Color object. By default, the\nparameters are interpreted as RGB values. Calling color(255, 204, 0)
will\nreturn a bright yellow color. The way these parameters are interpreted may\nbe changed with the colorMode() function.
The version of color()
with one parameter interprets the value one of two\nways. If the parameter is a number, it's interpreted as a grayscale value.\nIf the parameter is a string, it's interpreted as a CSS color string.
The version of color()
with two parameters interprets the first one as a\ngrayscale value. The second parameter sets the alpha (transparency) value.
The version of color()
with three parameters interprets them as RGB, HSB,\nor HSL colors, depending on the current colorMode()
.
The version of color()
with four parameters interprets them as RGBA, HSBA,\nor HSLA colors, depending on the current colorMode()
. The last parameter\nsets the alpha (transparency) value.
\nconst c = color(255, 204, 0);\nfill(c);\nnoStroke();\nrect(30, 20, 55, 55);\ndescribe('A yellow rectangle on a gray canvas.');\n
\n\n// RGB values.\nlet c = color(255, 204, 0);\nfill(c);\nnoStroke();\ncircle(25, 25, 80);\n// A grayscale value.\nc = color(65);\nfill(c);\ncircle(75, 75, 80);\ndescribe(\n 'Two ellipses. The circle in the top-left corner is yellow and the one at the bottom-right is gray.'\n);\n
\n\n// A CSS named color.\nconst c = color('magenta');\nfill(c);\nnoStroke();\nsquare(20, 20, 60);\ndescribe('A magenta square on a gray canvas.');\n
\n\n// CSS hex color codes.\nnoStroke();\nlet c = color('#0f0');\nfill(c);\nrect(0, 10, 45, 80);\nc = color('#00ff00');\nfill(c);\nrect(55, 10, 45, 80);\ndescribe('Two bright green rectangles on a gray canvas.');\n
\n\n// RGB and RGBA color strings.\nnoStroke();\nlet c = color('rgb(0,0,255)');\nfill(c);\nsquare(10, 10, 35);\nc = color('rgb(0%, 0%, 100%)');\nfill(c);\nsquare(55, 10, 35);\nc = color('rgba(0, 0, 255, 1)');\nfill(c);\nsquare(10, 55, 35);\nc = color('rgba(0%, 0%, 100%, 1)');\nfill(c);\nsquare(55, 55, 35);\ndescribe('Four blue squares in corners of a gray canvas.');\n
\n\n// HSL and HSLA color strings.\nlet c = color('hsl(160, 100%, 50%)');\nnoStroke();\nfill(c);\nrect(0, 10, 45, 80);\nc = color('hsla(160, 100%, 50%, 0.5)');\nfill(c);\nrect(55, 10, 45, 80);\ndescribe('Two sea green rectangles. A darker rectangle on the left and a brighter one on the right.');\n
\n\n// HSB and HSBA color strings.\nlet c = color('hsb(160, 100%, 50%)');\nnoStroke();\nfill(c);\nrect(0, 10, 45, 80);\nc = color('hsba(160, 100%, 50%, 0.5)');\nfill(c);\nrect(55, 10, 45, 80);\ndescribe('Two green rectangles. A darker rectangle on the left and a brighter one on the right.');\n
\n\n// Changing color modes.\nnoStroke();\nlet c = color(50, 55, 100);\nfill(c);\nrect(0, 10, 45, 80);\ncolorMode(HSB, 100);\nc = color(50, 55, 100);\nfill(c);\nrect(55, 10, 45, 80);\ndescribe('Two blue rectangles. A darker rectangle on the left and a brighter one on the right.');\n
\n\nconst c = color(20, 75, 200);\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'greenValue' to 75.\nconst greenValue = green(c);\nfill(0, greenValue, 0);\nrect(50, 20, 35, 60);\ndescribe('Two rectangles. The rectangle on the left is blue and the one on the right is green.');\n
\nExtracts the hue value from a\np5.Color object, array of color components, or\nCSS color string.
\nHue exists in both HSB and HSL. It describes a color's position on the\ncolor wheel. By default, this function returns the HSL-normalized hue. If\nthe colorMode() is set to HSB, it returns the\nHSB-normalized hue.
\n", + "example": [ + "\nnoStroke();\ncolorMode(HSB, 255);\nconst c = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'hueValue' to 0.\nconst hueValue = hue(c);\nfill(hueValue);\nrect(50, 20, 35, 60);\ndescribe(\n 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.'\n);\n
\nBlends two colors to find a third color between them. The amt
parameter\nspecifies the amount to interpolate between the two values. 0 is equal to\nthe first color, 0.1 is very near the first color, 0.5 is halfway between\nthe two colors, and so on. Negative numbers are set to 0. Numbers greater\nthan 1 are set to 1. This differs from the behavior of\nlerp. It's necessary because numbers outside of the\ninterval [0, 1] will produce strange and unexpected colors.
The way that colors are interpolated depends on the current\ncolorMode().
\n", + "example": [ + "\ncolorMode(RGB);\nstroke(255);\nbackground(51);\nconst from = color(218, 165, 32);\nconst to = color(72, 61, 139);\ncolorMode(RGB);\nconst interA = lerpColor(from, to, 0.33);\nconst interB = lerpColor(from, to, 0.66);\nfill(from);\nrect(10, 20, 20, 60);\nfill(interA);\nrect(30, 20, 20, 60);\nfill(interB);\nrect(50, 20, 20, 60);\nfill(to);\nrect(70, 20, 20, 60);\ndescribe(\n 'Four rectangles with white edges. From left to right, the rectangles are tan, brown, brownish purple, and purple.'\n);\n
\n\nnoStroke();\ncolorMode(HSL);\nconst c = color(156, 100, 50, 1);\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'lightValue' to 50.\nconst lightValue = lightness(c);\nfill(lightValue);\nrect(50, 20, 35, 60);\ndescribe('Two rectangles. The rectangle on the left is light green and the one on the right is gray.');\n
\n\nconst c = color(255, 204, 0);\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'redValue' to 255.\nconst redValue = red(c);\nfill(redValue, 0, 0);\nrect(50, 20, 35, 60);\ndescribe(\n 'Two rectangles with black edges. The rectangle on the left is yellow and the one on the right is red.'\n);\n
\nExtracts the saturation value from a\np5.Color object, array of color components, or\nCSS color string.
\nSaturation is scaled differently in HSB and HSL. By default, this function\nreturns the HSL saturation. If the colorMode()\nis set to HSB, it returns the HSB saturation.
\n", + "example": [ + "\nnoStroke();\ncolorMode(HSB, 255);\nconst c = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\n// Sets 'satValue' to 126.\nconst satValue = saturation(c);\nfill(satValue);\nrect(50, 20, 35, 60);\ndescribe(\n 'Two rectangles. The rectangle on the left is deep pink and the one on the right is gray.'\n);\n
\nStart defining a shape that will mask subsequent things drawn to the canvas.\nOnly opaque regions of the mask shape will allow content to be drawn.\nAny shapes drawn between this and endClip() will\ncontribute to the mask shape.
\nThe mask will apply to anything drawn after this call. To draw without a mask, contain\nthe code to apply the mask and to draw the masked content between\npush() and pop().
\nAlternatively, rather than drawing the mask between this and\nendClip(), draw the mask in a callback function\npassed to clip().
\nOptions can include:
\ninvert
: A boolean specifying whether or not to mask the areas not filled by the mask shape. Defaults to false.\nnoStroke();\n\n// Mask in some shapes\npush();\nbeginClip();\ntriangle(15, 37, 30, 13, 43, 37);\ncircle(45, 45, 7);\nendClip();\n\nfill('red');\nrect(5, 5, 45, 45);\npop();\n\ntranslate(50, 50);\n\n// Mask out the same shapes\npush();\nbeginClip({ invert: true });\ntriangle(15, 37, 30, 13, 43, 37);\ncircle(45, 45, 7);\nendClip();\n\nfill('red');\nrect(5, 5, 45, 45);\npop();\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(255);\n noStroke();\n\n beginClip();\n push();\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n scale(0.5);\n torus(30, 15);\n pop();\n endClip();\n\n beginShape(QUAD_STRIP);\n fill(0, 255, 255);\n vertex(-width/2, -height/2);\n vertex(width/2, -height/2);\n fill(100, 0, 100);\n vertex(-width/2, height/2);\n vertex(width/2, height/2);\n endShape();\n}\n
\nUse the shape drawn by a callback function to mask subsequent things drawn to the canvas.\nOnly opaque regions of the mask shape will allow content to be drawn.
\nThe mask will apply to anything drawn after this call. To draw without a mask, contain\nthe code to apply the mask and to draw the masked content between\npush() and pop().
\nAlternatively, rather than drawing the mask shape in a function, draw the\nshape between beginClip() and endClip().
\nOptions can include:
\ninvert
: A boolean specifying whether or not to mask the areas not filled by the mask shape. Defaults to false.\nnoStroke();\n\n// Mask in some shapes\npush();\nclip(() => {\n triangle(15, 37, 30, 13, 43, 37);\n circle(45, 45, 7);\n});\n\nfill('red');\nrect(5, 5, 45, 45);\npop();\n\ntranslate(50, 50);\n\n// Mask out the same shapes\npush();\nclip(() => {\n triangle(15, 37, 30, 13, 43, 37);\n circle(45, 45, 7);\n}, { invert: true });\n\nfill('red');\nrect(5, 5, 45, 45);\npop();\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(255);\n noStroke();\n\n clip(() => {\n push();\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n scale(0.5);\n torus(30, 15);\n pop();\n });\n\n beginShape(QUAD_STRIP);\n fill(0, 255, 255);\n vertex(-width/2, -height/2);\n vertex(width/2, -height/2);\n fill(100, 0, 100);\n vertex(-width/2, height/2);\n vertex(width/2, height/2);\n endShape();\n}\n
\nSets the color used for the background of the canvas. By default, the\nbackground is transparent. This function is typically used within\ndraw() to clear the display window at the beginning\nof each frame. It can also be used inside setup() to\nset the background on the first frame of animation.
\nThe version of background()
with one parameter interprets the value one of four\nways. If the parameter is a number, it's interpreted as a grayscale value.\nIf the parameter is a string, it's interpreted as a CSS color string. RGB, RGBA,\nHSL, HSLA, hex, and named color strings are supported. If the parameter is a\np5.Color object, it will be used as the background color.\nIf the parameter is a p5.Image object, it will be used as\nthe background image.
The version of background()
with two parameters interprets the first one as a\ngrayscale value. The second parameter sets the alpha (transparency) value.
The version of background()
with three parameters interprets them as RGB, HSB,\nor HSL colors, depending on the current colorMode().\nBy default, colors are specified in RGB values. Calling background(255, 204, 0)\nsets the background a bright yellow color.
\n// A grayscale integer value.\nbackground(51);\ndescribe('A canvas with a dark charcoal gray background.');\n
\n\n// A grayscale integer value and an alpha value.\nbackground(51, 0.4);\ndescribe('A canvas with a transparent gray background.');\n
\n\n// R, G & B integer values.\nbackground(255, 204, 0);\ndescribe('A canvas with a yellow background.');\n
\n\n// H, S & B integer values.\ncolorMode(HSB);\nbackground(255, 204, 100);\ndescribe('A canvas with a royal blue background.');\n
\n\n// A CSS named color.\nbackground('red');\ndescribe('A canvas with a red background.');\n
\n\n// Three-digit hex RGB notation.\nbackground('#fae');\ndescribe('A canvas with a pink background.');\n
\n\n// Six-digit hex RGB notation.\nbackground('#222222');\ndescribe('A canvas with a black background.');\n
\n\n// Integer RGB notation.\nbackground('rgb(0,255,0)');\ndescribe('A canvas with a bright green background.');\n
\n\n// Integer RGBA notation.\nbackground('rgba(0,255,0, 0.25)');\ndescribe('A canvas with a transparent green background.');\n
\n\n// Percentage RGB notation.\nbackground('rgb(100%,0%,10%)');\ndescribe('A canvas with a red background.');\n
\n\n// Percentage RGBA notation.\nbackground('rgba(100%,0%,100%,0.5)');\ndescribe('A canvas with a transparent purple background.');\n
\n\n// A p5.Color object.\nlet c = color(0, 0, 255);\nbackground(c);\ndescribe('A canvas with a blue background.');\n
\nClears the pixels on the canvas. This function makes every pixel 100%\ntransparent. Calling clear()
doesn't clear objects created by createX()
\nfunctions such as createGraphics(),\ncreateVideo(), and\ncreateImg(). These objects will remain\nunchanged after calling clear() and can be redrawn.
In WebGL mode, this function can clear the screen to a specific color. It\ninterprets four numeric parameters as normalized RGBA color values. It also\nclears the depth buffer. If you are not using the WebGL renderer, these\nparameters will have no effect.
\n", + "example": [ + "\nfunction draw() {\n circle(mouseX, mouseY, 20);\n describe('A white circle is drawn at the mouse x- and y-coordinates.');\n}\n\nfunction mousePressed() {\n clear();\n background(128);\n describe('The canvas is cleared when the mouse is clicked.');\n}\n
\n\nlet pg;\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n\n pg = createGraphics(60, 60);\n pg.background(200);\n pg.noStroke();\n pg.circle(pg.width / 2, pg.height / 2, 15);\n image(pg, 20, 20);\n describe('A white circle drawn on a gray square. The square gets smaller when the mouse is pressed.');\n}\n\nfunction mousePressed() {\n clear();\n image(pg, 20, 20);\n}\n
\n\n// create writer object\nlet writer = createWriter('newFile.txt');\nwriter.write(['clear me']);\n// clear writer object here\nwriter.clear();\n// close writer\nwriter.close();\n
\nfunction setup() {\n button = createButton('CLEAR ME');\n button.position(21, 40);\n button.mousePressed(createFile);\n}\n\nfunction createFile() {\n let writer = createWriter('newFile.txt');\n writer.write(['clear me']);\n writer.clear();\n writer.close();\n}\n
\nChanges the way p5.js interprets color data. By default, the numeric\nparameters for fill(),\nstroke(),\nbackground(), and\ncolor() are defined by values between 0 and 255\nusing the RGB color model. This is equivalent to calling\ncolorMode(RGB, 255)
. Pure red is color(255, 0, 0)
in this model.
Calling colorMode(RGB, 100)
sets colors to be interpreted as RGB color\nvalues between 0 and 100. Pure red is color(100, 0, 0)
in this model.
Calling colorMode(HSB)
or colorMode(HSL)
changes to HSB or HSL system\ninstead of RGB.
p5.Color objects remember the mode that they were\ncreated in. Changing modes doesn't affect their appearance.
\n", + "example": [ + "\nnoStroke();\ncolorMode(RGB, 100);\nfor (let i = 0; i < 100; i += 1) {\n for (let j = 0; j < 100; j += 1) {\n stroke(i, j, 0);\n point(i, j);\n }\n}\ndescribe(\n 'A diagonal green to red gradient from bottom-left to top-right with shading transitioning to black at top-left corner.'\n);\n
\n\nnoStroke();\ncolorMode(HSB, 100);\nfor (let i = 0; i < 100; i++) {\n for (let j = 0; j < 100; j++) {\n stroke(i, j, 100);\n point(i, j);\n }\n}\ndescribe('A rainbow gradient from left-to-right. Brightness transitions to white at the top.');\n
\n\ncolorMode(RGB, 255);\nlet myColor = color(180, 175, 230);\nbackground(myColor);\ncolorMode(RGB, 1);\nlet redValue = red(myColor);\nlet greenValue = green(myColor);\nlet blueValue = blue(myColor);\ntext(`Red: ${redValue}`, 10, 10, 80, 80);\ntext(`Green: ${greenValue}`, 10, 40, 80, 80);\ntext(`Blue: ${blueValue}`, 10, 70, 80, 80);\ndescribe('A purple canvas with the red, green, and blue decimal values of the color written on it.');\n
\n\nnoFill();\ncolorMode(RGB, 255, 255, 255, 1);\nbackground(255);\nstrokeWeight(4);\nstroke(255, 0, 10, 0.3);\ncircle(40, 40, 50);\ncircle(50, 60, 50);\ndescribe('Two overlapping translucent pink circle outlines.');\n
\nSets the color used to fill shapes. Calling fill(255, 165, 0)
or\nfill('orange')
means all shapes drawn after the fill command will be\nfilled with the color orange.
The version of fill()
with one parameter interprets the value one of\nthree ways. If the parameter is a number, it's interpreted as a grayscale\nvalue. If the parameter is a string, it's interpreted as a CSS color\nstring. A p5.Color object can also be provided to\nset the fill color.
The version of fill()
with three parameters interprets them as RGB, HSB,\nor HSL colors, depending on the current\ncolorMode(). The default color space is RGB,\nwith each value in the range from 0 to 255.
\n// Grayscale integer value.\nfill(51);\nsquare(20, 20, 60);\ndescribe('A dark charcoal gray square with a black outline.');\n
\n\n// R, G & B integer values.\nfill(255, 204, 0);\nsquare(20, 20, 60);\ndescribe('A yellow square with a black outline.');\n
\n\n// H, S & B integer values.\ncolorMode(HSB);\nfill(255, 204, 100);\nsquare(20, 20, 60);\ndescribe('A royal blue square with a black outline.');\n
\n\n// A CSS named color.\nfill('red');\nsquare(20, 20, 60);\ndescribe('A red square with a black outline.');\n
\n\n// Three-digit hex RGB notation.\nfill('#fae');\nsquare(20, 20, 60);\ndescribe('A pink square with a black outline.');\n
\n\n// Six-digit hex RGB notation.\nfill('#A251FA');\nsquare(20, 20, 60);\ndescribe('A purple square with a black outline.');\n
\n\n// Integer RGB notation.\nfill('rgb(0,255,0)');\nsquare(20, 20, 60);\ndescribe('A bright green square with a black outline.');\n
\n\n// Integer RGBA notation.\nfill('rgba(0,255,0, 0.25)');\nsquare(20, 20, 60);\ndescribe('A soft green rectange with a black outline.');\n
\n\n// Percentage RGB notation.\nfill('rgb(100%,0%,10%)');\nsquare(20, 20, 60);\ndescribe('A red square with a black outline.');\n
\n\n// Percentage RGBA notation.\nfill('rgba(100%,0%,100%,0.5)');\nsquare(20, 20, 60);\ndescribe('A dark fuchsia square with a black outline.');\n
\n\n// p5.Color object.\nlet c = color(0, 0, 255);\nfill(c);\nsquare(20, 20, 60);\ndescribe('A blue square with a black outline.');\n
\n\nsquare(32, 10, 35);\nnoFill();\nsquare(32, 55, 35);\ndescribe('A white square on top of an empty square. Both squares have black outlines.');\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(0);\n noFill();\n stroke(100, 100, 240);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(45, 45, 45);\n describe('A purple cube wireframe spinning on a black canvas.');\n}\n
\n\nnoStroke();\nsquare(20, 20, 60);\ndescribe('A white square with no outline.');\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(0);\n noStroke();\n fill(240, 150, 150);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(45, 45, 45);\n describe('A pink cube with no edge outlines spinning on a black canvas.');\n}\n
\nSets the color used to draw lines and borders around shapes. Calling\nstroke(255, 165, 0)
or stroke('orange')
means all shapes drawn after\nthe stroke()
command will be filled with the color orange. The way these\nparameters are interpreted may be changed with the\ncolorMode() function.
The version of stroke()
with one parameter interprets the value one of\nthree ways. If the parameter is a number, it's interpreted as a grayscale\nvalue. If the parameter is a string, it's interpreted as a CSS color\nstring. A p5.Color object can also be provided to\nset the stroke color.
The version of stroke()
with two parameters interprets the first one as a\ngrayscale value. The second parameter sets the alpha (transparency) value.
The version of stroke()
with three parameters interprets them as RGB, HSB,\nor HSL colors, depending on the current colorMode()
.
The version of stroke()
with four parameters interprets them as RGBA, HSBA,\nor HSLA colors, depending on the current colorMode()
. The last parameter\nsets the alpha (transparency) value.
\n// Grayscale integer value.\nstrokeWeight(4);\nstroke(51);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a dark charcoal gray outline.');\n
\n\n// R, G & B integer values.\nstroke(255, 204, 0);\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a yellow outline.');\n
\n\n// H, S & B integer values.\ncolorMode(HSB);\nstrokeWeight(4);\nstroke(255, 204, 100);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a royal blue outline.');\n
\n\n// A CSS named color.\nstroke('red');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a red outline.');\n
\n\n// Three-digit hex RGB notation.\nstroke('#fae');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a pink outline.');\n
\n\n// Six-digit hex RGB notation.\nstroke('#222222');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a black outline.');\n
\n\n// Integer RGB notation.\nstroke('rgb(0,255,0)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A whiite rectangle with a bright green outline.');\n
\n\n// Integer RGBA notation.\nstroke('rgba(0,255,0,0.25)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a soft green outline.');\n
\n\n// Percentage RGB notation.\nstroke('rgb(100%,0%,10%)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a red outline.');\n
\n\n// Percentage RGBA notation.\nstroke('rgba(100%,0%,100%,0.5)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a dark fuchsia outline.');\n
\n\n// p5.Color object.\nstroke(color(0, 0, 255));\nstrokeWeight(4);\nrect(20, 20, 60, 60);\ndescribe('A white rectangle with a blue outline.');\n
\nAll drawing that follows erase() will subtract\nfrom the canvas, revealing the web page underneath. The erased areas will\nbecome transparent, allowing the content behind the canvas to show through.\nThe fill(), stroke(), and\nblendMode() have no effect once erase()
is\ncalled.
The erase()
function has two optional parameters. The first parameter\nsets the strength of erasing by the shape's interior. A value of 0 means\nthat no erasing will occur. A value of 255 means that the shape's interior\nwill fully erase the content underneath. The default value is 255\n(full strength).
The second parameter sets the strength of erasing by the shape's edge. A\nvalue of 0 means that no erasing will occur. A value of 255 means that the\nshape's edge will fully erase the content underneath. The default value is\n255 (full strength).
\nTo cancel the erasing effect, use the noErase()\nfunction.
\nerase()
has no effect on drawing done with the\nimage() and\nbackground() functions.
\nbackground(100, 100, 250);\nfill(250, 100, 100);\nsquare(20, 20, 60);\nerase();\ncircle(25, 30, 30);\nnoErase();\ndescribe('A purple canvas with a pink square in the middle. A circle is erased from the top-left, leaving a white hole.');\n
\n\nlet p = createP('I am a DOM element');\np.style('font-size', '12px');\np.style('width', '65px');\np.style('text-align', 'center');\np.position(18, 26);\n\nbackground(100, 170, 210);\nerase(200, 100);\ncircle(50, 50, 77);\nnoErase();\ndescribe('A blue canvas with a circular hole in the center that reveals the message \"I am a DOM element\".');\n
\n\nbackground(150, 250, 150);\nfill(100, 100, 250);\nsquare(20, 20, 60);\nstrokeWeight(5);\nerase(150, 255);\ntriangle(50, 10, 70, 50, 90, 10);\nnoErase();\ndescribe('A mint green canvas with a purple square in the center. A triangle in the top-right corner partially erases its interior and a fully erases its outline.');\n
\n\nbackground(235, 145, 15);\nnoStroke();\nfill(30, 45, 220);\nrect(30, 10, 10, 80);\nerase();\ncircle(50, 50, 60);\nnoErase();\nrect(70, 10, 10, 80);\ndescribe('An orange canvas with two tall blue rectangles. A circular hole in the center erases the rectangle on the left but not the one on the right.');\n
\nDisplays text in the web browser's console.
\nprint()
is helpful for printing values while debugging. Each call to\nprint()
creates a new line of text.
Note: Call print('\\n')
to print a blank line. Calling print()
without\nan argument opens the browser's dialog for printing documents.
\nfunction setup() {\n // Prints \"hello, world\" to the console.\n print('hello, world');\n}\n
\n\nfunction setup() {\n let name = 'ada';\n // Prints \"hello, ada\" to the console.\n print(`hello, ${name}`);\n}\n
\n\n// creates a file called 'newFile.txt'\nlet writer = createWriter('newFile.txt');\n// creates a file containing\n// My name is:\n// Teddy\nwriter.print('My name is:');\nwriter.print('Teddy');\n// close the PrintWriter and save the file\nwriter.close();\n
\n\nlet writer;\n\nfunction setup() {\n createCanvas(400, 400);\n // create a PrintWriter\n writer = createWriter('newFile.txt');\n}\n\nfunction draw() {\n writer.print([mouseX, mouseY]);\n}\n\nfunction mouseClicked() {\n writer.close();\n}\n
\nChanges the cursor's appearance.
\nThe first parameter, type
, sets the type of cursor to display. The\nbuilt-in options are ARROW
, CROSS
, HAND
, MOVE
, TEXT
, and WAIT
.\ncursor()
also recognizes standard CSS cursor properties passed as\nstrings: 'help'
, 'wait'
, 'crosshair'
, 'not-allowed'
, 'zoom-in'
,\nand 'grab'
. If the path to an image is passed, as in\ncursor('assets/target.png')
, then the image will be used as the cursor.\nImages must be in .cur, .gif, .jpg, .jpeg, or .png format.
The parameters x
and y
are optional. If an image is used for the\ncursor, x
and y
set the location pointed to within the image. They are\nboth 0 by default, so the cursor points to the image's top-left corner. x
\nand y
must be less than the image's width and height, respectively.
\nfunction draw() {\n background(200);\n\n // Set the cursor to crosshairs: +\n cursor(CROSS);\n\n describe('A gray square. The cursor appears as crosshairs.');\n}\n
\n\nfunction draw() {\n background(200);\n\n // Divide the canvas into quadrants.\n line(50, 0, 50, 100);\n line(0, 50, 100, 50);\n\n // Change cursor based on mouse position.\n if (mouseX < 50 && mouseY < 50) {\n cursor(CROSS);\n } else if (mouseX > 50 && mouseY < 50) {\n cursor('progress');\n } else if (mouseX > 50 && mouseY > 50) {\n cursor('https://avatars0.githubusercontent.com/u/1617169?s=16');\n } else {\n cursor('grab');\n }\n\n describe('A gray square divided into quadrants. The cursor image changes when the mouse moves to each quadrant.');\n}\n
\n\nfunction draw() {\n background(200);\n\n // Change the cursor's active spot\n // when the mouse is pressed.\n if (mouseIsPressed === true) {\n cursor('https://avatars0.githubusercontent.com/u/1617169?s=16', 8, 8);\n } else {\n cursor('https://avatars0.githubusercontent.com/u/1617169?s=16');\n }\n\n describe('An image of three purple curves follows the mouse. The image shifts when the mouse is pressed.');\n}\n
\nSets the number of frames to draw per second.
\nCalling frameRate()
with one numeric argument, as in frameRate(30)
,\nattempts to draw 30 frames per second (FPS). The target frame rate may not\nbe achieved depending on the sketch's processing needs. Most computers\ndefault to a frame rate of 60 FPS. Frame rates of 24 FPS and above are\nfast enough for smooth animations.
Calling frameRate()
without an argument returns the current frame rate.\nThe value returned is an approximation.
\nfunction draw() {\n background(200);\n\n // Set the x variable based\n // on the current frameCount.\n let x = frameCount % 100;\n\n // If the mouse is pressed,\n // decrease the frame rate.\n if (mouseIsPressed === true) {\n frameRate(10);\n } else {\n frameRate(60);\n }\n\n // Use x to set the circle's\n // position.\n circle(x, 50, 20);\n\n describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.');\n}\n
\n\nfunction draw() {\n background(200);\n\n // If the mouse is pressed, do lots\n // of math to slow down drawing.\n if (mouseIsPressed === true) {\n for (let i = 0; i < 1000000; i += 1) {\n random();\n }\n }\n\n // Get the current frame rate\n // and display it.\n let fps = frameRate();\n text(fps, 50, 50);\n\n describe('A number written in black written on a gray background. The number decreases when the mouse is pressed.');\n}\n
\n\nfunction draw() {\n background(200);\n\n // Set the frame rate to 20.\n frameRate(20);\n\n // Get the target frame rate and\n // display it.\n let fps = getTargetFrameRate();\n text(fps, 43, 54);\n\n describe('The number 20 written in black on a gray background.');\n}\n
\n\nfunction setup() {\n // Hide the cursor.\n noCursor();\n}\n\nfunction draw() {\n background(200);\n\n circle(mouseX, mouseY, 10);\n\n describe('A white circle on a gray background. The circle follows the mouse as it moves. The cursor is hidden.');\n}\n
\nThe code in windowResized()
is called once each time the browser window\nis resized. It's a good place to resize the canvas or make other\nadjustments to accommodate the new window size.
The event
parameter is optional. If added to the function definition, it\ncan be used for debugging or other purposes.
\nfunction setup() {\n createCanvas(windowWidth, windowHeight);\n}\n\nfunction draw() {\n background(200);\n\n describe('A gray canvas that takes up the entire browser window. It changes size to match the browser window.');\n}\n\n// Resize the canvas when the\n// browser's size changes.\nfunction windowResized() {\n resizeCanvas(windowWidth, windowHeight);\n}\n
\n\nfunction setup() {\n createCanvas(windowWidth, windowHeight);\n}\n\nfunction draw() {\n background(200);\n\n describe('A gray canvas that takes up the entire browser window. It changes size to match the browser window.');\n}\n\nfunction windowResized(event) {\n // Resize the canvas when the\n // browser's size changes.\n resizeCanvas(windowWidth, windowHeight);\n\n // Print the resize event to the console for debugging.\n print(event);\n}\n
\nToggles full-screen mode or returns the current mode.
\nCalling fullscreen(true)
makes the sketch full-screen. Calling\nfullscreen(false)
makes the sketch its original size.
Calling fullscreen()
without an argument returns true
if the sketch\nis in full-screen mode and false
if not.
Note: Due to browser restrictions, fullscreen()
can only be called with\nuser input such as a mouse press.
\nfunction setup() {\n background(200);\n\n describe('A gray canvas that switches between default and full-screen display when clicked.');\n}\n\n// If the mouse is pressed,\n// toggle full-screen mode.\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n let fs = fullscreen();\n fullscreen(!fs);\n }\n}\n
\nSets the pixel scaling for high pixel density displays.
\nBy default, the pixel density is set to match display density. Calling\npixelDensity(1)
turn this off.
Calling pixelDensity()
without an argument returns the current pixel\ndensity.
\nfunction setup() {\n // Set the pixel density to 1.\n pixelDensity(1);\n\n // Create a canvas and draw\n // a circle.\n createCanvas(100, 100);\n background(200);\n circle(50, 50, 70);\n\n describe('A fuzzy white circle on a gray canvas.');\n}\n
\n\nfunction setup() {\n // Set the pixel density to 3.\n pixelDensity(3);\n\n // Create a canvas, paint the\n // background, and draw a\n // circle.\n createCanvas(100, 100);\n background(200);\n circle(50, 50, 70);\n\n describe('A sharp white circle on a gray canvas.');\n}\n
\n\nfunction setup() {\n // Set the pixel density to 1.\n pixelDensity(1);\n\n // Create a canvas and draw\n // a circle.\n createCanvas(100, 100);\n background(200);\n circle(50, 50, 70);\n\n describe('A fuzzy white circle drawn on a gray background. The circle becomes sharper when the mouse is pressed.');\n}\n\nfunction mousePressed() {\n // Get the current display density.\n let d = displayDensity();\n\n // Use the display density to set\n // the sketch's pixel density.\n pixelDensity(d);\n\n // Paint the background and\n // draw a circle.\n background(200);\n circle(50, 50, 70);\n}\n
\n\nfunction setup() {\n background(200);\n\n // Get the sketch's URL\n // and display it.\n let url = getURL();\n textWrap(CHAR);\n text(url, 0, 40, 100);\n\n describe('The URL \"https://p5js.org/reference/#/p5/getURL\" written in black on a gray background.');\n}\n
\nReturns the current\nURL\npath as an array of strings.
\nFor example, consider a sketch hosted at the URL\nhttps://example.com/sketchbook
. Calling getURLPath()
returns\n['sketchbook']
. For a sketch hosted at the URL\nhttps://example.com/sketchbook/monday
, getURLPath()
returns\n['sketchbook', 'monday']
.
\nfunction setup() {\n background(200);\n\n // Get the sketch's URL path\n // and display the first\n // part.\n let path = getURLPath();\n text(path[0], 25, 54);\n\n describe('The word \"reference\" written in black on a gray background.');\n}\n
\nReturns the current\nURL parameters\nin an Object.
\nFor example, calling getURLParams()
in a sketch hosted at the URL\nhttp://p5js.org?year=2014&month=May&day=15
returns\n{ year: 2014, month: 'May', day: 15 }
.
\n// Imagine this sketch is hosted at the following URL:\n// https://p5js.org?year=2014&month=May&day=15\n\nfunction setup() {\n background(200);\n\n // Get the sketch's URL\n // parameters and display\n // them.\n let params = getURLParams();\n text(params.day, 10, 20);\n text(params.month, 10, 40);\n text(params.year, 10, 60);\n\n describe('The text \"15\", \"May\", and \"2014\" written in black on separate lines.');\n}\n
\nCalled directly before setup(), the preload() function is used to handle\nasynchronous loading of external files in a blocking way. If a preload\nfunction is defined, setup() will wait until any load calls within have\nfinished. Nothing besides load calls (loadImage, loadJSON, loadFont,\nloadStrings, etc.) should be inside the preload function. If asynchronous\nloading is preferred, the load methods can instead be called in setup()\nor anywhere else with the use of a callback parameter.
\nBy default the text \"loading...\" will be displayed. To make your own\nloading page, include an HTML element with id \"p5_loading\" in your\npage. More information here.
\n", + "example": [ + "\nlet img;\nlet c;\nfunction preload() {\n // preload() runs once\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n // setup() waits until preload() is done\n img.loadPixels();\n // get color of middle pixel\n c = img.get(img.width / 2, img.height / 2);\n}\n\nfunction draw() {\n background(c);\n image(img, 25, 25, 50, 50);\n}\n
The setup() function is called once when the program starts. It's used to\ndefine initial environment properties such as screen size and background\ncolor and to load media such as images and fonts as the program starts.\nThere can only be one setup() function for each program and it shouldn't\nbe called again after its initial execution.
\nNote: Variables declared within setup() are not accessible within other\nfunctions, including draw().
\n", + "example": [ + "\nlet a = 0;\n\nfunction setup() {\n background(0);\n noStroke();\n fill(102);\n}\n\nfunction draw() {\n rect(a++ % width, 10, 2, 80);\n}\n
Called directly after setup(), the draw() function continuously executes\nthe lines of code contained inside its block until the program is stopped\nor noLoop() is called. Note if noLoop() is called in setup(), draw() will\nstill be executed once before stopping. draw() is called automatically and\nshould never be called explicitly.
\nIt should always be controlled with noLoop(), redraw() and loop(). After\nnoLoop() stops the code in draw() from executing, redraw() causes the\ncode inside draw() to execute once, and loop() will cause the code\ninside draw() to resume executing continuously.
\nThe number of times draw() executes in each second may be controlled with\nthe frameRate() function.
\nThere can only be one draw() function for each sketch, and draw() must\nexist if you want the code to run continuously, or to process events such\nas mousePressed(). Sometimes, you might have an empty call to draw() in\nyour program, as shown in the above example.
\nIt is important to note that the drawing coordinate system will be reset\nat the beginning of each draw() call. If any transformations are performed\nwithin draw() (ex: scale, rotate, translate), their effects will be\nundone at the beginning of draw(), so transformations will not accumulate\nover time. On the other hand, styling applied (ex: fill, stroke, etc) will\nremain in effect.
\n", + "example": [ + "\nlet yPos = 0;\nfunction setup() {\n // setup() runs once\n frameRate(30);\n}\nfunction draw() {\n // draw() loops forever, until stopped\n background(204);\n yPos = yPos - 1;\n if (yPos < 0) {\n yPos = height;\n }\n line(0, yPos, width, yPos);\n}\n
Attaches this element to a parent element.
\nFor example, a <div></div>
element may be used as a box to\nhold two pieces of text, a header and a paragraph. The\n<div></div>
is the parent element of both the header and\nparagraph.
The parameter parent
can have one of three types. parent
can be a\nstring with the parent element's ID, as in\nmyElement.parent('container')
. It can also be another\np5.Element object, as in\nmyElement.parent(myDiv)
. Finally, parent
can be an HTMLElement
\nobject, as in myElement.parent(anotherElement)
.
Calling myElement.parent()
without an argument returns this element's\nparent.
\nfunction setup() {\n background(200);\n\n // Create a div element.\n let div = createDiv();\n // Place the div in the top-left corner.\n div.position(10, 20);\n // Set its width and height.\n div.size(80, 60);\n // Set its background color to white\n div.style('background-color', 'white');\n // Align any text to the center.\n div.style('text-align', 'center');\n // Set its ID to \"container\".\n div.id('container');\n\n // Create a paragraph element.\n let p = createP('p5*js');\n // Make the div its parent\n // using its ID \"container\".\n p.parent('container');\n\n describe('The text \"p5*js\" written in black at the center of a white rectangle. The rectangle is inside a gray square.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create rectangular div element.\n let div = createDiv();\n // Place the div in the top-left corner.\n div.position(10, 20);\n // Set its width and height.\n div.size(80, 60);\n // Set its background color and align\n // any text to the center.\n div.style('background-color', 'white');\n div.style('text-align', 'center');\n\n // Create a paragraph element.\n let p = createP('p5*js');\n // Make the div its parent.\n p.parent(div);\n\n describe('The text \"p5*js\" written in black at the center of a white rectangle. The rectangle is inside a gray square.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create rectangular div element.\n let div = createDiv();\n // Place the div in the top-left corner.\n div.position(10, 20);\n // Set its width and height.\n div.size(80, 60);\n // Set its background color and align\n // any text to the center.\n div.style('background-color', 'white');\n div.style('text-align', 'center');\n\n // Create a paragraph element.\n let p = createP('p5*js');\n // Make the div its parent\n // using the underlying\n // HTMLElement.\n p.parent(div.elt);\n\n describe('The text \"p5*js\" written in black at the center of a white rectangle. The rectangle is inside a gray square.');\n}\n
\nSets this element's ID using a given string.
\nCalling myElement.id()
without an argument returns its ID as a string.
\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Set the canvas' ID\n // to \"mycanvas\".\n cnv.id('mycanvas');\n\n // Get the canvas' ID.\n let id = cnv.id();\n text(id, 24, 54);\n\n describe('The text \"mycanvas\" written in black on a gray background.');\n}\n
\nAdds a\nclass attribute\nto the element.
\nCalling myElement.class()
without an argument returns a string with its current classes.
\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Add the class \"small\" to the\n // canvas element.\n cnv.class('small');\n\n // Get the canvas element's class\n // and display it.\n let c = cnv.class();\n text(c, 35, 54);\n\n describe('The word \"small\" written in black on a gray canvas.');\n\n}\n
\nCalls a function when the mouse is pressed over the element.\nCalling myElement.mousePressed(false)
disables the function.
Note: Some mobile browsers may also trigger this event when the element\nreceives a quick tap.
\n", + "example": [ + "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the canvas\n // is pressed.\n cnv.mousePressed(randomColor);\n\n describe('A gray square changes color when the mouse is pressed.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the canvas is pressed.\n cnv.mousePressed(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the mouse is pressed.');\n}\n
\n\n// Click anywhere in the webpage to change\n// the color value of the rectangle\n\nlet colorValue = 0;\nfunction draw() {\n fill(colorValue);\n rect(25, 25, 50, 50);\n describe('black 50-by-50 rect turns white with mouse click/press.');\n}\nfunction mousePressed() {\n if (colorValue === 0) {\n colorValue = 255;\n } else {\n colorValue = 0;\n }\n}\n
\n\nfunction mousePressed() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mousePressed(event) {\n console.log(event);\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional MouseEvent callback argument.",
+ "optional": 1,
+ "type": "MouseEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Mouse"
+ },
+ {
+ "name": "doubleClicked",
+ "file": "src/events/mouse.js",
+ "line": 872,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the mouse is pressed twice over the element.\nCalling myElement.doubleClicked(false)
disables the function.",
+ "example": [
+ "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // canvas is double-clicked.\n cnv.doubleClicked(randomColor);\n\n describe('A gray square changes color when the user double-clicks the canvas.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the canvas is double-clicked.\n cnv.doubleClicked(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the user double-clicks the canvas.');\n}\n
\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been double clicked\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe('black 50-by-50 rect turns white with mouse doubleClick/press.');\n}\n\nfunction doubleClicked() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\nfunction doubleClicked() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n// returns a MouseEvent object\n// as a callback argument\nfunction doubleClicked(event) {\n console.log(event);\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional MouseEvent callback argument.",
+ "optional": 1,
+ "type": "MouseEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Mouse"
+ },
+ {
+ "name": "mouseWheel",
+ "file": "src/events/mouse.js",
+ "line": 938,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the mouse wheel scrolls over th element.
\nThe callback function, fxn
, is passed an event
object. event
has\ntwo numeric properties, deltaY
and deltaX
. event.deltaY
is\nnegative if the mouse wheel rotates away from the user. It's positive if\nthe mouse wheel rotates toward the user. event.deltaX
is positive if\nthe mouse wheel moves to the right. It's negative if the mouse wheel moves\nto the left.
Calling myElement.mouseWheel(false)
disables the function.
\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // mouse wheel moves.\n cnv.mouseWheel(randomColor);\n\n describe('A gray square changes color when the user scrolls the mouse wheel over the canvas.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the mouse wheel moves.\n cnv.mouseWheel(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the user scrolls the mouse wheel over the canvas.');\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call changeBackground() when the\n // mouse wheel moves.\n cnv.mouseWheel(changeBackground);\n\n describe('A gray square. When the mouse wheel scrolls over the square, it changes color and displays shapes.');\n}\n\nfunction changeBackground(event) {\n // Change the background color\n // based on deltaY.\n if (event.deltaY > 0) {\n background('deeppink');\n } else if (event.deltaY < 0) {\n background('cornflowerblue');\n } else {\n background(200);\n }\n\n // Draw a shape based on deltaX.\n if (event.deltaX > 0) {\n circle(50, 50, 20);\n } else if (event.deltaX < 0) {\n square(40, 40, 20);\n }\n}\n
\n\nlet pos = 25;\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n rect(25, pos, 50, 50);\n describe(`black 50-by-50 rect moves up and down with vertical scroll.\n fuchsia background`);\n}\n\nfunction mouseWheel(event) {\n print(event.delta);\n //move the square according to the vertical scroll amount\n pos += event.delta;\n //uncomment to block page scrolling\n //return false;\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional WheelEvent callback argument.",
+ "optional": 1,
+ "type": "WheelEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Mouse"
+ },
+ {
+ "name": "mouseReleased",
+ "file": "src/events/mouse.js",
+ "line": 730,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the mouse is released over the element. Calling\nmyElement.mouseReleased(false)
disables the function.
Note: Some mobile browsers may also trigger this event when the element\nreceives a quick tap.
\n", + "example": [ + "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when a\n // mouse press ends.\n cnv.mouseReleased(randomColor);\n\n describe('A gray square changes color when the user releases a mouse press.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when a mouse press ends.\n cnv.mouseReleased(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the user releases a mouse press.');\n}\n
\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been clicked\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe('black 50-by-50 rect turns white with mouse click/press.');\n}\nfunction mouseReleased() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\nfunction mouseReleased() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseReleased(event) {\n console.log(event);\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional MouseEvent callback argument.",
+ "optional": 1,
+ "type": "MouseEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Mouse"
+ },
+ {
+ "name": "mouseClicked",
+ "file": "src/events/mouse.js",
+ "line": 806,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the mouse is pressed and released over the element.\nCalling myElement.mouseReleased(false)
disables the function.
Note: Some mobile browsers may also trigger this event when the element\nreceives a quick tap.
\n", + "example": [ + "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when a\n // mouse press ends.\n cnv.mouseClicked(randomColor);\n\n describe('A gray square changes color when the user releases a mouse press.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when a mouse press ends.\n cnv.mouseClicked(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the user releases a mouse press.');\n}\n
\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been clicked\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe('black 50-by-50 rect turns white with mouse click/press.');\n}\n\nfunction mouseClicked() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\nfunction mouseClicked() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseClicked(event) {\n console.log(event);\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional MouseEvent callback argument.",
+ "optional": 1,
+ "type": "MouseEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Mouse"
+ },
+ {
+ "name": "mouseMoved",
+ "file": "src/events/mouse.js",
+ "line": 573,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the mouse moves over the element. Calling\nmyElement.mouseMoved(false)
disables the function.",
+ "example": [
+ "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // mouse moves.\n cnv.mouseMoved(randomColor);\n\n describe('A gray square changes color when the mouse moves over the canvas.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the mouse moves.\n cnv.mouseMoved(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the mouse moves over the canvas.');\n}\n
\n\n// Move the mouse across the page\n// to change its value\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`black 50-by-50 rect becomes lighter with mouse movements until\n white then resets no image displayed`);\n}\nfunction mouseMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n\nfunction mouseMoved() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseMoved(event) {\n console.log(event);\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional MouseEvent callback argument.",
+ "optional": 1,
+ "type": "MouseEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Mouse"
+ },
+ {
+ "name": "mouseOver",
+ "file": "src/core/p5.Element.js",
+ "line": 823,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the mouse moves onto the element. Calling\nmyElement.mouseOver(false)
disables the function.",
+ "example": [
+ "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // mouse moves onto the canvas.\n cnv.mouseOver(randomColor);\n\n describe('A gray square changes color when the mouse moves onto the canvas.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the mouse moves onto\n // the canvas.\n cnv.mouseOver(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the mouse moves onto the canvas.');\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "mouseOut",
+ "file": "src/core/p5.Element.js",
+ "line": 886,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the mouse moves off the element. Calling\nmyElement.mouseOut(false)
disables the function.",
+ "example": [
+ "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // mouse moves off the canvas.\n cnv.mouseOut(randomColor);\n\n describe('A gray square changes color when the mouse moves off the canvas.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the mouse moves off\n // the canvas.\n cnv.mouseOut(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the mouse moves off the canvas.');\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "touchStarted",
+ "file": "src/events/touch.js",
+ "line": 124,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the element is touched. Calling\nmyElement.touchStarted(false)
disables the function.
Note: Touch functions only work on mobile devices.
\n", + "example": [ + "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // user touches the canvas.\n cnv.touchStarted(randomColor);\n\n describe('A gray square changes color when the user touches the canvas.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the user touches the\n // canvas.\n cnv.touchStarted(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the user touches the canvas.');\n}\n
\n\n// Touch within the image to change\n// the value of the rectangle\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe('50-by-50 black rect turns white with touch event.');\n}\nfunction touchStarted() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\nfunction touchStarted() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\ndescribe('no image displayed');\n
\n\n// returns a TouchEvent object\n// as a callback argument\nfunction touchStarted(event) {\n console.log(event);\n}\ndescribe('no image displayed');\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional TouchEvent callback argument.",
+ "optional": 1,
+ "type": "TouchEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Touch"
+ },
+ {
+ "name": "touchMoved",
+ "file": "src/events/touch.js",
+ "line": 202,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the user touches the element and moves their\nfinger. Calling myElement.touchMoved(false)
disables the\nfunction.
Note: Touch functions only work on mobile devices.
\n", + "example": [ + "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // user touches the canvas\n // and moves.\n cnv.touchMoved(randomColor);\n\n describe('A gray square changes color when the user touches the canvas and moves.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the user touches the\n // canvas and moves.\n cnv.touchMoved(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the user touches the canvas and moves.');\n}\n
\n\n// Move your finger across the page\n// to change its value\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe('50-by-50 black rect turns lighter with touch until white. resets');\n}\nfunction touchMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n\nfunction touchMoved() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\ndescribe('no image displayed');\n
\n\n// returns a TouchEvent object\n// as a callback argument\nfunction touchMoved(event) {\n console.log(event);\n}\ndescribe('no image displayed');\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional TouchEvent callback argument.",
+ "optional": 1,
+ "type": "TouchEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Touch"
+ },
+ {
+ "name": "touchEnded",
+ "file": "src/events/touch.js",
+ "line": 274,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when the user stops touching the element. Calling\nmyElement.touchMoved(false)
disables the function.
Note: Touch functions only work on mobile devices.
\n", + "example": [ + "\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call randomColor() when the\n // user touches the canvas,\n // then lifts their finger.\n cnv.touchEnded(randomColor);\n\n describe('A gray square changes color when the user touches the canvas, then lifts their finger.');\n}\n\n// Paint the background either\n// red, yellow, blue, or green.\nfunction randomColor() {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n}\n
\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Paint the background either\n // red, yellow, blue, or green\n // when the user touches the\n // canvas, then lifts their\n // finger.\n cnv.touchEnded(() => {\n let c = random(['red', 'yellow', 'blue', 'green']);\n background(c);\n });\n\n describe('A gray square changes color when the user touches the canvas, then lifts their finger.');\n}\n
\n\n// Release touch within the image to\n// change the value of the rectangle\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe('50-by-50 black rect turns white with touch.');\n}\nfunction touchEnded() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\nfunction touchEnded() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\ndescribe('no image displayed');\n
\n\n// returns a TouchEvent object\n// as a callback argument\nfunction touchEnded(event) {\n console.log(event);\n}\ndescribe('no image displayed');\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "event",
+ "description": "optional TouchEvent callback argument.",
+ "optional": 1,
+ "type": "TouchEvent"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "Events",
+ "submodule": "Touch"
+ },
+ {
+ "name": "dragOver",
+ "file": "src/core/p5.Element.js",
+ "line": 1148,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when a file is dragged over the element. Calling\nmyElement.dragOver(false)
disables the function.",
+ "example": [
+ "\n// Drag a file over the canvas to test.\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call helloFile() when a\n // file is dragged over\n // the canvas.\n cnv.dragOver(helloFile);\n\n describe('A gray square. The text \"hello, file\" appears when a file is dragged over the square.');\n}\n\nfunction helloFile() {\n text('hello, file', 50, 50);\n}\n
\n\n// Drag a file over the canvas to test.\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Say \"hello, file\" when a\n // file is dragged over\n // the canvas.\n cnv.dragOver(() => {\n text('hello, file', 50, 50);\n });\n\n describe('A gray square. The text \"hello, file\" appears when a file is dragged over the square.');\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "dragLeave",
+ "file": "src/core/p5.Element.js",
+ "line": 1213,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Calls a function when a file is dragged off the element. Calling\nCalling myElement.dragLeave(false)
disables the function.",
+ "example": [
+ "\n// Drag a file over, then off\n// the canvas to test.\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Call byeFile() when a\n // file is dragged over,\n // then off the canvas.\n cnv.dragLeave(byeFile);\n\n describe('A gray square. The text \"bye, file\" appears when a file is dragged over, then off the square.');\n}\n\nfunction byeFile() {\n text('bye, file', 50, 50);\n}\n
\n\n// Drag a file over, then off\n// the canvas to test.\n\nfunction setup() {\n // Create a canvas element and\n // assign it to cnv.\n let cnv = createCanvas(100, 100);\n\n background(200);\n\n // Say \"bye, file\" when a\n // file is dragged over,\n // then off the canvas.\n cnv.dragLeave(() => {\n text('bye, file', 50, 50);\n });\n\n describe('A gray square. The text \"bye, file\" appears when a file is dragged over, then off the square.');\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Element",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "calculateOffset",
+ "file": "src/core/p5.Renderer.js",
+ "line": 524,
+ "itemtype": "method",
+ "description": "Helper fxn to measure ascent and descent.\nAdapted from http://stackoverflow.com/a/25355178",
+ "example": [],
+ "overloads": [
+ {
+ "params": []
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "Rendering",
+ "submodule": "Rendering"
+ },
+ {
+ "name": "log",
+ "file": "src/math/calculation.js",
+ "line": 314,
+ "itemtype": "method",
+ "description": "Calculates the natural logarithm (the base-e logarithm) of a number. This\nfunction expects the n
parameter to be a value greater than 0.0.",
+ "example": [
+ "\nfunction draw() {\n // Invert the y-axis.\n scale(1, -1);\n translate(0, -height);\n\n let x = frameCount;\n let y = 15 * log(x);\n point(x, y);\n\n describe('A series of black dots that get higher slowly from left to right.');\n}\n
\nCreates a canvas element in the document and sets its dimensions\nin pixels. This method should be called only once at the start of setup().\nCalling createCanvas more than once in a\nsketch will result in very unpredictable behavior. If you want more than\none drawing canvas you could use createGraphics()\n(hidden by default but it can be shown).
\nImportant note: in 2D mode (i.e. when p5.Renderer
is not set) the origin (0,0)\nis positioned at the top left of the screen. In 3D mode (i.e. when p5.Renderer
\nis set to WEBGL
), the origin is positioned at the center of the canvas.\nSee this issue for more information.
A WebGL canvas will use a WebGL2 context if it is supported by the browser.\nCheck the webglVersion property to check what\nversion is being used, or call setAttributes({ version: 1 })\nto create a WebGL1 context.
\nThe system variables width and height are set by the parameters passed to this\nfunction. If createCanvas() is not used, the\nwindow will be given a default size of 100×100 pixels.
\nOptionally, an existing canvas can be passed using a selector, ie. document.getElementById('')
.\nIf specified, avoid using setAttributes()
afterwards, as this will remove and recreate the existing canvas.
For more ways to position the canvas, see the\n\npositioning the canvas wiki page.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 50);\n background(153);\n line(0, 0, width, height);\n}\n
\n\nfunction setup() {\n createCanvas(windowWidth, windowHeight);\n}\n\nfunction draw() {\n background(0, 100, 200);\n}\n\nfunction windowResized() {\n resizeCanvas(windowWidth, windowHeight);\n}\n
\nfunction setup() {\n noCanvas();\n}\n
\nCreates and returns a new p5.Graphics object. Use this class if you need\nto draw into an off-screen graphics buffer. The two parameters define the\nwidth and height in pixels.
\nA WebGL p5.Graphics will use a WebGL2 context if it is supported by the browser.\nCheck the pg.webglVersion property of the renderer\nto check what version is being used, or call pg.setAttributes({ version: 1 })\nto create a WebGL1 context.
\nOptionally, an existing canvas can be passed using a selector, ie. document.getElementById('').\nBy default this canvas will be hidden (offscreen buffer), to make visible, set element's style to display:block;
\n", + "example": [ + "\nlet pg;\nfunction setup() {\n createCanvas(100, 100);\n pg = createGraphics(100, 100);\n}\n\nfunction draw() {\n background(200);\n pg.background(100);\n pg.noStroke();\n pg.ellipse(pg.width / 2, pg.height / 2, 50, 50);\n image(pg, 50, 50);\n image(pg, 0, 0, 50, 50);\n}\n
\nCreates and returns a new p5.Framebuffer, a\nhigh-performance WebGL object that you can draw to and then use as a texture.
\nOptions can include:
\nformat
: The data format of the texture, either UNSIGNED_BYTE
, FLOAT
, or HALF_FLOAT
. The default is UNSIGNED_BYTE
.channels
: What color channels to store, either RGB
or RGBA
. The default is to match the channels in the main canvas (with alpha unless disabled with setAttributes
.)depth
: A boolean, whether or not to include a depth buffer. Defaults to true.depthFormat
: The data format for depth information, either UNSIGNED_INT
or FLOAT
. The default is FLOAT
if available, or UNSIGNED_INT
otherwise.stencil
: A boolean, whether or not to include a stencil buffer, which can be used for masking. This may only be used if also using a depth buffer. Defaults to the value of depth
, which is true if not provided.antialias
: Boolean or Number, whether or not to render with antialiased edges, and if so, optionally the number of samples to use. Defaults to whether or not the main canvas is antialiased, using a default of 2 samples if so. Antialiasing is only supported when WebGL 2 is available.width
: The width of the texture. Defaults to matching the main canvas.height
: The height of the texture. Defaults to matching the main canvas.density
: The pixel density of the texture. Defaults to the pixel density of the main canvas.textureFiltering
: Either LINEAR
(nearby pixels will be interpolated when reading values from the color texture) or NEAREST
(no interpolation.) Generally, use LINEAR
when using the texture as an image, and use NEAREST
if reading the texture as data. Defaults to LINEAR
.If width
, height
, or density
are specified, then the framebuffer will\nkeep that size until manually changed. Otherwise, it will be autosized, and\nit will update to match the main canvas's size and density when the main\ncanvas changes.
\nlet prev, next;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n prev = createFramebuffer({ format: FLOAT });\n next = createFramebuffer({ format: FLOAT });\n noStroke();\n}\n\nfunction draw() {\n // Swap prev and next so that we can use the previous\n // frame as a texture when drawing the current frame\n [prev, next] = [next, prev];\n\n // Draw to the framebuffer\n next.begin();\n background(255);\n\n push();\n tint(255, 253);\n image(prev, -width/2, -height/2);\n // Make sure the image plane doesn't block you from seeing any part\n // of the scene\n clearDepth();\n pop();\n\n push();\n normalMaterial();\n translate(25*sin(frameCount * 0.014), 25*sin(frameCount * 0.02), 0);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(12);\n pop();\n next.end();\n\n image(next, -width/2, -height/2);\n}\n
\nThis makes the canvas forget how far from the camera everything that has\nbeen drawn was. Use this if you want to make sure the next thing you draw\nwill not draw behind anything that is already on the canvas.
\nThis is useful for things like feedback effects, where you want the previous\nframe to act like a background for the next frame, and not like a plane in\n3D space in the scene.
\nThis method is only available in WebGL mode. Since 2D mode does not have\n3D depth, anything you draw will always go on top of the previous content on\nthe canvas anyway.
\n", + "example": [ + "\nlet prev, next;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n prev = createFramebuffer({ format: FLOAT });\n next = createFramebuffer({ format: FLOAT });\n noStroke();\n}\n\nfunction draw() {\n // Swap prev and next so that we can use the previous\n // frame as a texture when drawing the current frame\n [prev, next] = [next, prev];\n\n // Draw to the framebuffer\n next.begin();\n background(255);\n\n push();\n tint(255, 253);\n image(prev, -width/2, -height/2);\n // Make sure the image plane doesn't block you from seeing any part\n // of the scene\n clearDepth();\n pop();\n\n push();\n normalMaterial();\n translate(25*sin(frameCount * 0.014), 25*sin(frameCount * 0.02), 0);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(12);\n pop();\n next.end();\n\n image(next, -width/2, -height/2);\n}\n
\nBlends the pixels in the display window according to the defined mode.\nThere is a choice of the following modes to blend the source pixels (A)\nwith the ones of pixels already in the display window (B):
\nBLEND
- linear interpolation of colours: C =\nA*factor + B. This is the default blending mode.ADD
- sum of A and BDARKEST
- only the darkest colour succeeds: C =\nmin(A*factor, B).LIGHTEST
- only the lightest colour succeeds: C =\nmax(A*factor, B).DIFFERENCE
- subtract colors from underlying image.\n(2D)EXCLUSION
- similar to DIFFERENCE
, but less\nextreme.MULTIPLY
- multiply the colors, result will always be\ndarker.SCREEN
- opposite multiply, uses inverse values of the\ncolors.REPLACE
- the pixels entirely replace the others and\ndon't utilize alpha (transparency) values.REMOVE
- removes pixels from B with the alpha strength of A.OVERLAY
- mix of MULTIPLY
and SCREEN\n
. Multiplies dark values, and screens light values. (2D)HARD_LIGHT
- SCREEN
when greater than 50%\ngray, MULTIPLY
when lower. (2D)SOFT_LIGHT
- mix of DARKEST
and\nLIGHTEST
. Works like OVERLAY
, but not as harsh. (2D)\nDODGE
- lightens light tones and increases contrast,\nignores darks. (2D)BURN
- darker areas are applied, increasing contrast,\nignores lights. (2D)SUBTRACT
- remainder of A and B (3D)(2D) indicates that this blend mode only works in the 2D renderer.
\n(3D) indicates that this blend mode only works in the WEBGL renderer.
\nblendMode(LIGHTEST);\nstrokeWeight(30);\nstroke(80, 150, 255);\nline(25, 25, 75, 75);\nstroke(255, 50, 50);\nline(75, 25, 25, 75);\n
\n\nblendMode(MULTIPLY);\nstrokeWeight(30);\nstroke(80, 150, 255);\nline(25, 25, 75, 75);\nstroke(255, 50, 50);\nline(75, 25, 25, 75);\n
\nDraws an arc to the canvas. Arcs are drawn along the outer edge of an ellipse\n(oval) defined by the x
, y
, w
, and h
parameters. Use the start
and stop
\nparameters to specify the angles (in radians) at which to draw the arc. Arcs are\nalways drawn clockwise from start
to stop
. The origin of the arc's ellipse may\nbe changed with the ellipseMode() function.
The optional mode
parameter determines the arc's fill style. The fill modes are\na semi-circle (OPEN
), a closed semi-circle (CHORD
), or a closed pie segment (PIE
).
\narc(50, 55, 50, 50, 0, HALF_PI);\nnoFill();\narc(50, 55, 60, 60, HALF_PI, PI);\narc(50, 55, 70, 70, PI, PI + QUARTER_PI);\narc(50, 55, 80, 80, PI + QUARTER_PI, TWO_PI);\ndescribe(\n 'A shattered outline of an ellipse with a quarter of a white circle at the bottom-right.'\n);\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI);\ndescribe('A white ellipse with the top-right third missing. The bottom is outlined in black.');\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN);\ndescribe(\n 'A white ellipse missing a section from the top-right. The bottom is outlined in black.'\n);\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD);\ndescribe('A white ellipse with a black outline missing a section from the top-right.');\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE);\ndescribe('A white ellipse with a black outline. The top-right third is missing.');\n
\nDraws an ellipse (oval) to the canvas. An ellipse with equal width and height\nis a circle. By default, the first two parameters set the location of the\ncenter of the ellipse. The third and fourth parameters set the shape's width\nand height, respectively. The origin may be changed with the\nellipseMode() function.
\nIf no height is specified, the value of width is used for both the width and\nheight. If a negative height or width is specified, the absolute value is\ntaken.
\n", + "example": [ + "\nellipse(56, 46, 55, 55);\ndescribe('A white ellipse with black outline in middle of a gray canvas.');\n
\n\ncircle(30, 30, 20);\ndescribe('A white circle with black outline in the middle of a gray canvas.');\n
\nDraws a line, a straight path between two points. Its default width is one pixel.\nThe version of line()
with four parameters draws the line in 2D. To color a line,\nuse the stroke() function. To change its width, use the\nstrokeWeight() function. A line\ncan't be filled, so the fill() function won't affect\nthe color of a line.
The version of line()
with six parameters allows the line to be drawn in 3D\nspace. Doing so requires adding the WEBGL
argument to\ncreateCanvas().
\nline(30, 20, 85, 75);\ndescribe(\n 'A black line on a gray canvas running from top-center to bottom-right.'\n);\n
\n\nline(30, 20, 85, 20);\nstroke(126);\nline(85, 20, 85, 75);\nstroke(255);\nline(85, 75, 30, 75);\ndescribe(\n 'Three lines drawn in grayscale on a gray canvas. They form the top, right, and bottom sides of a square.'\n);\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('A black line drawn on a gray canvas.');\n}\n\nfunction draw() {\n background(220);\n line(0, 0, 0, 10, 10, 0);\n}\n
\nDraws a point, a single coordinate in space. Its default size is one pixel. The first two\nparameters are the point's x- and y-coordinates, respectively. To color a point, use\nthe stroke() function. To change its size, use the\nstrokeWeight() function.
\nThe version of point()
with three parameters allows the point to be drawn in 3D\nspace. Doing so requires adding the WEBGL
argument to\ncreateCanvas().
The version of point() with one parameter allows the point's location to be set with\na p5.Vector object.
\n", + "example": [ + "\npoint(30, 20);\npoint(85, 20);\npoint(85, 75);\npoint(30, 75);\ndescribe(\n 'Four small, black points drawn on a gray canvas. The points form the corners of a square.'\n);\n
\n\npoint(30, 20);\npoint(85, 20);\nstroke('purple');\nstrokeWeight(10);\npoint(85, 75);\npoint(30, 75);\ndescribe(\n 'Four points drawn on a gray canvas. Two are black and two are purple. The points form the corners of a square.'\n);\n
\n\nlet a = createVector(10, 10);\npoint(a);\nlet b = createVector(10, 20);\npoint(b);\nlet c = createVector(20, 10);\npoint(c);\nlet d = createVector(20, 20);\npoint(d);\ndescribe(\n 'Four small, black points drawn on a gray canvas. The points form the corners of a square.'\n);\n
\nDraws a quad to the canvas. A quad is a quadrilateral, a four-sided\npolygon. Some examples of quads include rectangles, squares, rhombuses,\nand trapezoids. The first pair of parameters (x1
,y1
) sets the quad's\nfirst point. The following pairs of parameters set the coordinates for\nits next three points. Parameters should proceed clockwise or\ncounter-clockwise around the shape.
The version of quad()
with twelve parameters allows the quad to be drawn\nin 3D space. Doing so requires adding the WEBGL
argument to\ncreateCanvas().
\nquad(20, 20, 80, 20, 80, 80, 20, 80);\ndescribe('A white square with a black outline drawn on a gray canvas.');\n
\n\nquad(20, 30, 80, 30, 80, 70, 20, 70);\ndescribe('A white rectangle with a black outline drawn on a gray canvas.');\n
\n\nquad(50, 62, 86, 50, 50, 38, 14, 50);\ndescribe('A white rhombus with a black outline drawn on a gray canvas.');\n
\n\nquad(20, 50, 80, 30, 80, 70, 20, 70);\ndescribe('A white trapezoid with a black outline drawn on a gray canvas.');\n
\nDraws a rectangle to the canvas. A rectangle is a four-sided polygon with\nevery angle at ninety degrees. By default, the first two parameters set the\nlocation of the rectangle's upper-left corner. The third and fourth set the\nshape's the width and height, respectively. The way these parameters are\ninterpreted may be changed with the rectMode()\nfunction.
\nThe version of rect()
with five parameters creates a rounded rectangle. The\nfifth parameter is used as the radius value for all four corners.
The version of rect()
with eight parameters also creates a rounded rectangle.\nWhen using eight parameters, the latter four set the radius of the arc at\neach corner separately. The radii start with the top-left corner and move\nclockwise around the rectangle. If any of these parameters are omitted, they\nare set to the value of the last specified corner radius.
\nrect(30, 20, 55, 55);\ndescribe('A white rectangle with a black outline on a gray canvas.');\n
\n\nrect(30, 20, 55, 55, 20);\ndescribe(\n 'A white rectangle with a black outline and round edges on a gray canvas.'\n);\n
\n\nrect(30, 20, 55, 55, 20, 15, 10, 5);\ndescribe('A white rectangle with a black outline and round edges of different radii.');\n
\nDraws a square to the canvas. A square is a four-sided polygon with every\nangle at ninety degrees and equal side lengths. By default, the first two\nparameters set the location of the square's upper-left corner. The third\nparameter sets its side size. The way these parameters are interpreted may\nbe changed with the rectMode() function.
\nThe version of square()
with four parameters creates a rounded square. The\nfourth parameter is used as the radius value for all four corners.
The version of square()
with seven parameters also creates a rounded square.\nWhen using seven parameters, the latter four set the radius of the arc at\neach corner separately. The radii start with the top-left corner and move\nclockwise around the square. If any of these parameters are omitted, they\nare set to the value of the last specified corner radius.
\nsquare(30, 20, 55);\ndescribe('A white square with a black outline in on a gray canvas.');\n
\n\nsquare(30, 20, 55, 20);\ndescribe(\n 'A white square with a black outline and round edges on a gray canvas.'\n);\n
\n\nsquare(30, 20, 55, 20, 15, 10, 5);\ndescribe('A white square with a black outline and round edges of different radii.');\n
\n(x1,y1)
. The middle\ntwo parameters specify its second point (x2,y2)
. And the last two parameters\nspecify its third point (x3, y3)
.",
+ "example": [
+ "\ntriangle(30, 75, 58, 20, 86, 75);\ndescribe('A white triangle with a black outline on a gray canvas.');\n
\nModifies the location from which ellipses, circles, and arcs are drawn. By default, the\nfirst two parameters are the x- and y-coordinates of the shape's center. The next\nparameters are its width and height. This is equivalent to calling ellipseMode(CENTER)
.
ellipseMode(RADIUS)
also uses the first two parameters to set the x- and y-coordinates\nof the shape's center. The next parameters are half of the shapes's width and height.\nCalling ellipse(0, 0, 10, 15)
draws a shape with a width of 20 and height of 30.
ellipseMode(CORNER)
uses the first two parameters as the upper-left corner of the\nshape. The next parameters are its width and height.
ellipseMode(CORNERS)
uses the first two parameters as the location of one corner\nof the ellipse's bounding box. The third and fourth parameters are the location of the\nopposite corner.
The argument passed to ellipseMode()
must be written in ALL CAPS because the constants\nCENTER
, RADIUS
, CORNER
, and CORNERS
are defined this way. JavaScript is a\ncase-sensitive language.
\nellipseMode(RADIUS);\nfill(255);\nellipse(50, 50, 30, 30);\nellipseMode(CENTER);\nfill(100);\nellipse(50, 50, 30, 30);\ndescribe('A white circle with a gray circle at its center. Both circles have black outlines.');\n
\n\nellipseMode(CORNER);\nfill(255);\nellipse(25, 25, 50, 50);\nellipseMode(CORNERS);\nfill(100);\nellipse(25, 25, 50, 50);\ndescribe('A white circle with a gray circle at its top-left corner. Both circles have black outlines.');\n
\nDraws all geometry with jagged (aliased) edges.
\nsmooth() is active by default in 2D mode. It's necessary to call\nnoSmooth() to disable smoothing of geometry, images, and fonts.
\nIn WebGL mode, noSmooth() is active by default. It's necessary\nto call smooth() to draw smooth (antialiased) edges.
\n", + "example": [ + "\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\ndescribe('Two pixelated white circles on a black background.');\n
\nModifies the location from which rectangles and squares are drawn. By default,\nthe first two parameters are the x- and y-coordinates of the shape's upper-left\ncorner. The next parameters are its width and height. This is equivalent to\ncalling rectMode(CORNER)
.
rectMode(CORNERS)
also uses the first two parameters as the location of one of\nthe corners. The third and fourth parameters are the location of the opposite\ncorner.
rectMode(CENTER)
uses the first two parameters as the x- and y-coordinates of\nthe shape's center. The next parameters are its width and height.
rectMode(RADIUS)
also uses the first two parameters as the x- and y-coordinates\nof the shape's center. The next parameters are half of the shape's width and\nheight.
The argument passed to rectMode()
must be written in ALL CAPS because the\nconstants CENTER
, RADIUS
, CORNER
, and CORNERS
are defined this way.\nJavaScript is a case-sensitive language.
\nrectMode(CORNER);\nfill(255);\nrect(25, 25, 50, 50);\n\nrectMode(CORNERS);\nfill(100);\nrect(25, 25, 50, 50);\n\ndescribe('A small gray square drawn at the top-left corner of a white square.');\n
\n\nrectMode(RADIUS);\nfill(255);\nrect(50, 50, 30, 30);\n\nrectMode(CENTER);\nfill(100);\nrect(50, 50, 30, 30);\n\ndescribe('A small gray square drawn at the center of a white square.');\n
\nDraws all geometry with smooth (anti-aliased) edges. smooth() will also\nimprove image quality of resized images.
\nsmooth() is active by default in 2D mode. It's necessary to call\nnoSmooth() to disable smoothing of geometry, images, and fonts.
\nIn WebGL mode, noSmooth() is active by default. It's necessary\nto call smooth() to draw smooth (antialiased) edges.
\n", + "example": [ + "\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\ndescribe('Two pixelated white circles on a black background.');\n
\nSets the style for rendering line endings. These ends are either rounded\n(ROUND
), squared (SQUARE
), or extended (PROJECT
). The default cap is\nROUND
.
The argument passed to strokeCap()
must be written in ALL CAPS because\nthe constants ROUND
, SQUARE
, and PROJECT
are defined this way.\nJavaScript is a case-sensitive language.
\nstrokeWeight(12.0);\nstrokeCap(ROUND);\nline(20, 30, 80, 30);\nstrokeCap(SQUARE);\nline(20, 50, 80, 50);\nstrokeCap(PROJECT);\nline(20, 70, 80, 70);\ndescribe('Three horizontal lines. The top line has rounded ends, the middle line has squared ends, and the bottom line has longer, squared ends.');\n
\nSets the style of the joints which connect line segments. These joints are\neither mitered (MITER
), beveled (BEVEL
), or rounded (ROUND
). The default\njoint is MITER
in 2D mode and ROUND
in WebGL mode.
The argument passed to strokeJoin()
must be written in ALL CAPS because\nthe constants MITER
, BEVEL
, and ROUND
are defined this way.\nJavaScript is a case-sensitive language.
\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(MITER);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\ndescribe('A right-facing arrowhead shape with a pointed tip in center of canvas.');\n
\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(BEVEL);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\ndescribe('A right-facing arrowhead shape with a flat tip in center of canvas.');\n
\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(ROUND);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\ndescribe('A right-facing arrowhead shape with a rounded tip in center of canvas.');\n
\nSets the width of the stroke used for lines, points, and the border around\nshapes. All widths are set in units of pixels.
\nNote that strokeWeight()
is affected by any transformation or scaling that\nhas been applied previously.
\n// Default.\nline(20, 20, 80, 20);\n// Thicker.\nstrokeWeight(4);\nline(20, 40, 80, 40);\n// Beastly.\nstrokeWeight(10);\nline(20, 70, 80, 70);\ndescribe('Three horizontal black lines. The top line is thin, the middle is medium, and the bottom is thick.');\n
\n\n// Default.\nline(20, 20, 80, 20);\n// Adding scale transformation.\nscale(5);\n// Coordinates adjusted for scaling.\nline(4, 8, 16, 8);\ndescribe('Two horizontal black lines. The top line is thin and the bottom is five times thicker than the top.');\n
\nDraws a cubic Bezier curve on the screen. These curves are defined by a\nseries of anchor and control points. The first two parameters specify\nthe first anchor point and the last two parameters specify the other\nanchor point, which become the first and last points on the curve. The\nmiddle parameters specify the two control points which define the shape\nof the curve. Approximately speaking, control points \"pull\" the curve\ntowards them.
\nBezier curves were developed by French automotive engineer Pierre Bezier,\nand are commonly used in computer graphics to define gently sloping curves.\nSee also curve().
\n", + "example": [ + "\nnoFill();\nstroke(255, 102, 0);\nline(85, 20, 10, 10);\nline(90, 90, 15, 80);\nstroke(0, 0, 0);\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\n
\n\nbackground(0, 0, 0);\nnoFill();\nstroke(255);\nbezier(250, 250, 0, 100, 100, 0, 100, 0, 0, 0, 100, 0);\n
\nSets the resolution at which Bezier's curve is displayed. The default value is 20.
\nNote, This function is only useful when using the WEBGL renderer\nas the default canvas renderer does not use this information.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noFill();\n bezierDetail(5);\n}\n\nfunction draw() {\n background(200);\n bezier(\n -40, -40, 0,\n 90, -40, 0,\n -90, 40, 0,\n 40, 40, 0\n );\n}\n
\n\nnoFill();\nlet x1 = 85,\nx2 = 10,\nx3 = 90,\nx4 = 15;\nlet y1 = 20,\ny2 = 10,\ny3 = 90,\ny4 = 80;\nbezier(x1, y1, x2, y2, x3, y3, x4, y4);\nfill(255);\nlet steps = 10;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = bezierPoint(x1, x2, x3, x4, t);\n let y = bezierPoint(y1, y2, y3, y4, t);\n circle(x, y, 5);\n}\n
\n\nnoFill();\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\nlet steps = 6;\nfill(255);\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n // Get the location of the point\n let x = bezierPoint(85, 10, 90, 15, t);\n let y = bezierPoint(20, 10, 90, 80, t);\n // Get the tangent points\n let tx = bezierTangent(85, 10, 90, 15, t);\n let ty = bezierTangent(20, 10, 90, 80, t);\n // Calculate an angle from the tangent points\n let a = atan2(ty, tx);\n a += PI;\n stroke(255, 102, 0);\n line(x, y, cos(a) * 30 + x, sin(a) * 30 + y);\n // The following line of code makes a line\n // inverse of the above line\n //line(x, y, cos(a)*-30 + x, sin(a)*-30 + y);\n stroke(0);\n ellipse(x, y, 5, 5);\n}\n
\n\nnoFill();\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\nstroke(255, 102, 0);\nlet steps = 16;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = bezierPoint(85, 10, 90, 15, t);\n let y = bezierPoint(20, 10, 90, 80, t);\n let tx = bezierTangent(85, 10, 90, 15, t);\n let ty = bezierTangent(20, 10, 90, 80, t);\n let a = atan2(ty, tx);\n a -= HALF_PI;\n line(x, y, cos(a) * 8 + x, sin(a) * 8 + y);\n}\n
\n\nnoFill();\nstroke(255, 102, 0);\ncurve(5, 26, 5, 26, 73, 24, 73, 61);\nstroke(0);\ncurve(5, 26, 73, 24, 73, 61, 15, 65);\nstroke(255, 102, 0);\ncurve(73, 24, 73, 61, 15, 65, 15, 65);\n
\n\n// Define the curve points as JavaScript objects\nlet p1 = { x: 5, y: 26 };\nlet p2 = { x: 73, y: 24 };\nlet p3 = { x: 73, y: 61 };\nlet p4 = { x: 15, y: 65 };\nnoFill();\nstroke(255, 102, 0);\ncurve(p1.x, p1.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);\nstroke(0);\ncurve(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);\nstroke(255, 102, 0);\ncurve(p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, p4.x, p4.y);\n
\n\nnoFill();\nstroke(255, 102, 0);\ncurve(5, 26, 0, 5, 26, 0, 73, 24, 0, 73, 61, 0);\nstroke(0);\ncurve(5, 26, 0, 73, 24, 0, 73, 61, 0, 15, 65, 0);\nstroke(255, 102, 0);\ncurve(73, 24, 0, 73, 61, 0, 15, 65, 0, 15, 65, 0);\n
\nSets the resolution at which curves display. The default value is 20 while\nthe minimum value is 3.
\nThis function is only useful when using the WEBGL renderer\nas the default canvas renderer does not use this\ninformation.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n curveDetail(5);\n}\nfunction draw() {\n background(200);\n\n curve(250, 600, 0, -30, 40, 0, 30, 30, 0, -250, 600, 0);\n}\n
\n\n// Move the mouse left and right to see the curve change\nfunction setup() {\n createCanvas(100, 100);\n noFill();\n}\n\nfunction draw() {\n background(204);\n let t = map(mouseX, 0, width, -5, 5);\n curveTightness(t);\n beginShape();\n curveVertex(10, 26);\n curveVertex(10, 26);\n curveVertex(83, 24);\n curveVertex(83, 61);\n curveVertex(25, 65);\n curveVertex(25, 65);\n endShape();\n}\n
\n\nnoFill();\ncurve(5, 26, 5, 26, 73, 24, 73, 61);\ncurve(5, 26, 73, 24, 73, 61, 15, 65);\nfill(255);\nellipseMode(CENTER);\nlet steps = 6;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = curvePoint(5, 5, 73, 73, t);\n let y = curvePoint(26, 26, 24, 61, t);\n ellipse(x, y, 5, 5);\n x = curvePoint(5, 73, 73, 15, t);\n y = curvePoint(26, 24, 61, 65, t);\n ellipse(x, y, 5, 5);\n}\n
\n\nnoFill();\ncurve(5, 26, 73, 24, 73, 61, 15, 65);\nlet steps = 6;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = curvePoint(5, 73, 73, 15, t);\n let y = curvePoint(26, 24, 61, 65, t);\n //ellipse(x, y, 5, 5);\n let tx = curveTangent(5, 73, 73, 15, t);\n let ty = curveTangent(26, 24, 61, 65, t);\n let a = atan2(ty, tx);\n a -= PI / 2.0;\n line(x, y, cos(a) * 8 + x, sin(a) * 8 + y);\n}\n
\nUse the beginContour() and\nendContour() functions to create negative shapes\nwithin shapes such as the center of the letter 'O'. beginContour()\nbegins recording vertices for the shape and endContour() stops recording.\nThe vertices that define a negative shape must \"wind\" in the opposite direction\nfrom the exterior shape. First draw vertices for the exterior clockwise order, then for internal shapes, draw vertices\nshape in counter-clockwise.
\nThese functions can only be used within a beginShape()/endShape() pair and\ntransformations such as translate(), rotate(), and scale() do not work\nwithin a beginContour()/endContour() pair. It is also not possible to use\nother shapes, such as ellipse() or rect() within.
\n", + "example": [ + "\ntranslate(50, 50);\nstroke(255, 0, 0);\nbeginShape();\n// Exterior part of shape, clockwise winding\nvertex(-40, -40);\nvertex(40, -40);\nvertex(40, 40);\nvertex(-40, 40);\n// Interior part of shape, counter-clockwise winding\nbeginContour();\nvertex(-20, -20);\nvertex(-20, 20);\nvertex(20, 20);\nvertex(20, -20);\nendContour();\nendShape(CLOSE);\n
\nUsing the beginShape() and endShape() functions allow creating more\ncomplex forms. beginShape() begins recording vertices for a shape and\nendShape() stops recording. The value of the kind parameter tells it which\ntypes of shapes to create from the provided vertices. With no mode\nspecified, the shape can be any irregular polygon.
\nThe parameters available for beginShape() are:
\nPOINTS\nDraw a series of points
\nLINES\nDraw a series of unconnected line segments (individual lines)
\nTRIANGLES\nDraw a series of separate triangles
\nTRIANGLE_FAN\nDraw a series of connected triangles sharing the first vertex in a fan-like fashion
\nTRIANGLE_STRIP\nDraw a series of connected triangles in strip fashion
\nQUADS\nDraw a series of separate quads
\nQUAD_STRIP\nDraw quad strip using adjacent edges to form the next quad
\nTESS (WEBGL only)\nHandle irregular polygon for filling curve by explicit tessellation
\nAfter calling the beginShape() function, a series of vertex() commands must follow. To stop\ndrawing the shape, call endShape(). Each shape will be outlined with the\ncurrent stroke color and filled with the fill color.
\nTransformations such as translate(), rotate(), and scale() do not work\nwithin beginShape(). It is also not possible to use other shapes, such as\nellipse() or rect() within beginShape().
\n", + "example": [ + "\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n
\n\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\nbeginShape(LINES);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n
\n\nbeginShape(TRIANGLES);\nvertex(30, 75);\nvertex(40, 20);\nvertex(50, 75);\nvertex(60, 20);\nvertex(70, 75);\nvertex(80, 20);\nendShape();\n
\n\nbeginShape(TRIANGLE_STRIP);\nvertex(30, 75);\nvertex(40, 20);\nvertex(50, 75);\nvertex(60, 20);\nvertex(70, 75);\nvertex(80, 20);\nvertex(90, 75);\nendShape();\n
\n\nbeginShape(TRIANGLE_FAN);\nvertex(57.5, 50);\nvertex(57.5, 15);\nvertex(92, 50);\nvertex(57.5, 85);\nvertex(22, 50);\nvertex(57.5, 15);\nendShape();\n
\n\nbeginShape(QUADS);\nvertex(30, 20);\nvertex(30, 75);\nvertex(50, 75);\nvertex(50, 20);\nvertex(65, 20);\nvertex(65, 75);\nvertex(85, 75);\nvertex(85, 20);\nendShape();\n
\n\nbeginShape(QUAD_STRIP);\nvertex(30, 20);\nvertex(30, 75);\nvertex(50, 20);\nvertex(50, 75);\nvertex(65, 20);\nvertex(65, 75);\nvertex(85, 20);\nvertex(85, 75);\nendShape();\n
\n\nbeginShape(TESS);\nvertex(20, 20);\nvertex(80, 20);\nvertex(80, 40);\nvertex(40, 40);\nvertex(40, 60);\nvertex(80, 60);\nvertex(80, 80);\nvertex(20, 80);\nendShape(CLOSE);\n
\nSpecifies vertex coordinates for Bezier curves. Each call to\nbezierVertex() defines the position of two control points and\none anchor point of a Bezier curve, adding a new segment to a\nline or shape. For WebGL mode bezierVertex() can be used in 2D\nas well as 3D mode. 2D mode expects 6 parameters, while 3D mode\nexpects 9 parameters (including z coordinates).
\nThe first time bezierVertex() is used within a beginShape()\ncall, it must be prefaced with a call to vertex() to set the first anchor\npoint. This function must be used between beginShape() and endShape()\nand only when there is no MODE or POINTS parameter specified to\nbeginShape().
\n", + "example": [ + "\nnoFill();\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nendShape();\n
\n\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nbezierVertex(50, 80, 60, 25, 30, 20);\nendShape();\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n}\nfunction draw() {\n orbitControl();\n background(50);\n strokeWeight(4);\n stroke(255);\n point(-25, 30);\n point(25, 30);\n point(25, -30);\n point(-25, -30);\n\n strokeWeight(1);\n noFill();\n\n beginShape();\n vertex(-25, 30);\n bezierVertex(25, 30, 25, -30, -25, -30);\n endShape();\n\n beginShape();\n vertex(-25, 30, 20);\n bezierVertex(25, 30, 20, 25, -30, 20, -25, -30, 20);\n endShape();\n}\n
\nSpecifies vertex coordinates for curves. This function may only\nbe used between beginShape() and endShape() and only when there\nis no MODE parameter specified to beginShape().\nFor WebGL mode curveVertex() can be used in 2D as well as 3D mode.\n2D mode expects 2 parameters, while 3D mode expects 3 parameters.
\nThe first and last points in a series of curveVertex() lines will be used to\nguide the beginning and end of the curve. A minimum of four\npoints is required to draw a tiny curve between the second and\nthird points. Adding a fifth point with curveVertex() will draw\nthe curve between the second, third, and fourth points. The\ncurveVertex() function is an implementation of Catmull-Rom\nsplines.
\n", + "example": [ + "\nstrokeWeight(5);\npoint(84, 91);\npoint(68, 19);\npoint(21, 17);\npoint(32, 91);\nstrokeWeight(1);\n\nnoFill();\nbeginShape();\ncurveVertex(84, 91);\ncurveVertex(84, 91);\ncurveVertex(68, 19);\ncurveVertex(21, 17);\ncurveVertex(32, 91);\ncurveVertex(32, 91);\nendShape();\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n}\nfunction draw() {\n orbitControl();\n background(50);\n strokeWeight(4);\n stroke(255);\n\n point(-25, 25);\n point(-25, 25);\n point(-25, -25);\n point(25, -25);\n point(25, 25);\n point(25, 25);\n\n strokeWeight(1);\n noFill();\n\n beginShape();\n curveVertex(-25, 25);\n curveVertex(-25, 25);\n curveVertex(-25, -25);\n curveVertex(25, -25);\n curveVertex(25, 25);\n curveVertex(25, 25);\n endShape();\n\n beginShape();\n curveVertex(-25, 25, 20);\n curveVertex(-25, 25, 20);\n curveVertex(-25, -25, 20);\n curveVertex(25, -25, 20);\n curveVertex(25, 25, 20);\n curveVertex(25, 25, 20);\n endShape();\n}\n
\nUse the beginContour() and endContour() functions to create negative\nshapes within shapes such as the center of the letter 'O'. beginContour()\nbegins recording vertices for the shape and endContour() stops recording.\nThe vertices that define a negative shape must \"wind\" in the opposite\ndirection from the exterior shape. First draw vertices for the exterior\nclockwise order, then for internal shapes, draw vertices\nshape in counter-clockwise.
\nThese functions can only be used within a beginShape()/endShape() pair and\ntransformations such as translate(), rotate(), and scale() do not work\nwithin a beginContour()/endContour() pair. It is also not possible to use\nother shapes, such as ellipse() or rect() within.
\n", + "example": [ + "\ntranslate(50, 50);\nstroke(255, 0, 0);\nbeginShape();\n// Exterior part of shape, clockwise winding\nvertex(-40, -40);\nvertex(40, -40);\nvertex(40, 40);\nvertex(-40, 40);\n// Interior part of shape, counter-clockwise winding\nbeginContour();\nvertex(-20, -20);\nvertex(-20, 20);\nvertex(20, 20);\nvertex(20, -20);\nendContour();\nendShape(CLOSE);\n
\nmode
parameter to close\nthe shape (to connect the beginning and the end).\nWhen using instancing with endShape() the instancing will not apply to the strokes.\nWhen the count parameter is used with a value greater than 1, it enables instancing for shapes built when in WEBGL mode. Instancing\nis a feature that allows the GPU to efficiently draw multiples of the same shape. It's often used for particle effects or other\ntimes when you need a lot of repetition. In order to take advantage of instancing, you will also need to write your own custom\nshader using the gl_InstanceID keyword. You can read more about instancing\nhere or by working from the example on this\npage.",
+ "example": [
+ "\nnoFill();\n\nbeginShape();\nvertex(20, 20);\nvertex(45, 20);\nvertex(45, 80);\nendShape(CLOSE);\n\nbeginShape();\nvertex(50, 20);\nvertex(75, 20);\nvertex(75, 80);\nendShape();\n
\n\nlet fx;\nlet vs = `#version 300 es\n\nprecision mediump float;\n\nin vec3 aPosition;\nflat out int instanceID;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvoid main() {\n\n // copy the instance ID to the fragment shader\n instanceID = gl_InstanceID;\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n // gl_InstanceID represents a numeric value for each instance\n // using gl_InstanceID allows us to move each instance separately\n // here we move each instance horizontally by id * 23\n float xOffset = float(gl_InstanceID) * 23.0;\n\n // apply the offset to the final position\n gl_Position = uProjectionMatrix * uModelViewMatrix * (positionVec4 -\n vec4(xOffset, 0.0, 0.0, 0.0));\n}\n`;\nlet fs = `#version 300 es\n\nprecision mediump float;\n\nout vec4 outColor;\nflat in int instanceID;\nuniform float numInstances;\n\nvoid main() {\n vec4 red = vec4(1.0, 0.0, 0.0, 1.0);\n vec4 blue = vec4(0.0, 0.0, 1.0, 1.0);\n\n // Normalize the instance id\n float normId = float(instanceID) / numInstances;\n\n // Mix between two colors using the normalized instance id\n outColor = mix(red, blue, normId);\n}\n`;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n fx = createShader(vs, fs);\n}\n\nfunction draw() {\n background(220);\n\n // strokes aren't instanced, and are rather used for debug purposes\n shader(fx);\n fx.setUniform('numInstances', 4);\n\n // this doesn't have to do with instancing, this is just for centering the squares\n translate(25, -10);\n\n // here we draw the squares we want to instance\n beginShape();\n vertex(0, 0);\n vertex(0, 20);\n vertex(20, 20);\n vertex(20, 0);\n vertex(0, 0);\n endShape(CLOSE, 4);\n\n resetShader();\n}\n
\nSpecifies vertex coordinates for quadratic Bezier curves. Each call to\nquadraticVertex() defines the position of one control points and one\nanchor point of a Bezier curve, adding a new segment to a line or shape.\nThe first time quadraticVertex() is used within a beginShape() call, it\nmust be prefaced with a call to vertex() to set the first anchor point.\nFor WebGL mode quadraticVertex() can be used in 2D as well as 3D mode.\n2D mode expects 4 parameters, while 3D mode expects 6 parameters\n(including z coordinates).
\nThis function must be used between beginShape() and endShape()\nand only when there is no MODE or POINTS parameter specified to\nbeginShape().
\n", + "example": [ + "\nstrokeWeight(5);\npoint(20, 20);\npoint(80, 20);\npoint(50, 50);\n\nnoFill();\nstrokeWeight(1);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nendShape();\n
\n\nstrokeWeight(5);\npoint(20, 20);\npoint(80, 20);\npoint(50, 50);\n\npoint(20, 80);\npoint(80, 80);\npoint(80, 60);\n\nnoFill();\nstrokeWeight(1);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nquadraticVertex(20, 80, 80, 80);\nvertex(80, 60);\nendShape();\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n}\nfunction draw() {\n orbitControl();\n background(50);\n strokeWeight(4);\n stroke(255);\n\n point(-35, -35);\n point(35, -35);\n point(0, 0);\n point(-35, 35);\n point(35, 35);\n point(35, 10);\n\n strokeWeight(1);\n noFill();\n\n beginShape();\n vertex(-35, -35);\n quadraticVertex(35, -35, 0, 0);\n quadraticVertex(-35, 35, 35, 35);\n vertex(35, 10);\n endShape();\n\n beginShape();\n vertex(-35, -35, 20);\n quadraticVertex(35, -35, 20, 0, 0, 20);\n quadraticVertex(-35, 35, 20, 35, 35, 20);\n vertex(35, 10, 20);\n endShape();\n}\n
\n\nstrokeWeight(3);\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\ncreateCanvas(100, 100, WEBGL);\nbackground(240, 240, 240);\nfill(237, 34, 93);\nnoStroke();\nbeginShape();\nvertex(0, 35);\nvertex(35, 0);\nvertex(0, -35);\nvertex(-35, 0);\nendShape();\n
\n\ncreateCanvas(100, 100, WEBGL);\nbackground(240, 240, 240);\nfill(237, 34, 93);\nnoStroke();\nbeginShape();\nvertex(-10, 10);\nvertex(0, 35);\nvertex(10, 10);\nvertex(35, 0);\nvertex(10, -8);\nvertex(0, -35);\nvertex(-10, -8);\nvertex(-35, 0);\nendShape();\n
\n\nstrokeWeight(3);\nstroke(237, 34, 93);\nbeginShape(LINES);\nvertex(10, 35);\nvertex(90, 35);\nvertex(10, 65);\nvertex(90, 65);\nvertex(35, 10);\nvertex(35, 90);\nvertex(65, 10);\nvertex(65, 90);\nendShape();\n
\n\n// Click to change the number of sides.\n// In WebGL mode, custom shapes will only\n// display hollow fill sections when\n// all calls to vertex() use the same z-value.\n\nlet sides = 3;\nlet angle, px, py;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n fill(237, 34, 93);\n strokeWeight(3);\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n ngon(sides, 0, 0, 80);\n}\n\nfunction mouseClicked() {\n if (sides > 6) {\n sides = 3;\n } else {\n sides++;\n }\n}\n\nfunction ngon(n, x, y, d) {\n beginShape(TESS);\n for (let i = 0; i < n + 1; i++) {\n angle = TWO_PI / n * i;\n px = x + sin(angle) * d / 2;\n py = y - cos(angle) * d / 2;\n vertex(px, py, 0);\n }\n for (let i = 0; i < n + 1; i++) {\n angle = TWO_PI / n * i;\n px = x + sin(angle) * d / 4;\n py = y - cos(angle) * d / 4;\n vertex(px, py, 0);\n }\n endShape();\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n}\n\nfunction draw() {\n background(255);\n rotateY(frameCount / 100);\n normalMaterial();\n beginShape(TRIANGLE_STRIP);\n normal(-0.4, 0.4, 0.8);\n vertex(-30, 30, 0);\n\n normal(0, 0, 1);\n vertex(-30, -30, 30);\n vertex(30, 30, 30);\n\n normal(0.4, -0.4, 0.8);\n vertex(30, -30, 0);\n endShape();\n}\n
\nStops p5.js from continuously executing the code within draw().\nIf loop() is called, the code in draw()\nbegins to run continuously again. If using noLoop()\nin setup(), it should be the last line inside the block.
\nWhen noLoop() is used, it's not possible to manipulate\nor access the screen inside event handling functions such as\nmousePressed() or\nkeyPressed(). Instead, use those functions to\ncall redraw() or loop(),\nwhich will run draw(), which can update the screen\nproperly. This means that when noLoop() has been\ncalled, no drawing can happen, and functions like saveFrames()\nor loadPixels() may not be used.
\nNote that if the sketch is resized, redraw() will\nbe called to update the sketch, even after noLoop()\nhas been specified. Otherwise, the sketch would enter an odd state until\nloop() was called.
\nUse isLooping() to check the current state of loop().
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n noLoop();\n}\n\nfunction draw() {\n line(10, 10, 90, 90);\n}\n
\n\nlet x = 0;\nfunction setup() {\n createCanvas(100, 100);\n}\n\nfunction draw() {\n background(204);\n x = x + 0.1;\n if (x > width) {\n x = 0;\n }\n line(x, 0, x, height);\n}\n\nfunction mousePressed() {\n noLoop();\n}\n\nfunction mouseReleased() {\n loop();\n}\n
\nBy default, p5.js loops through draw() continuously, executing the code within\nit. However, the draw() loop may be stopped by calling\nnoLoop(). In that case, the draw()\nloop can be resumed with loop().
\nAvoid calling loop() from inside setup().
\nUse isLooping() to check the current state of loop().
\n", + "example": [ + "\nlet x = 0;\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n}\n\nfunction draw() {\n background(204);\n x = x + 0.1;\n if (x > width) {\n x = 0;\n }\n line(x, 0, x, height);\n}\n\nfunction mousePressed() {\n loop();\n}\n\nfunction mouseReleased() {\n noLoop();\n}\n
\n\nlet checkbox, button, colBG, colFill;\n\nfunction setup() {\n createCanvas(100, 100);\n\n button = createButton('Colorize if loop()');\n button.position(0, 120);\n button.mousePressed(changeBG);\n\n checkbox = createCheckbox('loop()', true);\n checkbox.changed(checkLoop);\n\n colBG = color(0);\n colFill = color(255);\n}\n\nfunction changeBG() {\n if (isLooping()) {\n colBG = color(random(255), random(255), random(255));\n colFill = color(random(255), random(255), random(255));\n }\n}\n\nfunction checkLoop() {\n if (this.checked()) {\n loop();\n } else {\n noLoop();\n }\n}\n\nfunction draw() {\n background(colBG);\n fill(colFill);\n ellipse(frameCount % width, height / 2, 50);\n}\n
\nThe push() function saves the current drawing style\nsettings and transformations, while pop() restores these\nsettings. Note that these functions are always used together. They allow you to\nchange the style and transformation settings and later return to what you had.\nWhen a new state is started with push(), it builds on\nthe current style and transform information. The push()\nand pop() functions can be embedded to provide more\ncontrol. (See the second example for a demonstration.)
\npush() stores information related to the current transformation state\nand style settings controlled by the following functions:\nfill(),\nnoFill(),\nnoStroke(),\nstroke(),\ntint(),\nnoTint(),\nstrokeWeight(),\nstrokeCap(),\nstrokeJoin(),\nimageMode(),\nrectMode(),\nellipseMode(),\ncolorMode(),\ntextAlign(),\ntextFont(),\ntextSize(),\ntextLeading(),\napplyMatrix(),\nresetMatrix(),\nrotate(),\nscale(),\nshearX(),\nshearY(),\ntranslate(),\nnoiseSeed().
\nIn WEBGL mode additional style settings are stored. These are controlled by the\nfollowing functions: setCamera(),\nambientLight(),\ndirectionalLight(),\npointLight(), texture(),\nspecularMaterial(),\nshininess(),\nnormalMaterial()\nand shader().
\n", + "example": [ + "\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\nstrokeWeight(10);\nfill(204, 153, 0);\ntranslate(50, 0);\nellipse(0, 50, 33, 33); // Middle circle\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\n\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\nstrokeWeight(10);\nfill(204, 153, 0);\nellipse(33, 50, 33, 33); // Left-middle circle\n\npush(); // Start another new drawing state\nstroke(0, 102, 153);\nellipse(66, 50, 33, 33); // Right-middle circle\npop(); // Restore previous state\n\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\nThe push() function saves the current drawing style\nsettings and transformations, while pop() restores\nthese settings. Note that these functions are always used together. They allow\nyou to change the style and transformation settings and later return to what\nyou had. When a new state is started with push(), it\nbuilds on the current style and transform information. The push()\nand pop() functions can be embedded to provide more\ncontrol. (See the second example for a demonstration.)
\npush() stores information related to the current transformation state\nand style settings controlled by the following functions:\nfill(),\nnoFill(),\nnoStroke(),\nstroke(),\ntint(),\nnoTint(),\nstrokeWeight(),\nstrokeCap(),\nstrokeJoin(),\nimageMode(),\nrectMode(),\nellipseMode(),\ncolorMode(),\ntextAlign(),\ntextFont(),\ntextSize(),\ntextLeading(),\napplyMatrix(),\nresetMatrix(),\nrotate(),\nscale(),\nshearX(),\nshearY(),\ntranslate(),\nnoiseSeed().
\nIn WEBGL mode additional style settings are stored. These are controlled by\nthe following functions:\nsetCamera(),\nambientLight(),\ndirectionalLight(),\npointLight(),\ntexture(),\nspecularMaterial(),\nshininess(),\nnormalMaterial() and\nshader().
\n", + "example": [ + "\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\ntranslate(50, 0);\nstrokeWeight(10);\nfill(204, 153, 0);\nellipse(0, 50, 33, 33); // Middle circle\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\n\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\nstrokeWeight(10);\nfill(204, 153, 0);\nellipse(33, 50, 33, 33); // Left-middle circle\n\npush(); // Start another new drawing state\nstroke(0, 102, 153);\nellipse(66, 50, 33, 33); // Right-middle circle\npop(); // Restore previous state\n\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\nExecutes the code within draw() one time. This\nfunction allows the program to update the display window only when necessary,\nfor example when an event registered by mousePressed()\nor keyPressed() occurs.
\nIn structuring a program, it only makes sense to call redraw()\nwithin events such as mousePressed(). This\nis because redraw() does not run\ndraw() immediately (it only sets a flag that indicates\nan update is needed).
\nThe redraw() function does not work properly when\ncalled inside draw().To enable/disable animations,\nuse loop() and noLoop().
\nIn addition you can set the number of redraws per method call. Just\nadd an integer as single parameter for the number of redraws.
\n", + "example": [ + "\nlet x = 0;\n\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n}\n\nfunction draw() {\n background(204);\n line(x, 0, x, height);\n}\n\nfunction mousePressed() {\n x += 1;\n redraw();\n}\n
\n\nlet x = 0;\n\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n}\n\nfunction draw() {\n background(204);\n x += 1;\n line(x, 0, x, height);\n}\n\nfunction mousePressed() {\n redraw(5);\n}\n
\nMultiplies the current matrix by the one specified through the parameters.\nThis is a powerful operation that can perform the equivalent of translate,\nscale, shear and rotate all at once. You can learn more about transformation\nmatrices on \nWikipedia.
\nThe naming of the arguments here follows the naming of the \nWHATWG specification and corresponds to a\ntransformation matrix of the\nform:
\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n background(200);\n // Equivalent to translate(x, y);\n applyMatrix(1, 0, 0, 1, 40 + step, 50);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n background(200);\n translate(50, 50);\n // Equivalent to scale(x, y);\n applyMatrix(1 / step, 0, 0, 1 / step, 0, 0);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n let angle = map(step, 0, 20, 0, TWO_PI);\n let cos_a = cos(angle);\n let sin_a = sin(angle);\n background(200);\n translate(50, 50);\n // Equivalent to rotate(angle);\n applyMatrix(cos_a, sin_a, -sin_a, cos_a, 0, 0);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n let angle = map(step, 0, 20, -PI / 4, PI / 4);\n background(200);\n translate(50, 50);\n // equivalent to shearX(angle);\n let shear_factor = 1 / tan(PI / 2 - angle);\n applyMatrix(1, 0, shear_factor, 1, 0, 0);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noFill();\n}\n\nfunction draw() {\n background(200);\n rotateY(PI / 6);\n stroke(153);\n box(35);\n let rad = millis() / 1000;\n // Set rotation angles\n let ct = cos(rad);\n let st = sin(rad);\n // Matrix for rotation around the Y axis\n applyMatrix(\n ct, 0.0, st, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n -st, 0.0, ct, 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n stroke(255);\n box(50);\n}\n
\n\nfunction draw() {\n background(200);\n let testMatrix = [1, 0, 0, 1, 0, 0];\n applyMatrix(testMatrix);\n rect(0, 0, 50, 50);\n}\n
\n\ntranslate(50, 50);\napplyMatrix(0.5, 0.5, -0.5, 0.5, 0, 0);\nrect(0, 0, 20, 20);\n// Note that the translate is also reset.\nresetMatrix();\nrect(0, 0, 20, 20);\n
\nRotates a shape by the amount specified by the angle parameter. This\nfunction accounts for angleMode, so angles\ncan be entered in either RADIANS or DEGREES.
\nObjects are always rotated around their relative position to the\norigin and positive numbers rotate objects in a clockwise direction.\nTransformations apply to everything that happens after and subsequent\ncalls to the function accumulate the effect. For example, calling\nrotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI).\nAll transformations are reset when draw() begins again.
\nTechnically, rotate() multiplies the current transformation matrix\nby a rotation matrix. This function can be further controlled by\npush() and pop().
\n", + "example": [ + "\ntranslate(width / 2, height / 2);\nrotate(PI / 3.0);\nrect(-26, -26, 52, 52);\n
\nRotates a shape around X axis by the amount specified in angle parameter.\nThe angles can be entered in either RADIANS or DEGREES.
\nObjects are always rotated around their relative position to the\norigin and positive numbers rotate objects in a clockwise direction.\nAll transformations are reset when draw() begins again.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n}\nfunction draw() {\n background(255);\n rotateX(millis() / 1000);\n box();\n}\n
\nRotates a shape around Y axis by the amount specified in angle parameter.\nThe angles can be entered in either RADIANS or DEGREES.
\nObjects are always rotated around their relative position to the\norigin and positive numbers rotate objects in a clockwise direction.\nAll transformations are reset when draw() begins again.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n}\nfunction draw() {\n background(255);\n rotateY(millis() / 1000);\n box();\n}\n
\nRotates a shape around Z axis by the amount specified in angle parameter.\nThe angles can be entered in either RADIANS or DEGREES.
\nThis method works in WEBGL mode only.
\nObjects are always rotated around their relative position to the\norigin and positive numbers rotate objects in a clockwise direction.\nAll transformations are reset when draw() begins again.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n}\nfunction draw() {\n background(255);\n rotateZ(millis() / 1000);\n box();\n}\n
\nIncreases or decreases the size of a shape by expanding or contracting\nvertices. Objects always scale from their relative origin to the\ncoordinate system. Scale values are specified as decimal percentages.\nFor example, the function call scale(2.0) increases the dimension of a\nshape by 200%.
\nTransformations apply to everything that happens after and subsequent\ncalls to the function multiply the effect. For example, calling scale(2.0)\nand then scale(1.5) is the same as scale(3.0). If scale() is called\nwithin draw(), the transformation is reset when the loop begins again.
\nUsing this function with the z parameter is only available in WEBGL mode.\nThis function can be further controlled with push() and pop().
\n", + "example": [ + "\nrect(30, 20, 50, 50);\nscale(0.5);\nrect(30, 20, 50, 50);\n
\n\nrect(30, 20, 50, 50);\nscale(0.5, 1.3);\nrect(30, 20, 50, 50);\n
\nShears a shape around the x-axis by the amount specified by the angle\nparameter. Angles should be specified in the current angleMode.\nObjects are always sheared around their relative position to the origin\nand positive numbers shear objects in a clockwise direction.
\nTransformations apply to everything that happens after and subsequent\ncalls to the function accumulates the effect. For example, calling\nshearX(PI/2) and then shearX(PI/2) is the same as shearX(PI).\nIf shearX() is called within the draw(),\nthe transformation is reset when the loop begins again.
\nTechnically, shearX() multiplies the current\ntransformation matrix by a rotation matrix. This function can be further\ncontrolled by the push() and pop() functions.
\n", + "example": [ + "\ntranslate(width / 4, height / 4);\nshearX(PI / 4.0);\nrect(0, 0, 30, 30);\n
\nShears a shape around the y-axis the amount specified by the angle\nparameter. Angles should be specified in the current angleMode. Objects\nare always sheared around their relative position to the origin and\npositive numbers shear objects in a clockwise direction.
\nTransformations apply to everything that happens after and subsequent\ncalls to the function accumulates the effect. For example, calling\nshearY(PI/2) and then shearY(PI/2) is the same as shearY(PI). If\nshearY() is called within the draw(), the transformation is reset when\nthe loop begins again.
\nTechnically, shearY() multiplies the current transformation matrix by a\nrotation matrix. This function can be further controlled by the\npush() and pop() functions.
\n", + "example": [ + "\ntranslate(width / 4, height / 4);\nshearY(PI / 4.0);\nrect(0, 0, 30, 30);\n
\nSpecifies an amount to displace objects within the display window.\nThe x parameter specifies left/right translation, the y parameter\nspecifies up/down translation.
\nTransformations are cumulative and apply to everything that happens after\nand subsequent calls to the function accumulates the effect. For example,\ncalling translate(50, 0) and then translate(20, 0) is the same as\ntranslate(70, 0). If translate() is called within draw(), the\ntransformation is reset when the loop begins again. This function can be\nfurther controlled by using push() and pop().
\n", + "example": [ + "\ntranslate(30, 20);\nrect(0, 0, 55, 55);\n
\n\nrect(0, 0, 55, 55); // Draw rect at original 0,0\ntranslate(30, 20);\nrect(0, 0, 55, 55); // Draw rect at new 0,0\ntranslate(14, 14);\nrect(0, 0, 55, 55); // Draw rect at new 0,0\n
\n\nfunction draw() {\n background(200);\n rectMode(CENTER);\n translate(width / 2, height / 2);\n translate(p5.Vector.fromAngle(millis() / 1000, 40));\n rect(0, 0, 20, 20);\n}\n
\nStores a value in local storage under the key name.\nLocal storage is saved in the browser and persists\nbetween browsing sessions and page reloads.\nThe key can be the name of the variable but doesn't\nhave to be. To retrieve stored items\nsee getItem.
\nSensitive data such as passwords or personal information\nshould not be stored in local storage.
\n", + "example": [ + "\n// Type to change the letter in the\n// center of the canvas.\n// If you reload the page, it will\n// still display the last key you entered\n\nlet myText;\n\nfunction setup() {\n createCanvas(100, 100);\n myText = getItem('myText');\n if (myText === null) {\n myText = '';\n }\n describe(`When you type the key name is displayed as black text on white background.\n If you reload the page, the last letter typed is still displaying.`);\n}\n\nfunction draw() {\n textSize(40);\n background(255);\n text(myText, width / 2, height / 2);\n}\n\nfunction keyPressed() {\n myText = key;\n storeItem('myText', myText);\n}\n
\n// Click the mouse to change\n// the color of the background\n// Once you have changed the color\n// it will stay changed even when you\n// reload the page.\n\nlet myColor;\n\nfunction setup() {\n createCanvas(100, 100);\n myColor = getItem('myColor');\n}\n\nfunction draw() {\n if (myColor !== null) {\n background(myColor);\n }\n describe(`If you click, the canvas changes to a random color.·\n If you reload the page, the canvas is still the color it was when the\n page was previously loaded.`);\n}\n\nfunction mousePressed() {\n myColor = color(random(255), random(255), random(255));\n storeItem('myColor', myColor);\n}\n
\nfunction setup() {\n let myNum = 10;\n let myBool = false;\n storeItem('myNum', myNum);\n storeItem('myBool', myBool);\n print(getItem('myNum')); // logs 10 to the console\n print(getItem('myBool')); // logs false to the console\n clearStorage();\n print(getItem('myNum')); // logs null to the console\n print(getItem('myBool')); // logs null to the console\n}\n
\nfunction setup() {\n let myVar = 10;\n storeItem('myVar', myVar);\n print(getItem('myVar')); // logs 10 to the console\n removeItem('myVar');\n print(getItem('myVar')); // logs null to the console\n}\n
\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n print(myDictionary.hasKey('p5')); // logs true to console\n\n let anotherDictionary = createStringDict({ happy: 'coding' });\n print(anotherDictionary.hasKey('happy')); // logs true to console\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict(100, 42);\n print(myDictionary.hasKey(100)); // logs true to console\n\n let anotherDictionary = createNumberDict({ 200: 84 });\n print(anotherDictionary.hasKey(200)); // logs true to console\n}\n
Searches the page for the first element that matches the given\nCSS selector string.\nThe string can be an ID, class, tag name, or a combination. select()
\nreturns a p5.Element object if it finds a match\nand null
otherwise.
The second parameter, container
, is optional. It specifies a container to\nsearch within. container can be CSS selector string, a\np5.Element object, or an\nHTMLElement object.
\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n\n // Select the canvas by its tag.\n let cnv = select('canvas');\n cnv.style('border', '5px deeppink dashed');\n\n describe('A gray square with a dashed pink border.');\n}\n
\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n // Add a class attribute to the canvas.\n cnv.class('pinkborder');\n\n background(200);\n\n // Select the canvas by its class.\n cnv = select('.pinkborder');\n // Style its border.\n cnv.style('border', '5px deeppink dashed');\n\n describe('A gray square with a dashed pink border.');\n}\n
\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n // Set the canvas ID.\n cnv.id('mycanvas');\n\n background(200);\n\n // Select the canvas by its ID.\n cnv = select('#mycanvas');\n // Style its border.\n cnv.style('border', '5px deeppink dashed');\n\n describe('A gray square with a dashed pink border.');\n}\n
\nSearches the page for all elements that matches the given\nCSS selector string.\nThe string can be an ID, class, tag name, or a combination. selectAll()
\nreturns an array of p5.Element objects if it\nfinds any matches and an empty array otherwise.
The second parameter, container
, is optional. It specifies a container to\nsearch within. container can be CSS selector string, a\np5.Element object, or an\nHTMLElement object.
\nfunction setup() {\n // Create three buttons.\n createButton('1');\n createButton('2');\n createButton('3');\n\n // Select the buttons by their tag.\n let buttons = selectAll('button');\n\n // Position the buttons.\n for (let i = 0; i < 3; i += 1) {\n buttons[i].position(0, i * 30);\n }\n\n describe('Three buttons stacked vertically. The buttons are labeled, \"1\", \"2\", and \"3\".');\n}\n
\n\nfunction setup() {\n // Create three buttons and position them.\n let b1 = createButton('1');\n b1.position(0, 0);\n let b2 = createButton('2');\n b2.position(0, 30);\n let b3 = createButton('3');\n b3.position(0, 60);\n\n // Add a class attribute to each button.\n b1.class('btn');\n b2.class('btn btn-pink');\n b3.class('btn');\n\n // Select the buttons by their class.\n let buttons = selectAll('.btn');\n let pinkButtons = selectAll('.btn-pink');\n\n // Style the selected buttons.\n buttons.forEach(btn => {\n btn.style('font-family', 'Comic Sans MS');\n });\n\n pinkButtons.forEach(btn => {\n btn.style('background', 'deeppink');\n btn.style('color', 'white');\n });\n\n describe('Three buttons stacked vertically. The buttons are labeled, \"1\", \"2\", and \"3\". Buttons \"1\" and \"3\" are gray. Button \"2\" is pink.');\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n\n // Create a paragraph element and place\n // it in the middle of the canvas.\n let p = createP('p5*js');\n p.position(25, 25);\n\n describe('A gray square with the text \"p5*js\" written in its center. The text disappears when the mouse is pressed.');\n}\n\nfunction mousePressed() {\n removeElements();\n}\n
\n\nlet slider;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Create a paragraph element and place\n // it at the top of the canvas.\n let p = createP('p5*js');\n p.position(25, 25);\n\n // Create a slider element and place it\n // beneath the canvas.\n slider = createSlider(0, 255, 200);\n slider.position(0, 100);\n\n describe('A gray square with the text \"p5*js\" written in its center and a range slider beneath it. The square changes color when the slider is moved. The text and slider disappear when the square is double-clicked.');\n}\n\nfunction draw() {\n // Use the slider value to change the background color.\n let g = slider.value();\n background(g);\n}\n\nfunction doubleClicked() {\n removeElements();\n}\n
\nmyElement.changed()
sets a function to call when the value of the\np5.Element object changes. Calling\nmyElement.changed(false)
disables the function.",
+ "example": [
+ "\nfunction setup() {\n background(200);\n\n // Create a dropdown menu and add a few color options.\n let drop = createSelect();\n drop.position(0, 0);\n drop.option('red');\n drop.option('green');\n drop.option('blue');\n\n // When the color option changes, paint the background with\n // that color.\n drop.changed(() => {\n let c = drop.value();\n background(c);\n });\n\n describe('A gray square with a dropdown menu at the top. The square changes color when an option is selected.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create a checkbox and place it beneath the canvas.\n let checkbox = createCheckbox(' circle');\n checkbox.position(0, 100);\n\n // When the checkbox changes, paint the background gray\n // and determine whether to draw a circle.\n checkbox.changed(() => {\n background(200);\n if (checkbox.checked() === true) {\n circle(50, 50, 30);\n }\n });\n\n describe('A gray square with a checkbox underneath it that says \"circle\". A white circle appears when the box is checked and disappears otherwise.');\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "input",
+ "file": "src/dom/dom.js",
+ "line": 426,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "myElement.input()
sets a function to call when input is detected within\nthe p5.Element object. It's often used to with\ntext inputs and sliders. Calling myElement.input(false)
disables the\nfunction.",
+ "example": [
+ "\nfunction setup() {\n background(200);\n\n // Create a slider and place it beneath the canvas.\n let slider = createSlider(0, 255, 200);\n slider.position(0, 100);\n\n // When the slider changes, use its value to paint\n // the background.\n slider.input(() => {\n let g = slider.value();\n background(g);\n });\n\n describe('A gray square with a range slider underneath it. The background changes shades of gray when the slider is moved.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create an input and place it beneath the canvas.\n let inp = createInput('');\n inp.position(0, 100);\n\n // When input is detected, paint the background gray\n // and display the text.\n inp.input(() => {\n background(200);\n let msg = inp.value();\n text(msg, 5, 50);\n });\n\n describe('A gray square with a text input bar beneath it. Any text written in the input appears in the middle of the square.');\n}\n
\nfalse
disables the function.",
+ "type": "Function|Boolean"
+ }
+ ]
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "addElement",
+ "file": "src/dom/dom.js",
+ "line": 434,
+ "itemtype": "method",
+ "description": "Helpers for create methods.",
+ "example": [],
+ "overloads": [
+ {
+ "params": []
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createDiv",
+ "file": "src/dom/dom.js",
+ "line": 482,
+ "itemtype": "method",
+ "description": "Creates a <div></div>
element. It's commonly used as a\ncontainer for other elements.
The parameter html
is optional. It accepts a string that sets the\ninner HTML of the new <div></div>
.
\nfunction setup() {\n background(200);\n\n let div = createDiv('p5*js');\n div.position(25, 35);\n\n describe('A gray square with the text \"p5*js\" written in its center.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create an h3 element within the div.\n let div = createDiv('p5*js
');\n div.position(20, 5);\n\n describe('A gray square with the text \"p5*js\" written in its center.');\n}\n
\n<div></div>
element.",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createP",
+ "file": "src/dom/dom.js",
+ "line": 512,
+ "itemtype": "method",
+ "description": "Creates a <p></p>
element. It's commonly used for\nparagraph-length text.
The parameter html
is optional. It accepts a string that sets the\ninner HTML of the new <p></p>
.
\nfunction setup() {\n background(200);\n\n let p = createP('Tell me a story.');\n p.position(5, 0);\n\n describe('A gray square displaying the text \"Tell me a story.\" written in black.');\n}\n
\n<p></p>
element.",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createSpan",
+ "file": "src/dom/dom.js",
+ "line": 577,
+ "itemtype": "method",
+ "description": "Creates a <span></span>
element. It's commonly used as a\ncontainer for inline elements. For example, a <span></span>
\ncan hold part of a sentence that's a\ndifferent style.
The parameter html
is optional. It accepts a string that sets the\ninner HTML of the new <span></span>
.
\nfunction setup() {\n background(200);\n\n // Create a span element.\n let span = createSpan('p5*js');\n span.position(25, 35);\n\n describe('A gray square with the text \"p5*js\" written in its center.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create a div element as\n // a container.\n let div = createDiv();\n // Place the div at the\n // center.\n div.position(25, 35);\n\n // Create a span element.\n let s1 = createSpan('p5');\n // Create a second span element.\n let s2 = createSpan('*');\n // Set the span's font color.\n s2.style('color', 'deeppink');\n // Create a third span element.\n let s3 = createSpan('js');\n\n // Add all the spans to the\n // container div.\n s1.parent(div);\n s2.parent(div);\n s3.parent(div);\n\n describe('A gray square with the text \"p5*js\" written in black at its center. The asterisk is pink.');\n}\n
\n<span></span>
element.",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createImg",
+ "file": "src/dom/dom.js",
+ "line": 633,
+ "itemtype": "method",
+ "description": "Creates an <img>
element that can appear outside of the canvas.
The first parameter, src
, is a string with the path to the image file.\nsrc
should be a relative path, as in 'assets/image.png'
, or a URL, as\nin 'https://example.com/image.png'
.
The second parameter, alt
, is a string with the\nalternate text\nfor the image. An empty string ''
can be used for images that aren't displayed.
The third parameter, crossOrigin
, is optional. It's a string that sets the\ncrossOrigin property\nof the image. Use 'anonymous'
or 'use-credentials'
to fetch the image\nwith cross-origin access.
The fourth parameter, callback
, is also optional. It sets a function to\ncall after the image loads. The new image is passed to the callback\nfunction as a p5.Element object.
\nfunction setup() {\n background(200);\n\n let img = createImg(\n 'https://p5js.org/assets/img/asterisk-01.png',\n 'The p5.js magenta asterisk.'\n );\n img.position(0, -10);\n\n describe('A gray square with a magenta asterisk in its center.');\n}\n
\nCreates an <a></a>
element that links to another web page.
The first parmeter, href
, is a string that sets the URL of the linked\npage.
The second parameter, html
, is a string that sets the inner HTML of the\nlink. It's common to use text, images, or buttons as links.
The third parameter, target
, is optional. It's a string that tells the\nweb browser where to open the link. By default, links open in the current\nbrowser tab. Passing '_blank'
will cause the link to open in a new\nbrowser tab. MDN describes a few\nother options.
\nfunction setup() {\n background(200);\n\n // Create an anchor element that links to p5js.org.\n let a = createA('http://p5js.org/', 'p5*js');\n a.position(25, 35);\n\n describe('The text \"p5*js\" written at the center of a gray square.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create an anchor element that links to p5js.org.\n // Open the link in a new tab.\n let a = createA('http://p5js.org/', 'p5*js', '_blank');\n a.position(25, 35);\n\n describe('The text \"p5*js\" written at the center of a gray square.');\n}\n
\n'_blank'
, '_self'
, '_parent'
, or '_top'
.",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createSlider",
+ "file": "src/dom/dom.js",
+ "line": 827,
+ "itemtype": "method",
+ "description": "Creates a slider <input></input>
element. Range sliders are\nuseful for quickly selecting numbers from a given range.
The first two parameters, min
and max
, are numbers that set the\nslider's minimum and maximum.
The third parameter, value
, is optional. It's a number that sets the\nslider's default value.
The fourth parameter, step
, is also optional. It's a number that sets the\nspacing between each value in the slider's range. Setting step
to 0\nallows the slider to move smoothly from min
to max
.
\nlet slider;\n\nfunction setup() {\n // Create a slider and place it at the top of the canvas.\n slider = createSlider(0, 255);\n slider.position(10, 10);\n slider.size(80);\n\n describe('A dark gray square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n // Use the slider as a grayscale value.\n let g = slider.value();\n background(g);\n}\n
\n\nlet slider;\n\nfunction setup() {\n // Create a slider and place it at the top of the canvas.\n // Set its default value to 0.\n slider = createSlider(0, 255, 0);\n slider.position(10, 10);\n slider.size(80);\n\n describe('A black square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n // Use the slider as a grayscale value.\n let g = slider.value();\n background(g);\n}\n
\n\nlet slider;\n\nfunction setup() {\n // Create a slider and place it at the top of the canvas.\n // Set its default value to 0.\n // Set its step size to 50.\n slider = createSlider(0, 255, 0, 50);\n slider.position(10, 10);\n slider.size(80);\n\n describe('A black square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n // Use the slider as a grayscale value.\n let g = slider.value();\n background(g);\n}\n
\n\nlet slider;\n\nfunction setup() {\n // Create a slider and place it at the top of the canvas.\n // Set its default value to 0.\n // Set its step size to 0 so that it moves smoothly.\n slider = createSlider(0, 255, 0, 0);\n slider.position(10, 10);\n slider.size(80);\n\n describe('A black square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n // Use the slider as a grayscale value.\n let g = slider.value();\n background(g);\n}\n
\nCreates a <button></button>
element.
The first parameter, label
, is a string that sets the label displayed on\nthe button.
The second parameter, value
, is optional. It's a string that sets the\nbutton's value. See\nMDN\nfor more details.
\nfunction setup() {\n background(200);\n\n // Create a button and place it beneath the canvas.\n let button = createButton('click me');\n button.position(0, 100);\n\n // Use the button to change the background color.\n button.mousePressed(() => {\n let g = random(255);\n background(g);\n });\n\n describe('A gray square with a button that says \"click me\" beneath it. The square changes color when the button is clicked.');\n}\n
\n\nlet button;\n\nfunction setup() {\n // Create a button and set its value to 0.\n // Place the button beneath the canvas.\n button = createButton('click me', 'red');\n button.position(0, 100);\n\n // Change the button's value when the mouse\n // is pressed.\n button.mousePressed(() => {\n let c = random(['red', 'green', 'blue', 'yellow']);\n button.value(c);\n });\n\n describe('A red square with a button that says \"click me\" beneath it. The square changes color when the button is clicked.');\n}\n\nfunction draw() {\n // Use the button's value to set the background color.\n let c = button.value();\n background(c);\n}\n
\nCreates a checkbox <input></input>
element. Checkboxes extend\nthe p5.Element class with a checked()
method.\nCalling myBox.checked()
returns true
if it the box is checked and\nfalse
otherwise.
The first parameter, label
, is optional. It's a string that sets the label\nto display next to the checkbox.
The second parameter, value
, is also optional. It's a boolean that sets the\ncheckbox's value.
\nlet checkbox;\n\nfunction setup() {\n // Create a checkbox and place it beneath the canvas.\n checkbox = createCheckbox();\n checkbox.position(0, 100);\n\n describe('A black square with a checkbox beneath it. The square turns white when the box is checked.');\n}\n\nfunction draw() {\n // Use the checkbox to set the background color.\n if (checkbox.checked()) {\n background(255);\n } else {\n background(0);\n }\n}\n
\n\nlet checkbox;\n\nfunction setup() {\n // Create a checkbox and place it beneath the canvas.\n // Label the checkbox \"white\".\n checkbox = createCheckbox(' white');\n checkbox.position(0, 100);\n\n describe('A black square with a checkbox labeled \"white\" beneath it. The square turns white when the box is checked.');\n}\n\nfunction draw() {\n // Use the checkbox to set the background color.\n if (checkbox.checked()) {\n background(255);\n } else {\n background(0);\n }\n}\n
\n\nlet checkbox;\n\nfunction setup() {\n // Create a checkbox and place it beneath the canvas.\n // Label the checkbox \"white\" and set its value to true.\n checkbox = createCheckbox(' white', true);\n checkbox.position(0, 100);\n\n describe('A white square with a checkbox labeled \"white\" beneath it. The square turns black when the box is unchecked.');\n}\n\nfunction draw() {\n // Use the checkbox to set the background color.\n if (checkbox.checked()) {\n background(255);\n } else {\n background(0);\n }\n}\n
\ntrue
and unchecked is false
.",
+ "optional": 1,
+ "type": "boolean"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createSelect",
+ "file": "src/dom/dom.js",
+ "line": 1214,
+ "itemtype": "method",
+ "description": "Creates a dropdown menu <select></select>
element.
The parameter is optional. If true
is passed, as in\nlet mySelect = createSelect(true)
, then the dropdown will support\nmultiple selections. If an existing <select></select>
element\nis passed, as in let mySelect = createSelect(otherSelect)
, the existing\nelement will be wrapped in a new p5.Element\nobject.
Dropdowns extend the p5.Element class with a few\nhelpful methods for managing options:
\nmySelect.option(name, [value])
adds an option to the menu. The first paremeter, name
, is a string that sets the option's name and value. The second parameter, value
, is optional. If provided, it sets the value that corresponds to the key name
. If an option with name
already exists, its value is changed to value
.mySelect.value()
returns the currently-selected option's value.mySelect.selected()
returns the currently-selected option.mySelect.selected(option)
selects the given option by default.mySelect.disable()
marks the whole dropdown element as disabled.mySelect.disable(option)
marks a given option as disabled.mySelect.enable()
marks the whole dropdown element as enabled.mySelect.enable(option)
marks a given option as enabled.\nlet mySelect;\n\nfunction setup() {\n // Create a dropdown and place it beneath the canvas.\n mySelect = createSelect();\n mySelect.position(0, 100);\n\n // Add color options.\n mySelect.option('red');\n mySelect.option('green');\n mySelect.option('blue');\n mySelect.option('yellow');\n\n // Set the selected option to \"red\".\n mySelect.selected('red');\n\n describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');\n}\n\nfunction draw() {\n // Use the selected value to paint the background.\n let c = mySelect.selected();\n background(c);\n}\n
\n\nlet mySelect;\n\nfunction setup() {\n // Create a dropdown and place it beneath the canvas.\n mySelect = createSelect();\n mySelect.position(0, 100);\n\n // Add color options.\n mySelect.option('red');\n mySelect.option('green');\n mySelect.option('blue');\n mySelect.option('yellow');\n\n // Set the selected option to \"red\".\n mySelect.selected('red');\n\n // Disable the \"yellow\" option.\n mySelect.disable('yellow');\n\n describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');\n}\n\nfunction draw() {\n // Use the selected value to paint the background.\n let c = mySelect.selected();\n background(c);\n}\n
\n\nlet mySelect;\n\nfunction setup() {\n // Create a dropdown and place it beneath the canvas.\n mySelect = createSelect();\n mySelect.position(0, 100);\n\n // Add color options with names and values.\n mySelect.option('one', 'red');\n mySelect.option('two', 'green');\n mySelect.option('three', 'blue');\n mySelect.option('four', 'yellow');\n\n // Set the selected option to \"one\".\n mySelect.selected('one');\n\n describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');\n}\n\nfunction draw() {\n // Use the selected value to paint the background.\n let c = mySelect.selected();\n background(c);\n}\n
\n\n// Hold CTRL to select multiple options on Windows and Linux.\n// Hold CMD to select multiple options on macOS.\nlet mySelect;\n\nfunction setup() {\n // Create a dropdown and allow multiple selections.\n // Place it beneath the canvas.\n mySelect = createSelect(true);\n mySelect.position(0, 100);\n\n // Add color options.\n mySelect.option('red');\n mySelect.option('green');\n mySelect.option('blue');\n mySelect.option('yellow');\n\n describe('A gray square with a dropdown menu beneath it. Colorful circles appear when their color is selected.');\n}\n\nfunction draw() {\n background(200);\n\n // Use the selected value(s) to draw circles.\n let colors = mySelect.selected();\n colors.forEach((c, index) => {\n let x = 10 + index * 20;\n fill(c);\n circle(x, 50, 20);\n });\n}\n
\nCreates a radio button element.
\nThe parameter is optional. If a string is passed, as in\nlet myRadio = createSelect('food')
, then each radio option will\nhave \"food\"
as its name
parameter: <input name=\"food\"></input>
.\nIf an existing <div></div>
or <span></span>
\nelement is passed, as in let myRadio = createSelect(container)
, it will\nbecome the radio button's parent element.
Radio buttons extend the p5.Element class with a few\nhelpful methods for managing options:
\nmyRadio.option(value, [label])
adds an option to the menu. The first paremeter, value
, is a string that sets the option's value and label. The second parameter, label
, is optional. If provided, it sets the label displayed for the value
. If an option with value
already exists, its label is changed and its value is returned.myRadio.value()
returns the currently-selected option's value.myRadio.selected()
returns the currently-selected option.myRadio.selected(value)
selects the given option and returns it as an HTMLInputElement
.myRadio.disable(shouldDisable)
enables the entire radio button if true
is passed and disables it if false
is passed.\nlet myRadio;\n\nfunction setup() {\n // Create a radio button element and place it\n // in the top-left corner.\n myRadio = createRadio();\n myRadio.position(0, 0);\n myRadio.size(60);\n\n // Add a few color options.\n myRadio.option('red');\n myRadio.option('yellow');\n myRadio.option('blue');\n\n // Choose a default option.\n myRadio.selected('yellow');\n\n describe('A yellow square with three color options listed, \"red\", \"yellow\", and \"blue\". The square changes color when the user selects a new option.');\n}\n\nfunction draw() {\n // Set the background color using the radio button.\n let g = myRadio.value();\n background(g);\n}\n
\n\nlet myRadio;\n\nfunction setup() {\n // Create a radio button element and place it\n // in the top-left corner.\n myRadio = createRadio();\n myRadio.position(0, 0);\n myRadio.size(50);\n\n // Add a few color options.\n // Color values are labeled with\n // emotions they evoke.\n myRadio.option('red', 'love');\n myRadio.option('yellow', 'joy');\n myRadio.option('blue', 'trust');\n\n // Choose a default option.\n myRadio.selected('yellow');\n\n describe('A yellow square with three options listed, \"love\", \"joy\", and \"trust\". The square changes color when the user selects a new option.');\n}\n\nfunction draw() {\n // Set the background color using the radio button.\n let c = myRadio.value();\n background(c);\n}\n
\n\nlet myRadio;\n\nfunction setup() {\n // Create a radio button element and place it\n // in the top-left corner.\n myRadio = createRadio();\n myRadio.position(0, 0);\n myRadio.size(50);\n\n // Add a few color options.\n myRadio.option('red');\n myRadio.option('yellow');\n myRadio.option('blue');\n\n // Choose a default option.\n myRadio.selected('yellow');\n\n // Create a button and place it beneath the canvas.\n let btn = createButton('disable');\n btn.position(0, 100);\n\n // Use the button to disable the radio button.\n btn.mousePressed(() => {\n myRadio.disable(true);\n });\n\n describe('A yellow square with three options listed, \"red\", \"yellow\", and \"blue\". The square changes color when the user selects a new option. A \"disable\" button beneath the canvas disables the color options when pressed.');\n}\n\nfunction draw() {\n // Set the background color using the radio button.\n let c = myRadio.value();\n background(c);\n}\n
\n<div></div>
\nor <span></span>
.",
+ "optional": 1,
+ "type": "Object"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ },
+ {
+ "params": [
+ {
+ "name": "name",
+ "description": "name parameter assigned to each option's <input></input>
element.",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ },
+ {
+ "params": [],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createColorPicker",
+ "file": "src/dom/dom.js",
+ "line": 1672,
+ "itemtype": "method",
+ "description": "Creates a color picker element.
\nThe parameter, value
, is optional. If a color string or\np5.Color object is passed, it will set the default\ncolor.
Color pickers extend the p5.Element class with a\ncouple of helpful methods for managing colors:
\nmyPicker.value()
returns the current color as a hex string in the format '#rrggbb'
.myPicker.color()
returns the current color as a p5.Color object.\nlet myPicker;\n\nfunction setup() {\n myPicker = createColorPicker('deeppink');\n myPicker.position(0, 100);\n\n describe('A pink square with a color picker beneath it. The square changes color when the user picks a new color.');\n}\n\nfunction draw() {\n // Use the color picker to paint the background.\n let c = myPicker.color();\n background(c);\n}\n
\n\nlet myPicker;\n\nfunction setup() {\n myPicker = createColorPicker('deeppink');\n myPicker.position(0, 100);\n\n describe('A number with the format \"#rrggbb\" is displayed on a pink canvas. The background color and number change when the user picks a new color.');\n}\n\nfunction draw() {\n // Use the color picker to paint the background.\n let c = myPicker.value();\n background(c);\n\n // Display the current color as a hex string.\n text(c, 25, 55);\n}\n
\nCreates a text <input></input>
element. Call myInput.size()
\nto set the length of the text box.
The first parameter, value
, is optional. It's a string that sets the\ninput's default value. The input is blank by default.
The second parameter, type
, is also optional. It's a string that\nspecifies the type of text being input. See MDN for a full\nlist of options.\nThe default is 'text'
.
\nlet myInput;\n\nfunction setup() {\n // Create an input element and place it\n // beneath the canvas.\n myInput = createInput();\n myInput.position(0, 100);\n\n describe('A gray square with a text box beneath it. The text in the square changes when the user types something new in the input bar.');\n}\n\nfunction draw() {\n background(200);\n\n // Use the input to display a message.\n let msg = myInput.value();\n text(msg, 25, 55);\n}\n
\n\nlet myInput;\n\nfunction setup() {\n // Create an input element and place it\n // beneath the canvas. Set its default\n // text to \"hello!\".\n myInput = createInput('hello!');\n myInput.position(0, 100);\n\n describe('The text \"hello!\" written at the center of a gray square. A text box beneath the square also says \"hello!\". The text in the square changes when the user types something new in the input bar.');\n}\n\nfunction draw() {\n background(200);\n\n // Use the input to display a message.\n let msg = myInput.value();\n text(msg, 25, 55);\n}\n
\n''
.",
+ "optional": 1,
+ "type": "String"
+ },
+ {
+ "name": "type",
+ "description": "type of input. Defaults to 'text'
.",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ }
+ },
+ {
+ "params": [
+ {
+ "name": "value",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "",
+ "type": "p5.Element"
+ }
+ }
+ ],
+ "return": {
+ "description": "new p5.Element object.",
+ "type": "p5.Element"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "createFileInput",
+ "file": "src/dom/dom.js",
+ "line": 1879,
+ "itemtype": "method",
+ "description": "Creates an <input></input>
element of type 'file'
.\nThis allows users to select local files for use in a sketch.
The first parameter, callback
, is a function that's called when the file\nloads. The callback function should have one parameter, file
, that's a\np5.File object.
The second parameter, multiple
, is optional. It's a boolean value that\nallows loading multiple files if set to true
. If true
, callback
\nwill be called once per file.
\n// Use the file input to select an image to\n// load and display.\nlet input;\nlet img;\n\nfunction setup() {\n // Create a file input and place it beneath\n // the canvas.\n input = createFileInput(handleImage);\n input.position(0, 100);\n\n describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.');\n}\n\nfunction draw() {\n background(200);\n\n // Draw the image if loaded.\n if (img) {\n image(img, 0, 0, width, height);\n }\n}\n\n// Create an image if the file is an image.\nfunction handleImage(file) {\n if (file.type === 'image') {\n img = createImg(file.data, '');\n img.hide();\n } else {\n img = null;\n }\n}\n
\n\n// Use the file input to select multiple images\n// to load and display.\nlet input;\nlet images = [];\n\nfunction setup() {\n // Create a file input and place it beneath\n // the canvas. Allow it to load multiple files.\n input = createFileInput(handleImage, true);\n input.position(0, 100);\n}\n\nfunction draw() {\n background(200);\n\n // Draw the images if loaded. Each image\n // is drawn 20 pixels lower than the\n // previous image.\n images.forEach((img, index) => {\n let y = index * 20;\n image(img, 0, y, width, height);\n });\n\n describe('A gray square with a file input beneath it. If the user selects multiple image files to load, they are displayed on the square.');\n}\n\n// Create an image if the file is an image,\n// then add it to the images array.\nfunction handleImage(file) {\n if (file.type === 'image') {\n let img = createImg(file.data, '');\n img.hide();\n images.push(img);\n }\n}\n
\nCreates a <video>
element for simple audio/video playback.\nReturns a new p5.MediaElement object.
Videos are shown by default. They can be hidden by calling video.hide()
\nand drawn to the canvas using image().
The first parameter, src
, is the path the video. If a single string is\npassed, as in 'assets/topsecret.mp4'
, a single video is loaded. An array\nof strings can be used to load the same video in different formats. For\nexample, ['assets/topsecret.mp4', 'assets/topsecret.ogv', 'assets/topsecret.webm']
.\nThis is useful for ensuring that the video can play across different browsers with\ndifferent capabilities. See\nMDN\nfor more information about supported formats.
The second parameter, callback
, is optional. It's a function to call once\nthe video is ready to play.
\nfunction setup() {\n noCanvas();\n\n // Load a video and add it to the page.\n // Note: this may not work in some browsers.\n let video = createVideo('assets/small.mp4');\n // Show the default video controls.\n video.showControls();\n\n describe('A video of a toy robot with playback controls beneath it.');\n}\n
\n\nfunction setup() {\n noCanvas();\n\n // Load a video and add it to the page.\n // Provide an array options for different file formats.\n let video = createVideo(\n ['assets/small.mp4', 'assets/small.ogv', 'assets/small.webm']\n );\n // Show the default video controls.\n video.showControls();\n\n describe('A video of a toy robot with playback controls beneath it.');\n}\n
\n\nlet video;\n\nfunction setup() {\n noCanvas();\n\n // Load a video and add it to the page.\n // Provide an array options for different file formats.\n // Call mute() once the video loads.\n video = createVideo(\n ['assets/small.mp4', 'assets/small.ogv', 'assets/small.webm'],\n muteVideo\n );\n // Show the default video controls.\n video.showControls();\n\n describe('A video of a toy robot with playback controls beneath it.');\n}\n\n// Mute the video once it loads.\nfunction muteVideo() {\n video.volume(0);\n}\n
\nCreates a hidden <audio>
element for simple audio playback.\nReturns a new p5.MediaElement object.
The first parameter, src
, is the path the video. If a single string is\npassed, as in 'assets/video.mp4'
, a single video is loaded. An array\nof strings can be used to load the same video in different formats. For\nexample, ['assets/video.mp4', 'assets/video.ogv', 'assets/video.webm']
.\nThis is useful for ensuring that the video can play across different\nbrowsers with different capabilities. See\nMDN\nfor more information about supported formats.
The second parameter, callback
, is optional. It's a function to call once\nthe audio is ready to play.
\nfunction setup() {\n noCanvas();\n\n // Load the audio.\n let beat = createAudio('assets/beat.mp3');\n // Show the default audio controls.\n beat.showControls();\n\n describe('An audio beat plays when the user double-clicks the square.');\n}\n
\nCreates a <video>
element that \"captures\" the audio/video stream from\nthe webcam and microphone. Returns a new\np5.Element object.
Videos are shown by default. They can be hidden by calling capture.hide()
\nand drawn to the canvas using image().
The first parameter, type
, is optional. It sets the type of capture to\nuse. By default, createCapture()
captures both audio and video. If VIDEO
\nis passed, as in createCapture(VIDEO)
, only video will be captured.\nIf AUDIO
is passed, as in createCapture(AUDIO)
, only audio will be\ncaptured. A constraints object can also be passed to customize the stream.\nSee the \nW3C documentation for possible properties. Different browsers support different\nproperties.
The second parameter, callback
, is optional. It's a function to call once\nthe capture is ready for use. The callback function should have one\nparameter, stream
, that's a\nMediaStream object.
Note: createCapture()
only works when running a sketch locally or using HTTPS. Learn more\nhere\nand here.
\nfunction setup() {\n noCanvas();\n createCapture(VIDEO);\n\n describe('A video stream from the webcam.');\n}\n
\n\nlet capture;\n\nfunction setup() {\n // Create the video capture and hide the element.\n capture = createCapture(VIDEO);\n capture.hide();\n\n describe('A video stream from the webcam with inverted colors.');\n}\n\nfunction draw() {\n // Draw the video capture within the canvas.\n image(capture, 0, 0, width, width * capture.height / capture.width);\n // Invert the colors in the stream.\n filter(INVERT);\n}\n
\n\nfunction setup() {\n createCanvas(480, 120);\n\n // Create a constraints object.\n let constraints = {\n video: {\n mandatory: {\n minWidth: 1280,\n minHeight: 720\n },\n optional: [{ maxFrameRate: 10 }]\n },\n audio: false\n };\n\n // Create the video capture.\n createCapture(constraints);\n\n describe('A video stream from the webcam.');\n}\n
\nCreates a new p5.Element object.
\nThe first parameter, tag
, is a string an HTML tag such as 'h5'
.
The second parameter, content
, is optional. It's a string that sets the\nHTML content to insert into the new element. New elements have no content\nby default.
\nfunction setup() {\n background(200);\n\n // Create an h5 element with nothing in it.\n createElement('h5');\n\n describe('A gray square.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create an h5 element with the content\n // \"p5*js\".\n let h5 = createElement('h5', 'p5*js');\n // Set the element's style and position.\n h5.style('color', 'deeppink');\n h5.position(30, 15);\n\n describe('The text \"p5*js\" written in pink in the middle of a gray square.');\n}\n
\n\nlet div = createDiv('div');\ndiv.addClass('myClass');\n
\n// In this example, a class is set when the div is created\n// and removed when mouse is pressed. This could link up\n// with a CSS style rule to toggle style properties.\n\nlet div;\n\nfunction setup() {\n div = createDiv('div');\n div.addClass('myClass');\n}\n\nfunction mousePressed() {\n div.removeClass('myClass');\n}\n
\nlet div;\n\nfunction setup() {\n div = createDiv('div');\n div.addClass('show');\n}\n\nfunction mousePressed() {\n if (div.hasClass('show')) {\n div.addClass('show');\n } else {\n div.removeClass('show');\n }\n}\n
\nlet div;\n\nfunction setup() {\n div = createDiv('div');\n div.addClass('show');\n}\n\nfunction mousePressed() {\n div.toggleClass('show');\n}\n
\nlet div0 = createDiv('this is the parent');\nlet div1 = createDiv('this is the child');\ndiv0.child(div1); // use p5.Element\n
\nlet div0 = createDiv('this is the parent');\nlet div1 = createDiv('this is the child');\ndiv1.id('apples');\ndiv0.child('apples'); // use id\n
\n// this example assumes there is a div already on the page\n// with id \"myChildDiv\"\nlet div0 = createDiv('this is the parent');\nlet elt = document.getElementById('myChildDiv');\ndiv0.child(elt); // use element from page\n
\nfunction setup() {\n let div = createDiv('').size(10, 10);\n div.style('background-color', 'orange');\n div.center();\n}\n
\nlet div = createDiv('').size(100, 100);\ndiv.html('hi');\n
\nlet div = createDiv('Hello ').size(100, 100);\ndiv.html('World', true);\n
Sets the position of the element. If no position type argument is given, the\nposition will be relative to (0, 0) of the window.\nEssentially, this sets position:absolute and left and top\nproperties of style. If an optional third argument specifying position type is given,\nthe x and y-coordinates will be interpreted based on the positioning scheme.\nIf no arguments given, the function returns the x and y position of the element.
\nfound documentation on how to be more specific with object type\nhttps://stackoverflow.com/questions/14714314/how-do-i-comment-object-literals-in-yuidoc
\n", + "example": [ + "\nfunction setup() {\n let cnv = createCanvas(100, 100);\n // positions canvas 50px to the right and 100px\n // below upper left corner of the window\n cnv.position(50, 100);\n}\n
\nfunction setup() {\n let cnv = createCanvas(100, 100);\n // positions canvas at upper left corner of the window\n // with a 'fixed' position type\n cnv.position(0, 0, 'fixed');\n}\n
Applies a style to an element by adding a\nCSS declaration.
\nThe first parameter, property
, is a string. If the name of a style\nproperty is passed, as in myElement.style('color')
, the method returns\nthe current value as a string or null
if it hasn't been set. If a\nproperty:style
string is passed, as in\nmyElement.style('color:deeppink')
, the method sets property
to\nvalue
.
The second parameter, value
, is optional. It sets the property's value.\nvalue
can be a string, as in\nmyElement.style('color', 'deeppink')
, or a\np5.Color object, as in\nmyElement.style('color', myColor)
.
\nfunction setup() {\n background(200);\n\n // Create a paragraph element and\n // set its font color to \"deeppink\".\n let p = createP('p5*js');\n p.position(25, 20);\n p.style('color', 'deeppink');\n\n describe('The text p5*js written in pink on a gray background.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create a p5.Color object.\n let c = color('deeppink');\n\n // Create a paragraph element and\n // set its font color using a\n // p5.Color object.\n let p = createP('p5*js');\n p.position(25, 20);\n p.style('color', c);\n\n describe('The text p5*js written in pink on a gray background.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create a paragraph element and\n // set its font color to \"deeppink\"\n // using property:value syntax.\n let p = createP('p5*js');\n p.position(25, 20);\n p.style('color:deeppink');\n\n describe('The text p5*js written in pink on a gray background.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create an empty paragraph element\n // and set its font color to \"deeppink\".\n let p = createP();\n p.position(5, 5);\n p.style('color', 'deeppink');\n\n // Get the element's color as an\n // RGB color string.\n let c = p.style('color');\n\n // Set the element's inner HTML\n // using the RGB color string.\n p.html(c);\n\n describe('The text \"rgb(255, 20, 147)\" written in pink on a gray background.');\n}\n
\nAdds an\nattribute\nto the element. This method is useful for advanced tasks.
\nMost commonly-used attributes, such as id
, can be set with their\ndedicated methods. For example, nextButton.id('next')
sets an element's\nid
attribute.
The first parameter, attr
, is the attribute's name as a string. Calling\nmyElement.attribute('align')
returns the attribute's current value as a\nstring or null
if it hasn't been set.
The second parameter, value
, is optional. It's a string used to set the\nattribute's value. For example, calling\nmyElement.attribute('align', 'center')
sets the element's horizontal\nalignment to center
.
\nfunction setup() {\n // Create a container div and\n // place it at the top-left\n // corner.\n let container = createDiv();\n container.position(0, 0);\n\n // Create a paragraph element\n // and place it within the container.\n // Set its horizontal alignment to\n // \"left\".\n let p1 = createP('hi');\n p1.parent(container);\n p1.attribute('align', 'left');\n\n // Create a paragraph element\n // and place it within the container.\n // Set its horizontal alignment to\n // \"center\".\n let p2 = createP('hi');\n p2.parent(container);\n p2.attribute('align', 'center');\n\n // Create a paragraph element\n // and place it within the container.\n // Set its horizontal alignment to\n // \"right\".\n let p3 = createP('hi');\n p3.parent(container);\n p3.attribute('align', 'right');\n\n describe('A gray square with the text \"hi\" written on three separate lines, each placed further to the right.');\n}\n
\nRemoves an attribute from the element.
\nThe parameter attr
is the attribute's name as a string. For example,\ncalling myElement.removeAttribute('align')
removes its align
\nattribute if it's been set.
\nlet p;\n\nfunction setup() {\n background(200);\n\n // Create a paragraph element and place it\n // in the center of the canvas.\n // Set its \"align\" attribute to \"center\".\n p = createP('hi');\n p.position(0, 20);\n p.attribute('align', 'center');\n\n describe('The text \"hi\" written in black at the center of a gray square. The text moves to the left edge when double-clicked.');\n}\n\nfunction doubleClicked() {\n p.removeAttribute('align');\n}\n
\nReturns or sets the element's value.
\nCalling myElement.value()
returns the element's current value.
The parameter, value
, is an optional number or string. If provided,\nas in myElement.value(123)
, it's used to set the element's value.
\nlet inp;\n\nfunction setup() {\n // Create a text input and place it\n // beneath the canvas. Set its default\n // value to \"hello\".\n inp = createInput('hello');\n inp.position(0, 100);\n\n describe('The text from an input box is displayed on a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Use the input's value to display a message.\n let msg = inp.value();\n text(msg, 0, 55);\n}\n
\n\nlet inp;\n\nfunction setup() {\n // Create a text input and place it\n // beneath the canvas. Set its default\n // value to \"hello\".\n inp = createInput('hello');\n inp.position(0, 100);\n\n describe('The text from an input box is displayed on a gray square. The text resets to \"hello\" when the user double-clicks the square.');\n}\n\nfunction draw() {\n background(200);\n\n // Use the input's value to display a message.\n let msg = inp.value();\n text(msg, 0, 55);\n}\n\n// Reset the input's value.\nfunction doubleClicked() {\n inp.value('hello');\n}\n
\n\nlet p;\n\nfunction setup() {\n background(200);\n\n // Create a paragraph element and hide it.\n p = createP('p5*js');\n p.position(10, 10);\n p.hide();\n\n describe('A gray square. The text \"p5*js\" appears when the user double-clicks the square.');\n}\n\n// Show the paragraph when double-clicked.\nfunction doubleClicked() {\n p.show();\n}\n
\nSets the element's width and height.
\nCalling myElement.size()
without an argument returns the element's size\nas an object with the properties width
and height
. For example,\n{ width: 20, height: 10 }
.
The first parameter, width
, is optional. It's a number used to set the\nelement's width. Calling myElement.size(10)
The second parameter, 'height, is also optional. It's a\nnumber used to set the element's height. For example, calling\n
myElement.size(20, 10)` sets the element's width to 20 pixels and height\nto 10 pixels.
The constant AUTO
can be used to adjust one dimension at a time while\nmaintaining the aspect ratio, which is width / height
. For example,\nconsider an element that's 200 pixels wide and 100 pixels tall. Calling\nmyElement.size(20, AUTO)
sets the width to 20 pixels and height to 10\npixels.
Note: In the case of elements that need to load data, such as images, wait\nto call myElement.size()
until after the data loads.
\nfunction setup() {\n background(200);\n\n // Create a pink div element and place it at\n // the top-left corner.\n let div = createDiv();\n div.position(10, 10);\n div.style('background-color', 'deeppink');\n\n // Set the div's width to 80 pixels and\n // height to 20 pixels.\n div.size(80, 20);\n\n describe('A gray square with a pink rectangle near its top.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Create a pink div element and place it at\n // the top-left corner.\n let div = createDiv();\n div.position(10, 10);\n div.style('background-color', 'deeppink');\n\n // Set the div's width to 80 pixels and\n // height to 40 pixels.\n div.size(80, 40);\n\n // Get the div's size as an object.\n let s = div.size();\n // Write the div's dimensions.\n div.html(`${s.width} x ${s.height}`);\n\n describe('A gray square with a pink rectangle near its top. The text \"80 x 40\" is written within the rectangle.');\n}\n
\n\nfunction setup() {\n background(200);\n\n // Load an image of an astronaut on the moon\n // and place it at the top-left of the canvas.\n let img1 = createImg(\n 'assets/moonwalk.jpg',\n 'An astronaut walking on the moon',\n ''\n );\n img1.position(0, 0);\n\n // Load an image of an astronaut on the moon\n // and place it at the top-left of the canvas.\n // Resize the image once it's loaded.\n let img2 = createImg(\n 'assets/moonwalk.jpg',\n 'An astronaut walking on the moon',\n '',\n () => {\n img2.size(50, AUTO);\n }\n );\n img2.position(0, 0);\n\n describe('A gray square two copies of a space image at the top-left. The copy in front is smaller.');\n}\n
\n\nlet p;\n\nfunction setup() {\n background(200);\n\n // Create a paragraph element.\n p = createP('p5*js');\n p.position(10, 10);\n\n describe('The text \"p5*js\" written at the center of a gray square. ');\n}\n\n// Remove the paragraph when double-clicked.\nfunction doubleClicked() {\n p.remove();\n}\n
\nSets a function to call when the user drops a file on the element.
\nThe first parameter, callback
, is a function to call once the file loads.\nThe callback function should have one parameter, file
, that's a\np5.File object. If the user drops multiple files on\nthe element, callback
, is called once for each file.
The second parameter, fxn
, is a function to call when the browser detects\none or more dropped files. The callback function should have one\nparameter, event
, that's a\nDragEvent.
\n// Drop an image on the canvas to view\n// this example.\nlet img;\n\nfunction setup() {\n let c = createCanvas(100, 100);\n\n background(200);\n\n // Call a function when a file\n // dropped on the canvas has\n // loaded.\n c.drop(file => {\n // Remove the current image, if any.\n if (img) {\n img.remove();\n }\n\n // Create an
element with the\n // dropped file.\n img = createImg(file.data, '');\n img.hide();\n\n // Draw the image.\n image(img, 0, 0, width, height);\n });\n\n describe('A gray square. When the user drops an image on the square, it is displayed.');\n}\n
\n\n// Drop an image on the canvas to view\n// this example.\nlet img;\nlet msg;\n\nfunction setup() {\n let c = createCanvas(100, 100);\n\n background(200);\n\n // Call functions when the user\n // drops a file on the canvas\n // and when the file loads.\n c.drop(handleFile, handleDrop);\n\n describe('A gray square. When the user drops an image on the square, it is displayed. The id attribute of canvas element is also displayed.');\n}\n\nfunction handleFile(file) {\n // Remove the current image, if any.\n if (img) {\n img.remove();\n }\n\n // Create an
element with the\n // dropped file.\n img = createImg(file.data, '');\n img.hide();\n\n // Draw the image.\n image(img, 0, 0, width, height);\n}\n\nfunction handleDrop(event) {\n // Remove current paragraph, if any.\n if (msg) {\n msg.remove();\n }\n\n // Use event to get the drop\n // target's id.\n let id = event.target.id;\n\n // Write the canvas' id\n // beneath it.\n msg = createP(id);\n msg.position(0, 100);\n\n // Set the font color\n // randomly for each drop.\n let c = random(['red', 'green', 'blue']);\n msg.style('color', c);\n msg.style('font-size', '12px');\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n\n createDiv('Post-It')\n .position(5, 5)\n .size(75, 20)\n .style('font-size', '16px')\n .style('background', 'yellow')\n .style('color', '#000')\n .style('border', '1px solid #aaaa00')\n .style('padding', '5px')\n .draggable();\n // .style('cursor', 'help') // override cursor\n\n let gui = createDiv('')\n .position(5, 40)\n .size(85, 50)\n .style('font-size', '16px')\n .style('background', 'yellow')\n .style('z-index', '100')\n .style('border', '1px solid #00aaaa');\n\n createDiv('= PANEL =')\n .parent(gui)\n .style('background', 'cyan')\n .style('padding', '2px')\n .style('text-align', 'center')\n .draggable(gui);\n\n createSlider(0, 100, random(100))\n .style('cursor', 'pointer')\n .size(80, 5)\n .parent(gui);\n}\n
\n// Run this example on a mobile device\n// You will need to move the device incrementally further\n// the closer the square's color gets to white in order to change the value.\n\nlet value = 0;\nlet threshold = 0.5;\nfunction setup() {\n setMoveThreshold(threshold);\n}\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when device moves`);\n}\nfunction deviceMoved() {\n value = value + 5;\n threshold = threshold + 0.1;\n if (value > 255) {\n value = 0;\n threshold = 30;\n }\n setMoveThreshold(threshold);\n}\n
\n\n// Run this example on a mobile device\n// You will need to shake the device more firmly\n// the closer the box's fill gets to white in order to change the value.\n\nlet value = 0;\nlet threshold = 30;\nfunction setup() {\n setShakeThreshold(threshold);\n}\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when device is being shaked`);\n}\nfunction deviceMoved() {\n value = value + 5;\n threshold = threshold + 5;\n if (value > 255) {\n value = 0;\n threshold = 30;\n }\n setShakeThreshold(threshold);\n}\n
\n\n// Run this example on a mobile device\n// Move the device around\n// to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when device moves`);\n}\nfunction deviceMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\nThe deviceTurned() function is called when the device rotates by\nmore than 90 degrees continuously.
\nThe axis that triggers the deviceTurned() method is stored in the turnAxis\nvariable. The deviceTurned() method can be locked to trigger on any axis:\nX, Y or Z by comparing the turnAxis variable to 'X', 'Y' or 'Z'.
\n", + "example": [ + "\n// Run this example on a mobile device\n// Rotate the device by 90 degrees\n// to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when device turns`);\n}\nfunction deviceTurned() {\n if (value === 0) {\n value = 255;\n } else if (value === 255) {\n value = 0;\n }\n}\n
\n\n// Run this example on a mobile device\n// Rotate the device by 90 degrees in the\n// X-axis to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when x-axis turns`);\n}\nfunction deviceTurned() {\n if (turnAxis === 'X') {\n if (value === 0) {\n value = 255;\n } else if (value === 255) {\n value = 0;\n }\n }\n}\n
\n\n// Run this example on a mobile device\n// Shake the device to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`50-by-50 black rect in center of canvas.\n turns white on mobile when device shakes`);\n}\nfunction deviceShaken() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\nThe keyPressed() function is called once every time a key is pressed. The\nkeyCode for the key that was pressed is stored in the keyCode variable.
\nFor non-ASCII keys, use the keyCode variable. You can check if the keyCode\nequals BACKSPACE, DELETE, ENTER, RETURN, TAB, ESCAPE, SHIFT, CONTROL,\nOPTION, ALT, UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW.
\nFor ASCII keys, the key that was pressed is stored in the key variable. However, it\ndoes not distinguish between uppercase and lowercase. For this reason, it\nis recommended to use keyTyped() to read the key variable, in which the\ncase of the variable will be distinguished.
\nBecause of how operating systems handle key repeats, holding down a key\nmay cause multiple calls to keyTyped() (and keyReleased() as well). The\nrate of repeat is set by the operating system and how each computer is\nconfigured.
\nBrowsers may have different default\nbehaviors attached to various key events. To prevent any default\nbehavior for this event, add \"return false\" to the end of the method.
\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`black rect center. turns white when key pressed and black\n when released.`);\n}\nfunction keyPressed() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`black rect center. turns white when left arrow pressed and\n black when right.`);\n}\nfunction keyPressed() {\n if (keyCode === LEFT_ARROW) {\n value = 255;\n } else if (keyCode === RIGHT_ARROW) {\n value = 0;\n }\n}\n
\n\nfunction keyPressed() {\n // Do something\n return false; // prevent any default behaviour\n}\n
\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`black rect center. turns white when key pressed and black\n when pressed again`);\n}\nfunction keyReleased() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n return false; // prevent any default behavior\n}\n
\nThe keyTyped() function is called once every time a key is pressed, but\naction keys such as Backspace, Delete, Ctrl, Shift, and Alt are ignored. If you are trying to detect\na keyCode for one of these keys, use the keyPressed() function instead.\nThe most recent key typed will be stored in the key variable.
\nBecause of how operating systems handle key repeats, holding down a key\nwill cause multiple calls to keyTyped() (and keyReleased() as well). The\nrate of repeat is set by the operating system and how each computer is\nconfigured.
\nBrowsers may have different default behaviors attached to various key\nevents. To prevent any default behavior for this event, add \"return false\"\nto the end of the function.
\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`black rect center. turns white when 'a' key typed and\n black when 'b' pressed`);\n}\nfunction keyTyped() {\n if (key === 'a') {\n value = 255;\n } else if (key === 'b') {\n value = 0;\n }\n // uncomment to prevent any default behavior\n // return false;\n}\n
\n\nlet x = 100;\nlet y = 100;\n\nfunction setup() {\n createCanvas(512, 512);\n fill(255, 0, 0);\n}\n\nfunction draw() {\n if (keyIsDown(LEFT_ARROW)) {\n x -= 5;\n }\n\n if (keyIsDown(RIGHT_ARROW)) {\n x += 5;\n }\n\n if (keyIsDown(UP_ARROW)) {\n y -= 5;\n }\n\n if (keyIsDown(DOWN_ARROW)) {\n y += 5;\n }\n\n clear();\n ellipse(x, y, 50, 50);\n describe(`50-by-50 red ellipse moves left, right, up, and\n down with arrow presses.`);\n}\n
\nlet diameter = 50;\n\nfunction setup() {\n createCanvas(512, 512);\n}\n\nfunction draw() {\n // 107 and 187 are keyCodes for \"+\"\n if (keyIsDown(107) || keyIsDown(187)) {\n diameter += 1;\n }\n\n // 109 and 189 are keyCodes for \"-\"\n if (keyIsDown(109) || keyIsDown(189)) {\n diameter -= 1;\n }\n\n clear();\n fill(255, 0, 0);\n ellipse(50, 50, diameter, diameter);\n describe(`50-by-50 red ellipse gets bigger or smaller when\n + or - are pressed.`);\n}\n
\n// Drag the mouse across the page\n// to change its value\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n describe(`black 50-by-50 rect turns lighter with mouse click and\n drag until white, resets`);\n}\nfunction mouseDragged() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n\nfunction mouseDragged() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseDragged(event) {\n console.log(event);\n}\n
\n\nlet cam;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n requestPointerLock();\n cam = createCamera();\n}\n\nfunction draw() {\n background(255);\n cam.pan(-movedX * 0.001);\n cam.tilt(movedY * 0.001);\n sphere(25);\n describe(`3D scene moves according to mouse mouse movement in a\n first person perspective`);\n}\n
\n\n//click the canvas to lock the pointer\n//click again to exit (otherwise escape)\nlet locked = false;\nfunction draw() {\n background(237, 34, 93);\n describe('cursor gets locked / unlocked on mouse-click');\n}\nfunction mouseClicked() {\n if (!locked) {\n locked = true;\n requestPointerLock();\n } else {\n exitPointerLock();\n locked = false;\n }\n}\n
\nCreates a new p5.Image object. The new image is\ntransparent by default.
\ncreateImage()
uses the width
and height
paremeters to set the new\np5.Image object's dimensions in pixels. The new\np5.Image can be modified by updating its\npixels array or by calling its\nget() and\nset() methods. The\nloadPixels() method must be called\nbefore reading or modifying pixel values. The\nupdatePixels() method must be called\nfor updates to take effect.
\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let x = 0; x < img.width; x += 1) {\n for (let y = 0; y < img.height; y += 1) {\n img.set(x, y, 0);\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let x = 0; x < img.width; x += 1) {\n for (let y = 0; y < img.height; y += 1) {\n let a = map(x, 0, img.width, 0, 255);\n let c = color(0, a);\n img.set(x, y, c);\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A square with a horizontal color gradient that transitions from gray to black.');\n
\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nlet d = pixelDensity();\nlet halfImage = 4 * (d * img.width) * (d * img.height / 2);\nfor (let i = 0; i < halfImage; i += 4) {\n // Red.\n img.pixels[i] = 0;\n // Green.\n img.pixels[i + 1] = 0;\n // Blue.\n img.pixels[i + 2] = 0;\n // Alpha.\n img.pixels[i + 3] = 255;\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(255);\n saveCanvas();\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(255);\n saveCanvas('myCanvas.jpg');\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(255);\n saveCanvas('myCanvas', 'jpg');\n}\n
\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(255);\n saveCanvas(cnv);\n}\n
\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(255);\n saveCanvas(cnv, 'myCanvas.jpg');\n}\n
\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(255);\n saveCanvas(cnv, 'myCanvas', 'jpg');\n}\n
\nCaptures a sequence of frames from the canvas that can be used to create a\nmovie. Frames are downloaded as individual image files by default.
\nThe first parameter, filename
, sets the prefix for the file names. For\nexample, setting the prefix to 'frame'
would generate the image files\nframe0.png
, frame1.png
, and so on. The second parameter, extension
,\nsets the file type to either 'png'
or 'jpg'
.
The third parameter, duration
, sets the duration to record in seconds.\nThe maximum duration is 15 seconds. The fourth parameter, framerate
, sets\nthe number of frames to record per second. The maximum frame rate value is\n22. Limits are placed on duration
and framerate
to avoid using too much\nmemory. Recording large canvases can easily crash sketches or even web\nbrowsers.
The fifth parameter, callback
, is optional. If a function is passed,\nimage files won't be saved by default. The callback function can be used\nto process an array containing the data for each captured frame. The array\nof image data contains a sequence of objects with three properties for each\nframe: imageData
, filename
, and extension
.
\nfunction draw() {\n let r = frameCount % 255;\n let g = 50;\n let b = 100;\n background(r, g, b);\n\n describe('A square repeatedly changes color from blue to pink.');\n}\n\nfunction keyPressed() {\n if (key === 's') {\n saveFrames('frame', 'png', 1, 5);\n }\n}\n
\n\nfunction draw() {\n let r = frameCount % 255;\n let g = 50;\n let b = 100;\n background(r, g, b);\n\n describe('A square repeatedly changes color from blue to pink.');\n}\n\nfunction mousePressed() {\n saveFrames('frame', 'png', 1, 5, data => {\n // Prints an array of objects containing raw image data,\n // filenames, and extensions.\n print(data);\n });\n}\n
\nimageData
, filename
, and extension
.",
+ "optional": 1
+ }
+ ]
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "Image",
+ "submodule": "Image"
+ },
+ {
+ "name": "loadImage",
+ "file": "src/image/loading_displaying.js",
+ "line": 92,
+ "itemtype": "method",
+ "description": "Loads an image to create a p5.Image object.
\nloadImage()
interprets the first parameter one of three ways. If the path\nto an image file is provided, loadImage()
will load it. Paths to local\nfiles should be relative, such as 'assets/thundercat.jpg'
. URLs such as\n'https://example.com/thundercat.jpg'
may be blocked due to browser\nsecurity. Raw image data can also be passed as a base64 encoded image in\nthe form 'data:image/png;base64,arandomsequenceofcharacters'
.
The second parameter is optional. If a function is passed, it will be\ncalled once the image has loaded. The callback function can optionally use\nthe new p5.Image object.
\nThe third parameter is also optional. If a function is passed, it will be\ncalled if the image fails to load. The callback function can optionally use\nthe event error.
\nImages can take time to load. Calling loadImage()
in\npreload() ensures images load before they're\nused in setup() or draw().
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n describe('Image of the underside of a white umbrella and a gridded ceiling.');\n}\n
\n\nfunction setup() {\n loadImage('assets/laDefense.jpg', img => {\n image(img, 0, 0);\n });\n describe('Image of the underside of a white umbrella and a gridded ceiling.');\n}\n
\n\nfunction setup() {\n loadImage('assets/laDefense.jpg', success, failure);\n}\n\nfunction success(img) {\n image(img, 0, 0);\n describe('Image of the underside of a white umbrella and a gridded ceiling.');\n}\n\nfunction failure(event) {\n console.error('Oops!', event);\n}\n
\nGenerates a gif from a sketch and saves it to a file. saveGif()
may be\ncalled in setup() or at any point while a sketch\nis running.
The first parameter, fileName
, sets the gif's file name. The second\nparameter, duration
, sets the gif's duration in seconds.
The third parameter, options
, is optional. If an object is passed,\nsaveGif()
will use its properties to customize the gif. saveGif()
\nrecognizes the properties delay
, units
, silent
,\nnotificationDuration
, and notificationID
.
\nfunction draw() {\n background(200);\n let c = frameCount % 255;\n fill(c);\n circle(50, 50, 25);\n\n describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.');\n}\n\nfunction keyPressed() {\n if (key === 's') {\n saveGif('mySketch', 5);\n }\n}\n
\ndelay
, a Number specifying how much time to wait before recording;\nunits
, a String that can be either 'seconds' or 'frames'. By default it's 'seconds’;\nsilent
, a Boolean that defines presence of progress notifications. By default it’s false
;\nnotificationDuration
, a Number that defines how long in seconds the final notification\nwill live. By default it's 0
, meaning the notification will never be removed;\nnotificationID
, a String that specifies the id of the notification's DOM element. By default it’s 'progressBar’
.",
+ "optional": 1,
+ "type": "Object"
+ }
+ ]
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "Image",
+ "submodule": "Loading & Displaying"
+ },
+ {
+ "name": "image",
+ "file": "src/image/loading_displaying.js",
+ "line": 1017,
+ "itemtype": "method",
+ "description": "Draws a source image to the canvas.
\nThe first parameter, img
, is the source image to be drawn. The second and\nthird parameters, dx
and dy
, set the coordinates of the destination\nimage's top left corner. See imageMode() for\nother ways to position images.
Here's a diagram that explains how optional parameters work in image()
:
The fourth and fifth parameters, dw
and dh
, are optional. They set the\nthe width and height to draw the destination image. By default, image()
\ndraws the full source image at its original size.
The sixth and seventh parameters, sx
and sy
, are also optional.\nThese coordinates define the top left corner of a subsection to draw from\nthe source image.
The eighth and ninth parameters, sw
and sh
, are also optional.\nThey define the width and height of a subsection to draw from the source\nimage. By default, image()
draws the full subsection that begins at\n(sx
, sy
) and extends to the edges of the source image.
The ninth parameter, fit
, is also optional. It enables a subsection of\nthe source image to be drawn without affecting its aspect ratio. If\nCONTAIN
is passed, the full subsection will appear within the destination\nrectangle. If COVER
is passed, the subsection will completely cover the\ndestination rectangle. This may have the effect of zooming into the\nsubsection.
The tenth and eleventh paremeters, xAlign
and yAlign
, are also\noptional. They determine how to align the fitted subsection. xAlign
can\nbe set to either LEFT
, RIGHT
, or CENTER
. yAlign
can be set to\neither TOP
, BOTTOM
, or CENTER
. By default, both xAlign
and yAlign
\nare set to CENTER
.
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n background(50);\n image(img, 0, 0);\n\n describe('An image of the underside of a white umbrella with a gridded ceiling above.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n background(50);\n image(img, 10, 10);\n\n describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n background(50);\n image(img, 0, 0, 50, 50);\n\n describe('An image of the underside of a white umbrella with a gridded ceiling above. The image is drawn in the top left corner of a dark gray square.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n background(50);\n image(img, 25, 25, 50, 50, 25, 25, 50, 50);\n\n describe('An image of a gridded ceiling drawn in the center of a dark gray square.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/moonwalk.jpg');\n}\n\nfunction setup() {\n background(50);\n image(img, 0, 0, width, height, 0, 0, img.width, img.height, CONTAIN);\n\n describe('An image of an astronaut on the moon. The top and bottom borders of the image are dark gray.');\n}\n
\n\nlet img;\n\nfunction preload() {\n // Image is 50 x 50 pixels.\n img = loadImage('assets/laDefense50.png');\n}\n\nfunction setup() {\n background(50);\n image(img, 0, 0, width, height, 0, 0, img.width, img.height, COVER);\n\n describe('A pixelated image of the underside of a white umbrella with a gridded ceiling above.');\n}\n
\nTints images using a specified color.
\nThe version of tint()
with one parameter interprets it one of four ways.\nIf the parameter is a number, it's interpreted as a grayscale value. If the\nparameter is a string, it's interpreted as a CSS color string. An array of\n[R, G, B, A]
values or a p5.Color object can\nalso be used to set the tint color.
The version of tint()
with two parameters uses the first one as a\ngrayscale value and the second as an alpha value. For example, calling\ntint(255, 128)
will make an image 50% transparent.
The version of tint()
with three parameters interprets them as RGB or\nHSB values, depending on the current\ncolorMode(). The optional fourth parameter\nsets the alpha value. For example, tint(255, 0, 0, 100)
will give images\na red tint and make them transparent.
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n tint('red');\n image(img, 50, 0);\n\n describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n tint(255, 0, 0);\n image(img, 50, 0);\n\n describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n tint(255, 0, 0, 100);\n image(img, 50, 0);\n\n describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a transparent red tint.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n tint(255, 180);\n image(img, 50, 0);\n\n describe('Two images of an umbrella and a ceiling side-by-side. The image on the right is transparent.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\nfunction setup() {\n tint('red');\n image(img, 0, 0);\n noTint();\n image(img, 50, 0);\n\n describe('Two images of an umbrella and a ceiling side-by-side. The image on the left has a red tint.');\n}\n
\nChanges the location from which images are drawn when\nimage() is called.
\nBy default, the first\ntwo parameters of image() are the x- and\ny-coordinates of the image's upper-left corner. The next parameters are\nits width and height. This is the same as calling imageMode(CORNER)
.
imageMode(CORNERS)
also uses the first two parameters of\nimage() as the x- and y-coordinates of the image's\ntop-left corner. The third and fourth parameters are the coordinates of its\nbottom-right corner.
imageMode(CENTER)
uses the first two parameters of\nimage() as the x- and y-coordinates of the image's\ncenter. The next parameters are its width and height.
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n background(200);\n imageMode(CORNER);\n image(img, 10, 10, 50, 50);\n\n describe('A square image of a brick wall is drawn at the top left of a gray square.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n background(200);\n imageMode(CORNERS);\n image(img, 10, 10, 90, 40);\n\n describe('An image of a brick wall is drawn on a gray square. The image is squeezed into a small rectangular area.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n background(200);\n imageMode(CENTER);\n image(img, 50, 50, 80, 80);\n\n describe('A square image of a brick wall is drawn on a gray square.');\n}\n
\nblendMode
\nparameter blends the images' colors to create different effects.",
+ "example": [
+ "\nlet img0;\nlet img1;\n\nfunction preload() {\n img0 = loadImage('assets/rockies.jpg');\n img1 = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n background(img0);\n image(img1, 0, 0);\n blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST);\n\n describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.');\n}\n
\n\nlet img0;\nlet img1;\n\nfunction preload() {\n img0 = loadImage('assets/rockies.jpg');\n img1 = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n background(img0);\n image(img1, 0, 0);\n blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST);\n\n describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.');\n}\n
\n\nlet img0;\nlet img1;\n\nfunction preload() {\n img0 = loadImage('assets/rockies.jpg');\n img1 = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n background(img0);\n image(img1, 0, 0);\n blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, ADD);\n\n describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.');\n}\n
\ncopy()
will scale pixels from the source region if it isn't the\nsame size as the destination region.",
+ "example": [
+ "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n background(img);\n copy(img, 7, 22, 10, 10, 35, 25, 50, 50);\n // Show copied region.\n stroke(255);\n noFill();\n square(7, 22, 10);\n\n describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.');\n}\n
\nApplies an image filter to the canvas. The preset options are:
\nINVERT
\nInverts the colors in the image. No parameter is used.
GRAY
\nConverts the image to grayscale. No parameter is used.
THRESHOLD
\nConverts the image to black and white. Pixels with a grayscale value\nabove a given threshold are converted to white. The rest are converted to\nblack. The threshold must be between 0.0 (black) and 1.0 (white). If no\nvalue is specified, 0.5 is used.
OPAQUE
\nSets the alpha channel to entirely opaque. No parameter is used.
POSTERIZE
\nLimits the number of colors in the image. Each color channel is limited to\nthe number of colors specified. Values between 2 and 255 are valid, but\nresults are most noticeable with lower values. The default value is 4.
BLUR
\nBlurs the image. The level of blurring is specified by a blur radius. Larger\nvalues increase the blur. The default value is 4. A gaussian blur is used\nin P2D
mode. A box blur is used in WEBGL
mode.
ERODE
\nReduces the light areas. No parameter is used.
DILATE
\nIncreases the light areas. No parameter is used.
filter()
uses WebGL in the background by default because it's faster.\nThis can be disabled in P2D
mode by adding a false
argument, as in\nfilter(BLUR, false)
. This may be useful to keep computation off the GPU\nor to work around a lack of WebGL support.
In WEBGL
mode, filter()
can also use custom shaders. See\ncreateFilterShader() for more\ninformation.
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(INVERT);\n\n describe('A blue brick wall.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(GRAY);\n\n describe('A brick wall drawn in grayscale.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(THRESHOLD);\n\n describe('A brick wall drawn in black and white.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(OPAQUE);\n\n describe('A red brick wall.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(POSTERIZE, 3);\n\n describe('An image of a red brick wall drawn with limited color palette.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(BLUR, 3);\n\n describe('A blurry image of a red brick wall.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(DILATE);\n\n describe('A red brick wall with bright lines between each brick.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n filter(ERODE);\n\n describe('A red brick wall with faint lines between each brick.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n // Don't use WebGL.\n filter(BLUR, 3, false);\n\n describe('A blurry image of a red brick wall.');\n}\n
\ntrue
.",
+ "optional": 1,
+ "type": "Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "filterType",
+ "type": "Constant"
+ },
+ {
+ "name": "filterParam",
+ "optional": 1,
+ "type": "Number"
+ },
+ {
+ "name": "useWebGL",
+ "optional": 1,
+ "type": "Boolean"
+ }
+ ]
+ },
+ {
+ "params": [
+ {
+ "name": "shaderFilter",
+ "description": "shader that's been loaded, with the\nfrag shader using a tex0
uniform.",
+ "type": "p5.Shader"
+ }
+ ]
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "Image",
+ "submodule": "Pixels"
+ },
+ {
+ "name": "get",
+ "file": "src/io/p5.TableRow.js",
+ "line": 223,
+ "itemtype": "method",
+ "description": "Gets a pixel or a region of pixels from the canvas.
\nget()
is easy to use but it's not as fast as\npixels. Use pixels\nto read many pixel values.
The version of get()
with no parameters returns the entire canvas.
The version of get()
with two parameters interprets them as\ncoordinates. It returns an array with the [R, G, B, A]
values of the\npixel at the given point.
The version of get()
with four parameters interprets them as coordinates\nand dimensions. It returns a subsection of the canvas as a\np5.Image object. The first two parameters are the\ncoordinates for the upper-left corner of the subsection. The last two\nparameters are the width and height of the subsection.
Use p5.Image.get() to work directly with\np5.Image objects.
\n", + "example": [ + "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let c = get();\n image(c, width / 2, 0);\n\n describe('Two identical mountain landscapes shown side-by-side.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let c = get(50, 90);\n fill(c);\n noStroke();\n square(25, 25, 50);\n\n describe('A mountain landscape with an olive green square in its center.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let c = get(0, 0, width / 2, height / 2);\n image(c, width / 2, height / 2);\n\n describe('A mountain landscape drawn on top of another mountain landscape.');\n}\n
\n\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let names = [];\n let rows = table.getRows();\n for (let r = 0; r < rows.length; r++) {\n names.push(rows[r].get('name'));\n }\n\n print(names);\n\n describe('no image displayed');\n}\n
[R, G, B, A]
.",
+ "type": "Number[]"
+ }
+ },
+ {
+ "params": [
+ {
+ "name": "column",
+ "description": "columnName (string) or\nID (number)",
+ "type": "String|Integer"
+ }
+ ],
+ "return": {
+ "description": "",
+ "type": "String|Number"
+ }
+ }
+ ],
+ "return": {
+ "description": "subsection as a p5.Image object.",
+ "type": "p5.Image"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "IO",
+ "submodule": "Table"
+ },
+ {
+ "name": "loadPixels",
+ "file": "src/image/pixels.js",
+ "line": 797,
+ "itemtype": "method",
+ "description": "Loads the current value of each pixel on the canvas into the\npixels array. This\nfunction must be called before reading from or writing to\npixels.",
+ "example": [
+ "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0, width, height);\n let d = pixelDensity();\n let halfImage = 4 * (d * width) * (d * height / 2);\n loadPixels();\n for (let i = 0; i < halfImage; i += 1) {\n pixels[i + halfImage] = pixels[i];\n }\n updatePixels();\n\n describe('Two identical images of mountain landscapes, one on top of the other.');\n}\n
\nSets the color of a pixel or draws an image to the canvas.
\nset()
is easy to use but it's not as fast as\npixels. Use pixels\nto set many pixel values.
set()
interprets the first two parameters as x- and y-coordinates. It\ninterprets the last parameter as a grayscale value, a [R, G, B, A]
pixel\narray, a p5.Color object, or a\np5.Image object. If an image is passed, the first\ntwo parameters set the coordinates for the image's upper-left corner,\nregardless of the current imageMode().
updatePixels() must be called after using\nset()
for changes to appear.
\nset(30, 20, 0);\nset(85, 20, 0);\nset(85, 75, 0);\nset(30, 75, 0);\nupdatePixels();\n\ndescribe('Four black dots arranged in a square drawn on a gray background.');\n
\n\nlet black = color(0);\nset(30, 20, black);\nset(85, 20, black);\nset(85, 75, black);\nset(30, 75, black);\nupdatePixels();\n\ndescribe('Four black dots arranged in a square drawn on a gray background.');\n
\n\nfor (let x = 0; x < width; x += 1) {\n for (let y = 0; y < height; y += 1) {\n let c = map(x, 0, width, 0, 255);\n set(x, y, c);\n }\n}\nupdatePixels();\n\ndescribe('A horiztonal color gradient from black to white.');\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n set(0, 0, img);\n updatePixels();\n\n describe('An image of a mountain landscape.');\n}\n
\n\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n print(table.getArray());\n\n describe('no image displayed');\n}\n
Updates the canvas with the RGBA values in the\npixels array.
\nupdatePixels()
only needs to be called after changing values in the\npixels array. Such changes can be made directly\nafter calling loadPixels() or by calling\nset().
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0, width, height);\n let d = pixelDensity();\n let halfImage = 4 * (d * width) * (d * height / 2);\n loadPixels();\n for (let i = 0; i < halfImage; i += 1) {\n pixels[i + halfImage] = pixels[i];\n }\n updatePixels();\n\n describe('Two identical images of mountain landscapes, one on top of the other.');\n}\n
\nLoads a JSON file from a file or a URL, and returns an Object.\nNote that even if the JSON file contains an Array, an Object will be\nreturned with index numbers as keys.
\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. JSONP is supported via a polyfill and you\ncan pass in as the second argument an object with definitions of the json\ncallback following the syntax specified here.
\nThis method is suitable for fetching files up to size of 64MB.
\n", + "example": [ + "Calling loadJSON() inside preload() guarantees to complete the\noperation before setup() and draw() are called.\n\n\n// Examples use USGS Earthquake API:\n// https://earthquake.usgs.gov/fdsnws/event/1/#methods\nlet earthquakes;\nfunction preload() {\n // Get the most recent earthquake in the database\n let url =\n'https://earthquake.usgs.gov/earthquakes/feed/v1.0/' +\n 'summary/all_day.geojson';\n earthquakes = loadJSON(url);\n}\n\nfunction setup() {\n noLoop();\n}\n\nfunction draw() {\n background(200);\n // Get the magnitude and name of the earthquake out of the loaded JSON\n let earthquakeMag = earthquakes.features[0].properties.mag;\n let earthquakeName = earthquakes.features[0].properties.place;\n ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10);\n textAlign(CENTER);\n text(earthquakeName, 0, height - 30, width, 30);\n describe(`50×50 ellipse that changes from black to white\n depending on the current humidity`);\n}\n
\nfunction setup() {\n noLoop();\n let url =\n'https://earthquake.usgs.gov/earthquakes/feed/v1.0/' +\n 'summary/all_day.geojson';\n loadJSON(url, drawEarthquake);\n}\n\nfunction draw() {\n background(200);\n describe(`50×50 ellipse that changes from black to white\n depending on the current humidity`);\n}\n\nfunction drawEarthquake(earthquakes) {\n // Get the magnitude and name of the earthquake out of the loaded JSON\n let earthquakeMag = earthquakes.features[0].properties.mag;\n let earthquakeName = earthquakes.features[0].properties.place;\n ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10);\n textAlign(CENTER);\n text(earthquakeName, 0, height - 30, width, 30);\n}\n
Reads the contents of a file and creates a String array of its individual\nlines. If the name of the file is used as the parameter, as in the above\nexample, the file must be located in the sketch directory/folder.
\nAlternatively, the file may be loaded from anywhere on the local\ncomputer using an absolute path (something that starts with / on Unix and\nLinux, or a drive letter on Windows), or the filename parameter can be a\nURL for a file found on a network.
\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed.
\nThis method is suitable for fetching files up to size of 64MB.
\n", + "example": [ + "Calling loadStrings() inside preload() guarantees to complete the\noperation before setup() and draw() are called.\n\n\nlet result;\nfunction preload() {\n result = loadStrings('assets/test.txt');\n}\n\nfunction setup() {\n background(200);\n text(random(result), 10, 10, 80, 80);\n describe(`randomly generated text from a file,\n for example \"i smell like butter\"`);\n}\n
\nfunction setup() {\n loadStrings('assets/test.txt', pickString);\n describe(`randomly generated text from a file,\n for example \"i have three feet\"`);\n}\n\nfunction pickString(result) {\n background(200);\n text(random(result), 10, 10, 80, 80);\n}\n
Reads the contents of a file or URL and creates a p5.Table object with\nits values. If a file is specified, it must be located in the sketch's\n\"data\" folder. The filename parameter can also be a URL to a file found\nonline. By default, the file is assumed to be comma-separated (in CSV\nformat). Table only looks for a header row if the 'header' option is\nincluded.
\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. Calling loadTable() inside preload()\nguarantees to complete the operation before setup() and draw() are called.\nOutside of preload(), you may supply a callback function to handle the\nobject:
\nAll files loaded and saved use UTF-8 encoding. This method is suitable for fetching files up to size of 64MB.
\n", + "example": [ + "\n// Given the following CSV file called \"mammals.csv\"\n// located in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n //the file can be remote\n //table = loadTable(\"http://p5js.org/reference/assets/mammals.csv\",\n // \"csv\", \"header\");\n}\n\nfunction setup() {\n //count the columns\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n\n print(table.getColumn('name'));\n //[\"Goat\", \"Leopard\", \"Zebra\"]\n\n //cycle through the table\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(table.getString(r, c));\n }\n describe(`randomly generated text from a file,\n for example \"i smell like butter\"`);\n}\n
\nReads the contents of a file and creates an XML object with its values.\nIf the name of the file is used as the parameter, as in the above example,\nthe file must be located in the sketch directory/folder.
\nAlternatively, the file maybe be loaded from anywhere on the local\ncomputer using an absolute path (something that starts with / on Unix and\nLinux, or a drive letter on Windows), or the filename parameter can be a\nURL for a file found on a network.
\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. Calling loadXML() inside preload()\nguarantees to complete the operation before setup() and draw() are called.
\nOutside of preload(), you may supply a callback function to handle the\nobject.
\nThis method is suitable for fetching files up to size of 64MB.
\n", + "example": [ + "\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let children = xml.getChildren('animal');\n\n for (let i = 0; i < children.length; i++) {\n let id = children[i].getNum('id');\n let coloring = children[i].getString('species');\n let name = children[i].getContent();\n print(id + ', ' + coloring + ', ' + name);\n }\n describe('no image displayed');\n}\n\n// Sketch prints:\n// 0, Capra hircus, Goat\n// 1, Panthera pardus, Leopard\n// 2, Equus zebra, Zebra\n
\nlet data;\n\nfunction preload() {\n data = loadBytes('assets/mammals.xml');\n}\n\nfunction setup() {\n for (let i = 0; i < 5; i++) {\n console.log(data.bytes[i].toString(16));\n }\n describe('no image displayed');\n}\n
httpDo(path, 'GET')
. The 'binary' datatype will return\na Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer\nwhich can be used to initialize typed arrays (such as Uint8Array).",
+ "example": [
+ "\n// Examples use USGS Earthquake API:\n// https://earthquake.usgs.gov/fdsnws/event/1/#methods\nlet earthquakes;\nfunction preload() {\n // Get the most recent earthquake in the database\n let url =\n'https://earthquake.usgs.gov/fdsnws/event/1/query?' +\n 'format=geojson&limit=1&orderby=time';\n httpGet(url, 'json', function(response) {\n // when the HTTP request completes, populate the variable that holds the\n // earthquake data used in the visualization.\n earthquakes = response;\n });\n}\n\nfunction draw() {\n if (!earthquakes) {\n // Wait until the earthquake data has loaded before drawing.\n return;\n }\n background(200);\n // Get the magnitude and name of the earthquake out of the loaded JSON\n let earthquakeMag = earthquakes.features[0].properties.mag;\n let earthquakeName = earthquakes.features[0].properties.place;\n ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10);\n textAlign(CENTER);\n text(earthquakeName, 0, height - 30, width, 30);\n noLoop();\n}\n
httpDo(path, 'POST')
.",
+ "example": [
+ "\n// Examples use jsonplaceholder.typicode.com for a Mock Data API\n\nlet url = 'https://jsonplaceholder.typicode.com/posts';\nlet postData = { userId: 1, title: 'p5 Clicked!', body: 'p5.js is very cool.' };\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n}\n\nfunction mousePressed() {\n httpPost(url, 'json', postData, function(result) {\n strokeWeight(2);\n text(result.body, mouseX, mouseY);\n });\n}\n
\n\nlet url = 'ttps://invalidURL'; // A bad URL that will cause errors\nlet postData = { title: 'p5 Clicked!', body: 'p5.js is very cool.' };\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n}\n\nfunction mousePressed() {\n httpPost(\n url,\n 'json',\n postData,\n function(result) {\n // ... won't be called\n },\n function(error) {\n strokeWeight(2);\n text(error.toString(), mouseX, mouseY);\n }\n );\n}\n
\n// Examples use USGS Earthquake API:\n// https://earthquake.usgs.gov/fdsnws/event/1/#methods\n\n// displays an animation of all USGS earthquakes\nlet earthquakes;\nlet eqFeatureIndex = 0;\n\nfunction preload() {\n let url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson';\n httpDo(\n url,\n {\n method: 'GET',\n // Other Request options, like special headers for apis\n headers: { authorization: 'Bearer secretKey' }\n },\n function(res) {\n earthquakes = res;\n }\n );\n}\n\nfunction draw() {\n // wait until the data is loaded\n if (!earthquakes || !earthquakes.features[eqFeatureIndex]) {\n return;\n }\n clear();\n\n let feature = earthquakes.features[eqFeatureIndex];\n let mag = feature.properties.mag;\n let rad = mag / 11 * ((width + height) / 2);\n fill(255, 0, 0, 100);\n ellipse(width / 2 + random(-2, 2), height / 2 + random(-2, 2), rad, rad);\n\n if (eqFeatureIndex >= earthquakes.features.length) {\n eqFeatureIndex = 0;\n } else {\n eqFeatureIndex += 1;\n }\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n const writer = createWriter('squares.txt');\n for (let i = 0; i < 10; i++) {\n writer.print(i * i);\n }\n writer.close();\n writer.clear();\n }\n}\n
\n\n// creates a file called 'newFile.txt'\nlet writer = createWriter('newFile.txt');\n// write 'Hello world!'' to the file\nwriter.write(['Hello world!']);\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n// creates a file called 'newFile2.txt'\nlet writer = createWriter('newFile2.txt');\n// write 'apples,bananas,123' to the file\nwriter.write(['apples', 'bananas', 123]);\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n// creates a file called 'newFile3.txt'\nlet writer = createWriter('newFile3.txt');\n// write 'My name is: Teddy' to the file\nwriter.write('My name is:');\nwriter.write(' Teddy');\n// close the PrintWriter and save the file\nwriter.close();\n
\n\nfunction setup() {\n createCanvas(100, 100);\n button = createButton('SAVE FILE');\n button.position(21, 40);\n button.mousePressed(createFile);\n}\n\nfunction createFile() {\n // creates a file called 'newFile.txt'\n let writer = createWriter('newFile.txt');\n // write 'Hello world!'' to the file\n writer.write(['Hello world!']);\n // close the PrintWriter and save the file\n writer.close();\n}\n
\n\n// create a file called 'newFile.txt'\nlet writer = createWriter('newFile.txt');\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n// create a file called 'newFile2.txt'\nlet writer = createWriter('newFile2.txt');\n// write some data to the file\nwriter.write([100, 101, 102]);\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n// Saves the canvas as an image\ncnv = createCanvas(300, 300);\nsave(cnv, 'myCanvas.jpg');\n\n// Saves the canvas as an image by default\nsave('myCanvas.jpg');\ndescribe('An example for saving a canvas as an image.');\n
\n// Saves p5.Image as an image\nimg = createImage(10, 10);\nsave(img, 'myImage.png');\ndescribe('An example for saving a p5.Image element as an image.');\n
\n// Saves p5.Renderer object as an image\nobj = createGraphics(100, 100);\nsave(obj, 'myObject.png');\ndescribe('An example for saving a p5.Renderer element.');\n
\nlet myTable = new p5.Table();\n// Saves table as html file\nsave(myTable, 'myTable.html');\n\n// Comma Separated Values\nsave(myTable, 'myTable.csv');\n\n// Tab Separated Values\nsave(myTable, 'myTable.tsv');\n\ndescribe(`An example showing how to save a table in formats of\n HTML, CSV and TSV.`);\n
\nlet myJSON = { a: 1, b: true };\n\n// Saves pretty JSON\nsave(myJSON, 'my.json');\n\n// Optimizes JSON filesize\nsave(myJSON, 'my.json', true);\n\ndescribe('An example for saving JSON to a txt file with some extra arguments.');\n
\n// Saves array of strings to text file with line breaks after each item\nlet arrayOfStrings = ['a', 'b'];\nsave(arrayOfStrings, 'my.txt');\ndescribe(`An example for saving an array of strings to text file\n with line breaks.`);\n
true
indicates that the\noutput will be optimized for filesize,\nrather than readability.",
+ "optional": 1,
+ "type": "Boolean|String"
+ }
+ ]
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "IO",
+ "submodule": "Input"
+ },
+ {
+ "name": "saveJSON",
+ "file": "src/io/files.js",
+ "line": 1536,
+ "itemtype": "method",
+ "description": "Writes the contents of an Array or a JSON object to a .json file.\nThe file saving process and location of the saved file will\nvary between web browsers.",
+ "example": [
+ "\nlet json = {}; // new JSON Object\n\njson.id = 0;\njson.species = 'Panthera leo';\njson.name = 'Lion';\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n describe('no image displayed');\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n saveJSON(json, 'lion.json');\n }\n}\n\n// saves the following to a file called \"lion.json\":\n// {\n// \"id\": 0,\n// \"species\": \"Panthera leo\",\n// \"name\": \"Lion\"\n// }\n
\nlet words = 'apple bear cat dog';\n\n// .split() outputs an Array\nlet list = split(words, ' ');\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n describe('no image displayed');\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n saveStrings(list, 'nouns.txt');\n }\n}\n\n// Saves the following to a file called 'nouns.txt':\n//\n// apple\n// bear\n// cat\n// dog\n
\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('id');\n table.addColumn('species');\n table.addColumn('name');\n\n let newRow = table.addRow();\n newRow.setNum('id', table.getRowCount() - 1);\n newRow.setString('species', 'Panthera leo');\n newRow.setString('name', 'Lion');\n\n // To save, un-comment next line then click 'run'\n // saveTable(table, 'new.csv');\n\n describe('no image displayed');\n}\n\n// Saves the following to a file called 'new.csv':\n// id,species,name\n// 0,Panthera leo,Lion\n
abs(-5)
and abs(5)
both return 5. The absolute\nvalue of a number is always positive.",
+ "example": [
+ "\nfunction draw() {\n // Invert the y-axis.\n scale(1, -1);\n translate(0, -height);\n\n let centerX = width / 2;\n let x = frameCount;\n let y = abs(x - centerX);\n point(x, y);\n\n describe('A series of black dots that form a \"V\" shape.');\n}\n
\nceil(9.03)
returns the value\n10.",
+ "example": [
+ "\n// Set the range for RGB values from 0 to 1.\ncolorMode(RGB, 1);\nnoStroke();\n\nlet r = 0.3;\nfill(r, 0, 0);\nrect(0, 0, width / 2, height);\n\n// Round r up to 1.\nr = ceil(r);\nfill(r, 0, 0);\nrect(width / 2, 0, width / 2, height);\n\ndescribe('Two rectangles. The one on the left is dark red and the one on the right is bright red.');\n
\n\nfunction draw() {\n background(200);\n\n let x = constrain(mouseX, 33, 67);\n let y = 50;\n\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot drawn on a gray square follows the mouse from left to right. Its movement is constrained to the middle third of the square.');\n}\n
\n\nfunction draw() {\n background(200);\n\n // Set boundaries and draw them.\n let leftWall = width * 0.25;\n let rightWall = width * 0.75;\n line(leftWall, 0, leftWall, height);\n line(rightWall, 0, rightWall, height);\n\n // Draw a circle that follows the mouse freely.\n fill(255);\n circle(mouseX, height / 3, 9);\n\n // Draw a circle that's constrained.\n let xc = constrain(mouseX, leftWall, rightWall);\n fill(0);\n circle(xc, 2 * height / 3, 9);\n\n describe('Two vertical lines. Two circles move horizontally with the mouse. One circle stops at the vertical lines.');\n}\n
\nCalculates the distance between two points.
\nThe version of dist()
with four parameters calculates distance in two\ndimensions.
The version of dist()
with six parameters calculates distance in three\ndimensions.
Use p5.Vector.dist() to calculate the\ndistance between two p5.Vector objects.
\n", + "example": [ + "\nlet x1 = 10;\nlet y1 = 50;\nlet x2 = 90;\nlet y2 = 50;\n\nline(x1, y1, x2, y2);\nstrokeWeight(5);\npoint(x1, y1);\npoint(x2, y2);\n\nlet d = dist(x1, y1, x2, y2);\ntext(d, 43, 40);\n\ndescribe('Two dots connected by a horizontal line. The number 80 is written above the center of the line.');\n
\nn
\nparameter.",
+ "example": [
+ "\nfunction draw() {\n // Invert the y-axis.\n scale(1, -1);\n translate(0, -height);\n\n let x = frameCount;\n let y = 0.005 * exp(x * 0.1);\n point(x, y);\n\n describe('A series of black dots that grow exponentially from left to right.');\n}\n
\nn
parameter.",
+ "example": [
+ "\n// Set the range for RGB values from 0 to 1.\ncolorMode(RGB, 1);\nnoStroke();\n\nlet r = 0.8;\nfill(r, 0, 0);\nrect(0, 0, width / 2, height);\n\n// Round r down to 0.\nr = floor(r);\nfill(r, 0, 0);\nrect(width / 2, 0, width / 2, height);\n\ndescribe('Two rectangles. The one on the left is bright red and the one on the right is black.');\n
\nCalculates a number between two numbers at a specific increment. The amt
\nparameter is the amount to interpolate between the two numbers. 0.0 is\nequal to the first number, 0.1 is very near the first number, 0.5 is\nhalf-way in between, and 1.0 is equal to the second number. The lerp()
\nfunction is convenient for creating motion along a straight path and for\ndrawing dotted lines.
If the value of amt
is less than 0 or more than 1, lerp()
will return a\nnumber outside of the original interval. For example, calling\nlerp(0, 10, 1.5)
will return 15.
\nlet a = 20;\nlet b = 80;\nlet c = lerp(a, b, 0.2);\nlet d = lerp(a, b, 0.5);\nlet e = lerp(a, b, 0.8);\n\nlet y = 50;\n\nstrokeWeight(5);\n\n// Draw the original points in black.\nstroke(0);\npoint(a, y);\npoint(b, y);\n\n// Draw the lerped points in gray.\nstroke(100);\npoint(c, y);\npoint(d, y);\npoint(e, y);\n\ndescribe('Five points in a horizontal line. The outer points are black and the inner points are gray.');\n
\nCalculates the magnitude, or length, of a vector. A vector is like an arrow\npointing in space. Vectors are commonly used for programming motion.
\nVectors don't have a \"start\" position because the same arrow can be drawn\nanywhere. A vector's magnitude can be thought of as the distance from the\norigin (0, 0) to its tip at (x, y). mag(x, y)
is a shortcut for calling\ndist(0, 0, x, y)
.
\nlet x = 30;\nlet y = 40;\nlet m = mag(x, y);\n\nline(0, 0, x, y);\ntext(m, x, y);\n\ndescribe('A diagonal line is drawn from the top left of the canvas. The number 50 is written at the end of the line.');\n
\nRe-maps a number from one range to another.
\nFor example, calling map(2, 0, 10, 0, 100)
returns 20. The first three\narguments set the original value to 2 and the original range from 0 to 10.\nThe last two arguments set the target range from 0 to 100. 20's position\nin the target range [0, 100] is proportional to 2's position in the\noriginal range [0, 10].
\nlet n = map(7, 0, 10, 0, 100);\ntext(n, 50, 50);\n\ndescribe('The number 70 written in the middle of a gray square.');\n
\n\nlet x = map(2, 0, 10, 0, width);\ncircle(x, 50, 10);\n\ndescribe('A white circle drawn on the left side of a gray square.');\n
\n\nfunction draw() {\n background(200);\n\n let c = map(mouseX, 0, width, 0, 255);\n fill(c);\n circle(50, 50, 20);\n\n describe('A circle changes color from black to white as the mouse moves from left to right.');\n}\n
\nReturns the largest value in a sequence of numbers.
\nThe version of max()
with one parameter interprets it as an array of\nnumbers and returns the largest number.
The version of max()
with two or more parameters interprets them as\nindividual numbers and returns the largest number.
\nlet m = max(10, 20);\ntext(m, 50, 50);\n\ndescribe('The number 20 written in the middle of a gray square.');\n
\n\nlet m = max([10, 20]);\ntext(m, 50, 50);\n\ndescribe('The number 20 written in the middle of a gray square.');\n
\n\nlet numbers = [2, 1, 5, 4, 8, 9];\n\n// Draw all of the numbers in the array.\nnoStroke();\nlet spacing = 15;\nnumbers.forEach((n, index) => {\n let x = index * spacing;\n let y = 25;\n text(n, x, y);\n});\n\n// Draw the maximum value in the array.\nlet m = max(numbers);\nlet maxX = 33;\nlet maxY = 80;\n\ntextSize(32);\ntext(m, maxX, maxY);\n\ndescribe('The numbers 2 1 5 4 8 9 are written in small text at the top of a gray square. The number 9 is written in large text at the center of the square.');\n
\nReturns the smallest value in a sequence of numbers.
\nThe version of min()
with one parameter interprets it as an array of\nnumbers and returns the smallest number.
The version of min()
with two or more parameters interprets them as\nindividual numbers and returns the smallest number.
\nlet m = min(10, 20);\ntext(m, 50, 50);\n\ndescribe('The number 10 written in the middle of a gray square.');\n
\n\nlet m = min([10, 20]);\ntext(m, 50, 50);\n\ndescribe('The number 10 written in the middle of a gray square.');\n
\n\nlet numbers = [2, 1, 5, 4, 8, 9];\n\n// Draw all of the numbers in the array.\nnoStroke();\nlet spacing = 15;\nnumbers.forEach((n, index) => {\n let x = index * spacing;\n let y = 25;\n text(n, x, y);\n});\n\n// Draw the minimum value in the array.\nlet m = min(numbers);\nlet minX = 33;\nlet minY = 80;\n\ntextSize(32);\ntext(m, minX, minY);\n\ndescribe('The numbers 2 1 5 4 8 9 are written in small text at the top of a gray square. The number 1 is written in large text at the center of the square.');\n
\nMaps a number from one range to a value between 0 and 1.
\nFor example, norm(2, 0, 10)
returns 0.2. 2's position in the original\nrange [0, 10] is proportional to 0.2's position in the range [0, 1]. This\nis equivalent to calling map(2, 0, 10, 0, 1)
.
Numbers outside of the original range are not constrained between 0 and 1.\nOut-of-range values are often intentional and useful.
\n", + "example": [ + "\nfunction draw() {\n // Set the range for RGB values from 0 to 1.\n colorMode(RGB, 1);\n\n let r = norm(mouseX, 0, width);\n background(r, 0, 0);\n\n describe('A square changes color from black to red as the mouse moves from left to right.');\n}\n
\nCalculates exponential expressions such as 2^3.
\nFor example, pow(2, 3)
is equivalent to the expression\n2 × 2 × 2. pow(2, -3)
is equivalent to 1 ÷\n(2 × 2 × 2).
\nlet base = 3;\n\nlet d = pow(base, 1);\ncircle(10, 10, d);\n\nd = pow(base, 2);\ncircle(20, 20, d);\n\nd = pow(base, 3);\ncircle(40, 40, d);\n\nd = pow(base, 4);\ncircle(80, 80, d);\n\ndescribe('A series of circles that grow exponentially from top left to bottom right.');\n
\nn
parameter. For example,\nround(133.8)
returns the value 134.",
+ "example": [
+ "\nlet x = round(3.7);\ntext(x, width / 2, height / 2);\n\ndescribe('The number 4 written in middle of canvas.');\n
\n\nlet x = round(12.782383, 2);\ntext(x, width / 2, height / 2);\n\ndescribe('The number 12.78 written in middle of canvas.');\n
\nSquares a number, which means multiplying the number by itself. The value\nreturned is always a positive number.
\nFor example, sq(3)
evaluates 3 × 3 which is 9. sq(-3)
evaluates\n-3 × -3 which is also 9. Multiplying two negative numbers produces\na positive number.
\nfunction draw() {\n // Invert the y-axis.\n scale(1, -1);\n translate(0, -height);\n\n let x = frameCount;\n let y = 0.01 * sq(x);\n point(x, y);\n\n describe('A series of black dots that get higher quickly from left to right.');\n}\n
\nCalculates the square root of a number. A number's square root can be\nmultiplied by itself to produce the original number.
\nFor example, sqrt(9)
returns 3 because 3 × 3 = 9. sqrt()
always\nreturns a positive value. sqrt()
doesn't work with negative arguments\nsuch as sqrt(-9)
.
\nfunction draw() {\n // Invert the y-axis.\n scale(1, -1);\n translate(0, -height);\n\n let x = frameCount;\n let y = 5 * sqrt(x);\n point(x, y);\n\n describe('A series of black dots that get higher slowly from left to right.');\n}\n
\nfract(12.34)
returns 0.34.",
+ "example": [
+ "\nlet n = 56.78;\ntext(n, 20, 33);\nlet f = fract(n);\ntext(f, 20, 66);\n\ndescribe('The number 56.78 written above the number 0.78.');\n
\nCreates a new p5.Vector object. A vector is like\nan arrow pointing in space. Vectors have both magnitude (length)\nand direction. Calling createVector()
without arguments sets the new\nvector's components to 0.
p5.Vector objects are often used to program\nmotion because they simplify the math. For example, a moving ball has a\nposition and a velocity. Position describes where the ball is in space. The\nball's position vector extends from the origin to the ball's center.\nVelocity describes the ball's speed and the direction it's moving. If the\nball is moving straight up, its velocity vector points straight up. Adding\nthe ball's velocity vector to its position vector moves it, as in\npos.add(vel)
. Vector math relies on methods inside the\np5.Vector class.
\nlet p1 = createVector(25, 25);\nlet p2 = createVector(50, 50);\nlet p3 = createVector(75, 75);\n\nstrokeWeight(5);\npoint(p1);\npoint(p2);\npoint(p3);\n\ndescribe('Three black dots form a diagonal line from top left to bottom right.');\n
\n\nlet pos;\nlet vel;\n\nfunction setup() {\n createCanvas(100, 100);\n pos = createVector(width / 2, height);\n vel = createVector(0, -1);\n}\n\nfunction draw() {\n background(200);\n\n pos.add(vel);\n\n if (pos.y < 0) {\n pos.y = height;\n }\n\n strokeWeight(5);\n point(pos);\n\n describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.');\n}\n
\nReturns random numbers that can be tuned to feel more organic. The values\nreturned will always be between 0 and 1.
\nValues returned by random() and\nrandomGaussian() can change by large\namounts between function calls. By contrast, values returned by noise()
\ncan be made \"smooth\". Calls to noise()
with similar inputs will produce\nsimilar outputs. noise()
is used to create textures, motion, shapes,\nterrains, and so on. Ken Perlin invented noise()
while animating the\noriginal Tron film in the 1980s.
noise()
returns the same value for a given input while a sketch is\nrunning. It produces different results each time a sketch runs. The\nnoiseSeed() function can be used to generate\nthe same sequence of Perlin noise values each time a sketch runs.
The character of the noise can be adjusted in two ways. The first way is to\nscale the inputs. noise()
interprets inputs as coordinates. The sequence\nof noise values will be smoother when the input coordinates are closer. The\nsecond way is to use the noiseDetail()\nfunction.
The version of noise()
with one parameter computes noise values in one\ndimension. This dimension can be thought of as space, as in noise(x)
, or\ntime, as in noise(t)
.
The version of noise()
with two parameters computes noise values in two\ndimensions. These dimensions can be thought of as space, as in\nnoise(x, y)
, or space and time, as in noise(x, t)
.
The version of noise()
with three parameters computes noise values in\nthree dimensions. These dimensions can be thought of as space, as in\nnoise(x, y, z)
, or space and time, as in noise(x, y, t)
.
\nfunction draw() {\n background(200);\n\n let x = 100 * noise(0.005 * frameCount);\n let y = 100 * noise(0.005 * frameCount + 10000);\n\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot moves randomly on a gray square.');\n}\n
\n\nfunction draw() {\n background(200);\n\n let noiseLevel = 100;\n let noiseScale = 0.005;\n // Scale input coordinate.\n let nt = noiseScale * frameCount;\n // Compute noise value.\n let x = noiseLevel * noise(nt);\n let y = noiseLevel * noise(nt + 10000);\n // Render.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot moves randomly on a gray square.');\n}\n
\n\nfunction draw() {\n let noiseLevel = 100;\n let noiseScale = 0.02;\n // Scale input coordinate.\n let x = frameCount;\n let nx = noiseScale * x;\n // Compute noise value.\n let y = noiseLevel * noise(nx);\n // Render.\n line(x, 0, x, y);\n\n describe('A hilly terrain drawn in gray against a black sky.');\n}\n
\n\nfunction draw() {\n background(200);\n\n let noiseLevel = 100;\n let noiseScale = 0.002;\n for (let x = 0; x < width; x += 1) {\n // Scale input coordinates.\n let nx = noiseScale * x;\n let nt = noiseScale * frameCount;\n // Compute noise value.\n let y = noiseLevel * noise(nx, nt);\n // Render.\n line(x, 0, x, y);\n }\n\n describe('A calm sea drawn in gray against a black sky.');\n}\n
\n\nlet noiseLevel = 255;\nlet noiseScale = 0.01;\nfor (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n // Scale input coordinates.\n let nx = noiseScale * x;\n let ny = noiseScale * y;\n // Compute noise value.\n let c = noiseLevel * noise(nx, ny);\n // Render.\n stroke(c);\n point(x, y);\n }\n}\n\ndescribe('A gray cloudy pattern.');\n
\n\nfunction draw() {\n let noiseLevel = 255;\n let noiseScale = 0.009;\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n // Scale input coordinates.\n let nx = noiseScale * x;\n let ny = noiseScale * y;\n let nt = noiseScale * frameCount;\n // Compute noise value.\n let c = noiseLevel * noise(nx, ny, nt);\n // Render.\n stroke(c);\n point(x, y);\n }\n }\n\n describe('A gray cloudy pattern that changes.');\n}\n
\nAdjusts the character of the noise produced by the\nnoise() function.
\nPerlin noise values are created by adding layers of noise together. The\nnoise layers, called octaves, are similar to harmonics in music. Lower\noctaves contribute more to the output signal. They define the overall\nintensity of the noise. Higher octaves create finer-grained details.
\nBy default, noise values are created by combining four octaves. Each higher\noctave contributes half as much (50% less) compared to its predecessor.\nnoiseDetail()
changes the number of octaves and the falloff amount. For\nexample, calling noiseDetail(6, 0.25)
ensures that\nnoise() will use six octaves. Each higher octave\nwill contribute 25% as much (75% less) compared to its predecessor. Falloff\nvalues between 0 and 1 are valid. However, falloff values greater than 0.5\nmight result in noise values greater than 1.
\nlet noiseLevel = 255;\nlet noiseScale = 0.02;\nfor (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width / 2; x += 1) {\n // Scale input coordinates.\n let nx = noiseScale * x;\n let ny = noiseScale * y;\n\n // Compute noise value.\n noiseDetail(6, 0.25);\n let c = noiseLevel * noise(nx, ny);\n // Render left side.\n stroke(c);\n point(x, y);\n\n // Compute noise value.\n noiseDetail(4, 0.5);\n c = noiseLevel * noise(nx, ny);\n // Render right side.\n stroke(c);\n point(x + width / 2, y);\n }\n}\n\ndescribe('Two gray cloudy patterns. The pattern on the right is cloudier than the pattern on the left.');\n
\nnoiseSeed()
with a constant\nargument, such as noiseSeed(99)
, makes noise()\nproduce the same results each time a sketch is run.",
+ "example": [
+ "\nfunction setup() {\n noiseSeed(99);\n background(255);\n}\n\nfunction draw() {\n let noiseLevel = 100;\n let noiseScale = 0.005;\n // Scale input coordinate.\n let nt = noiseScale * frameCount;\n // Compute noise value.\n let x = noiseLevel * noise(nt);\n // Render.\n line(x, 0, x, height);\n\n describe('A black rectangle that grows randomly, first to the right and then to the left.');\n}\n
\nrandomSeed()
with a constant\nargument, such as randomSeed(99)
, makes these functions produce the same\nresults each time a sketch is run.",
+ "example": [
+ "\nlet x = random(width);\nlet y = random(height);\ncircle(x, y, 10);\n\nrandomSeed(99);\nx = random(width);\ny = random(height);\nfill(0);\ncircle(x, y, 10);\n\ndescribe('A white circle appears at a random position. A black circle appears at (27.4, 25.8).');\n
\nReturns a random number or a random element from an array.
\nrandom()
follows uniform distribution, which means that all outcomes are\nequally likely. When random()
is used to generate numbers, all\nnumbers in the output range are equally likely to be returned. When\nrandom()
is used to select elements from an array, all elements are\nequally likely to be chosen.
By default, random()
produces different results each time a sketch runs.\nThe randomSeed() function can be used to\ngenerate the same sequence of numbers or choices each time a sketch runs.
The version of random()
with no parameters returns a random number from 0\nup to but not including 1.
The version of random()
with one parameter works one of two ways. If the\nargument passed is a number, random()
returns a random number from 0 up\nto but not including the number. For example, calling random(5)
returns\nvalues between 0 and 5. If the argument passed is an array, random()
\nreturns a random element from that array. For example, calling\nrandom(['🦁', '🐯', '🐻'])
returns either a lion, tiger, or bear emoji.
The version of random()
with two parameters returns a random number from\na given range. The arguments passed set the range's lower and upper bounds.\nFor example, calling random(-5, 10.2)
returns values from -5 up to but\nnot including 10.2.
\nlet x = random(width);\nlet y = random(height);\n\nstrokeWeight(5);\npoint(x, y);\n\ndescribe('A black dot appears in a random position on a gray square.');\n
\n\nlet animals = ['🦁', '🐯', '🐻'];\nlet animal = random(animals);\ntext(animal, 50, 50);\n\ndescribe('An animal face is displayed at random. Either a lion, tiger, or bear.');\n
\n\nfunction draw() {\n background(200);\n\n frameRate(5);\n let x = random(width);\n let y = random(height);\n\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot moves around randomly on a gray square.');\n}\n
\n\nfunction draw() {\n background(200);\n\n frameRate(5);\n let x = random(45, 55);\n let y = random(45, 55);\n\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot moves around randomly in the middle of a gray square.');\n}\n
\nReturns a random number fitting a Gaussian, or normal, distribution. Normal\ndistributions look like bell curves when plotted. Values from a normal\ndistribution cluster around a central value called the mean. The cluster's\nstandard deviation describes its spread.
\nBy default, randomGaussian()
produces different results each time a\nsketch runs. The randomSeed() function can be\nused to generate the same sequence of numbers each time a sketch runs.
There's no minimum or maximum value that randomGaussian()
might return.\nValues far from the mean are very unlikely and values near the mean are\nvery likely.
The version of randomGaussian()
with no parameters returns values with a\nmean of 0 and standard deviation of 1.
The version of randomGaussian()
with one parameter interprets the\nargument passed as the mean. The standard deviation is 1.
The version of randomGaussian()
with two parameters interprets the first\nargument passed as the mean and the second as the standard deviation.
\nfunction draw() {\n noStroke();\n fill(0, 10);\n\n // Uniform distribution.\n let x = random(width);\n let y = 25;\n circle(x, y, 5);\n\n // Gaussian distribution with sd = 1.\n x = randomGaussian(50);\n y = 50;\n circle(x, y, 5);\n\n // Gaussian distribution with sd = 10.\n x = randomGaussian(50, 10);\n y = 75;\n circle(x, y, 5);\n\n describe('Three horizontal black lines are filled in randomly. The top line spans entire canvas. The middle line is very short. The bottom line spans two-thirds of the canvas.');\n}\n
\nacos()
returns values in the range 0 to π (about 3.14). If the\nangleMode() is DEGREES
, then values are\nreturned in the range 0 to 180.",
+ "example": [
+ "\nlet a = PI + QUARTER_PI;\nlet c = cos(a);\nlet ac = acos(c);\ntext(`${round(a, 3)}`, 35, 25);\ntext(`${round(c, 3)}`, 35, 50);\ntext(`${round(ac, 3)}`, 35, 75);\n\ndescribe('The numbers 3.142, -1, and 3.142 written on separate rows.');\n
\n\nlet a = PI;\nlet c = cos(a);\nlet ac = acos(c);\ntext(`${round(a, 3)}`, 35, 25);\ntext(`${round(c, 3)}`, 35, 50);\ntext(`${round(ac, 3)}`, 35, 75);\n\ndescribe('The numbers 3.927, -0.707, and 2.356 written on separate rows.');\n
\nasin()
returns values in the range -π ÷ 2\n(about -1.57) to π ÷ 2 (about 1.57). If the\nangleMode() is DEGREES
then values are\nreturned in the range -90 to 90.",
+ "example": [
+ "\nlet a = PI / 3;\nlet s = sin(a);\nlet as = asin(s);\ntext(`${round(a, 3)}`, 35, 25);\ntext(`${round(s, 3)}`, 35, 50);\ntext(`${round(as, 3)}`, 35, 75);\n\ndescribe('The numbers 1.047, 0.866, and 1.047 written on separate rows.');\n
\n\nlet a = PI + PI / 3;\nlet s = sin(a);\nlet as = asin(s);\ntext(`${round(a, 3)}`, 35, 25);\ntext(`${round(s, 3)}`, 35, 50);\ntext(`${round(as, 3)}`, 35, 75);\n\ndescribe('The numbers 4.189, -0.866, and -1.047 written on separate rows.');\n
\natan()
returns values in the range -π ÷ 2\n(about -1.57) to π ÷ 2 (about 1.57). If the\nangleMode() is DEGREES
then values are\nreturned in the range -90 to 90.",
+ "example": [
+ "\nlet a = PI / 3;\nlet t = tan(a);\nlet at = atan(t);\ntext(`${round(a, 3)}`, 35, 25);\ntext(`${round(t, 3)}`, 35, 50);\ntext(`${round(at, 3)}`, 35, 75);\n\ndescribe('The numbers 1.047, 1.732, and 1.047 written on separate rows.');\n
\n\nlet a = PI + PI / 3;\nlet t = tan(a);\nlet at = atan(t);\ntext(`${round(a, 3)}`, 35, 25);\ntext(`${round(t, 3)}`, 35, 50);\ntext(`${round(at, 3)}`, 35, 75);\n\ndescribe('The numbers 4.189, 1.732, and 1.047 written on separate rows.');\n
\nCalculates the angle formed by a specified point, the origin, and the\npositive x-axis. By default, atan2()
returns values in the range\n-π (about -3.14) to π (3.14). If the\nangleMode() is DEGREES
, then values are\nreturned in the range -180 to 180. The atan2()
function is most often\nused for orienting geometry to the mouse's position.
Note: The y-coordinate of the point is the first parameter and the\nx-coordinate is the second parameter.
\n", + "example": [ + "\nfunction draw() {\n background(200);\n translate(width / 2, height / 2);\n let x = mouseX - width / 2;\n let y = mouseY - height / 2;\n let a = atan2(y, x);\n rotate(a);\n rect(-30, -5, 60, 10);\n\n describe('A rectangle at the center of the canvas rotates with mouse movements.');\n}\n
\ncos()
is useful for many geometric\ntasks in creative coding. The values returned oscillate between -1 and 1\nas the input angle increases. cos()
takes into account the current\nangleMode.",
+ "example": [
+ "\nfunction draw() {\n background(200);\n\n let t = frameCount;\n let x = 30 * cos(t * 0.05) + 50;\n let y = 50;\n line(50, y, x, y);\n circle(x, y, 20);\n\n describe('A white ball on a string oscillates left and right.');\n}\n
\n\nfunction draw() {\n let x = frameCount;\n let y = 30 * cos(x * 0.1) + 50;\n point(x, y);\n\n describe('A series of black dots form a wave pattern.');\n}\n
\n\nfunction draw() {\n let t = frameCount;\n let x = 30 * cos(t * 0.1) + 50;\n let y = 10 * sin(t * 0.2) + 50;\n point(x, y);\n\n describe('A series of black dots form an infinity symbol.');\n}\n
\nsin()
is useful for many geometric tasks\nin creative coding. The values returned oscillate between -1 and 1 as the\ninput angle increases. sin()
takes into account the current\nangleMode.",
+ "example": [
+ "\nfunction draw() {\n background(200);\n\n let t = frameCount;\n let x = 50;\n let y = 30 * sin(t * 0.05) + 50;\n line(x, 50, x, y);\n circle(x, y, 20);\n\n describe('A white ball on a string oscillates up and down.');\n}\n
\n\nfunction draw() {\n let x = frameCount;\n let y = 30 * sin(x * 0.1) + 50;\n point(x, y);\n\n describe('A series of black dots form a wave pattern.');\n}\n
\n\nfunction draw() {\n let t = frameCount;\n let x = 30 * cos(t * 0.1) + 50;\n let y = 10 * sin(t * 0.2) + 50;\n point(x, y);\n\n describe('A series of black dots form an infinity symbol.');\n}\n
\ntan()
is useful for many geometric\ntasks in creative coding. The values returned range from -Infinity\nto Infinity and repeat periodically as the input angle increases. tan()
\ntakes into account the current angleMode.",
+ "example": [
+ "\nfunction draw() {\n let x = frameCount;\n let y = 5 * tan(x * 0.1) + 50;\n point(x, y);\n\n describe('A series of identical curves drawn with black dots. Each curve starts from the top of the canvas, continues down at a slight angle, flattens out at the middle of the canvas, then continues to the bottom.');\n}\n
\n\nlet rad = QUARTER_PI;\nlet deg = degrees(rad);\ntext(`${round(rad, 2)} rad = ${deg}˚`, 10, 50);\n\ndescribe('The text \"0.79 rad = 45˚\".');\n
\n\nlet deg = 45;\nlet rad = radians(deg);\ntext(`${deg}˚ = ${round(rad, 3)} rad`, 10, 50);\n\ndescribe('The text \"45˚ = 0.785 rad\".');\n
\nChanges the way trigonometric functions interpret angle values. By default,\nthe mode is RADIANS
.
Calling angleMode()
with no arguments returns current angle mode.
\nlet r = 40;\npush();\nrotate(PI / 6);\nline(0, 0, r, 0);\ntext('0.524 rad', r, 0);\npop();\n\nangleMode(DEGREES);\npush();\nrotate(60);\nline(0, 0, r, 0);\ntext('60˚', r, 0);\npop();\n\ndescribe('Two diagonal lines radiating from the top left corner of a square. The lines are oriented 30 degrees from the edges of the square and 30 degrees apart from each other.');\n
\nSets the way text is aligned when text() is called.
\nBy default, calling text('hi', 10, 20)
places the bottom-left corner of\nthe text's bounding box at (10, 20).
The first parameter, horizAlign
, changes the way\ntext() interprets x-coordinates. By default, the\nx-coordinate sets the left edge of the bounding box. textAlign()
accepts\nthe following values for horizAlign
: LEFT
, CENTER
, or RIGHT
.
The second parameter, vertAlign
, is optional. It changes the way\ntext() interprets y-coordinates. By default, the\ny-coordinate sets the bottom edge of the bounding box. textAlign()
\naccepts the following values for vertAlign
: TOP
, BOTTOM
, CENTER
,\nor BASELINE
.
\nstrokeWeight(0.5);\nline(50, 0, 50, 100);\n\ntextSize(16);\ntextAlign(RIGHT);\ntext('ABCD', 50, 30);\ntextAlign(CENTER);\ntext('EFGH', 50, 50);\ntextAlign(LEFT);\ntext('IJKL', 50, 70);\n\ndescribe('The letters ABCD displayed at top-left, EFGH at center, and IJKL at bottom-right. A vertical line divides the canvas in half.');\n
\n\nstrokeWeight(0.5);\n\nline(0, 12, width, 12);\ntextAlign(CENTER, TOP);\ntext('TOP', 50, 12);\n\nline(0, 37, width, 37);\ntextAlign(CENTER, CENTER);\ntext('CENTER', 50, 37);\n\nline(0, 62, width, 62);\ntextAlign(CENTER, BASELINE);\ntext('BASELINE', 50, 62);\n\nline(0, 97, width, 97);\ntextAlign(CENTER, BOTTOM);\ntext('BOTTOM', 50, 97);\n\ndescribe('The words \"TOP\", \"CENTER\", \"BASELINE\", and \"BOTTOM\" each drawn relative to a horizontal line. Their positions demonstrate different vertical alignments.');\n
\nSets the spacing between lines of text when\ntext() is called. Spacing is measured in pixels.
\nCalling textLeading()
without an argument returns the current spacing.
\n// \"\\n\" starts a new line of text.\nlet lines = 'one\\ntwo';\n\ntext(lines, 10, 25);\n\ntextLeading(30);\ntext(lines, 70, 25);\n\ndescribe('The words \"one\" and \"two\" written on separate lines twice. The words on the left have less vertical spacing than the words on the right.');\n
\nSets the font size when\ntext() is called. Font size is measured in pixels.
\nCalling textSize()
without an arugment returns the current size.
\ntextSize(12);\ntext('Font Size 12', 10, 30);\ntextSize(14);\ntext('Font Size 14', 10, 60);\ntextSize(16);\ntext('Font Size 16', 10, 90);\n\ndescribe('The text \"Font Size 12\" drawn small, \"Font Size 14\" drawn medium, and \"Font Size 16\" drawn large.');\n
\nSets the style for system fonts when\ntext() is called. textStyle()
accepts the\nfollowing values: NORMAL
, ITALIC
, BOLD
or BOLDITALIC
.
textStyle()
may be overridden by CSS styling. This function doesn't\naffect fonts loaded with loadFont().
\ntextSize(12);\ntextAlign(CENTER);\n\ntextStyle(NORMAL);\ntext('Normal', 50, 15);\ntextStyle(ITALIC);\ntext('Italic', 50, 40);\ntextStyle(BOLD);\ntext('Bold', 50, 65);\ntextStyle(BOLDITALIC);\ntext('Bold Italic', 50, 90);\n\ndescribe('The words \"Normal\" displayed normally, \"Italic\" in italic, \"Bold\" in bold, and \"Bold Italic\" in bold italics.');\n
\n\nfunction setup() {\n background(200);\n\n textSize(28);\n strokeWeight(0.5);\n let s = 'yoyo';\n let w = textWidth(s);\n text(s, 22, 55);\n line(22, 55, 22 + w, 55);\n\n describe('The word \"yoyo\" underlined.');\n}\n
\n\nfunction setup() {\n background(200);\n\n textSize(28);\n strokeWeight(0.5);\n // \"\\n\" starts a new line.\n let s = 'yo\\nyo';\n let w = textWidth(s);\n text(s, 22, 55);\n line(22, 55, 22 + w, 55);\n\n describe('The word \"yo\" written twice, one copy beneath the other. The words are divided by a horizontal line.');\n}\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n background(200);\n textFont(font);\n\n // Different for each font.\n let fontScale = 0.8;\n\n let baseY = 75;\n strokeWeight(0.5);\n\n // Draw small text.\n textSize(24);\n text('dp', 0, baseY);\n // Draw baseline and ascent.\n let a = textAscent() * fontScale;\n line(0, baseY, 23, baseY);\n line(23, baseY - a, 23, baseY);\n\n // Draw large text.\n textSize(48);\n text('dp', 45, baseY);\n // Draw baseline and ascent.\n a = textAscent() * fontScale;\n line(45, baseY, 91, baseY);\n line(91, baseY - a, 91, baseY);\n\n describe('The letters \"dp\" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends upward from each baseline to the top of the \"d\".');\n}\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n background(200);\n textFont(font);\n\n // Different for each font.\n let fontScale = 0.9;\n\n let baseY = 75;\n strokeWeight(0.5);\n\n // Draw small text.\n textSize(24);\n text('dp', 0, baseY);\n // Draw baseline and descent.\n let d = textDescent() * fontScale;\n line(0, baseY, 23, baseY);\n line(23, baseY, 23, baseY + d);\n\n // Draw large text.\n textSize(48);\n text('dp', 45, baseY);\n // Draw baseline and descent.\n d = textDescent() * fontScale;\n line(45, baseY, 91, baseY);\n line(91, baseY, 91, baseY + d);\n\n describe('The letters \"dp\" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends downward from each baseline to the bottom of the \"p\".');\n}\n
\nSets the style for wrapping text when\ntext() is called. textWrap()
accepts the\nfollowing values:
WORD
starts new lines of text at spaces. If a string of text doesn't\nhave spaces, it may overflow the text box and the canvas. This is the\ndefault style.
CHAR
starts new lines as needed to stay within the text box.
textWrap()
only works when the maximum width is set for a text box. For\nexample, calling text('Have a wonderful day', 0, 10, 100)
sets the\nmaximum width to 100 pixels.
Calling textWrap()
without an argument returns the current style.
\ntextSize(20);\ntextWrap(WORD);\ntext('Have a wonderful day', 0, 10, 100);\n
\n\ntextSize(20);\ntextWrap(CHAR);\ntext('Have a wonderful day', 0, 10, 100);\n
\n\ntextSize(20);\ntextWrap(CHAR);\ntext('祝你有美好的一天', 0, 10, 100);\n
\nLoads a font and creates a p5.Font object.\nloadFont()
can load fonts in either .otf or .ttf format. Loaded fonts can\nbe used to style text on the canvas and in HTML elements.
The first parameter, path
, is the path to a font file.\nPaths to local files should be relative. For example,\n'assets/inconsolata.otf'
. The Inconsolata font used in the following\nexamples can be downloaded for free\nhere.\nPaths to remote files should be URLs. For example,\n'https://example.com/inconsolata.otf'
. URLs may be blocked due to browser\nsecurity.
The second parameter, successCallback
, is optional. If a function is\npassed, it will be called once the font has loaded. The callback function\nmay use the new p5.Font object if needed.
The third parameter, failureCallback
, is also optional. If a function is\npassed, it will be called if the font fails to load. The callback function\nmay use the error\nEvent\nobject if needed.
Fonts can take time to load. Calling loadFont()
in\npreload() ensures fonts load before they're\nused in setup() or\ndraw().
\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n fill('deeppink');\n textFont(font);\n textSize(36);\n text('p5*js', 10, 50);\n\n describe('The text \"p5*js\" written in pink on a white background.');\n}\n
\n\nfunction setup() {\n loadFont('assets/inconsolata.otf', font => {\n fill('deeppink');\n textFont(font);\n textSize(36);\n text('p5*js', 10, 50);\n\n describe('The text \"p5*js\" written in pink on a white background.');\n });\n}\n
\n\nfunction setup() {\n loadFont('assets/inconsolata.otf', success, failure);\n}\n\nfunction success(font) {\n fill('deeppink');\n textFont(font);\n textSize(36);\n text('p5*js', 10, 50);\n\n describe('The text \"p5*js\" written in pink on a white background.');\n}\n\nfunction failure(event) {\n console.error('Oops!', event);\n}\n
\n\nfunction preload() {\n loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n let p = createP('p5*js');\n p.style('color', 'deeppink');\n p.style('font-family', 'Inconsolata');\n p.style('font-size', '36px');\n p.position(10, 50);\n\n describe('The text \"p5*js\" written in pink on a white background.');\n}\n
\nDraws text to the canvas.
\nThe first parameter, str
, is the text to be drawn. The second and third\nparameters, x
and y
, set the coordinates of the text's bottom-left\ncorner. See textAlign() for other ways to\nalign text.
The fourth and fifth parameters, maxWidth
and maxHeight
, are optional.\nThey set the dimensions of the invisible rectangle containing the text. By\ndefault, they set its maximum width and height. See\nrectMode() for other ways to define the\nrectangular text box. Text will wrap to fit within the text box. Text\noutside of the box won't be drawn.
Text can be styled a few ways. Call the fill()\nfunction to set the text's fill color. Call\nstroke() and\nstrokeWeight() to set the text's outline.\nCall textSize() and\ntextFont() to set the text's size and font,\nrespectively.
\nNote: WEBGL
mode only supports fonts loaded with\nloadFont(). Calling\nstroke() has no effect in WEBGL
mode.
\nfunction setup() {\n background(200);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in black in the middle of a gray square.');\n}\n
\n\nfunction setup() {\n background('skyblue');\n textSize(100);\n text('🌈', 0, 100);\n\n describe('A rainbow in a blue sky.');\n}\n
\n\nfunction setup() {\n textSize(32);\n fill(255);\n stroke(0);\n strokeWeight(4);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in white with a black outline.');\n}\n
\n\nfunction setup() {\n background('black');\n textSize(22);\n fill('yellow');\n text('rainbows', 6, 20);\n fill('cornflowerblue');\n text('rainbows', 6, 45);\n fill('tomato');\n text('rainbows', 6, 70);\n fill('limegreen');\n text('rainbows', 6, 95);\n\n describe('The text \"rainbows\" written on several lines, each in a different color.');\n}\n
\n\nfunction setup() {\n background(200);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 10, 10, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n
\n\nfunction setup() {\n background(200);\n rectMode(CENTER);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 50, 50, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textFont(font);\n textSize(32);\n textAlign(CENTER, CENTER);\n}\n\nfunction draw() {\n background(0);\n rotateY(frameCount / 30);\n text('p5*js', 0, 0);\n\n describe('The text \"p5*js\" written in white and spinning in 3D.');\n}\n
\nSets the font used by the text() function.
\nThe first parameter, font
, sets the font. textFont()
recognizes either\na p5.Font object or a string with the name of a\nsystem font. For example, 'Courier New'
.
The second parameter, size
, is optional. It sets the font size in pixels.\nThis has the same effect as calling textSize().
Note: WEBGL
mode only supports fonts loaded with\nloadFont().
\nfunction setup() {\n background(200);\n textFont('Courier New');\n textSize(24);\n text('hi', 35, 55);\n\n describe('The text \"hi\" written in a black, monospace font on a gray background.');\n}\n
\n\nfunction setup() {\n background('black');\n fill('palegreen');\n textFont('Courier New', 10);\n text('You turn to the left and see a door. Do you enter?', 5, 5, 90, 90);\n text('>', 5, 70);\n\n describe('A text prompt from a game is written in a green, monospace font on a black background.');\n}\n
\n\nfunction setup() {\n background(200);\n textFont('Verdana');\n let currentFont = textFont();\n text(currentFont, 25, 50);\n\n describe('The text \"Verdana\" written in a black, sans-serif font on a gray background.');\n}\n
\n\nlet fontRegular;\nlet fontItalic;\nlet fontBold;\n\nfunction preload() {\n fontRegular = loadFont('assets/Regular.otf');\n fontItalic = loadFont('assets/Italic.ttf');\n fontBold = loadFont('assets/Bold.ttf');\n}\n\nfunction setup() {\n background(200);\n textFont(fontRegular);\n text('I am Normal', 10, 30);\n textFont(fontItalic);\n text('I am Italic', 10, 50);\n textFont(fontBold);\n text('I am Bold', 10, 70);\n\n describe('The statements \"I am Normal\", \"I am Italic\", and \"I am Bold\" written in black on separate lines. The statements have normal, italic, and bold fonts, respectively.');\n}\n
\n\nfunction setup() {\n let myArray = ['Mango', 'Apple', 'Papaya'];\n print(myArray); // ['Mango', 'Apple', 'Papaya']\n\n append(myArray, 'Peach');\n print(myArray); // ['Mango', 'Apple', 'Papaya', 'Peach']\n}\n
Copies an array (or part of an array) to another array. The src array is\ncopied to the dst array, beginning at the position specified by\nsrcPosition and into the position specified by dstPosition. The number of\nelements to copy is determined by length. Note that copying values\noverwrites existing values in the destination array. To append values\ninstead of overwriting them, use concat().
\nThe simplified version with only two arguments, arrayCopy(src, dst),\ncopies an entire array to another of the same size. It is equivalent to\narrayCopy(src, 0, dst, 0, src.length).
\nUsing this function is far more efficient for copying array data than\niterating through a for() loop and copying each element individually.
\n", + "example": [ + "\nlet src = ['A', 'B', 'C'];\nlet dst = [1, 2, 3];\nlet srcPosition = 1;\nlet dstPosition = 0;\nlet length = 2;\n\nprint(src); // ['A', 'B', 'C']\nprint(dst); // [ 1 , 2 , 3 ]\n\narrayCopy(src, srcPosition, dst, dstPosition, length);\nprint(dst); // ['B', 'C', 3]\n
\nfunction setup() {\n let arr1 = ['A', 'B', 'C'];\n let arr2 = [1, 2, 3];\n\n print(arr1); // ['A','B','C']\n print(arr2); // [1,2,3]\n\n let arr3 = concat(arr1, arr2);\n\n print(arr1); // ['A','B','C']\n print(arr2); // [1, 2, 3]\n print(arr3); // ['A','B','C', 1, 2, 3]\n}\n
\nfunction setup() {\n let myArray = ['A', 'B', 'C'];\n print(myArray); // ['A','B','C']\n\n reverse(myArray);\n print(myArray); // ['C','B','A']\n}\n
\nfunction setup() {\n let myArray = ['A', 'B', 'C'];\n print(myArray); // ['A', 'B', 'C']\n let newArray = shorten(myArray);\n print(myArray); // ['A','B','C']\n print(newArray); // ['A','B']\n}\n
\nfunction setup() {\n let regularArr = ['ABC', 'def', createVector(), TAU, Math.E];\n print(regularArr);\n shuffle(regularArr, true); // force modifications to passed array\n print(regularArr);\n\n // By default shuffle() returns a shuffled cloned array:\n let newArr = shuffle(regularArr);\n print(regularArr);\n print(newArr);\n}\n
\nfunction setup() {\n let words = ['banana', 'apple', 'pear', 'lime'];\n print(words); // ['banana', 'apple', 'pear', 'lime']\n let count = 4; // length of array\n\n words = sort(words, count);\n print(words); // ['apple', 'banana', 'lime', 'pear']\n}\n
\nfunction setup() {\n let numbers = [2, 6, 1, 5, 14, 9, 8, 12];\n print(numbers); // [2, 6, 1, 5, 14, 9, 8, 12]\n let count = 5; // Less than the length of the array\n\n numbers = sort(numbers, count);\n print(numbers); // [1,2,5,6,14,9,8,12]\n}\n
\nfunction setup() {\n let myArray = [0, 1, 2, 3, 4];\n let insArray = ['A', 'B', 'C'];\n print(myArray); // [0, 1, 2, 3, 4]\n print(insArray); // ['A','B','C']\n\n splice(myArray, insArray, 3);\n print(myArray); // [0,1,2,'A','B','C',3,4]\n}\n
\nfunction setup() {\n let myArray = [1, 2, 3, 4, 5];\n print(myArray); // [1, 2, 3, 4, 5]\n\n let sub1 = subset(myArray, 0, 3);\n let sub2 = subset(myArray, 2, 2);\n print(sub1); // [1,2,3]\n print(sub2); // [3,4]\n}\n
Converts a string to its floating point representation. The contents of a\nstring must resemble a number, or NaN (not a number) will be returned.\nFor example, float(\"1234.56\") evaluates to 1234.56, but float(\"giraffe\")\nwill return NaN.
\nWhen an array of values is passed in, then an array of floats of the same\nlength is returned.
\n", + "example": [ + "\nlet str = '20';\nlet diameter = float(str);\nellipse(width / 2, height / 2, diameter, diameter);\ndescribe('20-by-20 white ellipse in the center of the canvas');\n
\nprint(float('10.31')); // 10.31\nprint(float('Infinity')); // Infinity\nprint(float('-Infinity')); // -Infinity\n
\nprint(int('10')); // 10\nprint(int(10.31)); // 10\nprint(int(-10)); // -10\nprint(int(true)); // 1\nprint(int(false)); // 0\nprint(int([false, true, '10.3', 9.8])); // [0, 1, 10, 9]\nprint(int(Infinity)); // Infinity\nprint(int('-Infinity')); // -Infinity\n
\nprint(str('10')); // \"10\"\nprint(str(10.31)); // \"10.31\"\nprint(str(-10)); // \"-10\"\nprint(str(true)); // \"true\"\nprint(str(false)); // \"false\"\nprint(str([true, '10.3', 9.8])); // [ \"true\", \"10.3\", \"9.8\" ]\n
\nprint(boolean(0)); // false\nprint(boolean(1)); // true\nprint(boolean('true')); // true\nprint(boolean('abcd')); // false\nprint(boolean([0, 12, 'true'])); // [false, true, true]\n
\nprint(byte(127)); // 127\nprint(byte(128)); // -128\nprint(byte(23.4)); // 23\nprint(byte('23.4')); // 23\nprint(byte('hello')); // NaN\nprint(byte(true)); // 1\nprint(byte([0, 255, '100'])); // [0, -1, 100]\n
\nprint(char(65)); // \"A\"\nprint(char('65')); // \"A\"\nprint(char([65, 66, 67])); // [ \"A\", \"B\", \"C\" ]\nprint(join(char([65, 66, 67]), '')); // \"ABC\"\n
\nprint(unchar('A')); // 65\nprint(unchar(['A', 'B', 'C'])); // [ 65, 66, 67 ]\nprint(unchar(split('ABC', ''))); // [ 65, 66, 67 ]\n
\nprint(hex(255)); // \"000000FF\"\nprint(hex(255, 6)); // \"0000FF\"\nprint(hex([0, 127, 255], 6)); // [ \"000000\", \"00007F\", \"0000FF\" ]\nprint(Infinity); // \"FFFFFFFF\"\nprint(-Infinity); // \"00000000\"\n
\nprint(unhex('A')); // 10\nprint(unhex('FF')); // 255\nprint(unhex(['FF', 'AA', '00'])); // [ 255, 170, 0 ]\n
\nlet array = ['Hello', 'world!'];\nlet separator = ' ';\nlet message = join(array, separator);\ntext(message, 5, 50);\ndescribe('“Hello world!” displayed middle left of canvas.');\n
\nThis function is used to apply a regular expression to a piece of text,\nand return matching groups (elements found inside parentheses) as a\nString array. If there are no matches, a null value will be returned.\nIf no groups are specified in the regular expression, but the sequence\nmatches, an array of length 1 (with the matched text as the first element\nof the array) will be returned.
\nTo use the function, first check to see if the result is null. If the\nresult is null, then the sequence did not match at all. If the sequence\ndid match, an array is returned.
\nIf there are groups (specified by sets of parentheses) in the regular\nexpression, then the contents of each will be returned in the array.\nElement [0] of a regular expression match returns the entire matching\nstring, and the match groups start at element [1] (the first group is [1],\nthe second [2], and so on).
\n", + "example": [ + "\nlet string = 'Hello p5js*!';\nlet regexp = 'p5js\\\\*';\nlet m = match(string, regexp);\ntext(m, 5, 50);\ndescribe('“p5js*” displayed middle left of canvas.');\n
\nThis function is used to apply a regular expression to a piece of text,\nand return a list of matching groups (elements found inside parentheses)\nas a two-dimensional String array. If there are no matches, a null value\nwill be returned. If no groups are specified in the regular expression,\nbut the sequence matches, a two dimensional array is still returned, but\nthe second dimension is only of length one.
\nTo use the function, first check to see if the result is null. If the\nresult is null, then the sequence did not match at all. If the sequence\ndid match, a 2D array is returned.
\nIf there are groups (specified by sets of parentheses) in the regular\nexpression, then the contents of each will be returned in the array.\nAssuming a loop with counter variable i, element [i][0] of a regular\nexpression match returns the entire matching string, and the match groups\nstart at element [i][1] (the first group is [i][1], the second [i][2],\nand so on).
\n", + "example": [ + "\nlet string = 'Hello p5js*! Hello world!';\nlet regexp = 'Hello';\nmatchAll(string, regexp);\n
\nUtility function for formatting numbers into strings. There are two\nversions: one for formatting floats, and one for formatting ints.
\nThe values for the digits, left, and right parameters should always\nbe positive integers.
\n(NOTE): Be cautious when using left and right parameters as it prepends numbers of 0's if the parameter\nif greater than the current length of the number.
\nFor example if number is 123.2 and left parameter passed is 4 which is greater than length of 123\n(integer part) i.e 3 than result will be 0123.2. Same case for right parameter i.e. if right is 3 than\nthe result will be 123.200.
\n", + "example": [ + "\nfunction setup() {\n background(200);\n let num1 = 321;\n let num2 = -1321;\n\n noStroke();\n fill(0);\n textSize(16);\n\n text(nf(num1, 4, 2), 10, 30);\n text(nf(num2, 4, 2), 10, 80);\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n\n describe('“0321.00” middle top, “-1321.00” middle bottom canvas');\n}\n
\n\nfunction setup() {\n background(200);\n let num = 11253106.115;\n let numArr = [1, 1, 2];\n\n noStroke();\n fill(0);\n textSize(12);\n\n // Draw formatted numbers\n text(nfc(num, 4), 10, 30);\n text(nfc(numArr, 2), 10, 80);\n\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n\n describe('“11,253,106.115” top middle and “1.00,1.00,2.00” displayed bottom mid');\n}\n
\n\nfunction setup() {\n background(200);\n let num1 = 11253106.115;\n let num2 = -11253106.115;\n\n noStroke();\n fill(0);\n textSize(12);\n\n // Draw formatted numbers\n text(nfp(num1, 4, 2), 10, 30);\n text(nfp(num2, 4, 2), 10, 80);\n\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n\n describe('“+11253106.11” top middle and “-11253106.11” displayed bottom middle');\n}\n
\nUtility function for formatting numbers into strings. Similar to nf() but\nputs an additional \"_\" (space) in front of positive numbers just in case to align it with negative\nnumbers which includes \"-\" (minus) sign.
\nThe main usecase of nfs() can be seen when one wants to align the digits (place values) of a non-negative\nnumber with some negative number (See the example to get a clear picture).\nThere are two versions: one for formatting float, and one for formatting int.
\nThe values for the digits, left, and right parameters should always be positive integers.
\n(IMP): The result on the canvas basically the expected alignment can vary based on the typeface you are using.
\n(NOTE): Be cautious when using left and right parameters as it prepends numbers of 0's if the parameter\nif greater than the current length of the number.
\nFor example if number is 123.2 and left parameter passed is 4 which is greater than length of 123\n(integer part) i.e 3 than result will be 0123.2. Same case for right parameter i.e. if right is 3 than\nthe result will be 123.200.
\n", + "example": [ + "\nfunction setup() {\n background(200);\n let num1 = 321;\n let num2 = -1321;\n\n noStroke();\n fill(0);\n textSize(16);\n\n // nfs() aligns num1 (positive number) with num2 (negative number) by\n // adding a blank space in front of the num1 (positive number)\n // [left = 4] in num1 add one 0 in front, to align the digits with num2\n // [right = 2] in num1 and num2 adds two 0's after both numbers\n // To see the differences check the example of nf() too.\n text(nfs(num1, 4, 2), 10, 30);\n text(nfs(num2, 4, 2), 10, 80);\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n\n describe('“0321.00” top middle and “-1321.00” displayed bottom middle');\n}\n
\nThe split() function maps to String.split(), it breaks a String into\npieces using a character or string as the delimiter. The delim parameter\nspecifies the character or characters that mark the boundaries between\neach piece. A String[] array is returned that contains each of the pieces.
\nThe splitTokens() function works in a similar fashion, except that it\nsplits using a range of characters instead of a specific character or\nsequence.
\n", + "example": [ + "\nlet names = 'Pat,Xio,Alex';\nlet splitString = split(names, ',');\ntext(splitString[0], 5, 30);\ntext(splitString[1], 5, 50);\ntext(splitString[2], 5, 70);\ndescribe('“Pat” top left, “Xio” mid left, and “Alex” displayed bottom left');\n
\nThe splitTokens() function splits a String at one or many character\ndelimiters or \"tokens.\" The delim parameter specifies the character or\ncharacters to be used as a boundary.
\nIf no delim characters are specified, any whitespace character is used to\nsplit. Whitespace characters include tab (\\t), line feed (\\n), carriage\nreturn (\\r), form feed (\\f), and space.
\n", + "example": [ + "\nfunction setup() {\n let myStr = 'Mango, Banana, Lime';\n let myStrArr = splitTokens(myStr, ',');\n\n print(myStrArr); // prints : [\"Mango\",\" Banana\",\" Lime\"]\n}\n
\n\nlet string = trim(' No new lines\\n ');\ntext(string + ' here', 2, 50);\ndescribe('“No new lines here” displayed center canvas');\n
\n\nlet d = day();\ntext('Current day: \\n' + d, 5, 50);\ndescribe('Current day is displayed');\n
\n\nlet h = hour();\ntext('Current hour:\\n' + h, 5, 50);\ndescribe('Current hour is displayed');\n
\n\nlet m = minute();\ntext('Current minute: \\n' + m, 5, 50);\ndescribe('Current minute is displayed');\n
\nsetup()
is called). This information is often\nused for timing events and animation sequences.",
+ "example": [
+ "\nlet millisecond = millis();\ntext('Milliseconds \\nrunning: \\n' + millisecond, 5, 40);\ndescribe('number of milliseconds since sketch has started displayed');\n
\n\nlet m = month();\ntext('Current month: \\n' + m, 5, 50);\ndescribe('Current month is displayed');\n
\n\nlet s = second();\ntext('Current second: \\n' + s, 5, 50);\ndescribe('Current second is displayed');\n
\n\nlet y = year();\ntext('Current year: \\n' + y, 5, 50);\ndescribe('Current year is displayed');\n
\nStarts creating a new p5.Geometry. Subsequent shapes drawn will be added\nto the geometry and then returned when\nendGeometry() is called. One can also use\nbuildGeometry() to pass a function that\ndraws shapes.
\nIf you need to draw complex shapes every frame which don't change over time,\ncombining them upfront with beginGeometry()
and endGeometry()
and then\ndrawing that will run faster than repeatedly drawing the individual pieces.
\nlet shapes;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n makeShapes();\n}\n\nfunction makeShapes() {\n beginGeometry();\n scale(0.18);\n\n push();\n translate(100, -50);\n scale(0.5);\n rotateX(PI/4);\n cone();\n pop();\n cone();\n\n beginShape();\n vertex(-20, -50);\n quadraticVertex(\n -40, -70,\n 0, -60\n );\n endShape();\n\n beginShape(TRIANGLE_STRIP);\n for (let y = 20; y <= 60; y += 10) {\n for (let x of [20, 60]) {\n vertex(x, y);\n }\n }\n endShape();\n\n beginShape();\n vertex(-100, -120);\n vertex(-120, -110);\n vertex(-105, -100);\n endShape();\n\n shapes = endGeometry();\n}\n\nfunction draw() {\n background(255);\n lights();\n orbitControl();\n model(shapes);\n}\n
\nCreates a new p5.Geometry that contains all\nthe shapes drawn in a provided callback function. The returned combined shape\ncan then be drawn all at once using model().
\nIf you need to draw complex shapes every frame which don't change over time,\ncombining them with buildGeometry()
once and then drawing that will run\nfaster than repeatedly drawing the individual pieces.
One can also draw shapes directly between\nbeginGeometry() and\nendGeometry() instead of using a callback\nfunction.
\n", + "example": [ + "\nlet particles;\nlet button;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n button = createButton('New');\n button.mousePressed(makeParticles);\n makeParticles();\n}\n\nfunction makeParticles() {\n if (particles) freeGeometry(particles);\n\n particles = buildGeometry(() => {\n for (let i = 0; i < 60; i++) {\n push();\n translate(\n randomGaussian(0, 20),\n randomGaussian(0, 20),\n randomGaussian(0, 20)\n );\n sphere(5);\n pop();\n }\n });\n}\n\nfunction draw() {\n background(255);\n noStroke();\n lights();\n orbitControl();\n model(particles);\n}\n
\nClears the resources of a model to free up browser memory. A model whose\nresources have been cleared can still be drawn, but the first time it is\ndrawn again, it might take longer.
\nThis method works on models generated with\nbuildGeometry() as well as those loaded\nfrom loadModel().
\n", + "example": [], + "overloads": [ + { + "params": [ + { + "name": "geometry", + "description": "The geometry whose resources should be freed", + "type": "p5.Geometry" + } + ] + } + ], + "class": "p5", + "static": false, + "module": "Shape", + "submodule": "3D Primitives" + }, + { + "name": "plane", + "file": "src/webgl/3d_primitives.js", + "line": 219, + "itemtype": "method", + "chainable": 1, + "description": "Draw a plane with given a width and height", + "example": [ + "\n// draw a plane\n// with width 50 and height 50\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('a white plane with black wireframe lines');\n}\n\nfunction draw() {\n background(200);\n plane(50, 50);\n}\n
\n\n// draw a spinning box\n// with width, height and depth of 50\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n describe('a white box rotating in 3D space');\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(50);\n}\n
\nDraw a sphere with given radius.
\nDetailX and detailY determines the number of subdivisions in the x-dimension\nand the y-dimension of a sphere. More subdivisions make the sphere seem\nsmoother. The recommended maximum values are both 24. Using a value greater\nthan 24 may cause a warning or slow down the browser.
\n", + "example": [ + "\n// draw a sphere with radius 40\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('a white sphere with black wireframe lines');\n}\n\nfunction draw() {\n background(205, 102, 94);\n sphere(40);\n}\n
\n\nlet detailX;\n// slide to see how detailX works\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(3, 24, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n describe(\n 'a white sphere with low detail on the x-axis, including a slider to adjust detailX'\n );\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n sphere(40, detailX.value(), 16);\n}\n
\n\nlet detailY;\n// slide to see how detailY works\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(3, 16, 3);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n describe(\n 'a white sphere with low detail on the y-axis, including a slider to adjust detailY'\n );\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n sphere(40, 16, detailY.value());\n}\n
\nDraw a cylinder with given radius and height
\nDetailX and detailY determines the number of subdivisions in the x-dimension\nand the y-dimension of a cylinder. More subdivisions make the cylinder seem smoother.\nThe recommended maximum value for detailX is 24. Using a value greater than 24\nmay cause a warning or slow down the browser.
\n", + "example": [ + "\n// draw a spinning cylinder\n// with radius 20 and height 50\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('a rotating white cylinder');\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n cylinder(20, 50);\n}\n
\n\n// slide to see how detailX works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(3, 24, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n describe(\n 'a rotating white cylinder with limited X detail, with a slider that adjusts detailX'\n );\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n cylinder(20, 75, detailX.value(), 1);\n}\n
\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(1, 16, 1);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n describe(\n 'a rotating white cylinder with limited Y detail, with a slider that adjusts detailY'\n );\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n cylinder(20, 75, 16, detailY.value());\n}\n
\nDraw a cone with given radius and height
\nDetailX and detailY determine the number of subdivisions in the x-dimension and\nthe y-dimension of a cone. More subdivisions make the cone seem smoother. The\nrecommended maximum value for detailX is 24. Using a value greater than 24\nmay cause a warning or slow down the browser.
\n", + "example": [ + "\n// draw a spinning cone\n// with radius 40 and height 70\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('a rotating white cone');\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n cone(40, 70);\n}\n
\n\n// slide to see how detailx works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(3, 16, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n describe(\n 'a rotating white cone with limited X detail, with a slider that adjusts detailX'\n );\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n cone(30, 65, detailX.value(), 16);\n}\n
\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(3, 16, 3);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n describe(\n 'a rotating white cone with limited Y detail, with a slider that adjusts detailY'\n );\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n cone(30, 65, 16, detailY.value());\n}\n
\nDraw an ellipsoid with given radius
\nDetailX and detailY determine the number of subdivisions in the x-dimension and\nthe y-dimension of a cone. More subdivisions make the ellipsoid appear to be smoother.\nAvoid detail number above 150, it may crash the browser.
\n", + "example": [ + "\n// draw an ellipsoid\n// with radius 30, 40 and 40.\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('a white 3d ellipsoid');\n}\n\nfunction draw() {\n background(205, 105, 94);\n ellipsoid(30, 40, 40);\n}\n
\n\n// slide to see how detailX works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(2, 24, 12);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n describe(\n 'a rotating white ellipsoid with limited X detail, with a slider that adjusts detailX'\n );\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n ellipsoid(30, 40, 40, detailX.value(), 8);\n}\n
\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(2, 24, 6);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n describe(\n 'a rotating white ellipsoid with limited Y detail, with a slider that adjusts detailY'\n );\n}\n\nfunction draw() {\n background(205, 105, 9);\n rotateY(millis() / 1000);\n ellipsoid(30, 40, 40, 12, detailY.value());\n}\n
\nDraw a torus with given radius and tube radius
\nDetailX and detailY determine the number of subdivisions in the x-dimension and\nthe y-dimension of a torus. More subdivisions make the torus appear to be smoother.\nThe default and maximum values for detailX and detailY are 24 and 16, respectively.\nSetting them to relatively small values like 4 and 6 allows you to create new\nshapes other than a torus.
\n", + "example": [ + "\n// draw a spinning torus\n// with ring radius 30 and tube radius 15\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n describe('a rotating white torus');\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n torus(30, 15);\n}\n
\n\n// slide to see how detailX works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n detailX = createSlider(3, 24, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n describe(\n 'a rotating white torus with limited X detail, with a slider that adjusts detailX'\n );\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n torus(30, 15, detailX.value(), 12);\n}\n
\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n detailY = createSlider(3, 16, 3);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n describe(\n 'a rotating white torus with limited Y detail, with a slider that adjusts detailY'\n );\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n torus(30, 15, 16, detailY.value());\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n describe(\n 'Camera orbits around a box when mouse is hold-clicked & then moved.'\n );\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n}\nfunction draw() {\n background(200);\n\n // If you execute the line commented out instead of next line, the direction of rotation\n // will be the direction the mouse or touch pointer moves, not around the X or Y axis.\n orbitControl();\n // orbitControl(1, 1, 1, {freeRotation: true});\n\n rotateY(0.5);\n box(30, 50);\n}\n
\ndebugMode() helps visualize 3D space by adding a grid to indicate where the\n‘ground’ is in a sketch and an axes icon which indicates the +X, +Y, and +Z\ndirections. This function can be called without parameters to create a\ndefault grid and axes icon, or it can be called according to the examples\nabove to customize the size and position of the grid and/or axes icon. The\ngrid is drawn using the most recently set stroke color and weight. To\nspecify these parameters, add a call to stroke() and strokeWeight()\njust before the end of the draw() loop.
\nBy default, the grid will run through the origin (0,0,0) of the sketch\nalong the XZ plane\nand the axes icon will be offset from the origin. Both the grid and axes\nicon will be sized according to the current canvas size. Note that because the\ngrid runs parallel to the default camera view, it is often helpful to use\ndebugMode along with orbitControl to allow full view of the grid.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n normalMaterial();\n debugMode();\n describe(\n 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z. the grid and icon disappear when the spacebar is pressed.'\n );\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n // Press the spacebar to turn debugMode off!\n if (keyIsDown(32)) {\n noDebugMode();\n }\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n normalMaterial();\n debugMode(GRID);\n describe('a 3D box is centered on a grid in a 3D sketch.');\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n normalMaterial();\n debugMode(AXES);\n describe(\n 'a 3D box is centered in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z.'\n );\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n normalMaterial();\n debugMode(GRID, 100, 10, 0, 0, 0);\n describe('a 3D box is centered on a grid in a 3D sketch');\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n normalMaterial();\n debugMode(100, 10, 0, 0, 0, 20, 0, -40, 0);\n describe(\n 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z.'\n );\n}\n\nfunction draw() {\n noStroke();\n background(200);\n orbitControl();\n box(15, 30);\n // set the stroke color and weight for the grid!\n stroke(255, 0, 150);\n strokeWeight(0.8);\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n normalMaterial();\n debugMode();\n describe(\n 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z. the grid and icon disappear when the spacebar is pressed.'\n );\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n // Press the spacebar to turn debugMode off!\n if (keyIsDown(32)) {\n noDebugMode();\n }\n}\n
\nCreates an ambient light with the given color.
\nAmbient light does not come from a specific direction.\nObjects are evenly lit from all sides. Ambient lights are\nalmost always used in combination with other types of lights.
\nNote: lights need to be called (whether directly or indirectly)\nwithin draw() to remain persistent in a looping program.\nPlacing them in setup() will cause them to only have an effect\nthe first time through the loop.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n describe('sphere with coral color under black light');\n}\nfunction draw() {\n background(100);\n ambientLight(0); // black light (no light)\n ambientMaterial(255, 127, 80); // coral material\n sphere(40);\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n describe('sphere with coral color under white light');\n}\nfunction draw() {\n background(100);\n ambientLight(255); // white light\n ambientMaterial(255, 127, 80); // coral material\n sphere(40);\n}\n
\n\nfunction setup() {\n createCanvas(100,100,WEBGL);\n camera(0,-100,300);\n}\nfunction draw() {\n background(230);\n ambientMaterial(237,34,93); //Pink Material\n ambientLight(mouseY);\n //As you move the mouse up to down it changes from no ambient light to full ambient light.\n rotateY(millis()/2000);\n box(100);\n}\n
\nSets the color of the specular highlight of a non-ambient light\n(i.e. all lights except ambientLight()).
\nspecularColor() affects only the lights which are created after\nit in the code.
\nThis function is used in combination with\nspecularMaterial().\nIf a geometry does not use specularMaterial(), this function\nwill have no effect.
\nThe default color is white (255, 255, 255), which is used if\nspecularColor() is not explicitly called.
\nNote: specularColor is equivalent to the Processing function\nlightSpecular.
\n", + "example": [ + "\nlet setRedSpecularColor = true;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n describe(\n 'Sphere with specular highlight. Clicking the mouse toggles the specular highlight color between red and the default white.'\n );\n}\n\nfunction draw() {\n background(0);\n\n ambientLight(60);\n\n // add a point light to showcase specular color\n // -- use mouse location to position the light\n let lightPosX = mouseX - width / 2;\n let lightPosY = mouseY - height / 2;\n // -- set the light's specular color\n if (setRedSpecularColor) {\n specularColor(255, 0, 0); // red specular highlight\n }\n // -- create the light\n pointLight(200, 200, 200, lightPosX, lightPosY, 50); // white light\n\n // use specular material with high shininess\n specularMaterial(150);\n shininess(50);\n\n sphere(30, 64, 64);\n}\n\nfunction mouseClicked() {\n setRedSpecularColor = !setRedSpecularColor;\n}\n
\nCreates a directional light with the given color and direction.
\nDirectional light comes from one direction.\nThe direction is specified as numbers inclusively between -1 and 1.\nFor example, setting the direction as (0, -1, 0) will cause the\ngeometry to be lit from below (since the light will be facing\ndirectly upwards). Similarly, setting the direction as (1, 0, 0)\nwill cause the geometry to be lit from the left (since the light\nwill be facing directly rightwards).
\nDirectional lights do not have a specific point of origin, and\ntherefore cannot be positioned closer or farther away from a geometry.
\nA maximum of 5 directional lights can be active at once.
\nNote: lights need to be called (whether directly or indirectly)\nwithin draw() to remain persistent in a looping program.\nPlacing them in setup() will cause them to only have an effect\nthe first time through the loop.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe(\n 'scene with sphere and directional light. The direction of the light is controlled with the mouse position.'\n );\n}\nfunction draw() {\n background(0);\n //move your mouse to change light direction\n let dirX = (mouseX / width - 0.5) * 2;\n let dirY = (mouseY / height - 0.5) * 2;\n directionalLight(250, 250, 250, -dirX, -dirY, -1);\n noStroke();\n sphere(40);\n}\n
\nCreates a point light with the given color and position.
\nA point light emits light from a single point in all directions.\nBecause the light is emitted from a specific point (position),\nit has a different effect when it is positioned farther vs. nearer\nan object.
\nA maximum of 5 point lights can be active at once.
\nNote: lights need to be called (whether directly or indirectly)\nwithin draw() to remain persistent in a looping program.\nPlacing them in setup() will cause them to only have an effect\nthe first time through the loop.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe(\n 'scene with sphere and point light. The position of the light is controlled with the mouse position.'\n );\n}\nfunction draw() {\n background(0);\n // move your mouse to change light position\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n // to set the light position,\n // think of the world's coordinate as:\n // -width/2,-height/2 ----------- width/2,-height/2\n // | |\n // | 0,0 |\n // | |\n // -width/2,height/2 ----------- width/2,height/2\n pointLight(250, 250, 250, locX, locY, 50);\n noStroke();\n sphere(40);\n}\n
\nCreates an image light with the given image.
\nThe image light simulates light from all the directions.\nThis is done by using the image as a texture for an infinitely\nlarge sphere light. This sphere contains\nor encapsulates the whole scene/drawing.\nIt will have different effect for varying shininess of the\nobject in the drawing.\nUnder the hood it is mainly doing 2 types of calculations,\nthe first one is creating an irradiance map the\nenvironment map of the input image.\nThe second one is managing reflections based on the shininess\nor roughness of the material used in the scene.
\nNote: The image's diffuse light will be affected by fill()\nand the specular reflections will be affected by specularMaterial()\nand shininess().
\n", + "example": [ + "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/outdoor_image.jpg');\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0 ,1, 0);\n perspective(PI/3, 1, 5, 500);\n}\nfunction draw() {\n background(220);\n\n push();\n camera(0, 0, 1, 0, 0, 0, 0, 1, 0);\n ortho(-1, 1, -1, 1, 0, 1);\n noLights();\n noStroke();\n texture(img);\n plane(2);\n pop();\n\n ambientLight(50);\n imageLight(img);\n specularMaterial(20);\n noStroke();\n rotateX(frameCount * 0.005);\n rotateY(frameCount * 0.005);\n box(50);\n}\n
\n\nlet img;\nlet slider;\n\nfunction preload() {\n img = loadImage('assets/outdoor_spheremap.jpg');\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n slider = createSlider(0, 400, 100, 1);\n slider.position(0, height);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0 ,1, 0);\n perspective(PI/3, 1, 5, 500);\n}\nfunction draw() {\n background(220);\n\n push();\n camera(0, 0, 1, 0, 0, 0, 0, 1, 0);\n ortho(-1, 1, -1, 1, 0, 1);\n noLights();\n noStroke();\n texture(img);\n plane(2);\n pop();\n\n ambientLight(50);\n imageLight(img);\n specularMaterial(20);\n shininess(slider.value());\n noStroke();\n sphere(30);\n}\n
\nPlaces an ambient and directional light in the scene.\nThe lights are set to ambientLight(128, 128, 128) and\ndirectionalLight(128, 128, 128, 0, 0, -1).
\nNote: lights need to be called (whether directly or indirectly)\nwithin draw() to remain persistent in a looping program.\nPlacing them in setup() will cause them to only have an effect\nthe first time through the loop.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n describe('the light is partially ambient and partially directional');\n}\nfunction draw() {\n background(0);\n lights();\n rotateX(millis() / 1000);\n rotateY(millis() / 1000);\n rotateZ(millis() / 1000);\n box();\n}\n
\nSets the falloff rate for pointLight()\nand spotLight().
\nlightFalloff() affects only the lights which are created after it\nin the code.
\nThe constant
, linear
, an quadratic
parameters are used to calculate falloff as follows:
d = distance from light position to vertex position
\nfalloff = 1 / (CONSTANT + d * LINEAR + (d * d) * QUADRATIC)
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n describe(\n 'Two spheres with different falloff values show different intensity of light'\n );\n}\nfunction draw() {\n ortho();\n background(0);\n\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n locX /= 2; // half scale\n\n lightFalloff(1, 0, 0);\n push();\n translate(-25, 0, 0);\n pointLight(250, 250, 250, locX - 25, locY, 50);\n sphere(20);\n pop();\n\n lightFalloff(0.97, 0.03, 0);\n push();\n translate(25, 0, 0);\n pointLight(250, 250, 250, locX + 25, locY, 50);\n sphere(20);\n pop();\n}\n
\nCreates a spot light with the given color, position,\nlight direction, angle, and concentration.
\nLike a pointLight(), a spotLight()\nemits light from a specific point (position). It has a different effect\nwhen it is positioned farther vs. nearer an object.
\nHowever, unlike a pointLight(), the light is emitted in one direction\nalong a conical shape. The shape of the cone can be controlled using\nthe angle
and concentration
parameters.
The angle
parameter is used to\ndetermine the radius of the cone. And the concentration
\nparameter is used to focus the light towards the center of\nthe cone. Both parameters are optional, however if you want\nto specify concentration
, you must also specify angle
.\nThe minimum concentration value is 1.
A maximum of 5 spot lights can be active at once.
\nNote: lights need to be called (whether directly or indirectly)\nwithin draw() to remain persistent in a looping program.\nPlacing them in setup() will cause them to only have an effect\nthe first time through the loop.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe(\n 'scene with sphere and spot light. The position of the light is controlled with the mouse position.'\n );\n}\nfunction draw() {\n background(0);\n // move your mouse to change light position\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n // to set the light position,\n // think of the world's coordinate as:\n // -width/2,-height/2 ----------- width/2,-height/2\n // | |\n // | 0,0 |\n // | |\n // -width/2,height/2 ----------- width/2,height/2\n ambientLight(50);\n spotLight(0, 250, 0, locX, locY, 100, 0, 0, -1, Math.PI / 16);\n noStroke();\n sphere(40);\n}\n
\nRemoves all lights present in a sketch.
\nAll subsequent geometry is rendered without lighting (until a new\nlight is created with a call to one of the lighting functions\n(lights(),\nambientLight(),\ndirectionalLight(),\npointLight(),\nspotLight()).
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe(\n 'Three white spheres. Each appears as a different color due to lighting.'\n );\n}\nfunction draw() {\n background(200);\n noStroke();\n\n ambientLight(255, 0, 0);\n translate(-30, 0, 0);\n ambientMaterial(255);\n sphere(13);\n\n noLights();\n translate(30, 0, 0);\n ambientMaterial(255);\n sphere(13);\n\n ambientLight(0, 255, 0);\n translate(30, 0, 0);\n ambientMaterial(255);\n sphere(13);\n}\n
\nLoad a 3d model from an OBJ or STL file.
\nloadModel() should be placed inside of preload().\nThis allows the model to load fully before the rest of your code is run.
\nOne of the limitations of the OBJ and STL format is that it doesn't have a built-in\nsense of scale. This means that models exported from different programs might\nbe very different sizes. If your model isn't displaying, try calling\nloadModel() with the normalized parameter set to true. This will resize the\nmodel to a scale appropriate for p5. You can also make additional changes to\nthe final size of your model with the scale() function.
\nAlso, the support for colored STL files is not present. STL files with color will be\nrendered without color properties.
\nOptions can include:
\npath
: Specifies the location or path of the 3D model file for loading.normalize
: Enables standardized size scaling during loading if set to true.successCallback
: Callback for post-loading actions with the 3D model object.failureCallback
: Handles errors if model loading fails, receiving an event error.fileType
: Defines the file extension of the model.flipU
: Flips the U texture coordinates of the model.flipV
: Flips the V texture coordinates of the model.\n//draw a spinning octahedron\nlet octahedron;\n\nfunction preload() {\n octahedron = loadModel('assets/octahedron.obj');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('Vertically rotating 3-d octahedron.');\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n model(octahedron);\n}\n
\n\n//draw a spinning teapot\nlet teapot;\n\nfunction preload() {\n // Load model with normalise parameter set to true\n teapot = loadModel('assets/teapot.obj', true);\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('Vertically rotating 3-d teapot with red, green and blue gradient.');\n}\n\nfunction draw() {\n background(200);\n scale(0.4); // Scaled to make model fit into canvas\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n normalMaterial(); // For effect\n model(teapot);\n}\n
\n.stl
, .obj
).",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "the p5.Geometry object",
+ "type": "p5.Geometry"
+ }
+ },
+ {
+ "params": [
+ {
+ "name": "path",
+ "type": "String"
+ },
+ {
+ "name": "successCallback",
+ "optional": 1
+ },
+ {
+ "name": "failureCallback",
+ "optional": 1
+ },
+ {
+ "name": "fileType",
+ "optional": 1,
+ "type": "String"
+ }
+ ],
+ "return": {
+ "description": "the p5.Geometry object",
+ "type": "p5.Geometry"
+ }
+ },
+ {
+ "params": [
+ {
+ "name": "path",
+ "type": "String"
+ },
+ {
+ "name": "options",
+ "optional": 1,
+ "type": "Object"
+ },
+ {
+ "name": "options.successCallback",
+ "description": "",
+ "optional": 1
+ },
+ {
+ "name": "options.failureCallback",
+ "description": "",
+ "optional": 1
+ },
+ {
+ "name": "options.fileType",
+ "description": "",
+ "optional": 1,
+ "type": "String"
+ },
+ {
+ "name": "options.normalize",
+ "description": "",
+ "optional": 1,
+ "type": "boolean"
+ },
+ {
+ "name": "options.flipU",
+ "description": "",
+ "optional": 1,
+ "type": "boolean"
+ },
+ {
+ "name": "options.flipV",
+ "description": "",
+ "optional": 1,
+ "type": "boolean"
+ }
+ ],
+ "return": {
+ "description": "the p5.Geometry object",
+ "type": "p5.Geometry"
+ }
+ }
+ ],
+ "return": {
+ "description": "the p5.Geometry object",
+ "type": "p5.Geometry"
+ },
+ "class": "p5",
+ "static": false,
+ "module": "Shape",
+ "submodule": "3D Models"
+ },
+ {
+ "name": "parseObj",
+ "file": "src/webgl/loading.js",
+ "line": 238,
+ "itemtype": "method",
+ "description": "Parse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:
\nv -0.5 -0.5 0.5\nv -0.5 -0.5 -0.5\nv -0.5 0.5 -0.5\nv -0.5 0.5 0.5
\nf 4 3 2 1
\n", + "example": [], + "overloads": [ + { + "params": [] + } + ], + "class": "p5", + "static": false, + "module": "Shape", + "submodule": "3D Models" + }, + { + "name": "parseSTL", + "file": "src/webgl/loading.js", + "line": 344, + "itemtype": "method", + "description": "STL files can be of two types, ASCII and Binary,
\nWe need to convert the arrayBuffer to an array of strings,\nto parse it as an ASCII file.
\n", + "example": [], + "overloads": [ + { + "params": [] + } + ], + "class": "p5", + "static": false, + "module": "Shape", + "submodule": "3D Models" + }, + { + "name": "isBinary", + "file": "src/webgl/loading.js", + "line": 378, + "itemtype": "method", + "description": "This function checks if the file is in ASCII format or in Binary format
\nIt is done by searching keyword solid
at the start of the file.
An ASCII STL data must begin with solid
as the first six bytes.\nHowever, ASCII STLs lacking the SPACE after the d
are known to be\nplentiful. So, check the first 5 bytes for solid
.
Several encodings, such as UTF-8, precede the text with up to 5 bytes:\nhttps://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding\nSearch for solid
to start anywhere after those prefixes.
query
at the provided offset
",
+ "example": [],
+ "overloads": [
+ {
+ "params": []
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "Shape",
+ "submodule": "3D Models"
+ },
+ {
+ "name": "parseBinarySTL",
+ "file": "src/webgl/loading.js",
+ "line": 410,
+ "itemtype": "method",
+ "description": "This function parses the Binary STL files.\nhttps://en.wikipedia.org/wiki/STL_%28file_format%29#Binary_STL
\nCurrently there is no support for the colors provided in STL files.
\n", + "example": [], + "overloads": [ + { + "params": [] + } + ], + "class": "p5", + "static": false, + "module": "Shape", + "submodule": "3D Models" + }, + { + "name": "parseASCIISTL", + "file": "src/webgl/loading.js", + "line": 502, + "itemtype": "method", + "description": "ASCII STL file starts withsolid 'nameOfFile'
\nThen contain the normal of the face, starting with facet normal
\nNext contain a keyword indicating the start of face vertex, outer loop
\nNext comes the three vertex, starting with vertex x y z
\nVertices ends with endloop
\nFace ends with endfacet
\nNext face starts with facet normal
\nThe end of the file is indicated by endsolid
",
+ "example": [],
+ "overloads": [
+ {
+ "params": []
+ }
+ ],
+ "class": "p5",
+ "static": false,
+ "module": "Shape",
+ "submodule": "3D Models"
+ },
+ {
+ "name": "model",
+ "file": "src/webgl/loading.js",
+ "line": 668,
+ "itemtype": "method",
+ "description": "Render a 3d model to the screen.",
+ "example": [
+ "\n//draw a spinning octahedron\nlet octahedron;\n\nfunction preload() {\n octahedron = loadModel('assets/octahedron.obj');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('Vertically rotating 3-d octahedron.');\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n model(octahedron);\n}\n
\nCreates a new p5.Shader object\nfrom the provided vertex and fragment shader files.
\nThe shader files are loaded asynchronously in the\nbackground, so this method should be used in preload().
\nShaders can alter the positioning of shapes drawn with them.\nTo ensure consistency in rendering, it's recommended to use the vertex shader in the createShader example.
\nNote, shaders can only be used in WEBGL mode.
\n", + "example": [ + "\nlet mandel;\nfunction preload() {\n // load the shader definitions from files\n mandel = loadShader('assets/shader.vert', 'assets/shader.frag');\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n // use the shader\n shader(mandel);\n noStroke();\n mandel.setUniform('p', [-0.74364388703, 0.13182590421]);\n describe('zooming Mandelbrot set. a colorful, infinitely detailed fractal.');\n}\n\nfunction draw() {\n mandel.setUniform('r', 1.5 * exp(-6.5 * (1 + sin(millis() / 2000))));\n quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n
\nCreates a new p5.Shader object\nfrom the provided vertex and fragment shader code.
\nNote, shaders can only be used in WEBGL mode.
\nShaders can alter the positioning of shapes drawn with them.\nTo ensure consistency in rendering, it's recommended to use the vertex shader shown in the example below.
\n", + "example": [ + "\n\n// the vertex shader is called for each vertex\nlet vs = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n vTexCoord = aTexCoord;\n vec4 positionVec4 = vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n }\n`;\n\n\n// the fragment shader is called for each pixel\nlet fs = `\n precision highp float;\n uniform vec2 p;\n uniform float r;\n const int I = 500;\n varying vec2 vTexCoord;\n void main() {\n vec2 c = p + gl_FragCoord.xy * r, z = c;\n float n = 0.0;\n for (int i = I; i > 0; i --) {\n if(z.x*z.x+z.y*z.y > 4.0) {\n n = float(i)/float(I);\n break;\n }\n z = vec2(z.x*z.x-z.y*z.y, 2.0*z.x*z.y) + c;\n }\n gl_FragColor = vec4(0.5-cos(n*17.0)/2.0,0.5-cos(n*13.0)/2.0,0.5-cos(n*23.0)/2.0,1.0);\n }`;\n\nlet mandel;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n // create and initialize the shader\n mandel = createShader(vs, fs);\n shader(mandel);\n noStroke();\n\n // 'p' is the center point of the Mandelbrot image\n mandel.setUniform('p', [-0.74364388703, 0.13182590421]);\n describe('zooming Mandelbrot set. a colorful, infinitely detailed fractal.');\n}\n\nfunction draw() {\n // 'r' is the size of the image in Mandelbrot-space\n mandel.setUniform('r', 1.5 * exp(-6.5 * (1 + sin(millis() / 2000))));\n plane(width, height);\n}\n
\nCreates a new p5.Shader using only a fragment shader, as a convenience method for creating image effects.\nIt's like createShader() but with a default vertex shader included.
\ncreateFilterShader() is intended to be used along with filter() for filtering the contents of a canvas.\nA filter shader will not be applied to any geometries.
\nThe fragment shader receives some uniforms:
\nsampler2D tex0
, which contains the canvas contents as a texturevec2 canvasSize
, which is the p5 width and height of the canvas (not including pixel density)vec2 texelSize
, which is the size of a physical pixel including pixel density (1.0/(width*density)
, 1.0/(height*density)
)For more info about filters and shaders, see Adam Ferriss' repo of shader examples\nor the introduction to shaders page.
\n", + "example": [ + "\nfunction setup() {\n let fragSrc = `precision highp float;\n void main() {\n gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);\n }`;\n\n createCanvas(100, 100, WEBGL);\n let s = createFilterShader(fragSrc);\n filter(s);\n describe('a yellow canvas');\n}\n
\n\nlet img, s;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n let fragSrc = `precision highp float;\n\n // x,y coordinates, given from the vertex shader\n varying vec2 vTexCoord;\n\n // the canvas contents, given from filter()\n uniform sampler2D tex0;\n // other useful information from the canvas\n uniform vec2 texelSize;\n uniform vec2 canvasSize;\n // a custom variable from this sketch\n uniform float darkness;\n\n void main() {\n // get the color at current pixel\n vec4 color = texture2D(tex0, vTexCoord);\n // set the output color\n color.b = 1.0;\n color *= darkness;\n gl_FragColor = vec4(color.rgb, 1.0);\n }`;\n\n createCanvas(100, 100, WEBGL);\n s = createFilterShader(fragSrc);\n}\nfunction draw() {\n image(img, -50, -50);\n s.setUniform('darkness', 0.5);\n filter(s);\n describe('a image of bricks tinted dark blue');\n}\n
\nSets the p5.Shader object to\nbe used to render subsequent shapes.
\nShaders can alter the positioning of shapes drawn with them.\nTo ensure consistency in rendering, it's recommended to use the vertex shader in the createShader example.
\nCustom shaders can be created using the\ncreateShader() and\nloadShader() functions.
\nUse resetShader() to\nrestore the default shaders.
\nAdditional Information:\nThe shader will be used for:
\nsampler2D
.aNormal
, or if it has any of the following uniforms: uUseLighting
, uAmbientLightCount
, uDirectionalLightCount
, uPointLightCount
, uAmbientColor
, uDirectionalDiffuseColors
, uDirectionalSpecularColors
, uPointLightLocation
, uPointLightDiffuseColors
, uPointLightSpecularColors
, uLightingDirection
, or uSpecular
.uStrokeWeight
.\nNote: This behavior is considered experimental, and changes are planned in future releases.Note, shaders can only be used in WEBGL mode.
\n", + "example": [ + "\n// Click within the image to toggle\n// the shader used by the quad shape\n// Note: for an alternative approach to the same example,\n// involving changing uniforms please refer to:\n// https://p5js.org/reference/#/p5.Shader/setUniform\n\nlet redGreen;\nlet orangeBlue;\nlet showRedGreen = false;\n\nfunction preload() {\n // note that we are using two instances\n // of the same vertex and fragment shaders\n redGreen = loadShader('assets/shader.vert', 'assets/shader-gradient.frag');\n orangeBlue = loadShader('assets/shader.vert', 'assets/shader-gradient.frag');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n // initialize the colors for redGreen shader\n shader(redGreen);\n redGreen.setUniform('colorCenter', [1.0, 0.0, 0.0]);\n redGreen.setUniform('colorBackground', [0.0, 1.0, 0.0]);\n\n // initialize the colors for orangeBlue shader\n shader(orangeBlue);\n orangeBlue.setUniform('colorCenter', [1.0, 0.5, 0.0]);\n orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]);\n\n noStroke();\n\n describe(\n 'canvas toggles between a circular gradient of orange and blue vertically. and a circular gradient of red and green moving horizontally when mouse is clicked/pressed.'\n );\n}\n\nfunction draw() {\n // update the offset values for each shader,\n // moving orangeBlue in vertical and redGreen\n // in horizontal direction\n orangeBlue.setUniform('offset', [0, sin(millis() / 2000) + 1]);\n redGreen.setUniform('offset', [sin(millis() / 2000), 1]);\n\n if (showRedGreen === true) {\n shader(redGreen);\n } else {\n shader(orangeBlue);\n }\n quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n\nfunction mouseClicked() {\n showRedGreen = !showRedGreen;\n}\n
\n\n// This variable will hold our shader object\nlet shaderProgram;\n\n// This variable will hold our vertex shader source code\nlet vertSrc = `\n attribute vec3 aPosition;\n attribute vec2 aTexCoord;\n uniform mat4 uProjectionMatrix;\n uniform mat4 uModelViewMatrix;\n varying vec2 vTexCoord;\n\n void main() {\n vTexCoord = aTexCoord;\n vec4 position = vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * uModelViewMatrix * position;\n }\n`;\n\n// This variable will hold our fragment shader source code\nlet fragSrc = `\n precision mediump float;\n\n varying vec2 vTexCoord;\n\n void main() {\n vec2 uv = vTexCoord;\n vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0));\n gl_FragColor = vec4(color, 1.0);\n }\n`;\n\nfunction setup() {\n // Shaders require WEBGL mode to work\n createCanvas(100, 100, WEBGL);\n\n // Create our shader\n shaderProgram = createShader(vertSrc, fragSrc);\n\n describe(\n 'Two rotating cubes. The left one is painted using a custom (user-defined) shader, while the right one is painted using the default fill shader.'\n );\n}\n\nfunction draw() {\n // Clear the scene\n background(200);\n\n // Draw a box using our shader\n // shader() sets the active shader with our shader\n shader(shaderProgram);\n push();\n translate(-width / 4, 0, 0);\n rotateX(millis() * 0.00025);\n rotateY(millis() * 0.0005);\n box(width / 4);\n pop();\n\n // Draw a box using the default fill shader\n // resetShader() restores the default fill shader\n resetShader();\n fill(255, 0, 0);\n push();\n translate(width / 4, 0, 0);\n rotateX(millis() * 0.00025);\n rotateY(millis() * 0.0005);\n box(width / 4);\n pop();\n}\n
\nSets the texture that will be used to render subsequent shapes.
\nA texture is like a \"skin\" that wraps around a 3D geometry. Currently\nsupported textures are images, video, and offscreen renders.
\nTo texture a geometry created with beginShape(),\nyou will need to specify uv coordinates in vertex().
\nNote, texture() can only be used in WEBGL mode.
\nYou can view more materials in this\nexample.
\n", + "example": [ + "\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('spinning cube with a texture from an image');\n}\n\nfunction draw() {\n background(0);\n rotateZ(frameCount * 0.01);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n //pass image as texture\n texture(img);\n box(width / 2);\n}\n
\n\nlet pg;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n pg = createGraphics(200, 200);\n pg.textSize(75);\n describe('plane with a texture from an image created by createGraphics()');\n}\n\nfunction draw() {\n background(0);\n pg.background(255);\n pg.text('hello!', 0, 100);\n //pass image as texture\n texture(pg);\n rotateX(0.5);\n noStroke();\n plane(50);\n}\n
\n\nlet vid;\nfunction preload() {\n vid = createVideo('assets/fingers.mov');\n vid.hide();\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('rectangle with video as texture');\n}\n\nfunction draw() {\n background(0);\n //pass video frame as texture\n texture(vid);\n rect(-40, -40, 80, 80);\n}\n\nfunction mousePressed() {\n vid.loop();\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('quad with a texture, mapped using normalized coordinates');\n}\n\nfunction draw() {\n background(0);\n texture(img);\n textureMode(NORMAL);\n beginShape();\n vertex(-40, -40, 0, 0);\n vertex(40, -40, 1, 0);\n vertex(40, 40, 1, 1);\n vertex(-40, 40, 0, 1);\n endShape();\n}\n
\nSets the coordinate space for texture mapping. The default mode is IMAGE\nwhich refers to the actual coordinates of the image.\nNORMAL refers to a normalized space of values ranging from 0 to 1.
\nWith IMAGE, if an image is 100×200 pixels, mapping the image onto the entire\nsize of a quad would require the points (0,0) (100, 0) (100,200) (0,200).\nThe same mapping in NORMAL is (0,0) (1,0) (1,1) (0,1).
\n", + "example": [ + "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('quad with a texture, mapped using normalized coordinates');\n}\n\nfunction draw() {\n texture(img);\n textureMode(NORMAL);\n beginShape();\n vertex(-50, -50, 0, 0);\n vertex(50, -50, 1, 0);\n vertex(50, 50, 1, 1);\n vertex(-50, 50, 0, 1);\n endShape();\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('quad with a texture, mapped using image coordinates');\n}\n\nfunction draw() {\n texture(img);\n textureMode(IMAGE);\n beginShape();\n vertex(-50, -50, 0, 0);\n vertex(50, -50, img.width, 0);\n vertex(50, 50, img.width, img.height);\n vertex(-50, 50, 0, img.height);\n endShape();\n}\n
\nSets the global texture wrapping mode. This controls how textures behave\nwhen their uv's go outside of the 0 to 1 range. There are three options:\nCLAMP, REPEAT, and MIRROR.
\nCLAMP causes the pixels at the edge of the texture to extend to the bounds.\nREPEAT causes the texture to tile repeatedly until reaching the bounds.\nMIRROR works similarly to REPEAT but it flips the texture with every new tile.
\nREPEAT & MIRROR are only available if the texture\nis a power of two size (128, 256, 512, 1024, etc.).
\nThis method will affect all textures in your sketch until a subsequent\ntextureWrap() call is made.
\nIf only one argument is provided, it will be applied to both the\nhorizontal and vertical axes.
\n", + "example": [ + "\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies128.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textureWrap(MIRROR);\n describe('an image of the rocky mountains repeated in mirrored tiles');\n}\n\nfunction draw() {\n background(0);\n\n let dX = mouseX;\n let dY = mouseY;\n\n let u = lerp(1.0, 2.0, dX);\n let v = lerp(1.0, 2.0, dY);\n\n scale(width / 2);\n\n texture(img);\n\n beginShape(TRIANGLES);\n vertex(-1, -1, 0, 0, 0);\n vertex(1, -1, 0, u, 0);\n vertex(1, 1, 0, u, v);\n\n vertex(1, 1, 0, u, v);\n vertex(-1, 1, 0, 0, v);\n vertex(-1, -1, 0, 0, 0);\n endShape();\n}\n
\nSets the current material as a normal material.
\nA normal material is not affected by light. It is often used as\na placeholder material when debugging.
\nSurfaces facing the X-axis become red, those facing the Y-axis\nbecome green, and those facing the Z-axis become blue.
\nYou can view more materials in this\nexample.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('Sphere with normal material');\n}\n\nfunction draw() {\n background(200);\n normalMaterial();\n sphere(40);\n}\n
\nSets the ambient color of the material.
\nThe ambientMaterial() color represents the components\nof the ambientLight() color that the object reflects.
\nConsider an ambientMaterial() with the color yellow (255, 255, 0).\nIf the ambientLight() emits the color white (255, 255, 255), then the object\nwill appear yellow as it will reflect the red and green components\nof the light. If the ambientLight() emits the color red (255, 0, 0), then\nthe object will appear red as it will reflect the red component\nof the light. If the ambientLight() emits the color blue (0, 0, 255),\nthen the object will appear black, as there is no component of\nthe light that it can reflect.
\nYou can view more materials in this\nexample.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('sphere reflecting red, blue, and green light');\n}\nfunction draw() {\n background(0);\n noStroke();\n ambientLight(255);\n ambientMaterial(70, 130, 230);\n sphere(40);\n}\n
\n\n// ambientLight is both red and blue (magenta),\n// so object only reflects it's red and blue components\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('box reflecting only red and blue light');\n}\nfunction draw() {\n background(70);\n ambientLight(255, 0, 255); // magenta light\n ambientMaterial(255); // white material\n box(30);\n}\n
\n\n// ambientLight is green. Since object does not contain\n// green, it does not reflect any light\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('box reflecting no light');\n}\nfunction draw() {\n background(70);\n ambientLight(0, 255, 0); // green light\n ambientMaterial(255, 0, 255); // magenta material\n box(30);\n}\n
\nSets the emissive color of the material.
\nAn emissive material will display the emissive color at\nfull strength regardless of lighting. This can give the\nappearance that the object is glowing.
\nNote, \"emissive\" is a misnomer in the sense that the material\ndoes not actually emit light that will affect surrounding objects.
\nYou can view more materials in this\nexample.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('sphere with green emissive material');\n}\nfunction draw() {\n background(0);\n noStroke();\n ambientLight(0);\n emissiveMaterial(130, 230, 0);\n sphere(40);\n}\n
\nSets the specular color of the material.
\nA specular material is reflective (shiny). The shininess can be\ncontrolled by the shininess() function.
\nLike ambientMaterial(),\nthe specularMaterial() color is the color the object will reflect\nunder ambientLight().\nHowever unlike ambientMaterial(), for all other types of lights\n(directionalLight(),\npointLight(),\nspotLight()),\na specular material will reflect the color of the light source.\nThis is what gives it its \"shiny\" appearance.
\nYou can view more materials in this\nexample.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n describe('torus with specular material');\n}\n\nfunction draw() {\n background(0);\n\n ambientLight(60);\n\n // add point light to showcase specular material\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n pointLight(255, 255, 255, locX, locY, 50);\n\n specularMaterial(250);\n shininess(50);\n torus(30, 10, 64, 64);\n}\n
\nSets the amount of gloss (\"shininess\") of a\nspecularMaterial().
\nThe default and minimum value is 1.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n describe('two spheres, one more shiny than the other');\n}\nfunction draw() {\n background(0);\n noStroke();\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n ambientLight(60, 60, 60);\n pointLight(255, 255, 255, locX, locY, 50);\n specularMaterial(250);\n translate(-25, 0, 0);\n shininess(1);\n sphere(20);\n translate(50, 0, 0);\n shininess(20);\n sphere(20);\n}\n
\nSets the metalness property of a material used in 3D rendering.
\nThe metalness property controls the degree to which the material\nappears metallic. A higher metalness value makes the material look\nmore metallic, while a lower value makes it appear less metallic.
\nThe default and minimum value is 0, indicating a non-metallic appearance.
\nUnlike other materials, metals exclusively rely on reflections, particularly\nthose produced by specular lights (mirrorLike lights). They don't incorporate\ndiffuse or ambient lighting. Metals use a fill color to influence the overall\ncolor of their reflections. Pick a fill color, and you can easily change the\nappearance of the metal surfaces. When no fill color is provided, it defaults\nto using white.
\n", + "example": [ + "\nlet img;\nlet slider;\nlet slider2;\nfunction preload() {\n img = loadImage('assets/outdoor_spheremap.jpg');\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n slider = createSlider(0, 300, 100, 1);\n let sliderLabel = createP('Metalness');\n sliderLabel.position(100, height - 25);\n slider2 = createSlider(0, 350, 100);\n slider2.position(0, height + 20);\n slider2Label = createP('Shininess');\n slider2Label.position(100, height);\n}\nfunction draw() {\n background(220);\n imageMode(CENTER);\n push();\n image(img, 0, 0, width, height);\n clearDepth();\n pop();\n imageLight(img);\n fill('gray');\n specularMaterial('gray');\n shininess(slider2.value());\n metalness(slider.value());\n noStroke();\n sphere(30);\n}\n
\n\nlet slider;\nlet slider2;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n slider = createSlider(0, 200, 100);\n let sliderLabel = createP('Metalness');\n sliderLabel.position(100, height - 25);\n slider2 = createSlider(0, 200, 2);\n slider2.position(0, height + 25);\n let slider2Label = createP('Shininess');\n slider2Label.position(100, height);\n}\nfunction draw() {\n noStroke();\n background(100);\n fill(255, 215, 0);\n pointLight(255, 255, 255, 5000, 5000, 75);\n specularMaterial('gray');\n ambientLight(100);\n shininess(slider2.value());\n metalness(slider.value());\n rotateY(frameCount * 0.01);\n torus(20, 10);\n}\n
\nSets the position of the current camera in a 3D sketch.\nParameters for this function define the camera's position,\nthe center of the sketch (where the camera is pointing),\nand an up direction (the orientation of the camera).
\nThis function simulates the movements of the camera, allowing objects to be\nviewed from various angles. Remember, it does not move the objects themselves\nbut the camera instead. For example when the centerX value is positive,\nand the camera is rotating to the right side of the sketch,\nthe object will seem like it's moving to the left.
\nSee this example\nto view the position of your camera.
\nIf no parameters are given, the following default is used:\ncamera(0, 0, 800, 0, 0, 0, 0, 1, 0)
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n describe('a square moving closer and then away from the camera.');\n}\nfunction draw() {\n background(204);\n //move the camera away from the plane by a sin wave\n camera(0, 0, 20 + sin(frameCount * 0.01) * 10, 0, 0, 0, 0, 1, 0);\n plane(10, 10);\n}\n
\n\n//move slider to see changes!\n//sliders control the first 6 parameters of camera()\nlet sliderGroup = [];\nlet X;\nlet Y;\nlet Z;\nlet centerX;\nlet centerY;\nlet centerZ;\nlet h = 20;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n //create sliders\n for (var i = 0; i < 6; i++) {\n if (i === 2) {\n sliderGroup[i] = createSlider(10, 400, 200);\n } else {\n sliderGroup[i] = createSlider(-400, 400, 0);\n }\n h = map(i, 0, 6, 5, 85);\n sliderGroup[i].position(10, height + h);\n sliderGroup[i].style('width', '80px');\n }\n describe(\n 'White square repeatedly grows to fill canvas and then shrinks. An interactive example of a red cube with 3 sliders for moving it across x, y, z axis and 3 sliders for shifting its center.'\n );\n}\n\nfunction draw() {\n background(60);\n // assigning sliders' value to each parameters\n X = sliderGroup[0].value();\n Y = sliderGroup[1].value();\n Z = sliderGroup[2].value();\n centerX = sliderGroup[3].value();\n centerY = sliderGroup[4].value();\n centerZ = sliderGroup[5].value();\n camera(X, Y, Z, centerX, centerY, centerZ, 0, 1, 0);\n stroke(255);\n fill(255, 102, 94);\n box(85);\n}\n
\nSets a perspective projection for the current camera in a 3D sketch.\nThis projection represents depth through foreshortening: objects\nthat are close to the camera appear their actual size while those\nthat are further away from the camera appear smaller.
\nThe parameters to this function define the viewing frustum\n(the truncated pyramid within which objects are seen by the camera) through\nvertical field of view, aspect ratio (usually width/height), and near and far\nclipping planes.
\nIf no parameters are given, the default values are used as:
\nfov
: The default field of view for the camera is such that the full height of renderer is visible when it is positioned at a default distance of 800 units from the camera.aspect
: The default aspect ratio is the ratio of renderer's width to renderer's height.near
: The default value for the near clipping plane is 80, which is 0.1 times the default distance from the camera to its subject.far
: The default value for the far clipping plane is 8000, which is 10 times the default distance from the camera to its subject.If you prefer a fixed field of view, follow these steps:
\nfovy
). This is how wide the camera can see.(height / 2) / tan(fovy / 2)
back from its subject.perspective(fovy, width / height, cameraDistance / 10, cameraDistance * 10);
\n//drag the mouse to look around!\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n perspective(PI / 3.0, width / height, 0.1, 500);\n describe(\n 'two colored 3D boxes move back and forth, rotating as mouse is dragged.'\n );\n}\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateX(-0.3);\n rotateY(-0.2);\n translate(0, 0, -50);\n\n push();\n translate(-15, 0, sin(frameCount / 30) * 65);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 65);\n box(30);\n pop();\n}\n
\nSets an orthographic projection for the current camera in a 3D sketch\nand defines a box-shaped viewing frustum within which objects are seen.\nIn this projection, all objects with the same dimension appear the same\nsize, regardless of whether they are near or far from the camera.
\nThe parameters to this function specify the viewing frustum where\nleft and right are the minimum and maximum x values, top and bottom are\nthe minimum and maximum y values, and near and far are the minimum and\nmaximum z values.
\nIf no parameters are given, the following default is used:\northo(-width/2, width/2, -height/2, height/2, 0, max(width, height)).
\n", + "example": [ + "\n//drag the mouse to look around!\n//there's no vanishing point\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n ortho(-width / 2, width / 2, height / 2, -height / 2, 0, 500);\n describe(\n 'two 3D boxes move back and forth along same plane, rotating as mouse is dragged.'\n );\n}\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateX(0.2);\n rotateY(-0.2);\n push();\n translate(-15, 0, sin(frameCount / 30) * 65);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 65);\n box(30);\n pop();\n}\n
\nSets the frustum of the current camera as defined by\nthe parameters.
\nA frustum is a geometric form: a pyramid with its top\ncut off. With the viewer's eye at the imaginary top of\nthe pyramid, the six planes of the frustum act as clipping\nplanes when rendering a 3D view. Thus, any form inside the\nclipping planes is visible; anything outside\nthose planes is not visible.
\nSetting the frustum changes the perspective of the scene being rendered.\nThis can be achieved more simply in many cases by using\nperspective().
\nIf no parameters are given, the following default is used:\nfrustum(-width/20, width/20, height/20, -height/20, eyeZ/10, eyeZ*10),\nwhere eyeZ is equal to 800.
\n", + "example": [ + "\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n frustum(-0.1, 0.1, -0.1, 0.1, 0.1, 200);\n describe(\n 'two 3D boxes move back and forth along same plane, rotating as mouse is dragged.'\n );\n}\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateY(-0.2);\n rotateX(-0.3);\n push();\n translate(-15, 0, sin(frameCount / 30) * 25);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 25);\n box(30);\n pop();\n}\n
\nCreates a new p5.Camera object and sets it\nas the current (active) camera.
\nThe new camera is initialized with a default position\n(see camera())\nand a default perspective projection\n(see perspective()).\nIts properties can be controlled with the p5.Camera\nmethods.
\nNote: Every 3D sketch starts with a default camera initialized.\nThis camera can be controlled with the global methods\ncamera(),\nperspective(), ortho(),\nand frustum() if it is the only camera\nin the scene.
\n", + "example": [ + "\n// Creates a camera object and animates it around a box.\nlet camera;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n background(0);\n camera = createCamera();\n camera.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n camera.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n describe('An example that creates a camera and moves it around the box.');\n}\n\nfunction draw() {\n background(0);\n // The camera will automatically\n // rotate to look at [0, 0, 0].\n camera.lookAt(0, 0, 0);\n\n // The camera will move on the\n // x axis.\n camera.setPosition(sin(frameCount / 60) * 200, 0, 100);\n box(20);\n\n // A 'ground' box to give the viewer\n // a better idea of where the camera\n // is looking.\n translate(0, 50, 0);\n rotateX(HALF_PI);\n box(150, 150, 20);\n}\n
\nlet cam1, cam2;\nlet currentCamera;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n\n cam1 = createCamera();\n cam1.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam1.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n cam2 = createCamera();\n cam2.setPosition(30, 0, 50);\n cam2.lookAt(0, 0, 0);\n cam2.ortho(-50, 50, -50, 50, 0, 200);\n\n // set variable for previously active camera:\n currentCamera = 1;\n\n describe(\n 'Canvas switches between two camera views, each showing a series of spinning 3D boxes.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // every 100 frames, switch between the two cameras\n if (frameCount % 100 === 0) {\n if (currentCamera === 1) {\n setCamera(cam1);\n currentCamera = 0;\n } else {\n setCamera(cam2);\n currentCamera = 1;\n }\n }\n\n // camera 1:\n cam1.lookAt(0, 0, 0);\n cam1.setPosition(sin(frameCount / 60) * 200, 0, 100);\n\n drawBoxes();\n}\n\nfunction drawBoxes() {\n rotateX(frameCount * 0.01);\n translate(-100, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n}\n
\n\nlet img;\nlet model1;\nlet model2;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(150, 150, WEBGL);\n background(200);\n\n model1 = createShape(50, 50);\n model2 = createShape(50, 50);\n model2.flipU();\n}\n\nfunction draw() {\n background(0);\n\n // original\n push();\n translate(-40, 0, 0);\n texture(img);\n noStroke();\n plane(50);\n model(model1);\n pop();\n\n // flipped\n push();\n translate(40, 0, 0);\n texture(img);\n noStroke();\n plane(50);\n model(model2);\n pop();\n}\n\nfunction createShape(w, h) {\n return buildGeometry(() => {\n textureMode(NORMAL);\n beginShape();\n vertex(-w / 2, -h / 2, 0, 0);\n vertex(w / 2, -h / 2, 1, 0);\n vertex(w / 2, h / 2, 1, 1);\n vertex(-w / 2, h / 2, 0, 1);\n endShape(CLOSE);\n });\n}\n
\n\nlet img;\nlet model1;\nlet model2;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(150, 150, WEBGL);\n background(200);\n\n model1 = createShape(50, 50);\n model2 = createShape(50, 50);\n model2.flipV();\n}\n\nfunction draw() {\n background(0);\n\n // original\n push();\n translate(-40, 0, 0);\n texture(img);\n noStroke();\n plane(50);\n model(model1);\n pop();\n\n // flipped\n push();\n translate(40, 0, 0);\n texture(img);\n noStroke();\n plane(50);\n model(model2);\n pop();\n}\n\nfunction createShape(w, h) {\n return buildGeometry(() => {\n textureMode(NORMAL);\n beginShape();\n vertex(-w / 2, -h / 2, 0, 0);\n vertex(w / 2, -h / 2, 1, 0);\n vertex(w / 2, h / 2, 1, 1);\n vertex(-w / 2, h / 2, 0, 1);\n endShape(CLOSE);\n });\n}\n
\nSet attributes for the WebGL Drawing context.\nThis is a way of adjusting how the WebGL\nrenderer works to fine-tune the display and performance.
\nNote that this will reinitialize the drawing context\nif called after the WebGL canvas is made.
\nIf an object is passed as the parameter, all attributes\nnot declared in the object will be set to defaults.
\nThe available attributes are:\n
\nalpha - indicates if the canvas contains an alpha buffer\ndefault is true
depth - indicates whether the drawing buffer has a depth buffer\nof at least 16 bits - default is true
\nstencil - indicates whether the drawing buffer has a stencil buffer\nof at least 8 bits
\nantialias - indicates whether or not to perform anti-aliasing\ndefault is false (true in Safari)
\npremultipliedAlpha - indicates that the page compositor will assume\nthe drawing buffer contains colors with pre-multiplied alpha\ndefault is true
\npreserveDrawingBuffer - if true the buffers will not be cleared and\nand will preserve their values until cleared or overwritten by author\n(note that p5 clears automatically on draw loop)\ndefault is true
\nperPixelLighting - if true, per-pixel lighting will be used in the\nlighting shader otherwise per-vertex lighting is used.\ndefault is true.
\nversion - either 1 or 2, to specify which WebGL version to ask for. By\ndefault, WebGL 2 will be requested. If WebGL2 is not available, it will\nfall back to WebGL 1. You can check what version is used with by looking at\nthe global webglVersion
property.
\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(255);\n push();\n rotateZ(frameCount * 0.02);\n rotateX(frameCount * 0.02);\n rotateY(frameCount * 0.02);\n fill(0, 0, 0);\n box(50);\n pop();\n}\n
\n\nfunction setup() {\n setAttributes('antialias', true);\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(255);\n push();\n rotateZ(frameCount * 0.02);\n rotateX(frameCount * 0.02);\n rotateY(frameCount * 0.02);\n fill(0, 0, 0);\n box(50);\n pop();\n}\n
\n\n// press the mouse button to disable perPixelLighting\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n fill(255);\n}\n\nlet lights = [\n { c: '#f00', t: 1.12, p: 1.91, r: 0.2 },\n { c: '#0f0', t: 1.21, p: 1.31, r: 0.2 },\n { c: '#00f', t: 1.37, p: 1.57, r: 0.2 },\n { c: '#ff0', t: 1.12, p: 1.91, r: 0.7 },\n { c: '#0ff', t: 1.21, p: 1.31, r: 0.7 },\n { c: '#f0f', t: 1.37, p: 1.57, r: 0.7 }\n];\n\nfunction draw() {\n let t = millis() / 1000 + 1000;\n background(0);\n directionalLight(color('#222'), 1, 1, 1);\n\n for (let i = 0; i < lights.length; i++) {\n let light = lights[i];\n pointLight(\n color(light.c),\n p5.Vector.fromAngles(t * light.t, t * light.p, width * light.r)\n );\n }\n\n specularMaterial(255);\n sphere(width * 0.1);\n\n rotateX(t * 0.77);\n rotateY(t * 0.83);\n rotateZ(t * 0.91);\n torus(width * 0.3, width * 0.07, 24, 10);\n}\n\nfunction mousePressed() {\n setAttributes('perPixelLighting', false);\n noStroke();\n fill(255);\n}\nfunction mouseReleased() {\n setAttributes('perPixelLighting', true);\n noStroke();\n fill(255);\n}\n
\n\ncreateCanvas(200, 100);\nstroke(255);\nconst myColor = color(100, 100, 250);\nfill(myColor);\nrotate(HALF_PI);\ntext(myColor.toString(), 0, -5);\ntext(myColor.toString('#rrggbb'), 0, -30);\ntext(myColor.toString('rgba%'), 0, -55);\ndescribe('Three text representation of a color written sideways.');\n
\n\nconst myColor = color(100, 130, 250);\ntext(myColor.toString('#rrggbb'), 25, 25);\ndescribe('A hexadecimal representation of a color.');\n
\n\nlet backgroundColor;\n\nfunction setup() {\n backgroundColor = color(100, 50, 150);\n}\n\nfunction draw() {\n backgroundColor.setRed(128 + 128 * sin(millis() / 1000));\n background(backgroundColor);\n describe('A canvas with a gradually changing background color.');\n}\n
\n\nlet backgroundColor;\n\nfunction setup() {\n backgroundColor = color(100, 50, 150);\n}\n\nfunction draw() {\n backgroundColor.setGreen(128 + 128 * sin(millis() / 1000));\n background(backgroundColor);\n describe('A canvas with a gradually changing background color.');\n}\n
\n\nlet backgroundColor;\n\nfunction setup() {\n backgroundColor = color(100, 50, 150);\n}\n\nfunction draw() {\n backgroundColor.setBlue(128 + 128 * sin(millis() / 1000));\n background(backgroundColor);\n describe('A canvas with a gradually changing background color.');\n}\n
\n\nfunction draw() {\n clear();\n background(200);\n const squareColor = color(100, 50, 100);\n squareColor.setAlpha(128 + 128 * sin(millis() / 1000));\n fill(squareColor);\n rect(13, 13, width - 26, height - 26);\n describe(\n 'A purple square with gradually changing opacity drawn on a gray background.'\n );\n}\n
\n\nlet pg;\nfunction setup() {\n createCanvas(100, 100);\n background(0);\n pg = createGraphics(50, 100);\n pg.fill(0);\n frameRate(5);\n}\n\nfunction draw() {\n image(pg, width / 2, 0);\n pg.background(255);\n // p5.Graphics object behave a bit differently in some cases\n // The normal canvas on the left resets the translate\n // with every loop through draw()\n // the graphics object on the right doesn't automatically reset\n // so translate() is additive and it moves down the screen\n rect(0, 0, width / 2, 5);\n pg.rect(0, 0, width / 2, 5);\n translate(0, 5, 0);\n pg.translate(0, 5, 0);\n}\nfunction mouseClicked() {\n // if you click you will see that\n // reset() resets the translate back to the initial state\n // of the Graphics object\n pg.reset();\n}\n
\nlet bg;\nfunction setup() {\n bg = createCanvas(100, 100);\n bg.background(0);\n image(bg, 0, 0);\n bg.remove();\n}\n
\nlet bg;\nfunction setup() {\n pixelDensity(1);\n createCanvas(100, 100);\n stroke(255);\n fill(0);\n\n // create and draw the background image\n bg = createGraphics(100, 100);\n bg.background(200);\n bg.ellipse(50, 50, 80, 80);\n}\nfunction draw() {\n let t = millis() / 1000;\n // draw the background\n if (bg) {\n image(bg, frameCount % 100, 0);\n image(bg, frameCount % 100 - 100, 0);\n }\n // draw the foreground\n let p = p5.Vector.fromAngle(t, 35).add(50, 50);\n ellipse(p.x, p.y, 30);\n}\nfunction mouseClicked() {\n // remove the background\n if (bg) {\n bg.remove();\n bg = null;\n }\n}\n
Creates and returns a new p5.Framebuffer\ninside a p5.Graphics WebGL context.
\nThis takes the same parameters as the global\ncreateFramebuffer function.
\n", + "example": [], + "overloads": [ + { + "params": [], + "return": { + "description": "", + "type": "p5.Framebuffer" + } + } + ], + "return": { + "description": "", + "type": "p5.Framebuffer" + }, + "class": "p5.Graphics", + "static": false, + "module": "Rendering", + "submodule": "Rendering" + }, + { + "name": "resize", + "file": "src/core/p5.Renderer.js", + "line": 122, + "itemtype": "method", + "description": "Resize our canvas element.", + "example": [], + "overloads": [ + { + "params": [] + } + ], + "class": "p5.Renderer", + "static": false, + "module": "Rendering", + "submodule": "Rendering" + }, + { + "name": "size", + "file": "src/data/p5.TypedDict.js", + "line": 116, + "itemtype": "method", + "description": "Returns the number of key-value pairs currently stored in the Dictionary.", + "example": [ + "\nfunction setup() {\n let myDictionary = createNumberDict(1, 10);\n myDictionary.create(2, 20);\n myDictionary.create(3, 30);\n print(myDictionary.size()); // logs 3 to the console\n}\n
\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n print(myDictionary.hasKey('p5')); // logs true to console\n}\n
\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n let myValue = myDictionary.get('p5');\n print(myValue === 'js'); // logs true to console\n}\n
\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.set('p5', 'JS');\n myDictionary.print(); // logs \"key: p5 - value: JS\" to console\n}\n
\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.create('happy', 'coding');\n myDictionary.print();\n // above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n}\n
\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n print(myDictionary.hasKey('p5')); // prints 'true'\n myDictionary.clear();\n print(myDictionary.hasKey('p5')); // prints 'false'\n}\n
\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.create('happy', 'coding');\n myDictionary.print();\n // above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n myDictionary.remove('p5');\n myDictionary.print();\n // above logs \"key: happy value: coding\" to console\n}\n
\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.create('happy', 'coding');\n myDictionary.print();\n // above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n createStringDict({\n john: 1940,\n paul: 1942,\n george: 1943,\n ringo: 1940\n }).saveTable('beatles');\n }\n}\n
\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n createStringDict({\n john: 1940,\n paul: 1942,\n george: 1943,\n ringo: 1940\n }).saveJSON('beatles');\n }\n}\n
\n\nfunction setup() {\n let myDictionary = createNumberDict(2, 5);\n myDictionary.add(2, 2);\n print(myDictionary.get(2)); // logs 7 to console.\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict(2, 5);\n myDictionary.sub(2, 2);\n print(myDictionary.get(2)); // logs 3 to console.\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict(2, 4);\n myDictionary.mult(2, 2);\n print(myDictionary.get(2)); // logs 8 to console.\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict(2, 8);\n myDictionary.div(2, 2);\n print(myDictionary.get(2)); // logs 4 to console.\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });\n let lowestValue = myDictionary.minValue(); // value is -10\n print(lowestValue);\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });\n let highestValue = myDictionary.maxValue(); // value is 3\n print(highestValue);\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });\n let lowestKey = myDictionary.minKey(); // value is 1.2\n print(lowestKey);\n}\n
\nfunction setup() {\n let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });\n let highestKey = myDictionary.maxKey(); // value is 4\n print(highestKey);\n}\n
\nlet beat;\n\nfunction setup() {\n background(200);\n\n textAlign(CENTER);\n text('Click to play', 50, 50);\n\n // Create a p5.MediaElement using createAudio().\n beat = createAudio('assets/beat.mp3');\n\n describe('The text \"Click to play\" written in black on a gray background. A beat plays when the user clicks the square.');\n}\n\n// Play the beat when the user\n// presses the mouse.\nfunction mousePressed() {\n beat.play();\n}\n
\nmedia.play()
will restart playing audio/video from the beginning.",
+ "example": [
+ "\nlet beat;\nlet isStopped = true;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n beat = createAudio('assets/beat.mp3');\n\n describe('The text \"Click to start\" written in black on a gray background. The beat starts or stops when the user presses the mouse.');\n}\n\nfunction draw() {\n background(200);\n\n textAlign(CENTER);\n if (isStopped === true) {\n text('Click to start', 50, 50);\n } else {\n text('Click to stop', 50, 50);\n }\n}\n\n// Adjust playback when the user\n// presses the mouse.\nfunction mousePressed() {\n if (isStopped === true) {\n // If the beat is stopped,\n // play it.\n beat.play();\n isStopped = false;\n } else {\n // If the beat is playing,\n // stop it.\n beat.stop();\n isStopped = true;\n }\n}\n
\nmedia.play()
will resume playing\naudio/video from the moment it paused.",
+ "example": [
+ "\nlet beat;\nlet isPaused = true;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n beat = createAudio('assets/beat.mp3');\n\n describe('The text \"Click to play\" written in black on a gray background. The beat plays or pauses when the user clicks the square.');\n}\n\nfunction draw() {\n background(200);\n\n // Display different instructions\n // based on playback.\n textAlign(CENTER);\n if (isPaused === true) {\n text('Click to play', 50, 50);\n } else {\n text('Click to pause', 50, 50);\n }\n}\n\n// Adjust playback when the user\n// presses the mouse.\nfunction mousePressed() {\n if (isPaused === true) {\n // If the beat is paused,\n // play it.\n beat.play();\n isPaused = false;\n } else {\n // If the beat is playing,\n // pause it.\n beat.pause();\n isPaused = true;\n }\n}\n
\n\nlet beat;\nlet isLooping = false;\n\nfunction setup() {\n background(200);\n\n // Create a p5.MediaElement using createAudio().\n beat = createAudio('assets/beat.mp3');\n\n describe('The text \"Click to loop\" written in black on a gray background. A beat plays repeatedly in a loop when the user clicks. The beat stops when the user clicks again.');\n}\n\nfunction draw() {\n background(200);\n\n // Display different instructions\n // based on playback.\n textAlign(CENTER);\n if (isLooping === true) {\n text('Click to stop', 50, 50);\n } else {\n text('Click to loop', 50, 50);\n }\n}\n\n// Adjust playback when the user\n// presses the mouse.\nfunction mousePressed() {\n if (isLooping === true) {\n // If the beat is looping,\n // stop it.\n beat.stop();\n isLooping = false;\n } else {\n // If the beat is stopped,\n // loop it.\n beat.loop();\n isLooping = true;\n }\n}\n
\n\nlet beat;\nlet isPlaying = false;\n\nfunction setup() {\n background(200);\n\n // Create a p5.MediaElement using createAudio().\n beat = createAudio('assets/beat.mp3');\n\n describe('The text \"Click to play\" written in black on a gray background. A beat plays when the user clicks. The beat stops when the user clicks again.');\n}\n\nfunction draw() {\n background(200);\n\n // Display different instructions\n // based on playback.\n textAlign(CENTER);\n if (isPlaying === true) {\n text('Click to stop', 50, 50);\n } else {\n text('Click to play', 50, 50);\n }\n}\n\n// Adjust playback when the user\n// presses the mouse.\nfunction mousePressed() {\n if (isPlaying === true) {\n // If the beat is playing,\n // stop it.\n beat.stop();\n isPlaying = false;\n } else {\n // If the beat is stopped,\n // play it.\n beat.play();\n isPlaying = true;\n }\n}\n
\nSets the audio/video to play once it's loaded.
\nThe parameter, shouldAutoplay
, is optional. Calling\nmedia.autoplay()
without an argument causes the media to play\nautomatically. If true
is passed, as in media.autoplay(true)
, the\nmedia will automatically play. If false
is passed, as in\nmedia.autoPlay(false)
, it won't play automatically.
\nfunction setup() {\n noCanvas();\n\n // Load a video and play it automatically.\n let video = createVideo('assets/fingers.mov', () => {\n video.autoplay();\n video.size(100, 100);\n });\n\n describe('A video of fingers walking on a treadmill.');\n}\n
\n\nfunction setup() {\n noCanvas();\n\n // Load a video, but don't play it automatically.\n let video = createVideo('assets/fingers.mov', () => {\n video.autoplay(false);\n video.size(100, 100);\n });\n\n // Play the video when the user clicks on it.\n video.mousePressed(() => {\n video.play();\n });\n\n describe('An image of fingers on a treadmill. They start walking when the user double-clicks on them.');\n}\n
\nManages the audio/video volume.
\nCalling media.volume()
without an argument returns the current volume\nas a number in the range 0 (off) to 1 (maximum).
The parameter, val
, is optional. It's a number that sets the volume\nfrom 0 (off) to 1 (maximum). For example, calling media.volume(0.5)
\nsets the volume to half of its maximum.
\nlet dragon;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n dragon = createAudio('assets/lucky_dragons.mp3');\n // Show the default media controls.\n dragon.showControls();\n\n describe('The text \"Volume: V\" on a gray square with media controls beneath it. The number \"V\" oscillates between 0 and 1 as the music plays.');\n}\n\nfunction draw() {\n background(200);\n\n // Produce a number between 0 and 1.\n let n = 0.5 * sin(frameCount * 0.01) + 0.5;\n // Use n to set the volume.\n dragon.volume(n);\n\n // Get the current volume\n // and display it.\n let v = dragon.volume();\n // Round v to 1 decimal place\n // for display.\n v = round(v, 1);\n textAlign(CENTER);\n text(`Volume: ${v}`, 50, 50);\n}\n
\nManages the audio/video playback speed. Calling media.speed()
returns\nthe current speed as a number.
The parameter, val
, is optional. It's a number that sets the playback\nspeed. 1 plays the media at normal speed, 0.5 plays it at half speed, 2\nplays it at double speed, and so on. -1 plays the media at normal speed\nin reverse.
Note: Not all browsers support backward playback. Even if they do,\nplayback might not be smooth.
\n", + "example": [ + "\nlet dragon;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n dragon = createAudio('assets/lucky_dragons.mp3');\n\n // Show the default media controls.\n dragon.showControls();\n\n describe('The text \"Speed: S\" on a gray square with media controls beneath it. The number \"S\" oscillates between 0 and 1 as the music plays.');\n}\n\nfunction draw() {\n background(200);\n\n // Produce a number between 0 and 2.\n let n = sin(frameCount * 0.01) + 1;\n // Use n to set the playback speed.\n dragon.speed(n);\n\n // Get the current speed\n // and display it.\n let s = dragon.speed();\n // Round s to 1 decimal place\n // for display.\n s = round(s, 1);\n textAlign(CENTER);\n text(`Speed: ${s}`, 50, 50);\n}\n
"
+ ],
+ "overloads": [
+ {
+ "params": [],
+ "return": {
+ "description": "current playback speed.",
+ "type": "Number"
+ }
+ },
+ {
+ "params": [
+ {
+ "name": "speed",
+ "description": "speed multiplier for playback.",
+ "type": "Number"
+ }
+ ]
+ }
+ ],
+ "return": {
+ "description": "current playback speed.",
+ "type": "Number"
+ },
+ "class": "p5.MediaElement",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "time",
+ "file": "src/dom/dom.js",
+ "line": 4290,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Manages the media element's playback time. Calling media.time()
\nreturns the number of seconds the audio/video has played. Time resets to\n0 when the looping media restarts.
The parameter, time
, is optional. It's a number that specifies the\ntime, in seconds, to jump to when playback begins.
\nlet dragon;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n dragon = createAudio('assets/lucky_dragons.mp3');\n // Show the default media controls.\n dragon.showControls();\n\n describe('The text \"S seconds\" on a gray square with media controls beneath it. The number \"S\" increases as the song plays.');\n}\n\nfunction draw() {\n background(200);\n\n // Display the current time.\n let s = dragon.time();\n // Round s to 1 decimal place\n // for display.\n s = round(s, 1);\n textAlign(CENTER);\n text(`${s} seconds`, 50, 50);\n}\n
\n\nlet dragon;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n dragon = createAudio('assets/lucky_dragons.mp3');\n // Show the default media controls.\n dragon.showControls();\n\n // Jump to 2 seconds\n // to start.\n dragon.time(2);\n\n describe('The text \"S seconds\" on a gray square with media controls beneath it. The number \"S\" increases as the song plays.');\n}\n\nfunction draw() {\n background(200);\n\n // Display the current time.\n let s = dragon.time();\n // Round s to 1 decimal place\n // for display.\n s = round(s, 1);\n textAlign(CENTER);\n text(`${s} seconds`, 50, 50);\n}\n
\n\nlet dragon;\n\nfunction setup() {\n background(200);\n\n // Create a p5.MediaElement using createAudio().\n dragon = createAudio('assets/lucky_dragons.mp3');\n // Show the default media controls.\n dragon.showControls();\n\n describe('The text \"S seconds left\" on a gray square with media controls beneath it. The number \"S\" decreases as the song plays.');\n}\n\nfunction draw() {\n background(200);\n\n // Calculate the time remaining.\n let s = dragon.duration() - dragon.time();\n // Round s to 1 decimal place\n // for display.\n s = round(s, 1);\n\n // Display the time remaining.\n textAlign(CENTER);\n text(`${s} seconds left`, 50, 50);\n}\n
\nCalls a function when the audio/video reaches the end of its playback\nThe function won't be called if the media is looping.
\nThe p5.MediaElement
is passed as an argument to the callback function.
\nlet beat;\nlet isPlaying = false;\nlet isDone = false;\n\nfunction setup() {\n\n // Create a p5.MediaElement using createAudio().\n beat = createAudio('assets/beat.mp3');\n\n // Set isDone to false when\n // the beat finishes.\n beat.onended(() => {\n isDone = true;\n });\n\n describe('The text \"Click to play\" written in black on a gray square. A beat plays when the user clicks. The text \"Done!\" appears when the beat finishes playing.');\n}\n\nfunction draw() {\n background(200);\n\n // Display different messages\n // based on playback.\n textAlign(CENTER);\n if (isDone === true) {\n text('Done!', 50, 50);\n } else if (isPlaying === false) {\n text('Click to play', 50, 50);\n } else {\n text('Playing...', 50, 50);\n }\n}\n\n// Play the beat when the\n// user presses the mouse.\nfunction mousePressed() {\n if (isPlaying === false) {\n isPlaying = true;\n beat.play();\n }\n}\n
\np5.MediaElement
is passed as\nthe argument.",
+ "type": "Function"
+ }
+ ]
+ }
+ ],
+ "class": "p5.MediaElement",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "connect",
+ "file": "src/dom/dom.js",
+ "line": 4514,
+ "itemtype": "method",
+ "description": "Send the audio output of this element to a specified audioNode or\np5.sound object. If no element is provided, connects to p5's main\noutput. That connection is established when this method is first called.\nAll connections are removed by the .disconnect() method.
\nThis method is meant to be used with the p5.sound.js addon library.
\n", + "example": [], + "overloads": [ + { + "params": [ + { + "name": "audioNode", + "description": "AudioNode from the Web Audio API,\nor an object from the p5.sound library", + "type": "AudioNode|Object" + } + ] + } + ], + "class": "p5.MediaElement", + "static": false, + "module": "DOM", + "submodule": "DOM" + }, + { + "name": "disconnect", + "file": "src/dom/dom.js", + "line": 4556, + "itemtype": "method", + "description": "Disconnect all Web Audio routing, including to main output.\nThis is useful if you want to re-route the output through\naudio effects, for example.", + "example": [], + "overloads": [ + { + "params": [] + } + ], + "class": "p5.MediaElement", + "static": false, + "module": "DOM", + "submodule": "DOM" + }, + { + "name": "showControls", + "file": "src/dom/dom.js", + "line": 4591, + "itemtype": "method", + "description": "Show the default\nHTMLMediaElement\ncontrols. These vary between web browser.", + "example": [ + "\nfunction setup() {\n background('cornflowerblue');\n\n textAlign(CENTER);\n textSize(50);\n text('🐉', 50, 50);\n\n // Create a p5.MediaElement using createAudio().\n let dragon = createAudio('assets/lucky_dragons.mp3');\n // Show the default media controls.\n dragon.showControls();\n\n describe('A dragon emoji, 🐉, drawn in the center of a blue square. A song plays in the background. Audio controls are displayed beneath the canvas.');\n}\n
\n\nlet dragon;\nlet isHidden = false;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n dragon = createAudio('assets/lucky_dragons.mp3');\n // Show the default media controls.\n dragon.showControls();\n\n describe('The text \"Double-click to hide controls\" written in the middle of a gray square. A song plays in the background. Audio controls are displayed beneath the canvas. The controls appear/disappear when the user double-clicks the square.');\n}\n\nfunction draw() {\n background(200);\n\n // Display a different message when\n // controls are hidden or shown.\n textAlign(CENTER);\n if (isHidden === true) {\n text('Double-click to show controls', 10, 20, 80, 80);\n } else {\n text('Double-click to hide controls', 10, 20, 80, 80);\n }\n}\n\n// Show/hide controls based on a double-click.\nfunction doubleClicked() {\n if (isHidden === true) {\n dragon.showControls();\n isHidden = false;\n } else {\n dragon.hideControls();\n isHidden = true;\n }\n}\n
\nSchedules a function to call when the audio/video reaches a specific time\nduring its playback.
\nThe first parameter, time
, is the time, in seconds, when the function\nshould run. This value is passed to callback
as its first argument.
The second parameter, callback
, is the function to call at the specified\ncue time.
The third parameter, value
, is optional and can be any type of value.\nvalue
is passed to callback
.
Calling media.addCue()
returns an ID as a string. This is useful for\nremoving the cue later.
\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n let beat = createAudio('assets/beat.mp3');\n // Play the beat in a loop.\n beat.loop();\n\n // Schedule a few events.\n beat.addCue(0, changeBackground, 'red');\n beat.addCue(2, changeBackground, 'deeppink');\n beat.addCue(4, changeBackground, 'orchid');\n beat.addCue(6, changeBackground, 'lavender');\n\n describe('A red square with a beat playing in the background. Its color changes every 2 seconds while the audio plays.');\n}\n\nfunction changeBackground(c) {\n background(c);\n}\n
\ncallback
.",
+ "optional": 1,
+ "type": "Object"
+ }
+ ],
+ "return": {
+ "description": "id ID of this cue,\nuseful for media.removeCue(id)
.",
+ "type": "Number"
+ }
+ }
+ ],
+ "return": {
+ "description": "id ID of this cue,\nuseful for media.removeCue(id)
.",
+ "type": "Number"
+ },
+ "class": "p5.MediaElement",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "removeCue",
+ "file": "src/dom/dom.js",
+ "line": 4756,
+ "itemtype": "method",
+ "description": "Remove a callback based on its ID.",
+ "example": [
+ "\nlet lavenderID;\nlet isRemoved = false;\n\nfunction setup() {\n // Create a p5.MediaElement using createAudio().\n let beat = createAudio('assets/beat.mp3');\n // Play the beat in a loop.\n beat.loop();\n\n // Schedule a few events.\n beat.addCue(0, changeBackground, 'red');\n beat.addCue(2, changeBackground, 'deeppink');\n beat.addCue(4, changeBackground, 'orchid');\n\n // Record the ID of the \"lavender\" callback.\n lavenderID = beat.addCue(6, changeBackground, 'lavender');\n\n describe('The text \"Double-click to remove lavender.\" written on a red square. The color changes every 2 seconds while the audio plays. The lavender option is removed when the user double-clicks the square.');\n}\n\nfunction draw() {\n if (isRemoved === false) {\n text('Double-click to remove lavender.', 10, 10, 80, 80);\n } else {\n text('No more lavender.', 10, 10, 80, 80);\n }\n}\n\nfunction changeBackground(c) {\n background(c);\n}\n\n// Remove the lavender color-change cue\n// when the user double-clicks.\nfunction doubleClicked() {\n if (isRemoved === false) {\n beat.removeCue(lavenderID);\n isRemoved = true;\n }\n}\n
\nmedia.addCue()
.",
+ "type": "Number"
+ }
+ ]
+ }
+ ],
+ "class": "p5.MediaElement",
+ "static": false,
+ "module": "DOM",
+ "submodule": "DOM"
+ },
+ {
+ "name": "clearCues",
+ "file": "src/dom/dom.js",
+ "line": 4818,
+ "itemtype": "method",
+ "description": "Removes all functions scheduled with media.addCue()
.",
+ "example": [
+ "\nlet isChanging = true;\n\nfunction setup() {\n background(200);\n\n // Create a p5.MediaElement using createAudio().\n let beat = createAudio('assets/beat.mp3');\n // Play the beat in a loop.\n beat.loop();\n\n // Schedule a few events.\n beat.addCue(0, changeBackground, 'red');\n beat.addCue(2, changeBackground, 'deeppink');\n beat.addCue(4, changeBackground, 'orchid');\n beat.addCue(6, changeBackground, 'lavender');\n\n describe('The text \"Double-click to stop changing.\" written on a square. The color changes every 2 seconds while the audio plays. The color stops changing when the user double-clicks the square.');\n}\n\nfunction draw() {\n if (isChanging === true) {\n text('Double-click to stop changing.', 10, 10, 80, 80);\n } else {\n text('No more changes.', 10, 10, 80, 80);\n }\n}\n\nfunction changeBackground(c) {\n background(c);\n}\n\n// Remove cued functions and stop\n// changing colors when the user\n// double-clicks.\nfunction doubleClicked() {\n if (isChanging === true) {\n beat.clearCues();\n isChanging = false;\n }\n}\n
\nGets or sets the pixel density for high pixel density displays. By default,\nthe density will be set to 1.
\nCall this method with no arguments to get the default density, or pass\nin a number to set the density. If a non-positive number is provided,\nit defaults to 1.
\n", + "example": [], + "overloads": [ + { + "params": [ + { + "name": "density", + "description": "A scaling factor for the number of pixels per\nside", + "optional": 1, + "type": "Number" + } + ], + "return": { + "description": "The current density if called without arguments, or the instance for chaining if setting density.", + "type": "Number" + } + } + ], + "return": { + "description": "The current density if called without arguments, or the instance for chaining if setting density.", + "type": "Number" + }, + "class": "p5.Image", + "static": false, + "module": "Image", + "submodule": "Image" + }, + { + "name": "loadPixels", + "file": "src/image/p5.Image.js", + "line": 228, + "itemtype": "method", + "description": "Loads the current value of each pixel in the\np5.Image object into theimg.pixels
array.\nThis method must be called before reading or modifying pixel values.",
+ "example": [
+ "\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let x = 0; x < img.width; x += 1) {\n for (let y = 0; y < img.height; y += 1) {\n img.set(x, y, 0);\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nlet numPixels = 4 * img.width * img.height;\nfor (let i = 0; i < numPixels; i += 4) {\n // Red.\n img.pixels[i] = 0;\n // Green.\n img.pixels[i + 1] = 0;\n // Blue.\n img.pixels[i + 2] = 0;\n // Alpha.\n img.pixels[i + 3] = 255;\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\nUpdates the canvas with the RGBA values in the\nimg.pixels array.
\nimg.updatePixels()
only needs to be called after changing values in\nthe img.pixels array. Such changes can be\nmade directly after calling\nimg.loadPixels() or by calling\nimg.set().
The optional parameters x
, y
, width
, and height
define a\nsubsection of the p5.Image object to update.\nDoing so can improve performance in some cases.
If the p5.Image object was loaded from a GIF,\nthen calling img.updatePixels()
will update the pixels in current\nframe.
\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let x = 0; x < img.width; x += 1) {\n for (let y = 0; y < img.height; y += 1) {\n img.set(x, y, 0);\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nlet numPixels = 4 * img.width * img.height;\nfor (let i = 0; i < numPixels; i += 4) {\n // Red.\n img.pixels[i] = 0;\n // Green.\n img.pixels[i + 1] = 0;\n // Blue.\n img.pixels[i + 2] = 0;\n // Alpha.\n img.pixels[i + 3] = 255;\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A black square drawn in the middle of a gray square.');\n
\nGets a pixel or a region of pixels from a\np5.Image object.
\nimg.get()
is easy to use but it's not as fast as\nimg.pixels. Use\nimg.pixels to read many pixel values.
The version of img.get()
with no parameters returns the entire image.
The version of img.get()
with two parameters interprets them as\ncoordinates. It returns an array with the [R, G, B, A]
values of the\npixel at the given point.
The version of img.get()
with four parameters interprets them as\ncoordinates and dimensions. It returns a subsection of the canvas as a\np5.Image object. The first two parameters are\nthe coordinates for the upper-left corner of the subsection. The last two\nparameters are the width and height of the subsection.
Use img.get() to work directly with\np5.Image objects.
\n", + "example": [ + "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let img2 = get();\n image(img2, width / 2, 0);\n\n describe('Two identical mountain landscapes shown side-by-side.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let c = img.get(50, 90);\n fill(c);\n noStroke();\n square(25, 25, 50);\n\n describe('A mountain landscape with an olive green square in its center.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n let img2 = img.get(0, 0, img.width / 2, img.height / 2);\n image(img2, width / 2, height / 2);\n\n describe('A mountain landscape drawn on top of another mountain landscape.');\n}\n
\n[R, G, B, A]
.",
+ "type": "Number[]"
+ }
+ }
+ ],
+ "return": {
+ "description": "subsection as a p5.Image object.",
+ "type": "p5.Image"
+ },
+ "class": "p5.Image",
+ "static": false,
+ "module": "Image",
+ "submodule": "Image"
+ },
+ {
+ "name": "set",
+ "file": "src/image/p5.Image.js",
+ "line": 490,
+ "itemtype": "method",
+ "description": "Sets the color of one or more pixels within a\np5.Image object.
\nimg.set()
is easy to use but it's not as fast as\nimg.pixels. Use\nimg.pixels to set many pixel values.
img.set()
interprets the first two parameters as x- and y-coordinates. It\ninterprets the last parameter as a grayscale value, a [R, G, B, A]
pixel\narray, a p5.Color object, or another\np5.Image object.
img.updatePixels() must be called\nafter using img.set()
for changes to appear.
\nlet img = createImage(100, 100);\nimg.set(30, 20, 0);\nimg.set(85, 20, 0);\nimg.set(85, 75, 0);\nimg.set(30, 75, 0);\nimg.updatePixels();\nimage(img, 0, 0);\n\ndescribe('Four black dots arranged in a square drawn on a gray background.');\n
\n\nlet img = createImage(100, 100);\nlet black = color(0);\nimg.set(30, 20, black);\nimg.set(85, 20, black);\nimg.set(85, 75, black);\nimg.set(30, 75, black);\nimg.updatePixels();\nimage(img, 0, 0);\n\ndescribe('Four black dots arranged in a square drawn on a gray background.');\n
\n\nlet img = createImage(66, 66);\nfor (let x = 0; x < img.width; x += 1) {\n for (let y = 0; y < img.height; y += 1) {\n let c = map(x, 0, img.width, 0, 255);\n img.set(x, y, c);\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\ndescribe('A square with a horiztonal color gradient from black to white drawn on a gray background.');\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n let img2 = createImage(100, 100);\n img2.set(0, 0, img);\n image(img2, 0, 0);\n\n describe('An image of a mountain landscape.');\n}\n
\nwidth
\nand height
. The image's original aspect ratio can be kept by passing 0\nfor either width
or height
. For example, calling img.resize(50, 0)
\non an image that was 500 × 300 pixels will resize it to\n50 × 30 pixels.",
+ "example": [
+ "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n img.resize(50, 100);\n image(img, 0, 0);\n\n describe('Two images of a mountain landscape. One copy of the image is squeezed horizontally.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n img.resize(0, 30);\n image(img, 0, 0);\n\n describe('Two images of a mountain landscape. The small copy of the image covers the top-left corner of the larger image.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0);\n img.resize(60, 0);\n image(img, 0, 0);\n\n describe('Two images of a mountain landscape. The small copy of the image covers the top-left corner of the larger image.');\n}\n
\nimg.copy()
will scale pixels from the source\nregion if it isn't the same size as the destination region.",
+ "example": [
+ "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n img.copy(7, 22, 10, 10, 35, 25, 50, 50);\n image(img, 0, 0);\n // Outline copied region.\n stroke(255);\n noFill();\n square(7, 22, 10);\n\n describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.');\n}\n
\n\nlet mountains;\nlet bricks;\n\nfunction preload() {\n mountains = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n let x = bricks.width / 2;\n let y = bricks.height / 2;\n mountains.copy(bricks, 0, 0, x, y, 0, 0, x, y);\n image(mountains, 0, 0);\n\n describe('An image of a brick wall drawn at the top-left of an image of a mountain landscape.');\n}\n
\n\nlet photo;\nlet maskImage;\n\nfunction preload() {\n photo = loadImage('assets/rockies.jpg');\n maskImage = loadImage('assets/mask2.png');\n}\n\nfunction setup() {\n photo.mask(maskImage);\n image(photo, 0, 0);\n\n describe('An image of a mountain landscape. The right side of the image has a faded patch of white.');\n}\n
\nApplies an image filter to the p5.Image object.\nThe preset options are:
\nINVERT
\nInverts the colors in the image. No parameter is used.
GRAY
\nConverts the image to grayscale. No parameter is used.
THRESHOLD
\nConverts the image to black and white. Pixels with a grayscale value\nabove a given threshold are converted to white. The rest are converted to\nblack. The threshold must be between 0.0 (black) and 1.0 (white). If no\nvalue is specified, 0.5 is used.
OPAQUE
\nSets the alpha channel to be entirely opaque. No parameter is used.
POSTERIZE
\nLimits the number of colors in the image. Each color channel is limited to\nthe number of colors specified. Values between 2 and 255 are valid, but\nresults are most noticeable with lower values. The default value is 4.
BLUR
\nBlurs the image. The level of blurring is specified by a blur radius. Larger\nvalues increase the blur. The default value is 4. A gaussian blur is used\nin P2D
mode. A box blur is used in WEBGL
mode.
ERODE
\nReduces the light areas. No parameter is used.
DILATE
\nIncreases the light areas. No parameter is used.
\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(INVERT);\n image(img, 0, 0);\n\n describe('A blue brick wall.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(GRAY);\n image(img, 0, 0);\n\n describe('A brick wall drawn in grayscale.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(THRESHOLD);\n image(img, 0, 0);\n\n describe('A brick wall drawn in black and white.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(OPAQUE);\n image(img, 0, 0);\n\n describe('A red brick wall.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(POSTERIZE, 3);\n image(img, 0, 0);\n\n describe('An image of a red brick wall drawn with a limited color palette.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(BLUR, 3);\n image(img, 0, 0);\n\n describe('A blurry image of a red brick wall.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(DILATE);\n image(img, 0, 0);\n\n describe('A red brick wall with bright lines between each brick.');\n}\n
\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n img.filter(ERODE);\n image(img, 0, 0);\n\n describe('A red brick wall with faint lines between each brick.');\n}\n
\nblendMode
\nparameter blends the images' colors to create different effects.",
+ "example": [
+ "\nlet mountains;\nlet bricks;\n\nfunction preload() {\n mountains = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, ADD);\n image(mountains, 0, 0);\n image(bricks, 0, 0);\n\n describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.');\n}\n
\n\nlet mountains;\nlet bricks;\n\nfunction preload() {\n mountains = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST);\n image(mountains, 0, 0);\n image(bricks, 0, 0);\n\n describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.');\n}\n
\n\nlet mountains;\nlet bricks;\n\nfunction preload() {\n mountains = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST);\n image(mountains, 0, 0);\n image(bricks, 0, 0);\n\n describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.');\n}\n
\nthe blend mode. either\nBLEND, DARKEST, LIGHTEST, DIFFERENCE,\nMULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\nSOFT_LIGHT, DODGE, BURN, ADD or NORMAL.
\nAvailable blend modes are: normal | multiply | screen | overlay |\ndarken | lighten | color-dodge | color-burn | hard-light |\nsoft-light | difference | exclusion | hue | saturation |\ncolor | luminosity
\nhttp://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/
\n", + "type": "Constant" + } + ] + }, + { + "params": [ + { + "name": "sx", + "type": "Integer" + }, + { + "name": "sy", + "type": "Integer" + }, + { + "name": "sw", + "type": "Integer" + }, + { + "name": "sh", + "type": "Integer" + }, + { + "name": "dx", + "type": "Integer" + }, + { + "name": "dy", + "type": "Integer" + }, + { + "name": "dw", + "type": "Integer" + }, + { + "name": "dh", + "type": "Integer" + }, + { + "name": "blendMode", + "type": "Constant" + } + ] + } + ], + "class": "p5.Image", + "static": false, + "module": "Image", + "submodule": "Image" + }, + { + "name": "save", + "file": "src/image/p5.Image.js", + "line": 1145, + "itemtype": "method", + "description": "Saves the p5.Image object to a file.\nThe browser will either save the file immediately or prompt the user\nwith a dialogue window.
\nBy default, calling img.save()
will save the image as untitled.png
.
Calling img.save()
with one argument, as in img.save('photo.png')
,\nwill set the image's filename and type together.
Calling img.save()
with two arguments, as in\nimage.save('photo', 'png')
, will set the image's filename and type\nseparately.
The image will only be downloaded as an animated GIF if the\np5.Image object was loaded from a GIF file.\nSee saveGif() to create new GIFs.
\n", + "example": [ + "\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction draw() {\n image(img, 0, 0);\n\n describe('An image of a mountain landscape.');\n}\n\nfunction keyPressed() {\n if (key === 's') {\n img.save();\n } else if (key === 'j') {\n img.save('rockies.jpg');\n } else if (key === 'p') {\n img.save('rockies', 'png');\n }\n}\n
\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-wink-loop-once.gif');\n}\n\nfunction draw() {\n background(255);\n image(gif, 0, 0);\n\n describe('A cartoon face winks once and then freezes. Clicking resets the face and makes it wink again.');\n}\n\nfunction mousePressed() {\n gif.reset();\n}\n
\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction draw() {\n let index = gif.getCurrentFrame();\n image(gif, 0, 0);\n text(index, 10, 90);\n\n describe('A cartoon eye repeatedly looks around, then outwards. A number displayed in the bottom-left corner increases from 0 to 124, then repeats.');\n}\n
\n\nlet gif;\nlet frameSlider;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n let maxFrame = gif.numFrames() - 1;\n frameSlider = createSlider(0, maxFrame);\n frameSlider.position(10, 80);\n frameSlider.size(80);\n}\n\nfunction draw() {\n let index = frameSlider.value();\n gif.setFrame(index);\n image(gif, 0, 0);\n\n describe('A cartoon eye looks around when a slider is moved.');\n}\n
\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction draw() {\n image(gif, 0, 0);\n let total = gif.numFrames();\n let index = gif.getCurrentFrame();\n text(`${index} / ${total}`, 30, 90);\n\n describe('A cartoon eye looks around. The text \"n / 125\" is shown at the bottom of the canvas.');\n}\n
\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/nancy-liang-wind-loop-forever.gif');\n}\n\nfunction draw() {\n background(255);\n image(gif, 0, 0);\n\n describe('A drawing of a child with hair blowing in the wind. The animation freezes when clicked and resumes when released.');\n}\n\nfunction mousePressed() {\n gif.pause();\n}\n\nfunction mouseReleased() {\n gif.play();\n}\n
\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/nancy-liang-wind-loop-forever.gif');\n}\n\nfunction draw() {\n background(255);\n image(gif, 0, 0);\n\n describe('A drawing of a child with hair blowing in the wind. The animation freezes when clicked and resumes when released.');\n}\n\nfunction mousePressed() {\n gif.pause();\n}\n\nfunction mouseReleased() {\n gif.play();\n}\n
\nChanges the delay between frames in an animated GIF.
\nThe second parameter, index
, is optional. If provided, only the frame\nat index
will have its delay modified. All other frames will keep\ntheir default delay.
\nlet gifFast;\nlet gifSlow;\n\nfunction preload() {\n gifFast = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n gifSlow = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n gifFast.resize(50, 50);\n gifSlow.resize(50, 50);\n gifFast.delay(10);\n gifSlow.delay(100);\n}\n\nfunction draw() {\n image(gifFast, 0, 0);\n image(gifSlow, 50, 0);\n\n describe('Two animated eyes looking around. The eye on the left moves faster than the eye on the right.');\n}\n
\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n gif.delay(3000, 67);\n}\n\nfunction draw() {\n image(gif, 0, 0);\n\n describe('An animated eye looking around. It pauses for three seconds while it looks down.');\n}\n
\n\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let children = xml.getChildren('animal');\n let parent = children[1].getParent();\n print(parent.getName());\n}\n\n// Sketch prints:\n// mammals\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n print(xml.getName());\n}\n\n// Sketch prints:\n// mammals\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n print(xml.getName());\n xml.setName('fish');\n print(xml.getName());\n}\n\n// Sketch prints:\n// mammals\n// fish\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n print(xml.hasChildren());\n}\n\n// Sketch prints:\n// true\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n print(xml.listChildren());\n}\n\n// Sketch prints:\n// [\"animal\", \"animal\", \"animal\"]\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let animals = xml.getChildren('animal');\n\n for (let i = 0; i < animals.length; i++) {\n print(animals[i].getContent());\n }\n}\n\n// Sketch prints:\n// \"Goat\"\n// \"Leopard\"\n// \"Zebra\"\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.getContent());\n}\n\n// Sketch prints:\n// \"Goat\"\n
\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let secondChild = xml.getChild(1);\n print(secondChild.getContent());\n}\n\n// Sketch prints:\n// \"Leopard\"\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let child = new p5.XML();\n child.setName('animal');\n child.setAttribute('id', '3');\n child.setAttribute('species', 'Ornithorhynchus anatinus');\n child.setContent('Platypus');\n xml.addChild(child);\n\n let animals = xml.getChildren('animal');\n print(animals[animals.length - 1].getContent());\n}\n\n// Sketch prints:\n// \"Goat\"\n// \"Leopard\"\n// \"Zebra\"\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n xml.removeChild('animal');\n let children = xml.getChildren();\n for (let i = 0; i < children.length; i++) {\n print(children[i].getContent());\n }\n}\n\n// Sketch prints:\n// \"Leopard\"\n// \"Zebra\"\n
\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n xml.removeChild(1);\n let children = xml.getChildren();\n for (let i = 0; i < children.length; i++) {\n print(children[i].getContent());\n }\n}\n\n// Sketch prints:\n// \"Goat\"\n// \"Zebra\"\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.getAttributeCount());\n}\n\n// Sketch prints:\n// 2\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.listAttributes());\n}\n\n// Sketch prints:\n// [\"id\", \"species\"]\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.hasAttribute('species'));\n print(firstChild.hasAttribute('color'));\n}\n\n// Sketch prints:\n// true\n// false\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.getNum('id'));\n}\n\n// Sketch prints:\n// 0\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.getString('species'));\n}\n\n// Sketch prints:\n// \"Capra hircus\"\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.getString('species'));\n firstChild.setAttribute('species', 'Jamides zebra');\n print(firstChild.getString('species'));\n}\n\n// Sketch prints:\n// \"Capra hircus\"\n// \"Jamides zebra\"\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.getContent());\n}\n\n// Sketch prints:\n// \"Goat\"\n
\n// The following short XML file called \"mammals.xml\" is parsed\n// in the code below.\n//\n// \n// <mammals>\n// <animal id=\"0\" species=\"Capra hircus\">Goat</animal>\n// <animal id=\"1\" species=\"Panthera pardus\">Leopard</animal>\n// <animal id=\"2\" species=\"Equus zebra\">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n let firstChild = xml.getChild('animal');\n print(firstChild.getContent());\n firstChild.setContent('Mountain Goat');\n print(firstChild.getContent());\n}\n\n// Sketch prints:\n// \"Goat\"\n// \"Mountain Goat\"\n
\nlet xml;\n\nfunction preload() {\n xml = loadXML('assets/mammals.xml');\n}\n\nfunction setup() {\n print(xml.serialize());\n}\n\n// Sketch prints:\n// \n// Goat \n// Leopard \n// Zebra \n// \n
\nfunction setup() {\n let v = createVector(20, 30);\n // Prints 'p5.Vector Object : [20, 30, 0]'.\n print(v.toString());\n}\n
\nx
, y
, and z
components of the vector using separate numbers,\na p5.Vector object, or an array of numbers.\nCalling set()
with no arguments sets the vector's components to 0.",
+ "example": [
+ "\nstrokeWeight(5);\n\n// Top left.\nlet pos = createVector(25, 25);\npoint(pos);\n\n// Top right.\npos.set(75, 25);\npoint(pos);\n\n// Bottom right.\nlet p2 = createVector(75, 75);\npos.set(p2);\npoint(pos);\n\n// Bottom left.\nlet arr = [25, 75];\npos.set(arr);\npoint(pos);\n\ndescribe('Four black dots arranged in a square on a gray background.');\n
\n\nlet pos = createVector(50, 50);\nlet pc = pos.copy();\n\nstrokeWeight(5);\npoint(pc);\n\ndescribe('A black point drawn in the middle of a gray square.');\n
\nAdds to a vector's x
, y
, and z
components using separate numbers,\nanother p5.Vector object, or an array of numbers.\nCalling add()
with no arguments has no effect.
The static version of add()
, as in p5.Vector.add(v2, v1)
, returns a new\np5.Vector object and doesn't change the\noriginals.
\nstrokeWeight(5);\n\n// Top left.\nlet pos = createVector(25, 25);\npoint(pos);\n\n// Top right.\npos.add(50, 0);\npoint(pos);\n\n// Bottom right.\nlet p2 = createVector(0, 50);\npos.add(p2);\npoint(pos);\n\n// Bottom left.\nlet arr = [-50, 0];\npos.add(arr);\npoint(pos);\n\ndescribe('Four black dots arranged in a square on a gray background.');\n
\n\n// Top left.\nlet p1 = createVector(25, 25);\n\n// Center.\nlet p2 = createVector(50, 50);\n\n// Bottom right.\nlet p3 = p5.Vector.add(p1, p2);\n\nstrokeWeight(5);\npoint(p1);\npoint(p2);\npoint(p3);\n\ndescribe('Three black dots in a diagonal line from top left to bottom right.');\n
\n\nfunction draw() {\n background(200);\n\n let origin = createVector(0, 0);\n let v1 = createVector(50, 50);\n drawArrow(origin, v1, 'red');\n\n let v2 = createVector(-30, 20);\n drawArrow(v1, v2, 'blue');\n\n let v3 = p5.Vector.add(v1, v2);\n drawArrow(origin, v3, 'purple');\n\n describe('Three arrows drawn on a gray square. A red arrow extends from the top left corner to the center. A blue arrow extends from the tip of the red arrow. A purple arrow extends from the origin to the tip of the blue arrow.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nPerforms modulo (remainder) division with a vector's x
, y
, and z
\ncomponents using separate numbers, another\np5.Vector object, or an array of numbers.
The static version of rem()
as in p5.Vector.rem(v2, v1)
, returns a new\np5.Vector object and doesn't change the\noriginals.
\nlet v = createVector(3, 4, 5);\nv.rem(2, 3, 4);\n// Prints 'p5.Vector Object : [1, 1, 1]'.\nprint(v.toString());\n
\n\nlet v1 = createVector(3, 4, 5);\nlet v2 = createVector(2, 3, 4);\nv1.rem(v2);\n\n// Prints 'p5.Vector Object : [1, 1, 1]'.\nprint(v1.toString());\n
\n\nlet v = createVector(3, 4, 5);\nlet arr = [2, 3, 4];\nv.rem(arr);\n\n// Prints 'p5.Vector Object : [1, 1, 1]'.\nprint(v.toString());\n
\n\nlet v1 = createVector(3, 4, 5);\nlet v2 = createVector(2, 3, 4);\nlet v3 = p5.Vector.rem(v1, v2);\n\n// Prints 'p5.Vector Object : [1, 1, 1]'.\nprint(v3.toString());\n
\nSubtracts from a vector's x
, y
, and z
components using separate\nnumbers, another p5.Vector object, or an array of\nnumbers. Calling sub()
with no arguments has no effect.
The static version of sub()
, as in p5.Vector.sub(v2, v1)
, returns a new\np5.Vector object and doesn't change the\noriginals.
\nstrokeWeight(5);\n\n// Bottom right.\nlet pos = createVector(75, 75);\npoint(pos);\n\n// Top right.\npos.sub(0, 50);\npoint(pos);\n\n// Top left.\nlet p2 = createVector(50, 0);\npos.sub(p2);\npoint(pos);\n\n// Bottom left.\nlet arr = [0, -50];\npos.sub(arr);\npoint(pos);\n\ndescribe('Four black dots arranged in a square on a gray background.');\n
\n\n// Bottom right.\nlet p1 = createVector(75, 75);\n\n// Center.\nlet p2 = createVector(50, 50);\n\n// Top left.\nlet p3 = p5.Vector.sub(p1, p2);\n\nstrokeWeight(5);\npoint(p1);\npoint(p2);\npoint(p3);\n\ndescribe('Three black dots in a diagonal line from top left to bottom right.');\n
\n\nfunction draw() {\n background(200);\n\n let origin = createVector(0, 0);\n let v1 = createVector(50, 50);\n drawArrow(origin, v1, 'red');\n\n let v2 = createVector(20, 70);\n drawArrow(origin, v2, 'blue');\n\n let v3 = p5.Vector.sub(v2, v1);\n drawArrow(v1, v3, 'purple');\n\n describe('Three arrows drawn on a gray square. A red and a blue arrow extend from the top left. A purple arrow extends from the tip of the red arrow to the tip of the blue arrow.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nMultiplies a vector's x
, y
, and z
components by the same number,\nseparate numbers, the components of another\np5.Vector object, or an array of numbers. Calling\nmult()
with no arguments has no effect.
The static version of mult()
, as in p5.Vector.mult(v, 2)
, returns a new\np5.Vector object and doesn't change the\noriginals.
\nstrokeWeight(5);\n\nlet p = createVector(25, 25);\npoint(p);\n\np.mult(2);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(25, 25);\npoint(p);\n\np.mult(2, 3);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(25, 25);\npoint(p);\n\nlet arr = [2, 3];\np.mult(arr);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(25, 25);\npoint(p);\n\nlet p2 = createVector(2, 3);\np.mult(p2);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(25, 25);\npoint(p);\n\nlet p2 = createVector(2, 3);\nlet p3 = p5.Vector.mult(p, p2);\npoint(p3);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nfunction draw() {\n background(200);\n\n let origin = createVector(0, 0);\n let v1 = createVector(25, 25);\n drawArrow(origin, v1, 'red');\n\n let v2 = p5.Vector.mult(v1, 2);\n drawArrow(origin, v2, 'blue');\n\n describe('Two arrows extending from the top left corner. The blue arrow is twice the length of the red arrow.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nDivides a vector's x
, y
, and z
components by the same number,\nseparate numbers, the components of another\np5.Vector object, or an array of numbers. Calling\ndiv()
with no arguments has no effect.
The static version of div()
, as in p5.Vector.div(v, 2)
, returns a new\np5.Vector object and doesn't change the\noriginals.
\nstrokeWeight(5);\n\nlet p = createVector(50, 50);\npoint(p);\n\np.div(2);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(50, 75);\npoint(p);\n\np.div(2, 3);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(50, 75);\npoint(p);\n\nlet arr = [2, 3];\np.div(arr);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(50, 75);\npoint(p);\n\nlet p2 = createVector(2, 3);\np.div(p2);\npoint(p);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nstrokeWeight(5);\n\nlet p = createVector(50, 75);\npoint(p);\n\nlet p2 = createVector(2, 3);\nlet p3 = p5.Vector.div(p, p2);\npoint(p3);\n\ndescribe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n
\n\nfunction draw() {\n background(200);\n\n let origin = createVector(0, 0);\n let v1 = createVector(50, 50);\n drawArrow(origin, v1, 'red');\n\n let v2 = p5.Vector.div(v1, 2);\n drawArrow(origin, v2, 'blue');\n\n describe('Two arrows extending from the top left corner. The blue arrow is half the length of the red arrow.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n\nlet p = createVector(30, 40);\nline(0, 0, p.x, p.y);\n\nlet m = p.mag();\ntext(m, p.x, p.y);\n\ndescribe('A diagonal black line extends from the top left corner of a gray square. The number 50 is written at the end of the line.');\n
\n\nlet p = createVector(30, 40);\nline(0, 0, p.x, p.y);\n\nlet m = p.magSq();\ntext(m, p.x, p.y);\n\ndescribe('A diagonal black line extends from the top left corner of a gray square. The number 2500 is written at the end of the line.');\n
\nReturns the dot product of two vectors. The dot product is a number that\ndescribes the overlap between two vectors. Visually, the dot product can be\nthought of as the \"shadow\" one vector casts on another. The dot product's\nmagnitude is largest when two vectors point in the same or opposite\ndirections. Its magnitude is 0 when two vectors form a right angle.
\nThe version of dot()
with one parameter interprets it as another\np5.Vector object.
The version of dot()
with multiple parameters interprets them as the\nx
, y
, and z
components of another vector.
The static version of dot()
, as in p5.Vector.dot(v1, v2)
, is the same\nas calling v1.dot(v2)
.
\nlet v1 = createVector(3, 4);\nlet v2 = createVector(3, 0);\nlet dp = v1.dot(v2);\n// Prints \"9\" to the console.\nprint(dp);\n
\n\nlet v1 = createVector(1, 0);\nlet v2 = createVector(0, 1);\nlet dp = p5.Vector.dot(v1, v2);\n// Prints \"0\" to the console.\nprint(dp);\n
\n\nfunction draw() {\n background(200);\n\n let v0 = createVector(width / 2, height / 2);\n let v1 = createVector(30, 0);\n drawArrow(v0, v1, 'black');\n\n let v2 = createVector(mouseX - width / 2, mouseY - height / 2);\n drawArrow(v0, v2, 'red');\n\n let dp = v2.dot(v1);\n text(`v2 • v1 = ${dp}`, 15, 20);\n\n describe('Two arrows drawn on a gray square. A black arrow points to the right and a red arrow follows the mouse. The text \"v1 • v2 = something\" changes as the mouse moves.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nReturns the cross product of two vectors. The cross product is a vector\nthat points straight out of the plane created by two vectors. The cross\nproduct's magnitude is the area of the parallelogram formed by the original\ntwo vectors.
\nThe static version of cross()
, as in p5.Vector.cross(v1, v2)
, is the same\nas calling v1.cross(v2)
.
\nlet v1 = createVector(1, 0);\nlet v2 = createVector(3, 4);\nlet cp = v1.cross(v2);\n// Prints \"p5.Vector Object : [0, 0, 4]\" to the console.\nprint(cp.toString());\n
\n\nlet v1 = createVector(1, 0);\nlet v2 = createVector(3, 4);\nlet cp = p5.Vector.cross(v1, v2);\n// Prints \"p5.Vector Object : [0, 0, 4]\" to the console.\nprint(cp.toString());\n
\nReturns the distance between two points represented by vectors. A point's\ncoordinates can be thought of as a vector's components.
\nThe static version of dist()
, as in p5.Vector.dist(v1, v2)
, is the same\nas calling v1.dist(v2)
.
Use dist() to calculate the distance between points\nusing coordinates as in dist(x1, y1, x2, y2)
.
\nlet v1 = createVector(1, 0);\nlet v2 = createVector(0, 1);\nlet d = v1.dist(v2);\n// Prints \"1.414...\" to the console.\nprint(d);\n
\n\nlet v1 = createVector(1, 0);\nlet v2 = createVector(0, 1);\nlet d = p5.Vector.dist(v1, v2);\n// Prints \"1.414...\" to the console.\nprint(d);\n
\n\nfunction draw() {\n background(200);\n\n let origin = createVector(0, 0);\n let v1 = createVector(50, 50);\n drawArrow(origin, v1, 'red');\n\n let v2 = createVector(20, 70);\n drawArrow(origin, v2, 'blue');\n\n let v3 = p5.Vector.sub(v2, v1);\n drawArrow(v1, v3, 'purple');\n\n let m = floor(v3.mag());\n text(m, 50, 75);\n\n describe('Three arrows drawn on a gray square. A red and a blue arrow extend from the top left. A purple arrow extends from the tip of the red arrow to the tip of the blue arrow. The number 36 is written in black near the purple arrow.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nScales the components of a p5.Vector object so\nthat its magnitude is 1.
\nThe static version of normalize()
, as in p5.Vector.normalize(v)
,\nreturns a new p5.Vector object and doesn't change\nthe original.
\nlet v = createVector(10, 20, 2);\nv.normalize();\n// Prints \"p5.Vector Object : [0.445..., 0.890..., 0.089...]\" to the console.\nprint(v.toString());\n
\n\nlet v0 = createVector(10, 20, 2);\nlet v1 = p5.Vector.normalize(v0);\n// Prints \"p5.Vector Object : [10, 20, 2]\" to the console.\nprint(v0.toString());\n// Prints \"p5.Vector Object : [0.445..., 0.890..., 0.089...]\" to the console.\nprint(v1.toString());\n
\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(mouseX - 50, mouseY - 50);\n\n let r = 25;\n drawArrow(v0, v1, 'red');\n v1.normalize();\n drawArrow(v0, v1.mult(r), 'blue');\n\n noFill();\n circle(50, 50, r * 2);\n\n describe(\"A red and blue arrow extend from the center of a circle. Both arrows follow the mouse, but the blue arrow's length is fixed to the circle's radius.\");\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nLimits a vector's magnitude to a maximum value.
\nThe static version of limit()
, as in p5.Vector.limit(v, 5)
, returns a\nnew p5.Vector object and doesn't change the\noriginal.
\nlet v = createVector(10, 20, 2);\nv.limit(5);\n// Prints \"p5.Vector Object : [2.227..., 4.454..., 0.445...]\" to the console.\nprint(v.toString());\n
\n\nlet v0 = createVector(10, 20, 2);\nlet v1 = p5.Vector.limit(v0, 5);\n// Prints \"p5.Vector Object : [2.227..., 4.454..., 0.445...]\" to the console.\nprint(v1.toString());\n
\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(mouseX - 50, mouseY - 50);\n\n let r = 25;\n drawArrow(v0, v1, 'red');\n drawArrow(v0, v1.limit(r), 'blue');\n\n noFill();\n circle(50, 50, r * 2);\n\n describe(\"A red and blue arrow extend from the center of a circle. Both arrows follow the mouse, but the blue arrow never crosses the circle's edge.\");\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nSets a vector's magnitude to a given value.
\nThe static version of setMag()
, as in p5.Vector.setMag(v, 10)
, returns\na new p5.Vector object and doesn't change the\noriginal.
\nlet v = createVector(3, 4, 0);\n// Prints \"5\" to the console.\nprint(v.mag());\n\nv.setMag(10);\n// Prints \"p5.Vector Object : [6, 8, 0]\" to the console.\nprint(v.toString());\n
\n\nlet v0 = createVector(3, 4, 0);\nlet v1 = p5.Vector.setMag(v0, 10);\n// Prints \"5\" to the console.\nprint(v0.mag());\n// Prints \"p5.Vector Object : [6, 8, 0]\" to the console.\nprint(v1.toString());\n
\n\nfunction draw() {\n background(240);\n\n let origin = createVector(0, 0);\n let v = createVector(50, 50);\n\n drawArrow(origin, v, 'red');\n\n v.setMag(30);\n drawArrow(origin, v, 'blue');\n\n describe('Two arrows extend from the top left corner of a square toward its center. The red arrow reaches the center and the blue arrow only extends part of the way.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nCalculates the angle a 2D vector makes with the positive x-axis. Angles\nincrease in the clockwise direction.
\nIf the vector was created with\ncreateVector(), heading()
returns angles\nin the units of the current angleMode().
The static version of heading()
, as in p5.Vector.heading(v)
, works the\nsame way.
\nlet v = createVector(1, 1);\n// Prints \"0.785...\" to the console.\nprint(v.heading());\n\nangleMode(DEGREES);\n// Prints \"45\" to the console.\nprint(v.heading());\n
\n\nlet v = createVector(1, 1);\n// Prints \"0.785...\" to the console.\nprint(p5.Vector.heading(v));\n\nangleMode(DEGREES);\n// Prints \"45\" to the console.\nprint(p5.Vector.heading(v));\n
\n\nfunction draw() {\n background(200);\n\n let origin = createVector(0, 0);\n let v = createVector(50, 50);\n\n drawArrow(origin, v, 'black');\n\n angleMode(RADIANS);\n let h = round(v.heading(), 2);\n text(`Radians: ${h}`, 20, 70);\n angleMode(DEGREES);\n h = v.heading();\n text(`Degrees: ${h}`, 20, 85);\n\n describe('A black arrow extends from the top left of a square to its center. The text \"Radians: 0.79\" and \"Degrees: 45\" is written near the tip of the arrow.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nRotates a 2D vector to a specific angle without changing its magnitude.\nBy convention, the positive x-axis has an angle of 0. Angles increase in\nthe clockwise direction.
\nIf the vector was created with\ncreateVector(), setHeading()
uses\nthe units of the current angleMode().
\nlet v = createVector(0, 1);\n// Prints \"1.570...\" to the console.\nprint(v.heading());\n\nv.setHeading(PI);\n// Prints \"3.141...\" to the console.\nprint(v.heading());\n
\n\nangleMode(DEGREES);\nlet v = createVector(0, 1);\n// Prints \"90\" to the console.\nprint(v.heading());\n\nv.setHeading(180);\n// Prints \"180\" to the console.\nprint(v.heading());\n
\n\nfunction draw() {\n background(200);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(30, 0);\n\n drawArrow(v0, v1, 'red');\n\n v1.setHeading(HALF_PI);\n drawArrow(v0, v1, 'blue');\n\n describe('Two arrows extend from the center of a gray square. The red arrow points to the right and the blue arrow points down.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nRotates a 2D vector by an angle without changing its magnitude.\nBy convention, the positive x-axis has an angle of 0. Angles increase in\nthe clockwise direction.
\nIf the vector was created with\ncreateVector(), rotate()
uses\nthe units of the current angleMode().
The static version of rotate()
, as in p5.Vector.rotate(v, PI)
,\nreturns a new p5.Vector object and doesn't change\nthe original.
\nlet v = createVector(1, 0);\n// Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\nprint(v.toString());\nv.rotate(HALF_PI);\n// Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\nprint(v.toString());\n
\n\nangleMode(DEGREES);\nlet v = createVector(1, 0);\n// Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\nprint(v.toString());\nv.rotate(90);\n// Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\nprint(v.toString());\n
\n\nlet v0 = createVector(1, 0);\nlet v1 = p5.Vector.rotate(v0, HALF_PI);\n// Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\nprint(v0.toString());\n// Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\nprint(v1.toString());\n
\n\nangleMode(DEGREES);\nlet v0 = createVector(1, 0);\nlet v1 = p5.Vector.rotate(v0, 90);\n// Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\nprint(v0.toString());\n// Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\nprint(v1.toString());\n
\n\nlet v0;\nlet v1;\n\nfunction setup() {\n v0 = createVector(50, 50);\n v1 = createVector(30, 0);\n}\n\nfunction draw() {\n background(240);\n\n v1.rotate(0.01);\n\n drawArrow(v0, v1, 'black');\n\n describe('A black arrow extends from the center of a gray square. The arrow rotates counterclockwise.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nReturns the angle between two vectors. The angles returned are signed,\nwhich means that v1.angleBetween(v2) === -v2.angleBetween(v1)
.
If the vector was created with\ncreateVector(), angleBetween()
returns\nangles in the units of the current\nangleMode().
\nlet v0 = createVector(1, 0);\nlet v1 = createVector(0, 1);\n// Prints \"1.570...\" to the console.\nprint(v0.angleBetween(v1));\n// Prints \"-1.570...\" to the console.\nprint(v1.angleBetween(v0));\n
\n\nangleMode(DEGREES);\nlet v0 = createVector(1, 0);\nlet v1 = createVector(0, 1);\n// Prints \"90\" to the console.\nprint(v0.angleBetween(v1));\n// Prints \"-90\" to the console.\nprint(v1.angleBetween(v0));\n
\n\nlet v0 = createVector(1, 0);\nlet v1 = createVector(0, 1);\n// Prints \"1.570...\" to the console.\nprint(p5.Vector.angleBetween(v0, v1));\n// Prints \"-1.570...\" to the console.\nprint(p5.Vector.angleBetween(v1, v0));\n
\n\nangleMode(DEGREES);\nlet v0 = createVector(1, 0);\nlet v1 = createVector(0, 1);\n// Prints \"90\" to the console.\nprint(p5.Vector.angleBetween(v0, v1));\n// Prints \"-90\" to the console.\nprint(p5.Vector.angleBetween(v1, v0));\n
\n\nfunction draw() {\n background(200);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(30, 0);\n let v2 = createVector(0, 30);\n\n drawArrow(v0, v1, 'red');\n drawArrow(v0, v2, 'blue');\n\n angleMode(RADIANS);\n let angle = round(v1.angleBetween(v2), 2);\n text(`Radians: ${angle}`, 20, 20);\n angleMode(DEGREES);\n angle = round(v1.angleBetween(v2), 2);\n text(`Degrees: ${angle}`, 20, 35);\n\n describe('Two arrows extend from the center of a gray square. A red arrow points to the right and a blue arrow points down. The text \"Radians: 1.57\" and \"Degrees: 90\" is written above the arrows.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nCalculates new x
, y
, and z
components that are proportionally the\nsame distance between two vectors. The amt
parameter is the amount to\ninterpolate between the old vector and the new vector. 0.0 keeps all\ncomponents equal to the old vector's, 0.5 is halfway between, and 1.0 sets\nall components equal to the new vector's.
The static version of lerp()
, as in p5.Vector.lerp(v0, v1, 0.5)
,\nreturns a new p5.Vector object and doesn't change\nthe original.
\nlet v0 = createVector(1, 1, 1);\nlet v1 = createVector(3, 3, 3);\nv0.lerp(v1, 0.5);\n// Prints \"p5.Vector Object : [2, 2, 2]\" to the console.\nprint(v0.toString());\n
\n\nlet v = createVector(1, 1, 1);\nv.lerp(3, 3, 3, 0.5);\n// Prints \"p5.Vector Object : [2, 2, 2]\" to the console.\nprint(v.toString());\n
\n\nlet v0 = createVector(1, 1, 1);\nlet v1 = createVector(3, 3, 3);\nlet v2 = p5.Vector.lerp(v0, v1, 0.5);\n// Prints \"p5.Vector Object : [2, 2, 2]\" to the console.\nprint(v2.toString());\n
\n\nfunction draw() {\n background(200);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(30, 0);\n let v2 = createVector(0, 30);\n let v3 = p5.Vector.lerp(v1, v2, 0.5);\n\n drawArrow(v0, v1, 'red');\n drawArrow(v0, v2, 'blue');\n drawArrow(v0, v3, 'purple');\n\n describe('Three arrows extend from the center of a gray square. A red arrow points to the right, a blue arrow points down, and a purple arrow points to the bottom right.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nCalculates a new heading and magnitude that are between two vectors. The\namt
parameter is the amount to interpolate between the old vector and\nthe new vector. 0.0 keeps the heading and magnitude equal to the old\nvector's, 0.5 sets them halfway between, and 1.0 sets the heading and\nmagnitude equal to the new vector's.
slerp()
differs from lerp() because\nit interpolates magnitude. Calling v0.slerp(v1, 0.5)
sets v0
's\nmagnitude to a value halfway between its original magnitude and v1
's.\nCalling v0.lerp(v1, 0.5)
makes no such guarantee.
The static version of slerp()
, as in p5.Vector.slerp(v0, v1, 0.5)
,\nreturns a new p5.Vector object and doesn't change\nthe original.
\nlet v0 = createVector(3, 0);\n// Prints \"3\" to the console.\nprint(v0.mag());\n// Prints \"0\" to the console.\nprint(v0.heading());\n\nlet v1 = createVector(0, 1);\n// Prints \"1\" to the console.\nprint(v1.mag());\n// Prints \"1.570...\" to the console.\nprint(v1.heading());\n\nv0.slerp(v1, 0.5);\n// Prints \"2\" to the console.\nprint(v0.mag());\n// Prints \"0.785...\" to the console.\nprint(v0.heading());\n
\n\nlet v0 = createVector(3, 0);\n// Prints \"3\" to the console.\nprint(v0.mag());\n// Prints \"0\" to the console.\nprint(v0.heading());\n\nlet v1 = createVector(0, 1);\n// Prints \"1\" to the console.\nprint(v1.mag());\n// Prints \"1.570...\" to the console.\nprint(v1.heading());\n\nlet v3 = p5.Vector.slerp(v0, v1, 0.5);\n// Prints \"2\" to the console.\nprint(v3.mag());\n// Prints \"0.785...\" to the console.\nprint(v3.heading());\n
\n\nfunction draw() {\n background(200);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(20, 0);\n let v2 = createVector(-40, 0);\n let v3 = p5.Vector.slerp(v1, v2, 0.5);\n\n drawArrow(v0, v1, 'red');\n drawArrow(v0, v2, 'blue');\n drawArrow(v0, v3, 'purple');\n\n describe('Three arrows extend from the center of a gray square. A red arrow points to the right, a blue arrow points to the left, and a purple arrow points down.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\nReflects a vector about a line in 2D or a plane in 3D. The orientation of\nthe line or plane is described by a normal vector that points away from the\nshape.
\nThe static version of reflect()
, as in p5.Vector.reflect(v, n)
,\nreturns a new p5.Vector object and doesn't change\nthe original.
\nlet n = createVector(0, 1);\nlet v = createVector(4, 6);\nv.reflect(n);\n// Prints \"p5.Vector Object : [4, -6, 0]\" to the console.\nprint(v.toString());\n
\n\nlet n = createVector(0, 1);\nlet v0 = createVector(4, 6);\nlet v1 = p5.Vector.reflect(v0, n);\n// Prints \"p5.Vector Object : [4, -6, 0]\" to the console.\nprint(v1.toString());\n
\n\nfunction draw() {\n background(200);\n\n line(50, 0, 50, 100);\n let n = createVector(1, 0);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(30, 40);\n let v2 = p5.Vector.reflect(v1, n);\n\n n.setMag(30);\n drawArrow(v0, n, 'black');\n drawArrow(v0, v1, 'red');\n drawArrow(v0, v2, 'blue');\n\n describe('Three arrows extend from the center of a gray square with a vertical line down its middle. A black arrow points to the right, a blue arrow points to the bottom left, and a red arrow points to the bottom right.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n\nlet v = createVector(20, 30);\n// Prints \"[20, 30, 0]\" to the console.\nprint(v.array());\n
\nReturns true
if the vector's components are all the same as another\nvector's and false
if not.
The version of equals()
with one parameter interprets it as another\np5.Vector object.
The version of equals()
with multiple parameters interprets them as the\ncomponents of another vector. Any missing parameters are assigned the value\n0.
The static version of equals()
, as in p5.Vector.equals(v0, v1)
,\ninterprets both parameters as p5.Vector objects.
\nlet v0 = createVector(10, 20, 30);\nlet v1 = createVector(10, 20, 30);\nlet v2 = createVector(0, 0, 0);\n\n// Prints \"true\" to the console.\nprint(v0.equals(v1));\n// Prints \"false\" to the console.\nprint(v0.equals(v2));\n
\n\nlet v0 = createVector(5, 10, 20);\nlet v1 = createVector(5, 10, 20);\nlet v2 = createVector(13, 10, 19);\n\n// Prints \"true\" to the console.\nprint(v0.equals(v1.x, v1.y, v1.z));\n// Prints \"false\" to the console.\nprint(v0.equals(v2.x, v2.y, v2.z));\n
\n\nlet v0 = createVector(10, 20, 30);\nlet v1 = createVector(10, 20, 30);\nlet v2 = createVector(0, 0, 0);\n\n// Prints \"true\" to the console.\nprint(p5.Vector.equals(v0, v1));\n// Prints \"false\" to the console.\nprint(p5.Vector.equals(v0, v2));\n
\n\nlet v = p5.Vector.fromAngle(0);\n// Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\nprint(v.toString());\n
\n\nfunction draw() {\n background(200);\n\n let v0 = createVector(50, 50);\n let v1 = p5.Vector.fromAngle(0, 30);\n\n drawArrow(v0, v1, 'black');\n\n describe('A black arrow extends from the center of a gray square. It points to the right.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n\nlet v = p5.Vector.fromAngles(0, 0);\n// Prints \"p5.Vector Object : [0, -1, 0]\" to the console.\nprint(v.toString());\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(0);\n\n fill(255);\n noStroke();\n\n let theta = frameCount * 0.05;\n let phi = 0;\n let v = p5.Vector.fromAngles(theta, phi, 100);\n let c = color('deeppink');\n pointLight(c, v);\n\n sphere(35);\n\n describe('A light shines on a pink sphere as it orbits.');\n}\n
\n\nlet v = p5.Vector.random2D();\n// Prints \"p5.Vector Object : [x, y, 0]\" to the console\n// where x and y are small random numbers.\nprint(v.toString());\n
\n\nfunction draw() {\n background(200);\n\n frameRate(1);\n\n let v0 = createVector(50, 50);\n let v1 = p5.Vector.random2D();\n v1.mult(30);\n drawArrow(v0, v1, 'black');\n\n describe('A black arrow in extends from the center of a gray square. It changes direction once per second.');\n}\n\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n\nlet v = p5.Vector.random3D();\n// Prints \"p5.Vector Object : [x, y, z]\" to the console\n// where x, y, and z are small random numbers.\nprint(v.toString());\n
\nReturns the bounding box for a string of text written using this\np5.Font.
\nThe first parameter, str
, is a string of text. The second and third\nparameters, x
and y
, are the text's position. By default, they set the\ncoordinates of the bounding box's bottom-left corner. See\ntextAlign() for more ways to align text.
The fourth parameter, fontSize
, is optional. It sets the font size used to\ndetermine the bounding box. By default, font.textBounds()
will use the\ncurrent textSize().
\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n background(200);\n\n let bbox = font.textBounds('p5*js', 35, 53);\n rect(bbox.x, bbox.y, bbox.w, bbox.h);\n\n textFont(font);\n text('p5*js', 35, 53);\n\n describe('The text \"p5*js\" written in black inside a white rectangle.');\n}\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n background(200);\n\n textFont(font);\n textSize(15);\n textAlign(CENTER, CENTER);\n\n let bbox = font.textBounds('p5*js', 50, 50);\n rect(bbox.x, bbox.y, bbox.w, bbox.h);\n\n text('p5*js', 50, 50);\n\n describe('The text \"p5*js\" written in black inside a white rectangle.');\n}\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n background(200);\n\n let bbox = font.textBounds('p5*js', 31, 53, 15);\n rect(bbox.x, bbox.y, bbox.w, bbox.h);\n\n textFont(font);\n textSize(15);\n text('p5*js', 31, 53);\n\n describe('The text \"p5*js\" written in black inside a white rectangle.');\n}\n
\nReturns an array of points outlining a string of text written using this\np5.Font.
\nThe first parameter, str
, is a string of text. The second and third\nparameters, x
and y
, are the text's position. By default, they set the\ncoordinates of the bounding box's bottom-left corner. See\ntextAlign() for more ways to align text.
The fourth parameter, fontSize
, is optional. It sets the text's font\nsize. By default, font.textToPoints()
will use the current\ntextSize().
The fifth parameter, options
, is also optional. font.textToPoints()
\nexpects an object with the following properties:
sampleFactor
is the ratio of the text's path length to the number of\nsamples. It defaults to 0.1. Higher values produce more points along the\npath and are more precise.
simplifyThreshold
removes collinear points if it's set to a number other\nthan 0. The value represents the threshold angle to use when determining\nwhether two edges are collinear.
\nlet font;\n\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n background(200);\n let points = font.textToPoints('p5*js', 6, 60, 35, { sampleFactor: 0.5 });\n points.forEach(p => {\n point(p.x, p.y);\n });\n\n describe('A set of black dots outlining the text \"p5*js\" on a gray background.');\n}\n
\n\n// drag the mouse to look around!\n\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n // create a camera\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n // give it a perspective projection\n cam.perspective(PI / 3.0, width / height, 0.1, 500);\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateX(-0.3);\n rotateY(-0.2);\n translate(0, 0, -50);\n\n push();\n translate(-15, 0, sin(frameCount / 30) * 65);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 65);\n box(30);\n pop();\n}\n
\n\n// drag the mouse to look around!\n// there's no vanishing point\n\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n // create a camera\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n // give it an orthographic projection\n cam.ortho(-width / 2, width / 2, height / 2, -height / 2, 0, 500);\n}\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateX(0.2);\n rotateY(-0.2);\n push();\n translate(-15, 0, sin(frameCount / 30) * 65);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 65);\n box(30);\n pop();\n}\n
\n\nlet cam;\n\nfunction setup() {\n x = createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n // create a camera\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n // set its frustum\n cam.frustum(-0.1, 0.1, -0.1, 0.1, 0.1, 200);\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateY(-0.2);\n rotateX(-0.3);\n push();\n translate(-15, 0, sin(frameCount / 30) * 25);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 25);\n box(30);\n pop();\n}\n
\n\nlet cam;\nlet delta = 0.01;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // set initial pan angle\n cam.pan(-0.8);\n}\n\nfunction draw() {\n background(200);\n\n // pan camera according to angle 'delta'\n cam.pan(delta);\n\n // every 160 frames, switch direction\n if (frameCount % 160 === 0) {\n delta *= -1;\n }\n\n rotateX(frameCount * 0.01);\n translate(-100, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n}\n
\n\nlet cam;\nlet delta = 0.01;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // set initial tilt\n cam.tilt(-0.8);\n}\n\nfunction draw() {\n background(200);\n\n // pan camera according to angle 'delta'\n cam.tilt(delta);\n\n // every 160 frames, switch direction\n if (frameCount % 160 === 0) {\n delta *= -1;\n }\n\n rotateY(frameCount * 0.01);\n translate(0, -100, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n}\n
\n\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n}\n\nfunction draw() {\n background(200);\n\n // look at a new random point every 60 frames\n if (frameCount % 60 === 0) {\n cam.lookAt(random(-100, 100), random(-50, 50), 0);\n }\n\n rotateX(frameCount * 0.01);\n translate(-100, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n}\n
\n\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n // Create a camera.\n // createCamera() sets the newly created camera as\n // the current (active) camera.\n cam = createCamera();\n}\n\nfunction draw() {\n background(204);\n // Move the camera away from the plane by a sin wave\n cam.camera(0, 0, 20 + sin(frameCount * 0.01) * 10, 0, 0, 0, 0, 1, 0);\n plane(10, 10);\n}\n
\n\n// move slider to see changes!\n// sliders control the first 6 parameters of camera()\n\nlet sliderGroup = [];\nlet X;\nlet Y;\nlet Z;\nlet centerX;\nlet centerY;\nlet centerZ;\nlet h = 20;\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n // create a camera\n cam = createCamera();\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // create sliders\n for (var i = 0; i < 6; i++) {\n if (i === 2) {\n sliderGroup[i] = createSlider(10, 400, 200);\n } else {\n sliderGroup[i] = createSlider(-400, 400, 0);\n }\n h = map(i, 0, 6, 5, 85);\n sliderGroup[i].position(10, height + h);\n sliderGroup[i].style('width', '80px');\n }\n}\n\nfunction draw() {\n background(60);\n // assigning sliders' value to each parameters\n X = sliderGroup[0].value();\n Y = sliderGroup[1].value();\n Z = sliderGroup[2].value();\n centerX = sliderGroup[3].value();\n centerY = sliderGroup[4].value();\n centerZ = sliderGroup[5].value();\n cam.camera(X, Y, Z, centerX, centerY, centerZ, 0, 1, 0);\n stroke(255);\n fill(255, 102, 94);\n box(85);\n}\n
\n\n// see the camera move along its own axes while maintaining its orientation\nlet cam;\nlet delta = 0.5;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n}\n\nfunction draw() {\n background(200);\n\n // move the camera along its local axes\n cam.move(delta, delta, 0);\n\n // every 100 frames, switch direction\n if (frameCount % 150 === 0) {\n delta *= -1;\n }\n\n translate(-10, -10, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n}\n
\n\n// press '1' '2' or '3' keys to set camera position\n\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n}\n\nfunction draw() {\n background(200);\n\n // '1' key\n if (keyIsDown(49)) {\n cam.setPosition(30, 0, 80);\n }\n // '2' key\n if (keyIsDown(50)) {\n cam.setPosition(0, 0, 80);\n }\n // '3' key\n if (keyIsDown(51)) {\n cam.setPosition(-30, 0, 80);\n }\n\n box(20);\n}\n
\n\nlet cam, initialCam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n strokeWeight(3);\n\n // Set the initial state to initialCamera and set it to the camera\n // used for drawing. Then set cam to be the active camera.\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n initialCam = createCamera();\n initialCam.camera(100, 100, 100, 0, 0, 0, 0, 0, -1);\n initialCam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n cam.set(initialCam);\n\n setCamera(cam);\n}\n\nfunction draw() {\n orbitControl();\n background(255);\n box(50);\n translate(0, 0, -25);\n plane(100);\n}\n\nfunction doubleClicked(){\n // Double-click to return the camera to its initial position.\n cam.set(initialCam);\n}\n
\n\nlet cam0, cam1, cam;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n strokeWeight(3);\n\n // camera for slerp.\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // cam0 is looking at the cube from the front.\n cam0 = createCamera();\n cam0.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam0.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // cam1 is pointing straight to the right in the cube\n // at the same position as cam0 by doing a pan(-PI/2).\n cam1 = createCamera();\n cam1.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam1.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n cam1.pan(-PI/2);\n\n // we only use cam.\n setCamera(cam);\n}\n\nfunction draw() {\n // calculate amount.\n const amt = 0.5 - 0.5 * cos(frameCount * TAU / 120);\n // slerp cam0 and cam1 with amt, set to cam.\n // When amt moves from 0 to 1, cam moves from cam0 to cam1,\n // shaking the camera to the right.\n cam.slerp(cam0, cam1, amt);\n\n background(255);\n // Every time the camera turns right, the cube drifts left.\n box(40);\n}\n
\n\nlet cam, lastCam, initialCam;\nlet countForReset = 30;\n// This sample uses orbitControl() to move the camera.\n// Double-clicking the canvas restores the camera to its initial state.\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n strokeWeight(3);\n\n // main camera\n cam = createCamera();\n cam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n cam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // Camera for recording loc info before reset\n lastCam = createCamera();\n lastCam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n lastCam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n // Camera for recording the initial state\n initialCam = createCamera();\n initialCam.camera(0, 0, 50*sqrt(3), 0, 0, 0, 0, 1, 0);\n initialCam.perspective(PI/3, 1, 5*sqrt(3), 500*sqrt(3));\n\n setCamera(cam); // set main camera\n}\n\nfunction draw() {\n if (countForReset < 30) {\n // if the reset count is less than 30,\n // it will move closer to the original camera as it increases.\n countForReset++;\n cam.slerp(lastCam, initialCam, countForReset / 30);\n } else {\n // if the count is 30,\n // you can freely move the main camera with orbitControl().\n orbitControl();\n }\n\n background(255);\n box(40);\n}\n// A double-click sets countForReset to 0 and initiates a reset.\nfunction doubleClicked() {\n if (countForReset === 30) {\n countForReset = 0;\n lastCam.set(cam);\n }\n}\n
\n\nlet framebuffer;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n framebuffer = createFramebuffer();\n noStroke();\n}\n\nfunction mouseMoved() {\n framebuffer.resize(\n max(20, mouseX),\n max(20, mouseY)\n );\n}\n\nfunction draw() {\n // Draw to the framebuffer\n framebuffer.begin();\n background(255);\n normalMaterial();\n sphere(20);\n framebuffer.end();\n\n background(100);\n // Draw the framebuffer to the main canvas\n image(framebuffer, -width/2, -height/2);\n}\n
\nGets or sets the pixel scaling for high pixel density displays. By\ndefault, the density will match that of the canvas the framebuffer was\ncreated on, which will match the display density.
\nCall this method with no arguments to get the current density, or pass\nin a number to set the density.
\n", + "example": [], + "overloads": [ + { + "params": [ + { + "name": "density", + "description": "A scaling factor for the number of pixels per\nside of the framebuffer", + "optional": 1, + "type": "Number" + } + ] + } + ], + "class": "p5.Framebuffer", + "static": false, + "module": "Rendering" + }, + { + "name": "autoSized", + "file": "src/webgl/p5.Framebuffer.js", + "line": 243, + "itemtype": "method", + "description": "Gets or sets whether or not this framebuffer will automatically resize\nalong with the canvas it's attached to in order to match its size.
\nCall this method with no arguments to see if it is currently auto-sized,\nor pass in a boolean to set this property.
\n", + "example": [], + "overloads": [ + { + "params": [ + { + "name": "autoSized", + "description": "Whether or not the framebuffer should resize\nalong with the canvas it's attached to", + "optional": 1, + "type": "Boolean" + } + ] + } + ], + "class": "p5.Framebuffer", + "static": false, + "module": "Rendering" + }, + { + "name": "createCamera", + "file": "src/webgl/p5.Framebuffer.js", + "line": 681, + "itemtype": "method", + "description": "Creates and returns a new\np5.FramebufferCamera to be used\nwhile drawing to this framebuffer. The camera will be set as the\ncurrently active camera.", + "example": [], + "overloads": [ + { + "params": [], + "return": { + "description": "A new camera", + "type": "p5.Camera" + } + } + ], + "return": { + "description": "A new camera", + "type": "p5.Camera" + }, + "class": "p5.Framebuffer", + "static": false, + "module": "Rendering" + }, + { + "name": "remove", + "file": "src/webgl/p5.Framebuffer.js", + "line": 745, + "itemtype": "method", + "description": "Removes the framebuffer and frees its resources.", + "example": [ + "\nlet framebuffer;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n const useFramebuffer = (frameCount % 120) > 60;\n if (useFramebuffer && !framebuffer) {\n // Create a new framebuffer for us to use\n framebuffer = createFramebuffer();\n } else if (!useFramebuffer && framebuffer) {\n // Free the old framebuffer's resources\n framebuffer.remove();\n framebuffer = undefined;\n }\n\n background(255);\n if (useFramebuffer) {\n // Draw to the framebuffer\n framebuffer.begin();\n background(255);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n fill(255, 0, 0);\n box(30);\n framebuffer.end();\n\n image(framebuffer, -width/2, -height/2);\n }\n}\n
\n\nlet framebuffer;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n framebuffer = createFramebuffer();\n noStroke();\n}\n\nfunction draw() {\n // Draw to the framebuffer\n framebuffer.begin();\n background(255);\n translate(0, 10*sin(frameCount * 0.01), 0);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n fill(255, 0, 0);\n box(50);\n framebuffer.end();\n\n background(100);\n // Draw the framebuffer to the main canvas\n image(framebuffer, -50, -50, 25, 25);\n image(framebuffer, 0, 0, 35, 35);\n}\n
\nframebuffer.begin()
, running the function,\nand then calling framebuffer.end()
, but ensures that one never\naccidentally forgets begin
or end
.",
+ "example": [
+ "\nlet framebuffer;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n framebuffer = createFramebuffer();\n noStroke();\n}\n\nfunction draw() {\n // Draw to the framebuffer\n framebuffer.draw(function() {\n background(255);\n translate(0, 10*sin(frameCount * 0.01), 0);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n fill(255, 0, 0);\n box(50);\n });\n\n background(100);\n // Draw the framebuffer to the main canvas\n image(framebuffer, -50, -50, 25, 25);\n image(framebuffer, 0, 0, 35, 35);\n}\n
\nGet a region of pixels from the canvas in the form of a\np5.Image, or a single pixel as an array of\nnumbers.
\nReturns an array of [R,G,B,A] values for any pixel or grabs a section of\nan image. If the Framebuffer has been set up to not store alpha values, then\nonly [R,G,B] will be returned. If no parameters are specified, the entire\nimage is returned.\nUse the x and y parameters to get the value of one pixel. Get a section of\nthe display window by specifying additional w and h parameters. When\ngetting an image, the x and y parameters define the coordinates for the\nupper-left corner of the image, regardless of the current imageMode().
\n", + "example": [], + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the pixel", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the pixel", + "type": "Number" + }, + { + "name": "w", + "description": "width of the section to be returned", + "type": "Number" + }, + { + "name": "h", + "description": "height of the section to be returned", + "type": "Number" + } + ], + "return": { + "description": "the rectangle p5.Image", + "type": "p5.Image" + } + }, + { + "params": [], + "return": { + "description": "the whole p5.Image", + "type": "p5.Image" + } + }, + { + "params": [ + { + "name": "x", + "type": "Number" + }, + { + "name": "y", + "type": "Number" + } + ], + "return": { + "description": "color of pixel at x,y in array format [R, G, B, A]", + "type": "Number[]" + } + } + ], + "return": { + "description": "the rectangle p5.Image", + "type": "p5.Image" + }, + "class": "p5.Framebuffer", + "static": false, + "module": "Rendering" + }, + { + "name": "updatePixels", + "file": "src/webgl/p5.Framebuffer.js", + "line": 1168, + "itemtype": "method", + "description": "Call this after initially calling \nloadPixels() and updating pixels\nto replace the content of the framebuffer with the data in the pixels\narray.
\nThis will also clear the depth buffer so that any future drawing done\nafterwards will go on top.
\n", + "example": [ + "\nlet framebuffer;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n framebuffer = createFramebuffer();\n}\n\nfunction draw() {\n noStroke();\n lights();\n\n // Draw a sphere to the framebuffer\n framebuffer.begin();\n background(0);\n sphere(25);\n framebuffer.end();\n\n // Load its pixels and draw a gradient over the lower half of the canvas\n framebuffer.loadPixels();\n for (let y = height/2; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const idx = (y * width + x) * 4;\n framebuffer.pixels[idx] = (x / width) * 255;\n framebuffer.pixels[idx + 1] = (y / height) * 255;\n framebuffer.pixels[idx + 2] = 255;\n framebuffer.pixels[idx + 3] = 255;\n }\n }\n framebuffer.updatePixels();\n\n // Draw a cube on top of the pixels we just wrote\n framebuffer.begin();\n push();\n translate(20, 20);\n rotateX(0.5);\n rotateY(0.5);\n box(20);\n pop();\n framebuffer.end();\n\n image(framebuffer, -width/2, -height/2);\n noLoop();\n}\n
\nclearColors()
, you can use fill()
to supply new colors before drawing each shape.\nIf clearColors()
is not used, the shapes will use their internal colors by ignoring fill()
.",
+ "example": [
+ "\nlet shape01;\nlet shape02;\nlet points = [];\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n points.push(new p5.Vector(-1, -1, 0), new p5.Vector(-1, 1, 0),\n new p5.Vector(1, -1, 0), new p5.Vector(-1, -1, 0));\n buildShape01();\n buildShape02();\n}\nfunction draw() {\n background(0);\n fill('pink'); // shape01 retains its internal blue color, so it won't turn pink.\n model(shape01);\n fill('yellow'); // Now, shape02 is yellow.\n model(shape02);\n}\n\nfunction buildShape01() {\n beginGeometry();\n fill('blue'); // shape01's color is blue because its internal colors remain.\n beginShape();\n for (let vec of points) vertex(vec.x * 100, vec.y * 100, vec.z * 100);\n endShape(CLOSE);\n shape01 = endGeometry();\n}\n\nfunction buildShape02() {\n beginGeometry();\n fill('red'); // shape02.clearColors() removes its internal colors. Now, shape02 is red.\n beginShape();\n for (let vec of points) vertex(vec.x * 200, vec.y * 200, vec.z * 200);\n endShape(CLOSE);\n shape02 = endGeometry();\n shape02.clearColors(); // Resets shape02's colors.\n}\n
\nThis function calculates normals for each face, where each vertex's normal is the average of the normals of all faces it's connected to.\ni.e computes smooth normals per vertex as an average of each face.
\nWhen using FLAT
shading, vertices are disconnected/duplicated i.e each face has its own copy of vertices.\nWhen using SMOOTH
shading, vertices are connected/deduplicated i.e each face has its vertices shared with other faces.
Options can include:
\nroundToPrecision
: Precision value for rounding computations. Defaults to 3.\nlet helix;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n helix = buildGeometry(() => {\n beginShape();\n\n for (let i = 0; i < TWO_PI * 3; i += 0.6) {\n let radius = 20;\n let x = cos(i) * radius;\n let y = sin(i) * radius;\n let z = map(i, 0, TWO_PI * 3, -30, 30);\n vertex(x, y, z);\n }\n endShape();\n });\n helix.computeNormals();\n}\nfunction draw() {\n background(255);\n stroke(0);\n fill(150, 200, 250);\n lights();\n rotateX(PI*0.2);\n orbitControl();\n model(helix);\n}\n
\n\nlet star;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n star = buildGeometry(() => {\n beginShape();\n for (let i = 0; i < TWO_PI; i += PI / 5) {\n let outerRadius = 60;\n let innerRadius = 30;\n let xOuter = cos(i) * outerRadius;\n let yOuter = sin(i) * outerRadius;\n let zOuter = random(-20, 20);\n vertex(xOuter, yOuter, zOuter);\n\n let nextI = i + PI / 5 / 2;\n let xInner = cos(nextI) * innerRadius;\n let yInner = sin(nextI) * innerRadius;\n let zInner = random(-20, 20);\n vertex(xInner, yInner, zInner);\n }\n endShape(CLOSE);\n });\n star.computeNormals(SMOOTH);\n}\nfunction draw() {\n background(255);\n stroke(0);\n fill(150, 200, 250);\n lights();\n rotateX(PI*0.2);\n orbitControl();\n model(star);\n}\n
\nFLAT
for flat shading or SMOOTH
for smooth shading) for buildGeometry() outputs. Defaults to FLAT
.",
+ "optional": 1,
+ "type": "String"
+ },
+ {
+ "name": "options",
+ "description": "An optional object with configuration.",
+ "optional": 1,
+ "type": "Object"
+ }
+ ]
+ }
+ ],
+ "class": "p5.Geometry",
+ "static": false,
+ "module": "Shape",
+ "submodule": "3D Primitives"
+ },
+ {
+ "name": "averageNormals",
+ "file": "src/webgl/p5.Geometry.js",
+ "line": 503,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Averages the vertex normals. Used in curved\nsurfaces",
+ "example": [],
+ "overloads": [
+ {
+ "params": []
+ }
+ ],
+ "class": "p5.Geometry",
+ "static": false,
+ "module": "Shape",
+ "submodule": "3D Primitives"
+ },
+ {
+ "name": "averagePoleNormals",
+ "file": "src/webgl/p5.Geometry.js",
+ "line": 522,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Averages pole normals. Used in spherical primitives",
+ "example": [],
+ "overloads": [
+ {
+ "params": []
+ }
+ ],
+ "class": "p5.Geometry",
+ "static": false,
+ "module": "Shape",
+ "submodule": "3D Primitives"
+ },
+ {
+ "name": "normalize",
+ "file": "src/webgl/p5.Geometry.js",
+ "line": 831,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Modifies all vertices to be centered within the range -100 to 100.",
+ "example": [],
+ "overloads": [
+ {
+ "params": []
+ }
+ ],
+ "class": "p5.Geometry",
+ "static": false,
+ "module": "Shape",
+ "submodule": "3D Primitives"
+ },
+ {
+ "name": "copyToContext",
+ "file": "src/webgl/p5.Shader.js",
+ "line": 127,
+ "itemtype": "method",
+ "description": "Shaders belong to the main canvas or a p5.Graphics. Once they are compiled,\nthey can only be used in the context they were compiled on.
\nUse this method to make a new copy of a shader that gets compiled on a\ndifferent context.
\n", + "example": [ + "\nlet graphic = createGraphics(200, 200, WEBGL);\nlet graphicShader = graphic.createShader(vert, frag);\ngraphic.shader(graphicShader); // Use graphicShader on the graphic\n\nlet mainShader = graphicShader.copyToContext(window);\nshader(mainShader); // Use `mainShader` on the main canvas\n
\nwindow
if you need to copy to the main canvas.",
+ "type": "p5|p5.Graphics"
+ }
+ ],
+ "return": {
+ "description": "A new shader on the target context.",
+ "type": "p5.Shader"
+ }
+ }
+ ],
+ "return": {
+ "description": "A new shader on the target context.",
+ "type": "p5.Shader"
+ },
+ "class": "p5.Shader",
+ "static": false,
+ "module": "3D",
+ "submodule": "Material"
+ },
+ {
+ "name": "setUniform",
+ "file": "src/webgl/p5.Shader.js",
+ "line": 438,
+ "itemtype": "method",
+ "chainable": 1,
+ "description": "Used to set the uniforms of a\np5.Shader object.
\nUniforms are used as a way to provide shader programs\n(which run on the GPU) with values from a sketch\n(which runs on the CPU).
\nHere are some examples of uniforms you can make:
\nbooleans
\nsetUniform('x', true)
becomes uniform float x
with the value 1.0
numbers
\nsetUniform('x', -2)
becomes uniform float x
with the value -2.0
arrays of numbers
\nsetUniform('x', [0, 0.5, 1])
becomes uniform vec3 x
with the value vec3(0.0, 0.5, 1.0)
a p5.Image, p5.Graphics, p5.MediaElement, or p5.Texture
\nsetUniform('x', img)
becomes uniform sampler2D x
\n// Click within the image to toggle the value of uniforms\n// Note: for an alternative approach to the same example,\n// involving toggling between shaders please refer to:\n// https://p5js.org/reference/#/p5/shader\n\nlet grad;\nlet showRedGreen = false;\n\nfunction preload() {\n // note that we are using two instances\n // of the same vertex and fragment shaders\n grad = loadShader('assets/shader.vert', 'assets/shader-gradient.frag');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n shader(grad);\n noStroke();\n\n describe(\n 'canvas toggles between a circular gradient of orange and blue vertically. and a circular gradient of red and green moving horizontally when mouse is clicked/pressed.'\n );\n}\n\nfunction draw() {\n // update the offset values for each scenario,\n // moving the \"grad\" shader in either vertical or\n // horizontal direction each with differing colors\n\n if (showRedGreen === true) {\n grad.setUniform('colorCenter', [1, 0, 0]);\n grad.setUniform('colorBackground', [0, 1, 0]);\n grad.setUniform('offset', [sin(millis() / 2000), 1]);\n } else {\n grad.setUniform('colorCenter', [1, 0.5, 0]);\n grad.setUniform('colorBackground', [0.226, 0, 0.615]);\n grad.setUniform('offset', [0, sin(millis() / 2000) + 1]);\n }\n quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n\nfunction mouseClicked() {\n showRedGreen = !showRedGreen;\n}\n
\n\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
Use addRow() to add a new row of data to a p5.Table object. By default,\nan empty row is created. Typically, you would store a reference to\nthe new row in a TableRow object (see newRow in the example above),\nand then set individual values using set().
\nIf a p5.TableRow object is included as a parameter, then that row is\nduplicated and added to the table.
\n", + "example": [ + "\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //remove the first row\n table.removeRow(0);\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(row.getString(c));\n }\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let rows = table.getRows();\n\n //warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n rows[r].set('name', 'Unicorn');\n }\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //find the animal named zebra\n let row = table.findRow('Zebra', 'name');\n //find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add another goat\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n //find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp('ant'), 1);\n print(mammal.getString(1));\n //Output \"Panthera pardus\"\n}\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //getColumn returns an array that can be printed directly\n print(table.getColumn('species'));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.clearRows();\n print(table.getRowCount() + ' total rows in table');\n print(table.getColumnCount() + ' total columns in table');\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.addColumn('carnivore');\n table.set(0, 'carnivore', 'no');\n table.set(1, 'carnivore', 'yes');\n table.set(2, 'carnivore', 'no');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\n\n// given the cvs file \"blobs.csv\" in /assets directory\n//\n// ID, Name, Flavor, Shape, Color\n// Blob1, Blobby, Sweet, Blob, Pink\n// Blob2, Saddy, Savory, Blob, Blue\n\nlet table;\n\nfunction preload() {\n table = loadTable('assets/blobs.csv');\n}\n\nfunction setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n}\n\nfunction draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n}\n
\nRemoves any of the specified characters (or \"tokens\").
\nIf no column is specified, then the values in all columns and\nrows are processed. A specific column may be referenced by\neither its ID or title.
\n", + "example": [ + "\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' $Lion ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\nfunction setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', ' Lion ,');\n newRow.setString('type', ' Mammal ');\n\n newRow = table.addRow();\n newRow.setString('name', ' Snake ');\n newRow.setString('type', ' Reptile ');\n\n table.trim();\n print(table.getArray());\n}\n\n// prints:\n// 0 \"Lion\" \"Mamal\"\n// 1 \"Snake\" \"Reptile\"\n
\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.removeColumn('id');\n print(table.getColumnCount());\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.set(0, 'species', 'Canis Lupus');\n table.set(0, 'name', 'Wolf');\n\n //print the results\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++)\n print(table.getString(r, c));\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n table.setNum(1, 'id', 1);\n\n print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n\n describe('no image displayed');\n}\n
\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, 'species'));\n //Capra hircus\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableObject = table.getObject();\n\n print(tableObject);\n //outputs an object\n\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value \"CSV\"\n // and has specifiying header for column labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n describe('no image displayed');\n}\n
\ndescription of the canvas.
\n", + "type": "String" + }, + { + "name": "display", + "description": "either LABEL or FALLBACK.
\n", + "type": "Constant", + "optional": true + } + ], + "class": "p5", + "module": "Environment" + }, + "describeElement": { + "name": "describeElement", + "params": [ + { + "name": "name", + "description": "name of the element.
\n", + "type": "String" + }, + { + "name": "text", + "description": "description of the element.
\n", + "type": "String" + }, + { + "name": "display", + "description": "either LABEL or FALLBACK.
\n", + "type": "Constant", + "optional": true + } + ], + "class": "p5", + "module": "Environment" + }, + "textOutput": { + "name": "textOutput", + "params": [ + { + "name": "display", + "description": "either FALLBACK or LABEL.
\n", + "type": "Constant", + "optional": true + } + ], + "class": "p5", + "module": "Environment" + }, + "gridOutput": { + "name": "gridOutput", + "params": [ + { + "name": "display", + "description": "either FALLBACK or LABEL.
\n", + "type": "Constant", + "optional": true + } + ], + "class": "p5", + "module": "Environment" + }, + "alpha": { + "name": "alpha", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "blue": { + "name": "blue", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "brightness": { + "name": "brightness", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "color": { + "name": "color", + "class": "p5", + "module": "Color", + "overloads": [ + { + "params": [ + { + "name": "gray", + "description": "number specifying value between white and black.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "alpha value relative to current color range\n (default is 0-255).
\n", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to\n the current color range.
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value\n relative to the current color range.
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value\n relative to the current color range.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "value", + "description": "a color string.
\n", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "values", + "description": "an array containing the red, green, blue,\n and alpha components of the color.
\n", + "type": "Number[]" + } + ] + }, + { + "params": [ + { + "name": "color", + "description": "", + "type": "p5.Color" + } + ] + } + ] + }, + "green": { + "name": "green", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "hue": { + "name": "hue", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "lerpColor": { + "name": "lerpColor", + "params": [ + { + "name": "c1", + "description": "interpolate from this color.
\n", + "type": "p5.Color" + }, + { + "name": "c2", + "description": "interpolate to this color.
\n", + "type": "p5.Color" + }, + { + "name": "amt", + "description": "number between 0 and 1.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Color" + }, + "lightness": { + "name": "lightness", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "red": { + "name": "red", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "saturation": { + "name": "saturation", + "params": [ + { + "name": "color", + "description": "p5.Color object, array of\n color components, or CSS color string.
\n", + "type": "p5.Color|Number[]|String" + } + ], + "class": "p5", + "module": "Color" + }, + "beginClip": { + "name": "beginClip", + "params": [ + { + "name": "options", + "description": "An object containing clip settings.
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5", + "module": "Color" + }, + "endClip": { + "name": "endClip", + "class": "p5", + "module": "Color" + }, + "clip": { + "name": "clip", + "params": [ + { + "name": "callback", + "description": "A function that draws the mask shape.
\n", + "type": "Function" + }, + { + "name": "options", + "description": "An object containing clip settings.
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5", + "module": "Color" + }, + "background": { + "name": "background", + "class": "p5", + "module": "Color", + "overloads": [ + { + "params": [ + { + "name": "color", + "description": "any value created by the color() function
\n", + "type": "p5.Color" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "colorstring", + "description": "color string, possible formats include: integer\n rgb() or rgba(), percentage rgb() or rgba(),\n 3-digit hex, 6-digit hex.
\n", + "type": "String" + }, + { + "name": "a", + "description": "opacity of the background relative to current\n color range (default is 0-255).
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "gray", + "description": "specifies a value between white and black.
\n", + "type": "Number" + }, + { + "name": "a", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "red value if color mode is RGB, or hue value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green value if color mode is RGB, or saturation value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue value if color mode is RGB, or brightness value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "a", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "values", + "description": "an array containing the red, green, blue\n and alpha components of the color.
\n", + "type": "Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "image", + "description": "image created with loadImage()\n or createImage(),\n to set as background.\n (must be same size as the sketch window).
\n", + "type": "p5.Image" + }, + { + "name": "a", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "clear": { + "name": "clear", + "params": [ + { + "name": "r", + "description": "normalized red value.
\n", + "type": "Number", + "optional": true + }, + { + "name": "g", + "description": "normalized green value.
\n", + "type": "Number", + "optional": true + }, + { + "name": "b", + "description": "normalized blue value.
\n", + "type": "Number", + "optional": true + }, + { + "name": "a", + "description": "normalized alpha value.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Color" + }, + "colorMode": { + "name": "colorMode", + "class": "p5", + "module": "Color", + "overloads": [ + { + "params": [ + { + "name": "mode", + "description": "either RGB, HSB or HSL, corresponding to\n Red/Green/Blue and Hue/Saturation/Brightness\n (or Lightness).
\n", + "type": "Constant" + }, + { + "name": "max", + "description": "range for all values.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "mode", + "description": "", + "type": "Constant" + }, + { + "name": "max1", + "description": "range for the red or hue depending on the\n current color mode.
\n", + "type": "Number" + }, + { + "name": "max2", + "description": "range for the green or saturation depending\n on the current color mode.
\n", + "type": "Number" + }, + { + "name": "max3", + "description": "range for the blue or brightness/lightness\n depending on the current color mode.
\n", + "type": "Number" + }, + { + "name": "maxA", + "description": "range for the alpha.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "fill": { + "name": "fill", + "class": "p5", + "module": "Color", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red value if color mode is RGB or hue value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green value if color mode is RGB or saturation value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue value if color mode is RGB or brightness value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "a color string.
\n", + "type": "String" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "gray", + "description": "a grayscale value.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "values", + "description": "an array containing the red, green, blue &\n and alpha components of the color.
\n", + "type": "Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "the fill color.
\n", + "type": "p5.Color" + } + ], + "chainable": 1 + } + ] + }, + "noFill": { + "name": "noFill", + "class": "p5", + "module": "Color" + }, + "noStroke": { + "name": "noStroke", + "class": "p5", + "module": "Color" + }, + "stroke": { + "name": "stroke", + "class": "p5", + "module": "Color", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red value if color mode is RGB or hue value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green value if color mode is RGB or saturation value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue value if color mode is RGB or brightness value if color mode is HSB.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "a color string.
\n", + "type": "String" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "gray", + "description": "a grayscale value.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "values", + "description": "an array containing the red, green, blue,\n and alpha components of the color.
\n", + "type": "Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "the stroke color.
\n", + "type": "p5.Color" + } + ], + "chainable": 1 + } + ] + }, + "erase": { + "name": "erase", + "params": [ + { + "name": "strengthFill", + "description": "a number (0-255) for the strength of erasing under a shape's interior.\n Defaults to 255, which is full strength.
\n", + "type": "Number", + "optional": true + }, + { + "name": "strengthStroke", + "description": "a number (0-255) for the strength of erasing under a shape's edge.\n Defaults to 255, which is full strength.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Color" + }, + "noErase": { + "name": "noErase", + "class": "p5", + "module": "Color" + }, + "arc": { + "name": "arc", + "params": [ + { + "name": "x", + "description": "x-coordinate of the arc's ellipse.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the arc's ellipse.
\n", + "type": "Number" + }, + { + "name": "w", + "description": "width of the arc's ellipse by default.
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the arc's ellipse by default.
\n", + "type": "Number" + }, + { + "name": "start", + "description": "angle to start the arc, specified in radians.
\n", + "type": "Number" + }, + { + "name": "stop", + "description": "angle to stop the arc, specified in radians.
\n", + "type": "Number" + }, + { + "name": "mode", + "description": "optional parameter to determine the way of drawing\n the arc. either CHORD, PIE, or OPEN.
\n", + "type": "Constant", + "optional": true + }, + { + "name": "detail", + "description": "optional parameter for WebGL mode only. This is to\n specify the number of vertices that makes up the\n perimeter of the arc. Default value is 25. Won't\n draw a stroke for a detail of more than 50.
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "ellipse": { + "name": "ellipse", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the center of the ellipse.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the center of the ellipse.
\n", + "type": "Number" + }, + { + "name": "w", + "description": "width of the ellipse.
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the ellipse.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "w", + "description": "", + "type": "Number" + }, + { + "name": "h", + "description": "", + "type": "Number" + }, + { + "name": "detail", + "description": "optional parameter for WebGL mode only. This is to\n specify the number of vertices that makes up the\n perimeter of the ellipse. Default value is 25. Won't\n draw a stroke for a detail of more than 50.
\n", + "type": "Integer", + "optional": true + } + ] + } + ] + }, + "circle": { + "name": "circle", + "params": [ + { + "name": "x", + "description": "x-coordinate of the center of the circle.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the center of the circle.
\n", + "type": "Number" + }, + { + "name": "d", + "description": "diameter of the circle.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "line": { + "name": "line", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x1", + "description": "the x-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "y1", + "description": "the y-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "the x-coordinate of the second point.
\n", + "type": "Number" + }, + { + "name": "y2", + "description": "the y-coordinate of the second point.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x1", + "description": "", + "type": "Number" + }, + { + "name": "y1", + "description": "", + "type": "Number" + }, + { + "name": "z1", + "description": "the z-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "", + "type": "Number" + }, + { + "name": "y2", + "description": "", + "type": "Number" + }, + { + "name": "z2", + "description": "the z-coordinate of the second point.
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "point": { + "name": "point", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "the x-coordinate.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "the y-coordinate.
\n", + "type": "Number" + }, + { + "name": "z", + "description": "the z-coordinate (for WebGL mode).
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "coordinateVector", + "description": "the coordinate vector.
\n", + "type": "p5.Vector" + } + ], + "chainable": 1 + } + ] + }, + "quad": { + "name": "quad", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x1", + "description": "the x-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "y1", + "description": "the y-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "the x-coordinate of the second point.
\n", + "type": "Number" + }, + { + "name": "y2", + "description": "the y-coordinate of the second point.
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "the x-coordinate of the third point.
\n", + "type": "Number" + }, + { + "name": "y3", + "description": "the y-coordinate of the third point.
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "the x-coordinate of the fourth point.
\n", + "type": "Number" + }, + { + "name": "y4", + "description": "the y-coordinate of the fourth point.
\n", + "type": "Number" + }, + { + "name": "detailX", + "description": "number of segments in the x-direction.
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "number of segments in the y-direction.
\n", + "type": "Integer", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x1", + "description": "", + "type": "Number" + }, + { + "name": "y1", + "description": "", + "type": "Number" + }, + { + "name": "z1", + "description": "the z-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "", + "type": "Number" + }, + { + "name": "y2", + "description": "", + "type": "Number" + }, + { + "name": "z2", + "description": "the z-coordinate of the second point.
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "", + "type": "Number" + }, + { + "name": "y3", + "description": "", + "type": "Number" + }, + { + "name": "z3", + "description": "the z-coordinate of the third point.
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "", + "type": "Number" + }, + { + "name": "y4", + "description": "", + "type": "Number" + }, + { + "name": "z4", + "description": "the z-coordinate of the fourth point.
\n", + "type": "Number" + }, + { + "name": "detailX", + "description": "", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "", + "type": "Integer", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "rect": { + "name": "rect", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the rectangle.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the rectangle.
\n", + "type": "Number" + }, + { + "name": "w", + "description": "width of the rectangle.
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the rectangle.
\n", + "type": "Number", + "optional": true + }, + { + "name": "tl", + "description": "optional radius of top-left corner.
\n", + "type": "Number", + "optional": true + }, + { + "name": "tr", + "description": "optional radius of top-right corner.
\n", + "type": "Number", + "optional": true + }, + { + "name": "br", + "description": "optional radius of bottom-right corner.
\n", + "type": "Number", + "optional": true + }, + { + "name": "bl", + "description": "optional radius of bottom-left corner.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "w", + "description": "", + "type": "Number" + }, + { + "name": "h", + "description": "", + "type": "Number" + }, + { + "name": "detailX", + "description": "number of segments in the x-direction (for WebGL mode).
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "number of segments in the y-direction (for WebGL mode).
\n", + "type": "Integer", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "square": { + "name": "square", + "params": [ + { + "name": "x", + "description": "x-coordinate of the square.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the square.
\n", + "type": "Number" + }, + { + "name": "s", + "description": "side size of the square.
\n", + "type": "Number" + }, + { + "name": "tl", + "description": "optional radius of top-left corner.
\n", + "type": "Number", + "optional": true + }, + { + "name": "tr", + "description": "optional radius of top-right corner.
\n", + "type": "Number", + "optional": true + }, + { + "name": "br", + "description": "optional radius of bottom-right corner.
\n", + "type": "Number", + "optional": true + }, + { + "name": "bl", + "description": "optional radius of bottom-left corner.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "triangle": { + "name": "triangle", + "params": [ + { + "name": "x1", + "description": "x-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "y1", + "description": "y-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "x-coordinate of the second point.
\n", + "type": "Number" + }, + { + "name": "y2", + "description": "y-coordinate of the second point.
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "x-coordinate of the third point.
\n", + "type": "Number" + }, + { + "name": "y3", + "description": "y-coordinate of the third point.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "ellipseMode": { + "name": "ellipseMode", + "params": [ + { + "name": "mode", + "description": "either CENTER, RADIUS, CORNER, or CORNERS
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "Shape" + }, + "noSmooth": { + "name": "noSmooth", + "class": "p5", + "module": "Shape" + }, + "rectMode": { + "name": "rectMode", + "params": [ + { + "name": "mode", + "description": "either CORNER, CORNERS, CENTER, or RADIUS
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "Shape" + }, + "smooth": { + "name": "smooth", + "class": "p5", + "module": "Shape" + }, + "strokeCap": { + "name": "strokeCap", + "params": [ + { + "name": "cap", + "description": "either ROUND, SQUARE, or PROJECT
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "Shape" + }, + "strokeJoin": { + "name": "strokeJoin", + "params": [ + { + "name": "join", + "description": "either MITER, BEVEL, or ROUND
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "Shape" + }, + "strokeWeight": { + "name": "strokeWeight", + "params": [ + { + "name": "weight", + "description": "the weight of the stroke (in pixels).
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "bezier": { + "name": "bezier", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x1", + "description": "x-coordinate for the first anchor point
\n", + "type": "Number" + }, + { + "name": "y1", + "description": "y-coordinate for the first anchor point
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "x-coordinate for the first control point
\n", + "type": "Number" + }, + { + "name": "y2", + "description": "y-coordinate for the first control point
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "x-coordinate for the second control point
\n", + "type": "Number" + }, + { + "name": "y3", + "description": "y-coordinate for the second control point
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "x-coordinate for the second anchor point
\n", + "type": "Number" + }, + { + "name": "y4", + "description": "y-coordinate for the second anchor point
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x1", + "description": "", + "type": "Number" + }, + { + "name": "y1", + "description": "", + "type": "Number" + }, + { + "name": "z1", + "description": "z-coordinate for the first anchor point
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "", + "type": "Number" + }, + { + "name": "y2", + "description": "", + "type": "Number" + }, + { + "name": "z2", + "description": "z-coordinate for the first control point
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "", + "type": "Number" + }, + { + "name": "y3", + "description": "", + "type": "Number" + }, + { + "name": "z3", + "description": "z-coordinate for the second control point
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "", + "type": "Number" + }, + { + "name": "y4", + "description": "", + "type": "Number" + }, + { + "name": "z4", + "description": "z-coordinate for the second anchor point
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "bezierDetail": { + "name": "bezierDetail", + "params": [ + { + "name": "detail", + "description": "resolution of the curves
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "bezierPoint": { + "name": "bezierPoint", + "params": [ + { + "name": "a", + "description": "coordinate of first point on the curve
\n", + "type": "Number" + }, + { + "name": "b", + "description": "coordinate of first control point
\n", + "type": "Number" + }, + { + "name": "c", + "description": "coordinate of second control point
\n", + "type": "Number" + }, + { + "name": "d", + "description": "coordinate of second point on the curve
\n", + "type": "Number" + }, + { + "name": "t", + "description": "value between 0 and 1
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "bezierTangent": { + "name": "bezierTangent", + "params": [ + { + "name": "a", + "description": "coordinate of first point on the curve
\n", + "type": "Number" + }, + { + "name": "b", + "description": "coordinate of first control point
\n", + "type": "Number" + }, + { + "name": "c", + "description": "coordinate of second control point
\n", + "type": "Number" + }, + { + "name": "d", + "description": "coordinate of second point on the curve
\n", + "type": "Number" + }, + { + "name": "t", + "description": "value between 0 and 1
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "curve": { + "name": "curve", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x1", + "description": "x-coordinate for the beginning control point
\n", + "type": "Number" + }, + { + "name": "y1", + "description": "y-coordinate for the beginning control point
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "x-coordinate for the first point
\n", + "type": "Number" + }, + { + "name": "y2", + "description": "y-coordinate for the first point
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "x-coordinate for the second point
\n", + "type": "Number" + }, + { + "name": "y3", + "description": "y-coordinate for the second point
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "x-coordinate for the ending control point
\n", + "type": "Number" + }, + { + "name": "y4", + "description": "y-coordinate for the ending control point
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x1", + "description": "", + "type": "Number" + }, + { + "name": "y1", + "description": "", + "type": "Number" + }, + { + "name": "z1", + "description": "z-coordinate for the beginning control point
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "", + "type": "Number" + }, + { + "name": "y2", + "description": "", + "type": "Number" + }, + { + "name": "z2", + "description": "z-coordinate for the first point
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "", + "type": "Number" + }, + { + "name": "y3", + "description": "", + "type": "Number" + }, + { + "name": "z3", + "description": "z-coordinate for the second point
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "", + "type": "Number" + }, + { + "name": "y4", + "description": "", + "type": "Number" + }, + { + "name": "z4", + "description": "z-coordinate for the ending control point
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "curveDetail": { + "name": "curveDetail", + "params": [ + { + "name": "resolution", + "description": "resolution of the curves
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "curveTightness": { + "name": "curveTightness", + "params": [ + { + "name": "amount", + "description": "amount of deformation from the original vertices
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "curvePoint": { + "name": "curvePoint", + "params": [ + { + "name": "a", + "description": "coordinate of first control point of the curve
\n", + "type": "Number" + }, + { + "name": "b", + "description": "coordinate of first point
\n", + "type": "Number" + }, + { + "name": "c", + "description": "coordinate of second point
\n", + "type": "Number" + }, + { + "name": "d", + "description": "coordinate of second control point
\n", + "type": "Number" + }, + { + "name": "t", + "description": "value between 0 and 1
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "curveTangent": { + "name": "curveTangent", + "params": [ + { + "name": "a", + "description": "coordinate of first control point
\n", + "type": "Number" + }, + { + "name": "b", + "description": "coordinate of first point on the curve
\n", + "type": "Number" + }, + { + "name": "c", + "description": "coordinate of second point on the curve
\n", + "type": "Number" + }, + { + "name": "d", + "description": "coordinate of second conrol point
\n", + "type": "Number" + }, + { + "name": "t", + "description": "value between 0 and 1
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Shape" + }, + "beginContour": { + "name": "beginContour", + "class": "p5", + "module": "Shape" + }, + "beginShape": { + "name": "beginShape", + "params": [ + { + "name": "kind", + "description": "either POINTS, LINES, TRIANGLES, TRIANGLE_FAN\n TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS
\n", + "type": "Constant", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "bezierVertex": { + "name": "bezierVertex", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x2", + "description": "x-coordinate for the first control point
\n", + "type": "Number" + }, + { + "name": "y2", + "description": "y-coordinate for the first control point
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "x-coordinate for the second control point
\n", + "type": "Number" + }, + { + "name": "y3", + "description": "y-coordinate for the second control point
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "x-coordinate for the anchor point
\n", + "type": "Number" + }, + { + "name": "y4", + "description": "y-coordinate for the anchor point
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x2", + "description": "", + "type": "Number" + }, + { + "name": "y2", + "description": "", + "type": "Number" + }, + { + "name": "z2", + "description": "z-coordinate for the first control point (for WebGL mode)
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "", + "type": "Number" + }, + { + "name": "y3", + "description": "", + "type": "Number" + }, + { + "name": "z3", + "description": "z-coordinate for the second control point (for WebGL mode)
\n", + "type": "Number" + }, + { + "name": "x4", + "description": "", + "type": "Number" + }, + { + "name": "y4", + "description": "", + "type": "Number" + }, + { + "name": "z4", + "description": "z-coordinate for the anchor point (for WebGL mode)
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "curveVertex": { + "name": "curveVertex", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the vertex
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the vertex
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "z-coordinate of the vertex (for WebGL mode)
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "endContour": { + "name": "endContour", + "class": "p5", + "module": "Shape" + }, + "endShape": { + "name": "endShape", + "params": [ + { + "name": "mode", + "description": "use CLOSE to close the shape
\n", + "type": "Constant", + "optional": true + }, + { + "name": "count", + "description": "number of times you want to draw/instance the shape (for WebGL mode).
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "quadraticVertex": { + "name": "quadraticVertex", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "cx", + "description": "x-coordinate for the control point
\n", + "type": "Number" + }, + { + "name": "cy", + "description": "y-coordinate for the control point
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "x-coordinate for the anchor point
\n", + "type": "Number" + }, + { + "name": "y3", + "description": "y-coordinate for the anchor point
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "cx", + "description": "", + "type": "Number" + }, + { + "name": "cy", + "description": "", + "type": "Number" + }, + { + "name": "cz", + "description": "z-coordinate for the control point (for WebGL mode)
\n", + "type": "Number" + }, + { + "name": "x3", + "description": "", + "type": "Number" + }, + { + "name": "y3", + "description": "", + "type": "Number" + }, + { + "name": "z3", + "description": "z-coordinate for the anchor point (for WebGL mode)
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "vertex": { + "name": "vertex", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the vertex
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the vertex
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "z-coordinate of the vertex.\n Defaults to 0 if not specified.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "u", + "description": "the vertex's texture u-coordinate
\n", + "type": "Number", + "optional": true + }, + { + "name": "v", + "description": "the vertex's texture v-coordinate
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "normal": { + "name": "normal", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "vector", + "description": "A p5.Vector representing the vertex normal.
\n", + "type": "Vector" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "The x component of the vertex normal.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "The y component of the vertex normal.
\n", + "type": "Number" + }, + { + "name": "z", + "description": "The z component of the vertex normal.
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "VERSION": { + "name": "VERSION", + "class": "p5", + "module": "Constants" + }, + "P2D": { + "name": "P2D", + "class": "p5", + "module": "Constants" + }, + "WEBGL": { + "name": "WEBGL", + "class": "p5", + "module": "Constants" + }, + "WEBGL2": { + "name": "WEBGL2", + "class": "p5", + "module": "Constants" + }, + "ARROW": { + "name": "ARROW", + "class": "p5", + "module": "Constants" + }, + "CROSS": { + "name": "CROSS", + "class": "p5", + "module": "Constants" + }, + "HAND": { + "name": "HAND", + "class": "p5", + "module": "Constants" + }, + "MOVE": { + "name": "MOVE", + "class": "p5", + "module": "Constants" + }, + "TEXT": { + "name": "TEXT", + "class": "p5", + "module": "Constants" + }, + "WAIT": { + "name": "WAIT", + "class": "p5", + "module": "Constants" + }, + "HALF_PI": { + "name": "HALF_PI", + "class": "p5", + "module": "Constants" + }, + "PI": { + "name": "PI", + "class": "p5", + "module": "Constants" + }, + "QUARTER_PI": { + "name": "QUARTER_PI", + "class": "p5", + "module": "Constants" + }, + "TAU": { + "name": "TAU", + "class": "p5", + "module": "Constants" + }, + "TWO_PI": { + "name": "TWO_PI", + "class": "p5", + "module": "Constants" + }, + "DEGREES": { + "name": "DEGREES", + "class": "p5", + "module": "Constants" + }, + "RADIANS": { + "name": "RADIANS", + "class": "p5", + "module": "Constants" + }, + "CORNER": { + "name": "CORNER", + "class": "p5", + "module": "Constants" + }, + "CORNERS": { + "name": "CORNERS", + "class": "p5", + "module": "Constants" + }, + "RADIUS": { + "name": "RADIUS", + "class": "p5", + "module": "Constants" + }, + "RIGHT": { + "name": "RIGHT", + "class": "p5", + "module": "Constants" + }, + "LEFT": { + "name": "LEFT", + "class": "p5", + "module": "Constants" + }, + "CENTER": { + "name": "CENTER", + "class": "p5", + "module": "Constants" + }, + "TOP": { + "name": "TOP", + "class": "p5", + "module": "Constants" + }, + "BOTTOM": { + "name": "BOTTOM", + "class": "p5", + "module": "Constants" + }, + "BASELINE": { + "name": "BASELINE", + "class": "p5", + "module": "Constants" + }, + "POINTS": { + "name": "POINTS", + "class": "p5", + "module": "Constants" + }, + "LINES": { + "name": "LINES", + "class": "p5", + "module": "Constants" + }, + "LINE_STRIP": { + "name": "LINE_STRIP", + "class": "p5", + "module": "Constants" + }, + "LINE_LOOP": { + "name": "LINE_LOOP", + "class": "p5", + "module": "Constants" + }, + "TRIANGLES": { + "name": "TRIANGLES", + "class": "p5", + "module": "Constants" + }, + "TRIANGLE_FAN": { + "name": "TRIANGLE_FAN", + "class": "p5", + "module": "Constants" + }, + "TRIANGLE_STRIP": { + "name": "TRIANGLE_STRIP", + "class": "p5", + "module": "Constants" + }, + "QUADS": { + "name": "QUADS", + "class": "p5", + "module": "Constants" + }, + "QUAD_STRIP": { + "name": "QUAD_STRIP", + "class": "p5", + "module": "Constants" + }, + "TESS": { + "name": "TESS", + "class": "p5", + "module": "Constants" + }, + "CLOSE": { + "name": "CLOSE", + "class": "p5", + "module": "Constants" + }, + "OPEN": { + "name": "OPEN", + "class": "p5", + "module": "Constants" + }, + "CHORD": { + "name": "CHORD", + "class": "p5", + "module": "Constants" + }, + "PIE": { + "name": "PIE", + "class": "p5", + "module": "Constants" + }, + "PROJECT": { + "name": "PROJECT", + "class": "p5", + "module": "Constants" + }, + "SQUARE": { + "name": "SQUARE", + "class": "p5", + "module": "Constants" + }, + "ROUND": { + "name": "ROUND", + "class": "p5", + "module": "Constants" + }, + "BEVEL": { + "name": "BEVEL", + "class": "p5", + "module": "Constants" + }, + "MITER": { + "name": "MITER", + "class": "p5", + "module": "Constants" + }, + "RGB": { + "name": "RGB", + "class": "p5", + "module": "Constants" + }, + "HSB": { + "name": "HSB", + "class": "p5", + "module": "Constants" + }, + "HSL": { + "name": "HSL", + "class": "p5", + "module": "Constants" + }, + "AUTO": { + "name": "AUTO", + "class": "p5", + "module": "Constants" + }, + "ALT": { + "name": "ALT", + "class": "p5", + "module": "Constants" + }, + "BACKSPACE": { + "name": "BACKSPACE", + "class": "p5", + "module": "Constants" + }, + "CONTROL": { + "name": "CONTROL", + "class": "p5", + "module": "Constants" + }, + "DELETE": { + "name": "DELETE", + "class": "p5", + "module": "Constants" + }, + "DOWN_ARROW": { + "name": "DOWN_ARROW", + "class": "p5", + "module": "Constants" + }, + "ENTER": { + "name": "ENTER", + "class": "p5", + "module": "Constants" + }, + "ESCAPE": { + "name": "ESCAPE", + "class": "p5", + "module": "Constants" + }, + "LEFT_ARROW": { + "name": "LEFT_ARROW", + "class": "p5", + "module": "Constants" + }, + "OPTION": { + "name": "OPTION", + "class": "p5", + "module": "Constants" + }, + "RETURN": { + "name": "RETURN", + "class": "p5", + "module": "Constants" + }, + "RIGHT_ARROW": { + "name": "RIGHT_ARROW", + "class": "p5", + "module": "Constants" + }, + "SHIFT": { + "name": "SHIFT", + "class": "p5", + "module": "Constants" + }, + "TAB": { + "name": "TAB", + "class": "p5", + "module": "Constants" + }, + "UP_ARROW": { + "name": "UP_ARROW", + "class": "p5", + "module": "Constants" + }, + "BLEND": { + "name": "BLEND", + "class": "p5", + "module": "Constants" + }, + "REMOVE": { + "name": "REMOVE", + "class": "p5", + "module": "Constants" + }, + "ADD": { + "name": "ADD", + "class": "p5", + "module": "Constants" + }, + "DARKEST": { + "name": "DARKEST", + "class": "p5", + "module": "Constants" + }, + "LIGHTEST": { + "name": "LIGHTEST", + "class": "p5", + "module": "Constants" + }, + "DIFFERENCE": { + "name": "DIFFERENCE", + "class": "p5", + "module": "Constants" + }, + "SUBTRACT": { + "name": "SUBTRACT", + "class": "p5", + "module": "Constants" + }, + "EXCLUSION": { + "name": "EXCLUSION", + "class": "p5", + "module": "Constants" + }, + "MULTIPLY": { + "name": "MULTIPLY", + "class": "p5", + "module": "Constants" + }, + "SCREEN": { + "name": "SCREEN", + "class": "p5", + "module": "Constants" + }, + "REPLACE": { + "name": "REPLACE", + "class": "p5", + "module": "Constants" + }, + "OVERLAY": { + "name": "OVERLAY", + "class": "p5", + "module": "Constants" + }, + "HARD_LIGHT": { + "name": "HARD_LIGHT", + "class": "p5", + "module": "Constants" + }, + "SOFT_LIGHT": { + "name": "SOFT_LIGHT", + "class": "p5", + "module": "Constants" + }, + "DODGE": { + "name": "DODGE", + "class": "p5", + "module": "Constants" + }, + "BURN": { + "name": "BURN", + "class": "p5", + "module": "Constants" + }, + "THRESHOLD": { + "name": "THRESHOLD", + "class": "p5", + "module": "Constants" + }, + "GRAY": { + "name": "GRAY", + "class": "p5", + "module": "Constants" + }, + "OPAQUE": { + "name": "OPAQUE", + "class": "p5", + "module": "Constants" + }, + "INVERT": { + "name": "INVERT", + "class": "p5", + "module": "Constants" + }, + "POSTERIZE": { + "name": "POSTERIZE", + "class": "p5", + "module": "Constants" + }, + "DILATE": { + "name": "DILATE", + "class": "p5", + "module": "Constants" + }, + "ERODE": { + "name": "ERODE", + "class": "p5", + "module": "Constants" + }, + "BLUR": { + "name": "BLUR", + "class": "p5", + "module": "Constants" + }, + "NORMAL": { + "name": "NORMAL", + "class": "p5", + "module": "Constants" + }, + "ITALIC": { + "name": "ITALIC", + "class": "p5", + "module": "Constants" + }, + "BOLD": { + "name": "BOLD", + "class": "p5", + "module": "Constants" + }, + "BOLDITALIC": { + "name": "BOLDITALIC", + "class": "p5", + "module": "Constants" + }, + "CHAR": { + "name": "CHAR", + "class": "p5", + "module": "Constants" + }, + "WORD": { + "name": "WORD", + "class": "p5", + "module": "Constants" + }, + "LINEAR": { + "name": "LINEAR", + "class": "p5", + "module": "Constants" + }, + "QUADRATIC": { + "name": "QUADRATIC", + "class": "p5", + "module": "Constants" + }, + "BEZIER": { + "name": "BEZIER", + "class": "p5", + "module": "Constants" + }, + "CURVE": { + "name": "CURVE", + "class": "p5", + "module": "Constants" + }, + "STROKE": { + "name": "STROKE", + "class": "p5", + "module": "Constants" + }, + "FILL": { + "name": "FILL", + "class": "p5", + "module": "Constants" + }, + "TEXTURE": { + "name": "TEXTURE", + "class": "p5", + "module": "Constants" + }, + "IMMEDIATE": { + "name": "IMMEDIATE", + "class": "p5", + "module": "Constants" + }, + "IMAGE": { + "name": "IMAGE", + "class": "p5", + "module": "Constants" + }, + "NEAREST": { + "name": "NEAREST", + "class": "p5", + "module": "Constants" + }, + "REPEAT": { + "name": "REPEAT", + "class": "p5", + "module": "Constants" + }, + "CLAMP": { + "name": "CLAMP", + "class": "p5", + "module": "Constants" + }, + "MIRROR": { + "name": "MIRROR", + "class": "p5", + "module": "Constants" + }, + "FLAT": { + "name": "FLAT", + "class": "p5", + "module": "Constants" + }, + "SMOOTH": { + "name": "SMOOTH", + "class": "p5", + "module": "Constants" + }, + "LANDSCAPE": { + "name": "LANDSCAPE", + "class": "p5", + "module": "Constants" + }, + "PORTRAIT": { + "name": "PORTRAIT", + "class": "p5", + "module": "Constants" + }, + "GRID": { + "name": "GRID", + "class": "p5", + "module": "Constants" + }, + "AXES": { + "name": "AXES", + "class": "p5", + "module": "Constants" + }, + "LABEL": { + "name": "LABEL", + "class": "p5", + "module": "Constants" + }, + "FALLBACK": { + "name": "FALLBACK", + "class": "p5", + "module": "Constants" + }, + "CONTAIN": { + "name": "CONTAIN", + "class": "p5", + "module": "Constants" + }, + "COVER": { + "name": "COVER", + "class": "p5", + "module": "Constants" + }, + "UNSIGNED_BYTE": { + "name": "UNSIGNED_BYTE", + "class": "p5", + "module": "Constants" + }, + "UNSIGNED_INT": { + "name": "UNSIGNED_INT", + "class": "p5", + "module": "Constants" + }, + "FLOAT": { + "name": "FLOAT", + "class": "p5", + "module": "Constants" + }, + "HALF_FLOAT": { + "name": "HALF_FLOAT", + "class": "p5", + "module": "Constants" + }, + "RGBA": { + "name": "RGBA", + "class": "p5", + "module": "Constants" + }, + "print": { + "name": "print", + "params": [ + { + "name": "contents", + "description": "content to print to the console.
\n", + "type": "Any" + } + ], + "class": "p5", + "module": "Environment" + }, + "frameCount": { + "name": "frameCount", + "class": "p5", + "module": "Environment" + }, + "deltaTime": { + "name": "deltaTime", + "class": "p5", + "module": "Environment" + }, + "focused": { + "name": "focused", + "class": "p5", + "module": "Environment" + }, + "cursor": { + "name": "cursor", + "params": [ + { + "name": "type", + "description": "Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT.\n Native CSS properties: 'grab', 'progress', and so on.\n Path to cursor image.
\n", + "type": "String|Constant" + }, + { + "name": "x", + "description": "horizontal active spot of the cursor.
\n", + "type": "Number", + "optional": true + }, + { + "name": "y", + "description": "vertical active spot of the cursor.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Environment" + }, + "frameRate": { + "name": "frameRate", + "class": "p5", + "module": "Environment", + "overloads": [ + { + "params": [ + { + "name": "fps", + "description": "number of frames to draw per second.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "getTargetFrameRate": { + "name": "getTargetFrameRate", + "class": "p5", + "module": "Environment" + }, + "noCursor": { + "name": "noCursor", + "class": "p5", + "module": "Environment" + }, + "webglVersion": { + "name": "webglVersion", + "class": "p5", + "module": "Environment" + }, + "displayWidth": { + "name": "displayWidth", + "class": "p5", + "module": "Environment" + }, + "displayHeight": { + "name": "displayHeight", + "class": "p5", + "module": "Environment" + }, + "windowWidth": { + "name": "windowWidth", + "class": "p5", + "module": "Environment" + }, + "windowHeight": { + "name": "windowHeight", + "class": "p5", + "module": "Environment" + }, + "windowResized": { + "name": "windowResized", + "params": [ + { + "name": "event", + "description": "optional resize Event.
\n", + "type": "UIEvent", + "optional": true + } + ], + "class": "p5", + "module": "Environment" + }, + "width": { + "name": "width", + "class": "p5", + "module": "Environment" + }, + "height": { + "name": "height", + "class": "p5", + "module": "Environment" + }, + "fullscreen": { + "name": "fullscreen", + "params": [ + { + "name": "val", + "description": "whether the sketch should be in fullscreen mode.
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "Environment" + }, + "pixelDensity": { + "name": "pixelDensity", + "class": "p5", + "module": "Environment", + "overloads": [ + { + "params": [ + { + "name": "val", + "description": "desired pixel density.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "displayDensity": { + "name": "displayDensity", + "class": "p5", + "module": "Environment" + }, + "getURL": { + "name": "getURL", + "class": "p5", + "module": "Environment" + }, + "getURLPath": { + "name": "getURLPath", + "class": "p5", + "module": "Environment" + }, + "getURLParams": { + "name": "getURLParams", + "class": "p5", + "module": "Environment" + }, + "preload": { + "name": "preload", + "class": "p5", + "module": "Structure" + }, + "setup": { + "name": "setup", + "class": "p5", + "module": "Structure" + }, + "draw": { + "name": "draw", + "class": "p5", + "module": "Structure" + }, + "remove": { + "name": "remove", + "class": "p5", + "module": "Structure" + }, + "disableFriendlyErrors": { + "name": "disableFriendlyErrors", + "class": "p5", + "module": "Structure" + }, + "let": { + "name": "let", + "class": "p5", + "module": "Foundation" + }, + "const": { + "name": "const", + "class": "p5", + "module": "Foundation" + }, + "===": { + "name": "===", + "class": "p5", + "module": "Foundation" + }, + ">": { + "name": ">", + "class": "p5", + "module": "Foundation" + }, + ">=": { + "name": ">=", + "class": "p5", + "module": "Foundation" + }, + "<": { + "name": "<", + "class": "p5", + "module": "Foundation" + }, + "<=": { + "name": "<=", + "class": "p5", + "module": "Foundation" + }, + "if-else": { + "name": "if-else", + "class": "p5", + "module": "Foundation" + }, + "function": { + "name": "function", + "class": "p5", + "module": "Foundation" + }, + "return": { + "name": "return", + "class": "p5", + "module": "Foundation" + }, + "boolean": { + "name": "boolean", + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "String|Boolean|Number|Array" + } + ], + "class": "p5", + "module": "Data" + }, + "string": { + "name": "string", + "class": "p5", + "module": "Foundation" + }, + "number": { + "name": "number", + "class": "p5", + "module": "Foundation" + }, + "object": { + "name": "object", + "class": "p5", + "module": "Foundation" + }, + "class": { + "name": "class", + "class": "p5", + "module": "Foundation" + }, + "for": { + "name": "for", + "class": "p5", + "module": "Foundation" + }, + "while": { + "name": "while", + "class": "p5", + "module": "Foundation" + }, + "createCanvas": { + "name": "createCanvas", + "class": "p5", + "module": "Rendering", + "overloads": [ + { + "params": [ + { + "name": "w", + "description": "width of the canvas
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the canvas
\n", + "type": "Number" + }, + { + "name": "renderer", + "description": "either P2D or WEBGL
\n", + "type": "Constant", + "optional": true + }, + { + "name": "canvas", + "description": "existing html canvas element
\n", + "type": "HTMLCanvasElement", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "w", + "description": "", + "type": "Number" + }, + { + "name": "h", + "description": "", + "type": "Number" + }, + { + "name": "canvas", + "description": "", + "type": "HTMLCanvasElement", + "optional": true + } + ] + } + ] + }, + "resizeCanvas": { + "name": "resizeCanvas", + "params": [ + { + "name": "w", + "description": "width of the canvas
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the canvas
\n", + "type": "Number" + }, + { + "name": "noRedraw", + "description": "don't redraw the canvas immediately
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "Rendering" + }, + "noCanvas": { + "name": "noCanvas", + "class": "p5", + "module": "Rendering" + }, + "createGraphics": { + "name": "createGraphics", + "class": "p5", + "module": "Rendering", + "overloads": [ + { + "params": [ + { + "name": "w", + "description": "width of the offscreen graphics buffer
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the offscreen graphics buffer
\n", + "type": "Number" + }, + { + "name": "renderer", + "description": "either P2D or WEBGL\n undefined defaults to p2d
\n", + "type": "Constant", + "optional": true + }, + { + "name": "canvas", + "description": "existing html canvas element
\n", + "type": "HTMLCanvasElement", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "w", + "description": "", + "type": "Number" + }, + { + "name": "h", + "description": "", + "type": "Number" + }, + { + "name": "canvas", + "description": "", + "type": "HTMLCanvasElement", + "optional": true + } + ] + } + ] + }, + "createFramebuffer": { + "name": "createFramebuffer", + "params": [ + { + "name": "options", + "description": "An optional object with configuration
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5", + "module": "Rendering" + }, + "clearDepth": { + "name": "clearDepth", + "params": [ + { + "name": "depth", + "description": "The value, between 0 and 1, to reset the depth to, where\n0 corresponds to a value as close as possible to the camera before getting\nclipped, and 1 corresponds to a value as far away from the camera as possible.\nThe default value is 1.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Rendering" + }, + "blendMode": { + "name": "blendMode", + "params": [ + { + "name": "mode", + "description": "blend mode to set for canvas.\n either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY,\n EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "Rendering" + }, + "drawingContext": { + "name": "drawingContext", + "class": "p5", + "module": "Rendering" + }, + "noLoop": { + "name": "noLoop", + "class": "p5", + "module": "Structure" + }, + "loop": { + "name": "loop", + "class": "p5", + "module": "Structure" + }, + "isLooping": { + "name": "isLooping", + "class": "p5", + "module": "Structure" + }, + "push": { + "name": "push", + "class": "p5", + "module": "Structure" + }, + "pop": { + "name": "pop", + "class": "p5", + "module": "Structure" + }, + "redraw": { + "name": "redraw", + "params": [ + { + "name": "n", + "description": "Redraw for n-times. The default value is 1.
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Structure" + }, + "p5": { + "name": "p5", + "params": [ + { + "name": "sketch", + "description": "a function containing a p5.js sketch
\n", + "type": "Object" + }, + { + "name": "node", + "description": "ID or pointer to HTML DOM node to contain sketch in
\n", + "type": "String|Object" + } + ], + "class": "p5", + "module": "Structure" + }, + "applyMatrix": { + "name": "applyMatrix", + "class": "p5", + "module": "Transform", + "overloads": [ + { + "params": [ + { + "name": "arr", + "description": "an array of numbers - should be 6 or 16 length (2×3 or 4×4 matrix values)
\n", + "type": "Array" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "a", + "description": "numbers which define the 2×3 or 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "b", + "description": "numbers which define the 2×3 or 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "c", + "description": "numbers which define the 2×3 or 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "d", + "description": "numbers which define the 2×3 or 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "e", + "description": "numbers which define the 2×3 or 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "f", + "description": "numbers which define the 2×3 or 4×4 matrix to be multiplied
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "a", + "description": "", + "type": "Number" + }, + { + "name": "b", + "description": "", + "type": "Number" + }, + { + "name": "c", + "description": "", + "type": "Number" + }, + { + "name": "d", + "description": "", + "type": "Number" + }, + { + "name": "e", + "description": "", + "type": "Number" + }, + { + "name": "f", + "description": "", + "type": "Number" + }, + { + "name": "g", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "h", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "i", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "j", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "k", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "l", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "m", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "n", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "o", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + }, + { + "name": "p", + "description": "numbers which define the 4×4 matrix to be multiplied
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "resetMatrix": { + "name": "resetMatrix", + "class": "p5", + "module": "Transform" + }, + "rotate": { + "name": "rotate", + "params": [ + { + "name": "angle", + "description": "the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n", + "type": "Number" + }, + { + "name": "axis", + "description": "(in 3d) the axis to rotate around
\n", + "type": "p5.Vector|Number[]", + "optional": true + } + ], + "class": "p5", + "module": "Transform" + }, + "rotateX": { + "name": "rotateX", + "params": [ + { + "name": "angle", + "description": "the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Transform" + }, + "rotateY": { + "name": "rotateY", + "params": [ + { + "name": "angle", + "description": "the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Transform" + }, + "rotateZ": { + "name": "rotateZ", + "params": [ + { + "name": "angle", + "description": "the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Transform" + }, + "scale": { + "name": "scale", + "class": "p5", + "module": "Transform", + "overloads": [ + { + "params": [ + { + "name": "s", + "description": "percent to scale the object, or percentage to\n scale the object in the x-axis if multiple arguments\n are given
\n", + "type": "Number|p5.Vector|Number[]" + }, + { + "name": "y", + "description": "percent to scale the object in the y-axis
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "percent to scale the object in the z-axis (webgl only)
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "scales", + "description": "per-axis percents to scale the object
\n", + "type": "p5.Vector|Number[]" + } + ], + "chainable": 1 + } + ] + }, + "shearX": { + "name": "shearX", + "params": [ + { + "name": "angle", + "description": "angle of shear specified in radians or degrees,\n depending on current angleMode
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Transform" + }, + "shearY": { + "name": "shearY", + "params": [ + { + "name": "angle", + "description": "angle of shear specified in radians or degrees,\n depending on current angleMode
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Transform" + }, + "translate": { + "name": "translate", + "class": "p5", + "module": "Transform", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "left/right translation
\n", + "type": "Number" + }, + { + "name": "y", + "description": "up/down translation
\n", + "type": "Number" + }, + { + "name": "z", + "description": "forward/backward translation (WEBGL only)
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "vector", + "description": "the vector to translate by
\n", + "type": "p5.Vector" + } + ], + "chainable": 1 + } + ] + }, + "storeItem": { + "name": "storeItem", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "value", + "description": "", + "type": "String|Number|Object|Boolean|p5.Color|p5.Vector" + } + ], + "class": "p5", + "module": "Data" + }, + "getItem": { + "name": "getItem", + "params": [ + { + "name": "key", + "description": "name that you wish to use to store in local storage
\n", + "type": "String" + } + ], + "class": "p5", + "module": "Data" + }, + "clearStorage": { + "name": "clearStorage", + "class": "p5", + "module": "Data" + }, + "removeItem": { + "name": "removeItem", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "class": "p5", + "module": "Data" + }, + "createStringDict": { + "name": "createStringDict", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "value", + "description": "", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "object", + "description": "object
\n", + "type": "Object" + } + ] + } + ] + }, + "createNumberDict": { + "name": "createNumberDict", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "key", + "description": "", + "type": "Number" + }, + { + "name": "value", + "description": "", + "type": "Number" + } + ] + }, + { + "params": [ + { + "name": "object", + "description": "object
\n", + "type": "Object" + } + ] + } + ] + }, + "select": { + "name": "select", + "params": [ + { + "name": "selectors", + "description": "CSS selector string of element to search for.
\n", + "type": "String" + }, + { + "name": "container", + "description": "CSS selector string, p5.Element, or\n HTMLElement to search within.
\n", + "type": "String|p5.Element|HTMLElement", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "selectAll": { + "name": "selectAll", + "params": [ + { + "name": "selectors", + "description": "CSS selector string of element to search for.
\n", + "type": "String" + }, + { + "name": "container", + "description": "CSS selector string, p5.Element, or\n HTMLElement to search within.
\n", + "type": "String|p5.Element|HTMLElement", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "removeElements": { + "name": "removeElements", + "class": "p5", + "module": "DOM" + }, + "changed": { + "name": "changed", + "params": [ + { + "name": "fxn", + "description": "function to call when the element changes.\n false
disables the function.
function to call when input is detected within\n the element.\n false
disables the function.
inner HTML for the new <div></div>
element.
inner HTML for the new <p></p>
element.
inner HTML for the new <span></span>
element.
relative path or URL for the image.
\n", + "type": "String" + }, + { + "name": "alt", + "description": "alternate text for the image.
\n", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "src", + "description": "", + "type": "String" + }, + { + "name": "alt", + "description": "", + "type": "String" + }, + { + "name": "crossOrigin", + "description": "crossOrigin property to use when fetching the image.
\n", + "type": "String", + "optional": true + }, + { + "name": "successCallback", + "description": "function to call once the image loads. The new image will be passed\n to the function as a p5.Element object.
\n", + "type": "Function", + "optional": true + } + ] + } + ] + }, + "createA": { + "name": "createA", + "params": [ + { + "name": "href", + "description": "URL of linked page.
\n", + "type": "String" + }, + { + "name": "html", + "description": "inner HTML of link element to display.
\n", + "type": "String" + }, + { + "name": "target", + "description": "target where the new link should open,\n either '_blank'
, '_self'
, '_parent'
, or '_top'
.
minimum value of the slider.
\n", + "type": "Number" + }, + { + "name": "max", + "description": "maximum value of the slider.
\n", + "type": "Number" + }, + { + "name": "value", + "description": "default value of the slider.
\n", + "type": "Number", + "optional": true + }, + { + "name": "step", + "description": "size for each step in the slider's range.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "createButton": { + "name": "createButton", + "params": [ + { + "name": "label", + "description": "label displayed on the button.
\n", + "type": "String" + }, + { + "name": "value", + "description": "value of the button.
\n", + "type": "String", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "createCheckbox": { + "name": "createCheckbox", + "params": [ + { + "name": "label", + "description": "label displayed after the checkbox.
\n", + "type": "String", + "optional": true + }, + { + "name": "value", + "description": "value of the checkbox. Checked is true
and unchecked is false
.
support multiple selections.
\n", + "type": "Boolean", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "existing", + "description": "select element to wrap, either as a p5.Element or\n a HTMLSelectElement.
\n", + "type": "Object" + } + ] + } + ] + }, + "createRadio": { + "name": "createRadio", + "class": "p5", + "module": "DOM", + "overloads": [ + { + "params": [ + { + "name": "containerElement", + "description": "container HTML Element, either a <div></div>
\nor <span></span>
.
name parameter assigned to each option's <input></input>
element.
default color as a CSS color string.
\n", + "type": "String|p5.Color", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "createInput": { + "name": "createInput", + "class": "p5", + "module": "DOM", + "overloads": [ + { + "params": [ + { + "name": "value", + "description": "default value of the input box. Defaults to an empty string ''
.
type of input. Defaults to 'text'
.
function to call once the file loads.
\n", + "type": "Function" + }, + { + "name": "multiple", + "description": "allow multiple files to be selected.
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "createVideo": { + "name": "createVideo", + "params": [ + { + "name": "src", + "description": "path to a video file, or an array of paths for\n supporting different browsers.
\n", + "type": "String|String[]" + }, + { + "name": "callback", + "description": "function to call once the video is ready to play.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "createAudio": { + "name": "createAudio", + "params": [ + { + "name": "src", + "description": "path to an audio file, or an array of paths\n for supporting different browsers.
\n", + "type": "String|String[]", + "optional": true + }, + { + "name": "callback", + "description": "function to call once the audio is ready to play.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "createCapture": { + "name": "createCapture", + "params": [ + { + "name": "type", + "description": "type of capture, either AUDIO or VIDEO,\n or a constraints object. Both video and audio\n audio streams are captured by default.
\n", + "type": "String|Constant|Object", + "optional": true + }, + { + "name": "callback", + "description": "function to call once the stream\n has loaded.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "createElement": { + "name": "createElement", + "params": [ + { + "name": "tag", + "description": "tag for the new element.
\n", + "type": "String" + }, + { + "name": "content", + "description": "HTML content to insert into the element.
\n", + "type": "String", + "optional": true + } + ], + "class": "p5", + "module": "DOM" + }, + "deviceOrientation": { + "name": "deviceOrientation", + "class": "p5", + "module": "Events" + }, + "accelerationX": { + "name": "accelerationX", + "class": "p5", + "module": "Events" + }, + "accelerationY": { + "name": "accelerationY", + "class": "p5", + "module": "Events" + }, + "accelerationZ": { + "name": "accelerationZ", + "class": "p5", + "module": "Events" + }, + "pAccelerationX": { + "name": "pAccelerationX", + "class": "p5", + "module": "Events" + }, + "pAccelerationY": { + "name": "pAccelerationY", + "class": "p5", + "module": "Events" + }, + "pAccelerationZ": { + "name": "pAccelerationZ", + "class": "p5", + "module": "Events" + }, + "rotationX": { + "name": "rotationX", + "class": "p5", + "module": "Events" + }, + "rotationY": { + "name": "rotationY", + "class": "p5", + "module": "Events" + }, + "rotationZ": { + "name": "rotationZ", + "class": "p5", + "module": "Events" + }, + "pRotationX": { + "name": "pRotationX", + "class": "p5", + "module": "Events" + }, + "pRotationY": { + "name": "pRotationY", + "class": "p5", + "module": "Events" + }, + "pRotationZ": { + "name": "pRotationZ", + "class": "p5", + "module": "Events" + }, + "turnAxis": { + "name": "turnAxis", + "class": "p5", + "module": "Events" + }, + "setMoveThreshold": { + "name": "setMoveThreshold", + "params": [ + { + "name": "value", + "description": "The threshold value
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Events" + }, + "setShakeThreshold": { + "name": "setShakeThreshold", + "params": [ + { + "name": "value", + "description": "The threshold value
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Events" + }, + "deviceMoved": { + "name": "deviceMoved", + "class": "p5", + "module": "Events" + }, + "deviceTurned": { + "name": "deviceTurned", + "class": "p5", + "module": "Events" + }, + "deviceShaken": { + "name": "deviceShaken", + "class": "p5", + "module": "Events" + }, + "keyIsPressed": { + "name": "keyIsPressed", + "class": "p5", + "module": "Events" + }, + "key": { + "name": "key", + "class": "p5", + "module": "Events" + }, + "keyCode": { + "name": "keyCode", + "class": "p5", + "module": "Events" + }, + "keyPressed": { + "name": "keyPressed", + "params": [ + { + "name": "event", + "description": "optional KeyboardEvent callback argument.
\n", + "type": "KeyboardEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "keyReleased": { + "name": "keyReleased", + "params": [ + { + "name": "event", + "description": "optional KeyboardEvent callback argument.
\n", + "type": "KeyboardEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "keyTyped": { + "name": "keyTyped", + "params": [ + { + "name": "event", + "description": "optional KeyboardEvent callback argument.
\n", + "type": "KeyboardEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "keyIsDown": { + "name": "keyIsDown", + "params": [ + { + "name": "code", + "description": "The key to check for.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Events" + }, + "movedX": { + "name": "movedX", + "class": "p5", + "module": "Events" + }, + "movedY": { + "name": "movedY", + "class": "p5", + "module": "Events" + }, + "mouseX": { + "name": "mouseX", + "class": "p5", + "module": "Events" + }, + "mouseY": { + "name": "mouseY", + "class": "p5", + "module": "Events" + }, + "pmouseX": { + "name": "pmouseX", + "class": "p5", + "module": "Events" + }, + "pmouseY": { + "name": "pmouseY", + "class": "p5", + "module": "Events" + }, + "winMouseX": { + "name": "winMouseX", + "class": "p5", + "module": "Events" + }, + "winMouseY": { + "name": "winMouseY", + "class": "p5", + "module": "Events" + }, + "pwinMouseX": { + "name": "pwinMouseX", + "class": "p5", + "module": "Events" + }, + "pwinMouseY": { + "name": "pwinMouseY", + "class": "p5", + "module": "Events" + }, + "mouseButton": { + "name": "mouseButton", + "class": "p5", + "module": "Events" + }, + "mouseIsPressed": { + "name": "mouseIsPressed", + "class": "p5", + "module": "Events" + }, + "mouseMoved": { + "name": "mouseMoved", + "params": [ + { + "name": "event", + "description": "optional MouseEvent callback argument.
\n", + "type": "MouseEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "mouseDragged": { + "name": "mouseDragged", + "params": [ + { + "name": "event", + "description": "optional MouseEvent callback argument.
\n", + "type": "MouseEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "mousePressed": { + "name": "mousePressed", + "params": [ + { + "name": "event", + "description": "optional MouseEvent callback argument.
\n", + "type": "MouseEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "mouseReleased": { + "name": "mouseReleased", + "params": [ + { + "name": "event", + "description": "optional MouseEvent callback argument.
\n", + "type": "MouseEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "mouseClicked": { + "name": "mouseClicked", + "params": [ + { + "name": "event", + "description": "optional MouseEvent callback argument.
\n", + "type": "MouseEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "doubleClicked": { + "name": "doubleClicked", + "params": [ + { + "name": "event", + "description": "optional MouseEvent callback argument.
\n", + "type": "MouseEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "mouseWheel": { + "name": "mouseWheel", + "params": [ + { + "name": "event", + "description": "optional WheelEvent callback argument.
\n", + "type": "WheelEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "requestPointerLock": { + "name": "requestPointerLock", + "class": "p5", + "module": "Events" + }, + "exitPointerLock": { + "name": "exitPointerLock", + "class": "p5", + "module": "Events" + }, + "touches": { + "name": "touches", + "class": "p5", + "module": "Events" + }, + "touchStarted": { + "name": "touchStarted", + "params": [ + { + "name": "event", + "description": "optional TouchEvent callback argument.
\n", + "type": "TouchEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "touchMoved": { + "name": "touchMoved", + "params": [ + { + "name": "event", + "description": "optional TouchEvent callback argument.
\n", + "type": "TouchEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "touchEnded": { + "name": "touchEnded", + "params": [ + { + "name": "event", + "description": "optional TouchEvent callback argument.
\n", + "type": "TouchEvent", + "optional": true + } + ], + "class": "p5", + "module": "Events" + }, + "createImage": { + "name": "createImage", + "params": [ + { + "name": "width", + "description": "width in pixels.
\n", + "type": "Integer" + }, + { + "name": "height", + "description": "height in pixels.
\n", + "type": "Integer" + } + ], + "class": "p5", + "module": "Image" + }, + "saveCanvas": { + "name": "saveCanvas", + "class": "p5", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "selectedCanvas", + "description": "reference to a\n specific HTML5 canvas element.
\n", + "type": "p5.Framebuffer|p5.Element|HTMLCanvasElement" + }, + { + "name": "filename", + "description": "file name. Defaults to 'untitled'.
\n", + "type": "String", + "optional": true + }, + { + "name": "extension", + "description": "file extension, either 'jpg' or 'png'. Defaults to 'png'.
\n", + "type": "String", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "filename", + "description": "", + "type": "String", + "optional": true + }, + { + "name": "extension", + "description": "", + "type": "String", + "optional": true + } + ] + } + ] + }, + "saveFrames": { + "name": "saveFrames", + "params": [ + { + "name": "filename", + "description": "prefix of file name.
\n", + "type": "String" + }, + { + "name": "extension", + "description": "file extension, either 'jpg' or 'png'.
\n", + "type": "String" + }, + { + "name": "duration", + "description": "duration in seconds to record. This parameter will be constrained to be less or equal to 15.
\n", + "type": "Number" + }, + { + "name": "framerate", + "description": "number of frames to save per second. This parameter will be constrained to be less or equal to 22.
\n", + "type": "Number" + }, + { + "name": "callback", + "description": "callback function that will be executed\n to handle the image data. This function\n should accept an array as argument. The\n array will contain the specified number of\n frames of objects. Each object has three\n properties: imageData
, filename
, and extension
.
path of the image to be loaded or base64 encoded image.
\n", + "type": "String" + }, + { + "name": "successCallback", + "description": "function called with\n p5.Image once it\n loads.
\n", + "type": "function(p5.Image)", + "optional": true + }, + { + "name": "failureCallback", + "description": "function called with event\n error if the image fails to load.
\n", + "type": "Function(Event)", + "optional": true + } + ], + "class": "p5", + "module": "Image" + }, + "saveGif": { + "name": "saveGif", + "params": [ + { + "name": "filename", + "description": "file name of gif.
\n", + "type": "String" + }, + { + "name": "duration", + "description": "duration in seconds to capture from the sketch.
\n", + "type": "Number" + }, + { + "name": "options", + "description": "an object that can contain five more properties:\n delay
, a Number specifying how much time to wait before recording;\n units
, a String that can be either 'seconds' or 'frames'. By default it's 'seconds’;\n silent
, a Boolean that defines presence of progress notifications. By default it’s false
;\n notificationDuration
, a Number that defines how long in seconds the final notification\n will live. By default it's 0
, meaning the notification will never be removed;\n notificationID
, a String that specifies the id of the notification's DOM element. By default it’s 'progressBar’
.
image to display.
\n", + "type": "p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture" + }, + { + "name": "x", + "description": "x-coordinate of the top-left corner of the image.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the top-left corner of the image.
\n", + "type": "Number" + }, + { + "name": "width", + "description": "width to draw the image.
\n", + "type": "Number", + "optional": true + }, + { + "name": "height", + "description": "height to draw the image.
\n", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "img", + "description": "", + "type": "p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture" + }, + { + "name": "dx", + "description": "the x-coordinate of the destination\n rectangle in which to draw the source image
\n", + "type": "Number" + }, + { + "name": "dy", + "description": "the y-coordinate of the destination\n rectangle in which to draw the source image
\n", + "type": "Number" + }, + { + "name": "dWidth", + "description": "the width of the destination rectangle
\n", + "type": "Number" + }, + { + "name": "dHeight", + "description": "the height of the destination rectangle
\n", + "type": "Number" + }, + { + "name": "sx", + "description": "the x-coordinate of the subsection of the source\nimage to draw into the destination rectangle
\n", + "type": "Number" + }, + { + "name": "sy", + "description": "the y-coordinate of the subsection of the source\nimage to draw into the destination rectangle
\n", + "type": "Number" + }, + { + "name": "sWidth", + "description": "the width of the subsection of the\n source image to draw into the destination\n rectangle
\n", + "type": "Number", + "optional": true + }, + { + "name": "sHeight", + "description": "the height of the subsection of the\n source image to draw into the destination rectangle
\n", + "type": "Number", + "optional": true + }, + { + "name": "fit", + "description": "either CONTAIN or COVER
\n", + "type": "Constant", + "optional": true + }, + { + "name": "xAlign", + "description": "either LEFT, RIGHT or CENTER default is CENTER
\n", + "type": "Constant", + "optional": true + }, + { + "name": "yAlign", + "description": "either TOP, BOTTOM or CENTER default is CENTER
\n", + "type": "Constant", + "optional": true + } + ] + } + ] + }, + "tint": { + "name": "tint", + "class": "p5", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value.
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value.
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "value", + "description": "CSS color string.
\n", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "gray", + "description": "grayscale value.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "values", + "description": "array containing the red, green, blue &\n alpha components of the color.
\n", + "type": "Number[]" + } + ] + }, + { + "params": [ + { + "name": "color", + "description": "the tint color
\n", + "type": "p5.Color" + } + ] + } + ] + }, + "noTint": { + "name": "noTint", + "class": "p5", + "module": "Image" + }, + "imageMode": { + "name": "imageMode", + "params": [ + { + "name": "mode", + "description": "either CORNER, CORNERS, or CENTER.
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "Image" + }, + "pixels": { + "name": "pixels", + "class": "p5", + "module": "Image" + }, + "blend": { + "name": "blend", + "class": "p5", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "srcImage", + "description": "source image.
\n", + "type": "p5.Image" + }, + { + "name": "sx", + "description": "x-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sy", + "description": "y-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sw", + "description": "source image width.
\n", + "type": "Integer" + }, + { + "name": "sh", + "description": "source image height.
\n", + "type": "Integer" + }, + { + "name": "dx", + "description": "x-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dy", + "description": "y-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dw", + "description": "destination image width.
\n", + "type": "Integer" + }, + { + "name": "dh", + "description": "destination image height.
\n", + "type": "Integer" + }, + { + "name": "blendMode", + "description": "the blend mode. either\n BLEND, DARKEST, LIGHTEST, DIFFERENCE,\n MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.
\n", + "type": "Constant" + } + ] + }, + { + "params": [ + { + "name": "sx", + "description": "", + "type": "Integer" + }, + { + "name": "sy", + "description": "", + "type": "Integer" + }, + { + "name": "sw", + "description": "", + "type": "Integer" + }, + { + "name": "sh", + "description": "", + "type": "Integer" + }, + { + "name": "dx", + "description": "", + "type": "Integer" + }, + { + "name": "dy", + "description": "", + "type": "Integer" + }, + { + "name": "dw", + "description": "", + "type": "Integer" + }, + { + "name": "dh", + "description": "", + "type": "Integer" + }, + { + "name": "blendMode", + "description": "", + "type": "Constant" + } + ] + } + ] + }, + "copy": { + "name": "copy", + "class": "p5", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "srcImage", + "description": "source image.
\n", + "type": "p5.Image|p5.Element" + }, + { + "name": "sx", + "description": "x-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sy", + "description": "y-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sw", + "description": "source image width.
\n", + "type": "Integer" + }, + { + "name": "sh", + "description": "source image height.
\n", + "type": "Integer" + }, + { + "name": "dx", + "description": "x-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dy", + "description": "y-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dw", + "description": "destination image width.
\n", + "type": "Integer" + }, + { + "name": "dh", + "description": "destination image height.
\n", + "type": "Integer" + } + ] + }, + { + "params": [ + { + "name": "sx", + "description": "", + "type": "Integer" + }, + { + "name": "sy", + "description": "", + "type": "Integer" + }, + { + "name": "sw", + "description": "", + "type": "Integer" + }, + { + "name": "sh", + "description": "", + "type": "Integer" + }, + { + "name": "dx", + "description": "", + "type": "Integer" + }, + { + "name": "dy", + "description": "", + "type": "Integer" + }, + { + "name": "dw", + "description": "", + "type": "Integer" + }, + { + "name": "dh", + "description": "", + "type": "Integer" + } + ] + } + ] + }, + "filter": { + "name": "filter", + "class": "p5", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "filterType", + "description": "either THRESHOLD, GRAY, OPAQUE, INVERT,\n POSTERIZE, BLUR, ERODE, DILATE or BLUR.
\n", + "type": "Constant" + }, + { + "name": "filterParam", + "description": "parameter unique to each filter.
\n", + "type": "Number", + "optional": true + }, + { + "name": "useWebGL", + "description": "flag to control whether to use fast\n WebGL filters (GPU) or original image\n filters (CPU); defaults to true
.
shader that's been loaded, with the\n frag shader using a tex0
uniform.
x-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "w", + "description": "width of the subsection to be returned.
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the subsection to be returned.
\n", + "type": "Number" + } + ] + }, + { + "params": [] + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + } + ] + } + ] + }, + "loadPixels": { + "name": "loadPixels", + "class": "p5", + "module": "Image" + }, + "set": { + "name": "set", + "params": [ + { + "name": "x", + "description": "x-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "c", + "description": "grayscale value | pixel array |\n p5.Color object | p5.Image to copy.
\n", + "type": "Number|Number[]|Object" + } + ], + "class": "p5", + "module": "Image" + }, + "updatePixels": { + "name": "updatePixels", + "params": [ + { + "name": "x", + "description": "x-coordinate of the upper-left corner of region\n to update.
\n", + "type": "Number", + "optional": true + }, + { + "name": "y", + "description": "y-coordinate of the upper-left corner of region\n to update.
\n", + "type": "Number", + "optional": true + }, + { + "name": "w", + "description": "width of region to update.
\n", + "type": "Number", + "optional": true + }, + { + "name": "h", + "description": "height of region to update.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Image" + }, + "loadJSON": { + "name": "loadJSON", + "class": "p5", + "module": "IO", + "overloads": [ + { + "params": [ + { + "name": "path", + "description": "name of the file or url to load
\n", + "type": "String" + }, + { + "name": "jsonpOptions", + "description": "options object for jsonp related settings
\n", + "type": "Object", + "optional": true + }, + { + "name": "datatype", + "description": "\"json\" or \"jsonp\"
\n", + "type": "String", + "optional": true + }, + { + "name": "callback", + "description": "function to be executed after\n loadJSON() completes, data is passed\n in as first argument
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if\n there is an error, response is passed\n in as first argument
\n", + "type": "Function", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "datatype", + "description": "", + "type": "String" + }, + { + "name": "callback", + "description": "", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "", + "type": "Function", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "callback", + "description": "", + "type": "Function" + }, + { + "name": "errorCallback", + "description": "", + "type": "Function", + "optional": true + } + ] + } + ] + }, + "loadStrings": { + "name": "loadStrings", + "params": [ + { + "name": "filename", + "description": "name of the file or url to load
\n", + "type": "String" + }, + { + "name": "callback", + "description": "function to be executed after loadStrings()\n completes, Array is passed in as first\n argument
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if\n there is an error, response is passed\n in as first argument
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "loadTable": { + "name": "loadTable", + "params": [ + { + "name": "filename", + "description": "name of the file or URL to load
\n", + "type": "String" + }, + { + "name": "extension", + "description": "parse the table by comma-separated values \"csv\", semicolon-separated\n values \"ssv\", or tab-separated values \"tsv\"
\n", + "type": "String", + "optional": true + }, + { + "name": "header", + "description": "\"header\" to indicate table has header row
\n", + "type": "String", + "optional": true + }, + { + "name": "callback", + "description": "function to be executed after\n loadTable() completes. On success, the\n Table object is passed in as the\n first argument.
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if\n there is an error, response is passed\n in as first argument
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "loadXML": { + "name": "loadXML", + "params": [ + { + "name": "filename", + "description": "name of the file or URL to load
\n", + "type": "String" + }, + { + "name": "callback", + "description": "function to be executed after loadXML()\n completes, XML object is passed in as\n first argument
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if\n there is an error, response is passed\n in as first argument
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "loadBytes": { + "name": "loadBytes", + "params": [ + { + "name": "file", + "description": "name of the file or URL to load
\n", + "type": "String" + }, + { + "name": "callback", + "description": "function to be executed after loadBytes()\n completes
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if there\n is an error
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "httpGet": { + "name": "httpGet", + "class": "p5", + "module": "IO", + "overloads": [ + { + "params": [ + { + "name": "path", + "description": "name of the file or url to load
\n", + "type": "String" + }, + { + "name": "datatype", + "description": "\"json\", \"jsonp\", \"binary\", \"arrayBuffer\",\n \"xml\", or \"text\"
\n", + "type": "String", + "optional": true + }, + { + "name": "data", + "description": "param data passed sent with request
\n", + "type": "Object|Boolean", + "optional": true + }, + { + "name": "callback", + "description": "function to be executed after\n httpGet() completes, data is passed in\n as first argument
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if\n there is an error, response is passed\n in as first argument
\n", + "type": "Function", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "data", + "description": "", + "type": "Object|Boolean" + }, + { + "name": "callback", + "description": "", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "", + "type": "Function", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "callback", + "description": "", + "type": "Function" + }, + { + "name": "errorCallback", + "description": "", + "type": "Function", + "optional": true + } + ] + } + ] + }, + "httpPost": { + "name": "httpPost", + "class": "p5", + "module": "IO", + "overloads": [ + { + "params": [ + { + "name": "path", + "description": "name of the file or url to load
\n", + "type": "String" + }, + { + "name": "datatype", + "description": "\"json\", \"jsonp\", \"xml\", or \"text\".\n If omitted, httpPost() will guess.
\n", + "type": "String", + "optional": true + }, + { + "name": "data", + "description": "param data passed sent with request
\n", + "type": "Object|Boolean", + "optional": true + }, + { + "name": "callback", + "description": "function to be executed after\n httpPost() completes, data is passed in\n as first argument
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if\n there is an error, response is passed\n in as first argument
\n", + "type": "Function", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "data", + "description": "", + "type": "Object|Boolean" + }, + { + "name": "callback", + "description": "", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "", + "type": "Function", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "callback", + "description": "", + "type": "Function" + }, + { + "name": "errorCallback", + "description": "", + "type": "Function", + "optional": true + } + ] + } + ] + }, + "httpDo": { + "name": "httpDo", + "class": "p5", + "module": "IO", + "overloads": [ + { + "params": [ + { + "name": "path", + "description": "name of the file or url to load
\n", + "type": "String" + }, + { + "name": "method", + "description": "either \"GET\", \"POST\", or \"PUT\",\n defaults to \"GET\"
\n", + "type": "String", + "optional": true + }, + { + "name": "datatype", + "description": "\"json\", \"jsonp\", \"xml\", or \"text\"
\n", + "type": "String", + "optional": true + }, + { + "name": "data", + "description": "param data passed sent with request
\n", + "type": "Object", + "optional": true + }, + { + "name": "callback", + "description": "function to be executed after\n httpGet() completes, data is passed in\n as first argument
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to be executed if\n there is an error, response is passed\n in as first argument
\n", + "type": "Function", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "options", + "description": "Request object options as documented in the\n \"fetch\" API\nreference
\n", + "type": "Object" + }, + { + "name": "callback", + "description": "", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "", + "type": "Function", + "optional": true + } + ] + } + ] + }, + "createWriter": { + "name": "createWriter", + "params": [ + { + "name": "name", + "description": "name of the file to be created
\n", + "type": "String" + }, + { + "name": "extension", + "description": "", + "type": "String", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "save": { + "name": "save", + "params": [ + { + "name": "objectOrFilename", + "description": "If filename is provided, will\n save canvas as an image with\n either png or jpg extension\n depending on the filename.\n If object is provided, will\n save depending on the object\n and filename (see examples\n above).
\n", + "type": "Object|String", + "optional": true + }, + { + "name": "filename", + "description": "If an object is provided as the first\n parameter, then the second parameter\n indicates the filename,\n and should include an appropriate\n file extension (see examples above).
\n", + "type": "String", + "optional": true + }, + { + "name": "options", + "description": "Additional options depend on\n filetype. For example, when saving JSON,\n true
indicates that the\n output will be optimized for filesize,\n rather than readability.
If true, removes line breaks\n and spaces from the output\n file to optimize filesize\n (but not readability).
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "saveStrings": { + "name": "saveStrings", + "params": [ + { + "name": "list", + "description": "string array to be written
\n", + "type": "String[]" + }, + { + "name": "filename", + "description": "filename for output
\n", + "type": "String" + }, + { + "name": "extension", + "description": "the filename's extension
\n", + "type": "String", + "optional": true + }, + { + "name": "isCRLF", + "description": "if true, change line-break to CRLF
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "saveTable": { + "name": "saveTable", + "params": [ + { + "name": "Table", + "description": "the Table object to save to a file
\n", + "type": "p5.Table" + }, + { + "name": "filename", + "description": "the filename to which the Table should be saved
\n", + "type": "String" + }, + { + "name": "options", + "description": "can be one of \"tsv\", \"csv\", or \"html\"
\n", + "type": "String", + "optional": true + } + ], + "class": "p5", + "module": "IO" + }, + "abs": { + "name": "abs", + "params": [ + { + "name": "n", + "description": "number to compute.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "ceil": { + "name": "ceil", + "params": [ + { + "name": "n", + "description": "number to round up.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "constrain": { + "name": "constrain", + "params": [ + { + "name": "n", + "description": "number to constrain.
\n", + "type": "Number" + }, + { + "name": "low", + "description": "minimum limit.
\n", + "type": "Number" + }, + { + "name": "high", + "description": "maximum limit.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "dist": { + "name": "dist", + "class": "p5", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x1", + "description": "x-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "y1", + "description": "y-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "x-coordinate of the second point.
\n", + "type": "Number" + }, + { + "name": "y2", + "description": "y-coordinate of the second point.
\n", + "type": "Number" + } + ] + }, + { + "params": [ + { + "name": "x1", + "description": "", + "type": "Number" + }, + { + "name": "y1", + "description": "", + "type": "Number" + }, + { + "name": "z1", + "description": "z-coordinate of the first point.
\n", + "type": "Number" + }, + { + "name": "x2", + "description": "", + "type": "Number" + }, + { + "name": "y2", + "description": "", + "type": "Number" + }, + { + "name": "z2", + "description": "z-coordinate of the second point.
\n", + "type": "Number" + } + ] + } + ] + }, + "exp": { + "name": "exp", + "params": [ + { + "name": "n", + "description": "exponent to raise.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "floor": { + "name": "floor", + "params": [ + { + "name": "n", + "description": "number to round down.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "lerp": { + "name": "lerp", + "params": [ + { + "name": "start", + "description": "first value.
\n", + "type": "Number" + }, + { + "name": "stop", + "description": "second value.
\n", + "type": "Number" + }, + { + "name": "amt", + "description": "number.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "log": { + "name": "log", + "params": [ + { + "name": "n", + "description": "number greater than 0.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "mag": { + "name": "mag", + "params": [ + { + "name": "x", + "description": "first component.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "second component.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "map": { + "name": "map", + "params": [ + { + "name": "value", + "description": "the incoming value to be converted.
\n", + "type": "Number" + }, + { + "name": "start1", + "description": "lower bound of the value's current range.
\n", + "type": "Number" + }, + { + "name": "stop1", + "description": "upper bound of the value's current range.
\n", + "type": "Number" + }, + { + "name": "start2", + "description": "lower bound of the value's target range.
\n", + "type": "Number" + }, + { + "name": "stop2", + "description": "upper bound of the value's target range.
\n", + "type": "Number" + }, + { + "name": "withinBounds", + "description": "constrain the value to the newly mapped range.
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "Math" + }, + "max": { + "name": "max", + "class": "p5", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "n0", + "description": "first number to compare.
\n", + "type": "Number" + }, + { + "name": "n1", + "description": "second number to compare.
\n", + "type": "Number" + } + ] + }, + { + "params": [ + { + "name": "nums", + "description": "numbers to compare.
\n", + "type": "Number[]" + } + ] + } + ] + }, + "min": { + "name": "min", + "class": "p5", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "n0", + "description": "first number to compare.
\n", + "type": "Number" + }, + { + "name": "n1", + "description": "second number to compare.
\n", + "type": "Number" + } + ] + }, + { + "params": [ + { + "name": "nums", + "description": "numbers to compare.
\n", + "type": "Number[]" + } + ] + } + ] + }, + "norm": { + "name": "norm", + "params": [ + { + "name": "value", + "description": "incoming value to be normalized.
\n", + "type": "Number" + }, + { + "name": "start", + "description": "lower bound of the value's current range.
\n", + "type": "Number" + }, + { + "name": "stop", + "description": "upper bound of the value's current range.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "pow": { + "name": "pow", + "params": [ + { + "name": "n", + "description": "base of the exponential expression.
\n", + "type": "Number" + }, + { + "name": "e", + "description": "power by which to raise the base.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "round": { + "name": "round", + "params": [ + { + "name": "n", + "description": "number to round.
\n", + "type": "Number" + }, + { + "name": "decimals", + "description": "number of decimal places to round to, default is 0.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Math" + }, + "sq": { + "name": "sq", + "params": [ + { + "name": "n", + "description": "number to square.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "sqrt": { + "name": "sqrt", + "params": [ + { + "name": "n", + "description": "non-negative number to square root.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "fract": { + "name": "fract", + "params": [ + { + "name": "n", + "description": "number whose fractional part will be found.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "createVector": { + "name": "createVector", + "params": [ + { + "name": "x", + "description": "x component of the vector.
\n", + "type": "Number", + "optional": true + }, + { + "name": "y", + "description": "y component of the vector.
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "z component of the vector.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Math" + }, + "noise": { + "name": "noise", + "params": [ + { + "name": "x", + "description": "x-coordinate in noise space.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate in noise space.
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "z-coordinate in noise space.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Math" + }, + "noiseDetail": { + "name": "noiseDetail", + "params": [ + { + "name": "lod", + "description": "number of octaves to be used by the noise.
\n", + "type": "Number" + }, + { + "name": "falloff", + "description": "falloff factor for each octave.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "noiseSeed": { + "name": "noiseSeed", + "params": [ + { + "name": "seed", + "description": "seed value.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "randomSeed": { + "name": "randomSeed", + "params": [ + { + "name": "seed", + "description": "seed value.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "random": { + "name": "random", + "class": "p5", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "min", + "description": "lower bound (inclusive).
\n", + "type": "Number", + "optional": true + }, + { + "name": "max", + "description": "upper bound (exclusive).
\n", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "choices", + "description": "array to choose from.
\n", + "type": "Array" + } + ] + } + ] + }, + "randomGaussian": { + "name": "randomGaussian", + "params": [ + { + "name": "mean", + "description": "mean.
\n", + "type": "Number", + "optional": true + }, + { + "name": "sd", + "description": "standard deviation.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Math" + }, + "acos": { + "name": "acos", + "params": [ + { + "name": "value", + "description": "value whose arc cosine is to be returned.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "asin": { + "name": "asin", + "params": [ + { + "name": "value", + "description": "value whose arc sine is to be returned.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "atan": { + "name": "atan", + "params": [ + { + "name": "value", + "description": "value whose arc tangent is to be returned.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "atan2": { + "name": "atan2", + "params": [ + { + "name": "y", + "description": "y-coordinate of the point.
\n", + "type": "Number" + }, + { + "name": "x", + "description": "x-coordinate of the point.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "cos": { + "name": "cos", + "params": [ + { + "name": "angle", + "description": "the angle.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "sin": { + "name": "sin", + "params": [ + { + "name": "angle", + "description": "the angle.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "tan": { + "name": "tan", + "params": [ + { + "name": "angle", + "description": "the angle.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "degrees": { + "name": "degrees", + "params": [ + { + "name": "radians", + "description": "radians value to convert to degrees.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "radians": { + "name": "radians", + "params": [ + { + "name": "degrees", + "description": "degree value to convert to radians.
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "Math" + }, + "angleMode": { + "name": "angleMode", + "class": "p5", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "mode", + "description": "either RADIANS or DEGREES.
\n", + "type": "Constant" + } + ] + }, + { + "params": [] + } + ] + }, + "textAlign": { + "name": "textAlign", + "class": "p5", + "module": "Typography", + "overloads": [ + { + "params": [ + { + "name": "horizAlign", + "description": "horizontal alignment, either LEFT,\n CENTER, or RIGHT.
\n", + "type": "Constant" + }, + { + "name": "vertAlign", + "description": "vertical alignment, either TOP,\n BOTTOM, CENTER, or BASELINE.
\n", + "type": "Constant", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "textLeading": { + "name": "textLeading", + "class": "p5", + "module": "Typography", + "overloads": [ + { + "params": [ + { + "name": "leading", + "description": "spacing between lines of text in units of pixels.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "textSize": { + "name": "textSize", + "class": "p5", + "module": "Typography", + "overloads": [ + { + "params": [ + { + "name": "size", + "description": "size of the letters in units of pixels
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "textStyle": { + "name": "textStyle", + "class": "p5", + "module": "Typography", + "overloads": [ + { + "params": [ + { + "name": "style", + "description": "styling for text, either NORMAL,\n ITALIC, BOLD or BOLDITALIC
\n", + "type": "Constant" + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "textWidth": { + "name": "textWidth", + "params": [ + { + "name": "str", + "description": "string of text to measure.
\n", + "type": "String" + } + ], + "class": "p5", + "module": "Typography" + }, + "textAscent": { + "name": "textAscent", + "class": "p5", + "module": "Typography" + }, + "textDescent": { + "name": "textDescent", + "class": "p5", + "module": "Typography" + }, + "textWrap": { + "name": "textWrap", + "params": [ + { + "name": "style", + "description": "text wrapping style, either WORD or CHAR.
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "Typography" + }, + "loadFont": { + "name": "loadFont", + "params": [ + { + "name": "path", + "description": "path of the font to be loaded.
\n", + "type": "String" + }, + { + "name": "successCallback", + "description": "function called with the\n p5.Font object after it\n loads.
\n", + "type": "Function", + "optional": true + }, + { + "name": "failureCallback", + "description": "function called with the error\n Event\n object if the font fails to load.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "Typography" + }, + "text": { + "name": "text", + "params": [ + { + "name": "str", + "description": "text to be displayed.
\n", + "type": "String|Object|Array|Number|Boolean" + }, + { + "name": "x", + "description": "x-coordinate of the text box.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the text box.
\n", + "type": "Number" + }, + { + "name": "maxWidth", + "description": "maximum width of the text box. See\n rectMode() for\n other options.
\n", + "type": "Number", + "optional": true + }, + { + "name": "maxHeight", + "description": "maximum height of the text box. See\n rectMode() for\n other options.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "Typography" + }, + "textFont": { + "name": "textFont", + "class": "p5", + "module": "Typography", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "font", + "description": "font as a p5.Font object or a string.
\n", + "type": "Object|String" + }, + { + "name": "size", + "description": "font size in pixels.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "append": { + "name": "append", + "params": [ + { + "name": "array", + "description": "Array to append
\n", + "type": "Array" + }, + { + "name": "value", + "description": "to be added to the Array
\n", + "type": "Any" + } + ], + "class": "p5", + "module": "Data" + }, + "arrayCopy": { + "name": "arrayCopy", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "src", + "description": "the source Array
\n", + "type": "Array" + }, + { + "name": "srcPosition", + "description": "starting position in the source Array
\n", + "type": "Integer" + }, + { + "name": "dst", + "description": "the destination Array
\n", + "type": "Array" + }, + { + "name": "dstPosition", + "description": "starting position in the destination Array
\n", + "type": "Integer" + }, + { + "name": "length", + "description": "number of Array elements to be copied
\n", + "type": "Integer" + } + ] + }, + { + "params": [ + { + "name": "src", + "description": "", + "type": "Array" + }, + { + "name": "dst", + "description": "", + "type": "Array" + }, + { + "name": "length", + "description": "", + "type": "Integer", + "optional": true + } + ] + } + ] + }, + "concat": { + "name": "concat", + "params": [ + { + "name": "a", + "description": "first Array to concatenate
\n", + "type": "Array" + }, + { + "name": "b", + "description": "second Array to concatenate
\n", + "type": "Array" + } + ], + "class": "p5", + "module": "Data" + }, + "reverse": { + "name": "reverse", + "params": [ + { + "name": "list", + "description": "Array to reverse
\n", + "type": "Array" + } + ], + "class": "p5", + "module": "Data" + }, + "shorten": { + "name": "shorten", + "params": [ + { + "name": "list", + "description": "Array to shorten
\n", + "type": "Array" + } + ], + "class": "p5", + "module": "Data" + }, + "shuffle": { + "name": "shuffle", + "params": [ + { + "name": "array", + "description": "Array to shuffle
\n", + "type": "Array" + }, + { + "name": "bool", + "description": "modify passed array
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "Data" + }, + "sort": { + "name": "sort", + "params": [ + { + "name": "list", + "description": "Array to sort
\n", + "type": "Array" + }, + { + "name": "count", + "description": "number of elements to sort, starting from 0
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Data" + }, + "splice": { + "name": "splice", + "params": [ + { + "name": "list", + "description": "Array to splice into
\n", + "type": "Array" + }, + { + "name": "value", + "description": "value to be spliced in
\n", + "type": "Any" + }, + { + "name": "position", + "description": "in the array from which to insert data
\n", + "type": "Integer" + } + ], + "class": "p5", + "module": "Data" + }, + "subset": { + "name": "subset", + "params": [ + { + "name": "list", + "description": "Array to extract from
\n", + "type": "Array" + }, + { + "name": "start", + "description": "position to begin
\n", + "type": "Integer" + }, + { + "name": "count", + "description": "number of values to extract
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Data" + }, + "float": { + "name": "float", + "params": [ + { + "name": "str", + "description": "float string to parse
\n", + "type": "String" + } + ], + "class": "p5", + "module": "Data" + }, + "int": { + "name": "int", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "String|Boolean|Number" + }, + { + "name": "radix", + "description": "the radix to convert to (default: 10)
\n", + "type": "Integer", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "ns", + "description": "values to parse
\n", + "type": "Array" + }, + { + "name": "radix", + "description": "", + "type": "Integer", + "optional": true + } + ] + } + ] + }, + "str": { + "name": "str", + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "String|Boolean|Number|Array" + } + ], + "class": "p5", + "module": "Data" + }, + "byte": { + "name": "byte", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "String|Boolean|Number" + } + ] + }, + { + "params": [ + { + "name": "ns", + "description": "values to parse
\n", + "type": "Array" + } + ] + } + ] + }, + "char": { + "name": "char", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "String|Number" + } + ] + }, + { + "params": [ + { + "name": "ns", + "description": "values to parse
\n", + "type": "Array" + } + ] + } + ] + }, + "unchar": { + "name": "unchar", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "ns", + "description": "values to parse
\n", + "type": "Array" + } + ] + } + ] + }, + "hex": { + "name": "hex", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "Number" + }, + { + "name": "digits", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "ns", + "description": "array of values to parse
\n", + "type": "Number[]" + }, + { + "name": "digits", + "description": "", + "type": "Number", + "optional": true + } + ] + } + ] + }, + "unhex": { + "name": "unhex", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "value to parse
\n", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "ns", + "description": "values to parse
\n", + "type": "Array" + } + ] + } + ] + }, + "join": { + "name": "join", + "params": [ + { + "name": "list", + "description": "array of Strings to be joined
\n", + "type": "Array" + }, + { + "name": "separator", + "description": "String to be placed between each item
\n", + "type": "String" + } + ], + "class": "p5", + "module": "Data" + }, + "match": { + "name": "match", + "params": [ + { + "name": "str", + "description": "the String to be searched
\n", + "type": "String" + }, + { + "name": "regexp", + "description": "the regexp to be used for matching
\n", + "type": "String" + } + ], + "class": "p5", + "module": "Data" + }, + "matchAll": { + "name": "matchAll", + "params": [ + { + "name": "str", + "description": "the String to be searched
\n", + "type": "String" + }, + { + "name": "regexp", + "description": "the regexp to be used for matching
\n", + "type": "String" + } + ], + "class": "p5", + "module": "Data" + }, + "nf": { + "name": "nf", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "num", + "description": "the Number to format
\n", + "type": "Number|String" + }, + { + "name": "left", + "description": "number of digits to the left of the\n decimal point
\n", + "type": "Integer|String", + "optional": true + }, + { + "name": "right", + "description": "number of digits to the right of the\n decimal point
\n", + "type": "Integer|String", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "nums", + "description": "the Numbers to format
\n", + "type": "Array" + }, + { + "name": "left", + "description": "", + "type": "Integer|String", + "optional": true + }, + { + "name": "right", + "description": "", + "type": "Integer|String", + "optional": true + } + ] + } + ] + }, + "nfc": { + "name": "nfc", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "num", + "description": "the Number to format
\n", + "type": "Number|String" + }, + { + "name": "right", + "description": "number of digits to the right of the\n decimal point
\n", + "type": "Integer|String", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "nums", + "description": "the Numbers to format
\n", + "type": "Array" + }, + { + "name": "right", + "description": "", + "type": "Integer|String", + "optional": true + } + ] + } + ] + }, + "nfp": { + "name": "nfp", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "num", + "description": "the Number to format
\n", + "type": "Number" + }, + { + "name": "left", + "description": "number of digits to the left of the decimal\n point
\n", + "type": "Integer", + "optional": true + }, + { + "name": "right", + "description": "number of digits to the right of the\n decimal point
\n", + "type": "Integer", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "nums", + "description": "the Numbers to format
\n", + "type": "Number[]" + }, + { + "name": "left", + "description": "", + "type": "Integer", + "optional": true + }, + { + "name": "right", + "description": "", + "type": "Integer", + "optional": true + } + ] + } + ] + }, + "nfs": { + "name": "nfs", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "num", + "description": "the Number to format
\n", + "type": "Number" + }, + { + "name": "left", + "description": "number of digits to the left of the decimal\n point
\n", + "type": "Integer", + "optional": true + }, + { + "name": "right", + "description": "number of digits to the right of the\n decimal point
\n", + "type": "Integer", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "nums", + "description": "the Numbers to format
\n", + "type": "Array" + }, + { + "name": "left", + "description": "", + "type": "Integer", + "optional": true + }, + { + "name": "right", + "description": "", + "type": "Integer", + "optional": true + } + ] + } + ] + }, + "split": { + "name": "split", + "params": [ + { + "name": "value", + "description": "the String to be split
\n", + "type": "String" + }, + { + "name": "delim", + "description": "the String used to separate the data
\n", + "type": "String" + } + ], + "class": "p5", + "module": "Data" + }, + "splitTokens": { + "name": "splitTokens", + "params": [ + { + "name": "value", + "description": "the String to be split
\n", + "type": "String" + }, + { + "name": "delim", + "description": "list of individual Strings that will be used as\n separators
\n", + "type": "String", + "optional": true + } + ], + "class": "p5", + "module": "Data" + }, + "trim": { + "name": "trim", + "class": "p5", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "str", + "description": "a String to be trimmed
\n", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "strs", + "description": "an Array of Strings to be trimmed
\n", + "type": "Array" + } + ] + } + ] + }, + "day": { + "name": "day", + "class": "p5", + "module": "IO" + }, + "hour": { + "name": "hour", + "class": "p5", + "module": "IO" + }, + "minute": { + "name": "minute", + "class": "p5", + "module": "IO" + }, + "millis": { + "name": "millis", + "class": "p5", + "module": "IO" + }, + "month": { + "name": "month", + "class": "p5", + "module": "IO" + }, + "second": { + "name": "second", + "class": "p5", + "module": "IO" + }, + "year": { + "name": "year", + "class": "p5", + "module": "IO" + }, + "beginGeometry": { + "name": "beginGeometry", + "class": "p5", + "module": "Shape" + }, + "endGeometry": { + "name": "endGeometry", + "class": "p5", + "module": "Shape" + }, + "buildGeometry": { + "name": "buildGeometry", + "params": [ + { + "name": "callback", + "description": "A function that draws shapes.
\n", + "type": "Function" + } + ], + "class": "p5", + "module": "Shape" + }, + "freeGeometry": { + "name": "freeGeometry", + "params": [ + { + "name": "geometry", + "description": "The geometry whose resources should be freed
\n", + "type": "p5.Geometry" + } + ], + "class": "p5", + "module": "Shape" + }, + "plane": { + "name": "plane", + "params": [ + { + "name": "width", + "description": "width of the plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "height", + "description": "height of the plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "detailX", + "description": "Optional number of triangle\n subdivisions in x-dimension
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "Optional number of triangle\n subdivisions in y-dimension
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "box": { + "name": "box", + "params": [ + { + "name": "width", + "description": "width of the box
\n", + "type": "Number", + "optional": true + }, + { + "name": "height", + "description": "height of the box
\n", + "type": "Number", + "optional": true + }, + { + "name": "depth", + "description": "depth of the box
\n", + "type": "Number", + "optional": true + }, + { + "name": "detailX", + "description": "Optional number of triangle\n subdivisions in x-dimension
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "Optional number of triangle\n subdivisions in y-dimension
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "sphere": { + "name": "sphere", + "params": [ + { + "name": "radius", + "description": "radius of circle
\n", + "type": "Number", + "optional": true + }, + { + "name": "detailX", + "description": "optional number of subdivisions in x-dimension
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "optional number of subdivisions in y-dimension
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "cylinder": { + "name": "cylinder", + "params": [ + { + "name": "radius", + "description": "radius of the surface
\n", + "type": "Number", + "optional": true + }, + { + "name": "height", + "description": "height of the cylinder
\n", + "type": "Number", + "optional": true + }, + { + "name": "detailX", + "description": "number of subdivisions in x-dimension;\n default is 24
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "number of subdivisions in y-dimension;\n default is 1
\n", + "type": "Integer", + "optional": true + }, + { + "name": "bottomCap", + "description": "whether to draw the bottom of the cylinder
\n", + "type": "Boolean", + "optional": true + }, + { + "name": "topCap", + "description": "whether to draw the top of the cylinder
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "cone": { + "name": "cone", + "params": [ + { + "name": "radius", + "description": "radius of the bottom surface
\n", + "type": "Number", + "optional": true + }, + { + "name": "height", + "description": "height of the cone
\n", + "type": "Number", + "optional": true + }, + { + "name": "detailX", + "description": "number of segments,\n the more segments the smoother geometry\n default is 24
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "number of segments,\n the more segments the smoother geometry\n default is 1
\n", + "type": "Integer", + "optional": true + }, + { + "name": "cap", + "description": "whether to draw the base of the cone
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "ellipsoid": { + "name": "ellipsoid", + "params": [ + { + "name": "radiusx", + "description": "x-radius of ellipsoid
\n", + "type": "Number", + "optional": true + }, + { + "name": "radiusy", + "description": "y-radius of ellipsoid
\n", + "type": "Number", + "optional": true + }, + { + "name": "radiusz", + "description": "z-radius of ellipsoid
\n", + "type": "Number", + "optional": true + }, + { + "name": "detailX", + "description": "number of segments,\n the more segments the smoother geometry\n default is 24. Avoid detail number above\n 150, it may crash the browser.
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "number of segments,\n the more segments the smoother geometry\n default is 16. Avoid detail number above\n 150, it may crash the browser.
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "torus": { + "name": "torus", + "params": [ + { + "name": "radius", + "description": "radius of the whole ring
\n", + "type": "Number", + "optional": true + }, + { + "name": "tubeRadius", + "description": "radius of the tube
\n", + "type": "Number", + "optional": true + }, + { + "name": "detailX", + "description": "number of segments in x-dimension,\n the more segments the smoother geometry\n default is 24
\n", + "type": "Integer", + "optional": true + }, + { + "name": "detailY", + "description": "number of segments in y-dimension,\n the more segments the smoother geometry\n default is 16
\n", + "type": "Integer", + "optional": true + } + ], + "class": "p5", + "module": "Shape" + }, + "orbitControl": { + "name": "orbitControl", + "params": [ + { + "name": "sensitivityX", + "description": "sensitivity to mouse movement along X axis
\n", + "type": "Number", + "optional": true + }, + { + "name": "sensitivityY", + "description": "sensitivity to mouse movement along Y axis
\n", + "type": "Number", + "optional": true + }, + { + "name": "sensitivityZ", + "description": "sensitivity to scroll movement along Z axis
\n", + "type": "Number", + "optional": true + }, + { + "name": "options", + "description": "An optional object that can contain additional settings,\ndisableTouchActions - Boolean, default value is true.\nSetting this to true makes mobile interactions smoother by preventing\naccidental interactions with the page while orbiting. But if you're already\ndoing it via css or want the default touch actions, consider setting it to false.\nfreeRotation - Boolean, default value is false.\nBy default, horizontal movement of the mouse or touch pointer rotates the camera\naround the y-axis, and vertical movement rotates the camera around the x-axis.\nBut if setting this option to true, the camera always rotates in the direction\nthe pointer is moving. For zoom and move, the behavior is the same regardless of\ntrue/false.
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5", + "module": "3D" + }, + "debugMode": { + "name": "debugMode", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "mode", + "description": "either GRID or AXES
\n", + "type": "Constant" + } + ] + }, + { + "params": [ + { + "name": "mode", + "description": "", + "type": "Constant" + }, + { + "name": "gridSize", + "description": "size of one side of the grid
\n", + "type": "Number", + "optional": true + }, + { + "name": "gridDivisions", + "description": "number of divisions in the grid
\n", + "type": "Number", + "optional": true + }, + { + "name": "xOff", + "description": "X axis offset from origin (0,0,0)
\n", + "type": "Number", + "optional": true + }, + { + "name": "yOff", + "description": "Y axis offset from origin (0,0,0)
\n", + "type": "Number", + "optional": true + }, + { + "name": "zOff", + "description": "Z axis offset from origin (0,0,0)
\n", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "mode", + "description": "", + "type": "Constant" + }, + { + "name": "axesSize", + "description": "size of axes icon
\n", + "type": "Number", + "optional": true + }, + { + "name": "xOff", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "yOff", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "zOff", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "gridSize", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "gridDivisions", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "gridXOff", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "gridYOff", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "gridZOff", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "axesSize", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "axesXOff", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "axesYOff", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "axesZOff", + "description": "", + "type": "Number", + "optional": true + } + ] + } + ] + }, + "noDebugMode": { + "name": "noDebugMode", + "class": "p5", + "module": "3D" + }, + "ambientLight": { + "name": "ambientLight", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to\n the current color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value\n relative to the current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value\n relative to the current color range
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "alpha value relative to current\n color range (default is 0-255)
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "gray", + "description": "number specifying value between\n white and black
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "a color string
\n", + "type": "String" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "values", + "description": "an array containing the red,green,blue &\n and alpha components of the color
\n", + "type": "Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color
\n", + "type": "p5.Color" + } + ], + "chainable": 1 + } + ] + }, + "specularColor": { + "name": "specularColor", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to\n the current color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value\n relative to the current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value\n relative to the current color range
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "gray", + "description": "number specifying value between\n white and black
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "color as a CSS string
\n", + "type": "String" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "values", + "description": "color as an array containing the\n red, green, and blue components
\n", + "type": "Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color
\n", + "type": "p5.Color" + } + ], + "chainable": 1 + } + ] + }, + "directionalLight": { + "name": "directionalLight", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to the current\n color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value relative to the\n current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value relative to the\n current color range
\n", + "type": "Number" + }, + { + "name": "x", + "description": "x component of direction (inclusive range of -1 to 1)
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component of direction (inclusive range of -1 to 1)
\n", + "type": "Number" + }, + { + "name": "z", + "description": "z component of direction (inclusive range of -1 to 1)
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "", + "type": "Number" + }, + { + "name": "v2", + "description": "", + "type": "Number" + }, + { + "name": "v3", + "description": "", + "type": "Number" + }, + { + "name": "direction", + "description": "direction of light as a\n p5.Vector
\n", + "type": "p5.Vector" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color,\n as an array, or as a CSS string
\n", + "type": "p5.Color|Number[]|String" + }, + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "", + "type": "p5.Color|Number[]|String" + }, + { + "name": "direction", + "description": "", + "type": "p5.Vector" + } + ], + "chainable": 1 + } + ] + }, + "pointLight": { + "name": "pointLight", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to the current\n color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value relative to the\n current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value relative to the\n current color range
\n", + "type": "Number" + }, + { + "name": "x", + "description": "x component of position
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component of position
\n", + "type": "Number" + }, + { + "name": "z", + "description": "z component of position
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "", + "type": "Number" + }, + { + "name": "v2", + "description": "", + "type": "Number" + }, + { + "name": "v3", + "description": "", + "type": "Number" + }, + { + "name": "position", + "description": "of light as a p5.Vector
\n", + "type": "p5.Vector" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color,\n as an array, or as a CSS string
\n", + "type": "p5.Color|Number[]|String" + }, + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "", + "type": "p5.Color|Number[]|String" + }, + { + "name": "position", + "description": "", + "type": "p5.Vector" + } + ], + "chainable": 1 + } + ] + }, + "imageLight": { + "name": "imageLight", + "params": [ + { + "name": "img", + "description": "image for the background
\n", + "type": "p5.image" + } + ], + "class": "p5", + "module": "3D" + }, + "lights": { + "name": "lights", + "class": "p5", + "module": "3D" + }, + "lightFalloff": { + "name": "lightFalloff", + "params": [ + { + "name": "constant", + "description": "CONSTANT value for determining falloff
\n", + "type": "Number" + }, + { + "name": "linear", + "description": "LINEAR value for determining falloff
\n", + "type": "Number" + }, + { + "name": "quadratic", + "description": "QUADRATIC value for determining falloff
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "3D" + }, + "spotLight": { + "name": "spotLight", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to the current color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value relative to the current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value relative to the current color range
\n", + "type": "Number" + }, + { + "name": "x", + "description": "x component of position
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component of position
\n", + "type": "Number" + }, + { + "name": "z", + "description": "z component of position
\n", + "type": "Number" + }, + { + "name": "rx", + "description": "x component of light direction (inclusive range of -1 to 1)
\n", + "type": "Number" + }, + { + "name": "ry", + "description": "y component of light direction (inclusive range of -1 to 1)
\n", + "type": "Number" + }, + { + "name": "rz", + "description": "z component of light direction (inclusive range of -1 to 1)
\n", + "type": "Number" + }, + { + "name": "angle", + "description": "angle of cone. Defaults to PI/3
\n", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "concentration of cone. Defaults to 100
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color,\n as an array, or as a CSS string
\n", + "type": "p5.Color|Number[]|String" + }, + { + "name": "position", + "description": "position of light as a p5.Vector
\n", + "type": "p5.Vector" + }, + { + "name": "direction", + "description": "direction of light as a p5.Vector
\n", + "type": "p5.Vector" + }, + { + "name": "angle", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "", + "type": "Number" + }, + { + "name": "v2", + "description": "", + "type": "Number" + }, + { + "name": "v3", + "description": "", + "type": "Number" + }, + { + "name": "position", + "description": "", + "type": "p5.Vector" + }, + { + "name": "direction", + "description": "", + "type": "p5.Vector" + }, + { + "name": "angle", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "color", + "description": "", + "type": "p5.Color|Number[]|String" + }, + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number" + }, + { + "name": "direction", + "description": "", + "type": "p5.Vector" + }, + { + "name": "angle", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "color", + "description": "", + "type": "p5.Color|Number[]|String" + }, + { + "name": "position", + "description": "", + "type": "p5.Vector" + }, + { + "name": "rx", + "description": "", + "type": "Number" + }, + { + "name": "ry", + "description": "", + "type": "Number" + }, + { + "name": "rz", + "description": "", + "type": "Number" + }, + { + "name": "angle", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "", + "type": "Number" + }, + { + "name": "v2", + "description": "", + "type": "Number" + }, + { + "name": "v3", + "description": "", + "type": "Number" + }, + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number" + }, + { + "name": "direction", + "description": "", + "type": "p5.Vector" + }, + { + "name": "angle", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "", + "type": "Number" + }, + { + "name": "v2", + "description": "", + "type": "Number" + }, + { + "name": "v3", + "description": "", + "type": "Number" + }, + { + "name": "position", + "description": "", + "type": "p5.Vector" + }, + { + "name": "rx", + "description": "", + "type": "Number" + }, + { + "name": "ry", + "description": "", + "type": "Number" + }, + { + "name": "rz", + "description": "", + "type": "Number" + }, + { + "name": "angle", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "color", + "description": "", + "type": "p5.Color|Number[]|String" + }, + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number" + }, + { + "name": "rx", + "description": "", + "type": "Number" + }, + { + "name": "ry", + "description": "", + "type": "Number" + }, + { + "name": "rz", + "description": "", + "type": "Number" + }, + { + "name": "angle", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "concentration", + "description": "", + "type": "Number", + "optional": true + } + ] + } + ] + }, + "noLights": { + "name": "noLights", + "class": "p5", + "module": "3D" + }, + "loadModel": { + "name": "loadModel", + "class": "p5", + "module": "Shape", + "overloads": [ + { + "params": [ + { + "name": "path", + "description": "Path of the model to be loaded
\n", + "type": "String" + }, + { + "name": "normalize", + "description": "If true, scale the model to a\n standardized size when loading
\n", + "type": "Boolean" + }, + { + "name": "successCallback", + "description": "Function to be called\n once the model is loaded. Will be passed\n the 3D model object.
\n", + "type": "function(p5.Geometry)", + "optional": true + }, + { + "name": "failureCallback", + "description": "called with event error if\n the model fails to load.
\n", + "type": "Function(Event)", + "optional": true + }, + { + "name": "fileType", + "description": "The file extension of the model\n (.stl
, .obj
).
Loaded 3d model to be rendered
\n", + "type": "p5.Geometry" + } + ], + "class": "p5", + "module": "Shape" + }, + "loadShader": { + "name": "loadShader", + "params": [ + { + "name": "vertFilename", + "description": "path to file containing vertex shader\nsource code
\n", + "type": "String" + }, + { + "name": "fragFilename", + "description": "path to file containing fragment shader\nsource code
\n", + "type": "String" + }, + { + "name": "callback", + "description": "callback to be executed after loadShader\ncompletes. On success, the p5.Shader object is passed as the first argument.
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "callback to be executed when an error\noccurs inside loadShader. On error, the error is passed as the first\nargument.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "3D" + }, + "createShader": { + "name": "createShader", + "params": [ + { + "name": "vertSrc", + "description": "source code for the vertex shader
\n", + "type": "String" + }, + { + "name": "fragSrc", + "description": "source code for the fragment shader
\n", + "type": "String" + } + ], + "class": "p5", + "module": "3D" + }, + "createFilterShader": { + "name": "createFilterShader", + "params": [ + { + "name": "fragSrc", + "description": "source code for the fragment shader
\n", + "type": "String" + } + ], + "class": "p5", + "module": "3D" + }, + "shader": { + "name": "shader", + "params": [ + { + "name": "s", + "description": "the p5.Shader object\nto use for rendering shapes.
\n", + "type": "p5.Shader" + } + ], + "class": "p5", + "module": "3D" + }, + "resetShader": { + "name": "resetShader", + "class": "p5", + "module": "3D" + }, + "texture": { + "name": "texture", + "params": [ + { + "name": "tex", + "description": "image to use as texture
\n", + "type": "p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture" + } + ], + "class": "p5", + "module": "3D" + }, + "textureMode": { + "name": "textureMode", + "params": [ + { + "name": "mode", + "description": "either IMAGE or NORMAL
\n", + "type": "Constant" + } + ], + "class": "p5", + "module": "3D" + }, + "textureWrap": { + "name": "textureWrap", + "params": [ + { + "name": "wrapX", + "description": "either CLAMP, REPEAT, or MIRROR
\n", + "type": "Constant" + }, + { + "name": "wrapY", + "description": "either CLAMP, REPEAT, or MIRROR
\n", + "type": "Constant", + "optional": true + } + ], + "class": "p5", + "module": "3D" + }, + "normalMaterial": { + "name": "normalMaterial", + "class": "p5", + "module": "3D" + }, + "ambientMaterial": { + "name": "ambientMaterial", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to the current\n color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value relative to the\n current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value relative to the\n current color range
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "gray", + "description": "number specifying value between\n white and black
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color,\n as an array, or as a CSS string
\n", + "type": "p5.Color|Number[]|String" + } + ], + "chainable": 1 + } + ] + }, + "emissiveMaterial": { + "name": "emissiveMaterial", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to the current\n color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value relative to the\n current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value relative to the\n current color range
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "alpha value relative to current color\n range (default is 0-255)
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "gray", + "description": "number specifying value between\n white and black
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color,\n as an array, or as a CSS string
\n", + "type": "p5.Color|Number[]|String" + } + ], + "chainable": 1 + } + ] + }, + "specularMaterial": { + "name": "specularMaterial", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "gray", + "description": "number specifying value between white and black.
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "alpha value relative to current color range\n (default is 0-255)
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "red or hue value relative to\n the current color range
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "green or saturation value\n relative to the current color range
\n", + "type": "Number" + }, + { + "name": "v3", + "description": "blue or brightness value\n relative to the current color range
\n", + "type": "Number" + }, + { + "name": "alpha", + "description": "", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "color", + "description": "color as a p5.Color,\n as an array, or as a CSS string
\n", + "type": "p5.Color|Number[]|String" + } + ], + "chainable": 1 + } + ] + }, + "shininess": { + "name": "shininess", + "params": [ + { + "name": "shine", + "description": "degree of shininess
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "3D" + }, + "metalness": { + "name": "metalness", + "params": [ + { + "name": "metallic", + "description": "camera position value on x axis
\n", + "type": "Number", + "optional": true + }, + { + "name": "y", + "description": "camera position value on y axis
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "camera position value on z axis
\n", + "type": "Number", + "optional": true + }, + { + "name": "centerX", + "description": "x coordinate representing center of the sketch
\n", + "type": "Number", + "optional": true + }, + { + "name": "centerY", + "description": "y coordinate representing center of the sketch
\n", + "type": "Number", + "optional": true + }, + { + "name": "centerZ", + "description": "z coordinate representing center of the sketch
\n", + "type": "Number", + "optional": true + }, + { + "name": "upX", + "description": "x component of direction 'up' from camera
\n", + "type": "Number", + "optional": true + }, + { + "name": "upY", + "description": "y component of direction 'up' from camera
\n", + "type": "Number", + "optional": true + }, + { + "name": "upZ", + "description": "z component of direction 'up' from camera
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "3D" + }, + "perspective": { + "name": "perspective", + "params": [ + { + "name": "fovy", + "description": "camera frustum vertical field of view,\n from bottom to top of view, in angleMode units
\n", + "type": "Number", + "optional": true + }, + { + "name": "aspect", + "description": "camera frustum aspect ratio
\n", + "type": "Number", + "optional": true + }, + { + "name": "near", + "description": "frustum near plane length
\n", + "type": "Number", + "optional": true + }, + { + "name": "far", + "description": "frustum far plane length
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "3D" + }, + "linePerspective": { + "name": "linePerspective", + "class": "p5", + "module": "3D", + "overloads": [ + { + "params": [ + { + "name": "enable", + "description": "true
to enable line perspective, false
to disable.camera frustum left plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "right", + "description": "camera frustum right plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "bottom", + "description": "camera frustum bottom plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "top", + "description": "camera frustum top plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "near", + "description": "camera frustum near plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "far", + "description": "camera frustum far plane
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "3D" + }, + "frustum": { + "name": "frustum", + "params": [ + { + "name": "left", + "description": "camera frustum left plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "right", + "description": "camera frustum right plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "bottom", + "description": "camera frustum bottom plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "top", + "description": "camera frustum top plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "near", + "description": "camera frustum near plane
\n", + "type": "Number", + "optional": true + }, + { + "name": "far", + "description": "camera frustum far plane
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "3D" + }, + "createCamera": { + "name": "createCamera", + "class": "p5", + "module": "3D" + }, + "setCamera": { + "name": "setCamera", + "params": [ + { + "name": "cam", + "description": "p5.Camera object
\n", + "type": "p5.Camera" + } + ], + "class": "p5", + "module": "3D" + }, + "setAttributes": { + "name": "setAttributes", + "class": "p5", + "module": "Rendering", + "overloads": [ + { + "params": [ + { + "name": "key", + "description": "Name of attribute
\n", + "type": "String" + }, + { + "name": "value", + "description": "New value of named attribute
\n", + "type": "Boolean" + } + ] + }, + { + "params": [ + { + "name": "obj", + "description": "object with key-value pairs
\n", + "type": "Object" + } + ] + } + ] + }, + "getAudioContext": { + "name": "getAudioContext", + "class": "p5", + "module": "p5.sound" + }, + "userStartAudio": { + "params": [ + { + "name": "elements", + "description": "This argument can be an Element,\n Selector String, NodeList, p5.Element,\n jQuery Element, or an Array of any of those.
\n", + "type": "Element|Array", + "optional": true + }, + { + "name": "callback", + "description": "Callback to invoke when the AudioContext\n has started
\n", + "type": "Function", + "optional": true + } + ], + "name": "userStartAudio", + "class": "p5", + "module": "p5.sound" + }, + "getOutputVolume": { + "name": "getOutputVolume", + "class": "p5", + "module": "p5.sound" + }, + "outputVolume": { + "name": "outputVolume", + "params": [ + { + "name": "volume", + "description": "Volume (amplitude) between 0.0\n and 1.0 or modulating signal/oscillator
\n", + "type": "Number|Object" + }, + { + "name": "rampTime", + "description": "Fade for t seconds
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "Schedule this event to happen at\n t seconds in the future
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5", + "module": "p5.sound" + }, + "soundOut": { + "name": "soundOut", + "class": "p5", + "module": "p5.sound" + }, + "sampleRate": { + "name": "sampleRate", + "class": "p5", + "module": "p5.sound" + }, + "freqToMidi": { + "name": "freqToMidi", + "params": [ + { + "name": "frequency", + "description": "A freqeuncy, for example, the \"A\"\n above Middle C is 440Hz
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "p5.sound" + }, + "midiToFreq": { + "name": "midiToFreq", + "params": [ + { + "name": "midiNote", + "description": "The number of a MIDI note
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "p5.sound" + }, + "soundFormats": { + "name": "soundFormats", + "params": [ + { + "name": "formats", + "description": "i.e. 'mp3', 'wav', 'ogg'
\n", + "type": "String", + "optional": true, + "multiple": true + } + ], + "class": "p5", + "module": "p5.sound" + }, + "saveSound": { + "name": "saveSound", + "params": [ + { + "name": "soundFile", + "description": "p5.SoundFile that you wish to save
\n", + "type": "p5.SoundFile" + }, + { + "name": "fileName", + "description": "name of the resulting .wav file.
\n", + "type": "String" + } + ], + "class": "p5", + "module": "p5.sound" + }, + "loadSound": { + "name": "loadSound", + "params": [ + { + "name": "path", + "description": "Path to the sound file, or an array with\n paths to soundfiles in multiple formats\n i.e. ['sound.ogg', 'sound.mp3'].\n Alternately, accepts an object: either\n from the HTML5 File API, or a p5.File.
\n", + "type": "String|Array" + }, + { + "name": "successCallback", + "description": "Name of a function to call once file loads
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "Name of a function to call if there is\n an error loading the file.
\n", + "type": "Function", + "optional": true + }, + { + "name": "whileLoading", + "description": "Name of a function to call while file is loading.\n This function will receive the percentage loaded\n so far, from 0.0 to 1.0.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "p5.sound" + }, + "createConvolver": { + "name": "createConvolver", + "params": [ + { + "name": "path", + "description": "path to a sound file
\n", + "type": "String" + }, + { + "name": "callback", + "description": "function to call if loading is successful.\n The object will be passed in as the argument\n to the callback function.
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "function to call if loading is not successful.\n A custom error will be passed in as the argument\n to the callback function.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5", + "module": "p5.sound" + }, + "setBPM": { + "name": "setBPM", + "params": [ + { + "name": "BPM", + "description": "Beats Per Minute
\n", + "type": "Number" + }, + { + "name": "rampTime", + "description": "Seconds from now
\n", + "type": "Number" + } + ], + "class": "p5", + "module": "p5.sound" + } + }, + "p5.Color": { + "toString": { + "name": "toString", + "params": [ + { + "name": "format", + "description": "how the color string will be formatted.\nLeaving this empty formats the string as rgba(r, g, b, a).\n'#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes.\n'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode.\n'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels.\n'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.Color", + "module": "Color" + }, + "setRed": { + "name": "setRed", + "params": [ + { + "name": "red", + "description": "the new red value.
\n", + "type": "Number" + } + ], + "class": "p5.Color", + "module": "Color" + }, + "setGreen": { + "name": "setGreen", + "params": [ + { + "name": "green", + "description": "the new green value.
\n", + "type": "Number" + } + ], + "class": "p5.Color", + "module": "Color" + }, + "setBlue": { + "name": "setBlue", + "params": [ + { + "name": "blue", + "description": "the new blue value.
\n", + "type": "Number" + } + ], + "class": "p5.Color", + "module": "Color" + }, + "setAlpha": { + "name": "setAlpha", + "params": [ + { + "name": "alpha", + "description": "the new alpha value.
\n", + "type": "Number" + } + ], + "class": "p5.Color", + "module": "Color" + } + }, + "p5.Element": { + "elt": { + "name": "elt", + "class": "p5.Element", + "module": "DOM" + }, + "width": { + "name": "width", + "class": "p5.Element", + "module": "DOM" + }, + "height": { + "name": "height", + "class": "p5.Element", + "module": "DOM" + }, + "parent": { + "name": "parent", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [ + { + "name": "parent", + "description": "ID, p5.Element,\n or HTMLElement of desired parent element.
\n", + "type": "String|p5.Element|Object" + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "id": { + "name": "id", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [ + { + "name": "id", + "description": "ID of the element.
\n", + "type": "String" + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "class": { + "name": "class", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [ + { + "name": "class", + "description": "class to add.
\n", + "type": "String" + } + ], + "chainable": 1 + }, + { + "params": [] + } + ] + }, + "mousePressed": { + "name": "mousePressed", + "params": [ + { + "name": "fxn", + "description": "function to call when the mouse is\n pressed over the element.\n false
disables the function.
function to call when the mouse is\n double clicked over the element.\n false
disables the function.
function to call when the mouse wheel is\n scrolled over the element.\n false
disables the function.
function to call when the mouse is\n pressed over the element.\n false
disables the function.
function to call when the mouse is\n pressed and released over the element.\n false
disables the function.
function to call when the mouse\n moves over the element.\n false
disables the function.
function to call when the mouse\n moves onto the element.\n false
disables the function.
function to call when the mouse\n moves off the element.\n false
disables the function.
function to call when the touch\n starts.\n false
disables the function.
function to call when the touch\n moves over the element.\n false
disables the function.
function to call when the touch\n ends.\n false
disables the function.
function to call when the file is\n dragged over the element.\n false
disables the function.
function to call when the file is\n dragged off the element.\n false
disables the function.
name of class to add
\n", + "type": "String" + } + ], + "class": "p5.Element", + "module": "DOM" + }, + "removeClass": { + "name": "removeClass", + "params": [ + { + "name": "class", + "description": "name of class to remove
\n", + "type": "String" + } + ], + "class": "p5.Element", + "module": "DOM" + }, + "hasClass": { + "name": "hasClass", + "params": [ + { + "name": "c", + "description": "class name of class to check
\n", + "type": "String" + } + ], + "class": "p5.Element", + "module": "DOM" + }, + "toggleClass": { + "name": "toggleClass", + "params": [ + { + "name": "c", + "description": "class name to toggle
\n", + "type": "String" + } + ], + "class": "p5.Element", + "module": "DOM" + }, + "child": { + "name": "child", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "child", + "description": "the ID, DOM node, or p5.Element\n to add to the current element
\n", + "type": "String|p5.Element", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "center": { + "name": "center", + "params": [ + { + "name": "align", + "description": "passing 'vertical', 'horizontal' aligns element accordingly
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.Element", + "module": "DOM" + }, + "html": { + "name": "html", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "html", + "description": "the HTML to be placed inside the element
\n", + "type": "String", + "optional": true + }, + { + "name": "append", + "description": "whether to append HTML to existing
\n", + "type": "Boolean", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "position": { + "name": "position", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "x", + "description": "x-position relative to upper left of window (optional)
\n", + "type": "Number", + "optional": true + }, + { + "name": "y", + "description": "y-position relative to upper left of window (optional)
\n", + "type": "Number", + "optional": true + }, + { + "name": "positionType", + "description": "it can be static, fixed, relative, sticky, initial or inherit (optional)
\n", + "type": "String", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "style": { + "name": "style", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [ + { + "name": "property", + "description": "style property to set.
\n", + "type": "String" + } + ] + }, + { + "params": [ + { + "name": "property", + "description": "", + "type": "String" + }, + { + "name": "value", + "description": "value to assign to the property.
\n", + "type": "String|p5.Color" + } + ], + "chainable": 1 + } + ] + }, + "attribute": { + "name": "attribute", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "attr", + "description": "attribute to set.
\n", + "type": "String" + }, + { + "name": "value", + "description": "value to assign to the attribute.
\n", + "type": "String" + } + ], + "chainable": 1 + } + ] + }, + "removeAttribute": { + "name": "removeAttribute", + "params": [ + { + "name": "attr", + "description": "attribute to remove.
\n", + "type": "String" + } + ], + "class": "p5.Element", + "module": "DOM" + }, + "value": { + "name": "value", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "value", + "description": "", + "type": "String|Number" + } + ], + "chainable": 1 + } + ] + }, + "show": { + "name": "show", + "class": "p5.Element", + "module": "DOM" + }, + "hide": { + "name": "hide", + "class": "p5.Element", + "module": "DOM" + }, + "size": { + "name": "size", + "class": "p5.Element", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "w", + "description": "width of the element, either AUTO, or a number.
\n", + "type": "Number|Constant" + }, + { + "name": "h", + "description": "height of the element, either AUTO, or a number.
\n", + "type": "Number|Constant", + "optional": true + } + ], + "chainable": 1 + } + ] + }, + "remove": { + "name": "remove", + "class": "p5.Element", + "module": "DOM" + }, + "drop": { + "name": "drop", + "params": [ + { + "name": "callback", + "description": "called when a file loads. Called once for each file dropped.
\n", + "type": "Function" + }, + { + "name": "fxn", + "description": "called once when any files are dropped.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5.Element", + "module": "DOM" + }, + "draggable": { + "name": "draggable", + "params": [ + { + "name": "elmnt", + "description": "pass another p5.Element
\n", + "type": "p5.Element", + "optional": true + } + ], + "class": "p5.Element", + "module": "DOM" + } + }, + "p5.Graphics": { + "reset": { + "name": "reset", + "class": "p5.Graphics", + "module": "Rendering" + }, + "remove": { + "name": "remove", + "class": "p5.Graphics", + "module": "Rendering" + }, + "createFramebuffer": { + "name": "createFramebuffer", + "class": "p5.Graphics", + "module": "Rendering" + } + }, + "JSON": { + "stringify": { + "name": "stringify", + "params": [ + { + "name": "object", + "description": ":Javascript object that you would like to convert to JSON
\n", + "type": "Object" + } + ], + "class": "JSON", + "module": "Foundation" + } + }, + "console": { + "log": { + "name": "log", + "params": [ + { + "name": "message", + "description": ":Message that you would like to print to the console
\n", + "type": "String|Expression|Object" + } + ], + "class": "console", + "module": "Foundation" + } + }, + "p5.TypedDict": { + "size": { + "name": "size", + "class": "p5.TypedDict", + "module": "Data" + }, + "hasKey": { + "name": "hasKey", + "params": [ + { + "name": "key", + "description": "that you want to look up
\n", + "type": "Number|String" + } + ], + "class": "p5.TypedDict", + "module": "Data" + }, + "get": { + "name": "get", + "params": [ + { + "name": "the", + "description": "key you want to access
\n", + "type": "Number|String" + } + ], + "class": "p5.TypedDict", + "module": "Data" + }, + "set": { + "name": "set", + "params": [ + { + "name": "key", + "description": "", + "type": "Number|String" + }, + { + "name": "value", + "description": "", + "type": "Number|String" + } + ], + "class": "p5.TypedDict", + "module": "Data" + }, + "create": { + "name": "create", + "class": "p5.TypedDict", + "module": "Data", + "overloads": [ + { + "params": [ + { + "name": "key", + "description": "", + "type": "Number|String" + }, + { + "name": "value", + "description": "", + "type": "Number|String" + } + ] + }, + { + "params": [ + { + "name": "obj", + "description": "key/value pair
\n", + "type": "Object" + } + ] + } + ] + }, + "clear": { + "name": "clear", + "class": "p5.TypedDict", + "module": "Data" + }, + "remove": { + "name": "remove", + "params": [ + { + "name": "key", + "description": "for the pair to remove
\n", + "type": "Number|String" + } + ], + "class": "p5.TypedDict", + "module": "Data" + }, + "print": { + "name": "print", + "class": "p5.TypedDict", + "module": "Data" + }, + "saveTable": { + "name": "saveTable", + "class": "p5.TypedDict", + "module": "Data" + }, + "saveJSON": { + "name": "saveJSON", + "class": "p5.TypedDict", + "module": "Data" + } + }, + "p5.NumberDict": { + "add": { + "name": "add", + "params": [ + { + "name": "Key", + "description": "for the value you wish to add to
\n", + "type": "Number" + }, + { + "name": "Number", + "description": "to add to the value
\n", + "type": "Number" + } + ], + "class": "p5.NumberDict", + "module": "Data" + }, + "sub": { + "name": "sub", + "params": [ + { + "name": "Key", + "description": "for the value you wish to subtract from
\n", + "type": "Number" + }, + { + "name": "Number", + "description": "to subtract from the value
\n", + "type": "Number" + } + ], + "class": "p5.NumberDict", + "module": "Data" + }, + "mult": { + "name": "mult", + "params": [ + { + "name": "Key", + "description": "for value you wish to multiply
\n", + "type": "Number" + }, + { + "name": "Amount", + "description": "to multiply the value by
\n", + "type": "Number" + } + ], + "class": "p5.NumberDict", + "module": "Data" + }, + "div": { + "name": "div", + "params": [ + { + "name": "Key", + "description": "for value you wish to divide
\n", + "type": "Number" + }, + { + "name": "Amount", + "description": "to divide the value by
\n", + "type": "Number" + } + ], + "class": "p5.NumberDict", + "module": "Data" + }, + "minValue": { + "name": "minValue", + "class": "p5.NumberDict", + "module": "Data" + }, + "maxValue": { + "name": "maxValue", + "class": "p5.NumberDict", + "module": "Data" + }, + "minKey": { + "name": "minKey", + "class": "p5.NumberDict", + "module": "Data" + }, + "maxKey": { + "name": "maxKey", + "class": "p5.NumberDict", + "module": "Data" + } + }, + "p5.MediaElement": { + "src": { + "name": "src", + "class": "p5.MediaElement", + "module": "DOM" + }, + "play": { + "name": "play", + "class": "p5.MediaElement", + "module": "DOM" + }, + "stop": { + "name": "stop", + "class": "p5.MediaElement", + "module": "DOM" + }, + "pause": { + "name": "pause", + "class": "p5.MediaElement", + "module": "DOM" + }, + "loop": { + "name": "loop", + "class": "p5.MediaElement", + "module": "DOM" + }, + "noLoop": { + "name": "noLoop", + "class": "p5.MediaElement", + "module": "DOM" + }, + "autoplay": { + "name": "autoplay", + "params": [ + { + "name": "shouldAutoplay", + "description": "whether the element should autoplay.
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5.MediaElement", + "module": "DOM" + }, + "volume": { + "name": "volume", + "class": "p5.MediaElement", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "val", + "description": "volume between 0.0 and 1.0.
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "speed": { + "name": "speed", + "class": "p5.MediaElement", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "speed", + "description": "speed multiplier for playback.
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "time": { + "name": "time", + "class": "p5.MediaElement", + "module": "DOM", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "time", + "description": "time to jump to (in seconds).
\n", + "type": "Number" + } + ], + "chainable": 1 + } + ] + }, + "duration": { + "name": "duration", + "class": "p5.MediaElement", + "module": "DOM" + }, + "onended": { + "name": "onended", + "params": [ + { + "name": "callback", + "description": "function to call when playback ends.\n The p5.MediaElement
is passed as\n the argument.
AudioNode from the Web Audio API,\nor an object from the p5.sound library
\n", + "type": "AudioNode|Object" + } + ], + "class": "p5.MediaElement", + "module": "DOM" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.MediaElement", + "module": "DOM" + }, + "showControls": { + "name": "showControls", + "class": "p5.MediaElement", + "module": "DOM" + }, + "hideControls": { + "name": "hideControls", + "class": "p5.MediaElement", + "module": "DOM" + }, + "addCue": { + "name": "addCue", + "params": [ + { + "name": "time", + "description": "cue time to run the callback function.
\n", + "type": "Number" + }, + { + "name": "callback", + "description": "function to call at the cue time.
\n", + "type": "Function" + }, + { + "name": "value", + "description": "object to pass as the argument to\n callback
.
ID of the cue, created by media.addCue()
.
A scaling factor for the number of pixels per\nside
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Image", + "module": "Image" + }, + "loadPixels": { + "name": "loadPixels", + "class": "p5.Image", + "module": "Image" + }, + "updatePixels": { + "name": "updatePixels", + "class": "p5.Image", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the upper-left corner\n of the subsection to update.
\n", + "type": "Integer" + }, + { + "name": "y", + "description": "y-coordinate of the upper-left corner\n of the subsection to update.
\n", + "type": "Integer" + }, + { + "name": "w", + "description": "width of the subsection to update.
\n", + "type": "Integer" + }, + { + "name": "h", + "description": "height of the subsection to update.
\n", + "type": "Integer" + } + ] + }, + { + "params": [] + } + ] + }, + "get": { + "name": "get", + "class": "p5.Image", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "w", + "description": "width of the subsection to be returned.
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the subsection to be returned.
\n", + "type": "Number" + } + ] + }, + { + "params": [] + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + } + ] + } + ] + }, + "set": { + "name": "set", + "params": [ + { + "name": "x", + "description": "x-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the pixel.
\n", + "type": "Number" + }, + { + "name": "a", + "description": "grayscale value | pixel array |\n p5.Color object |\n p5.Image to copy.
\n", + "type": "Number|Number[]|Object" + } + ], + "class": "p5.Image", + "module": "Image" + }, + "resize": { + "name": "resize", + "params": [ + { + "name": "width", + "description": "resized image width.
\n", + "type": "Number" + }, + { + "name": "height", + "description": "resized image height.
\n", + "type": "Number" + } + ], + "class": "p5.Image", + "module": "Image" + }, + "copy": { + "name": "copy", + "class": "p5.Image", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "srcImage", + "description": "source image.
\n", + "type": "p5.Image|p5.Element" + }, + { + "name": "sx", + "description": "x-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sy", + "description": "y-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sw", + "description": "source image width.
\n", + "type": "Integer" + }, + { + "name": "sh", + "description": "source image height.
\n", + "type": "Integer" + }, + { + "name": "dx", + "description": "x-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dy", + "description": "y-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dw", + "description": "destination image width.
\n", + "type": "Integer" + }, + { + "name": "dh", + "description": "destination image height.
\n", + "type": "Integer" + } + ] + }, + { + "params": [ + { + "name": "sx", + "description": "", + "type": "Integer" + }, + { + "name": "sy", + "description": "", + "type": "Integer" + }, + { + "name": "sw", + "description": "", + "type": "Integer" + }, + { + "name": "sh", + "description": "", + "type": "Integer" + }, + { + "name": "dx", + "description": "", + "type": "Integer" + }, + { + "name": "dy", + "description": "", + "type": "Integer" + }, + { + "name": "dw", + "description": "", + "type": "Integer" + }, + { + "name": "dh", + "description": "", + "type": "Integer" + } + ] + } + ] + }, + "mask": { + "name": "mask", + "params": [ + { + "name": "srcImage", + "description": "source image.
\n", + "type": "p5.Image" + } + ], + "class": "p5.Image", + "module": "Image" + }, + "filter": { + "name": "filter", + "params": [ + { + "name": "filterType", + "description": "either THRESHOLD, GRAY, OPAQUE, INVERT,\n POSTERIZE, ERODE, DILATE or BLUR.
\n", + "type": "Constant" + }, + { + "name": "filterParam", + "description": "parameter unique to each filter.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Image", + "module": "Image" + }, + "blend": { + "name": "blend", + "class": "p5.Image", + "module": "Image", + "overloads": [ + { + "params": [ + { + "name": "srcImage", + "description": "source image
\n", + "type": "p5.Image" + }, + { + "name": "sx", + "description": "x-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sy", + "description": "y-coordinate of the source's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "sw", + "description": "source image width.
\n", + "type": "Integer" + }, + { + "name": "sh", + "description": "source image height.
\n", + "type": "Integer" + }, + { + "name": "dx", + "description": "x-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dy", + "description": "y-coordinate of the destination's upper-left corner.
\n", + "type": "Integer" + }, + { + "name": "dw", + "description": "destination image width.
\n", + "type": "Integer" + }, + { + "name": "dh", + "description": "destination image height.
\n", + "type": "Integer" + }, + { + "name": "blendMode", + "description": "the blend mode. either\n BLEND, DARKEST, LIGHTEST, DIFFERENCE,\n MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.
\nAvailable blend modes are: normal | multiply | screen | overlay |\n darken | lighten | color-dodge | color-burn | hard-light |\n soft-light | difference | exclusion | hue | saturation |\n color | luminosity
\nhttp://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/
\n", + "type": "Constant" + } + ] + }, + { + "params": [ + { + "name": "sx", + "description": "", + "type": "Integer" + }, + { + "name": "sy", + "description": "", + "type": "Integer" + }, + { + "name": "sw", + "description": "", + "type": "Integer" + }, + { + "name": "sh", + "description": "", + "type": "Integer" + }, + { + "name": "dx", + "description": "", + "type": "Integer" + }, + { + "name": "dy", + "description": "", + "type": "Integer" + }, + { + "name": "dw", + "description": "", + "type": "Integer" + }, + { + "name": "dh", + "description": "", + "type": "Integer" + }, + { + "name": "blendMode", + "description": "", + "type": "Constant" + } + ] + } + ] + }, + "save": { + "name": "save", + "params": [ + { + "name": "filename", + "description": "filename. Defaults to 'untitled'.
\n", + "type": "String" + }, + { + "name": "extension", + "description": "file extension, either 'png' or 'jpg'.\n Defaults to 'png'.
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.Image", + "module": "Image" + }, + "reset": { + "name": "reset", + "class": "p5.Image", + "module": "Image" + }, + "getCurrentFrame": { + "name": "getCurrentFrame", + "class": "p5.Image", + "module": "Image" + }, + "setFrame": { + "name": "setFrame", + "params": [ + { + "name": "index", + "description": "index of the frame to display.
\n", + "type": "Number" + } + ], + "class": "p5.Image", + "module": "Image" + }, + "numFrames": { + "name": "numFrames", + "class": "p5.Image", + "module": "Image" + }, + "play": { + "name": "play", + "class": "p5.Image", + "module": "Image" + }, + "pause": { + "name": "pause", + "class": "p5.Image", + "module": "Image" + }, + "delay": { + "name": "delay", + "params": [ + { + "name": "d", + "description": "delay in milliseconds between switching frames.
\n", + "type": "Number" + }, + { + "name": "index", + "description": "index of the frame that will have its delay modified.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Image", + "module": "Image" + } + }, + "p5.PrintWriter": { + "write": { + "name": "write", + "params": [ + { + "name": "data", + "description": "all data to be written by the PrintWriter
\n", + "type": "Array" + } + ], + "class": "p5.PrintWriter", + "module": "IO" + }, + "print": { + "name": "print", + "params": [ + { + "name": "data", + "description": "all data to be printed by the PrintWriter
\n", + "type": "Array" + } + ], + "class": "p5.PrintWriter", + "module": "IO" + }, + "clear": { + "name": "clear", + "class": "p5.PrintWriter", + "module": "IO" + }, + "close": { + "name": "close", + "class": "p5.PrintWriter", + "module": "IO" + } + }, + "p5.Table": { + "columns": { + "name": "columns", + "class": "p5.Table", + "module": "IO" + }, + "rows": { + "name": "rows", + "class": "p5.Table", + "module": "IO" + }, + "addRow": { + "name": "addRow", + "params": [ + { + "name": "row", + "description": "row to be added to the table
\n", + "type": "p5.TableRow", + "optional": true + } + ], + "class": "p5.Table", + "module": "IO" + }, + "removeRow": { + "name": "removeRow", + "params": [ + { + "name": "id", + "description": "ID number of the row to remove
\n", + "type": "Integer" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getRow": { + "name": "getRow", + "params": [ + { + "name": "rowID", + "description": "ID number of the row to get
\n", + "type": "Integer" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getRows": { + "name": "getRows", + "class": "p5.Table", + "module": "IO" + }, + "findRow": { + "name": "findRow", + "params": [ + { + "name": "value", + "description": "The value to match
\n", + "type": "String" + }, + { + "name": "column", + "description": "ID number or title of the\n column to search
\n", + "type": "Integer|String" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "findRows": { + "name": "findRows", + "params": [ + { + "name": "value", + "description": "The value to match
\n", + "type": "String" + }, + { + "name": "column", + "description": "ID number or title of the\n column to search
\n", + "type": "Integer|String" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "matchRow": { + "name": "matchRow", + "params": [ + { + "name": "regexp", + "description": "The regular expression to match
\n", + "type": "String|RegExp" + }, + { + "name": "column", + "description": "The column ID (number) or\n title (string)
\n", + "type": "String|Integer" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "matchRows": { + "name": "matchRows", + "params": [ + { + "name": "regexp", + "description": "The regular expression to match
\n", + "type": "String" + }, + { + "name": "column", + "description": "The column ID (number) or\n title (string)
\n", + "type": "String|Integer", + "optional": true + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getColumn": { + "name": "getColumn", + "params": [ + { + "name": "column", + "description": "String or Number of the column to return
\n", + "type": "String|Number" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "clearRows": { + "name": "clearRows", + "class": "p5.Table", + "module": "IO" + }, + "addColumn": { + "name": "addColumn", + "params": [ + { + "name": "title", + "description": "title of the given column
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getColumnCount": { + "name": "getColumnCount", + "class": "p5.Table", + "module": "IO" + }, + "getRowCount": { + "name": "getRowCount", + "class": "p5.Table", + "module": "IO" + }, + "removeTokens": { + "name": "removeTokens", + "params": [ + { + "name": "chars", + "description": "String listing characters to be removed
\n", + "type": "String" + }, + { + "name": "column", + "description": "Column ID (number)\n or name (string)
\n", + "type": "String|Integer", + "optional": true + } + ], + "class": "p5.Table", + "module": "IO" + }, + "trim": { + "name": "trim", + "params": [ + { + "name": "column", + "description": "Column ID (number)\n or name (string)
\n", + "type": "String|Integer", + "optional": true + } + ], + "class": "p5.Table", + "module": "IO" + }, + "removeColumn": { + "name": "removeColumn", + "params": [ + { + "name": "column", + "description": "columnName (string) or ID (number)
\n", + "type": "String|Integer" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "set": { + "name": "set", + "params": [ + { + "name": "row", + "description": "row ID
\n", + "type": "Integer" + }, + { + "name": "column", + "description": "column ID (Number)\n or title (String)
\n", + "type": "String|Integer" + }, + { + "name": "value", + "description": "value to assign
\n", + "type": "String|Number" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "setNum": { + "name": "setNum", + "params": [ + { + "name": "row", + "description": "row ID
\n", + "type": "Integer" + }, + { + "name": "column", + "description": "column ID (Number)\n or title (String)
\n", + "type": "String|Integer" + }, + { + "name": "value", + "description": "value to assign
\n", + "type": "Number" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "setString": { + "name": "setString", + "params": [ + { + "name": "row", + "description": "row ID
\n", + "type": "Integer" + }, + { + "name": "column", + "description": "column ID (Number)\n or title (String)
\n", + "type": "String|Integer" + }, + { + "name": "value", + "description": "value to assign
\n", + "type": "String" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "get": { + "name": "get", + "params": [ + { + "name": "row", + "description": "row ID
\n", + "type": "Integer" + }, + { + "name": "column", + "description": "columnName (string) or\n ID (number)
\n", + "type": "String|Integer" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getNum": { + "name": "getNum", + "params": [ + { + "name": "row", + "description": "row ID
\n", + "type": "Integer" + }, + { + "name": "column", + "description": "columnName (string) or\n ID (number)
\n", + "type": "String|Integer" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getString": { + "name": "getString", + "params": [ + { + "name": "row", + "description": "row ID
\n", + "type": "Integer" + }, + { + "name": "column", + "description": "columnName (string) or\n ID (number)
\n", + "type": "String|Integer" + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getObject": { + "name": "getObject", + "params": [ + { + "name": "headerColumn", + "description": "Name of the column which should be used to\n title each row object (optional)
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.Table", + "module": "IO" + }, + "getArray": { + "name": "getArray", + "class": "p5.Table", + "module": "IO" + } + }, + "p5.TableRow": { + "set": { + "name": "set", + "params": [ + { + "name": "column", + "description": "Column ID (Number)\n or Title (String)
\n", + "type": "String|Integer" + }, + { + "name": "value", + "description": "The value to be stored
\n", + "type": "String|Number" + } + ], + "class": "p5.TableRow", + "module": "IO" + }, + "setNum": { + "name": "setNum", + "params": [ + { + "name": "column", + "description": "Column ID (Number)\n or Title (String)
\n", + "type": "String|Integer" + }, + { + "name": "value", + "description": "The value to be stored\n as a Float
\n", + "type": "Number|String" + } + ], + "class": "p5.TableRow", + "module": "IO" + }, + "setString": { + "name": "setString", + "params": [ + { + "name": "column", + "description": "Column ID (Number)\n or Title (String)
\n", + "type": "String|Integer" + }, + { + "name": "value", + "description": "The value to be stored\n as a String
\n", + "type": "String|Number|Boolean|Object" + } + ], + "class": "p5.TableRow", + "module": "IO" + }, + "get": { + "name": "get", + "params": [ + { + "name": "column", + "description": "columnName (string) or\n ID (number)
\n", + "type": "String|Integer" + } + ], + "class": "p5.TableRow", + "module": "IO" + }, + "getNum": { + "name": "getNum", + "params": [ + { + "name": "column", + "description": "columnName (string) or\n ID (number)
\n", + "type": "String|Integer" + } + ], + "class": "p5.TableRow", + "module": "IO" + }, + "getString": { + "name": "getString", + "params": [ + { + "name": "column", + "description": "columnName (string) or\n ID (number)
\n", + "type": "String|Integer" + } + ], + "class": "p5.TableRow", + "module": "IO" + } + }, + "p5.XML": { + "getParent": { + "name": "getParent", + "class": "p5.XML", + "module": "IO" + }, + "getName": { + "name": "getName", + "class": "p5.XML", + "module": "IO" + }, + "setName": { + "name": "setName", + "params": [ + { + "name": "the", + "description": "new name of the node
\n", + "type": "String" + } + ], + "class": "p5.XML", + "module": "IO" + }, + "hasChildren": { + "name": "hasChildren", + "class": "p5.XML", + "module": "IO" + }, + "listChildren": { + "name": "listChildren", + "class": "p5.XML", + "module": "IO" + }, + "getChildren": { + "name": "getChildren", + "params": [ + { + "name": "name", + "description": "element name
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.XML", + "module": "IO" + }, + "getChild": { + "name": "getChild", + "params": [ + { + "name": "name", + "description": "element name or index
\n", + "type": "String|Integer" + } + ], + "class": "p5.XML", + "module": "IO" + }, + "addChild": { + "name": "addChild", + "params": [ + { + "name": "node", + "description": "a p5.XML Object which will be the child to be added
\n", + "type": "p5.XML" + } + ], + "class": "p5.XML", + "module": "IO" + }, + "removeChild": { + "name": "removeChild", + "params": [ + { + "name": "name", + "description": "element name or index
\n", + "type": "String|Integer" + } + ], + "class": "p5.XML", + "module": "IO" + }, + "getAttributeCount": { + "name": "getAttributeCount", + "class": "p5.XML", + "module": "IO" + }, + "listAttributes": { + "name": "listAttributes", + "class": "p5.XML", + "module": "IO" + }, + "hasAttribute": { + "name": "hasAttribute", + "params": [ + { + "name": "the", + "description": "attribute to be checked
\n", + "type": "String" + } + ], + "class": "p5.XML", + "module": "IO" + }, + "getNum": { + "name": "getNum", + "params": [ + { + "name": "name", + "description": "the non-null full name of the attribute
\n", + "type": "String" + }, + { + "name": "defaultValue", + "description": "the default value of the attribute
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.XML", + "module": "IO" + }, + "getString": { + "name": "getString", + "params": [ + { + "name": "name", + "description": "the non-null full name of the attribute
\n", + "type": "String" + }, + { + "name": "defaultValue", + "description": "the default value of the attribute
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.XML", + "module": "IO" + }, + "setAttribute": { + "name": "setAttribute", + "params": [ + { + "name": "name", + "description": "the full name of the attribute
\n", + "type": "String" + }, + { + "name": "value", + "description": "the value of the attribute
\n", + "type": "Number|String|Boolean" + } + ], + "class": "p5.XML", + "module": "IO" + }, + "getContent": { + "name": "getContent", + "params": [ + { + "name": "defaultValue", + "description": "value returned if no content is found
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.XML", + "module": "IO" + }, + "setContent": { + "name": "setContent", + "params": [ + { + "name": "text", + "description": "the new content
\n", + "type": "String" + } + ], + "class": "p5.XML", + "module": "IO" + }, + "serialize": { + "name": "serialize", + "class": "p5.XML", + "module": "IO" + } + }, + "p5.Vector": { + "x": { + "name": "x", + "class": "p5.Vector", + "module": "Math" + }, + "y": { + "name": "y", + "class": "p5.Vector", + "module": "Math" + }, + "z": { + "name": "z", + "class": "p5.Vector", + "module": "Math" + }, + "toString": { + "name": "toString", + "class": "p5.Vector", + "module": "Math" + }, + "set": { + "name": "set", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x component of the vector.
\n", + "type": "Number", + "optional": true + }, + { + "name": "y", + "description": "y component of the vector.
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "z component of the vector.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "vector to set.
\n", + "type": "p5.Vector|Number[]" + } + ], + "chainable": 1 + } + ] + }, + "copy": { + "name": "copy", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "v", + "description": "the p5.Vector to create a copy of
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "add": { + "name": "add", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x component of the vector to be added.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component of the vector to be added.
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "z component of the vector to be added.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "The vector to add
\n", + "type": "p5.Vector|Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "A p5.Vector to add
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "A p5.Vector to add
\n", + "type": "p5.Vector" + }, + { + "name": "target", + "description": "vector to receive the result.
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "rem": { + "name": "rem", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x component of divisor vector.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component of divisor vector.
\n", + "type": "Number" + }, + { + "name": "z", + "description": "z component of divisor vector.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "divisor vector.
\n", + "type": "p5.Vector | Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "The dividend p5.Vector
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "The divisor p5.Vector
\n", + "type": "p5.Vector" + } + ], + "static": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "sub": { + "name": "sub", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x component of the vector to subtract.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component of the vector to subtract.
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "z component of the vector to subtract.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "value", + "description": "the vector to subtract
\n", + "type": "p5.Vector|Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "A p5.Vector to subtract from
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "A p5.Vector to subtract
\n", + "type": "p5.Vector" + }, + { + "name": "target", + "description": "vector to receive the result.
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "mult": { + "name": "mult", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "The number to multiply with the vector
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "number to multiply with the x component of the vector.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "number to multiply with the y component of the vector.
\n", + "type": "Number" + }, + { + "name": "z", + "description": "number to multiply with the z component of the vector.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "arr", + "description": "array to multiply with the components of the vector.
\n", + "type": "Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v", + "description": "vector to multiply with the components of the original vector.
\n", + "type": "p5.Vector" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number", + "optional": true + } + ], + "static": 1 + }, + { + "params": [ + { + "name": "v", + "description": "", + "type": "p5.Vector" + }, + { + "name": "n", + "description": "", + "type": "Number" + }, + { + "name": "target", + "description": "vector to receive the result.
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + }, + { + "params": [ + { + "name": "v0", + "description": "", + "type": "p5.Vector" + }, + { + "name": "v1", + "description": "", + "type": "p5.Vector" + }, + { + "name": "target", + "description": "", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + }, + { + "params": [ + { + "name": "v0", + "description": "", + "type": "p5.Vector" + }, + { + "name": "arr", + "description": "", + "type": "Number[]" + }, + { + "name": "target", + "description": "", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "div": { + "name": "div", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "n", + "description": "The number to divide the vector by
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "number to divide with the x component of the vector.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "number to divide with the y component of the vector.
\n", + "type": "Number" + }, + { + "name": "z", + "description": "number to divide with the z component of the vector.
\n", + "type": "Number", + "optional": true + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "arr", + "description": "array to divide the components of the vector by.
\n", + "type": "Number[]" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v", + "description": "vector to divide the components of the original vector by.
\n", + "type": "p5.Vector" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + }, + { + "name": "z", + "description": "", + "type": "Number", + "optional": true + } + ], + "static": 1 + }, + { + "params": [ + { + "name": "v", + "description": "", + "type": "p5.Vector" + }, + { + "name": "n", + "description": "", + "type": "Number" + }, + { + "name": "target", + "description": "The vector to receive the result
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + }, + { + "params": [ + { + "name": "v0", + "description": "", + "type": "p5.Vector" + }, + { + "name": "v1", + "description": "", + "type": "p5.Vector" + }, + { + "name": "target", + "description": "", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + }, + { + "params": [ + { + "name": "v0", + "description": "", + "type": "p5.Vector" + }, + { + "name": "arr", + "description": "", + "type": "Number[]" + }, + { + "name": "target", + "description": "", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "mag": { + "name": "mag", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "vecT", + "description": "The vector to return the magnitude of
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "magSq": { + "name": "magSq", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "vecT", + "description": "the vector to return the squared magnitude of
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "dot": { + "name": "dot", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x component of the vector.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component of the vector.
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "z component of the vector.
\n", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "v", + "description": "p5.Vector to be dotted.
\n", + "type": "p5.Vector" + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "first p5.Vector.
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "second p5.Vector.
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "cross": { + "name": "cross", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "v", + "description": "p5.Vector to be crossed.
\n", + "type": "p5.Vector" + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "first p5.Vector.
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "second p5.Vector.
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "dist": { + "name": "dist", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "v", + "description": "x, y, and z coordinates of a p5.Vector.
\n", + "type": "p5.Vector" + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "The first p5.Vector
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "The second p5.Vector
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "normalize": { + "name": "normalize", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "v", + "description": "The vector to normalize
\n", + "type": "p5.Vector" + }, + { + "name": "target", + "description": "The vector to receive the result
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "limit": { + "name": "limit", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "max", + "description": "maximum magnitude for the vector.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v", + "description": "the vector to limit
\n", + "type": "p5.Vector" + }, + { + "name": "max", + "description": "", + "type": "Number" + }, + { + "name": "target", + "description": "the vector to receive the result (Optional)
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "setMag": { + "name": "setMag", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "len", + "description": "new length for this vector.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v", + "description": "the vector to set the magnitude of
\n", + "type": "p5.Vector" + }, + { + "name": "len", + "description": "", + "type": "Number" + }, + { + "name": "target", + "description": "the vector to receive the result (Optional)
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "heading": { + "name": "heading", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "v", + "description": "the vector to find the angle of
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "setHeading": { + "name": "setHeading", + "params": [ + { + "name": "angle", + "description": "angle of rotation.
\n", + "type": "Number" + } + ], + "class": "p5.Vector", + "module": "Math" + }, + "rotate": { + "name": "rotate", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "angle", + "description": "angle of rotation.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v", + "description": "", + "type": "p5.Vector" + }, + { + "name": "angle", + "description": "", + "type": "Number" + }, + { + "name": "target", + "description": "The vector to receive the result
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "angleBetween": { + "name": "angleBetween", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "value", + "description": "x, y, and z components of a p5.Vector.
\n", + "type": "p5.Vector" + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "the first vector.
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "the second vector.
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "lerp": { + "name": "lerp", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x component.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y component.
\n", + "type": "Number" + }, + { + "name": "z", + "description": "z component.
\n", + "type": "Number" + }, + { + "name": "amt", + "description": "amount of interpolation between 0.0 (old vector)\n and 1.0 (new vector). 0.5 is halfway between.
\n", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v", + "description": "p5.Vector to lerp toward.
\n", + "type": "p5.Vector" + }, + { + "name": "amt", + "description": "", + "type": "Number" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "v1", + "description": "", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "", + "type": "p5.Vector" + }, + { + "name": "amt", + "description": "", + "type": "Number" + }, + { + "name": "target", + "description": "The vector to receive the result
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "slerp": { + "name": "slerp", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "v", + "description": "p5.Vector to slerp toward.
\n", + "type": "p5.Vector" + }, + { + "name": "amt", + "description": "amount of interpolation between 0.0 (old vector)\n and 1.0 (new vector). 0.5 is halfway between.
\n", + "type": "Number" + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "old vector.
\n", + "type": "p5.Vector" + }, + { + "name": "v2", + "description": "new vector.
\n", + "type": "p5.Vector" + }, + { + "name": "amt", + "description": "", + "type": "Number" + }, + { + "name": "target", + "description": "vector to receive the result.
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "reflect": { + "name": "reflect", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "surfaceNormal", + "description": "p5.Vector\n to reflect about.
\n", + "type": "p5.Vector" + } + ], + "chainable": 1 + }, + { + "params": [ + { + "name": "incidentVector", + "description": "vector to be reflected.
\n", + "type": "p5.Vector" + }, + { + "name": "surfaceNormal", + "description": "", + "type": "p5.Vector" + }, + { + "name": "target", + "description": "vector to receive the result.
\n", + "type": "p5.Vector", + "optional": true + } + ], + "static": 1 + } + ] + }, + "array": { + "name": "array", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [] + }, + { + "params": [ + { + "name": "v", + "description": "the vector to convert to an array
\n", + "type": "p5.Vector" + } + ], + "static": 1 + } + ] + }, + "equals": { + "name": "equals", + "class": "p5.Vector", + "module": "Math", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x component of the vector.
\n", + "type": "Number", + "optional": true + }, + { + "name": "y", + "description": "y component of the vector.
\n", + "type": "Number", + "optional": true + }, + { + "name": "z", + "description": "z component of the vector.
\n", + "type": "Number", + "optional": true + } + ] + }, + { + "params": [ + { + "name": "value", + "description": "vector to compare.
\n", + "type": "p5.Vector|Array" + } + ] + }, + { + "params": [ + { + "name": "v1", + "description": "the first vector to compare
\n", + "type": "p5.Vector|Array" + }, + { + "name": "v2", + "description": "the second vector to compare
\n", + "type": "p5.Vector|Array" + } + ], + "static": 1 + } + ] + }, + "fromAngle": { + "name": "fromAngle", + "params": [ + { + "name": "angle", + "description": "desired angle, in radians. Unaffected by angleMode().
\n", + "type": "Number" + }, + { + "name": "length", + "description": "length of the new vector (defaults to 1).
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Vector", + "module": "Math" + }, + "fromAngles": { + "name": "fromAngles", + "params": [ + { + "name": "theta", + "description": "polar angle in radians (zero is up).
\n", + "type": "Number" + }, + { + "name": "phi", + "description": "azimuthal angle in radians\n (zero is out of the screen).
\n", + "type": "Number" + }, + { + "name": "length", + "description": "length of the new vector (defaults to 1).
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Vector", + "module": "Math" + }, + "random2D": { + "name": "random2D", + "class": "p5.Vector", + "module": "Math" + }, + "random3D": { + "name": "random3D", + "class": "p5.Vector", + "module": "Math" + } + }, + "p5.Font": { + "font": { + "name": "font", + "class": "p5.Font", + "module": "Typography" + }, + "textBounds": { + "name": "textBounds", + "params": [ + { + "name": "str", + "description": "string of text.
\n", + "type": "String" + }, + { + "name": "x", + "description": "x-coordinate of the text.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the text.
\n", + "type": "Number" + }, + { + "name": "fontSize", + "description": "font size. Defaults to the current\n textSize().
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Font", + "module": "Typography" + }, + "textToPoints": { + "name": "textToPoints", + "params": [ + { + "name": "str", + "description": "string of text.
\n", + "type": "String" + }, + { + "name": "x", + "description": "x-coordinate of the text.
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the text.
\n", + "type": "Number" + }, + { + "name": "fontSize", + "description": "font size. Defaults to the current\n textSize().
\n", + "type": "Number", + "optional": true + }, + { + "name": "options", + "description": "object with sampleFactor and simplifyThreshold\n properties.
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.Font", + "module": "Typography" + } + }, + "p5.Camera": { + "eyeX": { + "name": "eyeX", + "class": "p5.Camera", + "module": "3D" + }, + "eyeY": { + "name": "eyeY", + "class": "p5.Camera", + "module": "3D" + }, + "eyeZ": { + "name": "eyeZ", + "class": "p5.Camera", + "module": "3D" + }, + "centerX": { + "name": "centerX", + "class": "p5.Camera", + "module": "3D" + }, + "centerY": { + "name": "centerY", + "class": "p5.Camera", + "module": "3D" + }, + "centerZ": { + "name": "centerZ", + "class": "p5.Camera", + "module": "3D" + }, + "upX": { + "name": "upX", + "class": "p5.Camera", + "module": "3D" + }, + "upY": { + "name": "upY", + "class": "p5.Camera", + "module": "3D" + }, + "upZ": { + "name": "upZ", + "class": "p5.Camera", + "module": "3D" + }, + "perspective": { + "name": "perspective", + "class": "p5.Camera", + "module": "3D" + }, + "ortho": { + "name": "ortho", + "class": "p5.Camera", + "module": "3D" + }, + "frustum": { + "name": "frustum", + "class": "p5.Camera", + "module": "3D" + }, + "pan": { + "name": "pan", + "params": [ + { + "name": "angle", + "description": "amount to rotate camera in current\nangleMode units.\nGreater than 0 values rotate counterclockwise (to the left).
\n", + "type": "Number" + } + ], + "class": "p5.Camera", + "module": "3D" + }, + "tilt": { + "name": "tilt", + "params": [ + { + "name": "angle", + "description": "amount to rotate camera in current\nangleMode units.\nGreater than 0 values rotate counterclockwise (to the left).
\n", + "type": "Number" + } + ], + "class": "p5.Camera", + "module": "3D" + }, + "lookAt": { + "name": "lookAt", + "params": [ + { + "name": "x", + "description": "x position of a point in world space
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y position of a point in world space
\n", + "type": "Number" + }, + { + "name": "z", + "description": "z position of a point in world space
\n", + "type": "Number" + } + ], + "class": "p5.Camera", + "module": "3D" + }, + "camera": { + "name": "camera", + "class": "p5.Camera", + "module": "3D" + }, + "move": { + "name": "move", + "params": [ + { + "name": "x", + "description": "amount to move along camera's left-right axis
\n", + "type": "Number" + }, + { + "name": "y", + "description": "amount to move along camera's up-down axis
\n", + "type": "Number" + }, + { + "name": "z", + "description": "amount to move along camera's forward-backward axis
\n", + "type": "Number" + } + ], + "class": "p5.Camera", + "module": "3D" + }, + "setPosition": { + "name": "setPosition", + "params": [ + { + "name": "x", + "description": "x position of a point in world space
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y position of a point in world space
\n", + "type": "Number" + }, + { + "name": "z", + "description": "z position of a point in world space
\n", + "type": "Number" + } + ], + "class": "p5.Camera", + "module": "3D" + }, + "set": { + "name": "set", + "params": [ + { + "name": "cam", + "description": "source camera
\n", + "type": "p5.Camera" + } + ], + "class": "p5.Camera", + "module": "3D" + }, + "slerp": { + "name": "slerp", + "params": [ + { + "name": "cam0", + "description": "first p5.Camera
\n", + "type": "p5.Camera" + }, + { + "name": "cam1", + "description": "second p5.Camera
\n", + "type": "p5.Camera" + }, + { + "name": "amt", + "description": "amount to use for interpolation during slerp
\n", + "type": "Number" + } + ], + "class": "p5.Camera", + "module": "3D" + } + }, + "p5.Framebuffer": { + "pixels": { + "name": "pixels", + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "resize": { + "name": "resize", + "params": [ + { + "name": "width", + "description": "", + "type": "Number" + }, + { + "name": "height", + "description": "", + "type": "Number" + } + ], + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "pixelDensity": { + "name": "pixelDensity", + "params": [ + { + "name": "density", + "description": "A scaling factor for the number of pixels per\nside of the framebuffer
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "autoSized": { + "name": "autoSized", + "params": [ + { + "name": "autoSized", + "description": "Whether or not the framebuffer should resize\nalong with the canvas it's attached to
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "createCamera": { + "name": "createCamera", + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "remove": { + "name": "remove", + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "begin": { + "name": "begin", + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "end": { + "name": "end", + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "draw": { + "name": "draw", + "params": [ + { + "name": "callback", + "description": "A function to run that draws to the canvas. The\nfunction will immediately be run, but it will draw to the framebuffer\ninstead of the canvas.
\n", + "type": "Function" + } + ], + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "get": { + "name": "get", + "class": "p5.Framebuffer", + "module": "Rendering", + "overloads": [ + { + "params": [ + { + "name": "x", + "description": "x-coordinate of the pixel
\n", + "type": "Number" + }, + { + "name": "y", + "description": "y-coordinate of the pixel
\n", + "type": "Number" + }, + { + "name": "w", + "description": "width of the section to be returned
\n", + "type": "Number" + }, + { + "name": "h", + "description": "height of the section to be returned
\n", + "type": "Number" + } + ] + }, + { + "params": [] + }, + { + "params": [ + { + "name": "x", + "description": "", + "type": "Number" + }, + { + "name": "y", + "description": "", + "type": "Number" + } + ] + } + ] + }, + "color": { + "name": "color", + "class": "p5.Framebuffer", + "module": "Rendering" + }, + "depth": { + "name": "depth", + "class": "p5.Framebuffer", + "module": "Rendering" + } + }, + "p5.Geometry": { + "clearColors": { + "name": "clearColors", + "class": "p5.Geometry", + "module": "Shape" + }, + "flipU": { + "name": "flipU", + "class": "p5.Geometry", + "module": "Shape" + }, + "flipV": { + "name": "flipV", + "class": "p5.Geometry", + "module": "Shape" + }, + "computeFaces": { + "name": "computeFaces", + "class": "p5.Geometry", + "module": "Shape" + }, + "computeNormals": { + "name": "computeNormals", + "params": [ + { + "name": "shadingType", + "description": "shading type (FLAT
for flat shading or SMOOTH
for smooth shading) for buildGeometry() outputs. Defaults to FLAT
.
An optional object with configuration.
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.Geometry", + "module": "Shape" + }, + "averageNormals": { + "name": "averageNormals", + "class": "p5.Geometry", + "module": "Shape" + }, + "averagePoleNormals": { + "name": "averagePoleNormals", + "class": "p5.Geometry", + "module": "Shape" + }, + "normalize": { + "name": "normalize", + "class": "p5.Geometry", + "module": "Shape" + } + }, + "p5.Shader": { + "copyToContext": { + "name": "copyToContext", + "params": [ + { + "name": "context", + "description": "The graphic or instance to copy this shader to.\nPass window
if you need to copy to the main canvas.
the name of the uniform.\nMust correspond to the name used in the vertex and fragment shaders
\n", + "type": "String" + }, + { + "name": "data", + "description": "The value to assign to the uniform. This can be\na boolean (true/false), a number, an array of numbers, or\nan image (p5.Image, p5.Graphics, p5.MediaElement, p5.Texture)
\n", + "type": "Boolean|Number|Number[]|p5.Image|p5.Graphics|p5.MediaElement|p5.Texture" + } + ], + "class": "p5.Shader", + "module": "3D" + } + }, + "p5.SoundFile": { + "isLoaded": { + "name": "isLoaded", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "play": { + "name": "play", + "params": [ + { + "name": "startTime", + "description": "(optional) schedule playback to start (in seconds from now).
\n", + "type": "Number", + "optional": true + }, + { + "name": "rate", + "description": "(optional) playback rate
\n", + "type": "Number", + "optional": true + }, + { + "name": "amp", + "description": "(optional) amplitude (volume)\n of playback
\n", + "type": "Number", + "optional": true + }, + { + "name": "cueStart", + "description": "(optional) cue start time in seconds
\n", + "type": "Number", + "optional": true + }, + { + "name": "duration", + "description": "(optional) duration of playback in seconds
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "playMode": { + "name": "playMode", + "params": [ + { + "name": "str", + "description": "'restart' or 'sustain' or 'untilDone'
\n", + "type": "String" + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "pause": { + "name": "pause", + "params": [ + { + "name": "startTime", + "description": "(optional) schedule event to occur\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "loop": { + "name": "loop", + "params": [ + { + "name": "startTime", + "description": "(optional) schedule event to occur\n seconds from now
\n", + "type": "Number", + "optional": true + }, + { + "name": "rate", + "description": "(optional) playback rate
\n", + "type": "Number", + "optional": true + }, + { + "name": "amp", + "description": "(optional) playback volume
\n", + "type": "Number", + "optional": true + }, + { + "name": "cueLoopStart", + "description": "(optional) startTime in seconds
\n", + "type": "Number", + "optional": true + }, + { + "name": "duration", + "description": "(optional) loop duration in seconds
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "setLoop": { + "name": "setLoop", + "params": [ + { + "name": "Boolean", + "description": "set looping to true or false
\n", + "type": "Boolean" + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "isLooping": { + "name": "isLooping", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "isPlaying": { + "name": "isPlaying", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "isPaused": { + "name": "isPaused", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "stop": { + "name": "stop", + "params": [ + { + "name": "startTime", + "description": "(optional) schedule event to occur\n in seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "pan": { + "name": "pan", + "params": [ + { + "name": "panValue", + "description": "Set the stereo panner
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "getPan": { + "name": "getPan", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "rate": { + "name": "rate", + "params": [ + { + "name": "playbackRate", + "description": "Set the playback rate. 1.0 is normal,\n .5 is half-speed, 2.0 is twice as fast.\n Values less than zero play backwards.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "setVolume": { + "name": "setVolume", + "params": [ + { + "name": "volume", + "description": "Volume (amplitude) between 0.0\n and 1.0 or modulating signal/oscillator
\n", + "type": "Number|Object" + }, + { + "name": "rampTime", + "description": "Fade for t seconds
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "Schedule this event to happen at\n t seconds in the future
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "duration": { + "name": "duration", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "currentTime": { + "name": "currentTime", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "jump": { + "name": "jump", + "params": [ + { + "name": "cueTime", + "description": "cueTime of the soundFile in seconds.
\n", + "type": "Number" + }, + { + "name": "duration", + "description": "duration in seconds.
\n", + "type": "Number" + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "channels": { + "name": "channels", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "sampleRate": { + "name": "sampleRate", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "frames": { + "name": "frames", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "getPeaks": { + "name": "getPeaks", + "params": [ + { + "name": "length", + "description": "length is the size of the returned array.\n Larger length results in more precision.\n Defaults to 5*width of the browser window.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "reverseBuffer": { + "name": "reverseBuffer", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "onended": { + "name": "onended", + "params": [ + { + "name": "callback", + "description": "function to call when the\n soundfile has ended.
\n", + "type": "Function" + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "object", + "description": "Audio object that accepts an input
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "setPath": { + "name": "setPath", + "params": [ + { + "name": "path", + "description": "path to audio file
\n", + "type": "String" + }, + { + "name": "callback", + "description": "Callback
\n", + "type": "Function" + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "setBuffer": { + "name": "setBuffer", + "params": [ + { + "name": "buf", + "description": "Array of Float32 Array(s). 2 Float32 Arrays\n will create a stereo source. 1 will create\n a mono source.
\n", + "type": "Array" + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "addCue": { + "name": "addCue", + "params": [ + { + "name": "time", + "description": "Time in seconds, relative to this media\n element's playback. For example, to trigger\n an event every time playback reaches two\n seconds, pass in the number 2. This will be\n passed as the first parameter to\n the callback function.
\n", + "type": "Number" + }, + { + "name": "callback", + "description": "Name of a function that will be\n called at the given time. The callback will\n receive time and (optionally) param as its\n two parameters.
\n", + "type": "Function" + }, + { + "name": "value", + "description": "An object to be passed as the\n second parameter to the\n callback function.
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "removeCue": { + "name": "removeCue", + "params": [ + { + "name": "id", + "description": "ID of the cue, as returned by addCue
\n", + "type": "Number" + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "clearCues": { + "name": "clearCues", + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "save": { + "name": "save", + "params": [ + { + "name": "fileName", + "description": "name of the resulting .wav file.
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.SoundFile", + "module": "p5.sound" + }, + "getBlob": { + "name": "getBlob", + "class": "p5.SoundFile", + "module": "p5.sound" + } + }, + "p5.Amplitude": { + "setInput": { + "name": "setInput", + "params": [ + { + "name": "snd", + "description": "set the sound source\n (optional, defaults to\n main output)
\n", + "type": "SoundObject|undefined", + "optional": true + }, + { + "name": "smoothing", + "description": "a range between 0.0 and 1.0\n to smooth amplitude readings
\n", + "type": "Number|undefined", + "optional": true + } + ], + "class": "p5.Amplitude", + "module": "p5.sound" + }, + "getLevel": { + "name": "getLevel", + "params": [ + { + "name": "channel", + "description": "Optionally return only channel 0 (left) or 1 (right)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Amplitude", + "module": "p5.sound" + }, + "toggleNormalize": { + "name": "toggleNormalize", + "params": [ + { + "name": "boolean", + "description": "set normalize to true (1) or false (0)
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5.Amplitude", + "module": "p5.sound" + }, + "smooth": { + "name": "smooth", + "params": [ + { + "name": "set", + "description": "smoothing from 0.0 <= 1
\n", + "type": "Number" + } + ], + "class": "p5.Amplitude", + "module": "p5.sound" + } + }, + "p5.FFT": { + "setInput": { + "name": "setInput", + "params": [ + { + "name": "source", + "description": "p5.sound object (or web audio API source node)
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.FFT", + "module": "p5.sound" + }, + "waveform": { + "name": "waveform", + "params": [ + { + "name": "bins", + "description": "Must be a power of two between\n 16 and 1024. Defaults to 1024.
\n", + "type": "Number", + "optional": true + }, + { + "name": "precision", + "description": "If any value is provided, will return results\n in a Float32 Array which is more precise\n than a regular array.
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.FFT", + "module": "p5.sound" + }, + "analyze": { + "name": "analyze", + "params": [ + { + "name": "bins", + "description": "Must be a power of two between\n 16 and 1024. Defaults to 1024.
\n", + "type": "Number", + "optional": true + }, + { + "name": "scale", + "description": "If \"dB,\" returns decibel\n float measurements between\n -140 and 0 (max).\n Otherwise returns integers from 0-255.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.FFT", + "module": "p5.sound" + }, + "getEnergy": { + "name": "getEnergy", + "params": [ + { + "name": "frequency1", + "description": "Will return a value representing\n energy at this frequency. Alternately,\n the strings \"bass\", \"lowMid\" \"mid\",\n \"highMid\", and \"treble\" will return\n predefined frequency ranges.
\n", + "type": "Number|String" + }, + { + "name": "frequency2", + "description": "If a second frequency is given,\n will return average amount of\n energy that exists between the\n two frequencies.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.FFT", + "module": "p5.sound" + }, + "getCentroid": { + "name": "getCentroid", + "class": "p5.FFT", + "module": "p5.sound" + }, + "smooth": { + "name": "smooth", + "params": [ + { + "name": "smoothing", + "description": "0.0 < smoothing < 1.0.\n Defaults to 0.8.
\n", + "type": "Number" + } + ], + "class": "p5.FFT", + "module": "p5.sound" + }, + "linAverages": { + "name": "linAverages", + "params": [ + { + "name": "N", + "description": "Number of returned frequency groups
\n", + "type": "Number" + } + ], + "class": "p5.FFT", + "module": "p5.sound" + }, + "logAverages": { + "name": "logAverages", + "params": [ + { + "name": "octaveBands", + "description": "Array of Octave Bands objects for grouping
\n", + "type": "Array" + } + ], + "class": "p5.FFT", + "module": "p5.sound" + }, + "getOctaveBands": { + "name": "getOctaveBands", + "params": [ + { + "name": "N", + "description": "Specifies the 1/N type of generated octave bands
\n", + "type": "Number" + }, + { + "name": "fCtr0", + "description": "Minimum central frequency for the lowest band
\n", + "type": "Number" + } + ], + "class": "p5.FFT", + "module": "p5.sound" + } + }, + "p5.Oscillator": { + "start": { + "name": "start", + "params": [ + { + "name": "time", + "description": "startTime in seconds from now.
\n", + "type": "Number", + "optional": true + }, + { + "name": "frequency", + "description": "frequency in Hz.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "stop": { + "name": "stop", + "params": [ + { + "name": "secondsFromNow", + "description": "Time, in seconds from now.
\n", + "type": "Number" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "amp": { + "name": "amp", + "params": [ + { + "name": "vol", + "description": "between 0 and 1.0\n or a modulating signal/oscillator
\n", + "type": "Number|Object" + }, + { + "name": "rampTime", + "description": "create a fade that lasts rampTime
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "getAmp": { + "name": "getAmp", + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "freq": { + "name": "freq", + "params": [ + { + "name": "Frequency", + "description": "Frequency in Hz\n or modulating signal/oscillator
\n", + "type": "Number|Object" + }, + { + "name": "rampTime", + "description": "Ramp time (in seconds)
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "Schedule this event to happen\n at x seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "getFreq": { + "name": "getFreq", + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "setType": { + "name": "setType", + "params": [ + { + "name": "type", + "description": "'sine', 'triangle', 'sawtooth' or 'square'.
\n", + "type": "String" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "getType": { + "name": "getType", + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "A p5.sound or Web Audio object
\n", + "type": "Object" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "pan": { + "name": "pan", + "params": [ + { + "name": "panning", + "description": "Number between -1 and 1
\n", + "type": "Number" + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "getPan": { + "name": "getPan", + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "phase": { + "name": "phase", + "params": [ + { + "name": "phase", + "description": "float between 0.0 and 1.0
\n", + "type": "Number" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "add": { + "name": "add", + "params": [ + { + "name": "number", + "description": "Constant number to add
\n", + "type": "Number" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "mult": { + "name": "mult", + "params": [ + { + "name": "number", + "description": "Constant number to multiply
\n", + "type": "Number" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + }, + "scale": { + "name": "scale", + "params": [ + { + "name": "inMin", + "description": "input range minumum
\n", + "type": "Number" + }, + { + "name": "inMax", + "description": "input range maximum
\n", + "type": "Number" + }, + { + "name": "outMin", + "description": "input range minumum
\n", + "type": "Number" + }, + { + "name": "outMax", + "description": "input range maximum
\n", + "type": "Number" + } + ], + "class": "p5.Oscillator", + "module": "p5.sound" + } + }, + "p5.Envelope": { + "attackTime": { + "name": "attackTime", + "class": "p5.Envelope", + "module": "p5.sound" + }, + "attackLevel": { + "name": "attackLevel", + "class": "p5.Envelope", + "module": "p5.sound" + }, + "decayTime": { + "name": "decayTime", + "class": "p5.Envelope", + "module": "p5.sound" + }, + "decayLevel": { + "name": "decayLevel", + "class": "p5.Envelope", + "module": "p5.sound" + }, + "releaseTime": { + "name": "releaseTime", + "class": "p5.Envelope", + "module": "p5.sound" + }, + "releaseLevel": { + "name": "releaseLevel", + "class": "p5.Envelope", + "module": "p5.sound" + }, + "set": { + "name": "set", + "params": [ + { + "name": "attackTime", + "description": "Time (in seconds) before level\n reaches attackLevel
\n", + "type": "Number" + }, + { + "name": "attackLevel", + "description": "Typically an amplitude between\n 0.0 and 1.0
\n", + "type": "Number" + }, + { + "name": "decayTime", + "description": "Time
\n", + "type": "Number" + }, + { + "name": "decayLevel", + "description": "Amplitude (In a standard ADSR envelope,\n decayLevel = sustainLevel)
\n", + "type": "Number" + }, + { + "name": "releaseTime", + "description": "Release Time (in seconds)
\n", + "type": "Number" + }, + { + "name": "releaseLevel", + "description": "Amplitude
\n", + "type": "Number" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "setADSR": { + "name": "setADSR", + "params": [ + { + "name": "attackTime", + "description": "Time (in seconds before envelope\n reaches Attack Level
\n", + "type": "Number" + }, + { + "name": "decayTime", + "description": "Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n", + "type": "Number", + "optional": true + }, + { + "name": "susRatio", + "description": "Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
Time in seconds from now (defaults to 0)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "setRange": { + "name": "setRange", + "params": [ + { + "name": "aLevel", + "description": "attack level (defaults to 1)
\n", + "type": "Number" + }, + { + "name": "rLevel", + "description": "release level (defaults to 0)
\n", + "type": "Number" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "setInput": { + "name": "setInput", + "params": [ + { + "name": "inputs", + "description": "A p5.sound object or\n Web Audio Param.
\n", + "type": "Object", + "optional": true, + "multiple": true + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "setExp": { + "name": "setExp", + "params": [ + { + "name": "isExp", + "description": "true is exponential, false is linear
\n", + "type": "Boolean" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "play": { + "name": "play", + "params": [ + { + "name": "unit", + "description": "A p5.sound object or\n Web Audio Param.
\n", + "type": "Object" + }, + { + "name": "startTime", + "description": "time from now (in seconds) at which to play
\n", + "type": "Number", + "optional": true + }, + { + "name": "sustainTime", + "description": "time to sustain before releasing the envelope
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "triggerAttack": { + "name": "triggerAttack", + "params": [ + { + "name": "unit", + "description": "p5.sound Object or Web Audio Param
\n", + "type": "Object" + }, + { + "name": "secondsFromNow", + "description": "time from now (in seconds)
\n", + "type": "Number" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "triggerRelease": { + "name": "triggerRelease", + "params": [ + { + "name": "unit", + "description": "p5.sound Object or Web Audio Param
\n", + "type": "Object" + }, + { + "name": "secondsFromNow", + "description": "time to trigger the release
\n", + "type": "Number" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "ramp": { + "name": "ramp", + "params": [ + { + "name": "unit", + "description": "p5.sound Object or Web Audio Param
\n", + "type": "Object" + }, + { + "name": "secondsFromNow", + "description": "When to trigger the ramp
\n", + "type": "Number" + }, + { + "name": "v", + "description": "Target value
\n", + "type": "Number" + }, + { + "name": "v2", + "description": "Second target value
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "add": { + "name": "add", + "params": [ + { + "name": "number", + "description": "Constant number to add
\n", + "type": "Number" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "mult": { + "name": "mult", + "params": [ + { + "name": "number", + "description": "Constant number to multiply
\n", + "type": "Number" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + }, + "scale": { + "name": "scale", + "params": [ + { + "name": "inMin", + "description": "input range minumum
\n", + "type": "Number" + }, + { + "name": "inMax", + "description": "input range maximum
\n", + "type": "Number" + }, + { + "name": "outMin", + "description": "input range minumum
\n", + "type": "Number" + }, + { + "name": "outMax", + "description": "input range maximum
\n", + "type": "Number" + } + ], + "class": "p5.Envelope", + "module": "p5.sound" + } + }, + "p5.Noise": { + "setType": { + "name": "setType", + "params": [ + { + "name": "type", + "description": "'white', 'pink' or 'brown'
\n", + "type": "String", + "optional": true + } + ], + "class": "p5.Noise", + "module": "p5.sound" + } + }, + "p5.Pulse": { + "width": { + "name": "width", + "params": [ + { + "name": "width", + "description": "Width between the pulses (0 to 1.0,\n defaults to 0)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Pulse", + "module": "p5.sound" + } + }, + "p5.AudioIn": { + "input": { + "name": "input", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "output": { + "name": "output", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "stream": { + "name": "stream", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "mediaStream": { + "name": "mediaStream", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "currentSource": { + "name": "currentSource", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "enabled": { + "name": "enabled", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "amplitude": { + "name": "amplitude", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "start": { + "name": "start", + "params": [ + { + "name": "successCallback", + "description": "Name of a function to call on\n success.
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "Name of a function to call if\n there was an error. For example,\n some browsers do not support\n getUserMedia.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "stop": { + "name": "stop", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "An object that accepts audio input,\n such as an FFT
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "getLevel": { + "name": "getLevel", + "params": [ + { + "name": "smoothing", + "description": "Smoothing is 0.0 by default.\n Smooths values based on previous values.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "amp": { + "name": "amp", + "params": [ + { + "name": "vol", + "description": "between 0 and 1.0
\n", + "type": "Number" + }, + { + "name": "time", + "description": "ramp time (optional)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "getSources": { + "name": "getSources", + "params": [ + { + "name": "successCallback", + "description": "This callback function handles the sources when they\n have been enumerated. The callback function\n receives the deviceList array as its only argument
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "This optional callback receives the error\n message as its argument.
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5.AudioIn", + "module": "p5.sound" + }, + "setSource": { + "name": "setSource", + "params": [ + { + "name": "num", + "description": "position of input source in the array
\n", + "type": "Number" + } + ], + "class": "p5.AudioIn", + "module": "p5.sound" + } + }, + "p5.Effect": { + "amp": { + "name": "amp", + "params": [ + { + "name": "vol", + "description": "amplitude between 0 and 1.0
\n", + "type": "Number", + "optional": true + }, + { + "name": "rampTime", + "description": "create a fade that lasts until rampTime
\n", + "type": "Number", + "optional": true + }, + { + "name": "tFromNow", + "description": "schedule this event to happen in tFromNow seconds
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Effect", + "module": "p5.sound" + }, + "chain": { + "name": "chain", + "params": [ + { + "name": "arguments", + "description": "Chain together multiple sound objects
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.Effect", + "module": "p5.sound" + }, + "drywet": { + "name": "drywet", + "params": [ + { + "name": "fade", + "description": "The desired drywet value (0 - 1.0)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Effect", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "", + "type": "Object" + } + ], + "class": "p5.Effect", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.Effect", + "module": "p5.sound" + } + }, + "p5.Filter": { + "biquadFilter": { + "name": "biquadFilter", + "class": "p5.Filter", + "module": "p5.sound" + }, + "process": { + "name": "process", + "params": [ + { + "name": "Signal", + "description": "An object that outputs audio
\n", + "type": "Object" + }, + { + "name": "freq", + "description": "Frequency in Hz, from 10 to 22050
\n", + "type": "Number", + "optional": true + }, + { + "name": "res", + "description": "Resonance/Width of the filter frequency\n from 0.001 to 1000
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Filter", + "module": "p5.sound" + }, + "set": { + "name": "set", + "params": [ + { + "name": "freq", + "description": "Frequency in Hz, from 10 to 22050
\n", + "type": "Number", + "optional": true + }, + { + "name": "res", + "description": "Resonance (Q) from 0.001 to 1000
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Filter", + "module": "p5.sound" + }, + "freq": { + "name": "freq", + "params": [ + { + "name": "freq", + "description": "Filter Frequency
\n", + "type": "Number" + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Filter", + "module": "p5.sound" + }, + "res": { + "name": "res", + "params": [ + { + "name": "res", + "description": "Resonance/Width of filter freq\n from 0.001 to 1000
\n", + "type": "Number" + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Filter", + "module": "p5.sound" + }, + "gain": { + "name": "gain", + "params": [ + { + "name": "gain", + "description": "", + "type": "Number" + } + ], + "class": "p5.Filter", + "module": "p5.sound" + }, + "toggle": { + "name": "toggle", + "class": "p5.Filter", + "module": "p5.sound" + }, + "setType": { + "name": "setType", + "params": [ + { + "name": "t", + "description": "", + "type": "String" + } + ], + "class": "p5.Filter", + "module": "p5.sound" + } + }, + "p5.EQ": { + "bands": { + "name": "bands", + "class": "p5.EQ", + "module": "p5.sound" + }, + "process": { + "name": "process", + "params": [ + { + "name": "src", + "description": "Audio source
\n", + "type": "Object" + } + ], + "class": "p5.EQ", + "module": "p5.sound" + } + }, + "p5.Panner3D": { + "panner": { + "name": "panner", + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "process": { + "name": "process", + "params": [ + { + "name": "src", + "description": "Input source
\n", + "type": "Object" + } + ], + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "set": { + "name": "set", + "params": [ + { + "name": "xVal", + "description": "", + "type": "Number" + }, + { + "name": "yVal", + "description": "", + "type": "Number" + }, + { + "name": "zVal", + "description": "", + "type": "Number" + }, + { + "name": "time", + "description": "", + "type": "Number" + } + ], + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "positionX": { + "name": "positionX", + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "positionY": { + "name": "positionY", + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "positionZ": { + "name": "positionZ", + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "orient": { + "name": "orient", + "params": [ + { + "name": "xVal", + "description": "", + "type": "Number" + }, + { + "name": "yVal", + "description": "", + "type": "Number" + }, + { + "name": "zVal", + "description": "", + "type": "Number" + }, + { + "name": "time", + "description": "", + "type": "Number" + } + ], + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "orientX": { + "name": "orientX", + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "orientY": { + "name": "orientY", + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "orientZ": { + "name": "orientZ", + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "setFalloff": { + "name": "setFalloff", + "params": [ + { + "name": "maxDistance", + "description": "", + "type": "Number", + "optional": true + }, + { + "name": "rolloffFactor", + "description": "", + "type": "Number", + "optional": true + } + ], + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "maxDist": { + "name": "maxDist", + "params": [ + { + "name": "maxDistance", + "description": "", + "type": "Number" + } + ], + "class": "p5.Panner3D", + "module": "p5.sound" + }, + "rollof": { + "name": "rollof", + "params": [ + { + "name": "rolloffFactor", + "description": "", + "type": "Number" + } + ], + "class": "p5.Panner3D", + "module": "p5.sound" + } + }, + "p5.Delay": { + "leftDelay": { + "name": "leftDelay", + "class": "p5.Delay", + "module": "p5.sound" + }, + "rightDelay": { + "name": "rightDelay", + "class": "p5.Delay", + "module": "p5.sound" + }, + "process": { + "name": "process", + "params": [ + { + "name": "Signal", + "description": "An object that outputs audio
\n", + "type": "Object" + }, + { + "name": "delayTime", + "description": "Time (in seconds) of the delay/echo.\n Some browsers limit delayTime to\n 1 second.
\n", + "type": "Number", + "optional": true + }, + { + "name": "feedback", + "description": "sends the delay back through itself\n in a loop that decreases in volume\n each time.
\n", + "type": "Number", + "optional": true + }, + { + "name": "lowPass", + "description": "Cutoff frequency. Only frequencies\n below the lowPass will be part of the\n delay.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Delay", + "module": "p5.sound" + }, + "delayTime": { + "name": "delayTime", + "params": [ + { + "name": "delayTime", + "description": "Time (in seconds) of the delay
\n", + "type": "Number" + } + ], + "class": "p5.Delay", + "module": "p5.sound" + }, + "feedback": { + "name": "feedback", + "params": [ + { + "name": "feedback", + "description": "0.0 to 1.0, or an object such as an\n Oscillator that can be used to\n modulate this param
\n", + "type": "Number|Object" + } + ], + "class": "p5.Delay", + "module": "p5.sound" + }, + "filter": { + "name": "filter", + "params": [ + { + "name": "cutoffFreq", + "description": "A lowpass filter will cut off any\n frequencies higher than the filter frequency.
\n", + "type": "Number|Object" + }, + { + "name": "res", + "description": "Resonance of the filter frequency\n cutoff, or an object (i.e. a p5.Oscillator)\n that can be used to modulate this parameter.\n High numbers (i.e. 15) will produce a resonance,\n low numbers (i.e. .2) will produce a slope.
\n", + "type": "Number|Object" + } + ], + "class": "p5.Delay", + "module": "p5.sound" + }, + "setType": { + "name": "setType", + "params": [ + { + "name": "type", + "description": "'pingPong' (1) or 'default' (0)
\n", + "type": "String|Number" + } + ], + "class": "p5.Delay", + "module": "p5.sound" + }, + "amp": { + "name": "amp", + "params": [ + { + "name": "volume", + "description": "amplitude between 0 and 1.0
\n", + "type": "Number" + }, + { + "name": "rampTime", + "description": "create a fade that lasts rampTime
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Delay", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "", + "type": "Object" + } + ], + "class": "p5.Delay", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.Delay", + "module": "p5.sound" + } + }, + "p5.Reverb": { + "process": { + "name": "process", + "params": [ + { + "name": "src", + "description": "p5.sound / Web Audio object with a sound\n output.
\n", + "type": "Object" + }, + { + "name": "seconds", + "description": "Duration of the reverb, in seconds.\n Min: 0, Max: 10. Defaults to 3.
\n", + "type": "Number", + "optional": true + }, + { + "name": "decayRate", + "description": "Percentage of decay with each echo.\n Min: 0, Max: 100. Defaults to 2.
\n", + "type": "Number", + "optional": true + }, + { + "name": "reverse", + "description": "Play the reverb backwards or forwards.
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5.Reverb", + "module": "p5.sound" + }, + "set": { + "name": "set", + "params": [ + { + "name": "seconds", + "description": "Duration of the reverb, in seconds.\n Min: 0, Max: 10. Defaults to 3.
\n", + "type": "Number", + "optional": true + }, + { + "name": "decayRate", + "description": "Percentage of decay with each echo.\n Min: 0, Max: 100. Defaults to 2.
\n", + "type": "Number", + "optional": true + }, + { + "name": "reverse", + "description": "Play the reverb backwards or forwards.
\n", + "type": "Boolean", + "optional": true + } + ], + "class": "p5.Reverb", + "module": "p5.sound" + }, + "amp": { + "name": "amp", + "params": [ + { + "name": "volume", + "description": "amplitude between 0 and 1.0
\n", + "type": "Number" + }, + { + "name": "rampTime", + "description": "create a fade that lasts rampTime
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Reverb", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "", + "type": "Object" + } + ], + "class": "p5.Reverb", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.Reverb", + "module": "p5.sound" + } + }, + "p5.Convolver": { + "convolverNode": { + "name": "convolverNode", + "class": "p5.Convolver", + "module": "p5.sound" + }, + "impulses": { + "name": "impulses", + "class": "p5.Convolver", + "module": "p5.sound" + }, + "process": { + "name": "process", + "params": [ + { + "name": "src", + "description": "p5.sound / Web Audio object with a sound\n output.
\n", + "type": "Object" + } + ], + "class": "p5.Convolver", + "module": "p5.sound" + }, + "addImpulse": { + "name": "addImpulse", + "params": [ + { + "name": "path", + "description": "path to a sound file
\n", + "type": "String" + }, + { + "name": "callback", + "description": "function (optional)
\n", + "type": "Function" + }, + { + "name": "errorCallback", + "description": "function (optional)
\n", + "type": "Function" + } + ], + "class": "p5.Convolver", + "module": "p5.sound" + }, + "resetImpulse": { + "name": "resetImpulse", + "params": [ + { + "name": "path", + "description": "path to a sound file
\n", + "type": "String" + }, + { + "name": "callback", + "description": "function (optional)
\n", + "type": "Function" + }, + { + "name": "errorCallback", + "description": "function (optional)
\n", + "type": "Function" + } + ], + "class": "p5.Convolver", + "module": "p5.sound" + }, + "toggleImpulse": { + "name": "toggleImpulse", + "params": [ + { + "name": "id", + "description": "Identify the impulse by its original filename\n (String), or by its position in the\n .impulses
Array (Number).
Beats Per Minute
\n", + "type": "Number" + }, + { + "name": "rampTime", + "description": "Seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "getBPM": { + "name": "getBPM", + "class": "p5.Part", + "module": "p5.sound" + }, + "start": { + "name": "start", + "params": [ + { + "name": "time", + "description": "seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "loop": { + "name": "loop", + "params": [ + { + "name": "time", + "description": "seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "noLoop": { + "name": "noLoop", + "class": "p5.Part", + "module": "p5.sound" + }, + "stop": { + "name": "stop", + "params": [ + { + "name": "time", + "description": "seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "pause": { + "name": "pause", + "params": [ + { + "name": "time", + "description": "seconds from now
\n", + "type": "Number" + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "addPhrase": { + "name": "addPhrase", + "params": [ + { + "name": "phrase", + "description": "reference to a p5.Phrase
\n", + "type": "p5.Phrase" + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "removePhrase": { + "name": "removePhrase", + "params": [ + { + "name": "phraseName", + "description": "", + "type": "String" + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "getPhrase": { + "name": "getPhrase", + "params": [ + { + "name": "phraseName", + "description": "", + "type": "String" + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "replaceSequence": { + "name": "replaceSequence", + "params": [ + { + "name": "phraseName", + "description": "", + "type": "String" + }, + { + "name": "sequence", + "description": "Array of values to pass into the callback\n at each step of the phrase.
\n", + "type": "Array" + } + ], + "class": "p5.Part", + "module": "p5.sound" + }, + "onStep": { + "name": "onStep", + "params": [ + { + "name": "callback", + "description": "The name of the callback\n you want to fire\n on every beat/tatum.
\n", + "type": "Function" + } + ], + "class": "p5.Part", + "module": "p5.sound" + } + }, + "p5.Score": { + "start": { + "name": "start", + "class": "p5.Score", + "module": "p5.sound" + }, + "stop": { + "name": "stop", + "class": "p5.Score", + "module": "p5.sound" + }, + "pause": { + "name": "pause", + "class": "p5.Score", + "module": "p5.sound" + }, + "loop": { + "name": "loop", + "class": "p5.Score", + "module": "p5.sound" + }, + "noLoop": { + "name": "noLoop", + "class": "p5.Score", + "module": "p5.sound" + }, + "setBPM": { + "name": "setBPM", + "params": [ + { + "name": "BPM", + "description": "Beats Per Minute
\n", + "type": "Number" + }, + { + "name": "rampTime", + "description": "Seconds from now
\n", + "type": "Number" + } + ], + "class": "p5.Score", + "module": "p5.sound" + } + }, + "p5.SoundLoop": { + "bpm": { + "name": "bpm", + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "timeSignature": { + "name": "timeSignature", + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "interval": { + "name": "interval", + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "iterations": { + "name": "iterations", + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "musicalTimeMode": { + "name": "musicalTimeMode", + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "maxIterations": { + "name": "maxIterations", + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "start": { + "name": "start", + "params": [ + { + "name": "timeFromNow", + "description": "schedule a starting time
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "stop": { + "name": "stop", + "params": [ + { + "name": "timeFromNow", + "description": "schedule a stopping time
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "pause": { + "name": "pause", + "params": [ + { + "name": "timeFromNow", + "description": "schedule a pausing time
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundLoop", + "module": "p5.sound" + }, + "syncedStart": { + "name": "syncedStart", + "params": [ + { + "name": "otherLoop", + "description": "a p5.SoundLoop to sync with
\n", + "type": "Object" + }, + { + "name": "timeFromNow", + "description": "Start the loops in sync after timeFromNow seconds
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.SoundLoop", + "module": "p5.sound" + } + }, + "p5.Compressor": { + "compressor": { + "name": "compressor", + "class": "p5.Compressor", + "module": "p5.sound" + }, + "process": { + "name": "process", + "params": [ + { + "name": "src", + "description": "Sound source to be connected
\n", + "type": "Object" + }, + { + "name": "attack", + "description": "The amount of time (in seconds) to reduce the gain by 10dB,\n default = .003, range 0 - 1
\n", + "type": "Number", + "optional": true + }, + { + "name": "knee", + "description": "A decibel value representing the range above the\n threshold where the curve smoothly transitions to the \"ratio\" portion.\n default = 30, range 0 - 40
\n", + "type": "Number", + "optional": true + }, + { + "name": "ratio", + "description": "The amount of dB change in input for a 1 dB change in output\n default = 12, range 1 - 20
\n", + "type": "Number", + "optional": true + }, + { + "name": "threshold", + "description": "The decibel value above which the compression will start taking effect\n default = -24, range -100 - 0
\n", + "type": "Number", + "optional": true + }, + { + "name": "release", + "description": "The amount of time (in seconds) to increase the gain by 10dB\n default = .25, range 0 - 1
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Compressor", + "module": "p5.sound" + }, + "set": { + "name": "set", + "params": [ + { + "name": "attack", + "description": "The amount of time (in seconds) to reduce the gain by 10dB,\n default = .003, range 0 - 1
\n", + "type": "Number" + }, + { + "name": "knee", + "description": "A decibel value representing the range above the\n threshold where the curve smoothly transitions to the \"ratio\" portion.\n default = 30, range 0 - 40
\n", + "type": "Number" + }, + { + "name": "ratio", + "description": "The amount of dB change in input for a 1 dB change in output\n default = 12, range 1 - 20
\n", + "type": "Number" + }, + { + "name": "threshold", + "description": "The decibel value above which the compression will start taking effect\n default = -24, range -100 - 0
\n", + "type": "Number" + }, + { + "name": "release", + "description": "The amount of time (in seconds) to increase the gain by 10dB\n default = .25, range 0 - 1
\n", + "type": "Number" + } + ], + "class": "p5.Compressor", + "module": "p5.sound" + }, + "attack": { + "name": "attack", + "params": [ + { + "name": "attack", + "description": "Attack is the amount of time (in seconds) to reduce the gain by 10dB,\n default = .003, range 0 - 1
\n", + "type": "Number", + "optional": true + }, + { + "name": "time", + "description": "Assign time value to schedule the change in value
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Compressor", + "module": "p5.sound" + }, + "knee": { + "name": "knee", + "params": [ + { + "name": "knee", + "description": "A decibel value representing the range above the\n threshold where the curve smoothly transitions to the \"ratio\" portion.\n default = 30, range 0 - 40
\n", + "type": "Number", + "optional": true + }, + { + "name": "time", + "description": "Assign time value to schedule the change in value
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Compressor", + "module": "p5.sound" + }, + "ratio": { + "name": "ratio", + "params": [ + { + "name": "ratio", + "description": "The amount of dB change in input for a 1 dB change in output\n default = 12, range 1 - 20
\n", + "type": "Number", + "optional": true + }, + { + "name": "time", + "description": "Assign time value to schedule the change in value
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Compressor", + "module": "p5.sound" + }, + "threshold": { + "name": "threshold", + "params": [ + { + "name": "threshold", + "description": "The decibel value above which the compression will start taking effect\n default = -24, range -100 - 0
\n", + "type": "Number" + }, + { + "name": "time", + "description": "Assign time value to schedule the change in value
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Compressor", + "module": "p5.sound" + }, + "release": { + "name": "release", + "params": [ + { + "name": "release", + "description": "The amount of time (in seconds) to increase the gain by 10dB\n default = .25, range 0 - 1
\n", + "type": "Number" + }, + { + "name": "time", + "description": "Assign time value to schedule the change in value
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Compressor", + "module": "p5.sound" + }, + "reduction": { + "name": "reduction", + "class": "p5.Compressor", + "module": "p5.sound" + } + }, + "p5.PeakDetect": { + "isDetected": { + "name": "isDetected", + "class": "p5.PeakDetect", + "module": "p5.sound" + }, + "update": { + "name": "update", + "params": [ + { + "name": "fftObject", + "description": "A p5.FFT object
\n", + "type": "p5.FFT" + } + ], + "class": "p5.PeakDetect", + "module": "p5.sound" + }, + "onPeak": { + "name": "onPeak", + "params": [ + { + "name": "callback", + "description": "Name of a function that will\n be called when a peak is\n detected.
\n", + "type": "Function" + }, + { + "name": "val", + "description": "Optional value to pass\n into the function when\n a peak is detected.
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.PeakDetect", + "module": "p5.sound" + } + }, + "p5.SoundRecorder": { + "setInput": { + "name": "setInput", + "params": [ + { + "name": "unit", + "description": "p5.sound object or a web audio unit\n that outputs sound
\n", + "type": "Object", + "optional": true + } + ], + "class": "p5.SoundRecorder", + "module": "p5.sound" + }, + "record": { + "name": "record", + "params": [ + { + "name": "soundFile", + "description": "p5.SoundFile
\n", + "type": "p5.SoundFile" + }, + { + "name": "duration", + "description": "Time (in seconds)
\n", + "type": "Number", + "optional": true + }, + { + "name": "callback", + "description": "The name of a function that will be\n called once the recording completes
\n", + "type": "Function", + "optional": true + } + ], + "class": "p5.SoundRecorder", + "module": "p5.sound" + }, + "stop": { + "name": "stop", + "class": "p5.SoundRecorder", + "module": "p5.sound" + } + }, + "p5.Distortion": { + "WaveShaperNode": { + "name": "WaveShaperNode", + "class": "p5.Distortion", + "module": "p5.sound" + }, + "process": { + "name": "process", + "params": [ + { + "name": "amount", + "description": "Unbounded distortion amount.\n Normal values range from 0-1.
\n", + "type": "Number", + "optional": true, + "optdefault": "0.25" + }, + { + "name": "oversample", + "description": "'none', '2x', or '4x'.
\n", + "type": "String", + "optional": true, + "optdefault": "'none'" + } + ], + "class": "p5.Distortion", + "module": "p5.sound" + }, + "set": { + "name": "set", + "params": [ + { + "name": "amount", + "description": "Unbounded distortion amount.\n Normal values range from 0-1.
\n", + "type": "Number", + "optional": true, + "optdefault": "0.25" + }, + { + "name": "oversample", + "description": "'none', '2x', or '4x'.
\n", + "type": "String", + "optional": true, + "optdefault": "'none'" + } + ], + "class": "p5.Distortion", + "module": "p5.sound" + }, + "getAmount": { + "name": "getAmount", + "class": "p5.Distortion", + "module": "p5.sound" + }, + "getOversample": { + "name": "getOversample", + "class": "p5.Distortion", + "module": "p5.sound" + } + }, + "p5.Gain": { + "setInput": { + "name": "setInput", + "params": [ + { + "name": "src", + "description": "p5.sound / Web Audio object with a sound\n output.
\n", + "type": "Object" + } + ], + "class": "p5.Gain", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "", + "type": "Object" + } + ], + "class": "p5.Gain", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.Gain", + "module": "p5.sound" + }, + "amp": { + "name": "amp", + "params": [ + { + "name": "volume", + "description": "amplitude between 0 and 1.0
\n", + "type": "Number" + }, + { + "name": "rampTime", + "description": "create a fade that lasts rampTime
\n", + "type": "Number", + "optional": true + }, + { + "name": "timeFromNow", + "description": "schedule this event to happen\n seconds from now
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.Gain", + "module": "p5.sound" + } + }, + "p5.AudioVoice": { + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "", + "type": "Object" + } + ], + "class": "p5.AudioVoice", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.AudioVoice", + "module": "p5.sound" + } + }, + "p5.MonoSynth": { + "attack": { + "name": "attack", + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "decay": { + "name": "decay", + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "sustain": { + "name": "sustain", + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "release": { + "name": "release", + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "play": { + "name": "play", + "params": [ + { + "name": "note", + "description": "the note you want to play, specified as a\n frequency in Hertz (Number) or as a midi\n value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n See \n Tone. Defaults to 440 hz.
\n", + "type": "String | Number" + }, + { + "name": "velocity", + "description": "velocity of the note to play (ranging from 0 to 1)
\n", + "type": "Number", + "optional": true + }, + { + "name": "secondsFromNow", + "description": "time from now (in seconds) at which to play
\n", + "type": "Number", + "optional": true + }, + { + "name": "sustainTime", + "description": "time to sustain before releasing the envelope. Defaults to 0.15 seconds.
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "triggerAttack": { + "params": [ + { + "name": "note", + "description": "the note you want to play, specified as a\n frequency in Hertz (Number) or as a midi\n value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n See \n Tone. Defaults to 440 hz
\n", + "type": "String | Number" + }, + { + "name": "velocity", + "description": "velocity of the note to play (ranging from 0 to 1)
\n", + "type": "Number", + "optional": true + }, + { + "name": "secondsFromNow", + "description": "time from now (in seconds) at which to play
\n", + "type": "Number", + "optional": true + } + ], + "name": "triggerAttack", + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "triggerRelease": { + "params": [ + { + "name": "secondsFromNow", + "description": "time to trigger the release
\n", + "type": "Number" + } + ], + "name": "triggerRelease", + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "setADSR": { + "name": "setADSR", + "params": [ + { + "name": "attackTime", + "description": "Time (in seconds before envelope\n reaches Attack Level
\n", + "type": "Number" + }, + { + "name": "decayTime", + "description": "Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n", + "type": "Number", + "optional": true + }, + { + "name": "susRatio", + "description": "Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
Time in seconds from now (defaults to 0)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "amp": { + "name": "amp", + "params": [ + { + "name": "vol", + "description": "desired volume
\n", + "type": "Number" + }, + { + "name": "rampTime", + "description": "Time to reach new volume
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "A p5.sound or Web Audio object
\n", + "type": "Object" + } + ], + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.MonoSynth", + "module": "p5.sound" + }, + "dispose": { + "name": "dispose", + "class": "p5.MonoSynth", + "module": "p5.sound" + } + }, + "p5.PolySynth": { + "notes": { + "name": "notes", + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "polyvalue": { + "name": "polyvalue", + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "AudioVoice": { + "name": "AudioVoice", + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "play": { + "name": "play", + "params": [ + { + "name": "note", + "description": "midi note to play (ranging from 0 to 127 - 60 being a middle C)
\n", + "type": "Number", + "optional": true + }, + { + "name": "velocity", + "description": "velocity of the note to play (ranging from 0 to 1)
\n", + "type": "Number", + "optional": true + }, + { + "name": "secondsFromNow", + "description": "time from now (in seconds) at which to play
\n", + "type": "Number", + "optional": true + }, + { + "name": "sustainTime", + "description": "time to sustain before releasing the envelope
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "noteADSR": { + "name": "noteADSR", + "params": [ + { + "name": "note", + "description": "Midi note on which ADSR should be set.
\n", + "type": "Number", + "optional": true + }, + { + "name": "attackTime", + "description": "Time (in seconds before envelope\n reaches Attack Level
\n", + "type": "Number", + "optional": true + }, + { + "name": "decayTime", + "description": "Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n", + "type": "Number", + "optional": true + }, + { + "name": "susRatio", + "description": "Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
Time in seconds from now (defaults to 0)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "setADSR": { + "name": "setADSR", + "params": [ + { + "name": "attackTime", + "description": "Time (in seconds before envelope\n reaches Attack Level
\n", + "type": "Number", + "optional": true + }, + { + "name": "decayTime", + "description": "Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n", + "type": "Number", + "optional": true + }, + { + "name": "susRatio", + "description": "Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
Time in seconds from now (defaults to 0)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "noteAttack": { + "name": "noteAttack", + "params": [ + { + "name": "note", + "description": "midi note on which attack should be triggered.
\n", + "type": "Number", + "optional": true + }, + { + "name": "velocity", + "description": "velocity of the note to play (ranging from 0 to 1)/
\n", + "type": "Number", + "optional": true + }, + { + "name": "secondsFromNow", + "description": "time from now (in seconds)
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "noteRelease": { + "name": "noteRelease", + "params": [ + { + "name": "note", + "description": "midi note on which attack should be triggered.\n If no value is provided, all notes will be released.
\n", + "type": "Number", + "optional": true + }, + { + "name": "secondsFromNow", + "description": "time to trigger the release
\n", + "type": "Number", + "optional": true + } + ], + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "connect": { + "name": "connect", + "params": [ + { + "name": "unit", + "description": "A p5.sound or Web Audio object
\n", + "type": "Object" + } + ], + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "disconnect": { + "name": "disconnect", + "class": "p5.PolySynth", + "module": "p5.sound" + }, + "dispose": { + "name": "dispose", + "class": "p5.PolySynth", + "module": "p5.sound" + } + } +} \ No newline at end of file diff --git a/docs/preprocessor.js b/docs/preprocessor.js deleted file mode 100644 index 7826816885..0000000000 --- a/docs/preprocessor.js +++ /dev/null @@ -1,314 +0,0 @@ -const marked = require('marked'); -const Entities = require('html-entities').AllHtmlEntities; - -const DocumentedMethod = require('./documented-method'); - -function smokeTestMethods(data) { - data.classitems.forEach(function(classitem) { - if (classitem.itemtype === 'method') { - new DocumentedMethod(classitem); - - if ( - classitem.access !== 'private' && - classitem.file.slice(0, 3) === 'src' && - classitem.name && - !classitem.example - ) { - console.log( - classitem.file + - ':' + - classitem.line + - ': ' + - classitem.itemtype + - ' ' + - classitem.class + - '.' + - classitem.name + - ' missing example' - ); - } - } - }); -} - -function mergeOverloadedMethods(data) { - let methodsByFullName = {}; - let paramsForOverloadedMethods = {}; - - let consts = (data.consts = {}); - - data.classitems = data.classitems.filter(function(classitem) { - if (classitem.access === 'private') { - return false; - } - - const itemClass = data.classes[classitem.class]; - if (!itemClass || itemClass.private) { - return false; - } - - let methodConsts = {}; - - let fullName, method; - - var assertEqual = function(a, b, msg) { - if (a !== b) { - throw new Error( - 'for ' + - fullName + - '() defined in ' + - classitem.file + - ':' + - classitem.line + - ', ' + - msg + - ' (' + - JSON.stringify(a) + - ' !== ' + - JSON.stringify(b) + - ')' - ); - } - }; - - var extractConsts = function(param) { - if (!param.type) { - console.log(param); - } - if (param.type.split('|').indexOf('Constant') >= 0) { - let match; - if (classitem.name === 'endShape' && param.name === 'mode') { - match = 'CLOSE'; - } else { - const constantRe = /either\s+(?:[A-Z0-9_]+\s*,?\s*(?:or)?\s*)+/g; - const execResult = constantRe.exec(param.description); - match = execResult && execResult[0]; - if (!match) { - throw new Error( - classitem.file + - ':' + - classitem.line + - ', Constant-typed parameter ' + - fullName + - '(...' + - param.name + - '...) is missing valid value enumeration. ' + - 'See inline_documentation.md#specify-parameters.' - ); - } - } - if (match) { - const reConst = /[A-Z0-9_]+/g; - let matchConst; - while ((matchConst = reConst.exec(match)) !== null) { - methodConsts[matchConst] = true; - } - } - } - }; - - var processOverloadedParams = function(params) { - let paramNames; - - if (!(fullName in paramsForOverloadedMethods)) { - paramsForOverloadedMethods[fullName] = {}; - } - - paramNames = paramsForOverloadedMethods[fullName]; - - params.forEach(function(param) { - const origParam = paramNames[param.name]; - - if (origParam) { - assertEqual( - origParam.type, - param.type, - 'types for param "' + - param.name + - '" must match ' + - 'across all overloads' - ); - assertEqual( - param.description, - '', - 'description for param "' + - param.name + - '" should ' + - 'only be defined in its first use; subsequent ' + - 'overloads should leave it empty' - ); - } else { - paramNames[param.name] = param; - extractConsts(param); - } - }); - - return params; - }; - - if (classitem.itemtype && classitem.itemtype === 'method') { - fullName = classitem.class + '.' + classitem.name; - if (fullName in methodsByFullName) { - // It's an overloaded version of a method that we've already - // indexed. We need to make sure that we don't list it multiple - // times in our index pages and such. - - method = methodsByFullName[fullName]; - - assertEqual( - method.file, - classitem.file, - 'all overloads must be defined in the same file' - ); - assertEqual( - method.module, - classitem.module, - 'all overloads must be defined in the same module' - ); - assertEqual( - method.submodule, - classitem.submodule, - 'all overloads must be defined in the same submodule' - ); - assertEqual( - classitem.description || '', - '', - 'additional overloads should have no description' - ); - - var makeOverload = function(method) { - const overload = { - line: method.line, - params: processOverloadedParams(method.params || []) - }; - // TODO: the doc renderer assumes (incorrectly) that - // these are the same for all overrides - if (method.static) overload.static = method.static; - if (method.chainable) overload.chainable = method.chainable; - if (method.return) overload.return = method.return; - return overload; - }; - - if (!method.overloads) { - method.overloads = [makeOverload(method)]; - delete method.params; - } - method.overloads.push(makeOverload(classitem)); - return false; - } else { - if (classitem.params) { - classitem.params.forEach(function(param) { - extractConsts(param); - }); - } - methodsByFullName[fullName] = classitem; - } - - Object.keys(methodConsts).forEach(constName => - (consts[constName] || (consts[constName] = [])).push(fullName) - ); - } - return true; - }); -} - -// build a copy of data.json for the FES, restructured for object lookup on -// classitems and removing all the parts not needed by the FES -function buildParamDocs(docs) { - let newClassItems = {}; - // the fields we need for the FES, discard everything else - let allowed = new Set(['name', 'class', 'module', 'params', 'overloads']); - for (let classitem of docs.classitems) { - if (classitem.name && classitem.class) { - for (let key in classitem) { - if (!allowed.has(key)) { - delete classitem[key]; - } - } - if (classitem.hasOwnProperty('overloads')) { - for (let overload of classitem.overloads) { - // remove line number and return type - if (overload.line) { - delete overload.line; - } - - if (overload.return) { - delete overload.return; - } - } - } - if (!newClassItems[classitem.class]) { - newClassItems[classitem.class] = {}; - } - - newClassItems[classitem.class][classitem.name] = classitem; - } - } - - let fs = require('fs'); - let path = require('path'); - let out = fs.createWriteStream( - path.join(process.cwd(), 'docs', 'parameterData.json'), - { - flags: 'w', - mode: '0644' - } - ); - out.write(JSON.stringify(newClassItems, null, 2)); - out.end(); -} - -function renderItemDescriptionsAsMarkdown(item) { - if (item.description) { - const entities = new Entities(); - item.description = entities.decode(marked.parse(item.description)); - } - if (item.params) { - item.params.forEach(renderItemDescriptionsAsMarkdown); - } -} - -function renderDescriptionsAsMarkdown(data) { - Object.keys(data.modules).forEach(function(moduleName) { - renderItemDescriptionsAsMarkdown(data.modules[moduleName]); - }); - Object.keys(data.classes).forEach(function(className) { - renderItemDescriptionsAsMarkdown(data.classes[className]); - }); - data.classitems.forEach(function(classitem) { - renderItemDescriptionsAsMarkdown(classitem); - }); -} - -module.exports = (data, options) => { - data.classitems - .filter( - ci => !ci.itemtype && (ci.params || ci.return) && ci.access !== 'private' - ) - .forEach(ci => { - console.error(ci.file + ':' + ci.line + ': unnamed public member'); - }); - - Object.keys(data.classes) - .filter(k => data.classes[k].access === 'private') - .forEach(k => delete data.classes[k]); - - renderDescriptionsAsMarkdown(data); - mergeOverloadedMethods(data); - smokeTestMethods(data); - buildParamDocs(JSON.parse(JSON.stringify(data))); -}; - -module.exports.mergeOverloadedMethods = mergeOverloadedMethods; -module.exports.renderDescriptionsAsMarkdown = renderDescriptionsAsMarkdown; - -module.exports.register = (Handlebars, options) => { - Handlebars.registerHelper('root', function(context, options) { - // if (this.language === 'en') { - // return ''; - // } else { - // return '/'+this.language; - // } - return window.location.pathname; - }); -}; diff --git a/docs/yuidoc-p5-theme/assets/Bold.ttf b/docs/yuidoc-p5-theme/assets/Bold.ttf deleted file mode 100644 index 50d81bdad5..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Bold.ttf and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray.mp3 b/docs/yuidoc-p5-theme/assets/Damscray.mp3 deleted file mode 100644 index b113049905..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray.ogg b/docs/yuidoc-p5-theme/assets/Damscray.ogg deleted file mode 100644 index 77d530a2df..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray_-_Dancing_Tiger_01.ogg b/docs/yuidoc-p5-theme/assets/Damscray_-_Dancing_Tiger_01.ogg deleted file mode 100644 index ddb329fc15..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray_-_Dancing_Tiger_01.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray_-_Dancing_Tiger_02.mp3 b/docs/yuidoc-p5-theme/assets/Damscray_-_Dancing_Tiger_02.mp3 deleted file mode 100644 index b113049905..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray_-_Dancing_Tiger_02.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray_01.mp3 b/docs/yuidoc-p5-theme/assets/Damscray_01.mp3 deleted file mode 100644 index 9653a67bb6..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray_01.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray_01.ogg b/docs/yuidoc-p5-theme/assets/Damscray_01.ogg deleted file mode 100644 index ddb329fc15..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray_01.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray_02.mp3 b/docs/yuidoc-p5-theme/assets/Damscray_02.mp3 deleted file mode 100644 index b113049905..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray_02.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray_02.ogg b/docs/yuidoc-p5-theme/assets/Damscray_02.ogg deleted file mode 100644 index 77d530a2df..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray_02.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Damscray_DancingTiger.mp3 b/docs/yuidoc-p5-theme/assets/Damscray_DancingTiger.mp3 deleted file mode 100644 index b113049905..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Damscray_DancingTiger.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Italic.ttf b/docs/yuidoc-p5-theme/assets/Italic.ttf deleted file mode 100644 index e5a1a86e63..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Italic.ttf and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/Regular.otf b/docs/yuidoc-p5-theme/assets/Regular.otf deleted file mode 100644 index 38941ae72f..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/Regular.otf and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/all.css b/docs/yuidoc-p5-theme/assets/all.css deleted file mode 100644 index f73622fcba..0000000000 --- a/docs/yuidoc-p5-theme/assets/all.css +++ /dev/null @@ -1,4 +0,0 @@ -/*! normalize.css v1.1.0 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}button,html,input,select,textarea{font-family:sans-serif}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{font-size:2em;margin:.67em 0}h2{margin:.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.67em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}blockquote{margin:1em 40px}dfn{font-style:italic}hr{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}p,pre{margin:1em 0}code,kbd,pre,samp{font-family:monospace,serif;_font-family:courier new,monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:after,q:before{content:"";content:none}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}dl,menu,ol,ul{margin:1em 0}dd{margin:0 0 0 40px}menu,ol,ul{padding:0 0 0 40px}nav ol,nav ul{list-style:none;list-style-image:none}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure,form{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0;white-space:normal;*margin-left:-7px}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0;*height:13px;*width:13px}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0} -;code[class*=language-],pre[class*=language-],textarea{color:#222;font-family:Inconsolata,Consolas,Monaco,Andale Mono,monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;font-size:1em!important}pre[class*=language-]{position:relative;padding:.5em 1em;margin:.5em 0 0 -.5em;border-left:.5em solid #afafaf;background-color:#fff;background-image:-webkit-linear-gradient(transparent 50%,rgba(69,142,209,.06) 0);background-image:-o-linear-gradient(transparent 50%,rgba(69,142,209,.06) 50%);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(50%,transparent),color-stop(50%,rgba(69,142,209,.06)));background-image:linear-gradient(transparent 50%,rgba(69,142,209,.06) 0);-webkit-background-size:2.9em 2.9em;background-size:2.9em 2.9em;-webkit-background-origin:content-box;background-origin:content-box;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{margin-bottom:1em}:not(pre)>code[class*=language-]{position:relative;padding:.2em;border-radius:.3em;color:#333;border:1px solid rgba(0,0,0,.1)}:not(pre)>code[class*=language-]:after,pre[class*=language-]:after{right:.75em;left:auto}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#a0a0a0}.token.punctuation{color:#666}.token.boolean,.token.constant,.token.function-name,.token.number,.token.property,.token.symbol,.token.tag{color:#dc3787}.token.attr-name,.token.builtin,.token.function,.token.selector,.token.string{color:#00a1d3}.token.entity,.token.operator,.token.url,.token.variable{color:#a67f59;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.class-name,.token.keyword{color:#704f21}.token.important,.token.regex{color:#e90}.language-css .token.string,.style .token.string{color:#a67f59;background:hsla(0,0%,100%,.5)}.token.important{font-weight:400}.token.entity{cursor:help}.namespace{opacity:.7}@media screen and (max-width:767px){pre[class*=language-]:after,pre[class*=language-]:before{bottom:14px;-webkit-box-shadow:none;box-shadow:none}}.token.cr:before,.token.lf:before,.token.tab:not(:empty):before{color:#e0d7d1}pre.line-numbers{padding-left:3.8em;counter-reset:linenumber}pre.line-numbers,pre.line-numbers>code{position:relative}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right} -;button,html,input,select{color:#222}textarea{line-height:1.45em;padding:.5em 1em;border:none}body{font-size:1em;line-height:1.4}::-moz-selection{background:#b3d4fc;text-shadow:none}::selection{background:#b3d4fc;text-shadow:none}hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}img{vertical-align:middle}img.med_left{width:300px;float:left}img.med_right{width:300px;float:right}img.small_left{width:200px;float:left}img.smaller_left{width:140px;float:left}img.small_right{width:200px;float:right}img.smaller_right{width:140px;float:right}img.small_center{width:200px;margin-left:250px}img.small{width:160px}img.med{width:400px}img.med_center{width:400px;margin-left:150px}fieldset{border:0;margin:0;padding:0}textarea{resize:vertical}.tagline{display:none}#home-page .home{pointer-events:none}#home-page .home a{pointer-events:all}#lockup>a{position:relative;display:block;width:200px;height:90px}#logo_image{position:absolute;top:0}#menu,#menu.top_menu{list-style:none;font-family:Montserrat,sans-serif;width:100%;margin:0 0 1em;padding:0;height:100%;font-size:1.3em}#menu.top_menu li{display:inline}#home-sketch{position:absolute;top:0;left:0;z-index:-2}@media screen and (max-width:780px){.sidebar-menu{clear:both;max-height:0;-webkit-transition:max-height .4s ease-out;-o-transition:max-height .4s ease-out;transition:max-height .4s ease-out;overflow:hidden}.sidebar-menu-nav-element{width:91vw}.sidebar-menu a{display:block;text-align:center;padding-bottom:.11em;border-bottom:.11em dashed transparent}.sidebar-menu-icon{top:2rem;cursor:pointer;float:right;padding:28px 20px;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin-bottom:5rem}.sidebar-menu-icon .sidebar-nav-icon{background:#ed225d;display:block;height:2px;position:relative;-webkit-transition:background .4s ease-out;-o-transition:background .4s ease-out;transition:background .4s ease-out;width:18px}.sidebar-menu-icon .sidebar-nav-icon:after,.sidebar-menu-icon .sidebar-nav-icon:before{background:#ed225d;content:"";display:block;height:100%;position:absolute;-webkit-transition:all .4s ease-out;-o-transition:all .4s ease-out;transition:all .4s ease-out;width:100%}.sidebar-menu-icon .sidebar-nav-icon:before{top:5px}.sidebar-menu-icon .sidebar-nav-icon:after{top:-5px}.sidebar-menu-btn{display:none}.sidebar-menu-btn:checked~.sidebar-menu{max-height:475px}.sidebar-menu-btn:checked~.sidebar-menu-icon .sidebar-nav-icon{background:transparent}.sidebar-menu-btn:checked~.sidebar-menu-icon .sidebar-nav-icon:before{-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg);top:0}.sidebar-menu-btn:checked~.sidebar-menu-icon .sidebar-nav-icon:after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg);top:0}}.sidebar-menu-btn{display:none}#footer-menu{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;list-style:none;font-family:Montserrat,sans-serif;font-size:1em;padding-top:1em;border-bottom:.11em dashed transparent}#footer-menu li{margin-right:1em}#footer-menu a{color:#ed225d}#home-sketch-frame{position:fixed;width:100%;height:100%;left:0;top:0;z-index:-2;overflow:hidden;pointer-events:all;border:0}#credits{position:fixed;bottom:0;left:0;z-index:2;padding:1em;font-size:.7em}#skip-to-content{position:absolute;left:0;top:40px;z-index:5;background-color:#ed225d;color:#fff;width:auto;height:50px;border:none;outline-style:none;text-align:center;font-size:25px;padding:5px;opacity:0}#skip-to-content:focus{opacity:1}.button_box{padding:.4em .6em;margin:.5em 0;font-family:Montserrat,sans-serif;display:inline-block}.button_box,.download_box{border:1px solid #ed225d;color:#333}.download_box{padding:.4em;margin:0 1.75em 0 0;width:18.65em;float:left;height:7.45em;position:relative}.button_box:hover,.download_box:hover{border:1px solid #ed225d;background:#ed225d;color:#fff}.download_box.half_box{width:10.83em;margin-right:1.75em;float:left}.download_box.half_box.last_box{margin-right:0}.download_box .download_name{font-size:1em;margin:0;padding-bottom:.3em;border-bottom:.09em dashed #ed225d;line-height:1.2;font-family:Montserrat,sans-serif;display:block}.download_box:hover .download_name{-webkit-text-stroke-width:0;border-bottom-color:#fff}.download_box p{font-size:.65em;margin:0;position:absolute;bottom:1em}.download_box svg{height:.65em;width:.65em;position:absolute;bottom:3.5em}.download_box:hover svg{fill:#fff}.download_box h4+p{display:block}#download-page .link_group{width:100%;margin-bottom:3em}.download_box{margin-top:1em}.support div.download_box{margin-top:1em;margin-bottom:1em}#download-page .support p{font-size:.8em;position:static;margin-top:.3em}#slideshow{margin:1em 0}#slideshow p{font-size:.8em;color:#ababab;line-height:1.2em;margin-top:.5em}.extra{color:#fff;position:absolute;bottom:.65em;right:.9em;font-weight:700;-ms-transform:rotate(-12deg);-webkit-transform:rotate(-12deg);-o-transform:rotate(-12deg);transform:rotate(-12deg);font-size:.8em}#get-started-page .edit_space{position:relative;-webkit-box-ordinal-group:4;-webkit-order:3;-ms-flex-order:3;order:3;margin-bottom:4.8125em}#get-started-page .edit_space .copy_button{color:#2d7bb6;border-color:rgba(45,123,182,.25);float:right;margin:1.5em 0 1.5em .5em;background:hsla(0,0%,100%,.7);position:absolute;z-index:2;left:31.33em;top:-1.5em}@media (max-width:780px){#get-started-page .edit_space .copy_button{left:6.44em}}@media (max-width:600px){#get-started-page .edit_space .copy_button{left:5.91em}}#examples-page .column{margin-bottom:2em}#reference-page main h1{float:left}.reference-group h2{font-size:1.5em}.reference-group h3{font-size:1em;font-family:Montserrat,sans-serif;margin-top:.5em}div.reference-group{display:inline-block}div.reference-subgroups{margin:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}div.reference-subgroup{width:11em;margin-bottom:1em}#reference-page .params table p{display:inline;font-size:inherit}#reference-page .param-optional{color:#afafaf}#item{width:100%}#item h2{margin:.777em 0 0;font-size:1.444em;font-weight:inherit;font-family:Inconsolata,consolas,monospace;color:#00a1d3}#item h3{font-size:1.33em;margin:1em 0 0}#item ul{margin-top:.5em}#item li{margin-bottom:1em}#reference-page #item ul{list-style:initial;margin-left:1.5em}#reference-page #item .example_container li,#reference-page #item .params li{margin-bottom:1em}#reference-page #item .example_container ul,#reference-page #item .params ul,#reference-page #item ul[aria-labelledby=reference-fields],#reference-page #item ul[aria-labelledby=reference-methods]{list-style:none;margin-left:0}#reference-page #item li{margin-bottom:.5em}.description{clear:both;display:block;width:100%}.syntax pre{width:100%}.item-wrapper,.list-wrapper{float:left;outline:none}.paramname{display:inline-block;min-width:25%;margin-right:1%;font-size:1.2em}.paramtype p{display:inline;font-size:1em}.paramtype{font-size:1.2em;width:73%;vertical-align:top}#library-page .group-name,.paramtype{display:inline-block}#library-page .group-name:hover{color:#ed225d}.example div{position:relative}.example-content .example_code{position:relative;left:1em;padding-top:0;margin-top:1rem;border:none;width:30.5em;max-width:100%}.example-content .example_code.norender{left:0;margin-left:0}.example-content .edit_space{position:absolute;top:0;left:0;margin-top:-.5em;width:100%;pointer-events:none}.example-content .edit_space *{pointer-events:auto}.example-content .edit_space ul{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-webkit-flex-direction:row-reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse;position:relative;pointer-events:none}.example-content .edit_space ul li button{font-family:Montserrat,sans-serif;font-size:1em;color:#ccc;border:1px solid hsla(0,0%,78.4%,.15);background:transparent;outline:none;margin-top:.25em}.example-content .edit_space ul li button:hover,.example_container.editing ul li button{color:#2d7bb6;border-color:rgba(45,123,182,.25)}.example-content .edit_space .edit_area{position:absolute;top:.5em;left:120px;width:30.5em;display:none;font-family:monospace;padding:1.5em .5em .5em;font-size:15pt}.display_button{margin-bottom:2em;font-family:Montserrat,sans-serif;font-size:1em;color:#2d7bb6;border:1px solid rgba(45,123,182,.25);background:transparent;outline:none}.example-content .example_container{width:36em;max-width:100%;border-top:.09em dashed #333;padding-top:.5em;margin-top:2em;min-height:120px;height:-webkit-calc(110% + 20px);height:calc(110% + 20px);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.example-content .example_container:first-of-type{margin-top:1em}@media (max-width:600px){.example-content .example_code{margin-top:.2rem;left:.5rem}.example-content .example_container{width:100%;min-height:220px;height:-webkit-calc(110% + 120px);height:calc(110% + 120px);display:block}.example-content .edit_space .edit_area{top:-webkit-calc(120px + 1em);top:calc(120px + 1em);left:0;width:100%;padding:.5em}.example_container button{top:124px}.description{margin-top:3rem}.edit_button{left:0}.reset_button{left:2.58em}.copy_button{left:5.91em}}form{pointer-events:all}#search_button{background:url(../img/search.png) 100% no-repeat}#search input[type=search],#search input[type=text]{border:1px solid hsla(0,0%,78.4%,.5);font-family:Montserrat,sans-serif;font-size:2.25em;width:9.75em}#search .twitter-typeahead .tt-hint,#search ::-webkit-input-placeholder{color:#ccc}:-moz-placeholder,:-ms-input-placeholder,::-moz-placeholder{color:#ccc}#search input[type=text]:focus{color:#2d7bb6;outline-color:#2d7bb6;outline-width:1px;outline-style:solid}#search .twitter-typeahead .tt-dropdown-menu{background-color:#fff}#search .twitter-typeahead .tt-suggestion.tt-cursor{color:#333;background-color:#eee}#search .twitter-typeahead .tt-suggestion p{margin:0}#search .twitter-typeahead .tt-suggestion p .small{font-size:12px;color:#666}#search{float:right}#search .twitter-typeahead .tt-dropdown-menu{border:1px solid rgba(0,0,0,.2);padding:.5em;max-height:200px;overflow-y:auto;font-size:1em;line-height:1.4em}#search .twitter-typeahead .tt-suggestion{padding:3px 20px;line-height:24px;cursor:pointer}#search .twitter-typeahead .empty-message{padding:8px 20px 1px;font-size:14px;line-height:24px}#search_button{float:right}a.code.core{color:#333}a.code.addon{color:#704f21}#contribute-item{font-size:.75em;text-align:left;display:inline-block;width:320px;height:250px;float:left;border:1px solid #ed225d;margin:0 25px 25px 0;position:relative}.contribute-item-container{position:absolute;z-index:20;margin:0;padding:10px}.container{height:100px;position:relative;background:#fff;margin-top:1.5em}#infoi,#navi{width:100%;height:100%;position:absolute;top:0;left:0}#infoi{z-index:10}h3.contribute-title{font-size:1.33em;margin:0 0 27px;padding-bottom:.3em;border-bottom:.09em dashed #ed225d}.label{position:relative}.label .nounderline img{margin:.5em 0 0}.label h3{color:#fff;position:absolute;top:0;margin:1em}.label:hover h3{color:#ed225d}h3{font-size:1.33em;margin:1em 0 0}.bullet-list{padding:0 0 0 40px;list-style:disc}#libraries-page .label h3{background-color:#000;padding:0 5px}#learn-page .label .nounderline img{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}#learn-page .info{display:inline-block}#exampleDisplay,#exampleEditor,#exampleFrame{width:36em;border:none}#exampleDisplay{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-flow:column;-ms-flex-flow:column;flex-flow:column}#popupExampleFrame{position:fixed;top:0;left:0;right:0;bottom:0;z-index:1000;border:none}#exampleDisplay button{color:#2d7bb6;border-color:rgba(45,123,182,.25);float:right;margin:.5em 0 0 .5em;background:hsla(0,0%,100%,.7);position:absolute;left:0;z-index:2}#exampleDisplay .edit_button{left:25.42em;top:-2.5em}#exampleDisplay .reset_button{left:28em;top:-2.5em}#exampleDisplay .copy_button{left:31.33em;top:-2.5em}#exampleDisplay button:hover{background:#fff}#exampleDisplay .edit_space{position:relative;-webkit-box-ordinal-group:4;-webkit-order:3;-ms-flex-order:3;order:3}#exampleDisplay #exampleFrame{height:22em;-webkit-box-ordinal-group:3;-webkit-order:2;-ms-flex-order:2;order:2}#exampleDisplay #exampleEditor{height:500em;width:710px;overflow:hidden;margin-top:.5em;color:#222;font-family:Inconsolata,consolas,monospace;font-size:1em;background-color:#fff;line-height:1em;-webkit-box-ordinal-group:5;-webkit-order:4;-ms-flex-order:4;order:4}#exampleDisplay #exampleEditor .ace_gutter-cell{background-image:none;padding-left:10px;overflow:hidden;background-color:#afafaf}#exampleDisplay #exampleEditor .ace_gutter-cell.ace_info{background-color:#d7e5f5}#exampleDisplay #exampleEditor .ace_gutter-cell.ace_warning{background-color:gold;color:#fff}#exampleDisplay #exampleEditor .ace_gutter-cell.ace_error{background-color:tomato;color:#fff}#exampleDisplay #exampleEditor .ace_numeric,#exampleDisplay #exampleEditor .ace_tag{color:#dc3787}#exampleDisplay #exampleEditor .ace_attribute-name,#exampleDisplay #exampleEditor .ace_class,#exampleDisplay #exampleEditor .ace_type{color:#704f21}#exampleDisplay #exampleEditor .ace_function,#exampleDisplay #exampleEditor .ace_keyword,#exampleDisplay #exampleEditor .ace_support{color:#00a1d3}#exampleDisplay #exampleEditor .ace_comment{color:#a0a0a0}#exampleDisplay #exampleEditor .ace_string{color:#a67f59}#exampleDisplay #exampleEditor .ace_operator{color:#333}#exampleDisplay #exampleEditor .ace_regexp{color:#e90}#exampleDisplay #exampleEditor .ace-gutter,#exampleDisplay #exampleEditor .ace-gutter-layer{color:#333}#exampleDisplay #exampleEditor .ace_folding-enabled{width:10px!important;color:#333}.attribution{background-color:#eee;font-size:15px;padding:10px;margin:30px 0}#featuring{margin-bottom:1em}#showcase-page .showcase-intro h1{font:italic 900 14.5vw Montserrat,sans-serif;color:#ed225d;text-align:left;text-transform:uppercase}#showcase-page .showcase-intro p{font:400 1.4rem Montserrat,sans-serif;line-height:1.5em}#showcase-page .project-page h2,#showcase-page .showcase-featured h2{font:italic 900 2rem Montserrat,sans-serif;color:#ed225d;letter-spacing:.05rem}#showcase-page ul.left-column,#showcase-page ul.links,#showcase-page ul.project-tags,#showcase-page ul.right-column{list-style:none}#showcase-page img[alt]{font-size:.9rem}#showcase-page .showcase-featured{margin-top:15%}#showcase-page .showcase-featured h3.title{font:italic 900 1rem Montserrat,sans-serif}#showcase-page .showcase-featured p.credit{font:500 1rem Montserrat,sans-serif}#showcase-page .showcase-featured p.description{font-size:1em;margin-bottom:.5rem}#showcase-page .nominate{margin-top:1.5em;display:inline-block}#showcase-page .nominate a,#showcase-page .nominate a:visited{padding:.4em .5em;position:relative;top:0;left:0;border:2px solid #ed225d;-webkit-box-shadow:4px 4px 0 #ed225d;box-shadow:4px 4px 0 #ed225d;font:1.5rem Montserrat,sans-serif;color:#ed225d;letter-spacing:.02rem;-webkit-transition:all .3s;-o-transition:all .3s;transition:all .3s}@media (max-width:500px){#showcase-page .nominate a,#showcase-page .nominate a:visited{padding:.4em .3em;font:1.3rem Montserrat,sans-serif}}#showcase-page .nominate a:hover{top:4px;left:4px;-webkit-box-shadow:none;box-shadow:none}#showcase-page .showcase-featured a,#showcase-page .showcase-featured a:visited{font-size:1.2rem;color:#ed225d;letter-spacing:.02rem;line-height:1.5}#showcase-page .showcase-featured a:after{content:" →"}#showcase-page .showcase-featured a.tag:after{content:""}#showcase-page .showcase-featured .no-arrow-link:after{content:" "}#showcase-page .showcase-featured .no-arrow-link:hover{text-decoration:none;padding:none;border:none}.project-info{margin-top:1em}ul.project-tags a{line-height:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;font-size:.5em;margin:0}h3.title{margin-top:3em}#showcase-page ul.project-tags li{margin:5px;display:inline-block}h2.featuring{margin-top:0}#showcase-page a.tag{display:inline-block;padding:6px 14px;background-color:#ffe8e8;border-radius:27px;font:.7rem Montserrat,sans-serif;color:#333}#showcase-page ul.project-tags li{margin:0}#showcase-page{margin-top:3em}#showcase-page .project-page h2{line-height:1.4}@media (min-width:720px){#showcase-page .showcase-intro h1{font:italic 900 6.35vw Montserrat,sans-serif}#showcase-page .showcase-intro p{line-height:1.75em;font-size:1em}#showcase-page .project-metadata{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}#showcase-page .project-resources{margin-left:3rem}#showcase-page .project-a{width:90%;float:right;display:inline-block;clear:both}#showcase-page .half-image{width:48%}}#showcase-page .project-metadata{margin-top:3%}#showcase-page .project-metadata section h3{color:#ed225d;font:700 italic 1rem Montserrat,sans-serif}#showcase-page .project-resources ul.links{font:500 .7rem Montserrat,sans-serif;letter-spacing:.01rem;line-height:1.5;margin:.5rem 0}#showcase-page .project-credit{font:italic 700 1.25rem Montserrat,sans-serif}#showcase-page .project-credit p{margin:.5rem 0}#showcase-page .creator-from,#showcase-page .note{font-size:.7rem}#showcase-page .qa-group{margin-bottom:2em}#showcase-page .project-q{margin-left:0;display:inline-block;clear:both;font:900 1.2rem Montserrat,sans-serif;line-height:1.5}#showcase-page code{font-size:1.1rem}#teach-page .case-list a:hover{border-bottom:none}#teach-page .heading{width:100%;font:400 1.4rem Montserrat,sans-serif;color:#000;line-height:1.2em;padding-bottom:.4em;border-bottom:4px dotted #ed225d}#teach-page h3.title{margin-top:3em}#teach-page section.workshopS{overflow:auto}#teach-page .workshop-content{padding:.6em}#teach-page ul.workshops{padding-top:.4em;width:41%;float:left}#teach-page .btn,#teach-page li.workshop .active,li.workshop p:hover{margin-bottom:.8em;padding-bottom:.4em;font:400 .9rem Times,sans-serif;line-height:1.2em;border-bottom:.1em dashed #ffe8e8}#teach-page li.workshop .active,li.workshop p:hover{color:#ed225d}#teach-page .upcoming-banners{width:59%;float:right;padding-top:.8em;padding-left:1em;border:none}#teach-page .banner2,.banner3,.time2,.time3{display:none}#teach-page .banner1:hover,.banner2:hover,.banner3:hover{border:none}#teach-page .banner-img{float:left;-webkit-box-shadow:0 0 5px 2px rgba(0,0,0,.1);box-shadow:0 0 5px 2px rgba(0,0,0,.1);border-radius:5px;border:none}#teach-page .banner-img:hover{-webkit-box-shadow:0 0 5px 2px #e088a1;box-shadow:0 0 5px 2px #e088a1;border-radius:5px;border:none}#teach-page .upcoming-time p{float:right;margin-bottom:.8em;padding-bottom:.4em;font:400 .8rem Times,sans-serif;line-height:.01em}#teach-page .search-filter{display:inline}#teach-page .search-filter label{display:inline-block;font:italic 900 1rem Montserrat,sans-serif;padding:6px 12px;text-align:left;white-space:nowrap;color:#ed225d;margin-bottom:.6em;margin-top:1.2em;border:1px solid #ed225d;cursor:pointer}#teach-page .search-filter label:hover{color:#fff;background-color:#ed225d}#teach-page .search-filter input[type=checkbox]{display:absolute;position:absolute;opacity:0}#teach-page ul.filters p.filter-title{font:400 .83rem Montserrat,sans-serif;color:#ed225d;height:50px;padding-top:20px;background:none;background-color:none;-webkit-box-shadow:none;box-shadow:none;display:inline-block;border:none;clear:both}#teach-page ul.filters li{display:inline;list-style:none;width:100%}#teach-page ul.filters li label{display:inline-block;border-radius:25px;font:200 .7rem Montserrat,sans-serif;color:#000;white-space:nowrap;margin:3px 0;-webkit-transition:.2s;-o-transition:.2s;transition:.2s;background:#fafafa;padding:6px 12px;cursor:pointer}#teach-page ul.filters li label:before{display:inline-block;padding:2px}#teach-page ul.filters li label:hover{color:#ed225d;background:#ffe8e8}#teach-page ul.filters li input[type=checkbox]:checked+label{color:#fff;background:#ed225d}#teach-page ul.filters li input[type=checkbox]{display:absolute;position:absolute;opacity:0}#teach-page ul.filters li.clear{display:block;clear:both}#teach-page .filter-panel{background-color:#fff;max-height:0;overflow:hidden;-webkit-transition:max-height .2s ease-out;-o-transition:max-height .2s ease-out;transition:max-height .2s ease-out;margin-bottom:.8em;padding:0 0 .4em}#teach-page .filter-panel p{margin:0;color:#333;font-size:.83em;height:50px;padding-top:20px;-webkit-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out}#teach-page .teach-intro p{font:400 1.2rem Times,sans-serif;line-height:1.5em}#teach-page .modal-title{margin-left:1em;margin-right:1em;font:400 1rem Montserrat,sans-serif;color:#ed225d;line-height:1.2em}#teach-page ul.cases li.clear{display:block;clear:both;margin-top:1em;margin-bottom:1.2em}#teach-page img{margin-bottom:1.4em}#teach-page img[alt]{font:.6rem Montserrat,sans-serif;color:#bababa}#teach-page .close{position:relative;color:#ffc7c7;float:right;font-size:40px;font-weight:700;margin-right:.4em;margin-top:.4em;cursor:pointer}#teach-page .close:hover,.close:focus{color:#ed225d;text-decoration:none;cursor:pointer}#teach-page .case label{margin:2px;padding:5px 8px;display:inline-block;border-radius:25px;font:.7rem Montserrat,sans-serif;color:#aaa;white-space:nowrap;color:#fff;background:#ed225d}#teach-page .modal-body::-webkit-scrollbar{width:5px;height:5px;border-radius:10px}#teach-page .modal-body::-webkit-scrollbar-track{background:#f1f1f1}#teach-page .modal-body::-webkit-scrollbar-thumb{background:#ffe8e8}#teach-page .case{margin-left:2em;margin-right:2em}#teach-page .case span{color:#ed225d;font:900 1.4rem Montserrat,sans-serif}#teach-page .case p.lead-name{font:900 Italic 1.2rem Montserrat,sans-serif;color:#ed225d;line-height:1.4em;border-bottom:1.4em}#teach-page .case .speech{position:relative;font:200 Italic .8rem Montserrat,sans-serif;color:#000;background:#ffe8e8;padding:.5em 1.2em;border-radius:.4em;border-bottom:none;margin-bottom:2em;margin-top:1em}#teach-page .case .speech:after{content:"";position:absolute;top:0;left:8%;width:0;height:0;border:10px solid transparent;border-bottom-color:#ffe8e8;border-top:0;margin-left:-10px;margin-top:-10px}#teach-page .case p.subtitle{font:400 1rem Montserrat,sans-serif;color:#ed225d}#teach-page .case p,#teach-page .case p.subtitle{line-height:1.4em;border-bottom:.1em dashed rgba(237,34,93,.15)}#teach-page .case p{font:400 1rem Times,sans-serif;color:#000}#teach-page .modal-footer,#teach-page .modal-header{margin-bottom:.8em}#teach-page .modal-body:-webkit-scrollbar{display:none}#teach-page .modal{display:none;position:fixed;z-index:100;width:100%;height:100%;top:0;left:0;right:0;overflow:auto;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background-color:rgba(255,232,232,.5)}#teach-page .modal-content{position:fixed;background:#fff;top:2%;left:2%;right:2%;bottom:2%;margin:auto;border:1.2px solid #ffe8e8;max-width:740px;-webkit-box-shadow:10px 100px 30px -17px rgba(237,34,93,.5);box-shadow:10px 100px 30px -17px rgba(237,34,93,.5);-webkit-box-shadow:10px 100px 20px -17px rgba(237,34,93,.5);box-shadow:10px 100px 20px -17px rgba(237,34,93,.5);-webkit-box-shadow:10px 20px 10px -17px rgba(237,34,93,.5);box-shadow:10px 20px 10px -17px rgba(237,34,93,.5)}#teach-page .modal-body{margin:auto;height:85%;width:95%;overflow-y:auto}#teach-page .results-wrapper{width:100%;outline:none;background:#fff}#teach-page .results-wrapper ul li.case-list a.myBtn{overflow:hidden;text-overflow:ellipsis}#teach-page .case-list{margin-bottom:.8em;padding-bottom:.4em;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;font:400 1rem Times,sans-serif;line-height:1.2em;border-bottom:.1em dashed #ffe8e8}#teach-page .labels{width:40%}#teach-page .tags.selected{display:inline-block;margin:2px;padding:5px 8px;border-radius:25px;font:200 .7rem Montserrat,sans-serif;color:#fff;white-space:nowrap;background:#ed225d}#teach-page .caseBtn{padding-top:.2em;padding-bottom:.2em;width:60%;height:-webkit-max-content;height:-moz-max-content;height:max-content;float:left}#teach-page .case-list label{display:inline-block;margin:2px;padding:5px 8px;border-radius:25px;font:200 .7rem Montserrat,sans-serif;color:#000;white-space:nowrap;background:#fafafa}*,:after,:before{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}html{font-size:1.25em}body{margin:0;background-color:#fff;font-family:Times;font-weight:400;line-height:1.45;color:#333}p{font-size:1.2em;margin:.5em 0}.freeze{overflow:hidden}#menu li a:focus:active,#menu li a:focus:hover,#menu li a:link,#menu li a:visited{color:#ed225d;background:transparent;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}a:link,a:visited{color:#2d7bb6;text-decoration:none}#reference a:hover,a:active,a:hover{color:#ed225d;text-decoration:none;padding-bottom:.11em;border-bottom:.11em dashed #ed225d;-webkit-transition:border-bottom 30ms linear;-o-transition:border-bottom 30ms linear;transition:border-bottom 30ms linear}a.nounderline:hover{border:none}a.here{color:#ed225d;text-decoration:none;padding-bottom:.1em;border-bottom:transparent;border-bottom-color:#ed225d}.highlight{background-color:rgba(237,34,93,.15)}.container>div:first-of-type{margin-top:2em}h1,h2,h3,h4,h5{margin:1.414em 0 .5em;font-weight:inherit;line-height:1.2;font-family:Montserrat,sans-serif}h1{font-size:2.25em;margin:0}h2{font-size:1.5em;margin:1em 0 0}.code{font-family:Inconsolata,consolas,monospace}#backlink{margin:1.2em .444em 0 0;font-family:Montserrat,sans-serif;float:right}#backlink a{color:#afafaf}#backlink a:hover{color:#ed225d;border-bottom:none}#promo,#promo:visited{width:100%;background:#98fb98;margin:0;text-align:center;padding:.4em 0;background:#74ffb7;background:-webkit-radial-gradient(circle,#74ffb7 0,#8afff2 100%);background:-o-radial-gradient(circle,#74ffb7 0,#8afff2 100%);background:radial-gradient(circle,#74ffb7 0,#8afff2 100%);font-family:Montserrat,sans-serif;color:#ed225d!important}#promo:hover{background:#ed225d;color:#fff!important}#promo-link{margin:0!important;padding:0}#family a:link,#family a:visited{margin:.4em}#family a:active,#family a:hover{margin:.4em;border:none}#family{position:absolute;z-index:9999;top:0;left:0;width:100%;overflow:none;margin:0;border-bottom:1px solid rgba(51,51,51,.5);-webkit-box-shadow:0 0 10px #333;box-shadow:0 0 10px #333;background-color:hsla(0,0%,100%,.85)}#processing-sites{margin:.375em 0}#processing-sites li{list-style:none;display:inline-block;margin:0}#processing-sites li:first-child{margin-left:2em}#processing-sites li:last-child{float:right;margin-right:2em}.code-snippet{margin:0 0 0 1em;width:90%;clear:both}.column-span{margin:0 0 0 1em;padding:0;float:left;max-width:100%}.method_description p{margin-top:0}main{padding:0}.spacer{clear:both}ul{margin:0;padding:0;list-style:none}ol{font-size:1.2em}li{margin:0;padding:0}ul.list_view{margin:.5em 0 0 1em;padding:0;list-style:disc;list-style-position:outside;font-size:1.2em}ol ul.list_view{font-size:1em}ul.inside{margin:0 0 0 2em;padding:0;list-style:disc;list-style-position:inside}.image-row img{width:48%;height:14.3%}.image-row img+img{float:right;margin-right:0;margin-bottom:.25em}img,main div img{margin:.5em .5em 0 0;width:100%}p+img{margin-top:0}.video{width:100%}#lockup{position:absolute;top:-5.75em;left:1.25em;height:0;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#lockup object{margin:0;padding:0;border:none}#lockup a:focus{outline:0}.logo{padding:0;border:none;margin:0 0 .4em;height:4.5em;width:9.75em}#lockup p{color:#ed225d;font-size:.7em;font-family:Montserrat,sans-serif;margin:.5em 0 0 8.5em}#lockup a:link{border:transparent;height:4.5em;width:9.75em}.caption{margin-bottom:2.5em}.caption p,.caption span{text-align:right;font-size:.7em;font-family:Montserrat,sans-serif;padding-top:.25em}footer{clear:both;border-top:.1em dashed #ed225d;margin:2em 0}.videoWrapper{position:relative;padding-bottom:56.25%;height:0;margin-top:.5em}.videoWrapper iframe{position:absolute;top:0;left:0;width:100%;height:100%}.ir{background-color:transparent;border:0;overflow:hidden;*text-indent:-9999px}.ir:before{content:"";display:block;width:0;height:150%}.hidden{display:none!important;visibility:hidden}.sr-only{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.sr-only.focusable:active,.sr-only.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.invisible{visibility:hidden}.clearfix:after,.clearfix:before{content:" ";display:table}.clearfix:after{clear:both}.clearfix{*zoom:1}#notMobile-message{display:none;-webkit-box-ordinal-group:2;-webkit-order:1;-ms-flex-order:1;order:1}#asterisk-design-element,#isMobile-displayButton,.separator-design-element{display:none}.pointerevents #asterisk-design-element,.pointerevents .separator-design-element{pointer-events:none;display:inline-block}@media (min-width:780px){.container{width:49em!important;margin:11.5em auto}main{width:36em;padding:0!important}footer{width:48em}}@media (min-width:780px){.container{margin:11.5em auto;width:100%;padding:.8em 0 0;height:auto;min-height:100%}#home-page{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:row;-ms-flex-wrap:row;flex-wrap:row}main{padding:0 1em 0 0}#family,.small,footer,small{font-size:.7em}footer{clear:both}#i18n-btn{position:absolute;top:4em;right:1em}#i18n-btn a,#menu{font-family:Montserrat,sans-serif}#menu{list-style:none;margin:0 .75em 0 -1.85em;width:7.3em;height:100%;border-top:transparent;border-bottom:transparent;padding:0;font-size:.83em;z-index:100;position:relative;top:0}#menu li{float:none;margin:0 0 1em;text-align:right}#menu li:nth-child(11){margin-top:3em;padding-top:.5em}.left-column{width:48%;float:left;margin-bottom:40px}.right-column{width:48%;float:right;margin-right:0;margin-bottom:.25em}.narrow-left-column{width:32%;float:left}.wide-right-column{width:64%;float:right;margin-right:0;margin-bottom:.25em}.book{font-size:.7em}.column_0,.column_1,.column_2{float:left;width:11.333em}.column_0,.column_1{margin-right:1em}#collection-list-nav{width:100%;clear:both;border-bottom:1px dashed rgba(0,0,0,.2)}#collection-list-categories{font-family:Montserrat,sans-serif;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;margin:1em 0 1.5em}#collection-list-categories ul{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}#collection-list{margin:0}.group-name.first{margin-top:0!important}.column.group-name{margin-bottom:1em}#library-page .group-name{margin:2em 0 .5em}#library-page .column{margin-top:1em}#list{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-bottom:1em}}@media (max-width:780px){.tagline{display:none!important}#family{display:none}#i18n-btn{position:absolute;top:.5em;right:.7em;z-index:10}#search{float:left;margin-bottom:1em}#search,#search input[type=text]{width:100%}#search input[type=search],#search input[type=text]{font-size:1.5em}#lockup{position:absolute;top:2em;left:1em}.column-span{margin:0;padding:0 1em;float:left}#menu,#menu.top_menu{margin:6em 0 .5em;font-size:1.3em}#menu li{display:inline-block}#menu li:last-child a:after{content:""}#menu li a:after{content:","}#contribute-item:first-child{margin-left:0}.download_box{width:96%}.download_box.half_box{width:46%;margin-right:4%;float:left}#etc_list{font-size:1.2em;margin-top:1em}#asterisk-design-element,.separator-design-element{display:none!important;pointer-events:none}pre[class*=language-]{padding:.5em;width:100%}code{word-wrap:break-word;word-break:break-all}#credits{position:relative!important;z-index:2;margin-top:-7em;padding:0 2em 3em 1em;font-size:.5em;float:right;width:100%;text-align:right}#credits,#home-sketch-frame{display:none}#exampleDisplay,#exampleDisplay #exampleEditor,#exampleFrame{width:100%}#exampleDisplay .edit_button{left:-.58em}#exampleDisplay .reset_button{left:3em}#exampleDisplay .copy_button{left:6.44em}#exampleEditor{margin-top:3em}.small,footer,small{font-size:.5em}.paramtype{width:96%}}@media (max-width:400px){#i18n{margin-top:.75em!important}body{margin-top:-.75em!important}}iframe{border:none;width:100%}.iframe-container{overflow:hidden;position:relative}.iframe-container iframe{border:0;height:100%;left:0;position:absolute;top:0;width:100%}.cnv_div{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.cnv_div>*{width:100px;height:auto}@media (max-width:780px){#teach-page ul.workshops{width:100%}#teach-page .upcoming-banners{width:100%;float:left;padding-top:0;padding-left:0;border:none}#teach-page .case-list{display:block}#teach-page .caseBtn,#teach-page .labels{min-width:100%}}#i18n-buttons{margin:0;background:#fff}#i18n-buttons li{list-style:none;display:inline-block;margin-left:.5em}#i18n-btn a{border:none;outline:none;font-size:.7em;color:#696969;z-index:5}#i18n-btn a:hover{color:#ed225d}#i18n-btn a.disabled{color:#ed225d;cursor:default}#asterisk-design-element{position:fixed;z-index:-1;opacity:.6;pointer-events:none}.separator-design-element{width:.33em;height:.33em;margin:0 .09em .18em;display:inline-block;overflow:hidden;text-indent:-100%;background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCI+PHBhdGggZD0iTTE2LjkgMTAuM2w4LjUtMi42IDEuNyA1LjItOC41IDIuOSA1LjMgNy41LTQuNCAzLjItNS42LTcuMy01LjQgNy4xTDQuMiAyM2w1LjMtNy4yLTguNi0zLjIgMS43LTUuMiA4LjYgMi44VjEuNEgxN3Y4Ljl6IiBmaWxsPSIjZWQyMjVkIiBzdHJva2U9IiNlZDIyNWQiLz48L3N2Zz4=");-webkit-background-size:.33em .33em;background-size:.33em}#home-page #asterisk-design-element{bottom:-8%;right:20%;height:12em;width:12em;opacity:1}#examples-page #asterisk-design-element,#learn-page #asterisk-design-element,#other-content-types-page #asterisk-design-element{bottom:-14%;left:-20%;height:25em;width:25em;-webkit-transform:rotate(-1deg);-ms-transform:rotate(-1deg);-o-transform:rotate(-1deg);transform:rotate(-1deg)}#books-page #asterisk-design-element,#libraries-page #asterisk-design-element{bottom:-19%;right:-16%;height:28em;width:28em;-webkit-transform:rotate(2deg);-ms-transform:rotate(2deg);-o-transform:rotate(2deg);transform:rotate(2deg)}#community-page #asterisk-design-element,#get-started-page #asterisk-design-element{top:10%;right:-20%;height:30em;width:30em;-webkit-transform:rotate(2deg);-ms-transform:rotate(2deg);-o-transform:rotate(2deg);transform:rotate(2deg)}#download-page #asterisk-design-element,#reference-page #asterisk-design-element{top:7%;left:1%;height:10em;width:10em;-webkit-transform:rotate(-21deg);-ms-transform:rotate(-21deg);-o-transform:rotate(-21deg);transform:rotate(-21deg)}@media(max-width:1352px){#download-page #asterisk-design-element,#reference-page #asterisk-design-element{display:none!important}}.email-octopus-email-address{color:#ed225d;text-decoration:none;padding-bottom:.11em;outline:none;border:none;border-bottom:.11em dashed #ed225d;-webkit-transition:border-bottom 30ms linear;-o-transition:border-bottom 30ms linear;transition:border-bottom 30ms linear;width:13em}.email-octopus-form-row-hp{position:absolute;left:-5000px}.email-octopus-form-row button{border:1px solid #ed225d;color:#ed225d;padding:.4em .6em;margin:1em 0 0;font-family:Montserrat,sans-serif;display:block}.email-octopus-form-row button:hover{background-color:#ed225d;color:#fff}.email-octopus-email-address::-webkit-input-placeholder{color:#ababab}.email-octopus-email-address:-moz-placeholder,.email-octopus-email-address::-moz-placeholder{color:#ababab}.email-octopus-email-address:-ms-input-placeholder{color:#ababab}@media (min-width:720px){.email-octopus-email-address{width:16em}.email-octopus-form-row button{margin:0 0 0 .5em;display:inline}} -/*# sourceMappingURL=maps/all.css.map */ \ No newline at end of file diff --git a/docs/yuidoc-p5-theme/assets/arnott-wallace-eye-loop-forever.gif b/docs/yuidoc-p5-theme/assets/arnott-wallace-eye-loop-forever.gif deleted file mode 100644 index 992757bbaf..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/arnott-wallace-eye-loop-forever.gif and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/arnott-wallace-wink-loop-once.gif b/docs/yuidoc-p5-theme/assets/arnott-wallace-wink-loop-once.gif deleted file mode 100644 index 94f2015ff3..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/arnott-wallace-wink-loop-once.gif and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/beat.mp3 b/docs/yuidoc-p5-theme/assets/beat.mp3 deleted file mode 100644 index 3e5802604c..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/beat.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/beat.ogg b/docs/yuidoc-p5-theme/assets/beat.ogg deleted file mode 100644 index c13f86a41f..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/beat.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/beatbox.mp3 b/docs/yuidoc-p5-theme/assets/beatbox.mp3 deleted file mode 100644 index 23fb92eb71..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/beatbox.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/beatbox.ogg b/docs/yuidoc-p5-theme/assets/beatbox.ogg deleted file mode 100644 index b2593a6340..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/beatbox.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/blobs.csv b/docs/yuidoc-p5-theme/assets/blobs.csv deleted file mode 100644 index bda44d2203..0000000000 --- a/docs/yuidoc-p5-theme/assets/blobs.csv +++ /dev/null @@ -1,3 +0,0 @@ -ID,Name,Flavor,Shape,Color -Blob1,Blobby,Sweet,Blob,Pink -Blob2,Saddy,Savory,Blob,Blue \ No newline at end of file diff --git a/docs/yuidoc-p5-theme/assets/bricks.jpg b/docs/yuidoc-p5-theme/assets/bricks.jpg deleted file mode 100644 index 231161d752..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/bricks.jpg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/bricks_third.jpg b/docs/yuidoc-p5-theme/assets/bricks_third.jpg deleted file mode 100644 index 2fdb075996..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/bricks_third.jpg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/bx-spring.mp3 b/docs/yuidoc-p5-theme/assets/bx-spring.mp3 deleted file mode 100644 index 4a955ab7fa..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/bx-spring.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/bx-spring.ogg b/docs/yuidoc-p5-theme/assets/bx-spring.ogg deleted file mode 100644 index b01abee927..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/bx-spring.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/concrete-tunnel.mp3 b/docs/yuidoc-p5-theme/assets/concrete-tunnel.mp3 deleted file mode 100644 index 1bfbd4f8f8..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/concrete-tunnel.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/concrete-tunnel.ogg b/docs/yuidoc-p5-theme/assets/concrete-tunnel.ogg deleted file mode 100644 index be5f66b72c..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/concrete-tunnel.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/doorbell.mp3 b/docs/yuidoc-p5-theme/assets/doorbell.mp3 deleted file mode 100644 index 44b6367916..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/doorbell.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/doorbell.ogg b/docs/yuidoc-p5-theme/assets/doorbell.ogg deleted file mode 100644 index e816288c97..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/doorbell.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/drawImage.png b/docs/yuidoc-p5-theme/assets/drawImage.png deleted file mode 100644 index 1a7aa5d1d8..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/drawImage.png and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/drum.mp3 b/docs/yuidoc-p5-theme/assets/drum.mp3 deleted file mode 100644 index 9cd8727617..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/drum.mp3 and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/drum.ogg b/docs/yuidoc-p5-theme/assets/drum.ogg deleted file mode 100644 index 5061a1b319..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/drum.ogg and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/favicon.ico b/docs/yuidoc-p5-theme/assets/favicon.ico deleted file mode 100644 index 33ad9806c8..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/favicon.ico and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/fingers.mov b/docs/yuidoc-p5-theme/assets/fingers.mov deleted file mode 100644 index a9cbbbe3ea..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/fingers.mov and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.eot b/docs/yuidoc-p5-theme/assets/fonts/inconsolata.eot deleted file mode 100644 index 4b076884d0..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.eot and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.otf b/docs/yuidoc-p5-theme/assets/fonts/inconsolata.otf deleted file mode 100644 index e7e1fa0cd7..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.otf and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.svg b/docs/yuidoc-p5-theme/assets/fonts/inconsolata.svg deleted file mode 100644 index 2feb4e38c3..0000000000 --- a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.svg +++ /dev/null @@ -1,240 +0,0 @@ - - - \ No newline at end of file diff --git a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.ttf b/docs/yuidoc-p5-theme/assets/fonts/inconsolata.ttf deleted file mode 100644 index 2e8649b73d..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.ttf and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.woff b/docs/yuidoc-p5-theme/assets/fonts/inconsolata.woff deleted file mode 100644 index 41990c1dde..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/fonts/inconsolata.woff and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/gradient.png b/docs/yuidoc-p5-theme/assets/gradient.png deleted file mode 100644 index 5245af69cd..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/gradient.png and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/img/p5js.svg b/docs/yuidoc-p5-theme/assets/img/p5js.svg deleted file mode 100755 index eaf5b87618..0000000000 --- a/docs/yuidoc-p5-theme/assets/img/p5js.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/docs/yuidoc-p5-theme/assets/inconsolata.otf b/docs/yuidoc-p5-theme/assets/inconsolata.otf deleted file mode 100644 index e7e1fa0cd7..0000000000 Binary files a/docs/yuidoc-p5-theme/assets/inconsolata.otf and /dev/null differ diff --git a/docs/yuidoc-p5-theme/assets/js/reference.js b/docs/yuidoc-p5-theme/assets/js/reference.js deleted file mode 100644 index 455d4425d9..0000000000 --- a/docs/yuidoc-p5-theme/assets/js/reference.js +++ /dev/null @@ -1,4949 +0,0 @@ -(function () { -// https://github.com/umdjs/umd/blob/master/templates/returnExports.js -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - define('documented-method',[], factory); - } else if (typeof module === 'object' && module.exports) { - module.exports = factory(); - } else { - root.DocumentedMethod = factory(); - } -}(this, function () { - function extend(target, src) { - Object.keys(src).forEach(function(prop) { - target[prop] = src[prop]; - }); - return target; - } - - function DocumentedMethod(classitem) { - extend(this, classitem); - - if (this.overloads) { - // Make each overload inherit properties from their parent - // classitem. - this.overloads = this.overloads.map(function(overload) { - return extend(Object.create(this), overload); - }, this); - - if (this.params) { - throw new Error('params for overloaded methods should be undefined'); - } - - this.params = this._getMergedParams(); - } - } - - DocumentedMethod.prototype = { - // Merge parameters across all overloaded versions of this item. - _getMergedParams: function() { - var paramNames = {}; - var params = []; - - this.overloads.forEach(function(overload) { - if (!overload.params) { - return; - } - overload.params.forEach(function(param) { - if (param.name in paramNames) { - return; - } - paramNames[param.name] = param; - params.push(param); - }); - }); - - return params; - } - }; - - return DocumentedMethod; -})); - -/** - * @license RequireJS text 2.0.10 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/requirejs/text for details - */ -/*jslint regexp: true */ -/*global require, XMLHttpRequest, ActiveXObject, - define, window, process, Packages, - java, location, Components, FileUtils */ - -define('text',['module'], function (module) { - 'use strict'; - - var text, fs, Cc, Ci, xpcIsWindows, - progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'], - xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, - bodyRegExp = /]*>\s*([\s\S]+)\s*<\/body>/im, - hasLocation = typeof location !== 'undefined' && location.href, - defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''), - defaultHostName = hasLocation && location.hostname, - defaultPort = hasLocation && (location.port || undefined), - buildMap = {}, - masterConfig = (module.config && module.config()) || {}; - - text = { - version: '2.0.10', - - strip: function (content) { - //Strips declarations so that external SVG and XML - //documents can be added to a document without worry. Also, if the string - //is an HTML document, only the part inside the body tag is returned. - if (content) { - content = content.replace(xmlRegExp, ""); - var matches = content.match(bodyRegExp); - if (matches) { - content = matches[1]; - } - } else { - content = ""; - } - return content; - }, - - jsEscape: function (content) { - return content.replace(/(['\\])/g, '\\$1') - .replace(/[\f]/g, "\\f") - .replace(/[\b]/g, "\\b") - .replace(/[\n]/g, "\\n") - .replace(/[\t]/g, "\\t") - .replace(/[\r]/g, "\\r") - .replace(/[\u2028]/g, "\\u2028") - .replace(/[\u2029]/g, "\\u2029"); - }, - - createXhr: masterConfig.createXhr || function () { - //Would love to dump the ActiveX crap in here. Need IE 6 to die first. - var xhr, i, progId; - if (typeof XMLHttpRequest !== "undefined") { - return new XMLHttpRequest(); - } else if (typeof ActiveXObject !== "undefined") { - for (i = 0; i < 3; i += 1) { - progId = progIds[i]; - try { - xhr = new ActiveXObject(progId); - } catch (e) {} - - if (xhr) { - progIds = [progId]; // so faster next time - break; - } - } - } - - return xhr; - }, - - /** - * Parses a resource name into its component parts. Resource names - * look like: module/name.ext!strip, where the !strip part is - * optional. - * @param {String} name the resource name - * @returns {Object} with properties "moduleName", "ext" and "strip" - * where strip is a boolean. - */ - parseName: function (name) { - var modName, ext, temp, - strip = false, - index = name.indexOf("."), - isRelative = name.indexOf('./') === 0 || - name.indexOf('../') === 0; - - if (index !== -1 && (!isRelative || index > 1)) { - modName = name.substring(0, index); - ext = name.substring(index + 1, name.length); - } else { - modName = name; - } - - temp = ext || modName; - index = temp.indexOf("!"); - if (index !== -1) { - //Pull off the strip arg. - strip = temp.substring(index + 1) === "strip"; - temp = temp.substring(0, index); - if (ext) { - ext = temp; - } else { - modName = temp; - } - } - - return { - moduleName: modName, - ext: ext, - strip: strip - }; - }, - - xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/, - - /** - * Is an URL on another domain. Only works for browser use, returns - * false in non-browser environments. Only used to know if an - * optimized .js version of a text resource should be loaded - * instead. - * @param {String} url - * @returns Boolean - */ - useXhr: function (url, protocol, hostname, port) { - var uProtocol, uHostName, uPort, - match = text.xdRegExp.exec(url); - if (!match) { - return true; - } - uProtocol = match[2]; - uHostName = match[3]; - - uHostName = uHostName.split(':'); - uPort = uHostName[1]; - uHostName = uHostName[0]; - - return (!uProtocol || uProtocol === protocol) && - (!uHostName || uHostName.toLowerCase() === hostname.toLowerCase()) && - ((!uPort && !uHostName) || uPort === port); - }, - - finishLoad: function (name, strip, content, onLoad) { - content = strip ? text.strip(content) : content; - if (masterConfig.isBuild) { - buildMap[name] = content; - } - onLoad(content); - }, - - load: function (name, req, onLoad, config) { - //Name has format: some.module.filext!strip - //The strip part is optional. - //if strip is present, then that means only get the string contents - //inside a body tag in an HTML string. For XML/SVG content it means - //removing the declarations so the content can be inserted - //into the current doc without problems. - - // Do not bother with the work if a build and text will - // not be inlined. - if (config.isBuild && !config.inlineText) { - onLoad(); - return; - } - - masterConfig.isBuild = config.isBuild; - - var parsed = text.parseName(name), - nonStripName = parsed.moduleName + - (parsed.ext ? '.' + parsed.ext : ''), - url = req.toUrl(nonStripName), - useXhr = (masterConfig.useXhr) || - text.useXhr; - - // Do not load if it is an empty: url - if (url.indexOf('empty:') === 0) { - onLoad(); - return; - } - - //Load the text. Use XHR if possible and in a browser. - if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) { - text.get(url, function (content) { - text.finishLoad(name, parsed.strip, content, onLoad); - }, function (err) { - if (onLoad.error) { - onLoad.error(err); - } - }); - } else { - //Need to fetch the resource across domains. Assume - //the resource has been optimized into a JS module. Fetch - //by the module name + extension, but do not include the - //!strip part to avoid file system issues. - req([nonStripName], function (content) { - text.finishLoad(parsed.moduleName + '.' + parsed.ext, - parsed.strip, content, onLoad); - }); - } - }, - - write: function (pluginName, moduleName, write, config) { - if (buildMap.hasOwnProperty(moduleName)) { - var content = text.jsEscape(buildMap[moduleName]); - write.asModule(pluginName + "!" + moduleName, - "define(function () { return '" + - content + - "';});\n"); - } - }, - - writeFile: function (pluginName, moduleName, req, write, config) { - var parsed = text.parseName(moduleName), - extPart = parsed.ext ? '.' + parsed.ext : '', - nonStripName = parsed.moduleName + extPart, - //Use a '.js' file name so that it indicates it is a - //script that can be loaded across domains. - fileName = req.toUrl(parsed.moduleName + extPart) + '.js'; - - //Leverage own load() method to load plugin value, but only - //write out values that do not have the strip argument, - //to avoid any potential issues with ! in file names. - text.load(nonStripName, req, function (value) { - //Use own write() method to construct full module value. - //But need to create shell that translates writeFile's - //write() to the right interface. - var textWrite = function (contents) { - return write(fileName, contents); - }; - textWrite.asModule = function (moduleName, contents) { - return write.asModule(moduleName, fileName, contents); - }; - - text.write(pluginName, nonStripName, textWrite, config); - }, config); - } - }; - - if (masterConfig.env === 'node' || (!masterConfig.env && - typeof process !== "undefined" && - process.versions && - !!process.versions.node && - !process.versions['node-webkit'])) { - //Using special require.nodeRequire, something added by r.js. - fs = require.nodeRequire('fs'); - - text.get = function (url, callback, errback) { - try { - var file = fs.readFileSync(url, 'utf8'); - //Remove BOM (Byte Mark Order) from utf8 files if it is there. - if (file.indexOf('\uFEFF') === 0) { - file = file.substring(1); - } - callback(file); - } catch (e) { - errback(e); - } - }; - } else if (masterConfig.env === 'xhr' || (!masterConfig.env && - text.createXhr())) { - text.get = function (url, callback, errback, headers) { - var xhr = text.createXhr(), header; - xhr.open('GET', url, true); - - //Allow plugins direct access to xhr headers - if (headers) { - for (header in headers) { - if (headers.hasOwnProperty(header)) { - xhr.setRequestHeader(header.toLowerCase(), headers[header]); - } - } - } - - //Allow overrides specified in config - if (masterConfig.onXhr) { - masterConfig.onXhr(xhr, url); - } - - xhr.onreadystatechange = function (evt) { - var status, err; - //Do not explicitly handle errors, those should be - //visible via console output in the browser. - if (xhr.readyState === 4) { - status = xhr.status; - if (status > 399 && status < 600) { - //An http 4xx or 5xx error. Signal an error. - err = new Error(url + ' HTTP status: ' + status); - err.xhr = xhr; - errback(err); - } else { - callback(xhr.responseText); - } - - if (masterConfig.onXhrComplete) { - masterConfig.onXhrComplete(xhr, url); - } - } - }; - xhr.send(null); - }; - } else if (masterConfig.env === 'rhino' || (!masterConfig.env && - typeof Packages !== 'undefined' && typeof java !== 'undefined')) { - //Why Java, why is this so awkward? - text.get = function (url, callback) { - var stringBuffer, line, - encoding = "utf-8", - file = new java.io.File(url), - lineSeparator = java.lang.System.getProperty("line.separator"), - input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)), - content = ''; - try { - stringBuffer = new java.lang.StringBuffer(); - line = input.readLine(); - - // Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324 - // http://www.unicode.org/faq/utf_bom.html - - // Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK: - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058 - if (line && line.length() && line.charAt(0) === 0xfeff) { - // Eat the BOM, since we've already found the encoding on this file, - // and we plan to concatenating this buffer with others; the BOM should - // only appear at the top of a file. - line = line.substring(1); - } - - if (line !== null) { - stringBuffer.append(line); - } - - while ((line = input.readLine()) !== null) { - stringBuffer.append(lineSeparator); - stringBuffer.append(line); - } - //Make sure we return a JavaScript string and not a Java string. - content = String(stringBuffer.toString()); //String - } finally { - input.close(); - } - callback(content); - }; - } else if (masterConfig.env === 'xpconnect' || (!masterConfig.env && - typeof Components !== 'undefined' && Components.classes && - Components.interfaces)) { - //Avert your gaze! - Cc = Components.classes, - Ci = Components.interfaces; - Components.utils['import']('resource://gre/modules/FileUtils.jsm'); - xpcIsWindows = ('@mozilla.org/windows-registry-key;1' in Cc); - - text.get = function (url, callback) { - var inStream, convertStream, fileObj, - readData = {}; - - if (xpcIsWindows) { - url = url.replace(/\//g, '\\'); - } - - fileObj = new FileUtils.File(url); - - //XPCOM, you so crazy - try { - inStream = Cc['@mozilla.org/network/file-input-stream;1'] - .createInstance(Ci.nsIFileInputStream); - inStream.init(fileObj, 1, 0, false); - - convertStream = Cc['@mozilla.org/intl/converter-input-stream;1'] - .createInstance(Ci.nsIConverterInputStream); - convertStream.init(inStream, "utf-8", inStream.available(), - Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); - - convertStream.readString(inStream.available(), readData); - convertStream.close(); - inStream.close(); - callback(readData.value); - } catch (e) { - throw new Error((fileObj && fileObj.path || '') + ': ' + e); - } - }; - } - return text; -}); - - -define('text!tpl/search.html',[],function () { return '\n\n <%=name%>\n\n \n <% if (final) { %>\n constant\n <% } else if (itemtype) { %>\n <%=itemtype%> \n <% } %>\n\n <% if (className) { %>\n in <%=className%>\n <% } %>\n\n <% if (typeof is_constructor !== \'undefined\' && is_constructor) { %>\n constructor\n <% } %>\n \n\n
';}); - -/*! - * typeahead.js 0.10.2 - * https://github.com/twitter/typeahead.js - * Copyright 2013-2014 Twitter, Inc. and other contributors; Licensed MIT - */ -define('typeahead',[], function() { - -//(function($) { - - - var _ = { - isMsie: function() { - return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false; - }, - isBlankString: function(str) { - return !str || /^\s*$/.test(str); - }, - escapeRegExChars: function(str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); - }, - isString: function(obj) { - return typeof obj === "string"; - }, - isNumber: function(obj) { - return typeof obj === "number"; - }, - isArray: $.isArray, - isFunction: $.isFunction, - isObject: $.isPlainObject, - isUndefined: function(obj) { - return typeof obj === "undefined"; - }, - bind: $.proxy, - each: function(collection, cb) { - $.each(collection, reverseArgs); - function reverseArgs(index, value) { - return cb(value, index); - } - }, - map: $.map, - filter: $.grep, - every: function(obj, test) { - var result = true; - if (!obj) { - return result; - } - $.each(obj, function(key, val) { - if (!(result = test.call(null, val, key, obj))) { - return false; - } - }); - return !!result; - }, - some: function(obj, test) { - var result = false; - if (!obj) { - return result; - } - $.each(obj, function(key, val) { - if (result = test.call(null, val, key, obj)) { - return false; - } - }); - return !!result; - }, - mixin: $.extend, - getUniqueId: function() { - var counter = 0; - return function() { - return counter++; - }; - }(), - templatify: function templatify(obj) { - return $.isFunction(obj) ? obj : template; - function template() { - return String(obj); - } - }, - defer: function(fn) { - setTimeout(fn, 0); - }, - debounce: function(func, wait, immediate) { - var timeout, result; - return function() { - var context = this, args = arguments, later, callNow; - later = function() { - timeout = null; - if (!immediate) { - result = func.apply(context, args); - } - }; - callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) { - result = func.apply(context, args); - } - return result; - }; - }, - throttle: function(func, wait) { - var context, args, timeout, result, previous, later; - previous = 0; - later = function() { - previous = new Date(); - timeout = null; - result = func.apply(context, args); - }; - return function() { - var now = new Date(), remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); - timeout = null; - previous = now; - result = func.apply(context, args); - } else if (!timeout) { - timeout = setTimeout(later, remaining); - } - return result; - }; - }, - noop: function() {} - }; - var VERSION = "0.10.2"; - var tokenizers = function(root) { - return { - nonword: nonword, - whitespace: whitespace, - obj: { - nonword: getObjTokenizer(nonword), - whitespace: getObjTokenizer(whitespace) - } - }; - function whitespace(s) { - return s.split(/\s+/); - } - function nonword(s) { - return s.split(/\W+/); - } - function getObjTokenizer(tokenizer) { - return function setKey(key) { - return function tokenize(o) { - return tokenizer(o[key]); - }; - }; - } - }(); - var LruCache = function() { - function LruCache(maxSize) { - this.maxSize = maxSize || 100; - this.size = 0; - this.hash = {}; - this.list = new List(); - } - _.mixin(LruCache.prototype, { - set: function set(key, val) { - var tailItem = this.list.tail, node; - if (this.size >= this.maxSize) { - this.list.remove(tailItem); - delete this.hash[tailItem.key]; - } - if (node = this.hash[key]) { - node.val = val; - this.list.moveToFront(node); - } else { - node = new Node(key, val); - this.list.add(node); - this.hash[key] = node; - this.size++; - } - }, - get: function get(key) { - var node = this.hash[key]; - if (node) { - this.list.moveToFront(node); - return node.val; - } - } - }); - function List() { - this.head = this.tail = null; - } - _.mixin(List.prototype, { - add: function add(node) { - if (this.head) { - node.next = this.head; - this.head.prev = node; - } - this.head = node; - this.tail = this.tail || node; - }, - remove: function remove(node) { - node.prev ? node.prev.next = node.next : this.head = node.next; - node.next ? node.next.prev = node.prev : this.tail = node.prev; - }, - moveToFront: function(node) { - this.remove(node); - this.add(node); - } - }); - function Node(key, val) { - this.key = key; - this.val = val; - this.prev = this.next = null; - } - return LruCache; - }(); - var PersistentStorage = function() { - var ls, methods; - try { - ls = window.localStorage; - ls.setItem("~~~", "!"); - ls.removeItem("~~~"); - } catch (err) { - ls = null; - } - function PersistentStorage(namespace) { - this.prefix = [ "__", namespace, "__" ].join(""); - this.ttlKey = "__ttl__"; - this.keyMatcher = new RegExp("^" + this.prefix); - } - if (ls && window.JSON) { - methods = { - _prefix: function(key) { - return this.prefix + key; - }, - _ttlKey: function(key) { - return this._prefix(key) + this.ttlKey; - }, - get: function(key) { - if (this.isExpired(key)) { - this.remove(key); - } - return decode(ls.getItem(this._prefix(key))); - }, - set: function(key, val, ttl) { - if (_.isNumber(ttl)) { - ls.setItem(this._ttlKey(key), encode(now() + ttl)); - } else { - ls.removeItem(this._ttlKey(key)); - } - return ls.setItem(this._prefix(key), encode(val)); - }, - remove: function(key) { - ls.removeItem(this._ttlKey(key)); - ls.removeItem(this._prefix(key)); - return this; - }, - clear: function() { - var i, key, keys = [], len = ls.length; - for (i = 0; i < len; i++) { - if ((key = ls.key(i)).match(this.keyMatcher)) { - keys.push(key.replace(this.keyMatcher, "")); - } - } - for (i = keys.length; i--; ) { - this.remove(keys[i]); - } - return this; - }, - isExpired: function(key) { - var ttl = decode(ls.getItem(this._ttlKey(key))); - return _.isNumber(ttl) && now() > ttl ? true : false; - } - }; - } else { - methods = { - get: _.noop, - set: _.noop, - remove: _.noop, - clear: _.noop, - isExpired: _.noop - }; - } - _.mixin(PersistentStorage.prototype, methods); - return PersistentStorage; - function now() { - return new Date().getTime(); - } - function encode(val) { - return JSON.stringify(_.isUndefined(val) ? null : val); - } - function decode(val) { - return JSON.parse(val); - } - }(); - var Transport = function() { - var pendingRequestsCount = 0, pendingRequests = {}, maxPendingRequests = 6, requestCache = new LruCache(10); - function Transport(o) { - o = o || {}; - this._send = o.transport ? callbackToDeferred(o.transport) : $.ajax; - this._get = o.rateLimiter ? o.rateLimiter(this._get) : this._get; - } - Transport.setMaxPendingRequests = function setMaxPendingRequests(num) { - maxPendingRequests = num; - }; - Transport.resetCache = function clearCache() { - requestCache = new LruCache(10); - }; - _.mixin(Transport.prototype, { - _get: function(url, o, cb) { - var that = this, jqXhr; - if (jqXhr = pendingRequests[url]) { - jqXhr.done(done).fail(fail); - } else if (pendingRequestsCount < maxPendingRequests) { - pendingRequestsCount++; - pendingRequests[url] = this._send(url, o).done(done).fail(fail).always(always); - } else { - this.onDeckRequestArgs = [].slice.call(arguments, 0); - } - function done(resp) { - cb && cb(null, resp); - requestCache.set(url, resp); - } - function fail() { - cb && cb(true); - } - function always() { - pendingRequestsCount--; - delete pendingRequests[url]; - if (that.onDeckRequestArgs) { - that._get.apply(that, that.onDeckRequestArgs); - that.onDeckRequestArgs = null; - } - } - }, - get: function(url, o, cb) { - var resp; - if (_.isFunction(o)) { - cb = o; - o = {}; - } - if (resp = requestCache.get(url)) { - _.defer(function() { - cb && cb(null, resp); - }); - } else { - this._get(url, o, cb); - } - return !!resp; - } - }); - return Transport; - function callbackToDeferred(fn) { - return function customSendWrapper(url, o) { - var deferred = $.Deferred(); - fn(url, o, onSuccess, onError); - return deferred; - function onSuccess(resp) { - _.defer(function() { - deferred.resolve(resp); - }); - } - function onError(err) { - _.defer(function() { - deferred.reject(err); - }); - } - }; - } - }(); - var SearchIndex = function() { - function SearchIndex(o) { - o = o || {}; - if (!o.datumTokenizer || !o.queryTokenizer) { - $.error("datumTokenizer and queryTokenizer are both required"); - } - this.datumTokenizer = o.datumTokenizer; - this.queryTokenizer = o.queryTokenizer; - this.reset(); - } - _.mixin(SearchIndex.prototype, { - bootstrap: function bootstrap(o) { - this.datums = o.datums; - this.trie = o.trie; - }, - add: function(data) { - var that = this; - data = _.isArray(data) ? data : [ data ]; - _.each(data, function(datum) { - var id, tokens; - id = that.datums.push(datum) - 1; - tokens = normalizeTokens(that.datumTokenizer(datum)); - _.each(tokens, function(token) { - var node, chars, ch; - node = that.trie; - chars = token.split(""); - while (ch = chars.shift()) { - node = node.children[ch] || (node.children[ch] = newNode()); - node.ids.push(id); - } - }); - }); - }, - get: function get(query) { - var that = this, tokens, matches; - tokens = normalizeTokens(this.queryTokenizer(query)); - _.each(tokens, function(token) { - var node, chars, ch, ids; - if (matches && matches.length === 0) { - return false; - } - node = that.trie; - chars = token.split(""); - while (node && (ch = chars.shift())) { - node = node.children[ch]; - } - if (node && chars.length === 0) { - ids = node.ids.slice(0); - matches = matches ? getIntersection(matches, ids) : ids; - } else { - matches = []; - return false; - } - }); - return matches ? _.map(unique(matches), function(id) { - return that.datums[id]; - }) : []; - }, - reset: function reset() { - this.datums = []; - this.trie = newNode(); - }, - serialize: function serialize() { - return { - datums: this.datums, - trie: this.trie - }; - } - }); - return SearchIndex; - function normalizeTokens(tokens) { - tokens = _.filter(tokens, function(token) { - return !!token; - }); - tokens = _.map(tokens, function(token) { - return token.toLowerCase(); - }); - return tokens; - } - function newNode() { - return { - ids: [], - children: {} - }; - } - function unique(array) { - var seen = {}, uniques = []; - for (var i = 0; i < array.length; i++) { - if (!seen[array[i]]) { - seen[array[i]] = true; - uniques.push(array[i]); - } - } - return uniques; - } - function getIntersection(arrayA, arrayB) { - var ai = 0, bi = 0, intersection = []; - arrayA = arrayA.sort(compare); - arrayB = arrayB.sort(compare); - while (ai < arrayA.length && bi < arrayB.length) { - if (arrayA[ai] < arrayB[bi]) { - ai++; - } else if (arrayA[ai] > arrayB[bi]) { - bi++; - } else { - intersection.push(arrayA[ai]); - ai++; - bi++; - } - } - return intersection; - function compare(a, b) { - return a - b; - } - } - }(); - var oParser = function() { - return { - local: getLocal, - prefetch: getPrefetch, - remote: getRemote - }; - function getLocal(o) { - return o.local || null; - } - function getPrefetch(o) { - var prefetch, defaults; - defaults = { - url: null, - thumbprint: "", - ttl: 24 * 60 * 60 * 1e3, - filter: null, - ajax: {} - }; - if (prefetch = o.prefetch || null) { - prefetch = _.isString(prefetch) ? { - url: prefetch - } : prefetch; - prefetch = _.mixin(defaults, prefetch); - prefetch.thumbprint = VERSION + prefetch.thumbprint; - prefetch.ajax.type = prefetch.ajax.type || "GET"; - prefetch.ajax.dataType = prefetch.ajax.dataType || "json"; - !prefetch.url && $.error("prefetch requires url to be set"); - } - return prefetch; - } - function getRemote(o) { - var remote, defaults; - defaults = { - url: null, - wildcard: "%QUERY", - replace: null, - rateLimitBy: "debounce", - rateLimitWait: 300, - send: null, - filter: null, - ajax: {} - }; - if (remote = o.remote || null) { - remote = _.isString(remote) ? { - url: remote - } : remote; - remote = _.mixin(defaults, remote); - remote.rateLimiter = /^throttle$/i.test(remote.rateLimitBy) ? byThrottle(remote.rateLimitWait) : byDebounce(remote.rateLimitWait); - remote.ajax.type = remote.ajax.type || "GET"; - remote.ajax.dataType = remote.ajax.dataType || "json"; - delete remote.rateLimitBy; - delete remote.rateLimitWait; - !remote.url && $.error("remote requires url to be set"); - } - return remote; - function byDebounce(wait) { - return function(fn) { - return _.debounce(fn, wait); - }; - } - function byThrottle(wait) { - return function(fn) { - return _.throttle(fn, wait); - }; - } - } - }(); - (function(root) { - var old, keys; - old = root.Bloodhound; - keys = { - data: "data", - protocol: "protocol", - thumbprint: "thumbprint" - }; - root.Bloodhound = Bloodhound; - function Bloodhound(o) { - if (!o || !o.local && !o.prefetch && !o.remote) { - $.error("one of local, prefetch, or remote is required"); - } - this.limit = o.limit || 5; - this.sorter = getSorter(o.sorter); - this.dupDetector = o.dupDetector || ignoreDuplicates; - this.local = oParser.local(o); - this.prefetch = oParser.prefetch(o); - this.remote = oParser.remote(o); - this.cacheKey = this.prefetch ? this.prefetch.cacheKey || this.prefetch.url : null; - this.index = new SearchIndex({ - datumTokenizer: o.datumTokenizer, - queryTokenizer: o.queryTokenizer - }); - this.storage = this.cacheKey ? new PersistentStorage(this.cacheKey) : null; - } - Bloodhound.noConflict = function noConflict() { - root.Bloodhound = old; - return Bloodhound; - }; - Bloodhound.tokenizers = tokenizers; - _.mixin(Bloodhound.prototype, { - _loadPrefetch: function loadPrefetch(o) { - var that = this, serialized, deferred; - if (serialized = this._readFromStorage(o.thumbprint)) { - this.index.bootstrap(serialized); - deferred = $.Deferred().resolve(); - } else { - deferred = $.ajax(o.url, o.ajax).done(handlePrefetchResponse); - } - return deferred; - function handlePrefetchResponse(resp) { - that.clear(); - that.add(o.filter ? o.filter(resp) : resp); - that._saveToStorage(that.index.serialize(), o.thumbprint, o.ttl); - } - }, - _getFromRemote: function getFromRemote(query, cb) { - var that = this, url, uriEncodedQuery; - query = query || ""; - uriEncodedQuery = encodeURIComponent(query); - url = this.remote.replace ? this.remote.replace(this.remote.url, query) : this.remote.url.replace(this.remote.wildcard, uriEncodedQuery); - return this.transport.get(url, this.remote.ajax, handleRemoteResponse); - function handleRemoteResponse(err, resp) { - err ? cb([]) : cb(that.remote.filter ? that.remote.filter(resp) : resp); - } - }, - _saveToStorage: function saveToStorage(data, thumbprint, ttl) { - if (this.storage) { - this.storage.set(keys.data, data, ttl); - this.storage.set(keys.protocol, location.protocol, ttl); - this.storage.set(keys.thumbprint, thumbprint, ttl); - } - }, - _readFromStorage: function readFromStorage(thumbprint) { - var stored = {}, isExpired; - if (this.storage) { - stored.data = this.storage.get(keys.data); - stored.protocol = this.storage.get(keys.protocol); - stored.thumbprint = this.storage.get(keys.thumbprint); - } - isExpired = stored.thumbprint !== thumbprint || stored.protocol !== location.protocol; - return stored.data && !isExpired ? stored.data : null; - }, - _initialize: function initialize() { - var that = this, local = this.local, deferred; - deferred = this.prefetch ? this._loadPrefetch(this.prefetch) : $.Deferred().resolve(); - local && deferred.done(addLocalToIndex); - this.transport = this.remote ? new Transport(this.remote) : null; - return this.initPromise = deferred.promise(); - function addLocalToIndex() { - that.add(_.isFunction(local) ? local() : local); - } - }, - initialize: function initialize(force) { - return !this.initPromise || force ? this._initialize() : this.initPromise; - }, - add: function add(data) { - this.index.add(data); - }, - get: function get(query, cb) { - var that = this, matches = [], cacheHit = false; - matches = this.index.get(query); - matches = this.sorter(matches).slice(0, this.limit); - if (matches.length < this.limit && this.transport) { - cacheHit = this._getFromRemote(query, returnRemoteMatches); - } - if (!cacheHit) { - (matches.length > 0 || !this.transport) && cb && cb(matches); - } - function returnRemoteMatches(remoteMatches) { - var matchesWithBackfill = matches.slice(0); - _.each(remoteMatches, function(remoteMatch) { - var isDuplicate; - isDuplicate = _.some(matchesWithBackfill, function(match) { - return that.dupDetector(remoteMatch, match); - }); - !isDuplicate && matchesWithBackfill.push(remoteMatch); - return matchesWithBackfill.length < that.limit; - }); - cb && cb(that.sorter(matchesWithBackfill)); - } - }, - clear: function clear() { - this.index.reset(); - }, - clearPrefetchCache: function clearPrefetchCache() { - this.storage && this.storage.clear(); - }, - clearRemoteCache: function clearRemoteCache() { - this.transport && Transport.resetCache(); - }, - ttAdapter: function ttAdapter() { - return _.bind(this.get, this); - } - }); - return Bloodhound; - function getSorter(sortFn) { - return _.isFunction(sortFn) ? sort : noSort; - function sort(array) { - return array.sort(sortFn); - } - function noSort(array) { - return array; - } - } - function ignoreDuplicates() { - return false; - } - })(this); - var html = { - wrapper: '', - dropdown: '', - dataset: '', - suggestions: '', - suggestion: '' - }; - var css = { - wrapper: { - position: "relative", - display: "inline-block" - }, - hint: { - position: "absolute", - top: "0", - left: "0", - borderColor: "transparent", - boxShadow: "none" - }, - input: { - position: "relative", - verticalAlign: "top", - backgroundColor: "transparent" - }, - inputWithNoHint: { - position: "relative", - verticalAlign: "top" - }, - dropdown: { - position: "absolute", - top: "100%", - left: "0", - zIndex: "100", - display: "none" - }, - suggestions: { - display: "block" - }, - suggestion: { - whiteSpace: "nowrap", - cursor: "pointer" - }, - suggestionChild: { - whiteSpace: "normal" - }, - ltr: { - left: "0", - right: "auto" - }, - rtl: { - left: "auto", - right: " 0" - } - }; - if (_.isMsie()) { - _.mixin(css.input, { - backgroundImage: "url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)" - }); - } - if (_.isMsie() && _.isMsie() <= 7) { - _.mixin(css.input, { - marginTop: "-1px" - }); - } - var EventBus = function() { - var namespace = "typeahead:"; - function EventBus(o) { - if (!o || !o.el) { - $.error("EventBus initialized without el"); - } - this.$el = $(o.el); - } - _.mixin(EventBus.prototype, { - trigger: function(type) { - var args = [].slice.call(arguments, 1); - this.$el.trigger(namespace + type, args); - } - }); - return EventBus; - }(); - var EventEmitter = function() { - var splitter = /\s+/, nextTick = getNextTick(); - return { - onSync: onSync, - onAsync: onAsync, - off: off, - trigger: trigger - }; - function on(method, types, cb, context) { - var type; - if (!cb) { - return this; - } - types = types.split(splitter); - cb = context ? bindContext(cb, context) : cb; - this._callbacks = this._callbacks || {}; - while (type = types.shift()) { - this._callbacks[type] = this._callbacks[type] || { - sync: [], - async: [] - }; - this._callbacks[type][method].push(cb); - } - return this; - } - function onAsync(types, cb, context) { - return on.call(this, "async", types, cb, context); - } - function onSync(types, cb, context) { - return on.call(this, "sync", types, cb, context); - } - function off(types) { - var type; - if (!this._callbacks) { - return this; - } - types = types.split(splitter); - while (type = types.shift()) { - delete this._callbacks[type]; - } - return this; - } - function trigger(types) { - var type, callbacks, args, syncFlush, asyncFlush; - if (!this._callbacks) { - return this; - } - types = types.split(splitter); - args = [].slice.call(arguments, 1); - while ((type = types.shift()) && (callbacks = this._callbacks[type])) { - syncFlush = getFlush(callbacks.sync, this, [ type ].concat(args)); - asyncFlush = getFlush(callbacks.async, this, [ type ].concat(args)); - syncFlush() && nextTick(asyncFlush); - } - return this; - } - function getFlush(callbacks, context, args) { - return flush; - function flush() { - var cancelled; - for (var i = 0; !cancelled && i < callbacks.length; i += 1) { - cancelled = callbacks[i].apply(context, args) === false; - } - return !cancelled; - } - } - function getNextTick() { - var nextTickFn; - if (window.setImmediate) { - nextTickFn = function nextTickSetImmediate(fn) { - setImmediate(function() { - fn(); - }); - }; - } else { - nextTickFn = function nextTickSetTimeout(fn) { - setTimeout(function() { - fn(); - }, 0); - }; - } - return nextTickFn; - } - function bindContext(fn, context) { - return fn.bind ? fn.bind(context) : function() { - fn.apply(context, [].slice.call(arguments, 0)); - }; - } - }(); - var highlight = function(doc) { - var defaults = { - node: null, - pattern: null, - tagName: "strong", - className: null, - wordsOnly: false, - caseSensitive: false - }; - return function hightlight(o) { - var regex; - o = _.mixin({}, defaults, o); - if (!o.node || !o.pattern) { - return; - } - o.pattern = _.isArray(o.pattern) ? o.pattern : [ o.pattern ]; - regex = getRegex(o.pattern, o.caseSensitive, o.wordsOnly); - traverse(o.node, hightlightTextNode); - function hightlightTextNode(textNode) { - var match, patternNode; - if (match = regex.exec(textNode.data)) { - wrapperNode = doc.createElement(o.tagName); - o.className && (wrapperNode.className = o.className); - patternNode = textNode.splitText(match.index); - patternNode.splitText(match[0].length); - wrapperNode.appendChild(patternNode.cloneNode(true)); - textNode.parentNode.replaceChild(wrapperNode, patternNode); - } - return !!match; - } - function traverse(el, hightlightTextNode) { - var childNode, TEXT_NODE_TYPE = 3; - for (var i = 0; i < el.childNodes.length; i++) { - childNode = el.childNodes[i]; - if (childNode.nodeType === TEXT_NODE_TYPE) { - i += hightlightTextNode(childNode) ? 1 : 0; - } else { - traverse(childNode, hightlightTextNode); - } - } - } - }; - function getRegex(patterns, caseSensitive, wordsOnly) { - var escapedPatterns = [], regexStr; - for (var i = 0; i < patterns.length; i++) { - escapedPatterns.push(_.escapeRegExChars(patterns[i])); - } - regexStr = wordsOnly ? "\\b(" + escapedPatterns.join("|") + ")\\b" : "(" + escapedPatterns.join("|") + ")"; - return caseSensitive ? new RegExp(regexStr) : new RegExp(regexStr, "i"); - } - }(window.document); - var Input = function() { - var specialKeyCodeMap; - specialKeyCodeMap = { - 9: "tab", - 27: "esc", - 37: "left", - 39: "right", - 13: "enter", - 38: "up", - 40: "down" - }; - function Input(o) { - var that = this, onBlur, onFocus, onKeydown, onInput; - o = o || {}; - if (!o.input) { - $.error("input is missing"); - } - onBlur = _.bind(this._onBlur, this); - onFocus = _.bind(this._onFocus, this); - onKeydown = _.bind(this._onKeydown, this); - onInput = _.bind(this._onInput, this); - this.$hint = $(o.hint); - this.$input = $(o.input).on("blur.tt", onBlur).on("focus.tt", onFocus).on("keydown.tt", onKeydown); - if (this.$hint.length === 0) { - this.setHint = this.getHint = this.clearHint = this.clearHintIfInvalid = _.noop; - } - if (!_.isMsie()) { - this.$input.on("input.tt", onInput); - } else { - this.$input.on("keydown.tt keypress.tt cut.tt paste.tt", function($e) { - if (specialKeyCodeMap[$e.which || $e.keyCode]) { - return; - } - _.defer(_.bind(that._onInput, that, $e)); - }); - } - this.query = this.$input.val(); - this.$overflowHelper = buildOverflowHelper(this.$input); - } - Input.normalizeQuery = function(str) { - return (str || "").replace(/^\s*/g, "").replace(/\s{2,}/g, " "); - }; - _.mixin(Input.prototype, EventEmitter, { - _onBlur: function onBlur() { - this.resetInputValue(); - this.trigger("blurred"); - }, - _onFocus: function onFocus() { - this.trigger("focused"); - }, - _onKeydown: function onKeydown($e) { - var keyName = specialKeyCodeMap[$e.which || $e.keyCode]; - this._managePreventDefault(keyName, $e); - if (keyName && this._shouldTrigger(keyName, $e)) { - this.trigger(keyName + "Keyed", $e); - } - }, - _onInput: function onInput() { - this._checkInputValue(); - }, - _managePreventDefault: function managePreventDefault(keyName, $e) { - var preventDefault, hintValue, inputValue; - switch (keyName) { - case "tab": - hintValue = this.getHint(); - inputValue = this.getInputValue(); - preventDefault = hintValue && hintValue !== inputValue && !withModifier($e); - break; - - case "up": - case "down": - preventDefault = !withModifier($e); - break; - - default: - preventDefault = false; - } - preventDefault && $e.preventDefault(); - }, - _shouldTrigger: function shouldTrigger(keyName, $e) { - var trigger; - switch (keyName) { - case "tab": - trigger = !withModifier($e); - break; - - default: - trigger = true; - } - return trigger; - }, - _checkInputValue: function checkInputValue() { - var inputValue, areEquivalent, hasDifferentWhitespace; - inputValue = this.getInputValue(); - areEquivalent = areQueriesEquivalent(inputValue, this.query); - hasDifferentWhitespace = areEquivalent ? this.query.length !== inputValue.length : false; - if (!areEquivalent) { - this.trigger("queryChanged", this.query = inputValue); - } else if (hasDifferentWhitespace) { - this.trigger("whitespaceChanged", this.query); - } - }, - focus: function focus() { - this.$input.focus(); - }, - blur: function blur() { - this.$input.blur(); - }, - getQuery: function getQuery() { - return this.query; - }, - setQuery: function setQuery(query) { - this.query = query; - }, - getInputValue: function getInputValue() { - return this.$input.val(); - }, - setInputValue: function setInputValue(value, silent) { - this.$input.val(value); - silent ? this.clearHint() : this._checkInputValue(); - }, - resetInputValue: function resetInputValue() { - this.setInputValue(this.query, true); - }, - getHint: function getHint() { - return this.$hint.val(); - }, - setHint: function setHint(value) { - this.$hint.val(value); - }, - clearHint: function clearHint() { - this.setHint(""); - }, - clearHintIfInvalid: function clearHintIfInvalid() { - var val, hint, valIsPrefixOfHint, isValid; - val = this.getInputValue(); - hint = this.getHint(); - valIsPrefixOfHint = val !== hint && hint.indexOf(val) === 0; - isValid = val !== "" && valIsPrefixOfHint && !this.hasOverflow(); - !isValid && this.clearHint(); - }, - getLanguageDirection: function getLanguageDirection() { - return (this.$input.css("direction") || "ltr").toLowerCase(); - }, - hasOverflow: function hasOverflow() { - var constraint = this.$input.width() - 2; - this.$overflowHelper.text(this.getInputValue()); - return this.$overflowHelper.width() >= constraint; - }, - isCursorAtEnd: function() { - var valueLength, selectionStart, range; - valueLength = this.$input.val().length; - selectionStart = this.$input[0].selectionStart; - if (_.isNumber(selectionStart)) { - return selectionStart === valueLength; - } else if (document.selection) { - range = document.selection.createRange(); - range.moveStart("character", -valueLength); - return valueLength === range.text.length; - } - return true; - }, - destroy: function destroy() { - this.$hint.off(".tt"); - this.$input.off(".tt"); - this.$hint = this.$input = this.$overflowHelper = null; - } - }); - return Input; - function buildOverflowHelper($input) { - return $('').css({ - position: "absolute", - visibility: "hidden", - whiteSpace: "pre", - fontFamily: $input.css("font-family"), - fontSize: $input.css("font-size"), - fontStyle: $input.css("font-style"), - fontVariant: $input.css("font-variant"), - fontWeight: $input.css("font-weight"), - wordSpacing: $input.css("word-spacing"), - letterSpacing: $input.css("letter-spacing"), - textIndent: $input.css("text-indent"), - textRendering: $input.css("text-rendering"), - textTransform: $input.css("text-transform") - }).insertAfter($input); - } - function areQueriesEquivalent(a, b) { - return Input.normalizeQuery(a) === Input.normalizeQuery(b); - } - function withModifier($e) { - return $e.altKey || $e.ctrlKey || $e.metaKey || $e.shiftKey; - } - }(); - var Dataset = function() { - var datasetKey = "ttDataset", valueKey = "ttValue", datumKey = "ttDatum"; - function Dataset(o) { - o = o || {}; - o.templates = o.templates || {}; - if (!o.source) { - $.error("missing source"); - } - if (o.name && !isValidName(o.name)) { - $.error("invalid dataset name: " + o.name); - } - this.query = null; - this.highlight = !!o.highlight; - this.name = o.name || _.getUniqueId(); - this.source = o.source; - this.displayFn = getDisplayFn(o.display || o.displayKey); - this.templates = getTemplates(o.templates, this.displayFn); - this.$el = $(html.dataset.replace("%CLASS%", this.name)); - } - Dataset.extractDatasetName = function extractDatasetName(el) { - return $(el).data(datasetKey); - }; - Dataset.extractValue = function extractDatum(el) { - return $(el).data(valueKey); - }; - Dataset.extractDatum = function extractDatum(el) { - return $(el).data(datumKey); - }; - _.mixin(Dataset.prototype, EventEmitter, { - _render: function render(query, suggestions) { - if (!this.$el) { - return; - } - var that = this, hasSuggestions; - this.$el.empty(); - hasSuggestions = suggestions && suggestions.length; - if (!hasSuggestions && this.templates.empty) { - this.$el.html(getEmptyHtml()).prepend(that.templates.header ? getHeaderHtml() : null).append(that.templates.footer ? getFooterHtml() : null); - } else if (hasSuggestions) { - this.$el.html(getSuggestionsHtml()).prepend(that.templates.header ? getHeaderHtml() : null).append(that.templates.footer ? getFooterHtml() : null); - } - this.trigger("rendered"); - function getEmptyHtml() { - return that.templates.empty({ - query: query, - isEmpty: true - }); - } - function getSuggestionsHtml() { - var $suggestions, nodes; - $suggestions = $(html.suggestions).css(css.suggestions); - nodes = _.map(suggestions, getSuggestionNode); - $suggestions.append.apply($suggestions, nodes); - that.highlight && highlight({ - node: $suggestions[0], - pattern: query - }); - return $suggestions; - function getSuggestionNode(suggestion) { - var $el; - $el = $(html.suggestion).append(that.templates.suggestion(suggestion)).data(datasetKey, that.name).data(valueKey, that.displayFn(suggestion)).data(datumKey, suggestion); - $el.children().each(function() { - $(this).css(css.suggestionChild); - }); - return $el; - } - } - function getHeaderHtml() { - return that.templates.header({ - query: query, - isEmpty: !hasSuggestions - }); - } - function getFooterHtml() { - return that.templates.footer({ - query: query, - isEmpty: !hasSuggestions - }); - } - }, - getRoot: function getRoot() { - return this.$el; - }, - update: function update(query) { - var that = this; - this.query = query; - this.canceled = false; - this.source(query, render); - function render(suggestions) { - if (!that.canceled && query === that.query) { - that._render(query, suggestions); - } - } - }, - cancel: function cancel() { - this.canceled = true; - }, - clear: function clear() { - this.cancel(); - this.$el.empty(); - this.trigger("rendered"); - }, - isEmpty: function isEmpty() { - return this.$el.is(":empty"); - }, - destroy: function destroy() { - this.$el = null; - } - }); - return Dataset; - function getDisplayFn(display) { - display = display || "value"; - return _.isFunction(display) ? display : displayFn; - function displayFn(obj) { - return obj[display]; - } - } - function getTemplates(templates, displayFn) { - return { - empty: templates.empty && _.templatify(templates.empty), - header: templates.header && _.templatify(templates.header), - footer: templates.footer && _.templatify(templates.footer), - suggestion: templates.suggestion || suggestionTemplate - }; - function suggestionTemplate(context) { - return "" + displayFn(context) + "
"; - } - } - function isValidName(str) { - return /^[_a-zA-Z0-9-]+$/.test(str); - } - }(); - var Dropdown = function() { - function Dropdown(o) { - var that = this, onSuggestionClick, onSuggestionMouseEnter, onSuggestionMouseLeave; - o = o || {}; - if (!o.menu) { - $.error("menu is required"); - } - this.isOpen = false; - this.isEmpty = true; - this.datasets = _.map(o.datasets, initializeDataset); - onSuggestionClick = _.bind(this._onSuggestionClick, this); - onSuggestionMouseEnter = _.bind(this._onSuggestionMouseEnter, this); - onSuggestionMouseLeave = _.bind(this._onSuggestionMouseLeave, this); - this.$menu = $(o.menu).on("click.tt", ".tt-suggestion", onSuggestionClick).on("mouseenter.tt", ".tt-suggestion", onSuggestionMouseEnter).on("mouseleave.tt", ".tt-suggestion", onSuggestionMouseLeave); - _.each(this.datasets, function(dataset) { - that.$menu.append(dataset.getRoot()); - dataset.onSync("rendered", that._onRendered, that); - }); - } - _.mixin(Dropdown.prototype, EventEmitter, { - _onSuggestionClick: function onSuggestionClick($e) { - this.trigger("suggestionClicked", $($e.currentTarget)); - }, - _onSuggestionMouseEnter: function onSuggestionMouseEnter($e) { - this._removeCursor(); - this._setCursor($($e.currentTarget), true); - }, - _onSuggestionMouseLeave: function onSuggestionMouseLeave() { - this._removeCursor(); - }, - _onRendered: function onRendered() { - this.isEmpty = _.every(this.datasets, isDatasetEmpty); - this.isEmpty ? this._hide() : this.isOpen && this._show(); - this.trigger("datasetRendered"); - function isDatasetEmpty(dataset) { - return dataset.isEmpty(); - } - }, - _hide: function() { - this.$menu.hide(); - }, - _show: function() { - this.$menu.css("display", "block"); - }, - _getSuggestions: function getSuggestions() { - return this.$menu.find(".tt-suggestion"); - }, - _getCursor: function getCursor() { - return this.$menu.find(".tt-cursor").first(); - }, - _setCursor: function setCursor($el, silent) { - $el.first().addClass("tt-cursor"); - !silent && this.trigger("cursorMoved"); - }, - _removeCursor: function removeCursor() { - this._getCursor().removeClass("tt-cursor"); - }, - _moveCursor: function moveCursor(increment) { - var $suggestions, $oldCursor, newCursorIndex, $newCursor; - if (!this.isOpen) { - return; - } - $oldCursor = this._getCursor(); - $suggestions = this._getSuggestions(); - this._removeCursor(); - newCursorIndex = $suggestions.index($oldCursor) + increment; - newCursorIndex = (newCursorIndex + 1) % ($suggestions.length + 1) - 1; - if (newCursorIndex === -1) { - this.trigger("cursorRemoved"); - return; - } else if (newCursorIndex < -1) { - newCursorIndex = $suggestions.length - 1; - } - this._setCursor($newCursor = $suggestions.eq(newCursorIndex)); - this._ensureVisible($newCursor); - }, - _ensureVisible: function ensureVisible($el) { - var elTop, elBottom, menuScrollTop, menuHeight; - elTop = $el.position().top; - elBottom = elTop + $el.outerHeight(true); - menuScrollTop = this.$menu.scrollTop(); - menuHeight = this.$menu.height() + parseInt(this.$menu.css("paddingTop"), 10) + parseInt(this.$menu.css("paddingBottom"), 10); - if (elTop < 0) { - this.$menu.scrollTop(menuScrollTop + elTop); - } else if (menuHeight < elBottom) { - this.$menu.scrollTop(menuScrollTop + (elBottom - menuHeight)); - } - }, - close: function close() { - if (this.isOpen) { - this.isOpen = false; - this._removeCursor(); - this._hide(); - this.trigger("closed"); - } - }, - open: function open() { - if (!this.isOpen) { - this.isOpen = true; - !this.isEmpty && this._show(); - this.trigger("opened"); - } - }, - setLanguageDirection: function setLanguageDirection(dir) { - this.$menu.css(dir === "ltr" ? css.ltr : css.rtl); - }, - moveCursorUp: function moveCursorUp() { - this._moveCursor(-1); - }, - moveCursorDown: function moveCursorDown() { - this._moveCursor(+1); - }, - getDatumForSuggestion: function getDatumForSuggestion($el) { - var datum = null; - if ($el.length) { - datum = { - raw: Dataset.extractDatum($el), - value: Dataset.extractValue($el), - datasetName: Dataset.extractDatasetName($el) - }; - } - return datum; - }, - getDatumForCursor: function getDatumForCursor() { - return this.getDatumForSuggestion(this._getCursor().first()); - }, - getDatumForTopSuggestion: function getDatumForTopSuggestion() { - return this.getDatumForSuggestion(this._getSuggestions().first()); - }, - update: function update(query) { - _.each(this.datasets, updateDataset); - function updateDataset(dataset) { - dataset.update(query); - } - }, - empty: function empty() { - _.each(this.datasets, clearDataset); - this.isEmpty = true; - function clearDataset(dataset) { - dataset.clear(); - } - }, - isVisible: function isVisible() { - return this.isOpen && !this.isEmpty; - }, - destroy: function destroy() { - this.$menu.off(".tt"); - this.$menu = null; - _.each(this.datasets, destroyDataset); - function destroyDataset(dataset) { - dataset.destroy(); - } - } - }); - return Dropdown; - function initializeDataset(oDataset) { - return new Dataset(oDataset); - } - }(); - var Typeahead = function() { - var attrsKey = "ttAttrs"; - function Typeahead(o) { - var $menu, $input, $hint; - o = o || {}; - if (!o.input) { - $.error("missing input"); - } - this.isActivated = false; - this.autoselect = !!o.autoselect; - this.minLength = _.isNumber(o.minLength) ? o.minLength : 1; - this.$node = buildDomStructure(o.input, o.withHint); - $menu = this.$node.find(".tt-dropdown-menu"); - $input = this.$node.find(".tt-input"); - $hint = this.$node.find(".tt-hint"); - $input.on("blur.tt", function($e) { - var active, isActive, hasActive; - active = document.activeElement; - isActive = $menu.is(active); - hasActive = $menu.has(active).length > 0; - if (_.isMsie() && (isActive || hasActive)) { - $e.preventDefault(); - $e.stopImmediatePropagation(); - _.defer(function() { - $input.focus(); - }); - } - }); - $menu.on("mousedown.tt", function($e) { - $e.preventDefault(); - }); - this.eventBus = o.eventBus || new EventBus({ - el: $input - }); - this.dropdown = new Dropdown({ - menu: $menu, - datasets: o.datasets - }).onSync("suggestionClicked", this._onSuggestionClicked, this).onSync("cursorMoved", this._onCursorMoved, this).onSync("cursorRemoved", this._onCursorRemoved, this).onSync("opened", this._onOpened, this).onSync("closed", this._onClosed, this).onAsync("datasetRendered", this._onDatasetRendered, this); - this.input = new Input({ - input: $input, - hint: $hint - }).onSync("focused", this._onFocused, this).onSync("blurred", this._onBlurred, this).onSync("enterKeyed", this._onEnterKeyed, this).onSync("tabKeyed", this._onTabKeyed, this).onSync("escKeyed", this._onEscKeyed, this).onSync("upKeyed", this._onUpKeyed, this).onSync("downKeyed", this._onDownKeyed, this).onSync("leftKeyed", this._onLeftKeyed, this).onSync("rightKeyed", this._onRightKeyed, this).onSync("queryChanged", this._onQueryChanged, this).onSync("whitespaceChanged", this._onWhitespaceChanged, this); - this._setLanguageDirection(); - } - _.mixin(Typeahead.prototype, { - _onSuggestionClicked: function onSuggestionClicked(type, $el) { - var datum; - if (datum = this.dropdown.getDatumForSuggestion($el)) { - this._select(datum); - } - }, - _onCursorMoved: function onCursorMoved() { - var datum = this.dropdown.getDatumForCursor(); - this.input.setInputValue(datum.value, true); - this.eventBus.trigger("cursorchanged", datum.raw, datum.datasetName); - }, - _onCursorRemoved: function onCursorRemoved() { - this.input.resetInputValue(); - this._updateHint(); - }, - _onDatasetRendered: function onDatasetRendered() { - this._updateHint(); - }, - _onOpened: function onOpened() { - this._updateHint(); - this.eventBus.trigger("opened"); - }, - _onClosed: function onClosed() { - this.input.clearHint(); - this.eventBus.trigger("closed"); - }, - _onFocused: function onFocused() { - this.isActivated = true; - this.dropdown.open(); - }, - _onBlurred: function onBlurred() { - this.isActivated = false; - this.dropdown.empty(); - this.dropdown.close(); - this.setVal("", true); //LM - }, - _onEnterKeyed: function onEnterKeyed(type, $e) { - var cursorDatum, topSuggestionDatum; - cursorDatum = this.dropdown.getDatumForCursor(); - topSuggestionDatum = this.dropdown.getDatumForTopSuggestion(); - if (cursorDatum) { - this._select(cursorDatum); - $e.preventDefault(); - } else if (this.autoselect && topSuggestionDatum) { - this._select(topSuggestionDatum); - $e.preventDefault(); - } - }, - _onTabKeyed: function onTabKeyed(type, $e) { - var datum; - if (datum = this.dropdown.getDatumForCursor()) { - this._select(datum); - $e.preventDefault(); - } else { - this._autocomplete(true); - } - }, - _onEscKeyed: function onEscKeyed() { - this.dropdown.close(); - this.input.resetInputValue(); - }, - _onUpKeyed: function onUpKeyed() { - var query = this.input.getQuery(); - this.dropdown.isEmpty && query.length >= this.minLength ? this.dropdown.update(query) : this.dropdown.moveCursorUp(); - this.dropdown.open(); - }, - _onDownKeyed: function onDownKeyed() { - var query = this.input.getQuery(); - this.dropdown.isEmpty && query.length >= this.minLength ? this.dropdown.update(query) : this.dropdown.moveCursorDown(); - this.dropdown.open(); - }, - _onLeftKeyed: function onLeftKeyed() { - this.dir === "rtl" && this._autocomplete(); - }, - _onRightKeyed: function onRightKeyed() { - this.dir === "ltr" && this._autocomplete(); - }, - _onQueryChanged: function onQueryChanged(e, query) { - this.input.clearHintIfInvalid(); - query.length >= this.minLength ? this.dropdown.update(query) : this.dropdown.empty(); - this.dropdown.open(); - this._setLanguageDirection(); - }, - _onWhitespaceChanged: function onWhitespaceChanged() { - this._updateHint(); - this.dropdown.open(); - }, - _setLanguageDirection: function setLanguageDirection() { - var dir; - if (this.dir !== (dir = this.input.getLanguageDirection())) { - this.dir = dir; - this.$node.css("direction", dir); - this.dropdown.setLanguageDirection(dir); - } - }, - _updateHint: function updateHint() { - var datum, val, query, escapedQuery, frontMatchRegEx, match; - datum = this.dropdown.getDatumForTopSuggestion(); - if (datum && this.dropdown.isVisible() && !this.input.hasOverflow()) { - val = this.input.getInputValue(); - query = Input.normalizeQuery(val); - escapedQuery = _.escapeRegExChars(query); - frontMatchRegEx = new RegExp("^(?:" + escapedQuery + ")(.+$)", "i"); - match = frontMatchRegEx.exec(datum.value); - match ? this.input.setHint(val + match[1]) : this.input.clearHint(); - } else { - this.input.clearHint(); - } - }, - _autocomplete: function autocomplete(laxCursor) { - var hint, query, isCursorAtEnd, datum; - hint = this.input.getHint(); - query = this.input.getQuery(); - isCursorAtEnd = laxCursor || this.input.isCursorAtEnd(); - if (hint && query !== hint && isCursorAtEnd) { - datum = this.dropdown.getDatumForTopSuggestion(); - datum && this.input.setInputValue(datum.value); - this.eventBus.trigger("autocompleted", datum.raw, datum.datasetName); - } - }, - _select: function select(datum) { - this.input.setQuery(datum.value); - this.input.setInputValue(datum.value, true); - this._setLanguageDirection(); - this.eventBus.trigger("selected", datum.raw, datum.datasetName); - this.dropdown.close(); - _.defer(_.bind(this.dropdown.empty, this.dropdown)); - }, - open: function open() { - this.dropdown.open(); - }, - close: function close() { - this.dropdown.close(); - }, - setVal: function setVal(val) { - if (this.isActivated) { - this.input.setInputValue(val); - } else { - this.input.setQuery(val); - this.input.setInputValue(val, true); - } - this._setLanguageDirection(); - }, - getVal: function getVal() { - return this.input.getQuery(); - }, - destroy: function destroy() { - this.input.destroy(); - this.dropdown.destroy(); - destroyDomStructure(this.$node); - this.$node = null; - } - }); - return Typeahead; - function buildDomStructure(input, withHint) { - var $input, $wrapper, $dropdown, $hint; - $input = $(input); - $wrapper = $(html.wrapper).css(css.wrapper); - $dropdown = $(html.dropdown).css(css.dropdown); - $hint = $input.clone().css(css.hint).css(getBackgroundStyles($input)); - $hint.val("").removeData().addClass("tt-hint").removeAttr("id name placeholder").prop("disabled", true).attr({ - autocomplete: "off", - spellcheck: "false" - }); - $input.data(attrsKey, { - dir: $input.attr("dir"), - autocomplete: $input.attr("autocomplete"), - spellcheck: $input.attr("spellcheck"), - style: $input.attr("style") - }); - $input.addClass("tt-input").attr({ - autocomplete: "off", - spellcheck: false - }).css(withHint ? css.input : css.inputWithNoHint); - try { - !$input.attr("dir") && $input.attr("dir", "auto"); - } catch (e) {} - return $input.wrap($wrapper).parent().prepend(withHint ? $hint : null).append($dropdown); - } - function getBackgroundStyles($el) { - return { - backgroundAttachment: $el.css("background-attachment"), - backgroundClip: $el.css("background-clip"), - backgroundColor: $el.css("background-color"), - backgroundImage: $el.css("background-image"), - backgroundOrigin: $el.css("background-origin"), - backgroundPosition: $el.css("background-position"), - backgroundRepeat: $el.css("background-repeat"), - backgroundSize: $el.css("background-size") - }; - } - function destroyDomStructure($node) { - var $input = $node.find(".tt-input"); - _.each($input.data(attrsKey), function(val, key) { - _.isUndefined(val) ? $input.removeAttr(key) : $input.attr(key, val); - }); - $input.detach().removeData(attrsKey).removeClass("tt-input").insertAfter($node); - $node.remove(); - } - }(); - (function() { - var old, typeaheadKey, methods; - old = $.fn.typeahead; - typeaheadKey = "ttTypeahead"; - methods = { - initialize: function initialize(o, datasets) { - datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1); - o = o || {}; - return this.each(attach); - function attach() { - var $input = $(this), eventBus, typeahead; - _.each(datasets, function(d) { - d.highlight = !!o.highlight; - }); - typeahead = new Typeahead({ - input: $input, - eventBus: eventBus = new EventBus({ - el: $input - }), - withHint: _.isUndefined(o.hint) ? true : !!o.hint, - minLength: o.minLength, - autoselect: o.autoselect, - datasets: datasets - }); - $input.data(typeaheadKey, typeahead); - } - }, - open: function open() { - return this.each(openTypeahead); - function openTypeahead() { - var $input = $(this), typeahead; - if (typeahead = $input.data(typeaheadKey)) { - typeahead.open(); - } - } - }, - close: function close() { - return this.each(closeTypeahead); - function closeTypeahead() { - var $input = $(this), typeahead; - if (typeahead = $input.data(typeaheadKey)) { - typeahead.close(); - } - } - }, - val: function val(newVal) { - return !arguments.length ? getVal(this.first()) : this.each(setVal); - function setVal() { - var $input = $(this), typeahead; - if (typeahead = $input.data(typeaheadKey)) { - typeahead.setVal(newVal); - } - } - function getVal($input) { - var typeahead, query; - if (typeahead = $input.data(typeaheadKey)) { - query = typeahead.getVal(); - } - return query; - } - }, - destroy: function destroy() { - return this.each(unattach); - function unattach() { - var $input = $(this), typeahead; - if (typeahead = $input.data(typeaheadKey)) { - typeahead.destroy(); - $input.removeData(typeaheadKey); - } - } - } - }; - $.fn.typeahead = function(method) { - if (methods[method]) { - return methods[method].apply(this, [].slice.call(arguments, 1)); - } else { - return methods.initialize.apply(this, arguments); - } - }; - $.fn.typeahead.noConflict = function noConflict() { - $.fn.typeahead = old; - return this; - }; - })(); - - - -//})(window.jQuery); - - -}); -define('searchView',[ - 'App', - // Templates - 'text!tpl/search.html', - 'text!tpl/search_suggestion.html', - // Tools - 'typeahead' -], function(App, searchTpl, suggestionTpl) { - - var searchView = Backbone.View.extend({ - el: '#search', - /** - * Init. - */ - init: function() { - var tpl = _.template(searchTpl); - var className = 'form-control input-lg'; - var placeholder = 'Search reference'; - this.searchHtml = tpl({ - 'placeholder': placeholder, - 'className': className - }); - this.items = App.classes.concat(App.allItems); - - return this; - }, - /** - * Render input field with Typehead activated. - */ - render: function() { - // Append the view to the dom - this.$el.append(this.searchHtml); - - // Render Typeahead - var $searchInput = this.$el.find('input[type=text]'); - this.typeaheadRender($searchInput); - this.typeaheadEvents($searchInput); - - return this; - }, - /** - * Apply Twitter Typeahead to the search input field. - * @param {jquery} $input - */ - typeaheadRender: function($input) { - var self = this; - $input.typeahead(null, { - 'displayKey': 'name', - 'minLength': 2, - //'highlight': true, - 'source': self.substringMatcher(this.items), - 'templates': { - 'empty': ' ', - 'suggestion': _.template(suggestionTpl) - } - }); - }, - /** - * Setup typeahead custom events (item selected). - */ - typeaheadEvents: function($input) { - var self = this; - $input.on('typeahead:selected', function(e, item, datasetName) { - var selectedItem = self.items[item.idx]; - select(selectedItem); - }); - $input.on('keydown', function(e) { - if (e.which === 13) { // enter - var txt = $input.val(); - var f = _.find(self.items, function(it) { return it.name == txt; }); - if (f) { - select(f); - } - } else if (e.which === 27) { - $input.blur(); - } - }); - - function select(selectedItem) { - var hash = App.router.getHash(selectedItem);// - App.router.navigate(hash, {'trigger': true}); - $('#item').focus(); - } - }, - /** - * substringMatcher function for Typehead (search for strings in an array). - * @param {array} array - * @returns {Function} - */ - substringMatcher: function(array) { - return function findMatches(query, callback) { - var matches = [], substrRegex, arrayLength = array.length; - - // regex used to determine if a string contains the substring `query` - substrRegex = new RegExp(query, 'i'); - - // iterate through the pool of strings and for any string that - // contains the substring `query`, add it to the `matches` array - for (var i=0; i < arrayLength; i++) { - var item = array[i]; - if (substrRegex.test(item.name)) { - // typeahead expects suggestions to be a js object - matches.push({ - 'itemtype': item.itemtype, - 'name': item.name, - 'className': item.class, - 'is_constructor': !!item.is_constructor, - 'final': item.final, - 'idx': i - }); - } - } - - callback(matches); - }; - } - - }); - - return searchView; - -}); - - -define('text!tpl/list.html',[],function () { return '<% _.each(groups, function(group){ %>\n\n Deprecated: <%=item.name%><% if (item.isMethod) { %>()<% } %> is deprecated and will be removed in a future version of p5. <% if (item.deprecationMessage) { %><%=item.deprecationMessage%><% } %>\n
\n <% } %>\n \n\n <%= item.description %>\n\n <% if (item.extends) { %>\nExtends <%=item.extends%>
\n <% } %>\n\n <% if (item.module === \'p5.sound\') { %>\nThis function requires you include the p5.sound library. Add the following into the head of your index.html file:\n
<script src="path/to/p5.sound.js"></script>
\n \n <% } %>\n\n <% if (item.constRefs) { %>\n Used by:\n <%\n var refs = item.constRefs;\n for (var i = 0; i < refs.length; i ++) {\n var ref = refs[i];\n var name = ref;\n if (name.substr(0, 3) === \'p5.\') {\n name = name.substr(3);\n }\n if (i !== 0) {\n if (i == refs.length - 1) {\n %> and <%\n } else {\n %>, <%\n }\n }\n %><%= name %>()<%\n }\n %>\n
\n <% } %>\n\n <% syntaxes.forEach(function(syntax) { %>\n
<%= syntax %>
\n <% }) %>\n \n<%=item.return.type%>: <%= item.return.description %>
\n- * For a fairly comprehensive set of languages see the - * README - * file that came with this source. At a minimum, the lexer should work on a - * number of languages including C and friends, Java, Python, Bash, SQL, HTML, - * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk - * and a subset of Perl, but, because of commenting conventions, doesn't work on - * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class. - *
- * Usage:
} and {@code } tags in your source with
- * {@code class=prettyprint.}
- * You can also use the (html deprecated) {@code } tag, but the pretty
- * printer needs to do more substantial DOM manipulations to support that, so
- * some css styles may not be preserved.
- *
} or {@code } element to specify the
- * language, as in {@code }. Any class that
- * starts with "lang-" followed by a file extension, specifies the file type.
- * See the "lang-*.js" files in this directory for code that implements
- * per-language file handlers.
- *
- * Change log:
- * cbeust, 2006/08/22
- *
- * Java annotations (start with "@") are now captured as literals ("lit")
- *
- * @requires console
- */
-
-// JSLint declarations
-/*global console, document, navigator, setTimeout, window, define */
-
-/** @define {boolean} */
-var IN_GLOBAL_SCOPE = true;
-
-/**
- * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
- * UI events.
- * If set to {@code false}, {@code prettyPrint()} is synchronous.
- */
-window['PR_SHOULD_USE_CONTINUATION'] = true;
-
-/**
- * Pretty print a chunk of code.
- * @param {string} sourceCodeHtml The HTML to pretty print.
- * @param {string} opt_langExtension The language name to use.
- * Typically, a filename extension like 'cpp' or 'java'.
- * @param {number|boolean} opt_numberLines True to number lines,
- * or the 1-indexed number of the first line in sourceCodeHtml.
- * @return {string} code as html, but prettier
- */
-var prettyPrintOne;
-/**
- * Find all the {@code } and {@code } tags in the DOM with
- * {@code class=prettyprint} and prettify them.
- *
- * @param {Function} opt_whenDone called when prettifying is done.
- * @param {HTMLElement|HTMLDocument} opt_root an element or document
- * containing all the elements to pretty print.
- * Defaults to {@code document.body}.
- */
-var prettyPrint;
-
-
-(function () {
- var win = window;
- // Keyword lists for various languages.
- // We use things that coerce to strings to make them compact when minified
- // and to defeat aggressive optimizers that fold large string constants.
- var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
- var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
- "double,enum,extern,float,goto,inline,int,long,register,short,signed," +
- "sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];
- var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
- "new,operator,private,protected,public,this,throw,true,try,typeof"];
- var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
- "concept,concept_map,const_cast,constexpr,decltype,delegate," +
- "dynamic_cast,explicit,export,friend,generic,late_check," +
- "mutable,namespace,nullptr,property,reinterpret_cast,static_assert," +
- "static_cast,template,typeid,typename,using,virtual,where"];
- var JAVA_KEYWORDS = [COMMON_KEYWORDS,
- "abstract,assert,boolean,byte,extends,final,finally,implements,import," +
- "instanceof,interface,null,native,package,strictfp,super,synchronized," +
- "throws,transient"];
- var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
- "as,base,by,checked,decimal,delegate,descending,dynamic,event," +
- "fixed,foreach,from,group,implicit,in,internal,into,is,let," +
- "lock,object,out,override,orderby,params,partial,readonly,ref,sbyte," +
- "sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort," +
- "var,virtual,where"];
- var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
- "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
- "throw,true,try,unless,until,when,while,yes";
- var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
- "debugger,eval,export,function,get,null,set,undefined,var,with," +
- "Infinity,NaN"];
- var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
- "goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
- "sub,undef,unless,until,use,wantarray,while,BEGIN,END";
- var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
- "elif,except,exec,finally,from,global,import,in,is,lambda," +
- "nonlocal,not,or,pass,print,raise,try,with,yield," +
- "False,True,None"];
- var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
- "def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
- "rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
- "BEGIN,END"];
- var RUST_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "as,assert,const,copy,drop," +
- "enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv," +
- "pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"];
- var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
- "function,in,local,set,then,until"];
- var ALL_KEYWORDS = [
- CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS,
- PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
- var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;
-
- // token style names. correspond to css classes
- /**
- * token style for a string literal
- * @const
- */
- var PR_STRING = 'str';
- /**
- * token style for a keyword
- * @const
- */
- var PR_KEYWORD = 'kwd';
- /**
- * token style for a comment
- * @const
- */
- var PR_COMMENT = 'com';
- /**
- * token style for a type
- * @const
- */
- var PR_TYPE = 'typ';
- /**
- * token style for a literal value. e.g. 1, null, true.
- * @const
- */
- var PR_LITERAL = 'lit';
- /**
- * token style for a punctuation string.
- * @const
- */
- var PR_PUNCTUATION = 'pun';
- /**
- * token style for plain text.
- * @const
- */
- var PR_PLAIN = 'pln';
-
- /**
- * token style for an sgml tag.
- * @const
- */
- var PR_TAG = 'tag';
- /**
- * token style for a markup declaration such as a DOCTYPE.
- * @const
- */
- var PR_DECLARATION = 'dec';
- /**
- * token style for embedded source.
- * @const
- */
- var PR_SOURCE = 'src';
- /**
- * token style for an sgml attribute name.
- * @const
- */
- var PR_ATTRIB_NAME = 'atn';
- /**
- * token style for an sgml attribute value.
- * @const
- */
- var PR_ATTRIB_VALUE = 'atv';
-
- /**
- * A class that indicates a section of markup that is not code, e.g. to allow
- * embedding of line numbers within code listings.
- * @const
- */
- var PR_NOCODE = 'nocode';
-
-
-
- /**
- * A set of tokens that can precede a regular expression literal in
- * javascript
- * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
- * has the full list, but I've removed ones that might be problematic when
- * seen in languages that don't support regular expression literals.
- *
- * Specifically, I've removed any keywords that can't precede a regexp
- * literal in a syntactically legal javascript program, and I've removed the
- * "in" keyword since it's not a keyword in many languages, and might be used
- * as a count of inches.
- *
- *
The link above does not accurately describe EcmaScript rules since
- * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
- * very well in practice.
- *
- * @private
- * @const
- */
- var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
-
- // CAVEAT: this does not properly handle the case where a regular
- // expression immediately follows another since a regular expression may
- // have flags for case-sensitivity and the like. Having regexp tokens
- // adjacent is not valid in any language I'm aware of, so I'm punting.
- // TODO: maybe style special characters inside a regexp as punctuation.
-
- /**
- * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
- * matches the union of the sets of strings matched by the input RegExp.
- * Since it matches globally, if the input strings have a start-of-input
- * anchor (/^.../), it is ignored for the purposes of unioning.
- * @param {Array.} regexs non multiline, non-global regexs.
- * @return {RegExp} a global regex.
- */
- function combinePrefixPatterns(regexs) {
- var capturedGroupIndex = 0;
-
- var needToFoldCase = false;
- var ignoreCase = false;
- for (var i = 0, n = regexs.length; i < n; ++i) {
- var regex = regexs[i];
- if (regex.ignoreCase) {
- ignoreCase = true;
- } else if (/[a-z]/i.test(regex.source.replace(
- /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
- needToFoldCase = true;
- ignoreCase = false;
- break;
- }
- }
-
- var escapeCharToCodeUnit = {
- 'b': 8,
- 't': 9,
- 'n': 0xa,
- 'v': 0xb,
- 'f': 0xc,
- 'r': 0xd
- };
-
- function decodeEscape(charsetPart) {
- var cc0 = charsetPart.charCodeAt(0);
- if (cc0 !== 92 /* \\ */) {
- return cc0;
- }
- var c1 = charsetPart.charAt(1);
- cc0 = escapeCharToCodeUnit[c1];
- if (cc0) {
- return cc0;
- } else if ('0' <= c1 && c1 <= '7') {
- return parseInt(charsetPart.substring(1), 8);
- } else if (c1 === 'u' || c1 === 'x') {
- return parseInt(charsetPart.substring(2), 16);
- } else {
- return charsetPart.charCodeAt(1);
- }
- }
-
- function encodeEscape(charCode) {
- if (charCode < 0x20) {
- return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
- }
- var ch = String.fromCharCode(charCode);
- return (ch === '\\' || ch === '-' || ch === ']' || ch === '^')
- ? "\\" + ch : ch;
- }
-
- function caseFoldCharset(charSet) {
- var charsetParts = charSet.substring(1, charSet.length - 1).match(
- new RegExp(
- '\\\\u[0-9A-Fa-f]{4}'
- + '|\\\\x[0-9A-Fa-f]{2}'
- + '|\\\\[0-3][0-7]{0,2}'
- + '|\\\\[0-7]{1,2}'
- + '|\\\\[\\s\\S]'
- + '|-'
- + '|[^-\\\\]',
- 'g'));
- var ranges = [];
- var inverse = charsetParts[0] === '^';
-
- var out = ['['];
- if (inverse) { out.push('^'); }
-
- for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
- var p = charsetParts[i];
- if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
- out.push(p);
- } else {
- var start = decodeEscape(p);
- var end;
- if (i + 2 < n && '-' === charsetParts[i + 1]) {
- end = decodeEscape(charsetParts[i + 2]);
- i += 2;
- } else {
- end = start;
- }
- ranges.push([start, end]);
- // If the range might intersect letters, then expand it.
- // This case handling is too simplistic.
- // It does not deal with non-latin case folding.
- // It works for latin source code identifiers though.
- if (!(end < 65 || start > 122)) {
- if (!(end < 65 || start > 90)) {
- ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
- }
- if (!(end < 97 || start > 122)) {
- ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
- }
- }
- }
- }
-
- // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
- // -> [[1, 12], [14, 14], [16, 17]]
- ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
- var consolidatedRanges = [];
- var lastRange = [];
- for (var i = 0; i < ranges.length; ++i) {
- var range = ranges[i];
- if (range[0] <= lastRange[1] + 1) {
- lastRange[1] = Math.max(lastRange[1], range[1]);
- } else {
- consolidatedRanges.push(lastRange = range);
- }
- }
-
- for (var i = 0; i < consolidatedRanges.length; ++i) {
- var range = consolidatedRanges[i];
- out.push(encodeEscape(range[0]));
- if (range[1] > range[0]) {
- if (range[1] + 1 > range[0]) { out.push('-'); }
- out.push(encodeEscape(range[1]));
- }
- }
- out.push(']');
- return out.join('');
- }
-
- function allowAnywhereFoldCaseAndRenumberGroups(regex) {
- // Split into character sets, escape sequences, punctuation strings
- // like ('(', '(?:', ')', '^'), and runs of characters that do not
- // include any of the above.
- var parts = regex.source.match(
- new RegExp(
- '(?:'
- + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
- + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
- + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
- + '|\\\\[0-9]+' // a back-reference or octal escape
- + '|\\\\[^ux0-9]' // other escape sequence
- + '|\\(\\?[:!=]' // start of a non-capturing group
- + '|[\\(\\)\\^]' // start/end of a group, or line start
- + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
- + ')',
- 'g'));
- var n = parts.length;
-
- // Maps captured group numbers to the number they will occupy in
- // the output or to -1 if that has not been determined, or to
- // undefined if they need not be capturing in the output.
- var capturedGroups = [];
-
- // Walk over and identify back references to build the capturedGroups
- // mapping.
- for (var i = 0, groupIndex = 0; i < n; ++i) {
- var p = parts[i];
- if (p === '(') {
- // groups are 1-indexed, so max group index is count of '('
- ++groupIndex;
- } else if ('\\' === p.charAt(0)) {
- var decimalValue = +p.substring(1);
- if (decimalValue) {
- if (decimalValue <= groupIndex) {
- capturedGroups[decimalValue] = -1;
- } else {
- // Replace with an unambiguous escape sequence so that
- // an octal escape sequence does not turn into a backreference
- // to a capturing group from an earlier regex.
- parts[i] = encodeEscape(decimalValue);
- }
- }
- }
- }
-
- // Renumber groups and reduce capturing groups to non-capturing groups
- // where possible.
- for (var i = 1; i < capturedGroups.length; ++i) {
- if (-1 === capturedGroups[i]) {
- capturedGroups[i] = ++capturedGroupIndex;
- }
- }
- for (var i = 0, groupIndex = 0; i < n; ++i) {
- var p = parts[i];
- if (p === '(') {
- ++groupIndex;
- if (!capturedGroups[groupIndex]) {
- parts[i] = '(?:';
- }
- } else if ('\\' === p.charAt(0)) {
- var decimalValue = +p.substring(1);
- if (decimalValue && decimalValue <= groupIndex) {
- parts[i] = '\\' + capturedGroups[decimalValue];
- }
- }
- }
-
- // Remove any prefix anchors so that the output will match anywhere.
- // ^^ really does mean an anchored match though.
- for (var i = 0; i < n; ++i) {
- if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
- }
-
- // Expand letters to groups to handle mixing of case-sensitive and
- // case-insensitive patterns if necessary.
- if (regex.ignoreCase && needToFoldCase) {
- for (var i = 0; i < n; ++i) {
- var p = parts[i];
- var ch0 = p.charAt(0);
- if (p.length >= 2 && ch0 === '[') {
- parts[i] = caseFoldCharset(p);
- } else if (ch0 !== '\\') {
- // TODO: handle letters in numeric escapes.
- parts[i] = p.replace(
- /[a-zA-Z]/g,
- function (ch) {
- var cc = ch.charCodeAt(0);
- return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
- });
- }
- }
- }
-
- return parts.join('');
- }
-
- var rewritten = [];
- for (var i = 0, n = regexs.length; i < n; ++i) {
- var regex = regexs[i];
- if (regex.global || regex.multiline) { throw new Error('' + regex); }
- rewritten.push(
- '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
- }
-
- return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
- }
-
- /**
- * Split markup into a string of source code and an array mapping ranges in
- * that string to the text nodes in which they appear.
- *
- *
- * The HTML DOM structure:
- *
- * (Element "p"
- * (Element "b"
- * (Text "print ")) ; #1
- * (Text "'Hello '") ; #2
- * (Element "br") ; #3
- * (Text " + 'World';")) ; #4
- *
- *
- * corresponds to the HTML
- * {@code
print 'Hello '
+ 'World';
}.
- *
- *
- * It will produce the output:
- *
- * {
- * sourceCode: "print 'Hello '\n + 'World';",
- * // 1 2
- * // 012345678901234 5678901234567
- * spans: [0, #1, 6, #2, 14, #3, 15, #4]
- * }
- *
- *
- * where #1 is a reference to the {@code "print "} text node above, and so
- * on for the other text nodes.
- *
- *
- *
- * The {@code} spans array is an array of pairs. Even elements are the start
- * indices of substrings, and odd elements are the text nodes (or BR elements)
- * that contain the text for those substrings.
- * Substrings continue until the next index or the end of the source.
- *
- *
- * @param {Node} node an HTML DOM subtree containing source-code.
- * @param {boolean} isPreformatted true if white-space in text nodes should
- * be considered significant.
- * @return {Object} source code and the text nodes in which they occur.
- */
- function extractSourceSpans(node, isPreformatted) {
- var nocode = /(?:^|\s)nocode(?:\s|$)/;
-
- var chunks = [];
- var length = 0;
- var spans = [];
- var k = 0;
-
- function walk(node) {
- var type = node.nodeType;
- if (type == 1) { // Element
- if (nocode.test(node.className)) { return; }
- for (var child = node.firstChild; child; child = child.nextSibling) {
- walk(child);
- }
- var nodeName = node.nodeName.toLowerCase();
- if ('br' === nodeName || 'li' === nodeName) {
- chunks[k] = '\n';
- spans[k << 1] = length++;
- spans[(k++ << 1) | 1] = node;
- }
- } else if (type == 3 || type == 4) { // Text
- var text = node.nodeValue;
- if (text.length) {
- if (!isPreformatted) {
- text = text.replace(/[ \t\r\n]+/g, ' ');
- } else {
- text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
- }
- // TODO: handle tabs here?
- chunks[k] = text;
- spans[k << 1] = length;
- length += text.length;
- spans[(k++ << 1) | 1] = node;
- }
- }
- }
-
- walk(node);
-
- return {
- sourceCode: chunks.join('').replace(/\n$/, ''),
- spans: spans
- };
- }
-
- /**
- * Apply the given language handler to sourceCode and add the resulting
- * decorations to out.
- * @param {number} basePos the index of sourceCode within the chunk of source
- * whose decorations are already present on out.
- */
- function appendDecorations(basePos, sourceCode, langHandler, out) {
- if (!sourceCode) { return; }
- var job = {
- sourceCode: sourceCode,
- basePos: basePos
- };
- langHandler(job);
- out.push.apply(out, job.decorations);
- }
-
- var notWs = /\S/;
-
- /**
- * Given an element, if it contains only one child element and any text nodes
- * it contains contain only space characters, return the sole child element.
- * Otherwise returns undefined.
- *
- * This is meant to return the CODE element in {@code
} when
- * there is a single child element that contains all the non-space textual
- * content, but not to return anything where there are multiple child elements
- * as in {@code ...
...
} or when there
- * is textual content.
- */
- function childContentWrapper(element) {
- var wrapper = undefined;
- for (var c = element.firstChild; c; c = c.nextSibling) {
- var type = c.nodeType;
- wrapper = (type === 1) // Element Node
- ? (wrapper ? element : c)
- : (type === 3) // Text Node
- ? (notWs.test(c.nodeValue) ? element : wrapper)
- : wrapper;
- }
- return wrapper === element ? undefined : wrapper;
- }
-
- /** Given triples of [style, pattern, context] returns a lexing function,
- * The lexing function interprets the patterns to find token boundaries and
- * returns a decoration list of the form
- * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
- * where index_n is an index into the sourceCode, and style_n is a style
- * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
- * all characters in sourceCode[index_n-1:index_n].
- *
- * The stylePatterns is a list whose elements have the form
- * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
- *
- * Style is a style constant like PR_PLAIN, or can be a string of the
- * form 'lang-FOO', where FOO is a language extension describing the
- * language of the portion of the token in $1 after pattern executes.
- * E.g., if style is 'lang-lisp', and group 1 contains the text
- * '(hello (world))', then that portion of the token will be passed to the
- * registered lisp handler for formatting.
- * The text before and after group 1 will be restyled using this decorator
- * so decorators should take care that this doesn't result in infinite
- * recursion. For example, the HTML lexer rule for SCRIPT elements looks
- * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
- * '}\n * define style rules. See the example page for examples.\n * mark the {@code } and {@code } tags in your source with\n * {@code class=prettyprint.}\n * You can also use the (html deprecated) {@code } tag, but the pretty\n * printer needs to do more substantial DOM manipulations to support that, so\n * some css styles may not be preserved.\n * \n * That's it. I wanted to keep the API as simple as possible, so there's no\n * need to specify which language the code is in, but if you wish, you can add\n * another class to the {@code } or {@code } element to specify the\n * language, as in {@code }. Any class that\n * starts with \"lang-\" followed by a file extension, specifies the file type.\n * See the \"lang-*.js\" files in this directory for code that implements\n * per-language file handlers.\n * \n * Change log:
\n * cbeust, 2006/08/22\n *
\n * Java annotations (start with \"@\") are now captured as literals (\"lit\")\n *
\n * @requires console\n */\n\n// JSLint declarations\n/*global console, document, navigator, setTimeout, window, define */\n\n/** @define {boolean} */\nvar IN_GLOBAL_SCOPE = true;\n\n/**\n * Split {@code prettyPrint} into multiple timeouts so as not to interfere with\n * UI events.\n * If set to {@code false}, {@code prettyPrint()} is synchronous.\n */\nwindow['PR_SHOULD_USE_CONTINUATION'] = true;\n\n/**\n * Pretty print a chunk of code.\n * @param {string} sourceCodeHtml The HTML to pretty print.\n * @param {string} opt_langExtension The language name to use.\n * Typically, a filename extension like 'cpp' or 'java'.\n * @param {number|boolean} opt_numberLines True to number lines,\n * or the 1-indexed number of the first line in sourceCodeHtml.\n * @return {string} code as html, but prettier\n */\nvar prettyPrintOne;\n/**\n * Find all the {@code } and {@code } tags in the DOM with\n * {@code class=prettyprint} and prettify them.\n *\n * @param {Function} opt_whenDone called when prettifying is done.\n * @param {HTMLElement|HTMLDocument} opt_root an element or document\n * containing all the elements to pretty print.\n * Defaults to {@code document.body}.\n */\nvar prettyPrint;\n\n\n(function () {\n var win = window;\n // Keyword lists for various languages.\n // We use things that coerce to strings to make them compact when minified\n // and to defeat aggressive optimizers that fold large string constants.\n var FLOW_CONTROL_KEYWORDS = [\"break,continue,do,else,for,if,return,while\"];\n var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,\"auto,case,char,const,default,\" + \n \"double,enum,extern,float,goto,inline,int,long,register,short,signed,\" +\n \"sizeof,static,struct,switch,typedef,union,unsigned,void,volatile\"];\n var COMMON_KEYWORDS = [C_KEYWORDS,\"catch,class,delete,false,import,\" +\n \"new,operator,private,protected,public,this,throw,true,try,typeof\"];\n var CPP_KEYWORDS = [COMMON_KEYWORDS,\"alignof,align_union,asm,axiom,bool,\" +\n \"concept,concept_map,const_cast,constexpr,decltype,delegate,\" +\n \"dynamic_cast,explicit,export,friend,generic,late_check,\" +\n \"mutable,namespace,nullptr,property,reinterpret_cast,static_assert,\" +\n \"static_cast,template,typeid,typename,using,virtual,where\"];\n var JAVA_KEYWORDS = [COMMON_KEYWORDS,\n \"abstract,assert,boolean,byte,extends,final,finally,implements,import,\" +\n \"instanceof,interface,null,native,package,strictfp,super,synchronized,\" +\n \"throws,transient\"];\n var CSHARP_KEYWORDS = [JAVA_KEYWORDS,\n \"as,base,by,checked,decimal,delegate,descending,dynamic,event,\" +\n \"fixed,foreach,from,group,implicit,in,internal,into,is,let,\" +\n \"lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,\" +\n \"sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,\" +\n \"var,virtual,where\"];\n var COFFEE_KEYWORDS = \"all,and,by,catch,class,else,extends,false,finally,\" +\n \"for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,\" +\n \"throw,true,try,unless,until,when,while,yes\";\n var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,\n \"debugger,eval,export,function,get,null,set,undefined,var,with,\" +\n \"Infinity,NaN\"];\n var PERL_KEYWORDS = \"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,\" +\n \"goto,if,import,last,local,my,next,no,our,print,package,redo,require,\" +\n \"sub,undef,unless,until,use,wantarray,while,BEGIN,END\";\n var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, \"and,as,assert,class,def,del,\" +\n \"elif,except,exec,finally,from,global,import,in,is,lambda,\" +\n \"nonlocal,not,or,pass,print,raise,try,with,yield,\" +\n \"False,True,None\"];\n var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, \"alias,and,begin,case,class,\" +\n \"def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,\" +\n \"rescue,retry,self,super,then,true,undef,unless,until,when,yield,\" +\n \"BEGIN,END\"];\n var RUST_KEYWORDS = [FLOW_CONTROL_KEYWORDS, \"as,assert,const,copy,drop,\" +\n \"enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,\" +\n \"pub,pure,ref,self,static,struct,true,trait,type,unsafe,use\"];\n var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, \"case,done,elif,esac,eval,fi,\" +\n \"function,in,local,set,then,until\"];\n var ALL_KEYWORDS = [\n CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS,\n PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];\n var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\\d*)\\b/;\n\n // token style names. correspond to css classes\n /**\n * token style for a string literal\n * @const\n */\n var PR_STRING = 'str';\n /**\n * token style for a keyword\n * @const\n */\n var PR_KEYWORD = 'kwd';\n /**\n * token style for a comment\n * @const\n */\n var PR_COMMENT = 'com';\n /**\n * token style for a type\n * @const\n */\n var PR_TYPE = 'typ';\n /**\n * token style for a literal value. e.g. 1, null, true.\n * @const\n */\n var PR_LITERAL = 'lit';\n /**\n * token style for a punctuation string.\n * @const\n */\n var PR_PUNCTUATION = 'pun';\n /**\n * token style for plain text.\n * @const\n */\n var PR_PLAIN = 'pln';\n\n /**\n * token style for an sgml tag.\n * @const\n */\n var PR_TAG = 'tag';\n /**\n * token style for a markup declaration such as a DOCTYPE.\n * @const\n */\n var PR_DECLARATION = 'dec';\n /**\n * token style for embedded source.\n * @const\n */\n var PR_SOURCE = 'src';\n /**\n * token style for an sgml attribute name.\n * @const\n */\n var PR_ATTRIB_NAME = 'atn';\n /**\n * token style for an sgml attribute value.\n * @const\n */\n var PR_ATTRIB_VALUE = 'atv';\n\n /**\n * A class that indicates a section of markup that is not code, e.g. to allow\n * embedding of line numbers within code listings.\n * @const\n */\n var PR_NOCODE = 'nocode';\n\n \n \n /**\n * A set of tokens that can precede a regular expression literal in\n * javascript\n * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html\n * has the full list, but I've removed ones that might be problematic when\n * seen in languages that don't support regular expression literals.\n *\n * Specifically, I've removed any keywords that can't precede a regexp\n * literal in a syntactically legal javascript program, and I've removed the\n * \"in\" keyword since it's not a keyword in many languages, and might be used\n * as a count of inches.\n *\n *
The link above does not accurately describe EcmaScript rules since\n * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works\n * very well in practice.\n *\n * @private\n * @const\n */\n var REGEXP_PRECEDER_PATTERN = '(?:^^\\\\.?|[+-]|[!=]=?=?|\\\\#|%=?|&&?=?|\\\\(|\\\\*=?|[+\\\\-]=|->|\\\\/=?|::?|<=?|>>?>?=?|,|;|\\\\?|@|\\\\[|~|{|\\\\^\\\\^?=?|\\\\|\\\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\\\s*';\n \n // CAVEAT: this does not properly handle the case where a regular\n // expression immediately follows another since a regular expression may\n // have flags for case-sensitivity and the like. Having regexp tokens\n // adjacent is not valid in any language I'm aware of, so I'm punting.\n // TODO: maybe style special characters inside a regexp as punctuation.\n\n /**\n * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally\n * matches the union of the sets of strings matched by the input RegExp.\n * Since it matches globally, if the input strings have a start-of-input\n * anchor (/^.../), it is ignored for the purposes of unioning.\n * @param {Array.} regexs non multiline, non-global regexs.\n * @return {RegExp} a global regex.\n */\n function combinePrefixPatterns(regexs) {\n var capturedGroupIndex = 0;\n \n var needToFoldCase = false;\n var ignoreCase = false;\n for (var i = 0, n = regexs.length; i < n; ++i) {\n var regex = regexs[i];\n if (regex.ignoreCase) {\n ignoreCase = true;\n } else if (/[a-z]/i.test(regex.source.replace(\n /\\\\u[0-9a-f]{4}|\\\\x[0-9a-f]{2}|\\\\[^ux]/gi, ''))) {\n needToFoldCase = true;\n ignoreCase = false;\n break;\n }\n }\n \n var escapeCharToCodeUnit = {\n 'b': 8,\n 't': 9,\n 'n': 0xa,\n 'v': 0xb,\n 'f': 0xc,\n 'r': 0xd\n };\n \n function decodeEscape(charsetPart) {\n var cc0 = charsetPart.charCodeAt(0);\n if (cc0 !== 92 /* \\\\ */) {\n return cc0;\n }\n var c1 = charsetPart.charAt(1);\n cc0 = escapeCharToCodeUnit[c1];\n if (cc0) {\n return cc0;\n } else if ('0' <= c1 && c1 <= '7') {\n return parseInt(charsetPart.substring(1), 8);\n } else if (c1 === 'u' || c1 === 'x') {\n return parseInt(charsetPart.substring(2), 16);\n } else {\n return charsetPart.charCodeAt(1);\n }\n }\n \n function encodeEscape(charCode) {\n if (charCode < 0x20) {\n return (charCode < 0x10 ? '\\\\x0' : '\\\\x') + charCode.toString(16);\n }\n var ch = String.fromCharCode(charCode);\n return (ch === '\\\\' || ch === '-' || ch === ']' || ch === '^')\n ? \"\\\\\" + ch : ch;\n }\n \n function caseFoldCharset(charSet) {\n var charsetParts = charSet.substring(1, charSet.length - 1).match(\n new RegExp(\n '\\\\\\\\u[0-9A-Fa-f]{4}'\n + '|\\\\\\\\x[0-9A-Fa-f]{2}'\n + '|\\\\\\\\[0-3][0-7]{0,2}'\n + '|\\\\\\\\[0-7]{1,2}'\n + '|\\\\\\\\[\\\\s\\\\S]'\n + '|-'\n + '|[^-\\\\\\\\]',\n 'g'));\n var ranges = [];\n var inverse = charsetParts[0] === '^';\n \n var out = ['['];\n if (inverse) { out.push('^'); }\n \n for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {\n var p = charsetParts[i];\n if (/\\\\[bdsw]/i.test(p)) { // Don't muck with named groups.\n out.push(p);\n } else {\n var start = decodeEscape(p);\n var end;\n if (i + 2 < n && '-' === charsetParts[i + 1]) {\n end = decodeEscape(charsetParts[i + 2]);\n i += 2;\n } else {\n end = start;\n }\n ranges.push([start, end]);\n // If the range might intersect letters, then expand it.\n // This case handling is too simplistic.\n // It does not deal with non-latin case folding.\n // It works for latin source code identifiers though.\n if (!(end < 65 || start > 122)) {\n if (!(end < 65 || start > 90)) {\n ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);\n }\n if (!(end < 97 || start > 122)) {\n ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);\n }\n }\n }\n }\n \n // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]\n // -> [[1, 12], [14, 14], [16, 17]]\n ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });\n var consolidatedRanges = [];\n var lastRange = [];\n for (var i = 0; i < ranges.length; ++i) {\n var range = ranges[i];\n if (range[0] <= lastRange[1] + 1) {\n lastRange[1] = Math.max(lastRange[1], range[1]);\n } else {\n consolidatedRanges.push(lastRange = range);\n }\n }\n \n for (var i = 0; i < consolidatedRanges.length; ++i) {\n var range = consolidatedRanges[i];\n out.push(encodeEscape(range[0]));\n if (range[1] > range[0]) {\n if (range[1] + 1 > range[0]) { out.push('-'); }\n out.push(encodeEscape(range[1]));\n }\n }\n out.push(']');\n return out.join('');\n }\n \n function allowAnywhereFoldCaseAndRenumberGroups(regex) {\n // Split into character sets, escape sequences, punctuation strings\n // like ('(', '(?:', ')', '^'), and runs of characters that do not\n // include any of the above.\n var parts = regex.source.match(\n new RegExp(\n '(?:'\n + '\\\\[(?:[^\\\\x5C\\\\x5D]|\\\\\\\\[\\\\s\\\\S])*\\\\]' // a character set\n + '|\\\\\\\\u[A-Fa-f0-9]{4}' // a unicode escape\n + '|\\\\\\\\x[A-Fa-f0-9]{2}' // a hex escape\n + '|\\\\\\\\[0-9]+' // a back-reference or octal escape\n + '|\\\\\\\\[^ux0-9]' // other escape sequence\n + '|\\\\(\\\\?[:!=]' // start of a non-capturing group\n + '|[\\\\(\\\\)\\\\^]' // start/end of a group, or line start\n + '|[^\\\\x5B\\\\x5C\\\\(\\\\)\\\\^]+' // run of other characters\n + ')',\n 'g'));\n var n = parts.length;\n \n // Maps captured group numbers to the number they will occupy in\n // the output or to -1 if that has not been determined, or to\n // undefined if they need not be capturing in the output.\n var capturedGroups = [];\n \n // Walk over and identify back references to build the capturedGroups\n // mapping.\n for (var i = 0, groupIndex = 0; i < n; ++i) {\n var p = parts[i];\n if (p === '(') {\n // groups are 1-indexed, so max group index is count of '('\n ++groupIndex;\n } else if ('\\\\' === p.charAt(0)) {\n var decimalValue = +p.substring(1);\n if (decimalValue) {\n if (decimalValue <= groupIndex) {\n capturedGroups[decimalValue] = -1;\n } else {\n // Replace with an unambiguous escape sequence so that\n // an octal escape sequence does not turn into a backreference\n // to a capturing group from an earlier regex.\n parts[i] = encodeEscape(decimalValue);\n }\n }\n }\n }\n \n // Renumber groups and reduce capturing groups to non-capturing groups\n // where possible.\n for (var i = 1; i < capturedGroups.length; ++i) {\n if (-1 === capturedGroups[i]) {\n capturedGroups[i] = ++capturedGroupIndex;\n }\n }\n for (var i = 0, groupIndex = 0; i < n; ++i) {\n var p = parts[i];\n if (p === '(') {\n ++groupIndex;\n if (!capturedGroups[groupIndex]) {\n parts[i] = '(?:';\n }\n } else if ('\\\\' === p.charAt(0)) {\n var decimalValue = +p.substring(1);\n if (decimalValue && decimalValue <= groupIndex) {\n parts[i] = '\\\\' + capturedGroups[decimalValue];\n }\n }\n }\n \n // Remove any prefix anchors so that the output will match anywhere.\n // ^^ really does mean an anchored match though.\n for (var i = 0; i < n; ++i) {\n if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }\n }\n \n // Expand letters to groups to handle mixing of case-sensitive and\n // case-insensitive patterns if necessary.\n if (regex.ignoreCase && needToFoldCase) {\n for (var i = 0; i < n; ++i) {\n var p = parts[i];\n var ch0 = p.charAt(0);\n if (p.length >= 2 && ch0 === '[') {\n parts[i] = caseFoldCharset(p);\n } else if (ch0 !== '\\\\') {\n // TODO: handle letters in numeric escapes.\n parts[i] = p.replace(\n /[a-zA-Z]/g,\n function (ch) {\n var cc = ch.charCodeAt(0);\n return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';\n });\n }\n }\n }\n \n return parts.join('');\n }\n \n var rewritten = [];\n for (var i = 0, n = regexs.length; i < n; ++i) {\n var regex = regexs[i];\n if (regex.global || regex.multiline) { throw new Error('' + regex); }\n rewritten.push(\n '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');\n }\n \n return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');\n }\n\n /**\n * Split markup into a string of source code and an array mapping ranges in\n * that string to the text nodes in which they appear.\n *\n * \n * The HTML DOM structure:
\n * \n * (Element \"p\"\n * (Element \"b\"\n * (Text \"print \")) ; #1\n * (Text \"'Hello '\") ; #2\n * (Element \"br\") ; #3\n * (Text \" + 'World';\")) ; #4\n *
\n * \n * corresponds to the HTML\n * {@code
print 'Hello '
+ 'World';
}.
\n *\n * \n * It will produce the output:
\n * \n * {\n * sourceCode: \"print 'Hello '\\n + 'World';\",\n * // 1 2\n * // 012345678901234 5678901234567\n * spans: [0, #1, 6, #2, 14, #3, 15, #4]\n * }\n *
\n * \n * where #1 is a reference to the {@code \"print \"} text node above, and so\n * on for the other text nodes.\n *
\n *\n * \n * The {@code} spans array is an array of pairs. Even elements are the start\n * indices of substrings, and odd elements are the text nodes (or BR elements)\n * that contain the text for those substrings.\n * Substrings continue until the next index or the end of the source.\n *
\n *\n * @param {Node} node an HTML DOM subtree containing source-code.\n * @param {boolean} isPreformatted true if white-space in text nodes should\n * be considered significant.\n * @return {Object} source code and the text nodes in which they occur.\n */\n function extractSourceSpans(node, isPreformatted) {\n var nocode = /(?:^|\\s)nocode(?:\\s|$)/;\n \n var chunks = [];\n var length = 0;\n var spans = [];\n var k = 0;\n \n function walk(node) {\n var type = node.nodeType;\n if (type == 1) { // Element\n if (nocode.test(node.className)) { return; }\n for (var child = node.firstChild; child; child = child.nextSibling) {\n walk(child);\n }\n var nodeName = node.nodeName.toLowerCase();\n if ('br' === nodeName || 'li' === nodeName) {\n chunks[k] = '\\n';\n spans[k << 1] = length++;\n spans[(k++ << 1) | 1] = node;\n }\n } else if (type == 3 || type == 4) { // Text\n var text = node.nodeValue;\n if (text.length) {\n if (!isPreformatted) {\n text = text.replace(/[ \\t\\r\\n]+/g, ' ');\n } else {\n text = text.replace(/\\r\\n?/g, '\\n'); // Normalize newlines.\n }\n // TODO: handle tabs here?\n chunks[k] = text;\n spans[k << 1] = length;\n length += text.length;\n spans[(k++ << 1) | 1] = node;\n }\n }\n }\n \n walk(node);\n \n return {\n sourceCode: chunks.join('').replace(/\\n$/, ''),\n spans: spans\n };\n }\n\n /**\n * Apply the given language handler to sourceCode and add the resulting\n * decorations to out.\n * @param {number} basePos the index of sourceCode within the chunk of source\n * whose decorations are already present on out.\n */\n function appendDecorations(basePos, sourceCode, langHandler, out) {\n if (!sourceCode) { return; }\n var job = {\n sourceCode: sourceCode,\n basePos: basePos\n };\n langHandler(job);\n out.push.apply(out, job.decorations);\n }\n\n var notWs = /\\S/;\n\n /**\n * Given an element, if it contains only one child element and any text nodes\n * it contains contain only space characters, return the sole child element.\n * Otherwise returns undefined.\n * \n * This is meant to return the CODE element in {@code
} when\n * there is a single child element that contains all the non-space textual\n * content, but not to return anything where there are multiple child elements\n * as in {@code ...
...
} or when there\n * is textual content.\n */\n function childContentWrapper(element) {\n var wrapper = undefined;\n for (var c = element.firstChild; c; c = c.nextSibling) {\n var type = c.nodeType;\n wrapper = (type === 1) // Element Node\n ? (wrapper ? element : c)\n : (type === 3) // Text Node\n ? (notWs.test(c.nodeValue) ? element : wrapper)\n : wrapper;\n }\n return wrapper === element ? undefined : wrapper;\n }\n\n /** Given triples of [style, pattern, context] returns a lexing function,\n * The lexing function interprets the patterns to find token boundaries and\n * returns a decoration list of the form\n * [index_0, style_0, index_1, style_1, ..., index_n, style_n]\n * where index_n is an index into the sourceCode, and style_n is a style\n * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to\n * all characters in sourceCode[index_n-1:index_n].\n *\n * The stylePatterns is a list whose elements have the form\n * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].\n *\n * Style is a style constant like PR_PLAIN, or can be a string of the\n * form 'lang-FOO', where FOO is a language extension describing the\n * language of the portion of the token in $1 after pattern executes.\n * E.g., if style is 'lang-lisp', and group 1 contains the text\n * '(hello (world))', then that portion of the token will be passed to the\n * registered lisp handler for formatting.\n * The text before and after group 1 will be restyled using this decorator\n * so decorators should take care that this doesn't result in infinite\n * recursion. For example, the HTML lexer rule for SCRIPT elements looks\n * something like ['lang-js', /<[s]cript>(.+?)<\\/script>/]. This may match\n * '
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-