diff --git a/client/constants.js b/client/constants.js index cabaa570..ce5960c3 100644 --- a/client/constants.js +++ b/client/constants.js @@ -4,6 +4,9 @@ export const TOGGLE_SKETCH = 'TOGGLE_SKETCH'; export const START_SKETCH = 'START_SKETCH'; export const STOP_SKETCH = 'STOP_SKETCH'; +export const START_TEXT_OUTPUT = 'START_TEXT_OUTPUT'; +export const STOP_TEXT_OUTPUT = 'STOP_TEXT_OUTPUT'; + export const OPEN_PREFERENCES = 'OPEN_PREFERENCES'; export const CLOSE_PREFERENCES = 'CLOSE_PREFERENCES'; export const SET_FONT_SIZE = 'SET_FONT_SIZE'; @@ -61,6 +64,7 @@ export const HIDE_EDIT_FILE_NAME = 'HIDE_EDIT_FILE_NAME'; export const SET_AUTOSAVE = 'SET_AUTOSAVE'; export const SET_LINT_WARNING = 'SET_LINT_WARNING'; export const SET_PREFERENCES = 'SET_PREFERENCES'; +export const SET_TEXT_OUTPUT = 'SET_TEXT_OUTPUT'; // eventually, handle errors more specifically and better export const ERROR = 'ERROR'; diff --git a/client/modules/IDE/actions/ide.js b/client/modules/IDE/actions/ide.js index 1b8b18d8..4cb32913 100644 --- a/client/modules/IDE/actions/ide.js +++ b/client/modules/IDE/actions/ide.js @@ -18,6 +18,18 @@ export function stopSketch() { }; } +export function startTextOutput() { + return { + type: ActionTypes.START_TEXT_OUTPUT + }; +} + +export function stopTextOutput() { + return { + type: ActionTypes.STOP_TEXT_OUTPUT + }; +} + export function setSelectedFile(fileId) { return { type: ActionTypes.SET_SELECTED_FILE, diff --git a/client/modules/IDE/actions/preferences.js b/client/modules/IDE/actions/preferences.js index 82ea107a..f2270905 100644 --- a/client/modules/IDE/actions/preferences.js +++ b/client/modules/IDE/actions/preferences.js @@ -118,3 +118,21 @@ export function setLintWarning(value) { } }; } + +export function setTextOutput(value) { + return (dispatch, getState) => { + dispatch({ + type: ActionTypes.SET_TEXT_OUTPUT, + value + }); + const state = getState(); + if (state.user.authenticated) { + const formParams = { + preferences: { + textOutput: value + } + }; + updatePreferences(formParams, dispatch); + } + }; +} diff --git a/client/modules/IDE/components/Editor.js b/client/modules/IDE/components/Editor.js index d4b6c72e..34658b6f 100644 --- a/client/modules/IDE/components/Editor.js +++ b/client/modules/IDE/components/Editor.js @@ -89,8 +89,6 @@ class Editor extends React.Component { this._cm.setOption('mode', 'htmlmixed'); } } - - console.log('componentDidUpdate in editor'); } componentWillUnmount() { @@ -101,14 +99,14 @@ class Editor extends React.Component { render() { return ( -
-
+
+
-
+ ); } } diff --git a/client/modules/IDE/components/Preferences.js b/client/modules/IDE/components/Preferences.js index 59f13c0a..a705a098 100644 --- a/client/modules/IDE/components/Preferences.js +++ b/client/modules/IDE/components/Preferences.js @@ -62,6 +62,14 @@ class Preferences extends React.Component { preference__option: true, 'preference__option--selected': !this.props.lintWarning }); + let textOutputOnClass = classNames({ + preference__option: true, + 'preference__option--selected': this.props.textOutput + }); + let textOutputOffClass = classNames({ + preference__option: true, + 'preference__option--selected': !this.props.textOutput + }); return (
@@ -169,6 +177,22 @@ class Preferences extends React.Component { >Off
+
+

Accessible Text-based Canvas

+
Used with screen reader
+
+ + +
+
); } @@ -186,6 +210,8 @@ Preferences.propTypes = { setFontSize: PropTypes.func.isRequired, autosave: PropTypes.bool.isRequired, setAutosave: PropTypes.func.isRequired, + textOutput: PropTypes.bool.isRequired, + setTextOutput: PropTypes.func.isRequired, lintWarning: PropTypes.bool.isRequired, setLintWarning: PropTypes.func.isRequired }; diff --git a/client/modules/IDE/components/PreviewFrame.js b/client/modules/IDE/components/PreviewFrame.js index a5dce7b3..3abd5455 100644 --- a/client/modules/IDE/components/PreviewFrame.js +++ b/client/modules/IDE/components/PreviewFrame.js @@ -134,12 +134,18 @@ class PreviewFrame extends React.Component { htmlFile = htmlFile.replace(fileRegex, ``); }); - // const htmlHead = htmlFile.match(/(?:)([\s\S]*?)(?:<\/head>)/gmi); - // const headRegex = new RegExp('head', 'i'); - // let htmlHeadContents = htmlHead[0].split(headRegex)[1]; - // htmlHeadContents = htmlHeadContents.slice(1, htmlHeadContents.length - 2); - // htmlHeadContents += '\n'; - // htmlFile = htmlFile.replace(/(?:)([\s\S]*?)(?:<\/head>)/gmi, `\n${htmlHeadContents}\n`); + if (this.props.textOutput || this.props.isTextOutputPlaying) { + const htmlHead = htmlFile.match(/(?:)([\s\S]*?)(?:<\/head>)/gmi); + const headRegex = new RegExp('head', 'i'); + let htmlHeadContents = htmlHead[0].split(headRegex)[1]; + htmlHeadContents = htmlHeadContents.slice(1, htmlHeadContents.length - 2); + htmlHeadContents += '\n'; + htmlHeadContents += '\n'; + htmlHeadContents += '\n'; + htmlHeadContents += ''; + htmlFile = htmlFile.replace(/(?:)([\s\S]*?)(?:<\/head>)/gmi, `\n${htmlHeadContents}\n`); + } + htmlFile += hijackConsoleScript; return htmlFile; @@ -181,6 +187,8 @@ class PreviewFrame extends React.Component { PreviewFrame.propTypes = { isPlaying: PropTypes.bool.isRequired, + isTextOutputPlaying: PropTypes.bool.isRequired, + textOutput: PropTypes.bool.isRequired, head: PropTypes.object.isRequired, content: PropTypes.string, htmlFile: PropTypes.shape({ diff --git a/client/modules/IDE/components/TextOutput.js b/client/modules/IDE/components/TextOutput.js new file mode 100644 index 00000000..949215d6 --- /dev/null +++ b/client/modules/IDE/components/TextOutput.js @@ -0,0 +1,37 @@ +import React from 'react'; + +class TextOutput extends React.Component { + componentDidMount() { + + } + render() { + return ( +
+
+
+

+

+ +
+
+ ); + } +} + +export default TextOutput; diff --git a/client/modules/IDE/components/Toolbar.js b/client/modules/IDE/components/Toolbar.js index 4ec26975..79226d70 100644 --- a/client/modules/IDE/components/Toolbar.js +++ b/client/modules/IDE/components/Toolbar.js @@ -54,8 +54,18 @@ class Toolbar extends React.Component { - - +
@@ -106,6 +116,8 @@ Toolbar.propTypes = { preferencesIsVisible: PropTypes.bool.isRequired, startSketch: PropTypes.func.isRequired, stopSketch: PropTypes.func.isRequired, + startTextOutput: PropTypes.func.isRequired, + stopTextOutput: PropTypes.func.isRequired, setProjectName: PropTypes.func.isRequired, openPreferences: PropTypes.func.isRequired, owner: PropTypes.shape({ diff --git a/client/modules/IDE/pages/IDEView.js b/client/modules/IDE/pages/IDEView.js index 1a1c3a02..996d9fa0 100644 --- a/client/modules/IDE/pages/IDEView.js +++ b/client/modules/IDE/pages/IDEView.js @@ -3,6 +3,7 @@ import Editor from '../components/Editor'; import Sidebar from '../components/Sidebar'; import PreviewFrame from '../components/PreviewFrame'; import Toolbar from '../components/Toolbar'; +import TextOutput from '../components/TextOutput'; import Preferences from '../components/Preferences'; import NewFileModal from '../components/NewFileModal'; import Nav from '../../../components/Nav'; @@ -121,11 +122,15 @@ class IDEView extends React.Component { isPlaying={this.props.ide.isPlaying} startSketch={this.props.startSketch} stopSketch={this.props.stopSketch} + startTextOutput={this.props.startTextOutput} + stopTextOutput={this.props.stopTextOutput} + projectName={this.props.project.name} setProjectName={this.props.setProjectName} showEditProjectName={this.props.showEditProjectName} hideEditProjectName={this.props.hideEditProjectName} openPreferences={this.props.openPreferences} preferencesIsVisible={this.props.ide.preferencesIsVisible} + setTextOutput={this.props.setTextOutput} owner={this.props.project.owner} project={this.props.project} /> @@ -143,6 +148,8 @@ class IDEView extends React.Component { setAutosave={this.props.setAutosave} lintWarning={this.props.preferences.lintWarning} setLintWarning={this.props.setLintWarning} + textOutput={this.props.preferences.textOutput} + setTextOutput={this.props.setTextOutput} />
+
+ {(() => { + if ((this.props.preferences.textOutput && this.props.ide.isPlaying) || this.props.ide.isTextOutputPlaying) { + return ( + + ); + } + return ''; + })()} +
} isPlaying={this.props.ide.isPlaying} + isTextOutputPlaying={this.props.ide.isTextOutputPlaying} + textOutput={this.props.preferences.textOutput} dispatchConsoleEvent={this.props.dispatchConsoleEvent} />
@@ -267,6 +286,7 @@ IDEView.propTypes = { saveProject: PropTypes.func.isRequired, ide: PropTypes.shape({ isPlaying: PropTypes.bool.isRequired, + isTextOutputPlaying: PropTypes.bool.isRequired, consoleEvent: PropTypes.object, modalIsVisible: PropTypes.bool.isRequired, sidebarIsExpanded: PropTypes.bool.isRequired, @@ -275,6 +295,8 @@ IDEView.propTypes = { }).isRequired, startSketch: PropTypes.func.isRequired, stopSketch: PropTypes.func.isRequired, + startTextOutput: PropTypes.func.isRequired, + stopTextOutput: PropTypes.func.isRequired, project: PropTypes.shape({ id: PropTypes.string, name: PropTypes.string.isRequired, @@ -297,7 +319,8 @@ IDEView.propTypes = { indentationAmount: PropTypes.number.isRequired, isTabIndent: PropTypes.bool.isRequired, autosave: PropTypes.bool.isRequired, - lintWarning: PropTypes.bool.isRequired + lintWarning: PropTypes.bool.isRequired, + textOutput: PropTypes.bool.isRequired }).isRequired, closePreferences: PropTypes.func.isRequired, setFontSize: PropTypes.func.isRequired, @@ -306,6 +329,7 @@ IDEView.propTypes = { indentWithSpace: PropTypes.func.isRequired, setAutosave: PropTypes.func.isRequired, setLintWarning: PropTypes.func.isRequired, + setTextOutput: PropTypes.func.isRequired, files: PropTypes.array.isRequired, updateFileContent: PropTypes.func.isRequired, selectedFile: PropTypes.shape({ diff --git a/client/modules/IDE/reducers/ide.js b/client/modules/IDE/reducers/ide.js index 03a4dc4b..a73fddc0 100644 --- a/client/modules/IDE/reducers/ide.js +++ b/client/modules/IDE/reducers/ide.js @@ -2,6 +2,7 @@ import * as ActionTypes from '../../../constants'; const initialState = { isPlaying: false, + isTextOutputPlaying: false, selectedFile: '1', consoleEvent: { method: undefined, @@ -21,6 +22,10 @@ const ide = (state = initialState, action) => { return Object.assign({}, state, { isPlaying: true }); case ActionTypes.STOP_SKETCH: return Object.assign({}, state, { isPlaying: false }); + case ActionTypes.START_TEXT_OUTPUT: + return Object.assign({}, state, { isTextOutputPlaying: true }); + case ActionTypes.STOP_TEXT_OUTPUT: + return Object.assign({}, state, { isTextOutputPlaying: false }); case ActionTypes.SET_SELECTED_FILE: case ActionTypes.SET_PROJECT: case ActionTypes.NEW_PROJECT: diff --git a/client/modules/IDE/reducers/preferences.js b/client/modules/IDE/reducers/preferences.js index 5d1d65bf..252b51dc 100644 --- a/client/modules/IDE/reducers/preferences.js +++ b/client/modules/IDE/reducers/preferences.js @@ -5,7 +5,8 @@ const initialState = { indentationAmount: 2, isTabIndent: true, autosave: true, - lintWarning: false + lintWarning: false, + textOutput: false }; const preferences = (state = initialState, action) => { @@ -26,6 +27,8 @@ const preferences = (state = initialState, action) => { return Object.assign({}, state, { autosave: action.value }); case ActionTypes.SET_LINT_WARNING: return Object.assign({}, state, { lintWarning: action.value }); + case ActionTypes.SET_TEXT_OUTPUT: + return Object.assign({}, state, { textOutput: action.value }); case ActionTypes.SET_PREFERENCES: return action.preferences; default: diff --git a/client/styles/components/_preferences.scss b/client/styles/components/_preferences.scss index 1152a26a..06ca4b70 100644 --- a/client/styles/components/_preferences.scss +++ b/client/styles/components/_preferences.scss @@ -46,6 +46,13 @@ margin-bottom: #{10 / $base-font-size}rem; } +.preference__subtitle { + width: 100%; + margin-bottom: #{10 / $base-font-size}rem; + margin-top: 0; + color: $light-inactive-text-color; +} + .preference__value { border: 2px solid $light-button-border-color; text-align: center; diff --git a/client/styles/components/_toolbar.scss b/client/styles/components/_toolbar.scss index 77ba6109..00f9e33d 100644 --- a/client/styles/components/_toolbar.scss +++ b/client/styles/components/_toolbar.scss @@ -9,6 +9,10 @@ } } +.toolbar__play-sketch-button { + @extend %hidden-element; +} + .toolbar__stop-button { @extend %toolbar-button; &--selected { diff --git a/client/styles/layout/_ide.scss b/client/styles/layout/_ide.scss index 29041785..7312f78d 100644 --- a/client/styles/layout/_ide.scss +++ b/client/styles/layout/_ide.scss @@ -33,6 +33,10 @@ @extend %hidden-element; } +.text-output { + @extend %hidden-element; +} + .preview-frame { height: 100%; width: 100%; diff --git a/server/models/user.js b/server/models/user.js index 0c8f385c..b9fa4987 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -14,7 +14,8 @@ const userSchema = new Schema({ indentationAmount: { type: Number, default: 2 }, isTabIndent: { type: Boolean, default: false }, autosave: { type: Boolean, default: true }, - lintWarning: { type: Boolean, default: false } + lintWarning: { type: Boolean, default: false }, + textOutput: { type: Boolean, default: false } } }, { timestamps: true }); diff --git a/static/data.min.json b/static/data.min.json new file mode 100644 index 00000000..d03114d7 --- /dev/null +++ b/static/data.min.json @@ -0,0 +1 @@ +{"project":{},"files":{"src/color/color_conversion.js":{"name":"src/color/color_conversion.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/color/creating_reading.js":{"name":"src/color/creating_reading.js","modules":{"Creating & Reading":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/color/p5.Color.js":{"name":"src/color/p5.Color.js","modules":{},"classes":{"p5.Color":1},"fors":{"p5":1},"namespaces":{}},"src/color/setting.js":{"name":"src/color/setting.js","modules":{"Setting":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/2d_primitives.js":{"name":"src/core/2d_primitives.js","modules":{"2D Primitives":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/attributes.js":{"name":"src/core/attributes.js","modules":{"Attributes":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/canvas.js":{"name":"src/core/canvas.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/core/constants.js":{"name":"src/core/constants.js","modules":{"Constants":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/core.js":{"name":"src/core/core.js","modules":{"Structure":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/curves.js":{"name":"src/core/curves.js","modules":{"Curves":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/environment.js":{"name":"src/core/environment.js","modules":{"Environment":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/error_helpers.js":{"name":"src/core/error_helpers.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/p5.Element.js":{"name":"src/core/p5.Element.js","modules":{"DOM":1},"classes":{"p5.Element":1},"fors":{"p5.Element":1},"namespaces":{}},"src/core/p5.Graphics.js":{"name":"src/core/p5.Graphics.js","modules":{"Rendering":1},"classes":{"p5.Graphics":1},"fors":{"p5":1},"namespaces":{}},"src/core/p5.Renderer.js":{"name":"src/core/p5.Renderer.js","modules":{},"classes":{"p5.Renderer":1},"fors":{"p5":1},"namespaces":{}},"src/core/p5.Renderer2D.js":{"name":"src/core/p5.Renderer2D.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/core/rendering.js":{"name":"src/core/rendering.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/shim.js":{"name":"src/core/shim.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/core/structure.js":{"name":"src/core/structure.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/transform.js":{"name":"src/core/transform.js","modules":{"Transform":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/core/vertex.js":{"name":"src/core/vertex.js","modules":{"Vertex":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/events/acceleration.js":{"name":"src/events/acceleration.js","modules":{"Acceleration":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/events/keyboard.js":{"name":"src/events/keyboard.js","modules":{"Keyboard":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/events/mouse.js":{"name":"src/events/mouse.js","modules":{"Mouse":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/events/touch.js":{"name":"src/events/touch.js","modules":{"Touch":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/image/filters.js":{"name":"src/image/filters.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/image/image.js":{"name":"src/image/image.js","modules":{"Image":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/image/loading_displaying.js":{"name":"src/image/loading_displaying.js","modules":{"Loading & Displaying":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/image/p5.Image.js":{"name":"src/image/p5.Image.js","modules":{},"classes":{"p5.Image":1},"fors":{},"namespaces":{}},"src/image/pixels.js":{"name":"src/image/pixels.js","modules":{"Pixels":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/io/files.js":{"name":"src/io/files.js","modules":{"Input":1,"Output":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/io/p5.Table.js":{"name":"src/io/p5.Table.js","modules":{"Table":1},"classes":{"p5.Table":1},"fors":{},"namespaces":{}},"src/io/p5.TableRow.js":{"name":"src/io/p5.TableRow.js","modules":{},"classes":{"p5.TableRow":1},"fors":{},"namespaces":{}},"src/io/p5.XML.js":{"name":"src/io/p5.XML.js","modules":{"XML":1},"classes":{"p5.XML":1},"fors":{},"namespaces":{}},"src/math/calculation.js":{"name":"src/math/calculation.js","modules":{"Calculation":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/math/math.js":{"name":"src/math/math.js","modules":{"Math":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/math/noise.js":{"name":"src/math/noise.js","modules":{"Noise":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/math/p5.Vector.js":{"name":"src/math/p5.Vector.js","modules":{},"classes":{"p5.Vector":1},"fors":{},"namespaces":{}},"src/math/random.js":{"name":"src/math/random.js","modules":{"Random":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/math/trigonometry.js":{"name":"src/math/trigonometry.js","modules":{"Trigonometry":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/typography/attributes.js":{"name":"src/typography/attributes.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/typography/loading_displaying.js":{"name":"src/typography/loading_displaying.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/typography/p5.Font.js":{"name":"src/typography/p5.Font.js","modules":{"Font":1},"classes":{"p5.Font":1},"fors":{},"namespaces":{}},"src/utilities/array_functions.js":{"name":"src/utilities/array_functions.js","modules":{"Array Functions":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/utilities/conversion.js":{"name":"src/utilities/conversion.js","modules":{"Conversion":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/utilities/string_functions.js":{"name":"src/utilities/string_functions.js","modules":{"String Functions":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/utilities/time_date.js":{"name":"src/utilities/time_date.js","modules":{"Time & Date":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/webgl/camera.js":{"name":"src/webgl/camera.js","modules":{"Camera":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/webgl/light.js":{"name":"src/webgl/light.js","modules":{"Lights":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/webgl/loading.js":{"name":"src/webgl/loading.js","modules":{"3D Models":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/webgl/material.js":{"name":"src/webgl/material.js","modules":{"Material":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/webgl/p5.Geometry.js":{"name":"src/webgl/p5.Geometry.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/webgl/p5.Matrix.js":{"name":"src/webgl/p5.Matrix.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/webgl/p5.RendererGL.Immediate.js":{"name":"src/webgl/p5.RendererGL.Immediate.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/webgl/p5.RendererGL.Retained.js":{"name":"src/webgl/p5.RendererGL.Retained.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src/webgl/p5.RendererGL.js":{"name":"src/webgl/p5.RendererGL.js","modules":{},"classes":{"p5.RendererGL":1},"fors":{},"namespaces":{}},"src/webgl/primitives.js":{"name":"src/webgl/primitives.js","modules":{"3D Primitives":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src/app.js":{"name":"src/app.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"lib/addons/p5.dom.js":{"name":"lib/addons/p5.dom.js","modules":{"p5.dom":1},"classes":{"p5.MediaElement":1,"p5.File":1},"fors":{"p5.dom":1,"p5.Element":1},"namespaces":{}},"lib/addons/p5.sound.js":{"name":"lib/addons/p5.sound.js","modules":{"p5.sound":1},"classes":{"p5.SoundFile":1,"p5.Amplitude":1,"p5.FFT":1,"p5.Signal":1,"p5.Oscillator":1,"p5.Env":1,"p5.Pulse":1,"p5.Noise":1,"p5.AudioIn":1,"p5.Filter":1,"p5.Delay":1,"p5.Reverb":1,"p5.Convolver":1,"p5.Phrase":1,"p5.Part":1,"p5.Score":1,"p5.SoundRecorder":1,"p5.PeakDetect":1,"p5.Gain":1},"fors":{"p5.sound":1},"namespaces":{}}},"modules":{"Color":{"name":"Color","submodules":{"Creating & Reading":1,"Setting":1},"classes":{"p5.Color":1},"fors":{"p5":1},"namespaces":{},"file":"src/color/p5.Color.js","line":14},"Creating & Reading":{"name":"Creating & Reading","submodules":{},"classes":{"p5.Color":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Color","namespace":"","file":"src/color/p5.Color.js","line":14,"requires":["core","constants"],"description":"

We define colors to be immutable objects. Each color stores the color mode\nand level maxes that applied at the time of its construction. These are\nused to interpret the input arguments and to format the output e.g. when\nsaturation() is requested.

\n

Internally we store an array representing the ideal RGBA values in floating\npoint form, normalized from 0 to 1. From this we calculate the closest\nscreen color (RGBA levels from 0 to 255) and expose this to the renderer.

\n

We also cache normalized, floating point components of the color in various\nrepresentations as they are calculated. This is done to prevent repeating a\nconversion that has already been performed.

\n"},"Setting":{"name":"Setting","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Color","namespace":"","file":"src/color/setting.js","line":1,"requires":["core","constants"]},"Shape":{"name":"Shape","submodules":{"2D Primitives":1,"Curves":1,"Vertex":1,"3D Models":1,"3D Primitives":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"2D Primitives":{"name":"2D Primitives","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src/core/2d_primitives.js","line":1,"requires":["core","constants"]},"Attributes":{"name":"Attributes","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Typography","namespace":"","file":"src/core/attributes.js","line":1,"requires":["core","constants"]},"Constants":{"name":"Constants","submodules":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Constants","file":"src/core/constants.js","line":1},"Structure":{"name":"Structure","submodules":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Structure","file":"src/core/core.js","line":1,"requires":["constants"]},"Curves":{"name":"Curves","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src/core/curves.js","line":1,"requires":["core"]},"Environment":{"name":"Environment","submodules":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Environment","file":"src/core/environment.js","line":1,"requires":["core","constants"]},"DOM":{"name":"DOM","submodules":{},"classes":{"p5.Element":1},"fors":{"p5.Element":1},"namespaces":{},"module":"DOM","file":"src/core/p5.Element.js","line":9,"description":"

Base class for all elements added to a sketch, including canvas,\ngraphics buffers, and other HTML elements. Methods in blue are\nincluded in the core functionality, methods in brown are added\nwith the p5.dom\nlibrary.\nIt is not called directly, but p5.Element\nobjects are created by calling createCanvas, createGraphics,\nor in the p5.dom library, createDiv, createImg, createInput, etc.

\n"},"Rendering":{"name":"Rendering","submodules":{},"classes":{"p5.Graphics":1,"p5.Renderer":1},"fors":{"p5":1},"namespaces":{},"module":"Rendering","file":"src/core/p5.Renderer.js","line":10,"description":"

Thin wrapper around a renderer, to be used for creating a\ngraphics buffer 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. The fields and methods for this class are\nextensive, but mirror the normal drawing API for p5.

\n"},"Transform":{"name":"Transform","submodules":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Transform","file":"src/core/transform.js","line":1,"requires":["core","constants"]},"Vertex":{"name":"Vertex","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src/core/vertex.js","line":1,"requires":["core","constants"]},"Events":{"name":"Events","submodules":{"Acceleration":1,"Keyboard":1,"Mouse":1,"Touch":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"Acceleration":{"name":"Acceleration","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Events","namespace":"","file":"src/events/acceleration.js","line":1,"requires":["core"]},"Keyboard":{"name":"Keyboard","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Events","namespace":"","file":"src/events/keyboard.js","line":1,"requires":["core"]},"Mouse":{"name":"Mouse","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Events","namespace":"","file":"src/events/mouse.js","line":1,"requires":["core","constants"]},"Touch":{"name":"Touch","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Events","namespace":"","file":"src/events/touch.js","line":1,"requires":["core"]},"Image":{"name":"Image","submodules":{"Pixels":1},"classes":{"p5.Image":1},"fors":{"p5":1},"namespaces":{},"module":"Image","file":"src/image/p5.Image.js","line":23,"requires":["core"],"description":"

Creates a new p5.Image. A p5.Image is a canvas backed representation of an\nimage.\n

\np5 can display .gif, .jpg and .png images. Images may be displayed\nin 2D and 3D space. Before an image is used, it must be loaded with the\nloadImage() function. The p5.Image class contains fields for the width and\nheight of the image, as well as an array called pixels[] that contains the\nvalues for every pixel in the image.\n

\nThe methods described below allow easy access to the image's pixels and\nalpha channel and simplify the process of compositing.\n

\nBefore using the pixels[] array, be sure to use the loadPixels() method on\nthe image to make sure that the pixel data is properly loaded.

\n"},"Loading & Displaying":{"name":"Loading & Displaying","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Typography","namespace":"","file":"src/image/loading_displaying.js","line":1,"requires":["core"]},"Pixels":{"name":"Pixels","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Image","namespace":"","file":"src/image/pixels.js","line":1,"requires":["core"]},"IO":{"name":"IO","submodules":{"undefined":1,"Input":1,"Output":1,"Table":1,"XML":1,"Time & Date":1},"classes":{"p5":1,"p5.Table":1,"p5.TableRow":1,"p5.XML":1},"fors":{"p5":1},"namespaces":{},"file":"src/io/p5.XML.js","line":11},"Input":{"name":"Input","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src/io/files.js","line":1,"requires":["core","reqwest"]},"Output":{"name":"Output","submodules":{},"classes":{"p5":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src/io/files.js","line":897},"Table":{"name":"Table","submodules":{},"classes":{"p5.Table":1,"p5.TableRow":1},"fors":{},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src/io/p5.TableRow.js","line":11,"requires":["core"],"description":"

Table objects store data with multiple rows and columns, much\nlike in a traditional spreadsheet. Tables can be generated from\nscratch, dynamically, or using data from an existing file.

\n"},"XML":{"name":"XML","submodules":{},"classes":{"p5.XML":1},"fors":{},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src/io/p5.XML.js","line":11,"requires":["core"],"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.

\n"},"Math":{"name":"Math","submodules":{"Calculation":1,"Noise":1,"Random":1,"Trigonometry":1},"classes":{"p5.Vector":1},"fors":{"p5":1},"namespaces":{},"module":"Math","file":"src/math/p5.Vector.js","line":13,"requires":["core"],"description":"

A class to describe a two or three dimensional vector, specifically\na Euclidean (also known as geometric) vector. A vector is an entity\nthat has both magnitude and direction. The datatype, however, stores\nthe components of the vector (x, y for 2D, and x, y, z for 3D). The magnitude\nand direction can be accessed via the methods mag() and heading().\n

\nIn many of the p5.js examples, you will see p5.Vector used to describe a\nposition, velocity, or acceleration. For example, if you consider a rectangle\nmoving across the screen, at any given instant it has a position (a vector\nthat points from the origin to its location), a velocity (the rate at which\nthe object's position changes per time unit, expressed as a vector), and\nacceleration (the rate at which the object's velocity changes per time\nunit, expressed as a vector).\n

\nSince vectors represent groupings of values, we cannot simply use\ntraditional addition/multiplication/etc. Instead, we'll need to do some\n"vector" math, which is made easy by the methods inside the p5.Vector class.

\n"},"Calculation":{"name":"Calculation","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src/math/calculation.js","line":1,"requires":["core"]},"Noise":{"name":"Noise","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src/math/noise.js","line":14,"requires":["core"]},"Random":{"name":"Random","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src/math/random.js","line":1,"requires":["core"]},"Trigonometry":{"name":"Trigonometry","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src/math/trigonometry.js","line":1,"requires":["core","polargeometry","constants"]},"Typography":{"name":"Typography","submodules":{"Attributes":1,"Loading & Displaying":1,"Font":1},"classes":{"p5.Font":1},"fors":{"p5":1},"namespaces":{},"file":"src/typography/p5.Font.js","line":32},"Font":{"name":"Font","submodules":{},"classes":{"p5.Font":1},"fors":{},"is_submodule":1,"namespaces":{},"module":"Typography","namespace":"","file":"src/typography/p5.Font.js","line":32,"description":"

This module defines the p5.Font class and functions for\ndrawing text to the display canvas.

\n","requires":["core","constants"]},"Data":{"name":"Data","submodules":{"Array Functions":1,"Conversion":1,"String Functions":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"Array Functions":{"name":"Array Functions","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Data","namespace":"","file":"src/utilities/array_functions.js","line":1,"requires":["core"]},"Conversion":{"name":"Conversion","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Data","namespace":"","file":"src/utilities/conversion.js","line":1,"requires":["core"]},"String Functions":{"name":"String Functions","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Data","namespace":"","file":"src/utilities/string_functions.js","line":1,"requires":["core"]},"Time & Date":{"name":"Time & Date","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src/utilities/time_date.js","line":1,"requires":["core"]},"Lights, Camera":{"name":"Lights, Camera","submodules":{"Camera":1,"Lights":1,"Material":1},"classes":{"p5.RendererGL":1},"fors":{"p5":1},"namespaces":{},"file":"src/webgl/p5.RendererGL.js","line":21},"Camera":{"name":"Camera","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Lights, Camera","namespace":"","file":"src/webgl/camera.js","line":1,"requires":["core"]},"Lights":{"name":"Lights","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Lights, Camera","namespace":"","file":"src/webgl/light.js","line":1,"requires":["core"]},"3D Models":{"name":"3D Models","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src/webgl/loading.js","line":1,"requires":["core","p5.Geometry3D"]},"Material":{"name":"Material","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Lights, Camera","namespace":"","file":"src/webgl/material.js","line":1,"requires":["core"]},"3D Primitives":{"name":"3D Primitives","submodules":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src/webgl/primitives.js","line":1,"requires":["core","p5.Geometry"]},"p5.dom":{"name":"p5.dom","submodules":{},"classes":{"p5.dom":1,"p5.MediaElement":1,"p5.File":1},"fors":{"p5.dom":1,"p5.Element":1},"namespaces":{},"module":"p5.dom","file":"lib/addons/p5.dom.js","line":2090,"description":"

The web is much more than just canvas and p5.dom makes it easy to interact\nwith other HTML5 objects, including text, hyperlink, image, input, video,\naudio, and webcam.

\n

There is a set of creation methods, DOM manipulation methods, and\nan extended p5.Element that supports a range of HTML elements. See the\n\nbeyond the canvas tutorial for a full overview of how this addon works.

\n

Methods and properties shown in black are part of the p5.js core, items in\nblue are part of the p5.dom library. You will need to include an extra file\nin order to access the blue functions. See the\nusing a library\nsection for information on how to include this library. p5.dom comes with\np5 complete or you can download the single file\n\nhere.

\n

See tutorial: beyond the canvas\nfor more info on how to use this libary.

\n","tag":"main","itemtype":"main"},"p5.sound":{"name":"p5.sound","submodules":{},"classes":{"p5.sound":1,"p5.SoundFile":1,"p5.Amplitude":1,"p5.FFT":1,"p5.Signal":1,"p5.Oscillator":1,"p5.Env":1,"p5.Pulse":1,"p5.Noise":1,"p5.AudioIn":1,"p5.Filter":1,"p5.Delay":1,"p5.Reverb":1,"p5.Convolver":1,"p5.Phrase":1,"p5.Part":1,"p5.Score":1,"p5.SoundRecorder":1,"p5.PeakDetect":1,"p5.Gain":1},"fors":{"p5.sound":1},"namespaces":{},"module":"p5.sound","file":"lib/addons/p5.sound.js","line":8897,"description":"

p5.sound extends p5 with Web Audio functionality including audio input,\nplayback, analysis and synthesis.\n

\np5.SoundFile: Load and play sound files.
\np5.Amplitude: Get the current volume of a sound.
\np5.AudioIn: Get sound from an input source, typically\n a computer microphone.
\np5.FFT: Analyze the frequency of sound. Returns\n results from the frequency spectrum or time domain (waveform).
\np5.Oscillator: Generate Sine,\n Triangle, Square and Sawtooth waveforms. Base class of\n p5.Noise and p5.Pulse.\n
\np5.Env: An Envelope is a series\n of fades over time. Often used to control an object's\n output gain level as an "ADSR Envelope" (Attack, Decay,\n Sustain, Release). Can also modulate other parameters.
\np5.Delay: A delay effect with\n parameters for feedback, delayTime, and lowpass filter.
\np5.Filter: Filter the frequency range of a\n sound.\n
\np5.Reverb: Add reverb to a sound by specifying\n duration and decay.
\np5.Convolver: Extends\np5.Reverb to simulate the sound of real\n physical spaces through convolution.
\np5.SoundRecorder: Record sound for playback \n / save the .wav file.\np5.Phrase, p5.Part and\np5.Score: Compose musical sequences.\n

\np5.sound is on GitHub.\nDownload the latest version \nhere.

\n","tag":"main","itemtype":"main"}},"classes":{"p5":{"name":"p5","shortname":"p5","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"IO","submodule":"Output"},"p5.Color":{"name":"p5.Color","shortname":"p5.Color","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Color","submodule":"Creating & Reading","file":"src/color/p5.Color.js","line":14,"description":"

We define colors to be immutable objects. Each color stores the color mode\nand level maxes that applied at the time of its construction. These are\nused to interpret the input arguments and to format the output e.g. when\nsaturation() is requested.

\n

Internally we store an array representing the ideal RGBA values in floating\npoint form, normalized from 0 to 1. From this we calculate the closest\nscreen color (RGBA levels from 0 to 255) and expose this to the renderer.

\n

We also cache normalized, floating point components of the color in various\nrepresentations as they are calculated. This is done to prevent repeating a\nconversion that has already been performed.

\n","is_constructor":1},"p5.Element":{"name":"p5.Element","shortname":"p5.Element","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"DOM","submodule":"DOM","namespace":"","file":"src/core/p5.Element.js","line":9,"description":"

Base class for all elements added to a sketch, including canvas,\ngraphics buffers, and other HTML elements. Methods in blue are\nincluded in the core functionality, methods in brown are added\nwith the p5.dom\nlibrary.\nIt is not called directly, but p5.Element\nobjects are created by calling createCanvas, createGraphics,\nor in the p5.dom library, createDiv, createImg, createInput, etc.

\n","is_constructor":1,"params":[{"name":"elt","description":"

DOM node that is wrapped

\n","type":"String"},{"name":"pInst","description":"

pointer to p5 instance

\n","type":"Object","optional":true}]},"p5.Graphics":{"name":"p5.Graphics","shortname":"p5.Graphics","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Rendering","submodule":"Rendering","file":"src/core/p5.Graphics.js","line":10,"description":"

Thin wrapper around a renderer, to be used for creating a\ngraphics buffer 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. The fields and methods for this class are\nextensive, but mirror the normal drawing API for p5.

\n","is_constructor":1,"extends":"p5.Element","params":[{"name":"elt","description":"

DOM node that is wrapped

\n","type":"String"},{"name":"pInst","description":"

pointer to p5 instance

\n","type":"Object","optional":true},{"name":"whether","description":"

we're using it as main canvas

\n","type":"Boolean"}]},"p5.Renderer":{"name":"p5.Renderer","shortname":"p5.Renderer","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Rendering","submodule":"Rendering","file":"src/core/p5.Renderer.js","line":10,"description":"

Main graphics and rendering context, as well as the base API\nimplementation for p5.js "core". To be used as the superclass for\nRenderer2D and Renderer3D classes, respecitvely.

\n","is_constructor":1,"extends":"p5.Element","params":[{"name":"elt","description":"

DOM node that is wrapped

\n","type":"String"},{"name":"pInst","description":"

pointer to p5 instance

\n","type":"Object","optional":true},{"name":"whether","description":"

we're using it as main canvas

\n","type":"Boolean"}]},"p5.Image":{"name":"p5.Image","shortname":"p5.Image","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Image","submodule":"Image","namespace":"","file":"src/image/p5.Image.js","line":23,"description":"

Creates a new p5.Image. A p5.Image is a canvas backed representation of an\nimage.\n

\np5 can display .gif, .jpg and .png images. Images may be displayed\nin 2D and 3D space. Before an image is used, it must be loaded with the\nloadImage() function. The p5.Image class contains fields for the width and\nheight of the image, as well as an array called pixels[] that contains the\nvalues for every pixel in the image.\n

\nThe methods described below allow easy access to the image's pixels and\nalpha channel and simplify the process of compositing.\n

\nBefore using the pixels[] array, be sure to use the loadPixels() method on\nthe image to make sure that the pixel data is properly loaded.

\n","is_constructor":1,"params":[{"name":"width","description":"","type":"Number"},{"name":"height","description":"","type":"Number"},{"name":"pInst","description":"

An instance of a p5 sketch.

\n","type":"Object"}]},"p5.Table":{"name":"p5.Table","shortname":"p5.Table","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"IO","submodule":"Table","namespace":"","file":"src/io/p5.Table.js","line":36,"description":"

Table objects store data with multiple rows and columns, much\nlike in a traditional spreadsheet. Tables can be generated from\nscratch, dynamically, or using data from an existing file.

\n","is_constructor":1,"params":[{"name":"rows","description":"

An array of p5.TableRow objects

\n","type":"Array","optional":true}],"return":{"description":"p5.Table generated","type":"p5.Table"}},"p5.TableRow":{"name":"p5.TableRow","shortname":"p5.TableRow","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"IO","submodule":"Table","namespace":"","file":"src/io/p5.TableRow.js","line":11,"description":"

A TableRow object represents a single row of data values,\nstored in columns, from a table.

\n

A Table Row contains both an ordered array, and an unordered\nJSON object.

\n","is_constructor":1,"params":[{"name":"str","description":"

optional: populate the row with a\n string of values, separated by the\n separator

\n","type":"String","optional":true},{"name":"separator","description":"

comma separated values (csv) by default

\n","type":"String","optional":true}]},"p5.XML":{"name":"p5.XML","shortname":"p5.XML","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"IO","submodule":"XML","namespace":"","file":"src/io/p5.XML.js","line":11,"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.

\n","is_constructor":1,"return":{"description":"p5.XML object generated","type":"p5.XML"},"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var children = xml.getChildren(\"animal\");\n\n for (var i = 0; i < children.length; i++) {\n var id = children[i].getNumber(\"id\");\n var coloring = children[i].getString(\"species\");\n var name = children[i].getContent();\n println(id + \", \" + coloring + \", \" + name);\n }\n}\n\n// Sketch prints:\n// 0, Capra hircus, Goat\n// 1, Panthera pardus, Leopard\n// 2, Equus zebra, Zebra\n
"]},"p5.Vector":{"name":"p5.Vector","shortname":"p5.Vector","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Math","submodule":"Math","namespace":"","file":"src/math/p5.Vector.js","line":13,"description":"

A class to describe a two or three dimensional vector, specifically\na Euclidean (also known as geometric) vector. A vector is an entity\nthat has both magnitude and direction. The datatype, however, stores\nthe components of the vector (x, y for 2D, and x, y, z for 3D). The magnitude\nand direction can be accessed via the methods mag() and heading().\n

\nIn many of the p5.js examples, you will see p5.Vector used to describe a\nposition, velocity, or acceleration. For example, if you consider a rectangle\nmoving across the screen, at any given instant it has a position (a vector\nthat points from the origin to its location), a velocity (the rate at which\nthe object's position changes per time unit, expressed as a vector), and\nacceleration (the rate at which the object's velocity changes per time\nunit, expressed as a vector).\n

\nSince vectors represent groupings of values, we cannot simply use\ntraditional addition/multiplication/etc. Instead, we'll need to do some\n"vector" math, which is made easy by the methods inside the p5.Vector class.

\n","is_constructor":1,"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}],"example":["\n
\n\nvar v1 = createVector(40, 50);\nvar v2 = createVector(40, 50);\n\nellipse(v1.x, v1.y, 50, 50);\nellipse(v2.x, v2.y, 50, 50);\nv1.add(v2);\nellipse(v1.x, v1.y, 50, 50);\n\n
"]},"p5.Font":{"name":"p5.Font","shortname":"p5.Font","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Typography","submodule":"Font","namespace":"","file":"src/typography/p5.Font.js","line":32,"description":"

Base class for font handling

\n","is_constructor":1,"params":[{"name":"pInst","description":"

pointer to p5 instance

\n","type":"Object","optional":true}]},"p5.RendererGL":{"name":"p5.RendererGL","shortname":"p5.RendererGL","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Lights, Camera","file":"src/webgl/p5.RendererGL.js","line":21,"is_constructor":1,"extends":"p5.Renderer\n3D graphics class.","todo":["extend class to include public method for offscreen\nrendering (FBO)."]},"p5.dom":{"name":"p5.dom","shortname":"p5.dom","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.dom","submodule":"p5.dom","namespace":""},"p5.MediaElement":{"name":"p5.MediaElement","shortname":"p5.MediaElement","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.dom","submodule":"p5.dom","namespace":"","file":"lib/addons/p5.dom.js","line":1596,"description":"

Extends p5.Element to handle audio and video. In addition to the methods\nof p5.Element, it also contains methods for controlling media. It is not\ncalled directly, but p5.MediaElements are created by calling createVideo,\ncreateAudio, and createCapture.

\n","is_constructor":1,"params":[{"name":"elt","description":"

DOM node that is wrapped

\n","type":"String"},{"name":"pInst","description":"

pointer to p5 instance

\n","type":"Object","optional":true}]},"p5.File":{"name":"p5.File","shortname":"p5.File","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.dom","submodule":"p5.dom","namespace":"","file":"lib/addons/p5.dom.js","line":2090,"description":"

Base class for a file\nUsing this for createFileInput

\n","is_constructor":1,"params":[{"name":"file","description":"

File that is wrapped

\n","type":"File"},{"name":"pInst","description":"

pointer to p5 instance

\n","type":"Object","optional":true}]},"p5.sound":{"name":"p5.sound","shortname":"p5.sound","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":""},"p5.SoundFile":{"name":"p5.SoundFile","shortname":"p5.SoundFile","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":738,"description":"

SoundFile object with a path to a file.

\n\n

The p5.SoundFile may not be available immediately because\nit loads the file information asynchronously.

\n\n

To do something with the sound as soon as it loads\npass the name of a function as the second parameter.

\n\n

Only one file path is required. However, audio file formats \n(i.e. mp3, ogg, wav and m4a/aac) are not supported by all\nweb browsers. If you want to ensure compatability, instead of a single\nfile path, you may include an Array of filepaths, and the browser will\nchoose a format that works.

","is_constructor":1,"params":[{"name":"path","description":"

path to a sound file (String). Optionally,\n you may include multiple file formats in\n an array. Alternately, accepts an object\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 file fails to\n load. This function will receive an error or\n XMLHttpRequest object with information\n about what went wrong.

\n","type":"Function","optional":true},{"name":"whileLoadingCallback","description":"

Name of a function to call while file\n is loading. That function will\n receive percentage loaded\n (between 0 and 1) as a\n parameter.

\n","type":"Function","optional":true}],"return":{"description":"p5.SoundFile Object","type":"Object"},"example":[" \n
\n\nfunction preload() {\n mySound = loadSound('assets/doorbell.mp3');\n}\n\nfunction setup() {\n mySound.setVolume(0.1);\n mySound.play();\n}\n \n
"]},"p5.Amplitude":{"name":"p5.Amplitude","shortname":"p5.Amplitude","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":2159,"description":"

Amplitude measures volume between 0.0 and 1.0.\nListens to all p5sound by default, or use setInput()\nto listen to a specific sound source. Accepts an optional\nsmoothing value, which defaults to 0.

\n","is_constructor":1,"params":[{"name":"smoothing","description":"

between 0.0 and .999 to smooth\n amplitude readings (defaults to 0)

\n","type":"Number","optional":true}],"return":{"description":"Amplitude Object","type":"Object"},"example":["\n
\nvar sound, amplitude, cnv;\n\nfunction preload(){\n sound = loadSound('assets/beat.mp3');\n}\nfunction setup() {\n cnv = createCanvas(100,100);\n amplitude = new p5.Amplitude();\n\n // start / stop the sound when canvas is clicked\n cnv.mouseClicked(function() {\n if (sound.isPlaying() ){\n sound.stop();\n } else {\n sound.play();\n }\n });\n}\nfunction draw() {\n background(0);\n fill(255);\n var level = amplitude.getLevel();\n var size = map(level, 0, 1, 0, 200);\n ellipse(width/2, height/2, size, size);\n}\n\n
"]},"p5.FFT":{"name":"p5.FFT","shortname":"p5.FFT","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":2432,"description":"

FFT (Fast Fourier Transform) is an analysis algorithm that\nisolates individual\n\naudio frequencies within a waveform.

\n\n

Once instantiated, a p5.FFT object can return an array based on\ntwo types of analyses:
FFT.waveform() computes\namplitude values along the time domain. The array indices correspond\nto samples across a brief moment in time. Each value represents\namplitude of the waveform at that sample of time.
\n• FFT.analyze() computes amplitude values along the\nfrequency domain. The array indices correspond to frequencies (i.e.\npitches), from the lowest to the highest that humans can hear. Each\nvalue represents amplitude at that slice of the frequency spectrum.\nUse with getEnergy() to measure amplitude at specific\nfrequencies, or within a range of frequencies.

\n\n

FFT analyzes a very short snapshot of sound called a sample\nbuffer. It returns an array of amplitude measurements, referred\nto as bins. The array is 1024 bins long by default.\nYou can change the bin array length, but it must be a power of 2\nbetween 16 and 1024 in order for the FFT algorithm to function\ncorrectly. The actual size of the FFT buffer is twice the \nnumber of bins, so given a standard sample rate, the buffer is\n2048/44100 seconds long.

","is_constructor":1,"params":[{"name":"smoothing","description":"

Smooth results of Freq Spectrum.\n 0.0 < smoothing < 1.0.\n Defaults to 0.8.

\n","type":"Number","optional":true},{"name":"bins","description":"

Length of resulting array.\n Must be a power of two between\n 16 and 1024. Defaults to 1024.

\n","type":"Number","optional":true}],"return":{"description":"FFT Object","type":"Object"},"example":["\n
\nfunction preload(){\n sound = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup(){\n var cnv = createCanvas(100,100);\n cnv.mouseClicked(togglePlay);\n fft = new p5.FFT();\n sound.amp(0.2);\n}\n\nfunction draw(){\n background(0);\n\n var spectrum = fft.analyze(); \n noStroke();\n fill(0,255,0); // spectrum is green\n for (var i = 0; i< spectrum.length; i++){\n var x = map(i, 0, spectrum.length, 0, width);\n var h = -height + map(spectrum[i], 0, 255, height, 0);\n rect(x, height, width / spectrum.length, h )\n }\n\n var waveform = fft.waveform();\n noFill();\n beginShape();\n stroke(255,0,0); // waveform is red\n strokeWeight(1);\n for (var i = 0; i< waveform.length; i++){\n var x = map(i, 0, waveform.length, 0, width);\n var y = map( waveform[i], -1, 1, 0, height);\n vertex(x,y);\n }\n endShape();\n\n text('click to play/pause', 4, 10);\n}\n\n// fade sound if mouse is over canvas\nfunction togglePlay() {\n if (sound.isPlaying()) {\n sound.pause();\n } else {\n sound.loop();\n }\n}\n
"]},"p5.Signal":{"name":"p5.Signal","shortname":"p5.Signal","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":4161,"description":"

p5.Signal is a constant audio-rate signal used by p5.Oscillator\nand p5.Envelope for modulation math.

\n\n

This is necessary because Web Audio is processed on a seprate clock.\nFor example, the p5 draw loop runs about 60 times per second. But\nthe audio clock must process samples 44100 times per second. If we\nwant to add a value to each of those samples, we can't do it in the\ndraw loop, but we can do it by adding a constant-rate audio signal.This class mostly functions behind the scenes in p5.sound, and returns\na Tone.Signal from the Tone.js library by Yotam Mann.\nIf you want to work directly with audio signals for modular\nsynthesis, check out\ntone.js.

","is_constructor":1,"return":{"description":"A Signal object from the Tone.js library","type":"Tone.Signal"},"example":["\n
\nfunction setup() {\n carrier = new p5.Oscillator('sine');\n carrier.amp(1); // set amplitude\n carrier.freq(220); // set frequency\n carrier.start(); // start oscillating\n \n modulator = new p5.Oscillator('sawtooth');\n modulator.disconnect();\n modulator.amp(1);\n modulator.freq(4);\n modulator.start();\n\n // Modulator's default amplitude range is -1 to 1.\n // Multiply it by -200, so the range is -200 to 200\n // then add 220 so the range is 20 to 420\n carrier.freq( modulator.mult(-200).add(220) );\n}\n
"]},"p5.Oscillator":{"name":"p5.Oscillator","shortname":"p5.Oscillator","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":4307,"description":"

Creates a signal that oscillates between -1.0 and 1.0.\nBy default, the oscillation takes the form of a sinusoidal\nshape ('sine'). Additional types include 'triangle',\n'sawtooth' and 'square'. The frequency defaults to\n440 oscillations per second (440Hz, equal to the pitch of an\n'A' note).

\n\n

Set the type of oscillation with setType(), or by creating a\nspecific oscillator.

For example:\nnew p5.SinOsc(freq)\nnew p5.TriOsc(freq)\nnew p5.SqrOsc(freq)\nnew p5.SawOsc(freq).\n

","is_constructor":1,"params":[{"name":"freq","description":"

frequency defaults to 440Hz

\n","type":"Number","optional":true},{"name":"type","description":"

type of oscillator. Options:\n 'sine' (default), 'triangle',\n 'sawtooth', 'square'

\n","type":"String","optional":true}],"return":{"description":"Oscillator object","type":"Object"},"example":["\n
\nvar osc;\nvar playing = false;\n\nfunction setup() {\n backgroundColor = color(255,0,255);\n textAlign(CENTER);\n \n osc = new p5.Oscillator();\n osc.setType('sine');\n osc.freq(240);\n osc.amp(0);\n osc.start();\n}\n\nfunction draw() {\n background(backgroundColor)\n text('click to play', width/2, height/2);\n}\n\nfunction mouseClicked() {\n if (mouseX > 0 && mouseX < width && mouseY < height && mouseY > 0) {\n if (!playing) {\n // ramp amplitude to 0.5 over 0.1 seconds\n osc.amp(0.5, 0.05);\n playing = true;\n backgroundColor = color(0,255,255);\n } else {\n // ramp amplitude to 0 over 0.5 seconds\n osc.amp(0, 0.5);\n playing = false;\n backgroundColor = color(255,0,255);\n }\n }\n}\n
"]},"p5.Env":{"name":"p5.Env","shortname":"p5.Env","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":5163,"description":"

Envelopes are pre-defined amplitude distribution over time.\nTypically, envelopes are used to control the output volume\nof an object, a series of fades referred to as Attack, Decay,\nSustain and Release (\nADSR\n). Envelopes can also control other Web Audio Parameters—for example, a p5.Env can \ncontrol an Oscillator's frequency like this: osc.freq(env).

\n

Use setRange to change the attack/release level.\nUse setADSR to change attackTime, decayTime, sustainPercent and releaseTime.

\n

Use the play method to play the entire envelope,\nthe ramp method for a pingable trigger,\nor triggerAttack/\ntriggerRelease to trigger noteOn/noteOff.

","is_constructor":1,"example":["\n
\nvar attackLevel = 1.0;\nvar releaseLevel = 0;\n\nvar attackTime = 0.001\nvar decayTime = 0.2;\nvar susPercent = 0.2;\nvar releaseTime = 0.5;\n\nvar env, triOsc;\n\nfunction setup() {\n var cnv = createCanvas(100, 100);\n\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n\n env = new p5.Env();\n env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n env.setRange(attackLevel, releaseLevel);\n\n triOsc = new p5.Oscillator('triangle');\n triOsc.amp(env);\n triOsc.start();\n triOsc.freq(220);\n\n cnv.mousePressed(playEnv);\n}\n\nfunction playEnv(){\n env.play();\n}\n
"]},"p5.Pulse":{"name":"p5.Pulse","shortname":"p5.Pulse","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":5926,"description":"

Creates a Pulse object, an oscillator that implements\nPulse Width Modulation.\nThe pulse is created with two oscillators.\nAccepts a parameter for frequency, and to set the\nwidth between the pulses. See \np5.Oscillator for a full list of methods.

\n","is_constructor":1,"params":[{"name":"freq","description":"

Frequency in oscillations per second (Hz)

\n","type":"Number","optional":true},{"name":"w","description":"

Width between the pulses (0 to 1.0,\n defaults to 0)

\n","type":"Number","optional":true}],"example":["\n
\nvar pulse;\nfunction setup() {\n background(0);\n \n // Create and start the pulse wave oscillator\n pulse = new p5.Pulse();\n pulse.amp(0.5);\n pulse.freq(220);\n pulse.start();\n}\n\nfunction draw() {\n var w = map(mouseX, 0, width, 0, 1);\n w = constrain(w, 0, 1);\n pulse.width(w)\n}\n
"]},"p5.Noise":{"name":"p5.Noise","shortname":"p5.Noise","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":6102,"description":"

Noise is a type of oscillator that generates a buffer with random values.

\n","is_constructor":1,"params":[{"name":"type","description":"

Type of noise can be 'white' (default),\n 'brown' or 'pink'.

\n","type":"String"}],"return":{"description":"Noise Object","type":"Object"}},"p5.AudioIn":{"name":"p5.AudioIn","shortname":"p5.AudioIn","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":6281,"description":"

Get audio from an input, i.e. your computer's microphone.

\n\n

Turn the mic on/off with the start() and stop() methods. When the mic\nis on, its volume can be measured with getLevel or by connecting an\nFFT object.

\n\n

If you want to hear the AudioIn, use the .connect() method. \nAudioIn does not connect to p5.sound output by default to prevent\nfeedback.

\n\n

Note: This uses the getUserMedia/\nStream API, which is not supported by certain browsers.

","is_constructor":1,"return":{"description":"AudioIn","type":"Object"},"example":["\n
\nvar mic;\nfunction setup(){\n mic = new p5.AudioIn()\n mic.start();\n}\nfunction draw(){\n background(0);\n micLevel = mic.getLevel();\n ellipse(width/2, constrain(height-micLevel*height*5, 0, height), 10, 10);\n}\n
"]},"p5.Filter":{"name":"p5.Filter","shortname":"p5.Filter","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":6593,"description":"

A p5.Filter uses a Web Audio Biquad Filter to filter\nthe frequency response of an input source. Inheriting\nclasses include:

\n
    \n
  • p5.LowPass - allows frequencies below\nthe cutoff frequency to pass through, and attenuates\nfrequencies above the cutoff.
  • \n
  • p5.HighPass - the opposite of a lowpass\nfilter.
  • \n
  • p5.BandPass - allows a range of\nfrequencies to pass through and attenuates the frequencies\nbelow and above this frequency range.
  • \n
\n

The .res() method controls either width of the\nbandpass, or resonance of the low/highpass cutoff frequency.

\n","is_constructor":1,"params":[{"name":"type","description":"

'lowpass' (default), 'highpass', 'bandpass'

\n","type":"[String]"}],"return":{"description":"p5.Filter","type":"Object"},"example":["\n
\nvar fft, noise, filter;\n\nfunction setup() {\n fill(255, 40, 255);\n\n filter = new p5.BandPass();\n\n noise = new p5.Noise();\n // disconnect unfiltered noise,\n // and connect to filter\n noise.disconnect();\n noise.connect(filter);\n noise.start();\n\n fft = new p5.FFT();\n}\n\nfunction draw() {\n background(30);\n\n // set the BandPass frequency based on mouseX\n var freq = map(mouseX, 0, width, 20, 10000);\n filter.freq(freq);\n // give the filter a narrow band (lower res = wider bandpass)\n filter.res(50);\n\n // draw filtered spectrum\n var spectrum = fft.analyze();\n noStroke();\n for (var i = 0; i < spectrum.length; i++) {\n var x = map(i, 0, spectrum.length, 0, width);\n var h = -height + map(spectrum[i], 0, 255, height, 0);\n rect(x, height, width/spectrum.length, h);\n }\n \n isMouseOverCanvas();\n}\n\nfunction isMouseOverCanvas() {\n var mX = mouseX, mY = mouseY;\n if (mX > 0 && mX < width && mY < height && mY > 0) {\n noise.amp(0.5, 0.2);\n } else {\n noise.amp(0, 0.2);\n }\n}\n
"]},"p5.Delay":{"name":"p5.Delay","shortname":"p5.Delay","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":6866,"description":"

Delay is an echo effect. It processes an existing sound source,\nand outputs a delayed version of that sound. The p5.Delay can\nproduce different effects depending on the delayTime, feedback,\nfilter, and type. In the example below, a feedback of 0.5 will\nproduce a looping delay that decreases in volume by\n50% each repeat. A filter will cut out the high frequencies so\nthat the delay does not sound as piercing as the original source.

\n","is_constructor":1,"return":{"description":"Returns a p5.Delay object","type":"Object"},"example":["\n
\nvar noise, env, delay;\n\nfunction setup() {\n background(0);\n noStroke();\n fill(255);\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n \n noise = new p5.Noise('brown');\n noise.amp(0);\n noise.start();\n \n delay = new p5.Delay();\n\n // delay.process() accepts 4 parameters:\n // source, delayTime, feedback, filter frequency\n // play with these numbers!!\n delay.process(noise, .12, .7, 2300);\n \n // play the noise with an envelope,\n // a series of fades ( time / value pairs )\n env = new p5.Env(.01, 0.2, .2, .1);\n}\n\n// mouseClick triggers envelope\nfunction mouseClicked() {\n // is mouse over canvas?\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n env.play(noise);\n }\n}\n
"]},"p5.Reverb":{"name":"p5.Reverb","shortname":"p5.Reverb","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":7158,"description":"

Reverb adds depth to a sound through a large number of decaying\nechoes. It creates the perception that sound is occurring in a\nphysical space. The p5.Reverb has paramters for Time (how long does the\nreverb last) and decayRate (how much the sound decays with each echo)\nthat can be set with the .set() or .process() methods. The p5.Convolver\nextends p5.Reverb allowing you to recreate the sound of actual physical\nspaces through convolution.

\n","is_constructor":1,"example":["\n
\nvar soundFile, reverb;\nfunction preload() {\n soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n reverb = new p5.Reverb();\n soundFile.disconnect(); // so we'll only hear reverb...\n\n // connect soundFile to reverb, process w/\n // 3 second reverbTime, decayRate of 2%\n reverb.process(soundFile, 3, 2);\n soundFile.play();\n}\n
"]},"p5.Convolver":{"name":"p5.Convolver","shortname":"p5.Convolver","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":7340,"description":"

p5.Convolver extends p5.Reverb. It can emulate the sound of real\nphysical spaces through a process called \nconvolution.

\n\n

Convolution multiplies any audio input by an "impulse response"\nto simulate the dispersion of sound over time. The impulse response is\ngenerated from an audio file that you provide. One way to\ngenerate an impulse response is to pop a balloon in a reverberant space\nand record the echo. Convolution can also be used to experiment with\nsound.

\n\n

Use the method createConvolution(path) to instantiate a\np5.Convolver with a path to your impulse response audio file.

","is_constructor":1,"params":[{"name":"path","description":"

path to a sound file

\n","type":"String"},{"name":"callback","description":"

function to call when loading succeeds

\n","type":"Function","optional":true},{"name":"errorCallback","description":"

function to call if loading fails.\n This function will receive an error or\n XMLHttpRequest object with information\n about what went wrong.

\n","type":"Function","optional":true}],"example":["\n
\nvar cVerb, sound;\nfunction preload() {\n // We have both MP3 and OGG versions of all sound assets\n soundFormats('ogg', 'mp3');\n \n // Try replacing 'bx-spring' with other soundfiles like\n // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n cVerb = createConvolver('assets/bx-spring.mp3');\n\n // Try replacing 'Damscray_DancingTiger' with\n // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n sound = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n // disconnect from master output...\n sound.disconnect();\n \n // ...and process with cVerb\n // so that we only hear the convolution\n cVerb.process(sound);\n \n sound.play();\n}\n
"]},"p5.Phrase":{"name":"p5.Phrase","shortname":"p5.Phrase","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":7923,"description":"

A phrase is a pattern of musical events over time, i.e.\na series of notes and rests.

\n\n

Phrases must be added to a p5.Part for playback, and\neach part can play multiple phrases at the same time.\nFor example, one Phrase might be a kick drum, another\ncould be a snare, and another could be the bassline.

\n\n

The first parameter is a name so that the phrase can be\nmodified or deleted later. The callback is a a function that\nthis phrase will call at every step—for example it might be\ncalled playNote(value){}. The array determines\nwhich value is passed into the callback at each step of the\nphrase. It can be numbers, an object with multiple numbers,\nor a zero (0) indicates a rest so the callback won't be called).

","is_constructor":1,"params":[{"name":"name","description":"

Name so that you can access the Phrase.

\n","type":"String"},{"name":"callback","description":"

The name of a function that this phrase\n will call. Typically it will play a sound,\n and accept two parameters: a time at which\n to play the sound (in seconds from now),\n and a value from the sequence array. The\n time should be passed into the play() or\n start() method to ensure precision.

\n","type":"Function"},{"name":"sequence","description":"

Array of values to pass into the callback\n at each step of the phrase.

\n","type":"Array"}],"example":["\n
\nvar mySound, myPhrase, myPart;\nvar pattern = [1,0,0,2,0,2,0,0];\nvar msg = 'click to play';\n\nfunction preload() {\n mySound = loadSound('assets/beatbox.mp3');\n}\n\nfunction setup() {\n noStroke();\n fill(255);\n textAlign(CENTER);\n masterVolume(0.1);\n \n myPhrase = new p5.Phrase('bbox', makeSound, pattern);\n myPart = new p5.Part();\n myPart.addPhrase(myPhrase);\n myPart.setBPM(60);\n}\n\nfunction draw() {\n background(0);\n text(msg, width/2, height/2);\n}\n\nfunction makeSound(time, playbackRate) {\n mySound.rate(playbackRate);\n mySound.play(time);\n}\n\nfunction mouseClicked() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n myPart.start();\n msg = 'playing pattern';\n }\n}\n\n
"]},"p5.Part":{"name":"p5.Part","shortname":"p5.Part","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":8009,"description":"

A p5.Part plays back one or more p5.Phrases. Instantiate a part\nwith steps and tatums. By default, each step represents 1/16th note.

\n\n

See p5.Phrase for more about musical timing.

","is_constructor":1,"params":[{"name":"steps","description":"

Steps in the part

\n","type":"Number","optional":true},{"name":"tatums","description":"

Divisions of a beat (default is 1/16, a quarter note)

\n","type":"Number","optional":true}],"example":["\n
\nvar box, drum, myPart;\nvar boxPat = [1,0,0,2,0,2,0,0];\nvar drumPat = [0,1,1,0,2,0,1,0];\nvar msg = 'click to play';\n\nfunction preload() {\n box = loadSound('assets/beatbox.mp3');\n drum = loadSound('assets/drum.mp3');\n}\n\nfunction setup() {\n noStroke();\n fill(255);\n textAlign(CENTER);\n masterVolume(0.1);\n\n var boxPhrase = new p5.Phrase('box', playBox, boxPat);\n var drumPhrase = new p5.Phrase('drum', playDrum, drumPat);\n myPart = new p5.Part();\n myPart.addPhrase(boxPhrase);\n myPart.addPhrase(drumPhrase);\n myPart.setBPM(60);\n masterVolume(0.1);\n}\n\nfunction draw() {\n background(0);\n text(msg, width/2, height/2);\n}\n\nfunction playBox(time, playbackRate) {\n box.rate(playbackRate);\n box.play(time);\n}\n\nfunction playDrum(time, playbackRate) {\n drum.rate(playbackRate);\n drum.play(time);\n}\n\nfunction mouseClicked() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n myPart.start();\n msg = 'playing part';\n }\n}\n
"]},"p5.Score":{"name":"p5.Score","shortname":"p5.Score","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":8267,"description":"

A Score consists of a series of Parts. The parts will\nbe played back in order. For example, you could have an\nA part, a B part, and a C part, and play them back in this order\nnew p5.Score(a, a, b, a, c)

\n","is_constructor":1,"params":[{"name":"part(s)","description":"

One or multiple parts, to be played in sequence.

\n","type":"p5.Part"}],"return":{"description":"","type":"p5.Score"}},"p5.SoundRecorder":{"name":"p5.SoundRecorder","shortname":"p5.SoundRecorder","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":8391,"description":"

Record sounds for playback and/or to save as a .wav file.\nThe p5.SoundRecorder records all sound output from your sketch,\nor can be assigned a specific source with setInput().

\n

The record() method accepts a p5.SoundFile as a parameter.\nWhen playback is stopped (either after the given amount of time,\nor with the stop() method), the p5.SoundRecorder will send its\nrecording to that p5.SoundFile for playback.

","is_constructor":1,"example":["\n
\nvar mic, recorder, soundFile;\nvar state = 0;\n\nfunction setup() {\n background(200);\n // create an audio in\n mic = new p5.AudioIn();\n \n // prompts user to enable their browser mic\n mic.start();\n \n // create a sound recorder\n recorder = new p5.SoundRecorder();\n \n // connect the mic to the recorder\n recorder.setInput(mic);\n \n // this sound file will be used to\n // playback & save the recording\n soundFile = new p5.SoundFile();\n\n text('keyPress to record', 20, 20);\n}\n\nfunction keyPressed() {\n // make sure user enabled the mic\n if (state === 0 && mic.enabled) {\n \n // record to our p5.SoundFile\n recorder.record(soundFile);\n \n background(255,0,0);\n text('Recording!', 20, 20);\n state++;\n }\n else if (state === 1) {\n background(0,255,0);\n\n // stop recorder and\n // send result to soundFile\n recorder.stop(); \n \n text('Stopped', 20, 20);\n state++;\n }\n \n else if (state === 2) {\n soundFile.play(); // play the result!\n save(soundFile, 'mySound.wav');\n state++;\n }\n}\n
"]},"p5.PeakDetect":{"name":"p5.PeakDetect","shortname":"p5.PeakDetect","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":8675,"description":"

PeakDetect works in conjunction with p5.FFT to\nlook for onsets in some or all of the frequency spectrum.\n

\n

\nTo use p5.PeakDetect, call update in the draw loop\nand pass in a p5.FFT object.\n

\n

\nYou can listen for a specific part of the frequency spectrum by\nsetting the range between freq1 and freq2.\n

\n\n

threshold is the threshold for detecting a peak,\nscaled between 0 and 1. It is logarithmic, so 0.1 is half as loud\nas 1.0.

\n\n

\nThe update method is meant to be run in the draw loop, and\nframes determines how many loops must pass before\nanother peak can be detected.\nFor example, if the frameRate() = 60, you could detect the beat of a\n120 beat-per-minute song with this equation:\n framesPerPeak = 60 / (estimatedBPM / 60 );\n

\n\n

\nBased on example contribtued by @b2renger, and a simple beat detection\nexplanation by a\nhref="http://www.airtightinteractive.com/2013/10/making-audio-reactive-visuals/"\ntarget="_blank"Felix Turner.\n

","is_constructor":1,"params":[{"name":"freq1","description":"

lowFrequency - defaults to 20Hz

\n","type":"Number","optional":true},{"name":"freq2","description":"

highFrequency - defaults to 20000 Hz

\n","type":"Number","optional":true},{"name":"threshold","description":"

Threshold for detecting a beat between 0 and 1\n scaled logarithmically where 0.1 is 1/2 the loudness\n of 1.0. Defaults to 0.35.

\n","type":"Number","optional":true},{"name":"framesPerPeak","description":"

Defaults to 20.

\n","type":"Number","optional":true}],"example":["\n
\n\nvar cnv, soundFile, fft, peakDetect;\nvar ellipseWidth = 10;\n\nfunction setup() {\n background(0);\n noStroke();\n fill(255);\n textAlign(CENTER);\n\n soundFile = loadSound('assets/beat.mp3');\n\n // p5.PeakDetect requires a p5.FFT\n fft = new p5.FFT();\n peakDetect = new p5.PeakDetect();\n\n}\n\nfunction draw() {\n background(0);\n text('click to play/pause', width/2, height/2);\n\n // peakDetect accepts an fft post-analysis\n fft.analyze();\n peakDetect.update(fft);\n\n if ( peakDetect.isDetected ) {\n ellipseWidth = 50;\n } else {\n ellipseWidth *= 0.95;\n }\n\n ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n}\n\n// toggle play/stop when canvas is clicked\nfunction mouseClicked() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n if (soundFile.isPlaying() ) {\n soundFile.stop();\n } else {\n soundFile.play();\n }\n }\n}\n
"]},"p5.Gain":{"name":"p5.Gain","shortname":"p5.Gain","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib/addons/p5.sound.js","line":8897,"description":"

A gain node is usefull to set the relative volume of sound.\nIt's typically used to build mixers.

\n","is_constructor":1,"example":["\n
\n\n // load two soundfile and crossfade beetween them\n var sound1,sound2;\n var gain1, gain2, gain3;\n \n function preload(){\n soundFormats('ogg', 'mp3');\n sound1 = loadSound('../_files/Damscray_-_Dancing_Tiger_01');\n sound2 = loadSound('../_files/beat.mp3');\n }\n\n function setup() {\n createCanvas(400,200);\n\n // create a 'master' gain to which we will connect both soundfiles\n gain3 = new p5.Gain();\n gain3.connect();\n\n // setup first sound for playing\n sound1.rate(1);\n sound1.loop();\n sound1.disconnect(); // diconnect from p5 output\n\n gain1 = new p5.Gain(); // setup a gain node\n gain1.setInput(sound1); // connect the first sound to its input\n gain1.connect(gain3); // connect its output to the 'master'\n\n sound2.rate(1);\n sound2.disconnect();\n sound2.loop();\n\n gain2 = new p5.Gain();\n gain2.setInput(sound2);\n gain2.connect(gain3);\n\n }\n\n function draw(){\n background(180);\n\n // calculate the horizontal distance beetween the mouse and the right of the screen\n var d = dist(mouseX,0,width,0);\n\n // map the horizontal position of the mouse to values useable for volume control of sound1\n var vol1 = map(mouseX,0,width,0,1); \n var vol2 = 1-vol1; // when sound1 is loud, sound2 is quiet and vice versa\n\n gain1.amp(vol1,0.5,0);\n gain2.amp(vol2,0.5,0);\n\n // map the vertical position of the mouse to values useable for 'master volume control'\n var vol3 = map(mouseY,0,height,0,1); \n gain3.amp(vol3,0.5,0);\n }\n
\n"]}},"classitems":[{"file":"src/color/color_conversion.js","line":1,"description":"

module Conversion\nsubmodule Color Conversion

\n","requires":["core"],"class":"p5"},{"file":"src/color/color_conversion.js","line":10,"description":"

Conversions adapted from http://www.easyrgb.com/math.html.

\n

In these functions, hue is always in the range [0,1); all other components\nare in the range [0,1]. 'Brightness' and 'value' are used interchangeably.

\n","class":"p5"},{"file":"src/color/color_conversion.js","line":20,"description":"

Convert an HSBA array to HSLA.

\n","class":"p5"},{"file":"src/color/color_conversion.js","line":46,"description":"

Convert an HSBA array to RGBA.

\n","class":"p5"},{"file":"src/color/color_conversion.js","line":95,"description":"

Convert an HSLA array to HSBA.

\n","class":"p5"},{"file":"src/color/color_conversion.js","line":118,"description":"

Convert an HSLA array to RGBA.

\n

We need to change basis from HSLA to something that can be more easily be\nprojected onto RGBA. We will choose hue and brightness as our first two\ncomponents, and pick a convenient third one ('zest') so that we don't need\nto calculate formal HSBA saturation.

\n","class":"p5"},{"file":"src/color/color_conversion.js","line":176,"description":"

Convert an RGBA array to HSBA.

\n","class":"p5"},{"file":"src/color/color_conversion.js","line":211,"description":"

Convert an RGBA array to HSLA.

\n","class":"p5"},{"file":"src/color/creating_reading.js","line":15,"description":"

Extracts the alpha value from a color or pixel array.

\n","itemtype":"method","name":"alpha","params":[{"name":"obj","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nnoStroke();\nc = color(0, 126, 255, 102);\nfill(c);\nrect(15, 15, 35, 70);\nvalue = alpha(c); // Sets 'value' to 102\nfill(value);\nrect(50, 15, 35, 70);\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":41,"description":"

Extracts the blue value from a color or pixel array.

\n","itemtype":"method","name":"blue","params":[{"name":"obj","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nc = color(175, 100, 220); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(15, 20, 35, 60); // Draw left rectangle\n\nblueValue = blue(c); // Get blue in 'c'\nprintln(blueValue); // Prints \"220.0\"\nfill(0, 0, blueValue); // Use 'blueValue' in new fill\nrect(50, 20, 35, 60); // Draw right rectangle\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":68,"description":"

Extracts the HSB brightness value from a color or pixel array.

\n","itemtype":"method","name":"brightness","params":[{"name":"color","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nnoStroke();\ncolorMode(HSB, 255);\nc = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\nvalue = brightness(c); // Sets 'value' to 255\nfill(value);\nrect(50, 20, 35, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":95,"description":"

Creates colors for storing in variables of the color datatype. The\nparameters are interpreted as RGB or HSB values depending on the\ncurrent colorMode(). The default mode is RGB values from 0 to 255\nand, therefore, the function call color(255, 204, 0) will return a\nbright yellow color.\n

\nNote that if only one value is provided to color(), it will be interpreted\nas a grayscale value. Add a second value, and it will be used for alpha\ntransparency. When three values are specified, they are interpreted as\neither RGB or HSB values. Adding a fourth value applies alpha\ntransparency. If a single string parameter is provided it will be\ninterpreted as a CSS-compatible color string.

\n

Colors are stored as Numbers or Arrays.

\n","itemtype":"method","name":"color","return":{"description":"resulting color","type":"Array"},"alt":"This is alt text for example 1.\nThis is alt text for example 2.\nThis is alt text for example 3.","example":["\n
\n\nvar c = color(255, 204, 0); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nnoStroke(); // Don't draw a stroke around shapes\nrect(30, 20, 55, 55); // Draw rectangle\n\n
\n\n
\n\nvar c = color(255, 204, 0); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nnoStroke(); // Don't draw a stroke around shapes\nellipse(25, 25, 80, 80); // Draw left circle\n\n// Using only one value with color()\n// generates a grayscale value.\nvar c = color(65); // Update 'c' with grayscale value\nfill(c); // Use updated 'c' as fill color\nellipse(75, 75, 80, 80); // Draw right circle\n\n
\n\n
\n\n// Named SVG & CSS colors may be used,\nvar c = color('magenta');\nfill(c); // Use 'c' as fill color\nnoStroke(); // Don't draw a stroke around shapes\nrect(20, 20, 60, 60); // Draw rectangle\n\n
\n\n
\n\n// as can hex color codes:\nnoStroke(); // Don't draw a stroke around shapes\nvar c = color('#0f0');\nfill(c); // Use 'c' as fill color\nrect(0, 10, 45, 80); // Draw rectangle\n\nc = color('#00ff00');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw rectangle\n\n
\n\n
\n\n// RGB and RGBA color strings are also supported:\n// these all set to the same color (solid blue)\nvar c;\nnoStroke(); // Don't draw a stroke around shapes\nc = color('rgb(0,0,255)');\nfill(c); // Use 'c' as fill color\nrect(10, 10, 35, 35); // Draw rectangle\n\nc = color('rgb(0%, 0%, 100%)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 35, 35); // Draw rectangle\n\nc = color('rgba(0, 0, 255, 1)');\nfill(c); // Use updated 'c' as fill color\nrect(10, 55, 35, 35); // Draw rectangle\n\nc = color('rgba(0%, 0%, 100%, 1)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 55, 35, 35); // Draw rectangle\n\n
\n\n
\n\n// HSL color is also supported and can be specified\n// by value\nvar c;\nnoStroke(); // Don't draw a stroke around shapes\nc = color('hsl(160, 100%, 50%)');\nfill(c); // Use 'c' as fill color\nrect(0, 10, 45, 80); // Draw rectangle\n\nc = color('hsla(160, 100%, 50%, 0.5)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw rectangle\n\n
\n\n
\n\n// HSB color is also supported and can be specified\n// by value\nvar c;\nnoStroke(); // Don't draw a stroke around shapes\nc = color('hsb(160, 100%, 50%)');\nfill(c); // Use 'c' as fill color\nrect(0, 10, 45, 80); // Draw rectangle\n\nc = color('hsba(160, 100%, 50%, 0.5)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw rectangle\n\n
\n\n
\n\nvar c; // Declare color 'c'\nnoStroke(); // Don't draw a stroke around shapes\n\n// If no colorMode is specified, then the\n// default of RGB with scale of 0-255 is used.\nc = color(50, 55, 100); // Create a color for 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(0, 10, 45, 80); // Draw left rect\n\ncolorMode(HSB, 100); // Use HSB with scale of 0-100\nc = color(50, 55, 100); // Update 'c' with new color\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw right rect\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading","overloads":[{"line":95,"params":[{"name":"gray","description":"

number specifying value between white\n and black.

\n","type":"Number|String"},{"name":"alpha","description":"

alpha value relative to current color range\n (default is 0-100)

\n","type":"Number","optional":true}]},{"line":246,"params":[{"name":"v1","description":"

red or hue value relative to\n the current color range, or a color string

\n","type":"Number|String"},{"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}]}]},{"file":"src/color/creating_reading.js","line":275,"description":"

Extracts the green value from a color or pixel array.

\n","itemtype":"method","name":"green","params":[{"name":"color","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nc = color(20, 75, 200); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(15, 20, 35, 60); // Draw left rectangle\n\ngreenValue = green(c); // Get green in 'c'\nprintln(greenValue); // Print \"75.0\"\nfill(0, greenValue, 0); // Use 'greenValue' in new fill\nrect(50, 20, 35, 60); // Draw right rectangle\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":302,"description":"

Extracts the hue value from a color or pixel array.

\n

Hue exists in both HSB and HSL. This function will return the\nHSB-normalized hue when supplied with an HSB color object (or when supplied\nwith a pixel array while the color mode is HSB), but will default to the\nHSL-normalized hue otherwise. (The values will only be different if the\nmaximum hue setting for each system is different.)

\n","itemtype":"method","name":"hue","params":[{"name":"color","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nnoStroke();\ncolorMode(HSB, 255);\nc = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\nvalue = hue(c); // Sets 'value' to \"0\"\nfill(value);\nrect(50, 20, 35, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":335,"description":"

Blends two colors to find a third color somewhere between them. The amt\nparameter is the amount to interpolate between the two values where 0.0\nequal to the first color, 0.1 is very near the first color, 0.5 is halfway\nin between, etc. An amount below 0 will be treated as 0. Likewise, amounts\nabove 1 will be capped at 1. This is different from the behavior of lerp(),\nbut necessary because otherwise numbers outside the range will produce\nstrange and unexpected colors.\n

\nThe way that colours are interpolated depends on the current color mode.

\n","itemtype":"method","name":"lerpColor","params":[{"name":"c1","description":"

interpolate from this color

\n","type":"Array/Number"},{"name":"c2","description":"

interpolate to this color

\n","type":"Array/Number"},{"name":"amt","description":"

number between 0 and 1

\n","type":"Number"}],"return":{"description":"interpolated color","type":"Array/Number"},"example":["\n
\n\ncolorMode(RGB);\nstroke(255);\nbackground(51);\nfrom = color(218, 165, 32);\nto = color(72, 61, 139);\ncolorMode(RGB); // Try changing to HSB.\ninterA = lerpColor(from, to, .33);\ninterB = lerpColor(from, to, .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);\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":418,"description":"

Extracts the HSL lightness value from a color or pixel array.

\n","itemtype":"method","name":"lightness","params":[{"name":"color","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nnoStroke();\ncolorMode(HSL);\nc = color(156, 100, 50, 1);\nfill(c);\nrect(15, 20, 35, 60);\nvalue = lightness(c); // Sets 'value' to 50\nfill(value);\nrect(50, 20, 35, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":445,"description":"

Extracts the red value from a color or pixel array.

\n","itemtype":"method","name":"red","params":[{"name":"obj","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nc = color(255, 204, 0); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(15, 20, 35, 60); // Draw left rectangle\n\nredValue = red(c); // Get red in 'c'\nprintln(redValue); // Print \"255.0\"\nfill(redValue, 0, 0); // Use 'redValue' in new fill\nrect(50, 20, 35, 60); // Draw right rectangle\n\n
\n\n
\n\ncolorMode(RGB, 255);\nvar c = color(127, 255, 0);\ncolorMode(RGB, 1);\nvar myColor = red(c);\nprintln(myColor);\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/creating_reading.js","line":482,"description":"

Extracts the saturation value from a color or pixel array.

\n

Saturation is scaled differently in HSB and HSL. This function will return\nthe HSB saturation when supplied with an HSB color object (or when supplied\nwith a pixel array while the color mode is HSB), but will default to the\nHSL saturation otherwise.

\n","itemtype":"method","name":"saturation","params":[{"name":"color","description":"

p5.Color object or pixel array

\n","type":"Object"}],"example":["\n
\n\nnoStroke();\ncolorMode(HSB, 255);\nc = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\nvalue = saturation(c); // Sets 'value' to 126\nfill(value);\nrect(50, 20, 35, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/p5.Color.js","line":79,"description":"

Hue is the same in HSB and HSL, but the maximum value may be different.\nThis function will return the HSB-normalized saturation when supplied with\nan HSB color object, but will default to the HSL-normalized saturation\notherwise.

\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/p5.Color.js","line":110,"description":"

Saturation is scaled differently in HSB and HSL. This function will return\nthe HSB saturation when supplied with an HSB color object, but will default\nto the HSL saturation otherwise.

\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/p5.Color.js","line":129,"description":"

CSS named colors.

\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/p5.Color.js","line":282,"description":"

These 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.

\n

Note that RGB values of .9 are not parsed by IE, but are supported here for\ncolor string consistency.

\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/p5.Color.js","line":295,"description":"

Full color string patterns. The capture groups are necessary.

\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/p5.Color.js","line":402,"description":"

For a number of different inputs, returns a color formatted as [r, g, b, a]\narrays, with each component normalized between 0 and 1.

\n","params":[{"name":"args","description":"

An 'array-like' object that represents a list of\n arguments

\n","type":"Array-like"}],"return":{"description":"a color formatted as [r, g, b, a]\n Example:\n input ==> output\n g ==> [g, g, g, 255]\n g,a ==> [g, g, g, a]\n r, g, b ==> [r, g, b, 255]\n r, g, b, a ==> [r, g, b, a]\n [g] ==> [g, g, g, 255]\n [g, a] ==> [g, g, g, a]\n [r, g, b] ==> [r, g, b, 255]\n [r, g, b, a] ==> [r, g, b, a]","type":"Array"},"example":["\n
\n\n// todo\n\n
"],"class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/p5.Color.js","line":572,"description":"

For HSB and HSL, interpret the gray level as a brightness/lightness\nvalue (they are equivalent when chroma is zero). For RGB, normalize the\ngray level according to the blue maximum.

\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src/color/setting.js","line":15,"description":"

The background() function sets the color used for the background of the\np5.js canvas. The default background is light gray. This function is\ntypically used within draw() to clear the display window at the beginning\nof each frame, but it can be used inside setup() to set the background on\nthe first frame of animation or if the background need only be set once.

\n","itemtype":"method","name":"background","example":["\n
\n\n// Grayscale integer value\nbackground(51);\n\n
\n\n
\n\n// R, G & B integer values\nbackground(255, 204, 0);\n\n
\n\n
\n\n// H, S & B integer values\ncolorMode(HSB);\nbackground(255, 204, 100);\n\n
\n\n
\n\n// Named SVG/CSS color string\nbackground('red');\n\n
\n\n
\n\n// three-digit hexadecimal RGB notation\nbackground('#fae');\n\n
\n\n
\n\n// six-digit hexadecimal RGB notation\nbackground('#222222');\n\n
\n\n
\n\n// integer RGB notation\nbackground('rgb(0,255,0)');\n\n
\n\n
\n\n// integer RGBA notation\nbackground('rgba(0,255,0, 0.25)');\n\n
\n\n
\n\n// percentage RGB notation\nbackground('rgb(100%,0%,10%)');\n\n
\n\n
\n\n// percentage RGBA notation\nbackground('rgba(100%,0%,100%,0.5)');\n\n
\n\n
\n\n// p5 Color object\nbackground(color(0, 0, 255));\n\n
"],"class":"p5","module":"Color","submodule":"Setting","overloads":[{"line":15,"params":[{"name":"color","description":"

any value created by the color() function

\n","type":"p5.Color"},{"name":"a","description":"

opacity of the background relative to current\n color range (default is 0-100)

\n","type":"Number","optional":true}]},{"line":107,"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":"","type":"Number","optional":true}]},{"line":115,"params":[{"name":"gray","description":"

specifies a value between white and black

\n","type":"Number"},{"name":"a","description":"","type":"Number","optional":true}]},{"line":121,"params":[{"name":"v1","description":"

red or hue value (depending on the current color\n mode)

\n","type":"Number"},{"name":"v2","description":"

green or saturation value (depending on the current\n color mode)

\n","type":"Number"},{"name":"v3","description":"

blue or brightness value (depending on the current\n color mode)

\n","type":"Number"},{"name":"a","description":"","type":"Number","optional":true}]},{"line":132,"params":[{"name":"image","description":"

image created with loadImage() 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}]}]},{"file":"src/color/setting.js","line":148,"description":"

Clears the pixels within a buffer. This function only works on p5.Canvas\nobjects created with the createCanvas() function; it won't work with the\nmain display window. Unlike the main graphics context, pixels in\nadditional graphics areas created with createGraphics() can be entirely\nor partially transparent. This function clears everything to make all of\nthe pixels 100% transparent.

\n","itemtype":"method","name":"clear","example":["\n
\n\n// Clear the screen on mouse press.\nfunction setup() {\n createCanvas(100, 100);\n}\n\nfunction draw() {\n ellipse(mouseX, mouseY, 20, 20);\n}\n\nfunction mousePressed() {\n clear();\n}\n\n
"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src/color/setting.js","line":180,"description":"

colorMode() changes the way p5.js interprets color data. By default, the\nparameters for fill(), stroke(), background(), and color() are defined by\nvalues between 0 and 255 using the RGB color model. This is equivalent to\nsetting colorMode(RGB, 255). Setting colorMode(HSB) lets you use the HSB\nsystem instead. By default, this is colorMode(HSB, 360, 100, 100, 1). You\ncan also use HSL.\n

\nNote: existing color objects remember the mode that they were created in,\nso you can change modes as you like without affecting their appearance.

\n","itemtype":"method","name":"colorMode","params":[{"name":"mode","description":"

either RGB or HSB, corresponding to\n Red/Green/Blue and Hue/Saturation/Brightness\n (or Lightness)

\n","type":"Constant"},{"name":"max1","description":"

range for the red or hue depending on the\n current color mode, or range for all values

\n","type":"Number","optional":true},{"name":"max2","description":"

range for the green or saturation depending\n on the current color mode

\n","type":"Number","optional":true},{"name":"max3","description":"

range for the blue or brightness/lighntess\n depending on the current color mode

\n","type":"Number","optional":true},{"name":"maxA","description":"

range for the alpha

\n","type":"Number","optional":true}],"example":["\n
\n\nnoStroke();\ncolorMode(RGB, 100);\nfor (i = 0; i < 100; i++) {\n for (j = 0; j < 100; j++) {\n stroke(i, j, 0);\n point(i, j);\n }\n}\n\n
\n\n
\n\nnoStroke();\ncolorMode(HSB, 100);\nfor (i = 0; i < 100; i++) {\n for (j = 0; j < 100; j++) {\n stroke(i, j, 100);\n point(i, j);\n }\n}\n\n
\n\n
\n\ncolorMode(RGB, 255);\nvar c = color(127, 255, 0);\n\ncolorMode(RGB, 1);\nvar myColor = c._getRed();\ntext(myColor, 10, 10, 80, 80);\n\n
\n\n
\n\nnoFill();\ncolorMode(RGB, 255, 255, 255, 1);\nbackground(255);\n\nstrokeWeight(4);\nstroke(255, 0 , 10, 0.3);\nellipse(40, 40, 50, 50);\nellipse(50, 50, 40, 40);\n\n
"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src/color/setting.js","line":283,"description":"

Sets the color used to fill shapes. For example, if you run\nfill(204, 102, 0), all subsequent shapes will be filled with orange. This\ncolor is either specified in terms of the RGB or HSB color depending on\nthe current colorMode(). (The default color space is RGB, with each value\nin the range from 0 to 255).\n

\nIf a single string argument is provided, RGB, RGBA and Hex CSS color strings\nand all named color strings are supported. A p5 Color object can also be\nprovided to set the fill color.

\n","itemtype":"method","name":"fill","params":[{"name":"v1","description":"

gray value, red or hue value\n (depending on the current color\n mode), or color Array, or CSS\n color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

green or saturation value\n (depending on the current\n color mode)

\n","type":"Number","optional":true},{"name":"v3","description":"

blue or brightness value\n (depending on the current\n color mode)

\n","type":"Number","optional":true},{"name":"a","description":"

opacity of the background

\n","type":"Number","optional":true}],"example":["\n
\n\n// Grayscale integer value\nfill(51);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// R, G & B integer values\nfill(255, 204, 0);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// H, S & B integer values\ncolorMode(HSB);\nfill(255, 204, 100);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// Named SVG/CSS color string\nfill('red');\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// three-digit hexadecimal RGB notation\nfill('#fae');\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// six-digit hexadecimal RGB notation\nfill('#222222');\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// integer RGB notation\nfill('rgb(0,255,0)');\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// integer RGBA notation\nfill('rgba(0,255,0, 0.25)');\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// percentage RGB notation\nfill('rgb(100%,0%,10%)');\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// percentage RGBA notation\nfill('rgba(100%,0%,100%,0.5)');\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// p5 Color object\nfill(color(0, 0, 255));\nrect(20, 20, 60, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src/color/setting.js","line":404,"description":"

Disables filling geometry. If both noStroke() and noFill() are called,\nnothing will be drawn to the screen.

\n","itemtype":"method","name":"noFill","example":["\n
\n\nrect(15, 10, 55, 55);\nnoFill();\nrect(20, 20, 60, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src/color/setting.js","line":423,"description":"

Disables drawing the stroke (outline). If both noStroke() and noFill()\nare called, nothing will be drawn to the screen.

\n","itemtype":"method","name":"noStroke","example":["\n
\n\nnoStroke();\nrect(20, 20, 60, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src/color/setting.js","line":441,"description":"

Sets the color used to draw lines and borders around shapes. This color\nis either specified in terms of the RGB or HSB color depending on the\ncurrent colorMode() (the default color space is RGB, with each value in\nthe range from 0 to 255).\n

\nIf a single string argument is provided, RGB, RGBA and Hex CSS color\nstrings and all named color strings are supported. A p5 Color object\ncan also be provided to set the stroke color.

\n","itemtype":"method","name":"stroke","params":[{"name":"v1","description":"

gray value, red or hue value\n (depending on the current color\n mode), or color Array, or CSS\n color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

green or saturation value\n (depending on the current\n color mode)

\n","type":"Number","optional":true},{"name":"v3","description":"

blue or brightness value\n (depending on the current\n color mode)

\n","type":"Number","optional":true},{"name":"a","description":"

opacity of the background

\n","type":"Number","optional":true}],"example":["\n
\n\n// Grayscale integer value\nstrokeWeight(4);\nstroke(51);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// R, G & B integer values\nstroke(255, 204, 0);\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// H, S & B integer values\ncolorMode(HSB);\nstrokeWeight(4);\nstroke(255, 204, 100);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// Named SVG/CSS color string\nstroke('red');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// three-digit hexadecimal RGB notation\nstroke('#fae');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// six-digit hexadecimal RGB notation\nstroke('#222222');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// integer RGB notation\nstroke('rgb(0,255,0)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// integer RGBA notation\nstroke('rgba(0,255,0,0.25)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// percentage RGB notation\nstroke('rgb(100%,0%,10%)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// percentage RGBA notation\nstroke('rgba(100%,0%,100%,0.5)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
\n\n
\n\n// p5 Color object\nstroke(color(0, 0, 255));\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n\n
"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src/core/2d_primitives.js","line":16,"description":"

Draw an arc to the screen. If called with only a, b, c, d, start, and\nstop, the arc will be drawn as an open pie. If mode is provided, the arc\nwill be drawn either open, as a chord, or as a pie as specified. The\norigin may be changed with the ellipseMode() function.

\nNote that drawing a full circle (ex: 0 to TWO_PI) will appear blank\nbecause 0 and TWO_PI are the same position on the unit circle. The\nbest way to handle this is by using the ellipse() function instead\nto create a closed ellipse, and to use the arc() function\nonly to draw parts of an ellipse.

\n","itemtype":"method","name":"arc","params":[{"name":"a","description":"

x-coordinate of the arc's ellipse

\n","type":"Number"},{"name":"b","description":"

y-coordinate of the arc's ellipse

\n","type":"Number"},{"name":"c","description":"

width of the arc's ellipse by default

\n","type":"Number"},{"name":"d","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

\n","type":"Constant","optional":true}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\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);\n\n
\n\n
\n\narc(50, 50, 80, 80, 0, PI+QUARTER_PI, OPEN);\n\n
\n\n
\n\narc(50, 50, 80, 80, 0, PI+QUARTER_PI, CHORD);\n\n
\n\n
\n\narc(50, 50, 80, 80, 0, PI+QUARTER_PI, PIE);\n\n
"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src/core/2d_primitives.js","line":123,"description":"

Draws an ellipse (oval) to the screen. An ellipse with equal width and\nheight is a circle. By default, the first two parameters set the location,\nand the third and fourth parameters set the shape's width and height. If\nno height is specified, the value of width is used for both the width and\nheight. The origin may be changed with the ellipseMode() function.

\n","itemtype":"method","name":"ellipse","return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nellipse(56, 46, 55, 55);\n\n
"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":123,"params":[{"name":"x","description":"

x-coordinate of the ellipse.

\n","type":"Number"},{"name":"y","description":"

y-coordinate 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}]},{"line":143,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"w","description":"","type":"Number"},{"name":"h","description":"","type":"Number","optional":true}]}]},{"file":"src/core/2d_primitives.js","line":179,"description":"

Draws a line (a direct path between two points) to the screen. The version\nof line() with four parameters draws the line in 2D. To color a line, use\nthe stroke() function. A line cannot be filled, therefore the fill()\nfunction will not affect the color of a line. 2D lines are drawn with a\nwidth of one pixel by default, but this can be changed with the\nstrokeWeight() function.

\n","itemtype":"method","name":"line","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"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nline(30, 20, 85, 75);\n\n
\n\n
\n\nline(30, 20, 85, 20);\nstroke(126);\nline(85, 20, 85, 75);\nstroke(255);\nline(85, 75, 30, 75);\n\n
"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src/core/2d_primitives.js","line":247,"description":"

Draws a point, a coordinate in space at the dimension of one pixel.\nThe first parameter is the horizontal value for the point, the second\nvalue is the vertical value for the point. The color of the point is\ndetermined by the current stroke.

\n","itemtype":"method","name":"point","params":[{"name":"x","description":"

the x-coordinate

\n","type":"Number"},{"name":"y","description":"

the y-coordinate

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\npoint(30, 20);\npoint(85, 20);\npoint(85, 75);\npoint(30, 75);\n\n
"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src/core/2d_primitives.js","line":292,"description":"

Draw a quad. A quad is a quadrilateral, a four sided polygon. It is\nsimilar to a rectangle, but the angles between its edges are not\nconstrained to ninety degrees. The first pair of parameters (x1,y1)\nsets the first vertex and the subsequent pairs should proceed\nclockwise or counter-clockwise around the defined shape.

\n","itemtype":"method","name":"quad","return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nquad(38, 31, 86, 20, 69, 63, 30, 76);\n\n
"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":292,"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"}]},{"line":316,"params":[{"name":"x1","description":"","type":"Number"},{"name":"y1","description":"","type":"Number"},{"name":"x2","description":"","type":"Number"},{"name":"y2","description":"","type":"Number"},{"name":"x3","description":"","type":"Number"},{"name":"y3","description":"","type":"Number"},{"name":"x4","description":"","type":"Number"},{"name":"y4","description":"","type":"Number"}]}]},{"file":"src/core/2d_primitives.js","line":366,"description":"

Draws a rectangle to the screen. A rectangle is a four-sided shape with\nevery angle at ninety degrees. By default, the first two parameters set\nthe location of the upper-left corner, the third sets the width, and the\nfourth sets the height. The way these parameters are interpreted, however,\nmay be changed with the rectMode() function.\n

\nThe fifth, sixth, seventh and eighth parameters, if specified,\ndetermine corner radius for the top-right, top-left, lower-right and\nlower-left corners, respectively. An omitted corner radius parameter is set\nto the value of the previously specified radius value in the parameter list.

\n","itemtype":"method","name":"rect","return":{"description":"the p5 object.","type":"P5"},"example":["\n
\n\n// Draw a rectangle at location (30, 20) with a width and height of 55.\nrect(30, 20, 55, 55);\n\n
\n\n
\n\n// Draw a rectangle with rounded corners, each having a radius of 20.\nrect(30, 20, 55, 55, 20);\n\n
\n\n
\n\n// Draw a rectangle with rounded corners having the following radii:\n// top-left = 20, top-right = 15, bottom-right = 10, bottom-left = 5.\nrect(30, 20, 55, 55, 20, 15, 10, 5);\n\n
"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":366,"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"},{"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}]},{"line":411,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"w","description":"","type":"Number"},{"name":"h","description":"","type":"Number"},{"name":"detailX","description":"","type":"Number","optional":true},{"name":"detailY","description":"","type":"Number","optional":true}]}]},{"file":"src/core/2d_primitives.js","line":448,"description":"

A triangle is a plane created by connecting three points. The first two\narguments specify the first point, the middle two arguments specify the\nsecond point, and the last two arguments specify the third point.

\n","itemtype":"method","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"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\ntriangle(30, 75, 58, 20, 86, 75);\n\n
"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src/core/attributes.js","line":14,"description":"

Modifies the location from which ellipses are drawn by changing the way\nin which parameters given to ellipse() are interpreted.\n

\nThe default mode is ellipseMode(CENTER), which interprets the first two\nparameters of ellipse() as the shape's center point, while the third and\nfourth parameters are its width and height.\n

\nellipseMode(RADIUS) also uses the first two parameters of ellipse() as\nthe shape's center point, but uses the third and fourth parameters to\nspecify half of the shapes's width and height.\n

\nellipseMode(CORNER) interprets the first two parameters of ellipse() as\nthe upper-left corner of the shape, while the third and fourth parameters\nare its width and height.\n

\nellipseMode(CORNERS) interprets the first two parameters of ellipse() as\nthe location of one corner of the ellipse's bounding box, and the third\nand fourth parameters as the location of the opposite corner.\n

\nThe parameter must be written in ALL CAPS because Javascript is a\ncase-sensitive language.

\n","itemtype":"method","name":"ellipseMode","params":[{"name":"mode","description":"

either CENTER, RADIUS, CORNER, or CORNERS

\n","type":"Constant"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nellipseMode(RADIUS); // Set ellipseMode to RADIUS\nfill(255); // Set fill to white\nellipse(50, 50, 30, 30); // Draw white ellipse using RADIUS mode\n\nellipseMode(CENTER); // Set ellipseMode to CENTER\nfill(100); // Set fill to gray\nellipse(50, 50, 30, 30); // Draw gray ellipse using CENTER mode\n\n
\n\n
\n\nellipseMode(CORNER); // Set ellipseMode is CORNER\nfill(255); // Set fill to white\nellipse(25, 25, 50, 50); // Draw white ellipse using CORNER mode\n\nellipseMode(CORNERS); // Set ellipseMode to CORNERS\nfill(100); // Set fill to gray\nellipse(25, 25, 50, 50); // Draw gray ellipse using CORNERS mode\n\n
"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src/core/attributes.js","line":75,"description":"

Draws all geometry with jagged (aliased) edges. Note that smooth() is\nactive by default, so it is necessary to call noSmooth() to disable\nsmoothing of geometry, images, and fonts.

\n","itemtype":"method","name":"noSmooth","return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\n\n
"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src/core/attributes.js","line":99,"description":"

Modifies the location from which rectangles are drawn by changing the way\nin which parameters given to rect() are interpreted.\n

\nThe default mode is rectMode(CORNER), which interprets the first two\nparameters of rect() as the upper-left corner of the shape, while the\nthird and fourth parameters are its width and height.\n

\nrectMode(CORNERS) interprets the first two parameters of rect() as the\nlocation of one corner, and the third and fourth parameters as the\nlocation of the opposite corner.\n

\nrectMode(CENTER) interprets the first two parameters of rect() as the\nshape's center point, while the third and fourth parameters are its\nwidth and height.\n

\nrectMode(RADIUS) also uses the first two parameters of rect() as the\nshape's center point, but uses the third and fourth parameters to specify\nhalf of the shapes's width and height.\n

\nThe parameter must be written in ALL CAPS because Javascript is a\ncase-sensitive language.

\n","itemtype":"method","name":"rectMode","params":[{"name":"mode","description":"

either CORNER, CORNERS, CENTER, or RADIUS

\n","type":"Constant"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nrectMode(CORNER); // Default rectMode is CORNER\nfill(255); // Set fill to white\nrect(25, 25, 50, 50); // Draw white rect using CORNER mode\n\nrectMode(CORNERS); // Set rectMode to CORNERS\nfill(100); // Set fill to gray\nrect(25, 25, 50, 50); // Draw gray rect using CORNERS mode\n\n
\n\n
\n\nrectMode(RADIUS); // Set rectMode to RADIUS\nfill(255); // Set fill to white\nrect(50, 50, 30, 30); // Draw white rect using RADIUS mode\n\nrectMode(CENTER); // Set rectMode to CENTER\nfill(100); // Set fill to gray\nrect(50, 50, 30, 30); // Draw gray rect using CENTER mode\n\n
"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src/core/attributes.js","line":160,"description":"

Draws all geometry with smooth (anti-aliased) edges. smooth() will also\nimprove image quality of resized images. Note that smooth() is active by\ndefault; noSmooth() can be used to disable smoothing of geometry,\nimages, and fonts.

\n","itemtype":"method","name":"smooth","return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\n\n
"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src/core/attributes.js","line":185,"description":"

Sets the style for rendering line endings. These ends are either squared,\nextended, or rounded, each of which specified with the corresponding\nparameters: SQUARE, PROJECT, and ROUND. The default cap is ROUND.

\n","itemtype":"method","name":"strokeCap","params":[{"name":"cap","description":"

either SQUARE, PROJECT, or ROUND

\n","type":"Number/Constant"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nstrokeWeight(12.0);\nstrokeCap(ROUND);\nline(20, 30, 80, 30);\nstrokeCap(SQUARE);\nline(20, 50, 80, 50);\nstrokeCap(PROJECT);\nline(20, 70, 80, 70);\n\n
"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src/core/attributes.js","line":215,"description":"

Sets the style of the joints which connect line segments. These joints\nare either mitered, beveled, or rounded and specified with the\ncorresponding parameters MITER, BEVEL, and ROUND. The default joint is\nMITER.

\n","itemtype":"method","name":"strokeJoin","params":[{"name":"join","description":"

either MITER, BEVEL, ROUND

\n","type":"Number/Constant"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(MITER);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n\n
\n\n
\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(BEVEL);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n\n
\n\n
\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(ROUND);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n\n
"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src/core/attributes.js","line":273,"description":"

Sets the width of the stroke used for lines, points, and the border\naround shapes. All widths are set in units of pixels.

\n","itemtype":"method","name":"strokeWeight","params":[{"name":"weight","description":"

the weight (in pixels) of the stroke

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nstrokeWeight(1); // Default\nline(20, 20, 80, 20);\nstrokeWeight(4); // Thicker\nline(20, 40, 80, 40);\nstrokeWeight(10); // Beastly\nline(20, 70, 80, 70);\n\n
"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src/core/canvas.js","line":1,"requires":["constants"],"class":"p5","module":"Shape"},{"file":"src/core/constants.js","line":25,"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().

\n","itemtype":"property","name":"HALF_PI","example":["\n
\narc(50, 50, 80, 80, 0, HALF_PI);\n
\n"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src/core/constants.js","line":40,"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().

\n","itemtype":"property","name":"PI","example":["\n
\narc(50, 50, 80, 80, 0, PI);\n
"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src/core/constants.js","line":54,"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().

\n","itemtype":"property","name":"QUARTER_PI","example":["\n
\narc(50, 50, 80, 80, 0, QUARTER_PI);\n
\n"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src/core/constants.js","line":69,"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().

\n","itemtype":"property","name":"TAU","example":["\n
\narc(50, 50, 80, 80, 0, TAU);\n
\n"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src/core/constants.js","line":84,"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().

\n","itemtype":"property","name":"TWO_PI","example":["\n
\narc(50, 50, 80, 80, 0, TWO_PI);\n
\n"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src/core/core.js","line":15,"description":"

This is the p5 instance constructor.

\n

A 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(), setup(), and/or\ndraw() properties on it for running a sketch.

\n

A 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","params":[{"name":"sketch","description":"

a closure that can set optional preload(),\n setup(), and/or draw() properties on the\n given p5 instance

\n","type":"Function"},{"name":"node","description":"

element to attach canvas to, if a\n boolean is passed in use it as sync

\n","type":"HTMLElement|boolean","optional":true},{"name":"sync","description":"

start synchronously (optional)

\n","type":"Boolean","optional":true}],"return":{"description":"a p5 instance","type":"P5"},"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/core.js","line":49,"description":"

Called directly before setup(), the preload() function is used to handle\nasynchronous loading of external files. If a preload function is\ndefined, setup() will wait until any load calls within have finished.\nNothing besides load calls should be inside preload (loadImage,\nloadJSON, loadFont, loadStrings, etc).

\n","itemtype":"method","name":"preload","example":["\n
\nvar img;\nvar c;\nfunction preload() { // preload() runs once\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() { // 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
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/core.js","line":78,"description":"

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.\n

\nNote: Variables declared within setup() are not accessible within other\nfunctions, including draw().

\n","itemtype":"method","name":"setup","example":["\n
\nvar 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
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/core.js","line":105,"description":"

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.\n

\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.\n

\nThe number of times draw() executes in each second may be controlled with\nthe frameRate() function.\n

\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.\n

\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","itemtype":"method","name":"draw","example":["\n
\nvar yPos = 0;\nfunction setup() { // setup() runs once\n frameRate(30);\n}\nfunction draw() { // 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
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/core.js","line":375,"description":"

Removes the entire p5 sketch. This will remove the canvas and any\nelements created by p5.js. It will also stop the draw loop and unbind\nany properties or methods from the window global scope. It will\nleave a variable p5 in case you wanted to create a new p5 sketch.\nIf you like, you can set p5 = null to erase it.

\n","itemtype":"method","name":"remove","example":["\n
\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/curves.js","line":17,"description":"

Draws 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.

Bezier curves were developed by French\nautomotive engineer Pierre Bezier, and are commonly used in computer\ngraphics to define gently sloping curves. See also curve().

\n","itemtype":"method","name":"bezier","return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\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
"],"class":"p5","module":"Shape","submodule":"Curves","overloads":[{"line":17,"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"}]},{"line":50,"params":[{"name":"z1","description":"

z-coordinate for the first anchor point

\n","type":"Number"},{"name":"z2","description":"

z-coordinate for the first control point

\n","type":"Number"},{"name":"z3","description":"

z-coordinate for the first anchor point

\n","type":"Number"},{"name":"z4","description":"

z-coordinate for the first control point

\n","type":"Number"}]}]},{"file":"src/core/curves.js","line":106,"description":"

Sets the resolution at which Beziers display.

\n

The default value is 20.

\n","params":[{"name":"detail","description":"

resolution of the curves

\n","type":"Number"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\nbackground(204);\nbezierDetail(50);\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\n\n
"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src/core/curves.js","line":127,"description":"

Evaluates the Bezier at position t for points a, b, c, d.\nThe parameters a and d are the first and last points\non the curve, and b and c are the control points.\nThe final parameter t varies between 0 and 1.\nThis can be done once with the x coordinates and a second time\nwith the y coordinates to get the location of a bezier curve at t.

\n","itemtype":"method","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"}],"return":{"description":"the value of the Bezier at position t","type":"Number"},"example":["\n
\n\nnoFill();\nx1 = 85, x2 = 10, x3 = 90, x4 = 15;\ny1 = 20, y2 = 10, y3 = 90, y4 = 80;\nbezier(x1, y1, x2, y2, x3, y3, x4, y4);\nfill(255);\nsteps = 10;\nfor (i = 0; i <= steps; i++) {\n t = i / steps;\n x = bezierPoint(x1, x2, x3, x4, t);\n y = bezierPoint(y1, y2, y3, y4, t);\n ellipse(x, y, 5, 5);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src/core/curves.js","line":168,"description":"

Evaluates the tangent to the Bezier at position t for points a, b, c, d.\nThe parameters a and d are the first and last points\non the curve, and b and c are the control points.\nThe final parameter t varies between 0 and 1.

\n","itemtype":"method","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"}],"return":{"description":"the tangent at position t","type":"Number"},"example":["\n
\n\nnoFill();\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\nsteps = 6;\nfill(255);\nfor (i = 0; i <= steps; i++) {\n t = i / steps;\n // Get the location of the point\n x = bezierPoint(85, 10, 90, 15, t);\n y = bezierPoint(20, 10, 90, 80, t);\n // Get the tangent points\n tx = bezierTangent(85, 10, 90, 15, t);\n ty = bezierTangent(20, 10, 90, 80, t);\n // Calculate an angle from the tangent points\n 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
\n\n
\n\nnoFill();\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\nstroke(255, 102, 0);\nsteps = 16;\nfor (i = 0; i <= steps; i++) {\n t = i / steps;\n x = bezierPoint(85, 10, 90, 15, t);\n y = bezierPoint(20, 10, 90, 80, t);\n tx = bezierTangent(85, 10, 90, 15, t);\n ty = bezierTangent(20, 10, 90, 80, t);\n a = atan2(ty, tx);\n a -= HALF_PI;\n line(x, y, cos(a)*8 + x, sin(a)*8 + y);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src/core/curves.js","line":239,"description":"

Draws a curved line on the screen between two points, given as the\nmiddle four parameters. The first two parameters are a control point, as\nif the curve came from this point even though it's not drawn. The last\ntwo parameters similarly describe the other control point.

\nLonger curves can be created by putting a series of curve() functions\ntogether or using curveVertex(). An additional function called\ncurveTightness() provides control for the visual quality of the curve.\nThe curve() function is an implementation of Catmull-Rom splines.

\n","itemtype":"method","name":"curve","return":{"description":"the p5 object","type":"Object"},"example":["\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
\n\n// Define the curve points as JavaScript objects\np1 = {x: 5, y: 26}, p2 = {x: 73, y: 24}\np3 = {x: 73, y: 61}, 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
"],"class":"p5","module":"Shape","submodule":"Curves","overloads":[{"line":239,"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"}]},{"line":286,"params":[{"name":"z1","description":"

z-coordinate for the beginning control point

\n","type":"Number"},{"name":"z2","description":"

z-coordinate for the first point

\n","type":"Number"},{"name":"z3","description":"

z-coordinate for the second point

\n","type":"Number"},{"name":"z4","description":"

z-coordinate for the ending control point

\n","type":"Number"}]}]},{"file":"src/core/curves.js","line":344,"description":"

Sets the resolution at which curves display.

\n

The default value is 20.

\n","params":[{"name":"resolution","description":"

of the curves

\n","type":"Number"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\nbackground(204);\ncurveDetail(20);\ncurve(5, 26, 5, 26, 73, 24, 73, 61);\n\n
"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src/core/curves.js","line":365,"description":"

Modifies the quality of forms created with curve() and curveVertex().\nThe parameter tightness determines how the curve fits to the vertex\npoints. The value 0.0 is the default value for tightness (this value\ndefines the curves to be Catmull-Rom splines) and the value 1.0 connects\nall the points with straight lines. Values within the range -5.0 and 5.0\nwill deform the curves but will leave them recognizable and as values\nincrease in magnitude, they will continue to deform.

\n","itemtype":"method","name":"curveTightness","params":[{"name":"amount","description":"

of deformation from the original vertices

\n","type":"Number"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\n// Move the mouse left and right to see the curve change\n\nfunction setup() {\n createCanvas(100, 100);\n noFill();\n}\n\nfunction draw() {\n background(204);\n var 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
"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src/core/curves.js","line":407,"description":"

Evaluates the curve at position t for points a, b, c, d.\nThe parameter t varies between 0 and 1, a and d are points\non the curve, and b and c are the control points.\nThis can be done once with the x coordinates and a second time\nwith the y coordinates to get the location of a curve at t.

\n","itemtype":"method","name":"curvePoint","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"}],"return":{"description":"bezier value at position t","type":"Number"},"example":["\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);\nsteps = 6;\nfor (i = 0; i <= steps; i++) {\n t = i / steps;\n x = curvePoint(5, 5, 73, 73, t);\n 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
"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src/core/curves.js","line":452,"description":"

Evaluates the tangent to the curve at position t for points a, b, c, d.\nThe parameter t varies between 0 and 1, a and d are points on the curve,\nand b and c are the control points.

\n","itemtype":"method","name":"curveTangent","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"}],"return":{"description":"the tangent at position t","type":"Number"},"example":["\n
\n\nnoFill();\ncurve(5, 26, 73, 24, 73, 61, 15, 65);\nsteps = 6;\nfor (i = 0; i <= steps; i++) {\n t = i / steps;\n x = curvePoint(5, 73, 73, 15, t);\n y = curvePoint(26, 24, 61, 65, t);\n //ellipse(x, y, 5, 5);\n tx = curveTangent(5, 73, 73, 15, t);\n ty = curveTangent(26, 24, 61, 65, t);\n a = atan2(ty, tx);\n a -= PI/2.0;\n line(x, y, cos(a)*8 + x, sin(a)*8 + y);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src/core/environment.js","line":22,"description":"

The println() function writes to the console area of your browser.\nThis function is often helpful for looking at the data a program is\nproducing. This function creates a new line of text for each call to\nthe function. Individual elements can be\nseparated with quotes ("") and joined with the addition operator (+).\n

\nWhile println() is similar to console.log(), it does not directly map to\nit in order to simulate easier to understand behavior than\nconsole.log(). Due to this, it is slower. For fastest results, use\nconsole.log().

\n","itemtype":"method","name":"println","params":[{"name":"contents","description":"

any combination of Number, String, Object, Boolean,\n Array to print

\n","type":"Any"}],"example":["\n
\nvar x = 10;\nprintln(\"The value of x is \" + x);\n// prints \"The value of x is 10\"\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":65,"description":"

The system variable frameCount contains the number of frames that have\nbeen displayed since the program started. Inside setup() the value is 0,\nafter the first iteration of draw it is 1, etc.

\n","itemtype":"property","name":"frameCount","example":["\n
\n function setup() {\n frameRate(30);\n textSize(20);\n textSize(30);\n textAlign(CENTER);\n }\n\n function draw() {\n background(200);\n text(frameCount, width/2, height/2);\n }\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":88,"description":"

Confirms if the window a p5.js program is in is "focused," meaning that\nthe sketch will accept mouse or keyboard input. This variable is\n"true" if the window is focused and "false" if not.

\n","itemtype":"property","name":"focused","example":["\n
\n// To demonstrate, put two windows side by side.\n// Click on the window that the p5 sketch isn't in!\nfunction draw() {\n background(200);\n noStroke();\n fill(0, 200, 0);\n ellipse(25, 25, 50, 50);\n\n if (!focused) { // or \"if (focused === false)\"\n stroke(200,0,0);\n line(0, 0, 100, 100);\n line(100, 0, 0, 100);\n }\n}\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":114,"description":"

Sets the cursor to a predefined symbol or an image, or makes it visible\nif already hidden. If you are trying to set an image as the cursor, the\nrecommended size is 16x16 or 32x32 pixels. It is not possible to load an\nimage as the cursor if you are exporting your program for the Web, and not\nall MODES work with all browsers. The values for parameters x and y must\nbe less than the dimensions of the image.

\n","itemtype":"method","name":"cursor","params":[{"name":"type","description":"

either ARROW, CROSS, HAND, MOVE, TEXT, or\n WAIT, or path for image

\n","type":"Number/Constant"},{"name":"x","description":"

the horizontal active spot of the cursor

\n","type":"Number","optional":true},{"name":"y","description":"

the vertical active spot of the cursor

\n","type":"Number","optional":true}],"example":["\n
\n// Move the mouse left and right across the image\n// to see the cursor change from a cross to a hand\nfunction draw() {\n line(width/2, 0, width/2, height);\n if (mouseX < 50) {\n cursor(CROSS);\n } else {\n cursor(HAND);\n }\n}\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":168,"description":"

Specifies the number of frames to be displayed every second. For example,\nthe function call frameRate(30) will attempt to refresh 30 times a second.\nIf the processor is not fast enough to maintain the specified rate, the\nframe rate will not be achieved. Setting the frame rate within setup() is\nrecommended. The default rate is 60 frames per second. This is the same as\nsetFrameRate(val).\n

\nCalling frameRate() with no arguments returns the current framerate. This\nis the same as getFrameRate().\n

\nCalling frameRate() with arguments that are not of the type numbers\nor are non positive also returns current framerate.

\n","itemtype":"method","name":"frameRate","params":[{"name":"fps","description":"

number of frames to be displayed every second

\n","type":"Number","optional":true}],"return":{"description":"current frameRate","type":"Number"},"example":["\n\n
\nvar rectX = 0;\nvar fr = 30; //starting FPS\nvar clr;\n\nfunction setup() {\n background(200);\n frameRate(fr); // Attempt to refresh at starting FPS\n clr = color(255,0,0);\n}\n\nfunction draw() {\n background(200);\n rectX = rectX += 1; // Move Rectangle\n\n if (rectX >= width) { // If you go off screen.\n if (fr == 30) {\n clr = color(0,0,255);\n fr = 10;\n frameRate(fr); // make frameRate 10 FPS\n } else {\n clr = color(255,0,0);\n fr = 30;\n frameRate(fr); // make frameRate 30 FPS\n }\n rectX = 0;\n }\n fill(clr);\n rect(rectX, 40, 20,20);\n}\n
\n"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":229,"description":"

Returns the current framerate.

\n","return":{"description":"current frameRate","type":"Number"},"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":238,"description":"

Specifies the number of frames to be displayed every second. For example,\nthe function call frameRate(30) will attempt to refresh 30 times a second.\nIf the processor is not fast enough to maintain the specified rate, the\nframe rate will not be achieved. Setting the frame rate within setup() is\nrecommended. The default rate is 60 frames per second.

\n

Calling frameRate() with no arguments returns the current framerate.

\n","params":[{"name":"fps","description":"

number of frames to be displayed every second

\n","type":"Number","optional":true}],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":253,"description":"

Hides the cursor from view.

\n","itemtype":"method","name":"noCursor","example":["\n
\nfunction setup() {\n noCursor();\n}\n\nfunction draw() {\n background(200);\n ellipse(mouseX, mouseY, 10, 10);\n}\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":274,"description":"

System variable that stores the width of the entire screen display. This\nis used to run a full-screen program on any display size.

\n","itemtype":"property","name":"displayWidth","example":["\n
\ncreateCanvas(displayWidth, displayHeight);\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":286,"description":"

System variable that stores the height of the entire screen display. This\nis used to run a full-screen program on any display size.

\n","itemtype":"property","name":"displayHeight","example":["\n
\ncreateCanvas(displayWidth, displayHeight);\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":298,"description":"

System variable that stores the width of the inner window, it maps to\nwindow.innerWidth.

\n","itemtype":"property","name":"windowWidth","example":["\n
\ncreateCanvas(windowWidth, windowHeight);\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":309,"description":"

System variable that stores the height of the inner window, it maps to\nwindow.innerHeight.

\n","itemtype":"property","name":"windowHeight","example":["\n
\ncreateCanvas(windowWidth, windowHeight);\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":321,"description":"

The windowResized() function is called once every time the browser window\nis resized. This is a good place to resize the canvas or do any other\nadjustements to accomodate the new window size.

\n","itemtype":"method","name":"windowResized","example":["\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
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":366,"description":"

System variable that stores the width of the drawing canvas. This value\nis set by the first parameter of the createCanvas() function.\nFor example, the function call createCanvas(320, 240) sets the width\nvariable to the value 320. The value of width defaults to 100 if\ncreateCanvas() is not used in a program.

\n","itemtype":"property","name":"width","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":377,"description":"

System variable that stores the height of the drawing canvas. This value\nis set by the second parameter of the createCanvas() function. For\nexample, the function call createCanvas(320, 240) sets the height\nvariable to the value 240. The value of height defaults to 100 if\ncreateCanvas() is not used in a program.

\n","itemtype":"property","name":"height","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":388,"description":"

If argument is given, sets the sketch to fullscreen or not based on the\nvalue of the argument. If no argument is given, returns the current\nfullscreen state. Note that due to browser restrictions this can only\nbe called on user input, for example, on mouse press like the example\nbelow.

\n","itemtype":"method","name":"fullscreen","params":[{"name":"val","description":"

whether the sketch should be in fullscreen mode\nor not

\n","type":"Boolean","optional":true}],"return":{"description":"current fullscreen state","type":"Boolean"},"example":["\n
\n\n// Clicking in the box toggles fullscreen on and off.\nfunction setup() {\n background(200);\n}\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n var fs = fullscreen();\n fullscreen(!fs);\n }\n}\n\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":431,"description":"

Sets the pixel scaling for high pixel density displays. By default\npixel density is set to match display density, call pixelDensity(1)\nto turn this off. Calling pixelDensity() with no arguments returns\nthe current pixel density of the sketch.

\n","itemtype":"method","name":"pixelDensity","params":[{"name":"val","description":"

whether or how much the sketch should scale

\n","type":"Number","optional":true}],"return":{"description":"current pixel density of the sketch","type":"Number"},"example":["\n
\n\nfunction setup() {\n pixelDensity(1);\n createCanvas(100, 100);\n background(200);\n ellipse(width/2, height/2, 50, 50);\n}\n\n
\n
\n\nfunction setup() {\n pixelDensity(3.0);\n createCanvas(100, 100);\n background(200);\n ellipse(width/2, height/2, 50, 50);\n}\n\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":472,"description":"

Returns the pixel density of the current display the sketch is running on.

\n","itemtype":"method","name":"displayDensity","return":{"description":"current pixel density of the display","type":"Number"},"example":["\n
\n\nfunction setup() {\n var density = displayDensity();\n pixelDensity(density);\n createCanvas(100, 100);\n background(200);\n ellipse(width/2, height/2, 50, 50);\n}\n\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":526,"description":"

Gets the current URL.

\n","itemtype":"method","name":"getURL","return":{"description":"url","type":"String"},"example":["\n
\n\nvar url;\nvar x = 100;\n\nfunction setup() {\n fill(0);\n noStroke();\n url = getURL();\n}\n\nfunction draw() {\n background(200);\n text(url, x, height/2);\n x--;\n}\n\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":553,"description":"

Gets the current URL path as an array.

\n","itemtype":"method","name":"getURLPath","return":{"description":"path components","type":"Array"},"example":["\n
\nfunction setup() {\n var urlPath = getURLPath();\n for (var i=0; i<urlPath.length; i++) {\n text(urlPath[i], 10, i*20+20);\n }\n}\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/environment.js","line":570,"description":"

Gets the current URL params as an Object.

\n","itemtype":"method","name":"getURLParams","return":{"description":"URL params","type":"Object"},"example":["\n
\n\n// Example: http://p5js.org?year=2014&month=May&day=15\n\nfunction setup() {\n var params = getURLParams();\n text(params.day, 10, 20);\n text(params.month, 10, 40);\n text(params.year, 10, 60);\n}\n\n
"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src/core/error_helpers.js","line":1,"requires":["core"],"class":"p5","module":"Environment"},{"file":"src/core/error_helpers.js","line":39,"description":"

Checks the definition type against the argument type\nIf any of these passes (in order), it matches:

\n
    \n
  • p5.* definitions are checked with instanceof
  • \n
  • Booleans are let through (everything is truthy or falsey)
  • \n
  • Lowercase of the definition is checked against the js type
  • \n
  • Number types are checked to see if they are numerically castable
  • \n
\n","class":"p5","module":"Environment"},{"file":"src/core/error_helpers.js","line":59,"description":"

Prints out a fancy, colorful message to the console log

\n","params":[{"name":"message","description":"

the words to be said

\n","type":"String"},{"name":"func","description":"

the name of the function to link

\n","type":"String"},{"name":"color","description":"

CSS color string or error type

\n","type":"Integer/Color String"}],"return":{"description":"console logs"},"class":"p5","module":"Environment"},{"file":"src/core/error_helpers.js","line":106,"description":"

Validate all the parameters of a function for number and type\nNOTE THIS FUNCTION IS TEMPORARILY DISABLED UNTIL FURTHER WORK\nAND UPDATES ARE IMPLEMENTED. -LMCCART

\n","params":[{"name":"func","description":"

name of function we're checking

\n","type":"String"},{"name":"args","description":"

pass of the JS default arguments array

\n","type":"Array"},{"name":"types","description":"

List of types accepted ['Number', 'String, ...] OR\n a list of lists for each format: [\n ['String', 'Number', 'Number'],\n ['String', 'Number', 'Number', 'Number', 'Number'\n ]

\n","type":"Array"}],"return":{"description":"console logs"},"class":"p5","module":"Environment"},{"file":"src/core/error_helpers.js","line":244,"description":"

Prints out all the colors in the color pallete with white text.\nFor color blindness testing.

\n","class":"p5","module":"Environment"},{"file":"src/core/p5.Element.js","line":25,"description":"

Underlying HTML element. All normal HTML methods can be called on this.

\n","itemtype":"property","name":"elt","class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":37,"description":"

Attaches the element to the parent specified. A way of setting\n the container for the element. Accepts either a string ID, DOM\n node, or p5.Element. If no arguments given, parent node is returned.\n For more ways to position the canvas, see the\n \n positioning the canvas wiki page.

\n","itemtype":"method","name":"parent","params":[{"name":"parent","description":"

the ID, DOM node, or p5.Element\n of desired parent element

\n","type":"String|Object"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\n // in the html file:\n <div id=\"myContainer\"></div>\n // in the js file:\n var cnv = createCanvas(100, 100);\n cnv.parent(\"myContainer\");\n
\n
\n var div0 = createDiv('this is the parent');\n var div1 = createDiv('this is the child');\n div1.parent(div0); // use p5.Element\n
\n
\n var div0 = createDiv('this is the parent');\n div0.id('apples');\n var div1 = createDiv('this is the child');\n div1.parent('apples'); // use id\n
\n
\n var elt = document.getElementById('myParentDiv');\n var div1 = createDiv('this is the child');\n div1.parent(elt); // use element from page\n
"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":92,"description":"

Sets the ID of the element. If no ID argument is passed in, it instead\n returns the current ID of the element.

\n","itemtype":"method","name":"id","params":[{"name":"id","description":"

ID of the element

\n","type":"String","optional":true}],"return":{"description":"","type":"p5.Element|String"},"example":["\n
\n function setup() {\n var cnv = createCanvas(100, 100);\n // Assigns a CSS selector ID to\n // the canvas element.\n cnv.id(\"mycanvas\");\n }\n
"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":121,"description":"

Adds given class to the element. If no class argument is passed in, it\n instead returns a string containing the current class(es) of the element.

\n","itemtype":"method","name":"class","params":[{"name":"class","description":"

class to add

\n","type":"String","optional":true}],"return":{"description":"","type":"p5.Element|String"},"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":139,"description":"

The .mousePressed() function is called once after every time a\nmouse button is pressed over the element. This can be used to\nattach element specific event listeners.

\n","itemtype":"method","name":"mousePressed","params":[{"name":"fxn","description":"

function to be fired when mouse is\n pressed over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mousePressed(changeGray); // attach listener for\n // canvas click only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width/2, height/2, d, d);\n}\n\n// this function fires with any click anywhere\nfunction mousePressed() {\n d = d + 10;\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":184,"description":"

The .mouseWheel() function is called once after every time a\nmouse wheel is scrolled over the element. This can be used to\nattach element specific event listeners.

\nThe event.wheelDelta or event.detail property returns negative values if\nthe mouse wheel if rotated up or away from the user and positive in the\nother direction. On OS X with "natural" scrolling enabled, the values are\nopposite.

\n","itemtype":"method","name":"mouseWheel","params":[{"name":"fxn","description":"

function to be fired when mouse wheel is\n scrolled over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseWheel(changeSize); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width/2, height/2, d, d);\n}\n\n// this function fires with mousewheel movement\n// anywhere on screen\nfunction mouseWheel() {\n g = g + 10;\n}\n\n// this function fires with mousewheel movement\n// over canvas only\nfunction changeSize() {\n if (event.wheelDelta > 0) {\n d = d + 10;\n } else {\n d = d - 10;\n }\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":238,"description":"

The .mouseReleased() function is called once after every time a\nmouse button is released over the element. This can be used to\nattach element specific event listeners.

\n","itemtype":"method","name":"mouseReleased","params":[{"name":"fxn","description":"

function to be fired when mouse is\n released over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseReleased(changeGray); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width/2, height/2, d, d);\n}\n\n// this function fires after the mouse has been\n// released\nfunction mouseReleased() {\n d = d + 10;\n}\n\n// this function fires after the mouse has been\n// released while on canvas\nfunction changeGray() {\n g = random(0, 255);\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":286,"description":"

The .mouseClicked() function is called once after a mouse button is\npressed and released over the element. This can be used to\nattach element specific event listeners.

\n","itemtype":"method","name":"mouseClicked","params":[{"name":"fxn","description":"

function to be fired when mouse is\n clicked over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseClicked(changeGray); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width/2, height/2, d, d);\n}\n\n// this function fires after the mouse has been\n// clicked anywhere\nfunction mouseClicked() {\n d = d + 10;\n}\n\n// this function fires after the mouse has been\n// clicked on canvas\nfunction changeGray() {\n g = random(0, 255);\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":331,"description":"

The .mouseMoved() function is called once every time a\nmouse moves over the element. This can be used to attach an\nelement specific event listener.

\n","itemtype":"method","name":"mouseMoved","params":[{"name":"fxn","description":"

function to be fired when mouse is\n moved over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d = 30;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseMoved(changeSize); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n fill(200);\n ellipse(width/2, height/2, d, d);\n}\n\n// this function fires when mouse moves anywhere on\n// page\nfunction mouseMoved() {\n g = g + 5;\n if (g > 255) {\n g = 0;\n }\n}\n\n// this function fires when mouse moves over canvas\nfunction changeSize() {\n d = d + 2;\n if (d > 100) {\n d = 0;\n }\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":384,"description":"

The .mouseOver() function is called once after every time a\nmouse moves onto the element. This can be used to attach an\nelement specific event listener.

\n","itemtype":"method","name":"mouseOver","params":[{"name":"fxn","description":"

function to be fired when mouse is\n moved over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseOver(changeGray);\n d = 10;\n}\n\nfunction draw() {\n ellipse(width/2, height/2, d, d);\n}\n\nfunction changeGray() {\n d = d + 10;\n if (d > 100) {\n d = 0;\n }\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":423,"description":"

The .changed() function is called when the value of an\nelement is changed.\nThis can be used to attach an element specific event listener.

\n","itemtype":"method","name":"changed","params":[{"name":"fxn","description":"

function to be fired when the value of an\nelement changes.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar sel;\n\nfunction setup() {\n textAlign(CENTER);\n background(200);\n sel = createSelect();\n sel.position(10, 10);\n sel.option('pear');\n sel.option('kiwi');\n sel.option('grape');\n sel.changed(mySelectEvent);\n}\n\nfunction mySelectEvent() {\n var item = sel.value();\n background(200);\n text(\"it's a \"+item+\"!\", 50, 50);\n}\n
\n
\nvar checkbox;\nvar cnv;\n\nfunction setup() {\n checkbox = createCheckbox(\" fill\");\n checkbox.changed(changeFill);\n cnv = createCanvas(100, 100);\n cnv.position(0, 30);\n noFill();\n}\n\nfunction draw() {\n background(200);\n ellipse(50, 50, 50, 50);\n}\n\nfunction changeFill() {\n if (checkbox.checked()) {\n fill(0);\n } else {\n noFill();\n }\n}\n
"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":484,"description":"

The .input() function is called when any user input is\ndetected with an element. The input event is often used\nto detect keystrokes in a input element, or changes on a\nslider element. This can be used to attach an element specific\nevent listener.

\n","itemtype":"method","name":"input","params":[{"name":"fxn","description":"

function to be fired on user input.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\n// Open your console to see the output\nfunction setup() {\n var inp = createInput('');\n inp.input(myInputEvent);\n}\n\nfunction myInputEvent() {\n console.log('you are typing: ', this.value());\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":513,"description":"

The .mouseOut() function is called once after every time a\nmouse moves off the element. This can be used to attach an\nelement specific event listener.

\n","itemtype":"method","name":"mouseOut","params":[{"name":"fxn","description":"

function to be fired when mouse is\n moved off the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseOut(changeGray);\n d = 10;\n}\n\nfunction draw() {\n ellipse(width/2, height/2, d, d);\n}\n\nfunction changeGray() {\n d = d + 10;\n if (d > 100) {\n d = 0;\n }\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":551,"description":"

The .touchStarted() function is called once after every time a touch is\nregistered. This can be used to attach element specific event listeners.

\n","itemtype":"method","name":"touchStarted","params":[{"name":"fxn","description":"

function to be fired when touch is\n started over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.touchStarted(changeGray); // attach listener for\n // canvas click only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width/2, height/2, d, d);\n}\n\n// this function fires with any touch anywhere\nfunction touchStarted() {\n d = d + 10;\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":595,"description":"

The .touchMoved() function is called once after every time a touch move is\nregistered. This can be used to attach element specific event listeners.

\n","itemtype":"method","name":"touchMoved","params":[{"name":"fxn","description":"

function to be fired when touch is moved\n over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.touchMoved(changeGray); // attach listener for\n // canvas click only\n g = 100;\n}\n\nfunction draw() {\n background(g);\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":631,"description":"

The .touchEnded() function is called once after every time a touch is\nregistered. This can be used to attach element specific event listeners.

\n","itemtype":"method","name":"touchEnded","params":[{"name":"fxn","description":"

function to be fired when touch is\n ended over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nvar cnv;\nvar d;\nvar g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.touchEnded(changeGray); // attach listener for\n // canvas click only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width/2, height/2, d, d);\n}\n\n// this function fires with any touch anywhere\nfunction touchEnded() {\n d = d + 10;\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
\n"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":677,"description":"

The .dragOver() function is called once after every time a\nfile is dragged over the element. This can be used to attach an\nelement specific event listener.

\n","itemtype":"method","name":"dragOver","params":[{"name":"fxn","description":"

function to be fired when mouse is\n dragged over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":692,"description":"

The .dragLeave() function is called once after every time a\ndragged file leaves the element area. This can be used to attach an\nelement specific event listener.

\n","itemtype":"method","name":"dragLeave","params":[{"name":"fxn","description":"

function to be fired when mouse is\n dragged over the element.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":707,"description":"

The .drop() function is called for each file dropped on the element.\nIt requires a callback that is passed a p5.File object. You can\noptionally pass two callbacks, the first one (required) is triggered\nfor each file dropped when the file is loaded. The second (optional)\nis triggered just once when a file (or files) are dropped.

\n","itemtype":"method","name":"drop","params":[{"name":"callback","description":"

triggered when files are dropped.

\n","type":"Function"},{"name":"callback","description":"

to receive loaded file.

\n","type":"Function"}],"return":{"description":"","type":"p5.Element"},"example":["\n
\nfunction setup() {\n var c = createCanvas(100, 100);\n background(200);\n textAlign(CENTER);\n text('drop image', width/2, height/2);\n c.drop(gotFile);\n}\n\nfunction gotFile(file) {\n var img = createImg(file.data).hide();\n // Draw the image onto the canvas\n image(img, 0, 0, width, height);\n}\n
"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Element.js","line":811,"description":"

Helper fxn for sharing pixel methods

\n","class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src/core/p5.Renderer.js","line":71,"description":"

Resize our canvas element.

\n","class":"p5.Renderer","module":"Rendering","submodule":"Rendering"},{"file":"src/core/p5.Renderer.js","line":145,"description":"

Helper fxn to check font type (system or otf)

\n","class":"p5.Renderer","module":"Rendering","submodule":"Rendering"},{"file":"src/core/p5.Renderer.js","line":201,"description":"

Helper fxn to measure ascent and descent.\nAdapted from http://stackoverflow.com/a/25355178

\n","class":"p5.Renderer","module":"Rendering","submodule":"Rendering"},{"file":"src/core/p5.Renderer2D.js","line":9,"description":"

p5.Renderer2D\nThe 2D graphics canvas renderer class.\nextends p5.Renderer

\n","class":"p5","module":"Rendering"},{"file":"src/core/p5.Renderer2D.js","line":356,"description":"

Generate a cubic Bezier representing an arc on the unit circle of total\nangle size radians, beginning start radians above the x-axis. Up to\nfour of these curves are combined to make a full arc.

\n

See www.joecridge.me/bezier.pdf for an explanation of the method.

\n","class":"p5","module":"Rendering"},{"file":"src/core/rendering.js","line":14,"description":"

Creates a canvas element in the document, and sets the dimensions of it\nin pixels. This method should be called only once at the start of setup.\nCalling createCanvas more than once in a sketch will result in very\nunpredicable behavior. If you want more than one drawing canvas\nyou could use createGraphics (hidden by default but it can be shown).\n

\nThe system variables width and height are set by the parameters passed\nto this function. If createCanvas() is not used, the window will be\ngiven a default size of 100x100 pixels.\n

\nFor more ways to position the canvas, see the\n\npositioning the canvas wiki page.

\n","itemtype":"method","name":"createCanvas","params":[{"name":"w","description":"

width of the canvas

\n","type":"Number"},{"name":"h","description":"

height of the canvas

\n","type":"Number"},{"name":"renderer","description":"

P2D or WEBGL

\n","type":"Constant","optional":true}],"return":{"description":"canvas generated","type":"Object"},"example":["\n
\n\nfunction setup() {\n createCanvas(100, 50);\n background(153);\n line(0, 0, width, height);\n}\n\n
"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src/core/rendering.js","line":115,"description":"

Resizes the canvas to given width and height. The canvas will be cleared\nand draw will be called immediately, allowing the sketch to re-render itself\nin the resized canvas.

\n","itemtype":"method","name":"resizeCanvas","example":["\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
"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src/core/rendering.js","line":158,"description":"

Removes the default canvas for a p5 sketch that doesn't\nrequire a canvas

\n","itemtype":"method","name":"noCanvas","example":["\n
\n\nfunction setup() {\n noCanvas();\n}\n\n
"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src/core/rendering.js","line":177,"description":"

Creates and returns a new p5.Renderer 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.

\n","itemtype":"method","name":"createGraphics","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":"

P2D or WEBGL\nundefined defaults to p2d

\n","type":"Constant","optional":true}],"return":{"description":"offscreen graphics buffer","type":"Object"},"example":["\n
\n\nvar pg;\nfunction setup() {\n createCanvas(100, 100);\n pg = createGraphics(100, 100);\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\n
"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src/core/rendering.js","line":211,"description":"

Blends 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):

\n
    \n
  • BLEND - linear interpolation of colours: C =\nAfactor + B. This is the default blending mode.
  • \n
  • ADD - sum of A and B
  • \n
  • DARKEST - only the darkest colour succeeds: C =\nmin(Afactor, B).
  • \n
  • LIGHTEST - only the lightest colour succeeds: C =\nmax(A*factor, B).
  • \n
  • DIFFERENCE - subtract colors from underlying image.
  • \n
  • EXCLUSION - similar to DIFFERENCE, but less\nextreme.
  • \n
  • MULTIPLY - multiply the colors, result will always be\ndarker.
  • \n
  • SCREEN - opposite multiply, uses inverse values of the\ncolors.
  • \n
  • REPLACE - the pixels entirely replace the others and\ndon't utilize alpha (transparency) values.
  • \n
  • OVERLAY - mix of MULTIPLY and SCREEN\n. Multiplies dark values, and screens light values.
  • \n
  • HARD_LIGHT - SCREEN when greater than 50%\ngray, MULTIPLY when lower.
  • \n
  • SOFT_LIGHT - mix of DARKEST and\nLIGHTEST. Works like OVERLAY, but not as harsh.\n
  • \n
  • DODGE - lightens light tones and increases contrast,\nignores darks.
  • \n
  • BURN - darker areas are applied, increasing contrast,\nignores lights.
  • \n
","itemtype":"method","name":"blendMode","params":[{"name":"mode","description":"

blend mode to set for canvas

\n","type":"Constant"}],"example":["\n
\n\nblendMode(LIGHTEST);\nstrokeWeight(30);\nstroke(80, 150, 255);\nline(25, 25, 75, 75);\nstroke(255, 50, 50);\nline(75, 25, 25, 75);\n\n
\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\n
"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src/core/shim.js","line":65,"description":"

shim for Uint8ClampedArray.slice\n(allows arrayCopy to work with pixels[])\nwith thanks to http://halfpapstudios.com/blog/tag/html5-canvas/\nEnumerable set to false to protect for...in from\nUint8ClampedArray.prototype pollution.

\n","class":"p5","module":"Rendering"},{"file":"src/core/structure.js","line":15,"description":"

Stops p5.js from continuously executing the code within draw().\nIf loop() is called, the code in draw() begins to run continuously again.\nIf using noLoop() in setup(), it should be the last line inside the block.\n

\nWhen noLoop() is used, it's not possible to manipulate or access the\nscreen inside event handling functions such as mousePressed() or\nkeyPressed(). Instead, use those functions to call redraw() or loop(),\nwhich will run draw(), which can update the screen properly. This means\nthat when noLoop() has been called, no drawing can happen, and functions\nlike saveFrame() or loadPixels() may not be used.\n

\nNote that if the sketch is resized, redraw() will be called to update\nthe sketch, even after noLoop() has been specified. Otherwise, the sketch\nwould enter an odd state until loop() was called.

\n","itemtype":"method","name":"noLoop","example":["\n
\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n noLoop();\n}\n\nfunction draw() {\n line(10, 10, 90, 90);\n}\n
\n\n
\nvar 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
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/structure.js","line":72,"description":"

By default, p5.js loops through draw() continuously, executing the code\nwithin it. However, the draw() loop may be stopped by calling noLoop().\nIn that case, the draw() loop can be resumed with loop().

\n","itemtype":"method","name":"loop","example":["\n
\nvar 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
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/structure.js","line":110,"description":"

The push() function saves the current drawing style settings and\ntransformations, while pop() restores these settings. Note that these\nfunctions are always used together. They allow you to change the style\nand transformation settings and later return to what you had. When a new\nstate is started with push(), it builds on the current style and transform\ninformation. The push() and pop() functions can be embedded to provide\nmore control. (See the second example for a demonstration.)\n

\npush() stores information related to the current transformation state\nand style settings controlled by the following functions: fill(),\nstroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(),\nimageMode(), rectMode(), ellipseMode(), colorMode(), textAlign(),\ntextFont(), textMode(), textSize(), textLeading().

\n","itemtype":"method","name":"push","example":["\n
\n\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
\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\n
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/structure.js","line":180,"description":"

The push() function saves the current drawing style settings and\ntransformations, while pop() restores these settings. Note that these\nfunctions are always used together. They allow you to change the style\nand transformation settings and later return to what you had. When a new\nstate is started with push(), it builds on the current style and transform\ninformation. The push() and pop() functions can be embedded to provide\nmore control. (See the second example for a demonstration.)\n

\npush() stores information related to the current transformation state\nand style settings controlled by the following functions: fill(),\nstroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(),\nimageMode(), rectMode(), ellipseMode(), colorMode(), textAlign(),\ntextFont(), textMode(), textSize(), textLeading().

\n","itemtype":"method","name":"pop","example":["\n
\n\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
\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\n
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/structure.js","line":247,"description":"

Executes the code within draw() one time. This functions allows the\n program to update the display window only when necessary, for example\n when an event registered by mousePressed() or keyPressed() occurs.\n

\n In structuring a program, it only makes sense to call redraw() within\n events such as mousePressed(). This is because redraw() does not run\n draw() immediately (it only sets a flag that indicates an update is\n needed).\n

\n The redraw() function does not work properly when called inside draw().\n To enable/disable animations, use loop() and noLoop().\n

\n In addition you can set the number of redraws per method call. Just\n add an integer as single parameter for the number of redraws.

\n","itemtype":"method","name":"redraw","params":[{"name":"n","description":"

Redraw for n-times. The default value is 1.

\n","type":"Integer","optional":true}],"example":["\n
\n var x = 0;\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n }\nfunction draw() {\n background(204);\n line(x, 0, x, height);\n }\nfunction mousePressed() {\n x += 1;\n redraw();\n }\n
\n
\n var x = 0;\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n }\nfunction draw() {\n background(204);\n x += 1;\n line(x, 0, x, height);\n }\nfunction mousePressed() {\n redraw(5);\n }\n
"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src/core/transform.js","line":15,"description":"

Multiplies the current matrix by the one specified through the parameters.\nThis is very slow because it will try to calculate the inverse of the\ntransform, so avoid it whenever possible.

\n","itemtype":"method","name":"applyMatrix","params":[{"name":"n00","description":"

numbers which define the 3x2 matrix to be multiplied

\n","type":"Number"},{"name":"n01","description":"

numbers which define the 3x2 matrix to be multiplied

\n","type":"Number"},{"name":"n02","description":"

numbers which define the 3x2 matrix to be multiplied

\n","type":"Number"},{"name":"n10","description":"

numbers which define the 3x2 matrix to be multiplied

\n","type":"Number"},{"name":"n11","description":"

numbers which define the 3x2 matrix to be multiplied

\n","type":"Number"},{"name":"n12","description":"

numbers which define the 3x2 matrix to be multiplied

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n// Example in the works.\n\n
"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":52,"description":"

Replaces the current matrix with the identity matrix.

\n","itemtype":"method","name":"resetMatrix","return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n// Example in the works.\n\n
"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":69,"description":"

Rotates a shape the amount specified by the angle parameter. This\nfunction accounts for angleMode, so angles can be entered in either\nRADIANS or DEGREES.\n

\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 accumulates the effect. For example, calling\nrotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI).\nAll tranformations are reset when draw() begins again.\n

\nTechnically, rotate() multiplies the current transformation matrix\nby a rotation matrix. This function can be further controlled by\nthe push() and pop().

\n","itemtype":"method","name":"rotate","return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\ntranslate(width/2, height/2);\nrotate(PI/3.0);\nrect(-26, -26, 52, 52);\n\n
"],"class":"p5","module":"Transform","submodule":"Transform","overloads":[{"line":69,"params":[{"name":"angle","description":"

the angle of rotation, specified in radians\n or degrees, depending on current angleMode

\n","type":"Number"}]},{"line":98,"params":[{"name":"rad","description":"

angle in radians

\n","type":"Number"},{"name":"axis","description":"

axis to rotate around

\n","type":"p5.Vector | Array"}]}]},{"file":"src/core/transform.js","line":125,"description":"

Rotates around X axis.

\n","itemtype":"method","name":"rotateX","params":[{"name":"rad","description":"

angles in radians

\n","type":"Number"}],"return":{"description":"[description]","type":"[type]"},"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":151,"description":"

Rotates around Y axis.

\n","itemtype":"method","name":"rotateY","params":[{"name":"rad","description":"

angles in radians

\n","type":"Number"}],"return":{"description":"[description]","type":"[type]"},"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":177,"description":"

Rotates around Z axis. Webgl mode only.

\n","itemtype":"method","name":"rotateZ","params":[{"name":"rad","description":"

angles in radians

\n","type":"Number"}],"return":{"description":"[description]","type":"[type]"},"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":203,"description":"

Increases or decreases the size of a shape by expanding and 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%.\n

\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.\n

\nUsing this function with the z parameter is only available in WEBGL mode.\nThis function can be further controlled with push() and pop().

\n","itemtype":"method","name":"scale","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 | Array"},{"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}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\ntranslate(width/2, height/2);\nrotate(PI/3.0);\nrect(-26, -26, 52, 52);\n\n
\n\n
\n\nrect(30, 20, 50, 50);\nscale(0.5, 1.3);\nrect(30, 20, 50, 50);\n\n
"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":279,"description":"

Shears a shape around the x-axis 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.\n

\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(), the transformation is reset when\nthe loop begins again.\n

\nTechnically, shearX() multiplies the current transformation matrix by a\nrotation matrix. This function can be further controlled by the\npush() and pop() functions.

\n","itemtype":"method","name":"shearX","params":[{"name":"angle","description":"

angle of shear specified in radians or degrees,\n depending on current angleMode

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\ntranslate(width/4, height/4);\nshearX(PI/4.0);\nrect(0, 0, 30, 30);\n\n
"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":316,"description":"

Shears 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.\n

\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.\n

\nTechnically, shearY() multiplies the current transformation matrix by a\nrotation matrix. This function can be further controlled by the\npush() and pop() functions.

\n","itemtype":"method","name":"shearY","params":[{"name":"angle","description":"

angle of shear specified in radians or degrees,\n depending on current angleMode

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\ntranslate(width/4, height/4);\nshearY(PI/4.0);\nrect(0, 0, 30, 30);\n\n
"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/transform.js","line":353,"description":"

Specifies an amount to displace objects within the display window.\nThe x parameter specifies left/right translation, the y parameter\nspecifies up/down translation.\n

\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","itemtype":"method","name":"translate","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}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\ntranslate(30, 20);\nrect(0, 0, 55, 55);\n\n
\n\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
"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src/core/vertex.js","line":22,"description":"

Use 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.\n

\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","itemtype":"method","name":"beginContour","return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\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\n
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/core/vertex.js","line":66,"description":"

Using 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.\n

\nThe parameters available for beginShape() are POINTS, LINES, TRIANGLES,\nTRIANGLE_FAN, TRIANGLE_STRIP, QUADS, and QUAD_STRIP. After calling the\nbeginShape() 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.\n

\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","itemtype":"method","name":"beginShape","params":[{"name":"kind","description":"

either POINTS, LINES, TRIANGLES, TRIANGLE_FAN\n TRIANGLE_STRIP, QUADS, or QUAD_STRIP

\n","type":"Constant"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n\n
\n\n
\n\n// currently not working\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n\n
\n\n
\n\nbeginShape(LINES);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n\n
\n\n
\n\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n\n
\n\n
\n\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n\n
\n\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
\n\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
\n\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
\n\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
\n\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
\n\n
\n\nbeginShape();\nvertex(20, 20);\nvertex(40, 20);\nvertex(40, 40);\nvertex(60, 40);\nvertex(60, 60);\nvertex(20, 60);\nendShape(CLOSE);\n\n
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/core/vertex.js","line":250,"description":"

Specifies 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.\n

\nThe first time bezierVertex() is used within a\nbeginShape() call, it must be prefaced with a call to vertex()\nto set the first anchor point. This function must be used between\nbeginShape() and endShape() and only when there is no MODE\nparameter specified to beginShape().

\n","itemtype":"method","name":"bezierVertex","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"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\nnoFill();\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nendShape();\n\n
\n\n
\n\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nbezierVertex(50, 80, 60, 25, 30, 20);\nendShape();\n\n
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/core/vertex.js","line":310,"description":"

Specifies 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().\n

\nThe first and last points in a series of curveVertex() lines will be used to\nguide the beginning and end of a 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","itemtype":"method","name":"curveVertex","params":[{"name":"x","description":"

x-coordinate of the vertex

\n","type":"Number"},{"name":"y","description":"

y-coordinate of the vertex

\n","type":"Number"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\nnoFill();\nbeginShape();\ncurveVertex(84, 91);\ncurveVertex(84, 91);\ncurveVertex(68, 19);\ncurveVertex(21, 17);\ncurveVertex(32, 100);\ncurveVertex(32, 100);\nendShape();\n\n
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/core/vertex.js","line":348,"description":"

Use 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.\n

\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","itemtype":"method","name":"endContour","return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\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\n
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/core/vertex.js","line":404,"description":"

The endShape() function is the companion to beginShape() and may only be\ncalled after beginShape(). When endshape() is called, all of image data\ndefined since the previous call to beginShape() is written into the image\nbuffer. The constant CLOSE as the value for the MODE parameter to close\nthe shape (to connect the beginning and the end).

\n","itemtype":"method","name":"endShape","params":[{"name":"mode","description":"

use CLOSE to close the shape

\n","type":"Constant"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\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
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/core/vertex.js","line":468,"description":"

Specifies 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.\nThis function must be used between beginShape() and endShape() and only\nwhen there is no MODE parameter specified to beginShape().

\n","itemtype":"method","name":"quadraticVertex","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"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\nnoFill();\nstrokeWeight(4);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nendShape();\n\n
\n\n
\n\nnoFill();\nstrokeWeight(4);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nquadraticVertex(20, 80, 80, 80);\nvertex(80, 60);\nendShape();\n\n
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/core/vertex.js","line":540,"description":"

All shapes are constructed by connecting a series of vertices. vertex()\nis used to specify the vertex coordinates for points, lines, triangles,\nquads, and polygons. It is used exclusively within the beginShape() and\nendShape() functions.

\n","itemtype":"method","name":"vertex","params":[{"name":"x","description":"

x-coordinate of the vertex

\n","type":"Number"},{"name":"y","description":"

y-coordinate of the vertex

\n","type":"Number"}],"return":{"description":"the p5 object","type":"Object"},"example":["\n
\n\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n\n
"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src/events/acceleration.js","line":12,"description":"

The system variable deviceOrientation always contains the orientation of\nthe device. The value of this variable will either be set 'landscape'\nor 'portrait'. If no data is available it will be set to 'undefined'.

\n","itemtype":"property","name":"deviceOrientation","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":21,"description":"

The system variable accelerationX always contains the acceleration of the\ndevice along the x axis. Value is represented as meters per second squared.

\n","itemtype":"property","name":"accelerationX","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":29,"description":"

The system variable accelerationY always contains the acceleration of the\ndevice along the y axis. Value is represented as meters per second squared.

\n","itemtype":"property","name":"accelerationY","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":37,"description":"

The system variable accelerationZ always contains the acceleration of the\ndevice along the z axis. Value is represented as meters per second squared.

\n","itemtype":"property","name":"accelerationZ","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":45,"description":"

The system variable pAccelerationX always contains the acceleration of the\ndevice along the x axis in the frame previous to the current frame. Value\nis represented as meters per second squared.

\n","itemtype":"property","name":"pAccelerationX","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":54,"description":"

The system variable pAccelerationY always contains the acceleration of the\ndevice along the y axis in the frame previous to the current frame. Value\nis represented as meters per second squared.

\n","itemtype":"property","name":"pAccelerationY","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":63,"description":"

The system variable pAccelerationZ always contains the acceleration of the\ndevice along the z axis in the frame previous to the current frame. Value\nis represented as meters per second squared.

\n","itemtype":"property","name":"pAccelerationZ","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":72,"description":"

_updatePAccelerations updates the pAcceleration values

\n","access":"private","tagname":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":83,"description":"

The system variable rotationX always contains the rotation of the\ndevice along the x axis. Value is represented as 0 to +/-180 degrees.\n

\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","example":["\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}\n\n
"],"itemtype":"property","name":"rotationX","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":112,"description":"

The system variable rotationY always contains the rotation of the\ndevice along the y axis. Value is represented as 0 to +/-90 degrees.\n

\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","example":["\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}\n\n
"],"itemtype":"property","name":"rotationY","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":141,"description":"

The system variable rotationZ always contains the rotation of the\ndevice along the z axis. Value is represented as 0 to 359 degrees.\n

\nUnlike rotationX and rotationY, this variable is available for devices\nwith a built-in compass only.\n

\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","example":["\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}\n\n
"],"itemtype":"property","name":"rotationZ","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":173,"description":"

The system variable pRotationX always contains the rotation of the\ndevice along the x axis in the frame previous to the current frame. Value\nis represented as 0 to +/-180 degrees.\n

\npRotationX can also be used with rotationX to determine the rotate\ndirection of the device along the X-axis.

\n","example":["\n
\n\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.\nvar rotateDirection = 'clockwise';\n\n// Simple range conversion to make things simpler.\n// This is not absolutely neccessary but the logic\n// will be different in that case.\n\nvar rX = rotationX + 180;\nvar 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\n
"],"itemtype":"property","name":"pRotationX","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":211,"description":"

The system variable pRotationY always contains the rotation of the\ndevice along the y axis in the frame previous to the current frame. Value\nis represented as 0 to +/-90 degrees.\n

\npRotationY can also be used with rotationY to determine the rotate\ndirection of the device along the Y-axis.

\n","example":["\n
\n\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.\nvar rotateDirection = 'clockwise';\n\n// Simple range conversion to make things simpler.\n// This is not absolutely neccessary but the logic\n// will be different in that case.\n\nvar rY = rotationY + 180;\nvar 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}\n\n
"],"itemtype":"property","name":"pRotationY","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":249,"description":"

The system variable pRotationZ always contains the rotation of the\ndevice along the z axis in the frame previous to the current frame. Value\nis represented as 0 to 359 degrees.\n

\npRotationZ can also be used with rotationZ to determine the rotate\ndirection of the device along the Z-axis.

\n","example":["\n
\n\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.\nvar rotateDirection = 'clockwise';\n\nif ((rotationZ - pRotationZ > 0 &&\n rotationZ - pRotationZ < 270)||\n rotationZ - pRotationZ < -270){\n\n rotateDirection = 'clockwise';\n\n} else if (rotationZ - pRotationZ < 0 ||\n rotationZ - pRotationZ > 270){\n\n rotateDirection = 'counter-clockwise';\n\n}\n\n
"],"itemtype":"property","name":"pRotationZ","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":310,"description":"

The setMoveThreshold() function is used to set the movement threshold for\nthe deviceMoved() function. The default threshold is set to 0.5.

\n","itemtype":"method","name":"setMoveThreshold","params":[{"name":"value","description":"

The threshold value

\n","type":"Number"}],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":323,"description":"

The setShakeThreshold() function is used to set the movement threshold for\nthe deviceShaken() function. The default threshold is set to 30.

\n","itemtype":"method","name":"setShakeThreshold","params":[{"name":"value","description":"

The threshold value

\n","type":"Number"}],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":336,"description":"

The deviceMoved() function is called when the device is moved by more than\nthe threshold value along X, Y or Z axis. The default threshold is set to\n0.5.

\n","itemtype":"method","name":"deviceMoved","example":["\n
\n\n// Run this example on a mobile device\n// Move the device around\n// to change the value.\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n\n
"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":363,"description":"

The deviceTurned() function is called when the device rotates by\nmore than 90 degrees continuously.\n

\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","itemtype":"method","name":"deviceTurned","example":["\n
\n\n// Run this example on a mobile device\n// Rotate the device by 90 degrees\n// to change the value.\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceTurned() {\n if (value == 0){\n value = 255\n } else if (value == 255) {\n value = 0;\n }\n}\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\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\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
"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/acceleration.js","line":417,"description":"

The deviceShaken() function is called when the device total acceleration\nchanges of accelerationX and accelerationY values is more than\nthe threshold value. The default threshold is set to 30.

\n","itemtype":"method","name":"deviceShaken","example":["\n
\n\n// Run this example on a mobile device\n// Shake the device to change the value.\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceShaken() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n\n
"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src/events/keyboard.js","line":12,"description":"

Holds the key codes of currently pressed keys.

\n","access":"private","tagname":"","class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":18,"description":"

The boolean system variable keyIsPressed is true if any key is pressed\nand false if no keys are pressed.

\n","itemtype":"property","name":"keyIsPressed","example":["\n
\n\nvar value = 0;\nfunction draw() {\n if (keyIsPressed === true) {\n fill(0);\n } else {\n fill(255);\n }\n rect(25, 25, 50, 50);\n}\n\n
"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":41,"description":"

The system variable key always contains the value of the most recent\nkey on the keyboard that was typed. To get the proper capitalization, it\nis best to use it within keyTyped(). For non-ASCII keys, use the keyCode\nvariable.

\n","itemtype":"property","name":"key","example":["\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}\n
"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":65,"description":"

The variable keyCode is used to detect special keys such as BACKSPACE,\nDELETE, ENTER, RETURN, TAB, ESCAPE, SHIFT, CONTROL, OPTION, ALT, UP_ARROW,\nDOWN_ARROW, LEFT_ARROW, RIGHT_ARROW.

\n","itemtype":"property","name":"keyCode","example":["\n
\nvar fillVal = 126;\nfunction draw() {\n fill(fillVal);\n rect(25, 25, 50, 50);\n}\n\nfunction keyPressed() {\n if (keyCode == UP_ARROW) {\n fillVal = 255;\n } else if (keyCode == DOWN_ARROW) {\n fillVal = 0;\n }\n return false; // prevent default\n}\n
"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":91,"description":"

The 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.\n

\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.\n

\nFor ASCII keys 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.\n

\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.

\n","itemtype":"method","name":"keyPressed","example":["\n
\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction keyPressed() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n\n
\n
\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction keyPressed() {\n if (keyCode === LEFT_ARROW) {\n value = 255;\n } else if (keyCode === RIGHT_ARROW) {\n value = 0;\n }\n}\n\n
\n
\n\nfunction keyPressed(){\n // Do something\n return false; // prevent any default behaviour\n}\n\n
"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":176,"description":"

The keyReleased() function is called once every time a key is released.\nSee key and keyCode for more information.

\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.

\n","itemtype":"method","name":"keyReleased","example":["\n
\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\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\n
"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":224,"description":"

The keyTyped() function is called once every time a key is pressed, but\naction keys such as Ctrl, Shift, and Alt are ignored. The most recent\nkey pressed will be stored in the key variable.\n

\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 method.

\n","itemtype":"method","name":"keyTyped","example":["\n
\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\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
"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":273,"description":"

The onblur function is called when the user is no longer focused\non the p5 element. Because the keyup events will not fire if the user is\nnot focused on the element we must assume all keys currently down have\nbeen released.

\n","class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/keyboard.js","line":283,"description":"

The keyIsDown() function checks if the key is currently down, i.e. pressed.\nIt can be used if you have an object that moves, and you want several keys\nto be able to affect its behaviour simultaneously, such as moving a\nsprite diagonally. You can put in any number representing the keyCode of\nthe key, or use any of the variable keyCode names listed\nhere.

\n","itemtype":"method","name":"keyIsDown","params":[{"name":"code","description":"

The key to check for.

\n","type":"Number"}],"return":{"description":"whether key is down or not","type":"Boolean"},"example":["\n
\nvar x = 100;\nvar y = 100;\n\nfunction setup() {\n createCanvas(512, 512);\n}\n\nfunction draw() {\n if (keyIsDown(LEFT_ARROW))\n x-=5;\n\n if (keyIsDown(RIGHT_ARROW))\n x+=5;\n\n if (keyIsDown(UP_ARROW))\n y-=5;\n\n if (keyIsDown(DOWN_ARROW))\n y+=5;\n\n clear();\n fill(255, 0, 0);\n ellipse(x, y, 50, 50);\n}\n
"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src/events/mouse.js","line":23,"description":"

The system variable mouseX always contains the current horizontal\nposition of the mouse, relative to (0, 0) of the canvas.

\n","itemtype":"property","name":"mouseX","example":["\n
\n\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(mouseX, 0, mouseX, 100);\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":42,"description":"

The system variable mouseY always contains the current vertical position\nof the mouse, relative to (0, 0) of the canvas.

\n","itemtype":"property","name":"mouseY","example":["\n
\n\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(0, mouseY, 100, mouseY);\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":61,"description":"

The system variable pmouseX always contains the horizontal position of\nthe mouse in the frame previous to the current frame, relative to (0, 0)\nof the canvas.

\n","itemtype":"property","name":"pmouseX","example":["\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 println(pmouseX + \" -> \" + mouseX);\n}\n\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":88,"description":"

The system variable pmouseY always contains the vertical position of the\nmouse in the frame previous to the current frame, relative to (0, 0) of\nthe canvas.

\n","itemtype":"property","name":"pmouseY","example":["\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 println(pmouseY + \" -> \" + mouseY);\n}\n\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":113,"description":"

The system variable winMouseX always contains the current horizontal\nposition of the mouse, relative to (0, 0) of the window.

\n","itemtype":"property","name":"winMouseX","example":["\n
\n\nvar myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\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}\n\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":146,"description":"

The system variable winMouseY always contains the current vertical\nposition of the mouse, relative to (0, 0) of the window.

\n","itemtype":"property","name":"winMouseY","example":["\n
\n\nvar myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\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}\n\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":179,"description":"

The system variable pwinMouseX always contains the horizontal position\nof the mouse in the frame previous to the current frame, relative to\n(0, 0) of the window.

\n","itemtype":"property","name":"pwinMouseX","example":["\n
\n\n\nvar 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 var 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}\n\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":216,"description":"

The system variable pwinMouseY always contains the vertical position of\nthe mouse in the frame previous to the current frame, relative to (0, 0)\nof the window.

\n","itemtype":"property","name":"pwinMouseY","example":["\n
\n\n\nvar 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 var 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}\n\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":254,"description":"

Processing automatically tracks if the mouse button is pressed and which\nbutton is pressed. The value of the system variable mouseButton is either\nLEFT, RIGHT, or CENTER depending on which button was pressed last.\nWarning: different browsers may track mouseButton differently.

\n","itemtype":"property","name":"mouseButton","example":["\n
\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n if (mouseIsPressed) {\n if (mouseButton == LEFT)\n ellipse(50, 50, 50, 50);\n if (mouseButton == RIGHT)\n rect(25, 25, 50, 50);\n if (mouseButton == CENTER)\n triangle(23, 75, 50, 20, 78, 75);\n }\n\n println(mouseButton);\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":285,"description":"

The boolean system variable mouseIsPressed is true if the mouse is pressed\nand false if not.

\n","itemtype":"property","name":"mouseIsPressed","example":["\n
\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n if (mouseIsPressed)\n ellipse(50, 50, 50, 50);\n else\n rect(25, 25, 50, 50);\n\n println(mouseIsPressed);\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":360,"description":"

The mouseMoved() function is called every time the mouse moves and a mouse\nbutton is not pressed.

\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.

\n","itemtype":"method","name":"mouseMoved","example":["\n
\n\n// Move the mouse across the page\n// to change its value\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mouseMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction mouseMoved() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":399,"description":"

The mouseDragged() function is called once every time the mouse moves and\na mouse button is pressed. If no mouseDragged() function is defined, the\ntouchMoved() function will be called instead if it is defined.

\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.

\n","itemtype":"method","name":"mouseDragged","example":["\n
\n\n// Drag the mouse across the page\n// to change its value\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mouseDragged() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction mouseDragged() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":466,"description":"

The mousePressed() function is called once after every time a mouse button\nis pressed. The mouseButton variable (see the related reference entry)\ncan be used to determine which button has been pressed. If no\nmousePressed() function is defined, the touchStarted() function will be\ncalled instead if it is defined.

\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.

\n","itemtype":"method","name":"mousePressed","example":["\n
\n\n// Click within the image to change\n// the value of the rectangle\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mousePressed() {\n if (value == 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction mousePressed() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":529,"description":"

The mouseReleased() function is called every time a mouse button is\nreleased. If no mouseReleased() function is defined, the touchEnded()\nfunction will be called instead if it is defined.

\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.

\n","itemtype":"method","name":"mouseReleased","example":["\n
\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been clicked\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mouseReleased() {\n if (value == 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction mouseReleased() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":592,"description":"

The mouseClicked() function is called once after a mouse button has been\npressed and then released.

\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.

\n","itemtype":"method","name":"mouseClicked","example":["\n
\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been clicked\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mouseClicked() {\n if (value == 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction mouseClicked() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/mouse.js","line":642,"description":"

The function mouseWheel() is executed every time a vertical mouse wheel\nevent is detected either triggered by an actual mouse wheel or by a\ntouchpad.

\nThe event.delta property returns the amount the mouse wheel\nhave scrolled. The values can be positive or negative depending on the\nscroll direction (on OS X with "natural" scrolling enabled, the signs\nare inverted).

\nBrowsers may have different default behaviors attached to various\nmouse events. To prevent any default behavior for this event, add\n"return false" to the end of the method.

\nDue to the current support of the "wheel" event on Safari, the function\nmay only work as expected if "return false" is included while using Safari.

\n","itemtype":"method","name":"mouseWheel","example":["\n
\n\nvar pos = 25;\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n rect(25, pos, 50, 50);\n}\n\nfunction mouseWheel(event) {\n println(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\n
"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src/events/touch.js","line":20,"description":"

The system variable touchX always contains the horizontal position of\none finger, relative to (0, 0) of the canvas. This is best used for\nsingle touch interactions. For multi-touch interactions, use the\ntouches[] array.

\n","itemtype":"method","name":"touchX","example":["\n
\n\n// Touch and move the finger in horizontally across the canvas\nfunction setup() {\n createCanvas(100, 100);\n}\n\nfunction draw() {\n background(51);\n stroke(255, 204, 0);\n strokeWeight(4);\n rect(touchX, 50, 10, 10);\n}\n\n
"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":47,"description":"

The system variable touchY always contains the vertical position of\none finger, relative to (0, 0) of the canvas. This is best used for\nsingle touch interactions. For multi-touch interactions, use the\ntouches[] array.

\n","itemtype":"method","name":"touchY","example":["\n
\n\n// Touch and move the finger vertically across the canvas\nfunction setup() {\n createCanvas(100, 100);\n}\n\nfunction draw() {\n background(51);\n stroke(255, 204, 0);\n strokeWeight(4);\n rect(50, touchY, 10, 10);\n}\n\n
"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":74,"description":"

The system variable ptouchX always contains the horizontal position of\none finger, relative to (0, 0) of the canvas, in the frame previous to the\ncurrent frame.

\n","itemtype":"property","name":"ptouchX","class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":83,"description":"

The system variable ptouchY always contains the vertical position of\none finger, relative to (0, 0) of the canvas, in the frame previous to the\ncurrent frame.

\n","itemtype":"property","name":"ptouchY","class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":92,"description":"

The 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.

\n","itemtype":"property","name":"touches[]","class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":102,"description":"

The boolean system variable touchIsDown is true if the screen is\ntouched and false if not.

\n","itemtype":"property","name":"touchIsDown","class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":156,"description":"

The touchStarted() function is called once after every time a touch is\nregistered. If no touchStarted() function is defined, the mousePressed()\nfunction will be called instead if it is defined.

\nBrowsers may have different default behaviors attached to various touch\nevents. To prevent any default behavior for this event, add "return false"\nto the end of the method.

\n","itemtype":"method","name":"touchStarted","example":["\n
\n\n// Touch within the image to change\n// the value of the rectangle\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction touchStarted() {\n if (value == 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction touchStarted() {\n ellipse(touchX, touchY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":216,"description":"

The touchMoved() function is called every time a touch move is registered.\nIf no touchMoved() function is defined, the mouseDragged() function will\nbe called instead if it is defined.

\nBrowsers may have different default behaviors attached to various touch\nevents. To prevent any default behavior for this event, add "return false"\nto the end of the method.

\n","itemtype":"method","name":"touchMoved","example":["\n
\n\n// Move your finger across the page\n// to change its value\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction touchMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction touchMoved() {\n ellipse(touchX, touchY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src/events/touch.js","line":273,"description":"

The touchEnded() function is called every time a touch ends. If no\ntouchEnded() function is defined, the mouseReleased() function will be\ncalled instead if it is defined.

\nBrowsers may have different default behaviors attached to various touch\nevents. To prevent any default behavior for this event, add "return false"\nto the end of the method.

\n","itemtype":"method","name":"touchEnded","example":["\n
\n\n// Release touch within the image to\n// change the value of the rectangle\n\nvar value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction touchEnded() {\n if (value == 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n\n
\n\n
\n\nfunction touchEnded() {\n ellipse(touchX, touchY, 5, 5);\n // prevent default\n return false;\n}\n\n
"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src/image/filters.js","line":3,"description":"

This module defines the filters for use with image buffers.

\n

This 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.

\n

Generally speaking users of this module will use the Filters.apply method\non a canvas to create an effect.

\n

A number of functions are borrowed/adapted from\nhttp://www.html5rocks.com/en/tutorials/canvas/imagefilters/\nor the java processing implementation.

\n","class":"p5","module":"Events"},{"file":"src/image/filters.js","line":28,"description":"

Returns the pixel buffer for a canvas

\n","access":"private","tagname":"","params":[{"name":"canvas","description":"

the canvas to get pixels from

\n","type":"Canvas|ImageData"}],"return":{"description":"a one-dimensional array containing\n the data in thc RGBA order, with integer\n values between 0 and 255","type":"Uint8ClampedArray"},"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":51,"description":"

Returns a 32 bit number containing ARGB data at ith pixel in the\n1D array containing pixels data.

\n","access":"private","tagname":"","params":[{"name":"data","description":"

array returned by _toPixels()

\n","type":"Uint8ClampedArray"},{"name":"i","description":"

index of a 1D Image Array

\n","type":"Integer"}],"return":{"description":"32 bit integer value representing\n ARGB value.","type":"Integer"},"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":70,"description":"

Modifies pixels RGBA values to values contained in the data object.

\n","access":"private","tagname":"","params":[{"name":"pixels","description":"

array returned by _toPixels()

\n","type":"Uint8ClampedArray"},{"name":"data","description":"

source 1D array where each value\n represents ARGB values

\n","type":"Int32Array"}],"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":90,"description":"

Returns the ImageData object for a canvas\nhttps://developer.mozilla.org/en-US/docs/Web/API/ImageData

\n","access":"private","tagname":"","params":[{"name":"canvas","description":"

canvas to get image data from

\n","type":"Canvas|ImageData"}],"return":{"description":"Holder of pixel data (and width and\n height) for a canvas","type":"ImageData"},"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":113,"description":"

Returns a blank ImageData object.

\n","access":"private","tagname":"","params":[{"name":"width","description":"","type":"Integer"},{"name":"height","description":"","type":"Integer"}],"return":{"description":"","type":"ImageData"},"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":129,"description":"

Applys a filter function to a canvas.

\n

The difference between this and the actual filter functions defined below\nis that the filter functions generally modify the pixel buffer but do\nnot actually put that data back to the canvas (where it would actually\nupdate what is visible). By contrast this method does make the changes\nactually visible in the canvas.

\n

The apply method is the method that callers of this module would generally\nuse. It has been separated from the actual filters to support an advanced\nuse case of creating a filter chain that executes without actually updating\nthe canvas in between everystep.

\n","params":[{"name":"func","description":"

[description]

\n","type":"[type]"},{"name":"canvas","description":"

[description]

\n","type":"[type]"},{"name":"level","description":"

[description]

\n","type":"[type]"}],"return":{"description":"[description]","type":"[type]"},"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":168,"description":"

Converts the image to black and white pixels depending if they are above or\nbelow the threshold defined by the level parameter. The parameter must be\nbetween 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is used.

\n

Borrowed from http://www.html5rocks.com/en/tutorials/canvas/imagefilters/

\n","params":[{"name":"canvas","description":"","type":"Canvas"},{"name":"level","description":"","type":"Float"}],"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":203,"description":"

Converts any colors in the image to grayscale equivalents.\nNo parameter is used.

\n

Borrowed from http://www.html5rocks.com/en/tutorials/canvas/imagefilters/

\n","params":[{"name":"canvas","description":"","type":"Canvas"}],"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":225,"description":"

Sets the alpha channel to entirely opaque. No parameter is used.

\n","params":[{"name":"canvas","description":"","type":"Canvas"}],"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":240,"description":"

Sets each pixel to its inverse value. No parameter is used.

\n","params":[{"name":"UNKNOWN","description":"","type":"Invert"}],"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":256,"description":"

Limits each channel of the image to the number of colors specified as\nthe parameter. The parameter can be set to values between 2 and 255, but\nresults are most noticeable in the lower ranges.

\n

Adapted from java based processing implementation

\n","params":[{"name":"canvas","description":"","type":"Canvas"},{"name":"level","description":"","type":"Integer"}],"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":287,"description":"

reduces the bright areas in an image

\n","params":[{"name":"canvas","description":"","type":"Canvas"}],"class":"p5","module":"Events"},{"file":"src/image/filters.js","line":368,"description":"

increases the bright areas in an image

\n","params":[{"name":"canvas","description":"","type":"Canvas"}],"class":"p5","module":"Events"},{"file":"src/image/image.js","line":8,"description":"

This module defines the p5 methods for the p5.Image class\nfor drawing images to the main display canvas.

\n","class":"p5","module":"Image","submodule":"Image"},{"file":"src/image/image.js","line":24,"description":"

Creates a new p5.Image (the datatype for storing images). This provides a\nfresh buffer of pixels to play with. Set the size of the buffer with the\nwidth and height parameters.\n

\n.pixels gives access to an array containing the values for all the pixels\nin the display window.\nThese values are numbers. This array is the size (including an appropriate\nfactor for the pixelDensity) of the display window x4,\nrepresenting the R, G, B, A values in order for each pixel, moving from\nleft to right across each row, then down each column. See .pixels for\nmore info. It may also be simpler to use set() or get().\n

\nBefore accessing the pixels of an image, the data must loaded with the\nloadPixels() function. After the array data has been modified, the\nupdatePixels() function must be run to update the changes.

\n","itemtype":"method","name":"createImage","params":[{"name":"width","description":"

width in pixels

\n","type":"Integer"},{"name":"height","description":"

height in pixels

\n","type":"Integer"}],"return":{"description":"the p5.Image object","type":"p5.Image"},"example":["\n
\n\nimg = createImage(66, 66);\nimg.loadPixels();\nfor (i = 0; i < img.width; i++) {\n for (j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\n
\n\n
\n\nimg = createImage(66, 66);\nimg.loadPixels();\nfor (i = 0; i < img.width; i++) {\n for (j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102, i % img.width * 2));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\nimage(img, 34, 34);\n\n
\n\n
\n\nvar pink = color(255, 102, 204);\nimg = createImage(66, 66);\nimg.loadPixels();\nvar d = pixelDensity;\nvar halfImage = 4 * (width * d) * (height/2 * d);\nfor (var i = 0; i < halfImage; i+=4) {\n img.pixels[i] = red(pink);\n img.pixels[i+1] = green(pink);\n img.pixels[i+2] = blue(pink);\n img.pixels[i+3] = alpha(pink);\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\n
"],"class":"p5","module":"Image","submodule":"Image"},{"file":"src/image/image.js","line":97,"description":"

Save the current canvas as an image. In Safari, this will open the\nimage in the window and the user must provide their own\nfilename on save-as. Other browsers will either save the\nfile immediately, or prompt the user with a dialogue window.

\n","itemtype":"method","name":"saveCanvas","params":[{"name":"canvas","description":"

a variable representing a\n specific html5 canvas (optional)

\n","type":"[selectedCanvas]"},{"name":"filename","description":"","type":"[String]"},{"name":"extension","description":"

'jpg' or 'png'

\n","type":"[String]"}],"example":["\n
\nfunction setup() {\n var c = createCanvas(100, 100);\n background(255, 0, 0);\n saveCanvas(c, 'myCanvas', 'jpg');\n}\n
\n
\n// note that this example has the same result as above\n// if no canvas is specified, defaults to main canvas\nfunction setup() {\n createCanvas(100, 100);\n background(255, 0, 0);\n saveCanvas('myCanvas', 'jpg');\n}\n
\n
\n// all of the following are valid\nsaveCanvas(c, 'myCanvas', 'jpg');\nsaveCanvas(c, 'myCanvas');\nsaveCanvas(c);\nsaveCanvas('myCanvas', 'png');\nsaveCanvas('myCanvas');\nsaveCanvas();\n
"],"class":"p5","module":"Image","submodule":"Image"},{"file":"src/image/image.js","line":215,"description":"

Capture a sequence of frames that can be used to create a movie.\nAccepts a callback. For example, you may wish to send the frames\nto a server where they can be stored or converted into a movie.\nIf no callback is provided, the browser will pop up save dialogues in an\nattempt to download all of the images that have just been created. With the\ncallback provided the image data isn't saved by default but instead passed\nas an argument to the callback function as an array of objects, with the\nsize of array equal to the total number of frames.

\n","itemtype":"method","name":"saveFrames","params":[{"name":"filename","description":"","type":"String"},{"name":"extension","description":"

'jpg' or 'png'

\n","type":"String"},{"name":"duration","description":"

Duration in seconds to save the frames for.

\n","type":"Number"},{"name":"framerate","description":"

Framerate to save the frames in.

\n","type":"Number"},{"name":"callback","description":"

A 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 - an\n image/octet-stream, filename and extension.

\n","type":"Function","optional":true}],"example":["\n
\nfunction draw() {\n background(mouseX);\n}\n\nfunction mousePressed() {\n saveFrames(\"out\", \"png\", 1, 25, function(data){\n println(data);\n });\n}\n
"],"class":"p5","module":"Image","submodule":"Image"},{"file":"src/image/loading_displaying.js","line":17,"description":"

Loads an image from a path and creates a p5.Image from it.\n

\nThe image may not be immediately available for rendering\nIf you want to ensure that the image is ready before doing\nanything with it, place the loadImage() call in preload().\nYou may also supply a callback function to handle the image when it's ready.\n

\nThe path to the image should be relative to the HTML file\nthat links in your sketch. Loading an from a URL or other\nremote location may be blocked due to your browser's built-in\nsecurity.

\n","itemtype":"method","name":"loadImage","params":[{"name":"path","description":"

Path of the image to be loaded

\n","type":"String"},{"name":"successCallback","description":"

Function to be called once\n the image is loaded. Will be passed the\n p5.Image.

\n","type":"Function(p5.Image)","optional":true},{"name":"failureCallback","description":"

called with event error if\n the image fails to load.

\n","type":"Function(Event)","optional":true}],"return":{"description":"the p5.Image object","type":"p5.Image"},"example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/laDefense.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n}\n\n
\n
\n\nfunction setup() {\n // here we use a callback to display the image after loading\n loadImage(\"assets/laDefense.jpg\", function(img) {\n image(img, 0, 0);\n });\n}\n\n
"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src/image/loading_displaying.js","line":104,"description":"

Validates clipping params. Per drawImage spec sWidth and sHight cannot be\nnegative or greater than image intrinsic width and height

\n","access":"private","tagname":"","params":[{"name":"sVal","description":"","type":"Number"},{"name":"iVal","description":"","type":"Number"}],"return":{"description":"","type":"Number"},"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src/image/loading_displaying.js","line":122,"description":"

Draw an image to the main canvas of the p5js sketch

\n","itemtype":"method","name":"image","params":[{"name":"img","description":"

the image to display

\n","type":"p5.Image"},{"name":"sx","description":"

The X coordinate of the top left corner of the\n sub-rectangle of the source image to draw into\n the destination canvas.

\n","type":"Number","optional":true,"optdefault":"0"},{"name":"sy","description":"

The Y coordinate of the top left corner of the\n sub-rectangle of the source image to draw into\n the destination canvas.

\n","type":"Number","optional":true,"optdefault":"0"},{"name":"sWidth","description":"

The width of the sub-rectangle of the\n source image to draw into the destination\n canvas.

\n","type":"Number","optional":true,"optdefault":"img.width"},{"name":"sHeight","description":"

The height of the sub-rectangle of the\n source image to draw into the\n destination context.

\n","type":"Number","optional":true,"optdefault":"img.height"},{"name":"dx","description":"

The X coordinate in the destination canvas at\n which to place the top-left corner of the\n source image.

\n","type":"Number","optional":true,"optdefault":"0"},{"name":"dy","description":"

The Y coordinate in the destination canvas at\n which to place the top-left corner of the\n source image.

\n","type":"Number","optional":true,"optdefault":"0"},{"name":"dWidth","description":"

The width to draw the image in the destination\n canvas. This allows scaling of the drawn image.

\n","type":"Number","optional":true},{"name":"dHeight","description":"

The height to draw the image in the destination\n canvas. This allows scaling of the drawn image.

\n","type":"Number","optional":true}],"example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/laDefense.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n image(img, 0, 0, 100, 100);\n image(img, 0, 0, 100, 100, 0, 0, 100, 100);\n}\n\n
\n
\n\nfunction setup() {\n // here we use a callback to display the image after loading\n loadImage(\"assets/laDefense.jpg\", function(img) {\n image(img, 0, 0);\n });\n}\n\n
"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src/image/loading_displaying.js","line":231,"description":"

Sets the fill value for displaying images. Images can be tinted to\nspecified colors or made transparent by including an alpha value.\n

\nTo apply transparency to an image without affecting its color, use\nwhite as the tint color and specify an alpha value. For instance,\ntint(255, 128) will make an image 50% transparent (assuming the default\nalpha range of 0-255, which can be changed with colorMode()).\n

\nThe value for the gray parameter must be less than or equal to the current\nmaximum value as specified by colorMode(). The default maximum value is\n255.

\n","itemtype":"method","name":"tint","params":[{"name":"v1","description":"

gray value, red or hue value (depending on the\n current color mode), or color Array

\n","type":"Number|Array"},{"name":"v2","description":"

green or saturation value (depending on the\n current color mode)

\n","type":"Number|Array","optional":true},{"name":"v3","description":"

blue or brightness value (depending on the\n current color mode)

\n","type":"Number|Array","optional":true},{"name":"a","description":"

opacity of the background

\n","type":"Number|Array","optional":true}],"example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/laDefense.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n tint(0, 153, 204); // Tint blue\n image(img, 50, 0);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/laDefense.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n tint(0, 153, 204, 126); // Tint blue and set transparency\n image(img, 50, 0);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/laDefense.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n tint(255, 126); // Apply transparency without changing color\n image(img, 50, 0);\n}\n\n
"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src/image/loading_displaying.js","line":300,"description":"

Removes the current fill value for displaying images and reverts to\ndisplaying images with their original hues.

\n","itemtype":"method","name":"noTint","example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n tint(0, 153, 204); // Tint blue\n image(img, 0, 0);\n noTint(); // Disable tint\n image(img, 50, 0);\n}\n\n
"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src/image/loading_displaying.js","line":325,"description":"

Apply the current tint color to the input image, return the resulting\ncanvas.

\n","params":[{"name":"The","description":"

image to be tinted

\n","type":"p5.Image"}],"return":{"description":"The resulting tinted canvas","type":"Canvas"},"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src/image/loading_displaying.js","line":361,"description":"

Set image mode. Modifies the location from which images are drawn by\nchanging the way in which parameters given to image() are interpreted.\nThe default mode is imageMode(CORNER), which interprets the second and\nthird parameters of image() as the upper-left corner of the image. If\ntwo additional parameters are specified, they are used to set the image's\nwidth and height.\n

\nimageMode(CORNERS) interprets the second and third parameters of image()\nas the location of one corner, and the fourth and fifth parameters as the\nopposite corner.\n

\nimageMode(CENTER) interprets the second and third parameters of image()\nas the image's center point. If two additional parameters are specified,\nthey are used to set the image's width and height.

\n","itemtype":"method","name":"imageMode","params":[{"name":"mode","description":"

either CORNER, CORNERS, or CENTER

\n","type":"Constant"}],"example":["\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n imageMode(CORNER);\n image(img, 10, 10, 50, 50);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n imageMode(CORNERS);\n image(img, 10, 10, 90, 40);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n imageMode(CENTER);\n image(img, 50, 50, 80, 80);\n}\n\n
"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src/image/p5.Image.js","line":9,"description":"

This module defines the p5.Image class and P5 methods for\ndrawing images to the main display canvas.

\n","class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":46,"description":"

Image width.

\n","itemtype":"property","name":"width","example":["\n
\nvar img;\nfunction preload() {\n img = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n createCanvas(100, 100);\n image(img, 0, 0);\n for (var i=0; i < img.width; i++) {\n var c = img.get(i, img.height/2);\n stroke(c);\n line(i, height/2, i, height);\n }\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":68,"description":"

Image height.

\n","itemtype":"property","name":"height","example":["\n
\nvar img;\nfunction preload() {\n img = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n createCanvas(100, 100);\n image(img, 0, 0);\n for (var i=0; i < img.height; i++) {\n var c = img.get(img.width/2, i);\n stroke(c);\n line(0, i, width/2, i);\n }\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":97,"description":"

Array containing the values for all the pixels in the display window.\nThese values are numbers. This array is the size (include an appropriate\nfactor for pixelDensity) of the display window x4,\nrepresenting the R, G, B, A values in order for each pixel, moving from\nleft to right across each row, then down each column. Retina and other\nhigh denisty displays may have more pixels[] (by a factor of\npixelDensity^2).\nFor example, if the image is 100x100 pixels, there will be 40,000. With\npixelDensity = 2, there will be 160,000. The first four values\n(indices 0-3) in the array will be the R, G, B, A values of the pixel at\n(0, 0). The second four values (indices 4-7) will contain the R, G, B, A\nvalues of the pixel at (1, 0). More generally, to set values for a pixel\nat (x, y):\n

var d = pixelDensity;\nfor (var i = 0; i < d; i++) {\n  for (var j = 0; j < d; j++) {\n    // loop over\n    idx = 4((y  d + j)  width  d + (x * d + i));\n    pixels[idx] = r;\n    pixels[idx+1] = g;\n    pixels[idx+2] = b;\n    pixels[idx+3] = a;\n  }\n}\n
\n

\nBefore accessing this array, the data must loaded with the loadPixels()\nfunction. After the array data has been modified, the updatePixels()\nfunction must be run to update the changes.

\n","itemtype":"property","name":"pixels[]","example":["\n
\n\nimg = createImage(66, 66);\nimg.loadPixels();\nfor (i = 0; i < img.width; i++) {\n for (j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\n
\n
\n\nvar pink = color(255, 102, 204);\nimg = createImage(66, 66);\nimg.loadPixels();\nfor (var i = 0; i < 4*(width*height/2); i+=4) {\n img.pixels[i] = red(pink);\n img.pixels[i+1] = green(pink);\n img.pixels[i+2] = blue(pink);\n img.pixels[i+3] = alpha(pink);\n}\nimg.updatePixels();\nimage(img, 17, 17);\n\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":161,"description":"

Helper fxn for sharing pixel methods

\n","class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":169,"description":"

Loads the pixels data for this image into the [pixels] attribute.

\n","itemtype":"method","name":"loadPixels","example":["\n
\nvar myImage;\nvar halfImage;\n\nfunction preload() {\n myImage = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n myImage.loadPixels();\n halfImage = 4 * width * height/2;\n for(var i = 0; i < halfImage; i++){\n myImage.pixels[i+halfImage] = myImage.pixels[i];\n }\n myImage.updatePixels();\n}\n\nfunction draw() {\n image(myImage, 0, 0);\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":200,"description":"

Updates the backing canvas for this image with the contents of\nthe [pixels] array.

\n","itemtype":"method","name":"updatePixels","params":[{"name":"x","description":"

x-offset of the target update area for the\n underlying canvas

\n","type":"Integer|undefined"},{"name":"y","description":"

y-offset of the target update area for the\n underlying canvas

\n","type":"Integer|undefined"},{"name":"w","description":"

height of the target update area for the\n underlying canvas

\n","type":"Integer|undefined"},{"name":"h","description":"

height of the target update area for the\n underlying canvas

\n","type":"Integer|undefined"}],"example":["\n
\nvar myImage;\nvar halfImage;\n\nfunction preload() {\n myImage = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n myImage.loadPixels();\n halfImage = 4 * width * height/2;\n for(var i = 0; i < halfImage; i++){\n myImage.pixels[i+halfImage] = myImage.pixels[i];\n }\n myImage.updatePixels();\n}\n\nfunction draw() {\n image(myImage, 0, 0);\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":240,"description":"

Get a region of pixels from an image.

\n

If no params are passed, those whole image is returned,\nif x and y are the only params passed a single pixel is extracted\nif all params are passed a rectangle region is extracted and a p5.Image\nis returned.

\n

Returns undefined if the region is outside the bounds of the image

\n","itemtype":"method","name":"get","params":[{"name":"x","description":"

x-coordinate of the pixel

\n","type":"Number","optional":true},{"name":"y","description":"

y-coordinate of the pixel

\n","type":"Number","optional":true},{"name":"w","description":"

width

\n","type":"Number","optional":true},{"name":"h","description":"

height

\n","type":"Number","optional":true}],"return":{"description":"color of pixel at x,y in array format\n [R, G, B, A] or p5.Image","type":"Array/Color | p5.Image"},"example":["\n
\nvar myImage;\nvar c;\n\nfunction preload() {\n myImage = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n background(myImage);\n noStroke();\n c = myImage.get(60, 90);\n fill(c);\n rect(25, 25, 50, 50);\n}\n\n//get() returns color here\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":281,"description":"

Set the color of a single pixel or write an image into\nthis p5.Image.

\n

Note that for a large number of pixels this will\nbe slower than directly manipulating the pixels array\nand then calling updatePixels().

\n","itemtype":"method","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 a p5.Color | image to copy

\n","type":"Number|Array|Object"}],"example":["\n
\n\nimg = createImage(66, 66);\nimg.loadPixels();\nfor (i = 0; i < img.width; i++) {\n for (j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102, i % img.width * 2));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\nimage(img, 34, 34);\n\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":314,"description":"

Resize the image to a new width and height. To make the image scale\nproportionally, use 0 as the value for the wide or high parameter.\nFor instance, to make the width of an image 150 pixels, and change\nthe height using the same proportion, use resize(150, 0).

\n","itemtype":"method","name":"resize","params":[{"name":"width","description":"

the resized image width

\n","type":"Number"},{"name":"height","description":"

the resized image height

\n","type":"Number"}],"example":["\n
\nvar img;\n\nfunction setup() {\n img = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction draw() {\n image(img, 0, 0);\n}\n\nfunction mousePressed() {\n img.resize(50, 100);\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":387,"description":"

Copies a region of pixels from one image to another. If no\nsrcImage is specified this is used as the source. If the source\nand destination regions aren't the same size, it will\nautomatically resize source pixels to fit the specified\ntarget region.

\n","itemtype":"method","name":"copy","params":[{"name":"srcImage","description":"

source image

\n","type":"p5.Image|undefined"},{"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"}],"example":["\n
\nvar photo;\nvar bricks;\nvar x;\nvar y;\n\nfunction preload() {\n photo = loadImage(\"assets/rockies.jpg\");\n bricks = loadImage(\"assets/bricks.jpg\");\n}\n\nfunction setup() {\n x = bricks.width/2;\n y = bricks.height/2;\n photo.copy(bricks, 0, 0, x, y, 0, 0, x, y);\n image(photo, 0, 0);\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":428,"description":"

Masks part of an image from displaying by loading another\nimage and using it's blue channel as an alpha channel for\nthis image.

\n","itemtype":"method","name":"mask","params":[{"name":"srcImage","description":"

source image

\n","type":"p5.Image"}],"example":["\n
\nvar photo, maskImage;\nfunction preload() {\n photo = loadImage(\"assets/rockies.jpg\");\n maskImage = loadImage(\"assets/mask2.png\");\n}\n\nfunction setup() {\n createCanvas(100, 100);\n photo.mask(maskImage);\n image(photo, 0, 0);\n}\n
\n\nhttp://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/\n"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":486,"description":"

Applies an image filter to a p5.Image

\n","itemtype":"method","name":"filter","params":[{"name":"operation","description":"

one of threshold, gray, invert, posterize and\n opaque see Filters.js for docs on each available\n filter

\n","type":"String"},{"name":"value","description":"","type":"Number|undefined"}],"example":["\n
\nvar photo1;\nvar photo2;\n\nfunction preload() {\n photo1 = loadImage(\"assets/rockies.jpg\");\n photo2 = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n photo2.filter(\"gray\");\n image(photo1, 0, 0);\n image(photo2, width/2, 0);\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":515,"description":"

Copies a region of pixels from one image to another, using a specified\nblend mode to do the operation.

\n","itemtype":"method","name":"blend","params":[{"name":"srcImage","description":"

source image

\n","type":"p5.Image|undefined"},{"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

\n

Available 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

\n

http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/

\n","type":"Integer"}],"example":["\n
\nvar mountains;\nvar 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
\n
\nvar mountains;\nvar 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
\n
\nvar mountains;\nvar 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
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/p5.Image.js","line":589,"description":"

Saves the image to a file and force the browser to download it.\nAccepts two strings for filename and file extension\nSupports png (default) and jpg.

\n","itemtype":"method","name":"save","params":[{"name":"filename","description":"

give your file a name

\n","type":"String"},{"name":"extension","description":"

'png' or 'jpg'

\n","type":"String"}],"example":["\n
\nvar photo;\n\nfunction preload() {\n photo = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction draw() {\n image(photo, 0, 0);\n}\n\nfunction keyTyped() {\n if (key == 's') {\n photo.save(\"photo\", \"png\");\n }\n}\n
"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src/image/pixels.js","line":14,"description":"

Uint8ClampedArray\ncontaining the values for all the pixels in the display window.\nThese values are numbers. This array is the size (include an appropriate\nfactor for pixelDensity) of the display window x4,\nrepresenting the R, G, B, A values in order for each pixel, moving from\nleft to right across each row, then down each column. Retina and other\nhigh denisty displays will have more pixels[] (by a factor of\npixelDensity^2).\nFor example, if the image is 100x100 pixels, there will be 40,000. On a\nretina display, there will be 160,000.\n

\nThe first four values (indices 0-3) in the array will be the R, G, B, A\nvalues of the pixel at (0, 0). The second four values (indices 4-7) will\ncontain the R, G, B, A values of the pixel at (1, 0). More generally, to\nset values for a pixel at (x, y):\n

\nvar d = pixelDensity;\nfor (var i = 0; i < d; i++) {\n  for (var j = 0; j < d; j++) {\n    // loop over\n    idx = 4  ((y  d + j)  width  d + (x * d + i));\n    pixels[idx] = r;\n    pixels[idx+1] = g;\n    pixels[idx+2] = b;\n    pixels[idx+3] = a;\n  }\n}\n

\n

While the above method is complex, it is flexible enough to work with\nany pixelDensity. Note that set() will automatically take care of\nsetting all the appropriate values in pixels[] for a given (x, y) at\nany pixelDensity, but the performance may not be as fast when lots of\nmodifications are made to the pixel array.\n

\nBefore accessing this array, the data must loaded with the loadPixels()\nfunction. After the array data has been modified, the updatePixels()\nfunction must be run to update the changes.\n

\nNote that this is not a standard javascript array. This means that\nstandard javascript functions such as slice() or\narrayCopy() do not\nwork.

","itemtype":"property","name":"pixels[]","example":["\n
\n\nvar pink = color(255, 102, 204);\nloadPixels();\nvar d = pixelDensity();\nvar halfImage = 4 * (width * d) * (height/2 * d);\nfor (var 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\n
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/image/pixels.js","line":80,"description":"

Copies a region of pixels from one image to another, using a specified\nblend mode to do the operation.

\nAvailable blend modes are: BLEND | DARKEST | LIGHTEST | DIFFERENCE |\nMULTIPLY| EXCLUSION | SCREEN | REPLACE | OVERLAY | HARD_LIGHT |\nSOFT_LIGHT | DODGE | BURN | ADD | NORMAL

\n","itemtype":"method","name":"blend","params":[{"name":"srcImage","description":"

source image

\n","type":"p5.Image|undefined"},{"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

\n","type":"Integer"}],"example":["\n
\nvar img0;\nvar 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
\n
\nvar img0;\nvar 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
\n
\nvar img0;\nvar 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
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/image/pixels.js","line":155,"description":"

Copies a region of the canvas to another region of the canvas\nand copies a region of pixels from an image used as the srcImg parameter\ninto the canvas srcImage is specified this is used as the source. If\nthe source and destination regions aren't the same size, it will\nautomatically resize source pixels to fit the specified\ntarget region.

\n","itemtype":"method","name":"copy","params":[{"name":"srcImage","description":"

source image

\n","type":"p5.Image|undefined"},{"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"}],"example":["\n
\nvar 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 stroke(255);\n noFill();\n // Rectangle shows area being copied\n rect(7, 22, 10, 10);\n}\n
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/image/pixels.js","line":196,"description":"

Applies a filter to the canvas.\n

\n

The presets options are:\n

\n

THRESHOLD\nConverts the image to black and white pixels depending if they are above or\nbelow the threshold defined by the level parameter. The parameter must be\nbetween 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is used.\n

\n

GRAY\nConverts any colors in the image to grayscale equivalents. No parameter\nis used.\n

\n

OPAQUE\nSets the alpha channel to entirely opaque. No parameter is used.\n

\n

INVERT\nSets each pixel to its inverse value. No parameter is used.\n

\n

POSTERIZE\nLimits each channel of the image to the number of colors specified as the\nparameter. The parameter can be set to values between 2 and 255, but\nresults are most noticeable in the lower ranges.\n

\n

BLUR\nExecutes a Guassian blur with the level parameter specifying the extent\nof the blurring. If no parameter is used, the blur is equivalent to\nGuassian blur of radius 1. Larger values increase the blur.\n

\n

ERODE\nReduces the light areas. No parameter is used.\n

\n

DILATE\nIncreases the light areas. No parameter is used.

\n","itemtype":"method","name":"filter","params":[{"name":"filterType","description":"","type":"Constant"},{"name":"filterParam","description":"

an optional parameter unique\n to each filter, see above

\n","type":"Number"}],"example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(THRESHOLD);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(GRAY);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(OPAQUE);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(INVERT);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(POSTERIZE,3);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(DILATE);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(BLUR,3);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(ERODE);\n}\n\n
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/image/pixels.js","line":356,"description":"

Returns an array of [R,G,B,A] values for any pixel or grabs a section of\nan image. If no parameters are specified, the entire image 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

\nIf the pixel requested is outside of the image window, [0,0,0,255] is\nreturned. To get the numbers scaled according to the current color ranges\nand taking into account colorMode, use getColor instead of get.\n

\nGetting the color of a single pixel with get(x, y) is easy, but not as fast\nas grabbing the data directly from pixels[]. The equivalent statement to\nget(x, y) using pixels[] with pixel density d is\n\nvar off = (y width + x) d * 4;\n[pixels[off],\npixels[off+1],\npixels[off+2],\npixels[off+3]]\n

\nSee the reference for pixels[] for more information.

\n","itemtype":"method","name":"get","params":[{"name":"x","description":"

x-coordinate of the pixel

\n","type":"Number","optional":true},{"name":"y","description":"

y-coordinate of the pixel

\n","type":"Number","optional":true},{"name":"w","description":"

width

\n","type":"Number","optional":true},{"name":"h","description":"

height

\n","type":"Number","optional":true}],"return":{"description":"values of pixel at x,y in array format\n [R, G, B, A] or p5.Image","type":"Array|p5.Image"},"example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/rockies.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n var c = get();\n image(c, width/2, 0);\n}\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/rockies.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n var c = get(50, 90);\n fill(c);\n noStroke();\n rect(25, 25, 50, 50);\n}\n\n
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/image/pixels.js","line":422,"description":"

Loads the pixel data for the display window into the pixels[] array. This\nfunction must always be called before reading from or writing to pixels[].

\n","itemtype":"method","name":"loadPixels","example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n image(img, 0, 0);\n var d = pixelDensity();\n var halfImage = 4 * (img.width * d) *\n (img.height/2 * d);\n loadPixels();\n for (var i = 0; i < halfImage; i++) {\n pixels[i+halfImage] = pixels[i];\n }\n updatePixels();\n}\n\n
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/image/pixels.js","line":453,"description":"

Changes the color of any pixel, or writes an image directly to the\ndisplay window.

\n

The x and y parameters specify the pixel to change and the c parameter\nspecifies the color value. This can be a p5.Color object, or [R, G, B, A]\npixel array. It can also be a single grayscale value.\nWhen setting an image, the x and y parameters define the coordinates for\nthe upper-left corner of the image, regardless of the current imageMode().\n

\n

\nAfter using set(), you must call updatePixels() for your changes to\nappear. This should be called once all pixels have been set.\n

\n

Setting the color of a single pixel with set(x, y) is easy, but not as\nfast as putting the data directly into pixels[]. Setting the pixels[]\nvalues directly may be complicated when working with a retina display,\nbut will perform better when lots of pixels need to be set directly on\nevery loop.

\n

See the reference for pixels[] for more information.

","itemtype":"method","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":"

insert a grayscale value | a pixel array |\n a p5.Color object | a p5.Image to copy

\n","type":"Number|Array|Object"}],"example":["\n
\n\nvar black = color(0);\nset(30, 20, black);\nset(85, 20, black);\nset(85, 75, black);\nset(30, 75, black);\nupdatePixels();\n\n
\n\n
\n\nfor (var i = 30; i < width-15; i++) {\n for (var j = 20; j < height-25; j++) {\n var c = color(204-j, 153-i, 0);\n set(i, j, c);\n }\n}\nupdatePixels();\n\n
\n\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n set(0, 0, img);\n updatePixels();\n line(0, 0, width, height);\n line(0, height, width, 0);\n}\n\n
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/image/pixels.js","line":521,"description":"

Updates the display window with the data in the pixels[] array.\nUse in conjunction with loadPixels(). If you're only reading pixels from\nthe array, there's no need to call updatePixels() — updating is only\nnecessary to apply changes. updatePixels() should be called anytime the\npixels array is manipulated or set() is called.

\n","itemtype":"method","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":"w","description":"

height of region to update

\n","type":"Number","optional":true}],"example":["\n
\n\nvar img;\nfunction preload() {\n img = loadImage(\"assets/rockies.jpg\");\n}\n\nfunction setup() {\n image(img, 0, 0);\n var halfImage = 4 * (img.width * pixelDensity()) *\n (img.height * pixelDensity()/2);\n loadPixels();\n for (var i = 0; i < halfImage; i++) {\n pixels[i+halfImage] = pixels[i];\n }\n updatePixels();\n}\n\n
"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src/io/files.js","line":16,"description":"

Checks if we are in preload and returns the last arg which will be the\n_decrementPreload function if called from a loadX() function. Should\nonly be used in loadX() functions.

\n","access":"private","tagname":"","class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":35,"description":"

Loads an opentype font file (.otf, .ttf) from a file or a URL,\nand returns a PFont Object. This method is asynchronous,\nmeaning it may not finish before the next line in your sketch\nis executed.\n

\nThe path to the font should be relative to the HTML file\nthat links in your sketch. Loading an from a URL or other\nremote location may be blocked due to your browser's built-in\nsecurity.

\n","itemtype":"method","name":"loadFont","params":[{"name":"path","description":"

name of the file or url to load

\n","type":"String"},{"name":"callback","description":"

function to be executed after\n loadFont()\n completes

\n","type":"Function","optional":true}],"return":{"description":"p5.Font object","type":"Object"},"example":["\n\n

Calling loadFont() inside preload() guarantees that the load\noperation will have completed before setup() and draw() are called.

\n\n
\nvar myFont;\nfunction preload() {\n myFont = loadFont('assets/AvenirNextLTPro-Demi.otf');\n}\n\nfunction setup() {\n fill('#ED225D');\n textFont(myFont);\n textSize(36);\n text('p5*js', 10, 50);\n}\n
\n\nOutside of preload(), you may supply a callback function to handle the\nobject:\n\n
\nfunction setup() {\n loadFont('assets/AvenirNextLTPro-Demi.otf', drawText);\n}\n\nfunction drawText(font) {\n fill('#ED225D');\n textFont(font, 36);\n text('p5*js', 10, 50);\n}\n\n
\n\n

You can also use the string name of the font to style other HTML\nelements.

\n\n
\nvar myFont;\n\nfunction preload() {\n myFont = loadFont('assets/Avenir.otf');\n}\n\nfunction setup() {\n var myDiv = createDiv('hello there');\n myDiv.style('font-family', 'Avenir');\n}\n
"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":165,"description":"

Loads a JSON file from a file or a URL, and returns an Object or Array.\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed.

\n","itemtype":"method","name":"loadJSON","params":[{"name":"path","description":"

name of the file or url to load

\n","type":"String"},{"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},{"name":"datatype","description":"

"json" or "jsonp"

\n","type":"String","optional":true}],"return":{"description":"JSON data","type":"Object|Array"},"example":["\n\n

Calling loadJSON() inside preload() guarantees to complete the\noperation before setup() and draw() are called.

\n\n
\nvar weather;\nfunction preload() {\n var url = 'http://api.openweathermap.org/data/2.5/weather?q=London,UK'+\n '&APPID=7bbbb47522848e8b9c26ba35c226c734';\n weather = loadJSON(url);\n}\n\nfunction setup() {\n noLoop();\n}\n\nfunction draw() {\n background(200);\n // get the humidity value out of the loaded JSON\n var humidity = weather.main.humidity;\n fill(0, humidity); // use the humidity value to set the alpha\n ellipse(width/2, height/2, 50, 50);\n}\n
\n\n\n

Outside of preload(), you may supply a callback function to handle the\nobject:

\n
\nfunction setup() {\n noLoop();\n var url = 'http://api.openweathermap.org/data/2.5/weather?q=NewYork'+\n '&APPID=7bbbb47522848e8b9c26ba35c226c734';\n loadJSON(url, drawWeather);\n}\n\nfunction draw() {\n background(200);\n}\n\nfunction drawWeather(weather) {\n // get the humidity value out of the loaded JSON\n var humidity = weather.main.humidity;\n fill(0, humidity); // use the humidity value to set the alpha\n ellipse(width/2, height/2, 50, 50);\n}\n
\n"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":280,"description":"

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.\n

\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.\n

\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed.

\n","itemtype":"method","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}],"return":{"description":"Array of Strings","type":"Array"},"example":["\n\n

Calling loadStrings() inside preload() guarantees to complete the\noperation before setup() and draw() are called.

\n\n
\nvar result;\nfunction preload() {\n result = loadStrings('assets/test.txt');\n}\n\nfunction setup() {\n background(200);\n var ind = floor(random(result.length));\n text(result[ind], 10, 10, 80, 80);\n}\n
\n\n

Outside of preload(), you may supply a callback function to handle the\nobject:

\n\n
\nfunction setup() {\n loadStrings('assets/test.txt', pickString);\n}\n\nfunction pickString(result) {\n background(200);\n var ind = floor(random(result.length));\n text(result[ind], 10, 10, 80, 80);\n}\n
"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":376,"description":"

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.

\n\n

Possible options include:\n

    \n
  • csv - parse the table as comma-separated values
  • \n
  • tsv - parse the table as tab-separated values
  • \n
  • header - this table has a header (title) row
  • \n
\n

\n\n

When passing in multiple options, pass them in as separate parameters,\nseperated by commas. For example:\n

\n\n loadTable("my_csv_file.csv", "csv", "header")\n\n

\n\n

All files loaded and saved use UTF-8 encoding.

\n\n

This 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.\n

Outside of preload(), you may supply a callback function to handle the\nobject:

\n

","itemtype":"method","name":"loadTable","params":[{"name":"filename","description":"

name of the file or URL to load

\n","type":"String"},{"name":"options","description":"

"header" "csv" "tsv"

\n","type":"String|Strings","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; otherwise, false\n is passed in.

\n","type":"Function","optional":true}],"return":{"description":"Table object containing data","type":"Object"},"example":["\n
\n\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\nvar 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 println(table.getRowCount() + \" total rows in table\");\n println(table.getColumnCount() + \" total columns in table\");\n\n println(table.getColumn(\"name\"));\n //[\"Goat\", \"Leopard\", \"Zebra\"]\n\n //cycle through the table\n for (var r = 0; r < table.getRowCount(); r++)\n for (var c = 0; c < table.getColumnCount(); c++) {\n println(table.getString(r, c));\n }\n}\n\n
"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":684,"description":"

Reads 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.

\n

Alternatively, 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.

\n

This 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.

\n

Outside of preload(), you may supply a callback function to handle the\nobject:

","itemtype":"method","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}],"return":{"description":"XML object containing data","type":"Object"},"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":761,"description":"

Method for executing an HTTP GET request. If data type is not specified,\np5 will try to guess based on the URL, defaulting to text.

\n","itemtype":"method","name":"httpGet","params":[{"name":"path","description":"

name of the file or url to load

\n","type":"String"},{"name":"data","description":"

param data passed sent with request

\n","type":"Object","optional":true},{"name":"datatype","description":"

"json", "jsonp", "xml", or "text"

\n","type":"String","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}],"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":785,"description":"

Method for executing an HTTP POST request. If data type is not specified,\np5 will try to guess based on the URL, defaulting to text.

\n","itemtype":"method","name":"httpPost","params":[{"name":"path","description":"

name of the file or url to load

\n","type":"String"},{"name":"data","description":"

param data passed sent with request

\n","type":"Object","optional":true},{"name":"datatype","description":"

"json", "jsonp", "xml", or "text"

\n","type":"String","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}],"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":809,"description":"

Method for executing an HTTP request. If data type is not specified,\np5 will try to guess based on the URL, defaulting to text.

\nYou may also pass a single object specifying all parameters for the\nrequest following the examples inside the reqwest() calls here:\n\nhttps://github.com/ded/reqwest#api

\n","itemtype":"method","name":"httpDo","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":"data","description":"

param data passed sent with request

\n","type":"Object","optional":true},{"name":"datatype","description":"

"json", "jsonp", "xml", or "text"

\n","type":"String","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}],"class":"p5","module":"IO","submodule":"Input"},{"file":"src/io/files.js","line":995,"description":"

Save an image, text, json, csv, wav, or html. Prompts download to\nthe client's computer. Note that it is not recommended to call save()\nwithin draw if it's looping, as the save() function will open a new save\ndialog every frame.

\n

The default behavior is to save the canvas as an image. You can\noptionally specify a filename.\nFor example:

\n
\nsave();\nsave('myCanvas.jpg'); // save a specific canvas with a filename\n
\n\n

Alternately, the first parameter can be a pointer to a canvas\np5.Element, an Array of Strings,\nan Array of JSON, a JSON object, a p5.Table, a p5.Image, or a\np5.SoundFile (requires p5.sound). The second parameter is a filename\n(including extension). The third parameter is for options specific\nto this type of object. This method will save a file that fits the\ngiven paramaters. For example:

\n\n
\n\nsave('myCanvas.jpg');           // Saves canvas as an image\n\nvar cnv = createCanvas(100, 100);\nsave(cnv, 'myCanvas.jpg');      // Saves canvas as an image\n\nvar gb = createGraphics(100, 100);\nsave(gb, 'myGraphics.jpg');      // Saves p5.Renderer object as an image\n\nsave(myTable, 'myTable.html');  // Saves table as html file\nsave(myTable, 'myTable.csv',);  // Comma Separated Values\nsave(myTable, 'myTable.tsv');   // Tab Separated Values\n\nsave(myJSON, 'my.json');        // Saves pretty JSON\nsave(myJSON, 'my.json', true);  // Optimizes JSON filesize\n\nsave(img, 'my.png');            // Saves pImage as a png image\n\nsave(arrayOfStrings, 'my.txt'); // Saves strings to a text file with line\n                                // breaks after each item in the array\n
","itemtype":"method","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]"},{"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]"},{"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.

\n","type":"[Boolean/String]"}],"class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1112,"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.

\n","itemtype":"method","name":"saveJSON","params":[{"name":"json","description":"","type":"Array|Object"},{"name":"filename","description":"","type":"String"},{"name":"optimize","description":"

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}],"example":["\n
\nvar json;\n\nfunction setup() {\n\n json = {}; // new JSON Object\n\n json.id = 0;\n json.species = 'Panthera leo';\n json.name = 'Lion';\n\n// To save, un-comment the line below, then click 'run'\n// saveJSON(json, 'lion.json');\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
"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1168,"description":"

Writes an array of Strings to a text file, one line per String.\nThe file saving process and location of the saved file will\nvary between web browsers.

\n","itemtype":"method","name":"saveStrings","params":[{"name":"list","description":"

string array to be written

\n","type":"Array"},{"name":"filename","description":"

filename for output

\n","type":"String"}],"example":["\n
\nvar words = 'apple bear cat dog';\n\n// .split() outputs an Array\nvar list = split(words, ' ');\n\n// To save the file, un-comment next line and click 'run'\n// saveStrings(list, 'nouns.txt');\n\n// Saves the following to a file called 'nouns.txt':\n//\n// apple\n// bear\n// cat\n// dog\n
"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1233,"description":"

Writes the contents of a Table object to a file. Defaults to a\ntext file with comma-separated-values ('csv') but can also\nuse tab separation ('tsv'), or generate an HTML table ('html').\nThe file saving process and location of the saved file will\nvary between web browsers.

\n","itemtype":"method","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}],"example":["\n
\nvar table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('id');\n table.addColumn('species');\n table.addColumn('name');\n\n var 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\n // Saves the following to a file called 'new.csv':\n // id,species,name\n // 0,Panthera leo,Lion\n
"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1348,"description":"

Generate a blob of file data as a url to prepare for download.\nAccepts an array of data, a filename, and an extension (optional).\nThis is a private function because it does not do any formatting,\nbut it is used by saveStrings, saveJSON, saveTable etc.

\n","params":[{"name":"dataToDownload","description":"","type":"Array"},{"name":"filename","description":"","type":"String"},{"name":"extension","description":"","type":"[String]"}],"access":"private","tagname":"","class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1371,"description":"

Forces download. Accepts a url to filedata/blob, a filename,\nand an extension (optional).\nThis is a private function because it does not do any formatting,\nbut it is used by saveStrings, saveJSON, saveTable etc.

\n","params":[{"name":"href","description":"

i.e. an href generated by createObjectURL

\n","type":"String"},{"name":"filename","description":"","type":"[String]"},{"name":"extension","description":"","type":"[String]"}],"class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1407,"description":"

Returns a file extension, or another string\nif the provided parameter has no extension.

\n","params":[{"name":"filename","description":"","type":"String"}],"return":{"description":"[fileName, fileExtension]","type":"Array"},"access":"private","tagname":"","class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1439,"description":"

Returns true if the browser is Safari, false if not.\nSafari makes trouble for downloading files.

\n","return":{"description":"[description]","type":"Boolean"},"access":"private","tagname":"","class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/files.js","line":1451,"description":"

Helper function, a callback for download that deletes\nan invisible anchor element from the DOM once the file\nhas been automatically downloaded.

\n","access":"private","tagname":"","class":"p5","module":"IO","submodule":"Output"},{"file":"src/io/p5.Table.js","line":12,"description":"

Table Options

\n

Generic class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.

\n

CSV files are\n\ncomma separated values, often with the data in quotes. TSV\nfiles use tabs as separators, and usually don't bother with the\nquotes.

\n

File names should end with .csv if they're comma separated.

\n

A rough "spec" for CSV can be found\nhere.

\n

To load files, use the loadTable method.

\n

To save tables to your computer, use the save method\n or the saveTable method.

\n\n

Possible options include:

\n
    \n
  • csv - parse the table as comma-separated values\n
  • tsv - parse the table as tab-separated values\n
  • header - this table has a header (title) row\n
","class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":47,"itemtype":"property","name":"columns","type":"{Array}","class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":53,"itemtype":"property","name":"rows","type":"{Array}","class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":60,"description":"

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().

\n

If a p5.TableRow object is included as a parameter, then that row is\nduplicated and added to the table.

\n","itemtype":"method","name":"addRow","params":[{"name":"row","description":"

row to be added to the table

\n","type":"p5.TableRow","optional":true}],"example":["\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\n var table;\n\n function 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\n function setup() {\n //add a row\n var 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 (var r = 0; r < table.getRowCount(); r++)\n for (var c = 0; c < table.getColumnCount(); c++)\n println(table.getString(r, c));\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":119,"description":"

Removes a row from the table object.

\n","itemtype":"method","name":"removeRow","params":[{"name":"id","description":"

ID number of the row to remove

\n","type":"Number"}],"example":["\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\nvar 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 var r = table.removeRow(0);\n\n //print the results\n for (var r = 0; r < table.getRowCount(); r++)\n for (var c = 0; c < table.getColumnCount(); c++)\n println(table.getString(r, c));\n}\n\n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":164,"description":"

Returns a reference to the specified p5.TableRow. The reference\ncan then be used to get and set values of the selected row.

\n","itemtype":"method","name":"getRow","params":[{"name":"rowID","description":"

ID number of the row to get

\n","type":"Number"}],"return":{"description":"p5.TableRow object","type":"TableRow"},"example":["\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\nvar 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 var row = table.getRow(1);\n //print it column by column\n //note: a row is an object, not an array\n for (var c = 0; c < table.getColumnCount(); c++)\n println(row.getString(c));\n}\n\n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":205,"description":"

Gets all rows from the table. Returns an array of p5.TableRows.

\n","itemtype":"method","name":"getRows","return":{"description":"Array of p5.TableRows","type":"Array"},"example":["\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\n var table;\n\n function 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\n function setup() {\n var rows = table.getRows();\n\n //warning: rows is an array of objects\n for (var r = 0; r < rows.length; r++)\n rows[r].set(\"name\", \"Unicorn\");\n\n //print the results\n for (var r = 0; r < table.getRowCount(); r++)\n for (var c = 0; c < table.getColumnCount(); c++)\n println(table.getString(r, c));\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":249,"description":"

Finds the first row in the Table that contains the value\nprovided, and returns a reference to that row. Even if\nmultiple rows are possible matches, only the first matching\nrow is returned. The column to search may be specified by\neither its ID or title.

\n","itemtype":"method","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":"Number|String"}],"return":{"description":"","type":"TableRow"},"example":["\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\n var table;\n\n function 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\n function setup() {\n //find the animal named zebra\n var row = table.findRow(\"Zebra\", \"name\");\n //find the corresponding species\n println(row.getString(\"species\"));\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":311,"description":"

Finds the rows in the Table that contain the value\nprovided, and returns references to those rows. Returns an\nArray, so for must be used to iterate through all the rows,\nas shown in the example above. The column to search may be\nspecified by either its ID or title.

\n","itemtype":"method","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":"Number|String"}],"return":{"description":"An Array of TableRow objects","type":"Array"},"example":["\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\n var table;\n\n function 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\n function setup() {\n //add another goat\n var 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 var rows = table.findRows(\"Goat\", \"name\");\n println(rows.length + \" Goats found\");\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":377,"description":"

Finds the first row in the Table that matches the regular\nexpression provided, and returns a reference to that row.\nEven if multiple rows are possible matches, only the first\nmatching row is returned. The column to search may be\nspecified by either its ID or title.

\n","itemtype":"method","name":"matchRow","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|Number"}],"return":{"description":"TableRow object","type":"TableRow"},"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":409,"description":"

Finds the rows in the Table that match the regular expression provided,\nand returns references to those rows. Returns an array, so for must be\nused to iterate through all the rows, as shown in the example. The\ncolumn to search may be specified by either its ID or title.

\n","itemtype":"method","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|Number","optional":true}],"return":{"description":"An Array of TableRow objects","type":"Array"},"example":["\nvar table;\n\nfunction setup() {\n\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n var 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 var rows = table.matchRows('R.*', 'type');\n for (var i = 0; i < rows.length; i++) {\n println(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":476,"description":"

Retrieves all values in the specified column, and returns them\nas an array. The column may be specified by either its ID or title.

\n","itemtype":"method","name":"getColumn","params":[{"name":"column","description":"

String or Number of the column to return

\n","type":"String|Number"}],"return":{"description":"Array of column values","type":"Array"},"example":["\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\n var table;\n\n function 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\n function setup() {\n //getColumn returns an array that can be printed directly\n println(table.getColumn(\"species\"));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":525,"description":"

Removes all rows from a Table. While all rows are removed,\ncolumns and column titles are maintained.

\n","itemtype":"method","name":"clearRows","example":["\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\n var table;\n\n function 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\n function setup() {\n table.clearRows();\n println(table.getRowCount() + \" total rows in table\");\n println(table.getColumnCount() + \" total columns in table\");\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":563,"description":"

Use addColumn() to add a new column to a Table object.\nTypically, you will want to specify a title, so the column\nmay be easily referenced later by name. (If no title is\nspecified, the new column's title will be null.)

\n","itemtype":"method","name":"addColumn","params":[{"name":"title","description":"

title of the given column

\n","type":"String","optional":true}],"example":["\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\n var table;\n\n function 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\n function 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 (var r = 0; r < table.getRowCount(); r++)\n for (var c = 0; c < table.getColumnCount(); c++)\n println(table.getString(r, c));\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":610,"description":"

Returns the total number of columns in a Table.

\n","return":{"description":"Number of columns in this table","type":"Number"},"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":619,"description":"

Returns the total number of rows in a Table.

\n","itemtype":"method","name":"getRowCount","return":{"description":"Number of rows in this table","type":"Number"},"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":630,"description":"

Removes any of the specified characters (or "tokens").

\n\n

If 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.

","itemtype":"method","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|Number","optional":true}],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":681,"description":"

Trims leading and trailing whitespace, such as spaces and tabs,\nfrom String table values. If no column is specified, then the\nvalues in all columns and rows are trimmed. A specific column\nmay be referenced by either its ID or title.

\n","itemtype":"method","name":"trim","params":[{"name":"column","description":"

Column ID (number)\n or name (string)

\n","type":"String|Number"}],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":723,"description":"

Use removeColumn() to remove an existing column from a Table\nobject. The column to be removed may be identified by either\nits title (a String) or its index value (an int).\nremoveColumn(0) would remove the first column, removeColumn(1)\nwould remove the second column, and so on.

\n","itemtype":"method","name":"removeColumn","params":[{"name":"column","description":"

columnName (string) or ID (number)

\n","type":"String|Number"}],"example":["\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\n var table;\n\n function 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\n function setup() {\n table.removeColumn(\"id\");\n println(table.getColumnCount());\n }\n \n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":788,"description":"

Stores a value in the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified\nby either its ID or title.

\n","itemtype":"method","name":"set","params":[{"name":"column","description":"

column ID (Number)\n or title (String)

\n","type":"String|Number"},{"name":"value","description":"

value to assign

\n","type":"String|Number"}],"example":["\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\nvar 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 (var r = 0; r < table.getRowCount(); r++)\n for (var c = 0; c < table.getColumnCount(); c++)\n println(table.getString(r, c));\n}\n\n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":833,"description":"

Stores a Float value in the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified\nby either its ID or title.

\n","itemtype":"method","name":"setNum","params":[{"name":"row","description":"

row ID

\n","type":"Number"},{"name":"column","description":"

column ID (Number)\n or title (String)

\n","type":"String|Number"},{"name":"value","description":"

value to assign

\n","type":"Number"}],"example":["\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\nvar 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 println(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n}\n\n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":877,"description":"

Stores a String value in the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified\nby either its ID or title.

\n","itemtype":"method","name":"setString","params":[{"name":"row","description":"

row ID

\n","type":"Number"},{"name":"column","description":"

column ID (Number)\n or title (String)

\n","type":"String|Number"},{"name":"value","description":"

value to assign

\n","type":"String"}],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":892,"description":"

Retrieves a value from the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified by\neither its ID or title.

\n","itemtype":"method","name":"get","params":[{"name":"row","description":"

row ID

\n","type":"Number"},{"name":"column","description":"

columnName (string) or\n ID (number)

\n","type":"String|Number"}],"return":{"description":"","type":"String|Number"},"example":["\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\nvar 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 println(table.get(0, 1));\n //Capra hircus\n println(table.get(0, \"species\"));\n //Capra hircus\n}\n\n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":935,"description":"

Retrieves a Float value from the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified by\neither its ID or title.

\n","itemtype":"method","name":"getNum","params":[{"name":"row","description":"

row ID

\n","type":"Number"},{"name":"column","description":"

columnName (string) or\n ID (number)

\n","type":"String|Number"}],"return":{"description":"","type":"Number"},"example":["\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\nvar 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 println(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n}\n\n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":976,"description":"

Retrieves a String value from the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified by\neither its ID or title.

\n","itemtype":"method","name":"getString","params":[{"name":"row","description":"

row ID

\n","type":"Number"},{"name":"column","description":"

columnName (string) or\n ID (number)

\n","type":"String|Number"}],"return":{"description":"","type":"String"},"example":["\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\nvar 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 var tableArray = table.getArray();\n\n //output each row as array\n for (var i = 0; i < tableArray.length; i++)\n println(tableArray[i]);\n}\n\n
"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":1020,"description":"

Retrieves all table data and returns as an object. If a column name is\npassed in, each row object will be stored with that attribute as its\ntitle.

\n","itemtype":"method","name":"getObject","params":[{"name":"headerColumn","description":"

Name of the column which should be used to\n title each row object (optional)

\n","type":"String"}],"return":{"description":"","type":"Object"},"example":["\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\nvar 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 var tableObject = table.getObject();\n\n println(tableObject);\n //outputs an object\n}\n\n
\n"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.Table.js","line":1081,"description":"

Retrieves all table data and returns it as a multidimensional array.

\n","itemtype":"method","name":"getArray","return":{"description":"","type":"Array"},"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src/io/p5.TableRow.js","line":42,"description":"

Stores a value in the TableRow's specified column.\nThe column may be specified by either its ID or title.

\n","itemtype":"method","name":"set","params":[{"name":"column","description":"

Column ID (Number)\n or Title (String)

\n","type":"String|Number"},{"name":"value","description":"

The value to be stored

\n","type":"String|Number"}],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src/io/p5.TableRow.js","line":78,"description":"

Stores a Float value in the TableRow's specified column.\nThe column may be specified by either its ID or title.

\n","itemtype":"method","name":"setNum","params":[{"name":"column","description":"

Column ID (Number)\n or Title (String)

\n","type":"String|Number"},{"name":"value","description":"

The value to be stored\n as a Float

\n","type":"Number"}],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src/io/p5.TableRow.js","line":94,"description":"

Stores a String value in the TableRow's specified column.\nThe column may be specified by either its ID or title.

\n","itemtype":"method","name":"setString","params":[{"name":"column","description":"

Column ID (Number)\n or Title (String)

\n","type":"String|Number"},{"name":"value","description":"

The value to be stored\n as a String

\n","type":"String"}],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src/io/p5.TableRow.js","line":109,"description":"

Retrieves a value from the TableRow's specified column.\nThe column may be specified by either its ID or title.

\n","itemtype":"method","name":"get","params":[{"name":"column","description":"

columnName (string) or\n ID (number)

\n","type":"String|Number"}],"return":{"description":"","type":"String|Number"},"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src/io/p5.TableRow.js","line":126,"description":"

Retrieves a Float value from the TableRow's specified\ncolumn. The column may be specified by either its ID or\ntitle.

\n","itemtype":"method","name":"getNum","params":[{"name":"column","description":"

columnName (string) or\n ID (number)

\n","type":"String|Number"}],"return":{"description":"Float Floating point number","type":"Number"},"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src/io/p5.TableRow.js","line":150,"description":"

Retrieves an String value from the TableRow's specified\ncolumn. The column may be specified by either its ID or\ntitle.

\n","itemtype":"method","name":"getString","params":[{"name":"column","description":"

columnName (string) or\n ID (number)

\n","type":"String|Number"}],"return":{"description":"String","type":"String"},"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src/io/p5.XML.js","line":62,"description":"

Gets a copy of the element's parent. Returns the parent as another\np5.XML object.

\n","itemtype":"method","name":"getParent","return":{"description":"element parent","type":"Object"},"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var children = xml.getChildren(\"animal\");\n var parent = children[1].getParent();\n println(parent.getName());\n}\n\n// Sketch prints:\n// mammals\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":100,"description":"

Gets the element's full name, which is returned as a String.

\n","itemtype":"method","name":"getName","return":{"description":"the name of the node","type":"String"},"example":["<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\n var xml;\n\n function preload() {\n xml = loadXML(\"assets/mammals.xml\");\n }\n\n function setup() {\n println(xml.getName());\n }\n\n // Sketch prints:\n // mammals\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":135,"description":"

Sets the element's name, which is specified as a String.

\n","itemtype":"method","name":"setName","params":[{"name":"the","description":"

new name of the node

\n","type":"String"}],"example":["<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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n println(xml.getName());\n xml.setName(\"fish\");\n println(xml.getName());\n}\n\n// Sketch prints:\n// mammals\n// fish\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":173,"description":"

Checks whether or not the element has any children, and returns the result\nas a boolean.

\n","itemtype":"method","name":"hasChildren","return":{"description":"","type":"Boolean"},"example":["<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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n println(xml.hasChildren());\n}\n\n// Sketch prints:\n// true\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":209,"description":"

Get the names of all of the element's children, and returns the names as an\narray of Strings. This is the same as looping through and calling getName()\non each child element individually.

\n","itemtype":"method","name":"listChildren","return":{"description":"names of the children of the element","type":"Array"},"example":["<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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n println(xml.listChildren());\n}\n\n// Sketch prints:\n// [\"animal\", \"animal\", \"animal\"]\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":246,"description":"

Returns all of the element's children as an array of p5.XML objects. When\nthe name parameter is specified, then it will return all children that match\nthat name.

\n","itemtype":"method","name":"getChildren","params":[{"name":"name","description":"

element name

\n","type":"String","optional":true}],"return":{"description":"children of the element","type":"Array"},"example":["<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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var animals = xml.getChildren(\"animal\");\n\n for (var i = 0; i < animals.length; i++) {\n println(animals[i].getContent());\n }\n}\n\n// Sketch prints:\n// \"Goat\"\n// \"Leopard\"\n// \"Zebra\"\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":295,"description":"

Returns the first of the element's children that matches the name parameter\nor the child of the given index.It returns undefined if no matching\nchild is found.

\n","itemtype":"method","name":"getChild","params":[{"name":"name","description":"

element name or index

\n","type":"String|Number"}],"return":{"description":"","type":"p5.XML"},"example":["<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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.getContent());\n}\n\n// Sketch prints:\n// \"Goat\"\n
\n
\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var secondChild = xml.getChild(1);\n println(secondChild.getContent());\n}\n\n// Sketch prints:\n// \"Leopard\"\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":356,"description":"

Appends a new child to the element. The child can be specified with\neither a String, which will be used as the new tag's name, or as a\nreference to an existing p5.XML object.\nA reference to the newly created child is returned as an p5.XML object.

\n","itemtype":"method","name":"addChild","params":[{"name":"a","description":"

p5.XML Object which will be the child to be added

\n","type":"Object"}],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":373,"description":"

Removes the element specified by name or index.

\n","itemtype":"method","name":"removeChild","params":[{"name":"name","description":"

element name or index

\n","type":"String|Number"}],"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n xml.removeChild(\"animal\");\n var children = xml.getChildren();\n for (var i=0; i
\n
\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n xml.removeChild(1);\n var children = xml.getChildren();\n for (var i=0; i
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":446,"description":"

Counts the specified element's number of attributes, returned as an Number.

\n","itemtype":"method","name":"getAttributeCount","return":{"description":"","type":"Number"},"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.getAttributeCount());\n}\n\n// Sketch prints:\n// 2\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":482,"description":"

Gets all of the specified element's attributes, and returns them as an\narray of Strings.

\n","itemtype":"method","name":"listAttributes","return":{"description":"an array of strings containing the names of attributes","type":"Array"},"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.listAttributes());\n}\n\n// Sketch prints:\n// [\"id\", \"species\"]\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":519,"description":"

Checks whether or not an element has the specified attribute.

\n","itemtype":"method","name":"hasAttribute","params":[{"name":"the","description":"

attribute to be checked

\n","type":"String"}],"return":{"description":"true if attribute found else false","type":"Boolean"},"example":["\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\n var xml;\n\n function preload() {\n xml = loadXML(\"assets/mammals.xml\");\n }\n\n function setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.hasAttribute(\"species\"));\n println(firstChild.hasAttribute(\"color\"));\n }\n\n // Sketch prints:\n // true\n // false\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":558,"description":"

Returns an attribute value of the element as an Number. If the defaultValue\nparameter is specified and the attribute doesn't exist, then defaultValue\nis returned. If no defaultValue is specified and the attribute doesn't\nexist, the value 0 is returned.

\n","itemtype":"method","name":"getNumber","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}],"return":{"description":"","type":"Number"},"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.getNumber(\"id\"));\n}\n\n// Sketch prints:\n// 0\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":599,"description":"

Returns an attribute value of the element as an String. If the defaultValue\nparameter is specified and the attribute doesn't exist, then defaultValue\nis returned. If no defaultValue is specified and the attribute doesn't\nexist, null is returned.

\n","itemtype":"method","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}],"return":{"description":"","type":"Number"},"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.getString(\"species\"));\n}\n\n// Sketch prints:\n// \"Capra hircus\"\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":640,"description":"

Sets the content of an element's attribute. The first parameter specifies\nthe attribute name, while the second specifies the new content.

\n","itemtype":"method","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"}],"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.getString(\"species\"));\n firstChild.setAttribute(\"species\", \"Jamides zebra\");\n println(firstChild.getString(\"species\"));\n}\n\n// Sketch prints:\n// \"Capra hircus\"\n// \"Jamides zebra\"\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":683,"description":"

Returns the content of an element. If there is no such content,\ndefaultValue is returned if specified, otherwise null is returned.

\n","itemtype":"method","name":"getContent","params":[{"name":"defaultValue","description":"

value returned if no content is found

\n","type":"String","optional":true}],"return":{"description":"","type":"String"},"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.getContent());\n}\n\n// Sketch prints:\n// \"Goat\"\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":721,"description":"

Sets the element's content.

\n","itemtype":"method","name":"setContent","params":[{"name":"text","description":"

the new content

\n","type":"String"}],"example":["\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\nvar xml;\n\nfunction preload() {\n xml = loadXML(\"assets/mammals.xml\");\n}\n\nfunction setup() {\n var firstChild = xml.getChild(\"animal\");\n println(firstChild.getContent());\n firstChild.setContent(\"Mountain Goat\");\n println(firstChild.getContent());\n}\n\n// Sketch prints:\n// \"Goat\"\n// \"Mountain Goat\"\n
"],"class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":763,"description":"

This method is called while the parsing of XML (when loadXML() is\ncalled). The difference between this method and the setContent()\nmethod defined later is that this one is used to set the content\nwhen the node in question has more nodes under it and so on and\nnot directly text content. While in the other one is used when\nthe node in question directly has text inside it.

\n","class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/io/p5.XML.js","line":780,"description":"

This method is called while the parsing of XML (when loadXML() is\ncalled). The XML node is passed and its attributes are stored in the\np5.XML's attribute Object.

\n","class":"p5.XML","module":"IO","submodule":"XML"},{"file":"src/math/calculation.js","line":12,"description":"

Calculates the absolute value (magnitude) of a number. Maps to Math.abs().\nThe absolute value of a number is always positive.

\n","itemtype":"method","name":"abs","params":[{"name":"n","description":"

number to compute

\n","type":"Number"}],"return":{"description":"absolute value of given number","type":"Number"},"example":["\n
\nfunction setup() {\n var x = -3;\n var y = abs(x);\n\n println(x); // -3\n println(y); // 3\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":32,"description":"

Calculates the closest int value that is greater than or equal to the\nvalue of the parameter. Maps to Math.ceil(). For example, ceil(9.03)\nreturns the value 10.

\n","itemtype":"method","name":"ceil","params":[{"name":"n","description":"

number to round up

\n","type":"Number"}],"return":{"description":"rounded up number","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n // map, mouseX between 0 and 5.\n var ax = map(mouseX, 0, 100, 0, 5);\n var ay = 66;\n\n //Get the ceiling of the mapped number.\n var bx = ceil(map(mouseX, 0, 100, 0,5));\n var by = 33;\n\n // Multiply the mapped numbers by 20 to more easily\n // see the changes.\n stroke(0);\n fill(0);\n line(0, ay, ax * 20, ay);\n line(0, by, bx * 20, by);\n\n // Reformat the float returned by map and draw it.\n noStroke();\n text(nfc(ax, 2,2), ax, ay - 5);\n text(nfc(bx,1,1), bx, by - 5);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":68,"description":"

Constrains a value between a minimum and maximum value.

\n","itemtype":"method","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"}],"return":{"description":"constrained number","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n\n var leftWall = 25;\n var rightWall = 75;\n\n // xm is just the mouseX, while\n // xc is the mouseX, but constrained\n // between the leftWall and rightWall!\n var xm = mouseX;\n var xc = constrain(mouseX, leftWall, rightWall);\n\n // Draw the walls.\n stroke(150);\n line(leftWall, 0, leftWall, height);\n line(rightWall, 0, rightWall, height);\n\n // Draw xm and xc as circles.\n noStroke();\n fill(150);\n ellipse(xm, 33, 9,9); // Not Constrained\n fill(0);\n ellipse(xc, 66, 9,9); // Constrained\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":108,"description":"

Calculates the distance between two points.

\n","itemtype":"method","name":"dist","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":"z1","description":"

z-coordinate of the first point

\n","type":"Number","optional":true},{"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":"z2","description":"

z-coordinate of the second point

\n","type":"Number","optional":true}],"return":{"description":"distance between the two points","type":"Number"},"example":["\n
\n// Move your mouse inside the canvas to see the\n// change in distance between two points!\nfunction draw() {\n background(200);\n fill(0);\n\n var x1 = 10;\n var y1 = 90;\n var x2 = mouseX;\n var y2 = mouseY;\n\n line(x1, y1, x2, y2);\n ellipse(x1, y1, 7, 7);\n ellipse(x2, y2, 7, 7);\n\n // d is the length of the line\n // the distance from point 1 to point 2.\n var d = int(dist(x1, y1, x2, y2));\n\n // Let's write d along the line we are drawing!\n push();\n translate( (x1+x2)/2, (y1+y2)/2 );\n rotate( atan2(y2-y1,x2-x1) );\n text(nfc(d,1,1), 0, -5);\n pop();\n // Fancy!\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":159,"description":"

Returns Euler's number e (2.71828...) raised to the power of the n\nparameter. Maps to Math.exp().

\n","itemtype":"method","name":"exp","params":[{"name":"n","description":"

exponent to raise

\n","type":"Number"}],"return":{"description":"e^n","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n\n // Compute the exp() function with a value between 0 and 2\n var xValue = map(mouseX, 0, width, 0, 2);\n var yValue = exp(xValue);\n\n var y = map(yValue, 0, 8, height, 0);\n\n var legend = \"exp (\" + nfc(xValue, 3) +\")\\n= \" + nf(yValue, 1, 4);\n stroke(150);\n line(mouseX, y, mouseX, height);\n fill(0);\n text(legend, 5, 15);\n noStroke();\n ellipse (mouseX,y, 7, 7);\n\n // Draw the exp(x) curve,\n // over the domain of x from 0 to 2\n noFill();\n stroke(0);\n beginShape();\n for (var x = 0; x < width; x++) {\n xValue = map(x, 0, width, 0, 2);\n yValue = exp(xValue);\n y = map(yValue, 0, 8, height, 0);\n vertex(x, y);\n }\n\n endShape();\n line(0, 0, 0, height);\n line(0, height-1, width, height-1);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":205,"description":"

Calculates the closest int value that is less than or equal to the\nvalue of the parameter. Maps to Math.floor().

\n","itemtype":"method","name":"floor","params":[{"name":"n","description":"

number to round down

\n","type":"Number"}],"return":{"description":"rounded down number","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n //map, mouseX between 0 and 5.\n var ax = map(mouseX, 0, 100, 0, 5);\n var ay = 66;\n\n //Get the floor of the mapped number.\n var bx = floor(map(mouseX, 0, 100, 0,5));\n var by = 33;\n\n // Multiply the mapped numbers by 20 to more easily\n // see the changes.\n stroke(0);\n fill(0);\n line(0, ay, ax * 20, ay);\n line(0, by, bx * 20, by);\n\n // Reformat the float returned by map and draw it.\n noStroke();\n text(nfc(ax, 2,2), ax, ay - 5);\n text(nfc(bx,1,1), bx, by - 5);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":240,"description":"

Calculates a number between two numbers at a specific increment. The amt\nparameter is the amount to interpolate between the two values where 0.0\nequal to the first point, 0.1 is very near the first point, 0.5 is\nhalf-way in between, etc. The lerp function is convenient for creating\nmotion along a straight path and for drawing dotted lines.

\n","itemtype":"method","name":"lerp","params":[{"name":"start","description":"

first value

\n","type":"Number"},{"name":"stop","description":"

second value

\n","type":"Number"},{"name":"amt","description":"

number between 0.0 and 1.0

\n","type":"Number"}],"return":{"description":"lerped value","type":"Number"},"example":["\n
\nfunction setup() {\n background(200);\n var a = 20;\n var b = 80;\n var c = lerp(a,b, .2);\n var d = lerp(a,b, .5);\n var e = lerp(a,b, .8);\n\n var y = 50\n\n strokeWeight(5);\n stroke(0); // Draw the original points in black\n point(a, y);\n point(b, y);\n\n stroke(100); // Draw the lerp points in gray\n point(c, y);\n point(d, y);\n point(e, y);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":280,"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. Maps to\nMath.log().

\n","itemtype":"method","name":"log","params":[{"name":"n","description":"

number greater than 0

\n","type":"Number"}],"return":{"description":"natural logarithm of n","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n var maxX = 2.8;\n var maxY = 1.5;\n\n // Compute the natural log of a value between 0 and maxX\n var xValue = map(mouseX, 0, width, 0, maxX);\n if (xValue > 0) { // Cannot take the log of a negative number.\n var yValue = log(xValue);\n var y = map(yValue, -maxY, maxY, height, 0);\n\n // Display the calculation occurring.\n var legend = \"log(\" + nf(xValue, 1, 2) + \")\\n= \" + nf(yValue, 1, 3);\n stroke(150);\n line(mouseX, y, mouseX, height);\n fill(0);\n text (legend, 5, 15);\n noStroke();\n ellipse (mouseX, y, 7, 7);\n }\n\n // Draw the log(x) curve,\n // over the domain of x from 0 to maxX\n noFill();\n stroke(0);\n beginShape();\n for(var x=0; x < width; x++) {\n xValue = map(x, 0, width, 0, maxX);\n yValue = log(xValue);\n y = map(yValue, -maxY, maxY, height, 0);\n vertex(x, y);\n }\n endShape();\n line(0,0,0,height);\n line(0,height/2,width, height/2);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":330,"description":"

Calculates the magnitude (or length) of a vector. A vector is a direction\nin space commonly used in computer graphics and linear algebra. Because it\nhas no "start" position, the magnitude of a vector can be thought of as\nthe distance from the coordinate 0,0 to its x,y value. Therefore, mag() is\na shortcut for writing dist(0, 0, x, y).

\n","itemtype":"method","name":"mag","params":[{"name":"a","description":"

first value

\n","type":"Number"},{"name":"b","description":"

second value

\n","type":"Number"}],"return":{"description":"magnitude of vector from (0,0) to (a,b)","type":"Number"},"example":["\n
\nfunction setup() {\n var x1 = 20;\n var x2 = 80;\n var y1 = 30;\n var y2 = 70;\n\n line(0, 0, x1, y1);\n println(mag(x1, y1)); // Prints \"36.05551\"\n line(0, 0, x2, y1);\n println(mag(x2, y1)); // Prints \"85.44004\"\n line(0, 0, x1, y2);\n println(mag(x1, y2)); // Prints \"72.8011\"\n line(0, 0, x2, y2);\n println(mag(x2, y2)); // Prints \"106.30146\"\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":364,"description":"

Re-maps a number from one range to another.\n

\nIn the first example above, the number 25 is converted from a value in the\nrange of 0 to 100 into a value that ranges from the left edge of the\nwindow (0) to the right edge (width).

\n","itemtype":"method","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"}],"return":{"description":"remapped number","type":"Number"},"example":["\n
\n var value = 25;\n var m = map(value, 0, 100, 0, width);\n ellipse(m, 50, 10, 10);\n
\n\n
\n function setup() {\n noStroke();\n }\n\n function draw() {\n background(204);\n var x1 = map(mouseX, 0, width, 25, 75);\n ellipse(x1, 25, 25, 25);\n var x2 = map(mouseX, 0, width, 0, 100);\n ellipse(x2, 75, 25, 25);\n }\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":403,"description":"

Determines the largest value in a sequence of numbers, and then returns\nthat value. max() accepts any number of Number parameters, or an Array\nof any length.

\n","itemtype":"method","name":"max","params":[{"name":"n0","description":"

Numbers to compare

\n","type":"Number|Array"}],"return":{"description":"maximum Number","type":"Number"},"example":["\n
\nfunction setup() {\n // Change the elements in the array and run the sketch\n // to show how max() works!\n numArray = new Array(2,1,5,4,8,9);\n fill(0);\n noStroke();\n text(\"Array Elements\", 0, 10);\n // Draw all numbers in the array\n var spacing = 15;\n var elemsY = 25;\n for(var i = 0; i < numArray.length; i++) {\n text(numArray[i], i * spacing, elemsY);\n }\n maxX = 33;\n maxY = 80;\n // Draw the Maximum value in the array.\n textSize(32);\n text(max(numArray), maxX, maxY);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":442,"description":"

Determines the smallest value in a sequence of numbers, and then returns\nthat value. min() accepts any number of Number parameters, or an Array\nof any length.

\n","itemtype":"method","name":"min","params":[{"name":"n0","description":"

Numbers to compare

\n","type":"Number|Array"}],"return":{"description":"minimum Number","type":"Number"},"example":["\n
\nfunction setup() {\n // Change the elements in the array and run the sketch\n // to show how min() works!\n numArray = new Array(2,1,5,4,8,9);\n fill(0);\n noStroke();\n text(\"Array Elements\", 0, 10);\n // Draw all numbers in the array\n var spacing = 15;\n var elemsY = 25;\n for(var i = 0; i < numArray.length; i++) {\n text(numArray[i], i * spacing, elemsY);\n }\n maxX = 33;\n maxY = 80;\n // Draw the Minimum value in the array.\n textSize(32);\n text(min(numArray), maxX, maxY);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":481,"description":"

Normalizes a number from another range into a value between 0 and 1.\nIdentical to map(value, low, high, 0, 1).\nNumbers outside of the range are not clamped to 0 and 1, because\nout-of-range values are often intentional and useful. (See the second\nexample above.)

\n","itemtype":"method","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"}],"return":{"description":"normalized number","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n currentNum = mouseX;\n lowerBound = 0;\n upperBound = width; //100;\n normalized = norm(currentNum, lowerBound, upperBound);\n lineY = 70\n line(0, lineY, width, lineY);\n //Draw an ellipse mapped to the non-normalized value.\n noStroke();\n fill(50)\n var s = 7; // ellipse size\n ellipse(currentNum, lineY, s, s);\n\n // Draw the guide\n guideY = lineY + 15;\n text(\"0\", 0, guideY);\n textAlign(RIGHT);\n text(\"100\", width, guideY);\n\n // Draw the normalized value\n textAlign(LEFT);\n fill(0);\n textSize(32);\n normalY = 40;\n normalX = 20;\n text(normalized, normalX, normalY);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":529,"description":"

Facilitates exponential expressions. The pow() function is an efficient\nway of multiplying numbers by themselves (or their reciprocals) in large\nquantities. For example, pow(3, 5) is equivalent to the expression\n33333 and pow(3, -5) is equivalent to 1 / 33333. Maps to\nMath.pow().

\n","itemtype":"method","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"}],"return":{"description":"n^e","type":"Number"},"example":["\n
\nfunction setup() {\n //Exponentially increase the size of an ellipse.\n eSize = 3; // Original Size\n eLoc = 10; // Original Location\n\n ellipse(eLoc, eLoc, eSize, eSize);\n\n ellipse(eLoc*2, eLoc*2, pow(eSize, 2), pow(eSize, 2));\n\n ellipse(eLoc*4, eLoc*4, pow(eSize, 3), pow(eSize, 3));\n\n ellipse(eLoc*8, eLoc*8, pow(eSize, 4), pow(eSize, 4));\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":559,"description":"

Calculates the integer closest to the n parameter. For example,\nround(133.8) returns the value 134. Maps to Math.round().

\n","itemtype":"method","name":"round","params":[{"name":"n","description":"

number to round

\n","type":"Number"}],"return":{"description":"rounded number","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n //map, mouseX between 0 and 5.\n var ax = map(mouseX, 0, 100, 0, 5);\n var ay = 66;\n\n // Round the mapped number.\n var bx = round(map(mouseX, 0, 100, 0,5));\n var by = 33;\n\n // Multiply the mapped numbers by 20 to more easily\n // see the changes.\n stroke(0);\n fill(0);\n line(0, ay, ax * 20, ay);\n line(0, by, bx * 20, by);\n\n // Reformat the float returned by map and draw it.\n noStroke();\n text(nfc(ax, 2,2), ax, ay - 5);\n text(nfc(bx,1,1), bx, by - 5);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":594,"description":"

Squares a number (multiplies a number by itself). The result is always a\npositive number, as multiplying two negative numbers always yields a\npositive result. For example, -1 * -1 = 1.

\n","itemtype":"method","name":"sq","params":[{"name":"n","description":"

number to square

\n","type":"Number"}],"return":{"description":"squared number","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n eSize = 7;\n x1 = map(mouseX, 0, width, 0, 10);\n y1 = 80;\n x2 = sq(x1);\n y2 = 20;\n\n // Draw the non-squared.\n line(0, y1, width, y1);\n ellipse(x1, y1, eSize, eSize);\n\n // Draw the squared.\n line(0, y2, width, y2);\n ellipse(x2, y2, eSize, eSize);\n\n // Draw dividing line.\n stroke(100)\n line(0, height/2, width, height/2);\n\n // Draw text.\n var spacing = 15;\n noStroke();\n fill(0);\n text(\"x = \" + x1, 0, y1 + spacing);\n text(\"sq(x) = \" + x2, 0, y2 + spacing);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/calculation.js","line":635,"description":"

Calculates the square root of a number. The square root of a number is\nalways positive, even though there may be a valid negative root. The\nsquare root s of number a is such that s*s = a. It is the opposite of\nsquaring. Maps to Math.sqrt().

\n","itemtype":"method","name":"sqrt","params":[{"name":"n","description":"

non-negative number to square root

\n","type":"Number"}],"return":{"description":"square root of number","type":"Number"},"example":["\n
\nfunction draw() {\n background(200);\n eSize = 7;\n x1 = mouseX;\n y1 = 80;\n x2 = sqrt(x1);\n y2 = 20;\n\n // Draw the non-squared.\n line(0, y1, width, y1);\n ellipse(x1, y1, eSize, eSize);\n\n // Draw the squared.\n line(0, y2, width, y2);\n ellipse(x2, y2, eSize, eSize);\n\n // Draw dividing line.\n stroke(100)\n line(0, height/2, width, height/2);\n\n // Draw text.\n noStroke();\n fill(0);\n var spacing = 15;\n text(\"x = \" + x1, 0, y1 + spacing);\n text(\"sqrt(x) = \" + x2, 0, y2 + spacing);\n}\n
"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src/math/math.js","line":13,"description":"

Creates a new p5.Vector (the datatype for storing vectors). This provides a\ntwo or three dimensional vector, specifically a Euclidean (also known as\ngeometric) vector. A vector is an entity that has both magnitude and\ndirection.

\n","itemtype":"method","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","submodule":"Math"},{"file":"src/math/noise.js","line":41,"description":"

Returns the Perlin noise value at specified coordinates. Perlin noise is\na random sequence generator producing a more natural ordered, harmonic\nsuccession of numbers compared to the standard random() function.\nIt was invented by Ken Perlin in the 1980s and been used since in\ngraphical applications to produce procedural textures, natural motion,\nshapes, terrains etc.

The main difference to the\nrandom() function is that Perlin noise is defined in an infinite\nn-dimensional space where each pair of coordinates corresponds to a\nfixed semi-random value (fixed only for the lifespan of the program; see\nthe noiseSeed() function). p5.js can compute 1D, 2D and 3D noise,\ndepending on the number of coordinates given. The resulting value will\nalways be between 0.0 and 1.0. The noise value can be animated by moving\nthrough the noise space as demonstrated in the example above. The 2nd\nand 3rd dimension can also be interpreted as time.

The actual\nnoise is structured similar to an audio signal, in respect to the\nfunction's use of frequencies. Similar to the concept of harmonics in\nphysics, perlin noise is computed over several octaves which are added\ntogether for the final result.

Another way to adjust the\ncharacter of the resulting sequence is the scale of the input\ncoordinates. As the function works within an infinite space the value of\nthe coordinates doesn't matter as such, only the distance between\nsuccessive coordinates does (eg. when using noise() within a\nloop). As a general rule the smaller the difference between coordinates,\nthe smoother the resulting noise sequence will be. Steps of 0.005-0.03\nwork best for most applications, but this will differ depending on use.

\n","itemtype":"method","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"},{"name":"z","description":"

z-coordinate in noise space

\n","type":"Number"}],"return":{"description":"Perlin noise value (between 0 and 1) at specified\n coordinates","type":"Number"},"example":["\n
\nvar xoff = 0.0;\n\nfunction draw() {\n background(204);\n xoff = xoff + .01;\n var n = noise(xoff) * width;\n line(n, 0, n, height);\n}\n\n
\n
\nvar noiseScale=0.02;\n\nfunction draw() {\n background(0);\n for (var x=0; x < width; x++) {\n var noiseVal = noise((mouseX+x)*noiseScale, mouseY*noiseScale);\n stroke(noiseVal*255);\n line(x, mouseY+noiseVal*80, x, height);\n }\n}\n\n
"],"class":"p5","module":"Math","submodule":"Noise"},{"file":"src/math/noise.js","line":165,"description":"

Adjusts the character and level of detail produced by the Perlin noise\n function. Similar to harmonics in physics, noise is computed over\n several octaves. Lower octaves contribute more to the output signal and\n as such define the overall intensity of the noise, whereas higher octaves\n create finer grained details in the noise sequence.\n

\n By default, noise is computed over 4 octaves with each octave contributing\n exactly half than its predecessor, starting at 50% strength for the 1st\n octave. This falloff amount can be changed by adding an additional function\n parameter. Eg. a falloff factor of 0.75 means each octave will now have\n 75% impact (25% less) of the previous lower octave. Any value between\n 0.0 and 1.0 is valid, however note that values greater than 0.5 might\n result in greater than 1.0 values returned by noise().\n

\n By changing these parameters, the signal created by the noise()\n function can be adapted to fit very specific needs and characteristics.

\n","itemtype":"method","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"}],"example":["\n
\n \nvar noiseVal;\n var noiseScale=0.02;\nfunction setup() {\n createCanvas(100,100);\n }\nfunction draw() {\n background(0);\n for (var y = 0; y < height; y++) {\n for (var x = 0; x < width/2; x++) {\n noiseDetail(2,0.2);\n noiseVal = noise((mouseX+x) * noiseScale,\n (mouseY+y) * noiseScale);\n stroke(noiseVal*255);\n point(x,y);\n noiseDetail(8,0.65);\n noiseVal = noise((mouseX + x + width/2) * noiseScale,\n (mouseY + y) * noiseScale);\n stroke(noiseVal*255);\n point(x + width/2, y);\n }\n }\n }\n \n
"],"class":"p5","module":"Math","submodule":"Noise"},{"file":"src/math/noise.js","line":223,"description":"

Sets the seed value for noise(). By default, noise()\nproduces different results each time the program is run. Set the\nvalue parameter to a constant to return the same pseudo-random\nnumbers each time the software is run.

\n","itemtype":"method","name":"noiseSeed","params":[{"name":"seed","description":"

the seed value

\n","type":"Number"}],"example":["\n
\nvar xoff = 0.0;\n\nfunction setup() {\n noiseSeed(99);\n stroke(0, 10);\n}\n\nfunction draw() {\n xoff = xoff + .01;\n var n = noise(xoff) * width;\n line(n, 0, n, height);\n}\n\n
"],"class":"p5","module":"Math","submodule":"Noise"},{"file":"src/math/p5.Vector.js","line":65,"description":"

The x component of the vector

\n","itemtype":"property","name":"x","type":"{Number}","class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":71,"description":"

The y component of the vector

\n","itemtype":"property","name":"y","type":"{Number}","class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":77,"description":"

The z component of the vector

\n","itemtype":"property","name":"z","type":"{Number}","class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":85,"description":"

Returns a string representation of a vector v by calling String(v)\nor v.toString(). This method is useful for logging vectors in the\nconsole.

\n","itemtype":"method","name":"toString","example":["\n
\nfunction setup() {\n var v = createVector(20,30);\n println(String(v)); // prints \"p5.Vector Object : [20, 30, 0]\"\n}\n
\n"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":103,"description":"

Sets the x, y, and z component of the vector using two or three separate\nvariables, the data from a p5.Vector, or the values from a float array.

\n","itemtype":"method","name":"set","params":[{"name":"x","description":"

the x component of the vector or a\n p5.Vector or an Array

\n","type":"Number|p5.Vector|Array","optional":true},{"name":"y","description":"

the y component of the vector

\n","type":"Number","optional":true},{"name":"z","description":"

the z component of the vector

\n","type":"Number","optional":true}],"example":["\n
\n\nfunction setup() {\n var v = createVector(1, 2, 3);\n v.set(4,5,6); // Sets vector to [4, 5, 6]\n\n var v1 = createVector(0, 0, 0);\n var arr = [1, 2, 3];\n v1.set(arr); // Sets vector to [1, 2, 3]\n}\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":145,"description":"

Gets a copy of the vector, returns a p5.Vector object.

\n","itemtype":"method","name":"copy","return":{"description":"the copy of the p5.Vector object","type":"p5.Vector"},"example":["\n
\n\nvar v1 = createVector(1, 2, 3);\nvar v2 = v1.copy();\nprintln(v1.x == v2.x && v1.y == v2.y && v1.z == v2.z);\n// Prints \"true\"\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":168,"description":"

Adds x, y, and z components to a vector, adds one vector to another, or\nadds two independent vectors together. The version of the method that adds\ntwo vectors together is a static method and returns a p5.Vector, the others\nacts directly on the vector. See the examples for more context.

\n","itemtype":"method","name":"add","chainable":1,"params":[{"name":"x","description":"

the x component of the vector to be\n added or a p5.Vector or an Array

\n","type":"Number|p5.Vector|Array"},{"name":"y","description":"

the y component of the vector to be\n added

\n","type":"Number","optional":true},{"name":"z","description":"

the z component of the vector to be\n added

\n","type":"Number","optional":true}],"return":{"description":"the p5.Vector object.","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(1, 2, 3);\nv.add(4,5,6);\n// v's compnents are set to [5, 7, 9]\n\n
\n
\n\n// Static method\nvar v1 = createVector(1, 2, 3);\nvar v2 = createVector(2, 3, 4);\n\nvar v3 = p5.Vector.add(v1, v2);\n// v3 has components [3, 5, 7]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":221,"description":"

Subtracts x, y, and z components from a vector, subtracts one vector from\nanother, or subtracts two independent vectors. The version of the method\nthat subtracts two vectors is a static method and returns a p5.Vector, the\nother acts directly on the vector. See the examples for more context.

\n","itemtype":"method","name":"sub","chainable":1,"params":[{"name":"x","description":"

the x component of the vector or a\n p5.Vector or an Array

\n","type":"Number|p5.Vector|Array"},{"name":"y","description":"

the y component of the vector

\n","type":"Number","optional":true},{"name":"z","description":"

the z component of the vector

\n","type":"Number","optional":true}],"return":{"description":"p5.Vector object.","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(4, 5, 6);\nv.sub(1, 1, 1);\n// v's compnents are set to [3, 4, 5]\n\n
\n\n
\n\n// Static method\nvar v1 = createVector(2, 3, 4);\nvar v2 = createVector(1, 2, 3);\n\nvar v3 = p5.Vector.sub(v1, v2);\n// v3 has compnents [1, 1, 1]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":273,"description":"

Multiply the vector by a scalar. The static version of this method\ncreates a new p5.Vector while the non static version acts on the vector\ndirectly. See the examples for more context.

\n","itemtype":"method","name":"mult","chainable":1,"params":[{"name":"n","description":"

the number to multiply with the vector

\n","type":"Number"}],"return":{"description":"a reference to the p5.Vector object (allow chaining)","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(1, 2, 3);\nv.mult(2);\n// v's compnents are set to [2, 4, 6]\n\n
\n\n
\n\n// Static method\nvar v1 = createVector(1, 2, 3);\nvar v2 = p5.Vector.mult(v1, 2);\n// v2 has compnents [2, 4, 6]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":307,"description":"

Divide the vector by a scalar. The static version of this method creates a\nnew p5.Vector while the non static version acts on the vector directly.\nSee the examples for more context.

\n","itemtype":"method","name":"div","chainable":1,"params":[{"name":"n","description":"

the number to divide the vector by

\n","type":"Number"}],"return":{"description":"a reference to the p5.Vector object (allow chaining)","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(6, 4, 2);\nv.div(2); //v's compnents are set to [3, 2, 1]\n\n
\n\n
\n\n// Static method\nvar v1 = createVector(6, 4, 2);\nvar v2 = p5.Vector.div(v, 2);\n// v2 has compnents [3, 2, 1]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":340,"description":"

Calculates the magnitude (length) of the vector and returns the result as\na float (this is simply the equation sqrt(xx + yy + z*z).)

\n","itemtype":"method","name":"mag","return":{"description":"magnitude of the vector","type":"Number"},"example":["\n
\n\nvar v = createVector(20.0, 30.0, 40.0);\nvar m = v.mag();\nprintln(m); // Prints \"53.85164807134504\"\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":359,"description":"

Calculates the squared magnitude of the vector and returns the result\nas a float (this is simply the equation (xx + yy + z*z).)\nFaster if the real length is not required in the\ncase of comparing vectors, etc.

\n","itemtype":"method","name":"magSq","return":{"description":"squared magnitude of the vector","type":"Number"},"example":["\n
\n\n// Static method\nvar v1 = createVector(6, 4, 2);\nprintln(v1.magSq()); // Prints \"56\"\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":381,"description":"

Calculates the dot product of two vectors. The version of the method\nthat computes the dot product of two independent vectors is a static\nmethod. See the examples for more context.

\n","itemtype":"method","name":"dot","params":[{"name":"x","description":"

x component of the vector or a p5.Vector

\n","type":"Number|p5.Vector"},{"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}],"return":{"description":"the dot product","type":"Number"},"example":["\n
\n\nvar v1 = createVector(1, 2, 3);\nvar v2 = createVector(2, 3, 4);\n\nprintln(v1.dot(v2)); // Prints \"20\"\n\n
\n\n
\n\n//Static method\nvar v1 = createVector(1, 2, 3);\nvar v2 = createVector(3, 2, 1);\nprint (p5.Vector.dot(v1, v2)); // Prints \"10\"\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":421,"description":"

Calculates and returns a vector composed of the cross product between\ntwo vectors. Both the static and non static methods return a new p5.Vector.\nSee the examples for more context.

\n","itemtype":"method","name":"cross","params":[{"name":"v","description":"

p5.Vector to be crossed

\n","type":"p5.Vector"}],"return":{"description":"p5.Vector composed of cross product","type":"p5.Vector"},"example":["\n
\n\nvar v1 = createVector(1, 2, 3);\nvar v2 = createVector(1, 2, 3);\n\nv1.cross(v2); // v's components are [0, 0, 0]\n\n
\n\n
\n\n// Static method\nvar v1 = createVector(1, 0, 0);\nvar v2 = createVector(0, 1, 0);\n\nvar crossProduct = p5.Vector.cross(v1, v2);\n// crossProduct has components [0, 0, 1]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":461,"description":"

Calculates the Euclidean distance between two points (considering a\npoint as a vector object).

\n","itemtype":"method","name":"dist","params":[{"name":"v","description":"

the x, y, and z coordinates of a p5.Vector

\n","type":"p5.Vector"}],"return":{"description":"the distance","type":"Number"},"example":["\n
\n\nvar v1 = createVector(1, 0, 0);\nvar v2 = createVector(0, 1, 0);\n\nvar distance = v1.dist(v2); // distance is 1.4142...\n\n
\n
\n\n// Static method\nvar v1 = createVector(1, 0, 0);\nvar v2 = createVector(0, 1, 0);\n\nvar distance = p5.Vector.dist(v1,v2);\n// distance is 1.4142...\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":493,"description":"

Normalize the vector to length 1 (make it a unit vector).

\n","itemtype":"method","name":"normalize","return":{"description":"normalized p5.Vector","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(10, 20, 2);\n// v has compnents [10.0, 20.0, 2.0]\nv.normalize();\n// v's compnents are set to\n// [0.4454354, 0.8908708, 0.089087084]\n\n
\n"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":514,"description":"

Limit the magnitude of this vector to the value used for the max\nparameter.

\n","itemtype":"method","name":"limit","params":[{"name":"max","description":"

the maximum magnitude for the vector

\n","type":"Number"}],"return":{"description":"the modified p5.Vector","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(10, 20, 2);\n// v has compnents [10.0, 20.0, 2.0]\nv.limit(5);\n// v's compnents are set to\n// [2.2271771, 4.4543543, 0.4454354]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":541,"description":"

Set the magnitude of this vector to the value used for the len\nparameter.

\n","itemtype":"method","name":"setMag","params":[{"name":"len","description":"

the new length for this vector

\n","type":"Number"}],"return":{"description":"the modified p5.Vector","type":"p5.Vector"},"example":["\n
\n\nvar v1 = createVector(10, 20, 2);\n// v has compnents [10.0, 20.0, 2.0]\nv1.setMag(10);\n// v's compnents are set to [6.0, 8.0, 0.0]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":562,"description":"

Calculate the angle of rotation for this vector (only 2D vectors)

\n","itemtype":"method","name":"heading","return":{"description":"the angle of rotation","type":"Number"},"example":["\n
\nfunction setup() {\n var v1 = createVector(30,50);\n println(v1.heading()); // 1.0303768265243125\n\n var v1 = createVector(40,50);\n println(v1.heading()); // 0.8960553845713439\n\n var v1 = createVector(30,70);\n println(v1.heading()); // 1.1659045405098132\n}\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":594,"description":"

Rotate the vector by an angle (only 2D vectors), magnitude remains the\nsame

\n","itemtype":"method","name":"rotate","params":[{"name":"angle","description":"

the angle of rotation

\n","type":"Number"}],"return":{"description":"the modified p5.Vector","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(10.0, 20.0);\n// v has compnents [10.0, 20.0, 0.0]\nv.rotate(HALF_PI);\n// v's compnents are set to [-20.0, 9.999999, 0.0]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":624,"description":"

Linear interpolate the vector to another vector

\n","itemtype":"method","name":"lerp","params":[{"name":"x","description":"

the x component or the p5.Vector to lerp to

\n","type":"p5.Vector"},{"name":"y","description":"

y the y component

\n","type":"p5.Vector","optional":true},{"name":"z","description":"

z the z component

\n","type":"p5.Vector","optional":true},{"name":"amt","description":"

the amount of interpolation; some value between 0.0\n (old vector) and 1.0 (new vector). 0.1 is very near\n the new vector. 0.5 is halfway in between.

\n","type":"Number"}],"return":{"description":"the modified p5.Vector","type":"p5.Vector"},"example":["\n
\n\nvar v = createVector(1, 1, 0);\n\nv.lerp(3, 3, 0, 0.5); // v now has components [2,2,0]\n\n
\n\n
\n\nvar v1 = createVector(0, 0, 0);\nvar v2 = createVector(100, 100, 0);\n\nvar v3 = p5.Vector.lerp(v1, v2, 0.5);\n// v3 has components [50,50,0]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":664,"description":"

Return a representation of this vector as a float array. This is only\nfor temporary use. If used in any other fashion, the contents should be\ncopied by using the p5.Vector.copy() method to copy into your own\narray.

\n","itemtype":"method","name":"array","return":{"description":"an Array with the 3 values","type":"Array"},"example":["\n
\nfunction setup() {\n var v = createVector(20,30);\n println(v.array()); // Prints : Array [20, 30, 0]\n}\n
\n
\n\nvar v = createVector(10.0, 20.0, 30.0);\nvar f = v.array();\nprintln(f[0]); // Prints \"10.0\"\nprintln(f[1]); // Prints \"20.0\"\nprintln(f[2]); // Prints \"30.0\"\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":693,"description":"

Equality check against a p5.Vector

\n","itemtype":"method","name":"equals","params":[{"name":"x","description":"

the x component of the vector or a\n p5.Vector or an Array

\n","type":"Number|p5.Vector|Array","optional":true},{"name":"y","description":"

the y component of the vector

\n","type":"Number","optional":true},{"name":"z","description":"

the z component of the vector

\n","type":"Number","optional":true}],"return":{"description":"whether the vectors are equals","type":"Boolean"},"example":["\n
\nv1 = createVector(5,10,20);\nv2 = createVector(5,10,20);\nv3 = createVector(13,10,19);\n\nprintln(v1.equals(v2.x,v2.y,v2.z)); // true\nprintln(v1.equals(v3.x,v3.y,v3.z)); // false\n
\n
\n\nvar v1 = createVector(10.0, 20.0, 30.0);\nvar v2 = createVector(10.0, 20.0, 30.0);\nvar v3 = createVector(0.0, 0.0, 0.0);\nprint (v1.equals(v2)) // true\nprint (v1.equals(v3)) // false\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":743,"description":"

Make a new 2D unit vector from an angle

\n","itemtype":"method","name":"fromAngle","static":1,"params":[{"name":"angle","description":"

the desired angle

\n","type":"Number"}],"return":{"description":"the new p5.Vector object","type":"p5.Vector"},"example":["\n
\n\nfunction draw() {\n background (200);\n\n // Create a variable, proportional to the mouseX,\n // varying from 0-360, to represent an angle in degrees.\n angleMode(DEGREES);\n var myDegrees = map(mouseX, 0,width, 0,360);\n\n // Display that variable in an onscreen text.\n // (Note the nfc() function to truncate additional decimal places,\n // and the \"\\xB0\" character for the degree symbol.)\n var readout = \"angle = \" + nfc(myDegrees,1,1) + \"\\xB0\"\n noStroke();\n fill (0);\n text (readout, 5, 15);\n\n // Create a p5.Vector using the fromAngle function,\n // and extract its x and y components.\n var v = p5.Vector.fromAngle(radians(myDegrees));\n var vx = v.x;\n var vy = v.y;\n\n push();\n translate (width/2, height/2);\n noFill();\n stroke (150);\n line (0,0, 30,0);\n stroke (0);\n line (0,0, 30*vx, 30*vy);\n pop()\n}\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":800,"description":"

Make a new 2D unit vector from a random angle

\n","itemtype":"method","name":"random2D","static":1,"return":{"description":"the new p5.Vector object","type":"p5.Vector"},"example":["\n
\n\nvar v = p5.Vector.random2D();\n// May make v's attributes something like:\n// [0.61554617, -0.51195765, 0.0] or\n// [-0.4695841, -0.14366731, 0.0] or\n// [0.6091097, -0.22805278, 0.0]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":833,"description":"

Make a new random 3D unit vector.

\n","itemtype":"method","name":"random3D","static":1,"return":{"description":"the new p5.Vector object","type":"p5.Vector"},"example":["\n
\n\nvar v = p5.Vector.random3D();\n// May make v's attributes something like:\n// [0.61554617, -0.51195765, 0.599168] or\n// [-0.4695841, -0.14366731, -0.8711202] or\n// [0.6091097, -0.22805278, -0.7595902]\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":870,"description":"

Adds two vectors together and returns a new one.

\n","static":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":"

if undefined a new vector will be created

\n","type":"p5.Vector"}],"return":{"description":"the resulting p5.Vector","type":"p5.Vector"},"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":891,"description":"

Subtracts one p5.Vector from another and returns a new one. The second\nvector (v2) is subtracted from the first (v1), resulting in v1-v2.

\n","static":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":"

if undefined a new vector will be created

\n","type":"p5.Vector"}],"return":{"description":"the resulting p5.Vector","type":"p5.Vector"},"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":913,"description":"

Multiplies a vector by a scalar and returns a new vector.

\n","static":1,"params":[{"name":"v","description":"

the p5.Vector to multiply

\n","type":"p5.Vector"},{"name":"n","description":"

the scalar

\n","type":"Number"},{"name":"target","description":"

if undefined a new vector will be created

\n","type":"p5.Vector"}],"return":{"description":"the resulting new p5.Vector","type":"p5.Vector"},"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":932,"description":"

Divides a vector by a scalar and returns a new vector.

\n","static":1,"params":[{"name":"v","description":"

the p5.Vector to divide

\n","type":"p5.Vector"},{"name":"n","description":"

the scalar

\n","type":"Number"},{"name":"target","description":"

if undefined a new vector will be created

\n","type":"p5.Vector"}],"return":{"description":"the resulting new p5.Vector","type":"p5.Vector"},"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":952,"description":"

Calculates the dot product of two vectors.

\n","static":1,"params":[{"name":"v1","description":"

the first p5.Vector

\n","type":"p5.Vector"},{"name":"v2","description":"

the second p5.Vector

\n","type":"p5.Vector"}],"return":{"description":"the dot product","type":"Number"},"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":964,"description":"

Calculates the cross product of two vectors.

\n","static":1,"params":[{"name":"v1","description":"

the first p5.Vector

\n","type":"p5.Vector"},{"name":"v2","description":"

the second p5.Vector

\n","type":"p5.Vector"}],"return":{"description":"the cross product","type":"Number"},"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":976,"description":"

Calculates the Euclidean distance between two points (considering a\npoint as a vector object).

\n","static":1,"params":[{"name":"v1","description":"

the first p5.Vector

\n","type":"p5.Vector"},{"name":"v2","description":"

the second p5.Vector

\n","type":"p5.Vector"}],"return":{"description":"the distance","type":"Number"},"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":989,"description":"

Linear interpolate a vector to another vector and return the result as a\nnew vector.

\n","static":1,"params":[{"name":"v1","description":"

a starting p5.Vector

\n","type":"p5.Vector"},{"name":"v2","description":"

the p5.Vector to lerp to

\n","type":"p5.Vector"},{"name":"the","description":"

amount of interpolation; some value between 0.0\n (old vector) and 1.0 (new vector). 0.1 is very near\n the new vector. 0.5 is halfway in between.

\n","type":"Number"}],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":1010,"description":"

Calculates and returns the angle (in radians) between two vectors.

\n","itemtype":"method","name":"angleBetween","static":1,"params":[{"name":"v1","description":"

the x, y, and z components of a p5.Vector

\n","type":"p5.Vector"},{"name":"v2","description":"

the x, y, and z components of a p5.Vector

\n","type":"p5.Vector"}],"return":{"description":"the angle between (in radians)","type":"Number"},"example":["\n
\n\nvar v1 = createVector(1, 0, 0);\nvar v2 = createVector(0, 1, 0);\n\nvar angle = p5.Vector.angleBetween(v1, v2);\n// angle is PI/2\n\n
"],"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/p5.Vector.js","line":1038,"static":1,"class":"p5.Vector","module":"Math","submodule":"Math"},{"file":"src/math/random.js","line":45,"description":"

Sets the seed value for random().

\n

By default, random() produces different results each time the program\nis run. Set the seed parameter to a constant to return the same\npseudo-random numbers each time the software is run.

\n","itemtype":"method","name":"randomSeed","params":[{"name":"seed","description":"

the seed value

\n","type":"Number"}],"example":["\n
\n\nrandomSeed(99);\nfor (var i=0; i < 100; i++) {\n var r = random(0, 255);\n stroke(r);\n line(i, 0, i, 100);\n}\n\n
"],"class":"p5","module":"Math","submodule":"Random"},{"file":"src/math/random.js","line":71,"description":"

Return a random floating-point number.

\n

Takes either 0, 1 or 2 arguments.

\n

If no argument is given, returns a random number from 0\nup to (but not including) 1.

\n

If one argument is given and it is a number, returns a random number from 0\nup to (but not including) the number.

\n

If one argument is given and it is an array, returns a random element from\nthat array.

\n

If two arguments are given, returns a random number from the\nfirst argument up to (but not including) the second argument.

\n","itemtype":"method","name":"random","return":{"description":"the random number or a random element in choices","type":"Number|mixed"},"example":["\n
\n\nfor (var i = 0; i < 100; i++) {\n var r = random(50);\n stroke(r*5);\n line(50, i, 50+r, i);\n}\n\n
\n
\n\nfor (var i = 0; i < 100; i++) {\n var r = random(-50, 50);\n line(50,i,50+r,i);\n}\n\n
\n
\n\n// Get a random element from an array using the random(Array) syntax\nvar words = [ \"apple\", \"bear\", \"cat\", \"dog\" ];\nvar word = random(words); // select random word\ntext(word,10,50); // draw the word\n\n
"],"class":"p5","module":"Math","submodule":"Random","overloads":[{"line":71,"params":[{"name":"min","description":"

the lower bound (inclusive)

\n","type":"Number","optional":true},{"name":"max","description":"

the upper bound (exclusive)

\n","type":"Number","optional":true}]},{"line":119,"params":[{"name":"choices","description":"

the array to choose from

\n","type":"Array"}]}]},{"file":"src/math/random.js","line":155,"description":"

Returns a random number fitting a Gaussian, or\n normal, distribution. There is theoretically no minimum or maximum\n value that randomGaussian() might return. Rather, there is\n just a very low probability that values far from the mean will be\n returned; and a higher probability that numbers near the mean will\n be returned.\n

\n Takes either 0, 1 or 2 arguments.
\n If no args, returns a mean of 0 and standard deviation of 1.
\n If one arg, that arg is the mean (standard deviation is 1).
\n If two args, first is mean, second is standard deviation.

\n","itemtype":"method","name":"randomGaussian","params":[{"name":"mean","description":"

the mean

\n","type":"Number"},{"name":"sd","description":"

the standard deviation

\n","type":"Number"}],"return":{"description":"the random number","type":"Number"},"example":["\n
\n for (var y = 0; y < 100; y++) {\n var x = randomGaussian(50,15);\n line(50, y, x, y);\n}\n \n
\n
\n \nvar distribution = new Array(360);\n\nfunction setup() {\n createCanvas(100, 100);\n for (var i = 0; i < distribution.length; i++) {\n distribution[i] = floor(randomGaussian(0,15));\n }\n}\n\nfunction draw() {\n background(204);\n translate(width/2, width/2);\n for (var i = 0; i < distribution.length; i++) {\n rotate(TWO_PI/distribution.length);\n stroke(0);\n var dist = abs(distribution[i]);\n line(0, 0, dist, 0);\n }\n}\n \n
"],"class":"p5","module":"Math","submodule":"Random"},{"file":"src/math/trigonometry.js","line":18,"description":"

The inverse of cos(), returns the arc cosine of a value. This function\nexpects the values in the range of -1 to 1 and values are returned in\nthe range 0 to PI (3.1415927).

\n","itemtype":"method","name":"acos","params":[{"name":"value","description":"

the value whose arc cosine is to be returned

\n","type":"Number"}],"return":{"description":"the arc cosine of the given value","type":"Number"},"example":["\n
\n\nvar a = PI;\nvar c = cos(a);\nvar ac = acos(c);\n// Prints: \"3.1415927 : -1.0 : 3.1415927\"\nprintln(a + \" : \" + c + \" : \" + ac);\n\n
\n\n
\n\nvar a = PI + PI/4.0;\nvar c = cos(a);\nvar ac = acos(c);\n// Prints: \"3.926991 : -0.70710665 : 2.3561943\"\nprintln(a + \" : \" + c + \" : \" + ac);\n\n
"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":56,"description":"

The inverse of sin(), returns the arc sine of a value. This function\nexpects the values in the range of -1 to 1 and values are returned\nin the range -PI/2 to PI/2.

\n","itemtype":"method","name":"asin","params":[{"name":"value","description":"

the value whose arc sine is to be returned

\n","type":"Number"}],"return":{"description":"the arc sine of the given value","type":"Number"},"example":["\n
\n\nvar a = PI + PI/3;\nvar s = sin(a);\nvar as = asin(s);\n// Prints: \"1.0471976 : 0.86602545 : 1.0471976\"\nprintln(a + \" : \" + s + \" : \" + as);\n\n
\n\n
\n\nvar a = PI + PI/3.0;\nvar s = sin(a);\nvar as = asin(s);\n// Prints: \"4.1887903 : -0.86602545 : -1.0471976\"\nprintln(a + \" : \" + s + \" : \" + as);\n\n
\n"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":95,"description":"

The inverse of tan(), returns the arc tangent of a value. This function\nexpects the values in the range of -Infinity to Infinity (exclusive) and\nvalues are returned in the range -PI/2 to PI/2.

\n","itemtype":"method","name":"atan","params":[{"name":"value","description":"

the value whose arc tangent is to be returned

\n","type":"Number"}],"return":{"description":"the arc tangent of the given value","type":"Number"},"example":["\n
\n\nvar a = PI + PI/3;\nvar t = tan(a);\nvar at = atan(t);\n// Prints: \"1.0471976 : 1.7320509 : 1.0471976\"\nprintln(a + \" : \" + t + \" : \" + at);\n\n
\n\n
\n\nvar a = PI + PI/3.0;\nvar t = tan(a);\nvar at = atan(t);\n// Prints: \"4.1887903 : 1.7320513 : 1.0471977\"\nprintln(a + \" : \" + t + \" : \" + at);\n\n
\n"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":134,"description":"

Calculates the angle (in radians) from a specified point to the coordinate\norigin as measured from the positive x-axis. Values are returned as a\nfloat in the range from PI to -PI. The atan2() function is most often used\nfor orienting geometry to the position of the cursor.\n

\nNote: The y-coordinate of the point is the first parameter, and the\nx-coordinate is the second parameter, due the the structure of calculating\nthe tangent.

\n","itemtype":"method","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"}],"return":{"description":"the arc tangent of the given point","type":"Number"},"example":["\n
\n\nfunction draw() {\n background(204);\n translate(width/2, height/2);\n var a = atan2(mouseY-height/2, mouseX-width/2);\n rotate(a);\n rect(-30, -5, 60, 10);\n}\n\n
"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":170,"description":"

Calculates the cosine of an angle. This function takes into account the\ncurrent angleMode. Values are returned in the range -1 to 1.

\n","itemtype":"method","name":"cos","params":[{"name":"angle","description":"

the angle

\n","type":"Number"}],"return":{"description":"the cosine of the angle","type":"Number"},"example":["\n
\n\nvar a = 0.0;\nvar inc = TWO_PI/25.0;\nfor (var i = 0; i < 25; i++) {\n line(i*4, 50, i*4, 50+cos(a)*40.0);\n a = a + inc;\n}\n\n
\n"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":199,"description":"

Calculates the sine of an angle. This function takes into account the\ncurrent angleMode. Values are returned in the range -1 to 1.

\n","itemtype":"method","name":"sin","params":[{"name":"angle","description":"

the angle

\n","type":"Number"}],"return":{"description":"the sine of the angle","type":"Number"},"example":["\n
\n\nvar a = 0.0;\nvar inc = TWO_PI/25.0;\nfor (var i = 0; i < 25; i++) {\n line(i*4, 50, i*4, 50+sin(a)*40.0);\n a = a + inc;\n}\n\n
"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":227,"description":"

Calculates the tangent of an angle. This function takes into account\nthe current angleMode. Values are returned in the range -1 to 1.

\n","itemtype":"method","name":"tan","params":[{"name":"angle","description":"

the angle

\n","type":"Number"}],"return":{"description":"the tangent of the angle","type":"Number"},"example":["\n
\n\n var a = 0.0;\n var inc = TWO_PI/50.0;\n for (var i = 0; i < 100; i = i+2) {\n line(i, 50, i, 50+tan(a)*2.0);\n a = a + inc;\n }\n\n
\n"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":256,"description":"

Converts a radian measurement to its corresponding value in degrees.\nRadians and degrees are two ways of measuring the same thing. There are\n360 degrees in a circle and 2*PI radians in a circle. For example,\n90° = PI/2 = 1.5707964.

\n","itemtype":"method","name":"degrees","params":[{"name":"radians","description":"

the radians value to convert to degrees

\n","type":"Number"}],"return":{"description":"the converted angle","type":"Number"},"example":["\n
\n\nvar rad = PI/4;\nvar deg = degrees(rad);\nprintln(rad + \" radians is \" + deg + \" degrees\");\n// Prints: 0.7853981633974483 radians is 45 degrees\n\n
\n"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":282,"description":"

Converts a degree measurement to its corresponding value in radians.\nRadians and degrees are two ways of measuring the same thing. There are\n360 degrees in a circle and 2*PI radians in a circle. For example,\n90° = PI/2 = 1.5707964.

\n","itemtype":"method","name":"radians","params":[{"name":"degrees","description":"

the degree value to convert to radians

\n","type":"Number"}],"return":{"description":"the converted angle","type":"Number"},"example":["\n
\n\nvar deg = 45.0;\nvar rad = radians(deg);\nprintln(deg + \" degrees is \" + rad + \" radians\");\n// Prints: 45 degrees is 0.7853981633974483 radians\n\n
"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/math/trigonometry.js","line":306,"description":"

Sets the current mode of p5 to given mode. Default mode is RADIANS.

\n","itemtype":"method","name":"angleMode","params":[{"name":"mode","description":"

either RADIANS or DEGREES

\n","type":"Constant"}],"example":["\n
\n\nfunction draw(){\n background(204);\n angleMode(DEGREES); // Change the mode to DEGREES\n var a = atan2(mouseY-height/2, mouseX-width/2);\n translate(width/2, height/2);\n push();\n rotate(a);\n rect(-20, -5, 40, 10); // Larger rectangle is rotating in degrees\n pop();\n angleMode(RADIANS); // Change the mode to RADIANS\n rotate(a); // var a stays the same\n rect(-40, -5, 20, 10); // Smaller rectangle is rotating in radians\n}\n\n
\n"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src/typography/attributes.js","line":13,"description":"

Sets the current alignment for drawing text. Accepts two\narguments: horizAlign (LEFT, CENTER, or RIGHT) and\nvertAlign (TOP, BOTTOM, CENTER, or BASELINE).

\n

The horizAlign parameter is in reference to the x value\nof the text() function, while the vertAlign parameter is\nin reference to the y value.

\n

So if you write textAlign(LEFT), you are aligning the left\nedge of your text to the x value you give in text(). If you\nwrite textAlign(RIGHT, TOP), you are aligning the right edge\nof your text to the x value and the top of edge of the text\nto the y value.

\n","itemtype":"method","name":"textAlign","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"}],"return":{"description":"","type":"Number"},"example":["\n
\n\ntextSize(16);\ntextAlign(RIGHT);\ntext(\"ABCD\", 50, 30);\ntextAlign(CENTER);\ntext(\"EFGH\", 50, 50);\ntextAlign(LEFT);\ntext(\"IJKL\", 50, 70);\n\n
"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/attributes.js","line":51,"description":"

Sets/gets the spacing, in pixels, between lines of text. This\nsetting will be used in all subsequent calls to the text() function.

\n","itemtype":"method","name":"textLeading","params":[{"name":"leading","description":"

the size in pixels for spacing between lines

\n","type":"Number"}],"return":{"description":"","type":"Object|Number"},"example":["\n
\n\n// Text to display. The \"\\n\" is a \"new line\" character\nlines = \"L1\\nL2\\nL3\";\ntextSize(12);\n\ntextLeading(10); // Set leading to 10\ntext(lines, 10, 25);\n\ntextLeading(20); // Set leading to 20\ntext(lines, 40, 25);\n\ntextLeading(30); // Set leading to 30\ntext(lines, 70, 25);\n\n
"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/attributes.js","line":80,"description":"

Sets/gets the current font size. This size will be used in all subsequent\ncalls to the text() function. Font size is measured in pixels.

\n","itemtype":"method","name":"textSize","params":[{"name":"theSize","description":"

the size of the letters in units of pixels

\n","type":"Number"}],"return":{"description":"","type":"Object|Number"},"example":["\n
\n\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\n
"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/attributes.js","line":103,"description":"

Sets/gets the style of the text for system fonts to NORMAL, ITALIC, or BOLD.\nNote: this may be is overridden by CSS styling. For non-system fonts\n(opentype, truetype, etc.) please load styled fonts instead.

\n","itemtype":"method","name":"textStyle","params":[{"name":"theStyle","description":"

styling for text, either NORMAL,\n ITALIC, or BOLD

\n","type":"Number/Constant"}],"return":{"description":"","type":"Object|String"},"example":["\n
\n\nstrokeWeight(0);\ntextSize(12);\ntextStyle(NORMAL);\ntext(\"Font Style Normal\", 10, 30);\ntextStyle(ITALIC);\ntext(\"Font Style Italic\", 10, 60);\ntextStyle(BOLD);\ntext(\"Font Style Bold\", 10, 90);\n\n
"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/attributes.js","line":130,"description":"

Calculates and returns the width of any character or text string.

\n","itemtype":"method","name":"textWidth","params":[{"name":"theText","description":"

the String of characters to measure

\n","type":"String"}],"return":{"description":"","type":"Number"},"example":["\n
\n\ntextSize(28);\n\nvar aChar = 'P';\nvar cWidth = textWidth(aChar);\ntext(aChar, 0, 40);\nline(cWidth, 0, cWidth, 50);\n\nvar aString = \"p5.js\";\nvar sWidth = textWidth(aString);\ntext(aString, 0, 85);\nline(sWidth, 50, sWidth, 100);\n\n
"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/attributes.js","line":157,"description":"

Returns the ascent of the current font at its current size. The ascent\nrepresents the distance, in pixels, of the tallest character above\nthe baseline.

\n","return":{"description":"","type":"Number"},"example":["\n
\n\nvar base = height * 0.75;\nvar scalar = 0.8; // Different for each font\n\ntextSize(32); // Set initial text size\nvar asc = textAscent() * scalar; // Calc ascent\nline(0, base - asc, width, base - asc);\ntext(\"dp\", 0, base); // Draw text on baseline\n\ntextSize(64); // Increase text size\nasc = textAscent() * scalar; // Recalc ascent\nline(40, base - asc, width, base - asc);\ntext(\"dp\", 40, base); // Draw text on baseline\n\n
"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/attributes.js","line":185,"description":"

Returns the descent of the current font at its current size. The descent\nrepresents the distance, in pixels, of the character with the longest\ndescender below the baseline.

\n","return":{"description":"","type":"Number"},"example":["\n
\n\nvar base = height * 0.75;\nvar scalar = 0.8; // Different for each font\n\ntextSize(32); // Set initial text size\nvar desc = textDescent() * scalar; // Calc ascent\nline(0, base+desc, width, base+desc);\ntext(\"dp\", 0, base); // Draw text on baseline\n\ntextSize(64); // Increase text size\ndesc = textDescent() * scalar; // Recalc ascent\nline(40, base + desc, width, base + desc);\ntext(\"dp\", 40, base); // Draw text on baseline\n\n
"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/attributes.js","line":213,"description":"

Helper function to measure ascent and descent.

\n","class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src/typography/loading_displaying.js","line":16,"description":"

Draws text to the screen. Displays the information specified in the first\nparameter on the screen in the position specified by the additional\nparameters. A default font will be used unless a font is set with the\ntextFont() function and a default size will be used unless a font is set\nwith textSize(). Change the color of the text with the fill() function.\nChange the outline of the text with the stroke() and strokeWeight()\nfunctions.\n

\nThe text displays in relation to the textAlign() function, which gives the\noption to draw to the left, right, and center of the coordinates.\n

\nThe x2 and y2 parameters define a rectangular area to display within and\nmay only be used with string data. When these parameters are specified,\nthey are interpreted based on the current rectMode() setting. Text that\ndoes not fit completely within the rectangle specified will not be drawn\nto the screen.

\n","itemtype":"method","name":"text","params":[{"name":"str","description":"

the alphanumeric symbols to be displayed

\n","type":"String"},{"name":"x","description":"

x-coordinate of text

\n","type":"Number"},{"name":"y","description":"

y-coordinate of text

\n","type":"Number"},{"name":"x2","description":"

by default, the width of the text box,\n see rectMode() for more info

\n","type":"Number"},{"name":"y2","description":"

by default, the height of the text box,\n see rectMode() for more info

\n","type":"Number"}],"return":{"description":"this","type":"Object"},"example":["\n
\n\ntextSize(32);\ntext(\"word\", 10, 30);\nfill(0, 102, 153);\ntext(\"word\", 10, 60);\nfill(0, 102, 153, 51);\ntext(\"word\", 10, 90);\n\n
\n
\n\ns = \"The quick brown fox jumped over the lazy dog.\";\nfill(50);\ntext(s, 10, 10, 70, 80); // Text wraps within text box\n\n
"],"class":"p5","module":"Typography","submodule":"Loading & Displaying"},{"file":"src/typography/loading_displaying.js","line":80,"description":"

Sets the current font that will be drawn with the text() function.

\n","itemtype":"method","name":"textFont","params":[{"name":"f","description":"

a font loaded via loadFont(), or a String\n representing a browser-based default font.

\n","type":"Object|String"}],"return":{"description":"this","type":"Object"},"example":["\n
\n\nfill(0);\ntextSize(12);\ntextFont(\"Georgia\");\ntext(\"Georgia\", 12, 30);\ntextFont(\"Helvetica\");\ntext(\"Helvetica\", 12, 60);\n\n
\n
\n\nvar fontRegular, fontItalic, fontBold;\nfunction preload() {\n fontRegular = loadFont(\"assets/Regular.otf\");\n fontItalic = loadFont(\"assets/Italic.ttf\");\n fontBold = loadFont(\"assets/Bold.ttf\");\n}\nfunction setup() {\n background(210);\n fill(0).strokeWeight(0).textSize(10);\n textFont(fontRegular);\n text(\"Font Style Normal\", 10, 30);\n textFont(fontItalic);\n text(\"Font Style Italic\", 10, 50);\n textFont(fontBold);\n text(\"Font Style Bold\", 10, 70);\n}\n\n
"],"class":"p5","module":"Typography","submodule":"Loading & Displaying"},{"file":"src/typography/p5.Font.js","line":44,"description":"

Underlying opentype font implementation

\n","itemtype":"property","name":"font","class":"p5.Font","module":"Typography","submodule":"Font"},{"file":"src/typography/p5.Font.js","line":57,"description":"

Returns a tight bounding box for the given text string using this\nfont (currently only supports single lines)

\n","itemtype":"method","name":"textBounds","params":[{"name":"line","description":"

a line of text

\n","type":"String"},{"name":"x","description":"

x-position

\n","type":"Number"},{"name":"y","description":"

y-position

\n","type":"Number"},{"name":"fontSize","description":"

font size to use (optional)

\n","type":"Number"},{"name":"options","description":"

opentype options (optional)

\n","type":"Object"}],"return":{"description":"a rectangle object with properties: x, y, w, h","type":"Object"},"example":["\n
\n\nvar font;\nvar textString = 'Lorem ipsum dolor sit amet.';\nfunction preload() {\n font = loadFont('./assets/Regular.otf');\n};\nfunction setup() {\n background(210);\n\n var bbox = font.textBounds(textString, 10, 30, 12);\n fill(255);\n stroke(0);\n rect(bbox.x, bbox.y, bbox.w, bbox.h);\n fill(0);\n noStroke();\n\n textFont(font);\n textSize(12);\n text(textString, 10, 30);\n};\n\n
"],"class":"p5.Font","module":"Typography","submodule":"Font"},{"file":"src/typography/p5.Font.js","line":171,"description":"

Computes an array of points following the path for specified text

\n","params":[{"name":"txt","description":"

a line of text

\n","type":"String"},{"name":"x","description":"

x-position

\n","type":"Number"},{"name":"y","description":"

y-position

\n","type":"Number"},{"name":"fontSize","description":"

font size to use (optional)

\n","type":"Number"},{"name":"options","description":"

an (optional) object that can contain:

\n


sampleFactor - the ratio of path-length to number of samples\n(default=.25); higher values yield more points and are therefore\nmore precise

\n


simplifyThreshold - if set to a non-zero value, collinear points will be\nbe removed from the polygon; the value represents the threshold angle to use\nwhen determining whether two edges are collinear

\n","type":"Object"}],"return":{"description":"an array of points, each with x, y, alpha (the path angle)","type":"Array"},"class":"p5.Font","module":"Typography","submodule":"Font"},{"file":"src/typography/p5.Font.js","line":219,"description":"

Returns the set of opentype glyphs for the supplied string.

\n

Note that there is not a strict one-to-one mapping between characters\nand glyphs, so the list of returned glyphs can be larger or smaller\n than the length of the given string.

\n","params":[{"name":"str","description":"

the string to be converted

\n","type":"String"}],"return":{"description":"the opentype glyphs","type":"Array"},"class":"p5.Font","module":"Typography","submodule":"Font"},{"file":"src/typography/p5.Font.js","line":234,"description":"

Returns an opentype path for the supplied string and position.

\n","params":[{"name":"line","description":"

a line of text

\n","type":"String"},{"name":"x","description":"

x-position

\n","type":"Number"},{"name":"y","description":"

y-position

\n","type":"Number"},{"name":"options","description":"

opentype options (optional)

\n","type":"Object"}],"return":{"description":"the opentype path","type":"Object"},"class":"p5.Font","module":"Typography","submodule":"Font"},{"file":"src/utilities/array_functions.js","line":12,"description":"

Adds a value to the end of an array. Extends the length of\nthe array by one. Maps to Array.push().

\n","itemtype":"method","name":"append","params":[{"name":"array","description":"

Array to append

\n","type":"Array"},{"name":"value","description":"

to be added to the Array

\n","type":"Any"}],"example":["\n
\nfunction setup() {\n\nvar myArray = new Array(\"Mango\", \"Apple\", \"Papaya\")\nprintln(myArray) // [\"Mango\", \"Apple\", \"Papaya\"]\n\nappend(myArray, \"Peach\")\nprintln(myArray) // [\"Mango\", \"Apple\", \"Papaya\", \"Peach\"]\n\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":37,"description":"

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().\n

\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).\n

\nUsing this function is far more efficient for copying array data than\niterating through a for() loop and copying each element individually.

\n","itemtype":"method","name":"arrayCopy","params":[{"name":"src","description":"

the source Array

\n","type":"Array"},{"name":"srcPosition","description":"

starting position in the source Array

\n","type":"Number","optional":true},{"name":"dst","description":"

the destination Array

\n","type":"Array"},{"name":"dstPosition","description":"

starting position in the destination Array

\n","type":"Number","optional":true},{"name":"length","description":"

number of Array elements to be copied

\n","type":"Number","optional":true}],"example":["\n
\n function setup() {\n\n var src = new Array(\"A\", \"B\", \"C\");\n var dst = new Array( 1 , 2 , 3 );\n var srcPosition = 1;\n var dstPosition = 0;\n var length = 2;\n\n println(src); // [\"A\", \"B\", \"C\"]\n println(dst); // [ 1 , 2 , 3 ]\n\n arrayCopy(src, srcPosition, dst, dstPosition, length);\n println(dst); // [\"B\", \"C\", 3]\n\n }\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":118,"description":"

Concatenates two arrays, maps to Array.concat(). Does not modify the\ninput arrays.

\n","itemtype":"method","name":"concat","params":[{"name":"a","description":"

first Array to concatenate

\n","type":"Array"},{"name":"b","description":"

second Array to concatenate

\n","type":"Array"}],"return":{"description":"concatenated array","type":"Array"},"example":["\n
\nfunction setup() {\n var arr1 = new Array(\"A\", \"B\", \"C\");\n var arr2 = new Array( 1 , 2 , 3 );\n\n println(arr1); // [\"A\",\"B\",\"C\"]\n println(arr2); // [1,2,3]\n\n var arr3 = concat(arr1, arr2);\n\n println(arr1); // [\"A\",\"B\",\"C\"]\n println(arr2); // [1,2,3]\n println(arr3); // [\"A\",\"B\",\"C\",1,2,3]\n\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":149,"description":"

Reverses the order of an array, maps to Array.reverse()

\n","itemtype":"method","name":"reverse","params":[{"name":"list","description":"

Array to reverse

\n","type":"Array"}],"example":["\n
\nfunction setup() {\n var myArray = new Array(\"A\", \"B\", \"C\");\n println(myArray); // [\"A\",\"B\",\"C\"]\n\n reverse(myArray);\n println(myArray); // [\"C\",\"B\",\"A\"]\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":169,"description":"

Decreases an array by one element and returns the shortened array,\nmaps to Array.pop().

\n","itemtype":"method","name":"shorten","params":[{"name":"list","description":"

Array to shorten

\n","type":"Array"}],"return":{"description":"shortened Array","type":"Array"},"example":["\n
\nfunction setup() {\n var myArray = new Array(\"A\", \"B\", \"C\");\n println(myArray); // [\"A\",\"B\",\"C\"]\n\n var newArray = shorten(myArray);\n println(myArray); // [\"A\",\"B\",\"C\"]\n println(newArray); // [\"A\",\"B\"]\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":193,"description":"

Randomizes the order of the elements of an array. Implements\n\nFisher-Yates Shuffle Algorithm.

\n","itemtype":"method","name":"shuffle","params":[{"name":"array","description":"

Array to shuffle

\n","type":"Array"},{"name":"bool","description":"

modify passed array

\n","type":"Boolean","optional":true}],"return":{"description":"shuffled Array","type":"Array"},"example":["\n
\nfunction setup() {\n var regularArr = ['ABC', 'def', createVector(), TAU, Math.E];\n println(regularArr);\n shuffle(regularArr, true); // force modifications to passed array\n println(regularArr);\n\n // By default shuffle() returns a shuffled cloned array:\n var newArr = shuffle(regularArr);\n println(regularArr);\n println(newArr);\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":233,"description":"

Sorts an array of numbers from smallest to largest, or puts an array of\nwords in alphabetical order. The original array is not modified; a\nre-ordered array is returned. The count parameter states the number of\nelements to sort. For example, if there are 12 elements in an array and\ncount is set to 5, only the first 5 elements in the array will be sorted.

\n","itemtype":"method","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":"Number","optional":true}],"example":["\n
\nfunction setup() {\n var words = new Array(\"banana\", \"apple\", \"pear\",\"lime\");\n println(words); // [\"banana\", \"apple\", \"pear\", \"lime\"]\n var count = 4; // length of array\n\n words = sort(words, count);\n println(words); // [\"apple\", \"banana\", \"lime\", \"pear\"]\n}\n
\n
\nfunction setup() {\n var numbers = new Array(2,6,1,5,14,9,8,12);\n println(numbers); // [2,6,1,5,14,9,8,12]\n var count = 5; // Less than the length of the array\n\n numbers = sort(numbers, count);\n println(numbers); // [1,2,5,6,14,9,8,12]\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":277,"description":"

Inserts a value or an array of values into an existing array. The first\nparameter specifies the initial array to be modified, and the second\nparameter defines the data to be inserted. The third parameter is an index\nvalue which specifies the array position from which to insert data.\n(Remember that array index numbering starts at zero, so the first position\nis 0, the second position is 1, and so on.)

\n","itemtype":"method","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":"Number"}],"example":["\n
\nfunction setup() {\n var myArray = new Array(0,1,2,3,4);\n var insArray = new Array(\"A\",\"B\",\"C\");\n println(myArray); // [0,1,2,3,4]\n println(insArray); // [\"A\",\"B\",\"C\"]\n\n splice(myArray, insArray, 3);\n println(myArray); // [0,1,2,\"A\",\"B\",\"C\",3,4]\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/array_functions.js","line":311,"description":"

Extracts an array of elements from an existing array. The list parameter\ndefines the array from which the elements will be copied, and the start\nand count parameters specify which elements to extract. If no count is\ngiven, elements will be extracted from the start to the end of the array.\nWhen specifying the start, remember that the first array element is 0.\nThis function does not change the source array.

\n","itemtype":"method","name":"subset","params":[{"name":"list","description":"

Array to extract from

\n","type":"Array"},{"name":"start","description":"

position to begin

\n","type":"Number"},{"name":"count","description":"

number of values to extract

\n","type":"Number","optional":true}],"return":{"description":"Array of extracted elements","type":"Array"},"example":["\n
\nfunction setup() {\n var myArray = new Array(1,2,3,4,5);\n println(myArray); // [1,2,3,4,5]\n\n var sub1 = subset(myArray, 0, 3);\n var sub2 = subset(myArray, 2, 2);\n println(sub1); // [1,2,3]\n println(sub2); // [3,4]\n}\n
"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src/utilities/conversion.js","line":12,"description":"

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.

\n","itemtype":"method","name":"float","params":[{"name":"str","description":"

float string to parse

\n","type":"String"}],"return":{"description":"floating point representation of string","type":"Number"},"example":["\n
\nvar str = '20';\nvar diameter = float(str);\nellipse(width/2, height/2, diameter, diameter);\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":32,"description":"

Converts a boolean, string, or float to its integer representation.\nWhen an array of values is passed in, then an int array of the same length\nis returned.

\n","itemtype":"method","name":"int","params":[{"name":"n","description":"

value to parse

\n","type":"String|Boolean|Number|Array"}],"return":{"description":"integer representation of value","type":"Number"},"example":["\n
\nprintln(int(\"10\")); // 10\nprintln(int(10.31)); // 10\nprintln(int(-10)); // -10\nprintln(int(true)); // 1\nprintln(int(false)); // 0\nprintln(int([false, true, \"10.3\", 9.8])); // [0, 1, 10, 9]\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":63,"description":"

Converts a boolean, string or number to its string representation.\nWhen an array of values is passed in, then an array of strings of the same\nlength is returned.

\n","itemtype":"method","name":"str","params":[{"name":"n","description":"

value to parse

\n","type":"String|Boolean|Number|Array"}],"return":{"description":"string representation of value","type":"String"},"example":["\n
\nprintln(str(\"10\")); // \"10\"\nprintln(str(10.31)); // \"10.31\"\nprintln(str(-10)); // \"-10\"\nprintln(str(true)); // \"true\"\nprintln(str(false)); // \"false\"\nprintln(str([true, \"10.3\", 9.8])); // [ \"true\", \"10.3\", \"9.8\" ]\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":89,"description":"

Converts a number or string to its boolean representation.\nFor a number, any non-zero value (positive or negative) evaluates to true,\nwhile zero evaluates to false. For a string, the value "true" evaluates to\ntrue, while any other value evaluates to false. When an array of number or\nstring values is passed in, then a array of booleans of the same length is\nreturned.

\n","itemtype":"method","name":"boolean","params":[{"name":"n","description":"

value to parse

\n","type":"String|Boolean|Number|Array"}],"return":{"description":"boolean representation of value","type":"Boolean"},"example":["\n
\nprintln(boolean(0)); // false\nprintln(boolean(1)); // true\nprintln(boolean(\"true\")); // true\nprintln(boolean(\"abcd\")); // false\nprintln(boolean([0, 12, \"true\"])); // [false, true, false]\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":121,"description":"

Converts a number, string or boolean to its byte representation.\nA byte can be only a whole number between -128 and 127, so when a value\noutside of this range is converted, it wraps around to the corresponding\nbyte representation. When an array of number, string or boolean values is\npassed in, then an array of bytes the same length is returned.

\n","itemtype":"method","name":"byte","params":[{"name":"n","description":"

value to parse

\n","type":"String|Boolean|Number|Array"}],"return":{"description":"byte representation of value","type":"Number"},"example":["\n
\nprintln(byte(127)); // 127\nprintln(byte(128)); // -128\nprintln(byte(23.4)); // 23\nprintln(byte(\"23.4\")); // 23\nprintln(byte(true)); // 1\nprintln(byte([0, 255, \"100\"])); // [0, -1, 100]\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":150,"description":"

Converts a number or string to its corresponding single-character\nstring representation. If a string parameter is provided, it is first\nparsed as an integer and then translated into a single-character string.\nWhen an array of number or string values is passed in, then an array of\nsingle-character strings of the same length is returned.

\n","itemtype":"method","name":"char","params":[{"name":"n","description":"

value to parse

\n","type":"String|Number|Array"}],"return":{"description":"string representation of value","type":"String"},"example":["\n
\nprintln(char(65)); // \"A\"\nprintln(char(\"65\")); // \"A\"\nprintln(char([65, 66, 67])); // [ \"A\", \"B\", \"C\" ]\nprintln(join(char([65, 66, 67]), '')); // \"ABC\"\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":178,"description":"

Converts a single-character string to its corresponding integer\nrepresentation. When an array of single-character string values is passed\nin, then an array of integers of the same length is returned.

\n","itemtype":"method","name":"unchar","params":[{"name":"n","description":"

value to parse

\n","type":"String|Array"}],"return":{"description":"integer representation of value","type":"Number"},"example":["\n
\nprintln(unchar(\"A\")); // 65\nprintln(unchar([\"A\", \"B\", \"C\"])); // [ 65, 66, 67 ]\nprintln(unchar(split(\"ABC\", \"\"))); // [ 65, 66, 67 ]\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":201,"description":"

Converts a number to a string in its equivalent hexadecimal notation. If a\nsecond parameter is passed, it is used to set the number of characters to\ngenerate in the hexadecimal notation. When an array is passed in, an\narray of strings in hexadecimal notation of the same length is returned.

\n","itemtype":"method","name":"hex","params":[{"name":"n","description":"

value to parse

\n","type":"Number|Array"}],"return":{"description":"hexadecimal string representation of value","type":"String"},"example":["\n
\nprintln(hex(255)); // \"000000FF\"\nprintln(hex(255, 6)); // \"0000FF\"\nprintln(hex([0, 127, 255], 6)); // [ \"000000\", \"00007F\", \"0000FF\" ]\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/conversion.js","line":236,"description":"

Converts a string representation of a hexadecimal number to its equivalent\ninteger value. When an array of strings in hexadecimal notation is passed\nin, an array of integers of the same length is returned.

\n","itemtype":"method","name":"unhex","params":[{"name":"n","description":"

value to parse

\n","type":"String|Array"}],"return":{"description":"integer representation of hexadecimal value","type":"Number"},"example":["\n
\nprintln(unhex(\"A\")); // 10\nprintln(unhex(\"FF\")); // 255\nprintln(unhex([\"FF\", \"AA\", \"00\"])); // [ 255, 170, 0 ]\n
"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src/utilities/string_functions.js","line":14,"description":"

Combines an array of Strings into one String, each separated by the\ncharacter(s) used for the separator parameter. To join arrays of ints or\nfloats, it's necessary to first convert them to Strings using nf() or\nnfs().

\n","itemtype":"method","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"}],"return":{"description":"joined String","type":"String"},"example":["\n
\n\nvar array = [\"Hello\", \"world!\"]\nvar separator = \" \"\nvar message = join(array, separator);\ntext(message, 5, 50);\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":38,"description":"

This 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.\n

\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.\n

\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","itemtype":"method","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"}],"return":{"description":"Array of Strings found","type":"Array"},"example":["\n
\n\nvar string = \"Hello p5js*!\"\nvar regexp = \"p5js\\\\*\"\nvar match = match(string, regexp);\ntext(match, 5, 50);\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":74,"description":"

This 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.\n

\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.\n

\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","itemtype":"method","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"}],"return":{"description":"2d Array of Strings found","type":"Array"},"example":["\n
\n\nvar string = \"Hello p5js*! Hello world!\"\nvar regexp = \"Hello\"\nmatchAll(string, regexp);\n\n
\n"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":121,"description":"

Utility 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","itemtype":"method","name":"nf","params":[{"name":"num","description":"

the Number to format

\n","type":"Number|Array"},{"name":"left","description":"

number of digits to the left of the\n decimal point

\n","type":"Number","optional":true},{"name":"right","description":"

number of digits to the right of the\n decimal point

\n","type":"Number","optional":true}],"return":{"description":"formatted String","type":"String|Array"},"example":["\n
\n\nfunction setup() {\n background(200);\n var num = 112.53106115;\n\n noStroke();\n fill(0);\n textSize(14);\n // Draw formatted numbers\n text(nf(num, 5, 2), 10, 20);\n\n text(nf(num, 4, 3), 10, 55);\n\n text(nf(num, 3, 6), 10, 85);\n\n // Draw dividing lines\n stroke(120);\n line(0, 30, width, 30);\n line(0, 65, width, 65);\n}\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":222,"description":"

Utility function for formatting numbers into strings and placing\nappropriate commas to mark units of 1000. There are two versions: one\nfor formatting ints, and one for formatting an array of ints. The value\nfor the right parameter should always be a positive integer.

\n","itemtype":"method","name":"nfc","params":[{"name":"num","description":"

the Number to format

\n","type":"Number|Array"},{"name":"right","description":"

number of digits to the right of the\n decimal point

\n","type":"Number","optional":true}],"return":{"description":"formatted String","type":"String|Array"},"example":["\n
\n\nfunction setup() {\n background(200);\n var num = 11253106.115;\n var numArr = new Array(1,1,2);\n\n noStroke();\n fill(0);\n textSize(12);\n\n // Draw formatted numbers\n text(nfc(num, 4, 2), 10, 30);\n text(nfc(numArr, 2, 1), 10, 80);\n\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n}\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":290,"description":"

Utility function for formatting numbers into strings. Similar to nf() but\nputs a "+" in front of positive numbers and a "-" in front of negative\nnumbers. There are two versions: one for formatting floats, and one for\nformatting ints. The values for left, and right parameters\nshould always be positive integers.

\n","itemtype":"method","name":"nfp","params":[{"name":"num","description":"

the Number to format

\n","type":"Number|Array"},{"name":"left","description":"

number of digits to the left of the decimal\n point

\n","type":"Number","optional":true},{"name":"right","description":"

number of digits to the right of the\n decimal point

\n","type":"Number","optional":true}],"return":{"description":"formatted String","type":"String|Array"},"example":["\n
\n\nfunction setup() {\n background(200);\n var num1 = 11253106.115;\n var 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\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":343,"description":"

Utility function for formatting numbers into strings. Similar to nf() but\nputs a " " (space) in front of positive numbers and a "-" in front of\nnegative numbers. There are two versions: one for formatting floats, and\none for formatting ints. The values for the digits, left, and right\nparameters should always be positive integers.

\n","itemtype":"method","name":"nfs","params":[{"name":"num","description":"

the Number to format

\n","type":"Number|Array"},{"name":"left","description":"

number of digits to the left of the decimal\n point

\n","type":"Number","optional":true},{"name":"right","description":"

number of digits to the right of the\n decimal point

\n","type":"Number","optional":true}],"return":{"description":"formatted String","type":"String|Array"},"example":["\n
\n\nfunction setup() {\n background(200);\n var num1 = 11253106.115;\n var num2 = -11253106.115;\n\n noStroke();\n fill(0);\n textSize(12);\n // Draw formatted numbers\n text(nfs(num1, 4, 2), 10, 30);\n\n text(nfs(num2, 4, 2), 10, 80);\n\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n}\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":396,"description":"

The 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.

\n

The splitTokens() function works in a similar fashion, except that it\nsplits using a range of characters instead of a specific character or\nsequence.

\n","itemtype":"method","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"}],"return":{"description":"Array of Strings","type":"Array"},"example":["\n
\n\nvar names = \"Pat,Xio,Alex\"\nvar splitString = split(names, \",\");\ntext(splitString[0], 5, 30);\ntext(splitString[1], 5, 50);\ntext(splitString[2], 5, 70);\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":425,"description":"

The 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.\n

\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","itemtype":"method","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}],"return":{"description":"Array of Strings","type":"Array"},"example":["\n
\n\nfunction setup() {\n var myStr = \"Mango, Banana, Lime\";\n var myStrArr = splitTokens(myStr, \",\");\n\n println(myStrArr); // prints : [\"Mango\",\" Banana\",\" Lime\"]\n}\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/string_functions.js","line":477,"description":"

Removes whitespace characters from the beginning and end of a String. In\naddition to standard whitespace characters such as space, carriage return,\nand tab, this function also removes the Unicode "nbsp" character.

\n","itemtype":"method","name":"trim","params":[{"name":"str","description":"

a String or Array of Strings to be trimmed

\n","type":"String|Array"}],"return":{"description":"a trimmed String or Array of Strings","type":"String|Array"},"example":["\n
\n\nvar string = trim(\" No new lines\\n \");\ntext(string +\" here\", 2, 50);\n\n
"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src/utilities/time_date.js","line":12,"description":"

p5.js communicates with the clock on your computer. The day() function\nreturns the current day as a value from 1 - 31.

\n","itemtype":"method","name":"day","return":{"description":"the current day","type":"Number"},"example":["\n
\n\nvar d = day();\ntext(\"Current day: \\n\" + d, 5, 50);\n\n
"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src/utilities/time_date.js","line":30,"description":"

p5.js communicates with the clock on your computer. The hour() function\nreturns the current hour as a value from 0 - 23.

\n","itemtype":"method","name":"hour","return":{"description":"the current hour","type":"Number"},"example":["\n
\n\nvar h = hour();\ntext(\"Current hour:\\n\" + h, 5, 50);\n\n
"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src/utilities/time_date.js","line":48,"description":"

p5.js communicates with the clock on your computer. The minute() function\nreturns the current minute as a value from 0 - 59.

\n","itemtype":"method","name":"minute","return":{"description":"the current minute","type":"Number"},"example":["\n
\n\nvar m = minute();\ntext(\"Current minute: \\n\" + m, 5, 50);\n\n
"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src/utilities/time_date.js","line":66,"description":"

Returns the number of milliseconds (thousandths of a second) since\nstarting the program. This information is often used for timing events and\nanimation sequences.

\n","itemtype":"method","name":"millis","return":{"description":"the number of milliseconds since starting the program","type":"Number"},"example":["\n
\n\nvar millisecond = millis();\ntext(\"Milliseconds \\nrunning: \\n\" + millisecond, 5, 40);\n\n
"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src/utilities/time_date.js","line":85,"description":"

p5.js communicates with the clock on your computer. The month() function\nreturns the current month as a value from 1 - 12.

\n","itemtype":"method","name":"month","return":{"description":"the current month","type":"Number"},"example":["\n
\n\nvar m = month();\ntext(\"Current month: \\n\" + m, 5, 50);\n\n
"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src/utilities/time_date.js","line":103,"description":"

p5.js communicates with the clock on your computer. The second() function\nreturns the current second as a value from 0 - 59.

\n","itemtype":"method","name":"second","return":{"description":"the current second","type":"Number"},"example":["\n
\n\nvar s = second();\ntext(\"Current second: \\n\" + s, 5, 50);\n\n
"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src/utilities/time_date.js","line":121,"description":"

p5.js communicates with the clock on your computer. The year() function\nreturns the current year as an integer (2014, 2015, 2016, etc).

\n","itemtype":"method","name":"year","return":{"description":"the current year","type":"Number"},"example":["\n
\n\nvar y = year();\ntext(\"Current year: \\n\" + y, 5, 50);\n\n
"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src/webgl/camera.js","line":12,"description":"

Sets camera position

\n","itemtype":"method","name":"camera","params":[{"name":"x","description":"

camera position value on x axis

\n","type":"Number"},{"name":"y","description":"

camera position value on y axis

\n","type":"Number"},{"name":"z","description":"

camera position value on z axis

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\nfunction draw(){\n //move the camera away from the plane by a sin wave\n camera(0, 0, sin(frameCount * 0.01) * 100);\n plane(120, 120);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Camera"},{"file":"src/webgl/camera.js","line":47,"description":"

Sets perspective camera

\n","itemtype":"method","name":"perspective","params":[{"name":"fovy","description":"

camera frustum vertical field of view,\n from bottom to top of view, in degrees

\n","type":"Number"},{"name":"aspect","description":"

camera frustum aspect ratio

\n","type":"Number"},{"name":"near","description":"

frustum near plane length

\n","type":"Number"},{"name":"far","description":"

frustum far plane length

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n//drag mouse to toggle the world!\n//you will see there's a vanish point\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n perspective(60 / 180 * PI, width/height, 0.1, 100);\n}\nfunction draw(){\n background(200);\n orbitControl();\n for(var i = -1; i < 2; i++){\n for(var j = -2; j < 3; j++){\n push();\n translate(i*160, 0, j*160);\n box(40, 40, 40);\n pop();\n }\n }\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Camera"},{"file":"src/webgl/camera.js","line":95,"description":"

Setup ortho camera

\n","itemtype":"method","name":"ortho","params":[{"name":"left","description":"

camera frustum left plane

\n","type":"Number"},{"name":"right","description":"

camera frustum right plane

\n","type":"Number"},{"name":"bottom","description":"

camera frustum bottom plane

\n","type":"Number"},{"name":"top","description":"

camera frustum top plane

\n","type":"Number"},{"name":"near","description":"

camera frustum near plane

\n","type":"Number"},{"name":"far","description":"

camera frustum far plane

\n","type":"Number"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n//drag mouse to toggle the world!\n//there's no vanish point\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n ortho(-width/2, width/2, height/2, -height/2, 0.1, 100);\n}\nfunction draw(){\n background(200);\n orbitControl();\n for(var i = -1; i < 2; i++){\n for(var j = -2; j < 3; j++){\n push();\n translate(i*160, 0, j*160);\n box(40, 40, 40);\n pop();\n }\n }\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Camera"},{"file":"src/webgl/light.js","line":12,"description":"

Creates an ambient light with a color

\n","itemtype":"method","name":"ambientLight","params":[{"name":"v1","description":"

gray value,\nred or hue value (depending on the current color mode),\nor color Array, or CSS color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

optional: green or saturation value

\n","type":"Number","optional":true},{"name":"v3","description":"

optional: blue or brightness value

\n","type":"Number","optional":true},{"name":"a","description":"

optional: opacity

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\nfunction draw(){\n background(0);\n ambientLight(150);\n ambientMaterial(250);\n sphere(200);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Lights"},{"file":"src/webgl/light.js","line":68,"description":"

Creates a directional light with a color and a direction

\n","itemtype":"method","name":"directionalLight","params":[{"name":"v1","description":"

gray value,\nred or hue value (depending on the current color mode),\nor color Array, or CSS color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

optional: green or saturation value

\n","type":"Number","optional":true},{"name":"v3","description":"

optional: blue or brightness value

\n","type":"Number","optional":true},{"name":"a","description":"

optional: opacity

\n","type":"Number","optional":true},{"name":"x","description":"

x axis direction or a p5.Vector

\n","type":"Number|p5.Vector"},{"name":"y","description":"

optional: y axis direction

\n","type":"Number","optional":true},{"name":"z","description":"

optional: z axis direction

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\nfunction draw(){\n background(0);\n //move your mouse to change light direction\n var dirX = (mouseX / width - 0.5) *2;\n var dirY = (mouseY / height - 0.5) *(-2);\n directionalLight(250, 250, 250, dirX, dirY, 0.25);\n ambientMaterial(250);\n sphere(200);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Lights"},{"file":"src/webgl/light.js","line":192,"description":"

Creates a point light with a color and a light position

\n","itemtype":"method","name":"pointLight","params":[{"name":"v1","description":"

gray value,\nred or hue value (depending on the current color mode),\nor color Array, or CSS color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

optional: green or saturation value

\n","type":"Number","optional":true},{"name":"v3","description":"

optional: blue or brightness value

\n","type":"Number","optional":true},{"name":"a","description":"

optional: opacity

\n","type":"Number","optional":true},{"name":"x","description":"

x axis position or a p5.Vector

\n","type":"Number|p5.Vector"},{"name":"y","description":"

optional: y axis position

\n","type":"Number","optional":true},{"name":"z","description":"

optional: z axis position

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\nfunction draw(){\n background(0);\n //move your mouse to change light position\n var locY = (mouseY / height - 0.5) *(-2);\n var locX = (mouseX / width - 0.5) *2;\n //to set the light position,\n //think of the world's coordinate as:\n // -1,1 -------- 1,1\n // | |\n // | |\n // | |\n // -1,-1---------1,-1\n pointLight(250, 250, 250, locX, locY, 0);\n ambientMaterial(250);\n sphere(200);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Lights"},{"file":"src/webgl/loading.js","line":14,"description":"

Load a 3d model from an OBJ file.\n

\nOne of the limitations of the OBJ 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.

\n","itemtype":"method","name":"loadModel","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","optional":true},{"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.Geometry3D)","optional":true},{"name":"failureCallback","description":"

called with event error if\n the image fails to load.

\n","type":"Function(Event)","optional":true}],"return":{"description":"the p5.Geometry3D object","type":"p5.Geometry"},"example":["\n
\n\n//draw a spinning teapot\nvar teapot;\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n\n teapot = loadModel('assets/teapot.obj');\n}\n\nfunction draw(){\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n model(teapot);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src/webgl/loading.js","line":87,"description":"

Parse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:

\n

v -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

\n

f 4 3 2 1

\n","class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src/webgl/loading.js","line":187,"description":"

Render a 3d model to the screen.

\n","itemtype":"method","name":"model","params":[{"name":"model","description":"

Loaded 3d model to be rendered

\n","type":"p5.Geometry"}],"example":["\n
\n\n//draw a spinning teapot\nvar teapot;\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n\n teapot = loadModel('assets/teapot.obj');\n}\n\nfunction draw(){\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n model(teapot);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src/webgl/material.js","line":13,"description":"

Normal material for geometry. You can view all\npossible materials in this\nexample.

\n","itemtype":"method","name":"normalMaterial","return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(0);\n normalMaterial();\n sphere(200);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/material.js","line":39,"description":"

Texture for geometry. You can view other possible materials in this\nexample.

\n","itemtype":"method","name":"texture","params":[{"name":"tex","description":"

2-dimensional graphics\n to render as texture

\n","type":"p5.Image | p5.MediaElement | p5.Graphics"}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nvar img;\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n img = loadImage(\"assets/laDefense.jpg\");\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(200, 200, 200);\n}\n\n
\n\n
\n\nvar pg;\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n pg = createGraphics(200, 200);\n pg.textSize(100);\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 plane(200);\n}\n\n
\n\n
\n\nvar vid;\nfunction preload(){\n vid = createVideo(\"assets/fingers.mov\");\n vid.hide();\n vid.loop();\n}\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(0);\n //pass video frame as texture\n texture(vid);\n plane(200);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/material.js","line":161,"description":"

Texture Util functions

\n","class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/material.js","line":182,"description":"

Checks whether val is a pot\nmore info on power of 2 here:\nhttps://www.opengl.org/wiki/NPOT_Texture

\n","params":[{"name":"value","description":"","type":"Number"}],"return":{"description":"","type":"Boolean"},"class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/material.js","line":193,"description":"

returns the next highest power of 2 value

\n","params":[{"name":"value","description":"

[description]

\n","type":"Number"}],"return":{"description":"[description]","type":"Number"},"class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/material.js","line":205,"description":"

Ambient material for geometry with a given color. You can view all\npossible materials in this\nexample.

\n","itemtype":"method","name":"ambientMaterial","params":[{"name":"v1","description":"

gray value,\nred or hue value (depending on the current color mode),\nor color Array, or CSS color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

optional: green or saturation value

\n","type":"Number","optional":true},{"name":"v3","description":"

optional: blue or brightness value

\n","type":"Number","optional":true},{"name":"a","description":"

optional: opacity

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\nfunction draw(){\n background(0);\n ambientLight(100);\n pointLight(250, 250, 250, 100, 100, 0);\n ambientMaterial(250);\n sphere(200);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/material.js","line":255,"description":"

Specular material for geometry with a given color. You can view all\npossible materials in this\nexample.

\n","itemtype":"method","name":"specularMaterial","params":[{"name":"v1","description":"

gray value,\nred or hue value (depending on the current color mode),\nor color Array, or CSS color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

optional: green or saturation value

\n","type":"Number","optional":true},{"name":"v3","description":"

optional: blue or brightness value

\n","type":"Number","optional":true},{"name":"a","description":"

optional: opacity

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\nfunction draw(){\n background(0);\n ambientLight(100);\n pointLight(250, 250, 250, 100, 100, 0);\n specularMaterial(250);\n sphere(200);\n}\n\n
"],"class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/material.js","line":301,"access":"private","tagname":"blends colors according to color components.\nIf alpha value is less than 1, we need to enable blending\non our gl context. Otherwise opaque objects need to a depthMask.","params":[{"name":"v1","description":"

[description]

\n","type":"Number"},{"name":"v2","description":"

[description]

\n","type":"Number"},{"name":"v3","description":"

[description]

\n","type":"Number"},{"name":"a","description":"

[description]

\n","type":"Number"}],"return":{"description":"Normalized numbers array","type":"[Number]"},"class":"p5","module":"Lights, Camera","submodule":"Material"},{"file":"src/webgl/p5.Geometry.js","line":7,"description":"

p5 Geometry class

\n","is_constructor":1,"params":[{"name":"vertData","description":"

callback function or Object\n containing routine(s) for vertex data generation

\n","type":"Function | Object"},{"name":"detailX","description":"

number of vertices on horizontal surface

\n","type":"Number","optional":true},{"name":"detailY","description":"

number of vertices on horizontal surface

\n","type":"Number","optional":true},{"name":"callback","description":"

function to call upon object instantiation.

\n","type":"Function","optional":true}],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Geometry.js","line":71,"description":"

computes smooth normals per vertex as an average of each\nface.

\n","class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Geometry.js","line":95,"description":"

Averages the vertex normals. Used in curved\nsurfaces

\n","return":{"description":"","type":"p5.Geometry"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Geometry.js","line":114,"description":"

Averages pole normals. Used in spherical primitives

\n","return":{"description":"","type":"p5.Geometry"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Geometry.js","line":146,"description":"

Modifies all vertices to be centered within the range -100 to 100.

\n","return":{"description":"","type":"p5.Geometry"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":1,"requires":["constants"],"todo":["see methods below needing further implementation.\nfuture consideration: implement SIMD optimizations\nwhen browser compatibility becomes available\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/\n Reference/Global_Objects/SIMD"],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":19,"description":"

A class to describe a 4x4 matrix\nfor model and view matrix manipulation in the p5js webgl renderer.\nclass p5.Matrix

\n","is_constructor":1,"params":[{"name":"mat4","description":"

array literal of our 4x4 matrix

\n","type":"Array","optional":true}],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":74,"description":"

Sets the x, y, and z component of the vector using two or three separate\nvariables, the data from a p5.Matrix, or the values from a float array.

\n","params":[{"name":"inMatrix","description":"

the input p5.Matrix or\n an Array of length 16

\n","type":"p5.Matrix|Array","optional":true}],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":93,"description":"

Gets a copy of the vector, returns a p5.Matrix object.

\n","return":{"description":"the copy of the p5.Matrix object","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":102,"description":"

return a copy of a matrix

\n","return":{"description":"the result matrix","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":127,"description":"

return an identity matrix

\n","return":{"description":"the result matrix","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":135,"description":"

transpose according to a given matrix

\n","params":[{"name":"a","description":"

the matrix to be based on to transpose

\n","type":"p5.Matrix | Typed Array"}],"return":{"description":"this","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":195,"description":"

invert matrix according to a give matrix

\n","params":[{"name":"a","description":"

the matrix to be based on to invert

\n","type":"p5.Matrix or Typed Array"}],"return":{"description":"this","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":280,"description":"

Inverts a 3x3 matrix

\n","return":{"description":"[description]","type":"[type]"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":316,"description":"

transposes a 3x3 p5.Matrix by a mat3

\n","params":[{"name":"mat3","description":"

1-dimensional array

\n","type":"[Number]"}],"return":{"description":"this","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":332,"description":"

converts a 4x4 matrix to its 3x3 inverse tranform\ncommonly used in MVMatrix to NMatrix conversions.

\n","params":[{"name":"mat4","description":"

the matrix to be based on to invert

\n","type":"p5.Matrix"}],"return":{"description":"this with mat3","type":"p5.Matrix"},"todo":["finish implementation"],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":360,"description":"

inspired by Toji's mat4 determinant

\n","return":{"description":"Determinant of our 4x4 matrix","type":"Number"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":383,"description":"

multiply two mat4s

\n","params":[{"name":"multMatrix","description":"

The matrix we want to multiply by

\n","type":"p5.Matrix | Array"}],"return":{"description":"this","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":439,"description":"

scales a p5.Matrix by scalars or a vector

\n","params":[{"name":"UNKNOWN","description":"

vector to scale by

\n","type":"p5.Vector | Array"}],"return":{"description":"this","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":485,"description":"

rotate our Matrix around an axis by the given angle.

\n","params":[{"name":"a","description":"

The angle of rotation in radians

\n","type":"Number"},{"name":"axis","description":"

the axis(es) to rotate around

\n","type":"p5.Vector | Array"}],"return":{"description":"this\ninspired by Toji's gl-matrix lib, mat4 rotation","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":564,"todo":["finish implementing this method!\ntranslates"],"params":[{"name":"v","description":"

vector to translate by

\n","type":"Array"}],"return":{"description":"this","type":"p5.Matrix"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":594,"description":"

sets the perspective matrix

\n","params":[{"name":"fovy","description":"

[description]

\n","type":"Number"},{"name":"aspect","description":"

[description]

\n","type":"Number"},{"name":"near","description":"

near clipping plane

\n","type":"Number"},{"name":"far","description":"

far clipping plane

\n","type":"Number"}],"return":{"description":"","type":"Void"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":628,"description":"

sets the ortho matrix

\n","params":[{"name":"left","description":"

[description]

\n","type":"Number"},{"name":"right","description":"

[description]

\n","type":"Number"},{"name":"bottom","description":"

[description]

\n","type":"Number"},{"name":"top","description":"

[description]

\n","type":"Number"},{"name":"near","description":"

near clipping plane

\n","type":"Number"},{"name":"far","description":"

far clipping plane

\n","type":"Number"}],"return":{"description":"","type":"Void"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.Matrix.js","line":663,"description":"

PRIVATE

\n","class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Immediate.js","line":1,"description":"

Welcome to RendererGL Immediate Mode.\nImmediate mode is used for drawing custom shapes\nfrom a set of vertices. Immediate Mode is activated\nwhen you call beginShape() & de-activated when you call endShape().\nImmediate mode is a style of programming borrowed\nfrom OpenGL's (now-deprecated) immediate mode.\nIt differs from p5.js' default, Retained Mode, which caches\ngeometries and buffers on the CPU to reduce the number of webgl\ndraw calls. Retained mode is more efficient & performative,\nhowever, Immediate Mode is useful for sketching quick\ngeometric ideas.

\n","class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Immediate.js","line":19,"description":"

Begin shape drawing. This is a helpful way of generating\ncustom shapes quickly. However in WEBGL mode, application\nperformance will likely drop as a result of too many calls to\nbeginShape() / endShape(). As a high performance alternative,\nplease use p5.js geometry primitives.

\n","params":[{"name":"mode","description":"

webgl primitives mode. beginShape supports the\n following modes:\n POINTS,LINES,LINE_STRIP,LINE_LOOP,TRIANGLES,\n TRIANGLE_STRIP,and TRIANGLE_FAN.

\n","type":"Number"}],"return":{"description":"[description]","type":"[type]"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Immediate.js","line":49,"description":"

adds a vertex to be drawn in a custom Shape.

\n","params":[{"name":"x","description":"

x-coordinate of vertex

\n","type":"Number"},{"name":"y","description":"

y-coordinate of vertex

\n","type":"Number"},{"name":"z","description":"

z-coordinate of vertex

\n","type":"Number"}],"return":{"description":"[description]","type":"p5.RendererGL"},"todo":["implement handling of p5.Vector args"],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Immediate.js","line":68,"description":"

End shape drawing and render vertices to screen.

\n","return":{"description":"[description]","type":"p5.RendererGL"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Immediate.js","line":121,"description":"

Bind immediateMode buffers to data,\nthen draw gl arrays

\n","params":[{"name":"vertices","description":"

Numbers array representing\n vertex positions

\n","type":"Array"}],"return":{"description":"","type":"p5.RendererGL"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Retained.js","line":7,"description":"

initializes buffer defaults. runs each time a new geometry is\nregistered

\n","params":[{"name":"gId","description":"

key of the geometry object

\n","type":"String"}],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Retained.js","line":30,"description":"

createBuffers description

\n","params":[{"name":"gId","description":"

key of the geometry object

\n","type":"String"},{"name":"obj","description":"

contains geometry data

\n","type":"p5.Geometry"}],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Retained.js","line":93,"description":"

Draws buffers given a geometry key ID

\n","params":[{"name":"gId","description":"

ID in our geom hash

\n","type":"String"}],"return":{"description":"this","type":"p5.RendererGL"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Retained.js","line":129,"description":"

turn a two dimensional array into one dimensional array

\n","params":[{"name":"arr","description":"

2-dimensional array

\n","type":"Array"}],"return":{"description":"1-dimensional array\n[[1, 2, 3],[4, 5, 6]] -> [1, 2, 3, 4, 5, 6]","type":"Array"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.Retained.js","line":145,"description":"

turn a p5.Vector Array into a one dimensional number array

\n","params":[{"name":"arr","description":"

an array of p5.Vector

\n","type":"Array"}],"return":{"description":"a one dimensional array of numbers\n[p5.Vector(1, 2, 3), p5.Vector(4, 5, 6)] ->\n[1, 2, 3, 4, 5, 6]","type":"Array]"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":43,"description":"

model view, projection, & normal\nmatrices

\n","class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":106,"description":"

[background description]

\n","return":{"description":"[description]","type":"[type]"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":130,"description":"

[_initShaders description]

\n","params":[{"name":"vertId","description":"

[description]

\n","type":"String"},{"name":"fragId","description":"

[description]

\n","type":"String"}],"return":{"description":"[description]","type":"[type]"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":205,"description":"

Sets a shader uniform given a shaderProgram and uniform string

\n","params":[{"name":"shaderKey","description":"

key to material Hash.

\n","type":"String"},{"name":"uniform","description":"

location in shader.

\n","type":"String"},{"name":"data","description":"

data to bind uniform. Float data type.

\n","type":"Number"}],"todo":["currently this function sets uniform1f data.\nShould generalize function to accept any uniform\ndata type."],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":280,"description":"

Basic fill material for geometry with a given color

\n","itemtype":"method","name":"fill","params":[{"name":"v1","description":"

gray value,\nred or hue value (depending on the current color mode),\nor color Array, or CSS color string

\n","type":"Number|Array|String|p5.Color"},{"name":"v2","description":"

optional: green or saturation value

\n","type":"Number","optional":true},{"name":"v3","description":"

optional: blue or brightness value

\n","type":"Number","optional":true},{"name":"a","description":"

optional: opacity

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(0);\n fill(250, 0, 0);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n box(200, 200, 200);\n}\n\n
"],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":353,"description":"

[strokeWeight description]

\n","params":[{"name":"pointSize","description":"

stroke point size

\n","type":"Number"}],"return":{"description":"[description]","type":"[type]"},"todo":["strokeWeight currently works on points only.\nimplement on all wireframes and strokes."],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":376,"description":"

[resize description]

\n","params":[{"name":"w","description":"

[description]

\n","type":"[type]"},{"name":"h","description":"

[description]

\n","type":"[tyoe]"}],"return":{"description":"[description]","type":"[type]"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":393,"description":"

clears color and depth buffers\nwith r,g,b,a

\n","params":[{"name":"r","description":"

normalized red val.

\n","type":"Number"},{"name":"g","description":"

normalized green val.

\n","type":"Number"},{"name":"b","description":"

normalized blue val.

\n","type":"Number"},{"name":"a","description":"

normalized alpha val.

\n","type":"Number"}],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":410,"description":"

[translate description]

\n","params":[{"name":"x","description":"

[description]

\n","type":"[type]"},{"name":"y","description":"

[description]

\n","type":"[type]"},{"name":"z","description":"

[description]

\n","type":"[type]"}],"return":{"description":"[description]","type":"[type]"},"todo":["implement handle for components or vector as args"],"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":427,"description":"

Scales the Model View Matrix by a vector

\n","params":[{"name":"x","description":"

[description]

\n","type":"Number | p5.Vector | Array"},{"name":"y","description":"

y-axis scalar

\n","type":"Number","optional":true},{"name":"z","description":"

z-axis scalar

\n","type":"Number","optional":true}],"return":{"description":"[description]","type":"This"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":459,"description":"

pushes a copy of the model view matrix onto the\nMV Matrix stack.

\n","class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/p5.RendererGL.js","line":467,"description":"

[pop description]

\n","return":{"description":"[description]","type":"[type]"},"class":"p5.RendererGL","module":"Lights, Camera"},{"file":"src/webgl/primitives.js","line":13,"description":"

Draw a plane with given a width and height

\n","itemtype":"method","name":"plane","params":[{"name":"width","description":"

width of the plane

\n","type":"Number"},{"name":"height","description":"

height of the plane

\n","type":"Number"},{"name":"detailX","description":"

Optional number of triangle\n subdivisions in x-dimension

\n","type":"Number","optional":true},{"name":"detailY","description":"

Optional number of triangle\n subdivisions in y-dimension

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n//draw a plane with width 200 and height 200\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(200);\n plane(200, 200);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/webgl/primitives.js","line":77,"description":"

Draw a box with given width, height and depth

\n","itemtype":"method","name":"box","params":[{"name":"width","description":"

width of the box

\n","type":"Number"},{"name":"Height","description":"

height of the box

\n","type":"Number"},{"name":"depth","description":"

depth of the box

\n","type":"Number"},{"name":"detailX","description":"

Optional number of triangle\n subdivisions in x-dimension

\n","type":"Number","optional":true},{"name":"detailY","description":"

Optional number of triangle\n subdivisions in y-dimension

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n//draw a spinning box with width, height and depth 200\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(200, 200, 200);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/webgl/primitives.js","line":162,"description":"

Draw a sphere with given radius

\n","itemtype":"method","name":"sphere","params":[{"name":"radius","description":"

radius of circle

\n","type":"Number"},{"name":"detailX","description":"

optional: number of segments,\n the more segments the smoother geometry\n default is 24

\n","type":"Number","optional":true},{"name":"detailY","description":"

optional: number of segments,\n the more segments the smoother geometry\n default is 16

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n// draw a sphere with radius 200\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(200);\n sphere(200);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/webgl/primitives.js","line":230,"access":"private","tagname":"helper function for creating both cones and cyllinders","class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/webgl/primitives.js","line":308,"description":"

Draw a cylinder with given radius and height

\n","itemtype":"method","name":"cylinder","params":[{"name":"radius","description":"

radius of the surface

\n","type":"Number"},{"name":"height","description":"

height of the cylinder

\n","type":"Number"},{"name":"detailX","description":"

optional: number of segments,\n the more segments the smoother geometry\n default is 24

\n","type":"Number","optional":true},{"name":"detailY","description":"

optional: number of segments in y-dimension,\n the more segments the smoother geometry\n default is 16

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n//draw a spinning cylinder with radius 200 and height 200\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(200);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n cylinder(200, 200);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/webgl/primitives.js","line":367,"description":"

Draw a cone with given radius and height

\n","itemtype":"method","name":"cone","params":[{"name":"radius","description":"

radius of the bottom surface

\n","type":"Number"},{"name":"height","description":"

height of the cone

\n","type":"Number"},{"name":"detailX","description":"

optional: number of segments,\n the more segments the smoother geometry\n default is 24

\n","type":"Number","optional":true},{"name":"detailY","description":"

optional: number of segments,\n the more segments the smoother geometry\n default is 16

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n//draw a spinning cone with radius 200 and height 200\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(200);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n cone(200, 200);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/webgl/primitives.js","line":427,"description":"

Draw an ellipsoid with given raduis

\n","itemtype":"method","name":"ellipsoid","params":[{"name":"radiusx","description":"

xradius of circle

\n","type":"Number"},{"name":"radiusy","description":"

yradius of circle

\n","type":"Number"},{"name":"radiusz","description":"

zradius of circle

\n","type":"Number"},{"name":"detailX","description":"

optional: 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":"Number","optional":true},{"name":"detailY","description":"

optional: 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":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n// draw an ellipsoid with radius 200, 300 and 400 .\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(200);\n ellipsoid(200,300,400);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/webgl/primitives.js","line":501,"description":"

Draw a torus with given radius and tube radius

\n","itemtype":"method","name":"torus","params":[{"name":"radius","description":"

radius of the whole ring

\n","type":"Number"},{"name":"tubeRadius","description":"

radius of the tube

\n","type":"Number"},{"name":"detailX","description":"

optional: number of segments in x-dimension,\n the more segments the smoother geometry\n default is 24

\n","type":"Number","optional":true},{"name":"detailY","description":"

optional: number of segments in y-dimension,\n the more segments the smoother geometry\n default is 16

\n","type":"Number","optional":true}],"return":{"description":"the p5 object","type":"P5"},"example":["\n
\n\n//draw a spinning torus with radius 200 and tube radius 60\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n torus(200, 60);\n}\n\n
"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src/app.js","line":62,"description":"

_globalInit

\n

TODO: ???\nif sketch is on window\nassume "global" mode\nand instantiate p5 automatically\notherwise do nothing

\n","return":{"description":"","type":"Undefined"},"class":"p5.dom","module":"Shape"},{"file":"lib/addons/p5.dom.js","line":40,"description":"

Searches the page for an element with the given ID, class, or tag name (using the '#' or '.'\nprefixes to specify an ID or class respectively, and none for a tag) and returns it as\na p5.Element. If a class or tag name is given with more than 1 element,\nonly the first element will be returned.\nThe DOM node itself can be accessed with .elt.\nReturns null if none found. You can also specify a container to search within.

\n","itemtype":"method","name":"select","params":[{"name":"name","description":"

id, class, or tag name of element to search for

\n","type":"String"},{"name":"container","description":"

id, p5.Element, or HTML element to search within

\n","type":"String","optional":true}],"return":{"description":"p5.Element containing node found","type":"Object/p5.Element|Null"},"example":["\n
\nfunction setup() {\n createCanvas(100,100);\n //translates canvas 50px down\n select('canvas').position(100, 100);\n}\n
\n
\n// these are all valid calls to select()\nvar a = select('#moo');\nvar b = select('#blah', '#myContainer');\nvar c = select('#foo', b);\nvar d = document.getElementById('beep');\nvar e = select('p', d);\n
\n"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":99,"description":"

Searches the page for elements with the given class or tag name (using the '.' prefix\nto specify a class and no prefix for a tag) and returns them as p5.Elements\nin an array.\nThe DOM node itself can be accessed with .elt.\nReturns an empty array if none found.\nYou can also specify a container to search within.

\n","itemtype":"method","name":"selectAll","params":[{"name":"name","description":"

class or tag name of elements to search for

\n","type":"String"},{"name":"container","description":"

id, p5.Element, or HTML element to search within

\n","type":"String","optional":true}],"return":{"description":"Array of p5.Elements containing nodes found","type":"Array"},"example":["\n
\nfunction setup() {\n createButton('btn');\n createButton('2nd btn');\n createButton('3rd btn');\n var buttons = selectAll('button');\n\n for (var i = 0; i < buttons.length; i++){\n buttons[i].size(100,100);\n }\n}\n
\n
\n// these are all valid calls to selectAll()\nvar a = selectAll('.moo');\nvar b = selectAll('div');\nvar c = selectAll('button', '#myContainer');\nvar d = select('#container');\nvar e = selectAll('p', d);\nvar f = document.getElementById('beep');\nvar g = select('.blah', f);\n
\n"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":155,"description":"

Helper function for select and selectAll

\n","class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":171,"description":"

Helper function for getElement and getElements.

\n","class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":195,"description":"

Removes all elements created by p5, except any canvas / graphics\nelements created by createCanvas or createGraphics.\nEvent handlers are removed, and element is removed from the DOM.

\n","itemtype":"method","name":"removeElements","example":["\n
\nfunction setup() {\n createCanvas(100, 100);\n createDiv('this is some text');\n createP('this is a paragraph');\n}\nfunction mousePressed() {\n removeElements(); // this will remove the div and p, not canvas\n}\n
\n"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":221,"description":"

Helpers for create methods.

\n","class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":232,"description":"

Creates a <div></div> element in the DOM with given inner HTML.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createDiv","params":[{"name":"html","description":"

inner HTML for element created

\n","type":"String"}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar myDiv;\nfunction setup() {\n myDiv = createDiv('this is some text');\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":249,"description":"

Creates a <p></p> element in the DOM with given inner HTML. Used\nfor paragraph length text.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createP","params":[{"name":"html","description":"

inner HTML for element created

\n","type":"String"}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar myP;\nfunction setup() {\n myP = createP('this is some text');\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":267,"description":"

Creates a <span></span> element in the DOM with given inner HTML.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createSpan","params":[{"name":"html","description":"

inner HTML for element created

\n","type":"String"}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar mySpan;\nfunction setup() {\n mySpan = createSpan('this is some text');\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":293,"description":"

Creates an <img /> element in the DOM with given src and\nalternate text.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createImg","params":[{"name":"src","description":"

src path or url for image

\n","type":"String"},{"name":"alt","description":"

alternate text to be used if image does not load

\n","type":"String","optional":true},{"name":"successCallback","description":"

callback to be called once image data is loaded

\n","type":"Function","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar img;\nfunction setup() {\n img = createImg('http://p5js.org/img/asterisk-01.png');\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":338,"description":"

Creates an <a></a> element in the DOM for including a hyperlink.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createA","params":[{"name":"href","description":"

url of page to link to

\n","type":"String"},{"name":"html","description":"

inner html of link element to display

\n","type":"String"},{"name":"target","description":"

target where new link should open,\n could be _blank, _self, _parent, _top.

\n","type":"String","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar myLink;\nfunction setup() {\n myLink = createA('http://p5js.org/', 'this is a link');\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":365,"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":368,"description":"

Creates a slider <input></input> element in the DOM.\nUse .size() to set the display length of the slider.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createSlider","params":[{"name":"min","description":"

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":"

step size for each tick of the slider

\n","type":"Number","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar slider;\nfunction setup() {\n slider = createSlider(0, 255, 100);\n slider.position(10, 10);\n slider.style('width', '80px');\n}\n\nfunction draw() {\n var val = slider.value();\n background(val);\n}\n
\n\n
\nvar slider;\nfunction setup() {\n colorMode(HSB);\n slider = createSlider(0, 360, 60, 40);\n slider.position(10, 10);\n slider.style('width', '80px');\n}\n\nfunction draw() {\n var val = slider.value();\n background(val, 100, 100, 1);\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":420,"description":"

Creates a <button></button> element in the DOM.\nUse .size() to set the display size of the button.\nUse .mousePressed() to specify behavior on press.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","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}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar button;\nfunction setup() {\n createCanvas(100, 100);\n background(0);\n button = createButton('click me');\n button.position(19, 19);\n button.mousePressed(changeBG);\n}\n\nfunction changeBG() {\n var val = random(255);\n background(val);\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":456,"description":"

Creates a checkbox <input></input> element in the DOM.\nCalling .checked() on a checkbox returns if it is checked or not

\n","itemtype":"method","name":"createCheckbox","params":[{"name":"label","description":"

label displayed after checkbox

\n","type":"String","optional":true},{"name":"value","description":"

value of the checkbox; checked is true, unchecked is false.Unchecked if no value given

\n","type":"Boolean","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar checkbox;\n\nfunction setup() {\n checkbox = createCheckbox('label', false);\n checkbox.changed(myCheckedEvent);\n}\n\nfunction myCheckedEvent() {\n if (this.checked()) {\n console.log(\"Checking!\");\n } else {\n console.log(\"Unchecking!\");\n }\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":521,"description":"

Creates a dropdown menu <select></select> element in the DOM.

\n","itemtype":"method","name":"createSelect","params":[{"name":"multiple","description":"

[true if dropdown should support multiple selections]

\n","type":"Boolean","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar sel;\n\nfunction setup() {\n textAlign(CENTER);\n background(200);\n sel = createSelect();\n sel.position(10, 10);\n sel.option('pear');\n sel.option('kiwi');\n sel.option('grape');\n sel.changed(mySelectEvent);\n}\n\nfunction mySelectEvent() {\n var item = sel.value();\n background(200);\n text(\"it's a \"+item+\"!\", 50, 50);\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":586,"description":"

Creates a radio button <input></input> element in the DOM.\nThe .option() method can be used to set options for the radio after it is\ncreated. The .value() method will return the currently selected option.

\n","itemtype":"method","name":"createRadio","params":[{"name":"divId","description":"

the id and name of the created div and input field respectively

\n","type":"String","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar radio;\n\nfunction setup() {\n radio = createRadio();\n radio.option(\"black\");\n radio.option(\"white\");\n radio.option(\"gray\");\n radio.style('width', '60px');\n textAlign(CENTER);\n fill(255, 0, 0);\n}\n\nfunction draw() {\n var val = radio.value();\n background(val);\n text(val, width/2, height/2);\n}\n
\n
\nvar radio;\n\nfunction setup() {\n radio = createRadio();\n radio.option('apple', 1);\n radio.option('bread', 2);\n radio.option('juice', 3);\n radio.style('width', '60px');\n textAlign(CENTER);\n}\n\nfunction draw() {\n background(200);\n var val = radio.value();\n if (val) {\n text('item cost is $'+val, width/2, height/2);\n }\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":712,"description":"

Creates an <input></input> element in the DOM for text input.\nUse .size() to set the display length of the box.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createInput","params":[{"name":"value","description":"

default value of the input box

\n","type":"Number","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nfunction setup(){\n var inp = createInput('');\n inp.input(myInputEvent);\n}\n\nfunction myInputEvent(){\n console.log('you are typing: ', this.value());\n}\n\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":741,"description":"

Creates an <input></input> element in the DOM of type 'file'.\nThis allows users to select local files for use in a sketch.

\n","itemtype":"method","name":"createFileInput","params":[{"name":"callback","description":"

callback function for when a file loaded

\n","type":"Function","optional":true},{"name":"multiple","description":"

optional to allow multiple files selected

\n","type":"String","optional":true}],"return":{"description":"pointer to p5.Element holding created DOM element","type":"Object/p5.Element"},"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":804,"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":841,"description":"

Creates an HTML5 <video> element in the DOM for simple playback\nof audio/video. Shown by default, can be hidden with .hide()\nand drawn into canvas using video(). Appends to the container\nnode if one is specified, otherwise appends to body. The first parameter\ncan be either a single string path to a video file, or an array of string\npaths to different formats of the same video. This is useful for ensuring\nthat your video can play across different browsers, as each supports\ndifferent formats. See this\npage for further information about supported formats.

\n","itemtype":"method","name":"createVideo","params":[{"name":"src","description":"

path to a video file, or array of paths for\n supporting different browsers

\n","type":"String|Array"},{"name":"callback","description":"

callback function to be called upon\n 'canplaythrough' event fire, that is, when the\n browser can play the media, and estimates that\n enough data has been loaded to play the media\n up to its end without having to stop for\n further buffering of content

\n","type":"Object","optional":true}],"return":{"description":"pointer to video p5.Element","type":"Object/p5.Element"},"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":867,"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":869,"description":"

Creates a hidden HTML5 <audio> element in the DOM for simple audio\nplayback. Appends to the container node if one is specified,\notherwise appends to body. The first parameter\ncan be either a single string path to a audio file, or an array of string\npaths to different formats of the same audio. This is useful for ensuring\nthat your audio can play across different browsers, as each supports\ndifferent formats. See this\npage for further information about supported formats.

\n","itemtype":"method","name":"createAudio","params":[{"name":"src","description":"

path to an audio file, or array of paths for\n supporting different browsers

\n","type":"String|Array"},{"name":"callback","description":"

callback function to be called upon\n 'canplaythrough' event fire, that is, when the\n browser can play the media, and estimates that\n enough data has been loaded to play the media\n up to its end without having to stop for\n further buffering of content

\n","type":"Object","optional":true}],"return":{"description":"pointer to audio p5.Element","type":"Object/p5.Element"},"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":895,"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":905,"description":"

Creates a new <video> element that contains the audio/video feed\nfrom a webcam. This can be drawn onto the canvas using video().

\n

More specific properties of the feed can be passing in a Constraints object.\nSee the\n W3C\nspec for possible properties. Note that not all of these are supported\nby all browsers.

\n

Security note: A new browser security specification requires that getUserMedia,\nwhich is behind createCapture(), only works when you're running the code locally,\nor on HTTPS. Learn more here\nand here.

","itemtype":"method","name":"createCapture","params":[{"name":"type","description":"

type of capture, either VIDEO or\n AUDIO if none specified, default both,\n or a Constraints object

\n","type":"String|Constant|Object"},{"name":"callback","description":"

function to be called once\n stream has loaded

\n","type":"Function"}],"return":{"description":"capture video p5.Element","type":"Object/p5.Element"},"example":["\n
\nvar capture;\n\nfunction setup() {\n createCanvas(480, 120);\n capture = createCapture(VIDEO);\n}\n\nfunction draw() {\n image(capture, 0, 0, width, width*capture.height/capture.width);\n filter(INVERT);\n}\n
\n
\nfunction setup() {\n createCanvas(480, 120);\n var constraints = {\n video: {\n mandatory: {\n minWidth: 1280,\n minHeight: 720\n },\n optional: [\n { maxFrameRate: 10 }\n ]\n },\n audio: true\n };\n createCapture(constraints, function(stream) {\n console.log(stream);\n });\n}\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1005,"description":"

Creates element with given tag in the DOM with given content.\nAppends to the container node if one is specified, otherwise\nappends to body.

\n","itemtype":"method","name":"createElement","params":[{"name":"tag","description":"

tag for the new element

\n","type":"String"},{"name":"content","description":"

html content to be inserted into the element

\n","type":"String","optional":true}],"return":{"description":"pointer to p5.Element holding created node","type":"Object/p5.Element"},"example":["\n
\nvar h2 = createElement('h2','im an h2 p5.element!');\n
"],"class":"p5.dom","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1031,"description":"

Adds specified class to the element.

\n","itemtype":"method","name":"addClass","params":[{"name":"class","description":"

name of class to add

\n","type":"String"}],"return":{"description":"","type":"Object/p5.Element"},"example":["\n
\n var div = createDiv('div');\n div.addClass('myClass');\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1058,"description":"

Removes specified class from the element.

\n","itemtype":"method","name":"removeClass","params":[{"name":"class","description":"

name of class to remove

\n","type":"String"}],"return":{"description":"","type":"Object/p5.Element"},"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1073,"description":"

Attaches the element as a child to the parent specified.\n Accepts either a string ID, DOM node, or p5.Element.\n If no argument is specified, an array of children DOM nodes is returned.

\n","itemtype":"method","name":"child","params":[{"name":"child","description":"

the ID, DOM node, or p5.Element\n to add to the current element

\n","type":"String|Object|p5.Element","optional":true}],"return":{"description":"","type":"p5.Element"},"example":["\n
\n var div0 = createDiv('this is the parent');\n var div1 = createDiv('this is the child');\n div0.child(div1); // use p5.Element\n
\n
\n var div0 = createDiv('this is the parent');\n var div1 = createDiv('this is the child');\n div1.id('apples');\n div0.child('apples'); // use id\n
\n
\n var div0 = createDiv('this is the parent');\n var elt = document.getElementById('myChildDiv');\n div0.child(elt); // use element from page\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1117,"description":"

Centers a p5 Element either vertically, horizontally,\nor both, relative to its parent or according to\nthe body if the Element has no parent. If no argument is passed\nthe Element is aligned both vertically and horizontally.

\n","params":[{"name":"align","description":"

passing 'vertical', 'horizontal' aligns element accordingly

\n","type":"String"}],"return":{"description":"pointer to p5.Element","type":"Object/p5.Element"},"example":["\n
\nfunction setup() {\n var div = createDiv('').size(10,10);\n div.style('background-color','orange');\n div.center();\n\n}\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1170,"description":"

If an argument is given, sets the inner HTML of the element,\n replacing any existing html. If no arguments are given, returns\n the inner HTML of the element.

\n","itemtype":"method","name":"html","params":[{"name":"html","description":"

the HTML to be placed inside the element

\n","type":"String","optional":true}],"return":{"description":"","type":"Object/p5.Element|String"},"example":["\n
\n var div = createDiv('').size(100,100);\n div.style('background-color','orange');\n div.html('hi');\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1196,"description":"

Sets the position of the element relative to (0, 0) of the\n window. Essentially, sets position:absolute and left and top\n properties of style. If no arguments given returns the x and y position\n of the element in an object.

\n","itemtype":"method","name":"position","params":[{"name":"x","description":"

x-position relative to upper left of window

\n","type":"Number","optional":true},{"name":"y","description":"

y-position relative to upper left of window

\n","type":"Number","optional":true}],"return":{"description":"","type":"Object/p5.Element"},"example":["\n
\n function setup() {\n var 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
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1277,"description":"

Sets the given style (css) property (1st arg) of the element with the\ngiven value (2nd arg). If a single argument is given, .style()\nreturns the value of the given property; however, if the single argument\nis given in css syntax ('text-align:center'), .style() sets the css\nappropriatly. .style() also handles 2d and 3d css transforms. If\nthe 1st arg is 'rotate', 'translate', or 'position', the following arguments\naccept Numbers as values. ('translate', 10, 100, 50);

\n","itemtype":"method","name":"style","params":[{"name":"property","description":"

property to be set

\n","type":"String"},{"name":"value","description":"

value to assign to property

\n","type":"String|Number|p5.Color","optional":true},{"name":"value","description":"

value to assign to property (rotate/translate)

\n","type":"String|Number","optional":true},{"name":"value","description":"

value to assign to property (rotate/translate)

\n","type":"String|Number","optional":true},{"name":"value","description":"

value to assign to property (translate)

\n","type":"String|Number","optional":true}],"return":{"description":"value of property, if no value is specified\nor p5.Element","type":"String|Object/p5.Element"},"example":["\n
\nvar myDiv = createDiv(\"I like pandas.\");\nmyDiv.style(\"font-size\", \"18px\");\nmyDiv.style(\"color\", \"#ff0000\");\n
\n
\nvar col = color(25,23,200,50);\nvar button = createButton(\"button\");\nbutton.style(\"background-color\", col);\nbutton.position(10, 10);\n
\n
\nvar myDiv = createDiv(\"I like lizards.\");\nmyDiv.style(\"position\", 20, 20);\nmyDiv.style(\"rotate\", 45);\n
\n
\nvar myDiv;\nfunction setup() {\n background(200);\n myDiv = createDiv(\"I like gray.\");\n myDiv.position(20, 20);\n}\n\nfunction draw() {\n myDiv.style(\"font-size\", mouseX+\"px\");\n}\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1362,"description":"

Adds a new attribute or changes the value of an existing attribute\n on the specified element. If no value is specified, returns the\n value of the given attribute, or null if attribute is not set.

\n","itemtype":"method","name":"attribute","params":[{"name":"attr","description":"

attribute to set

\n","type":"String"},{"name":"value","description":"

value to assign to attribute

\n","type":"String","optional":true}],"return":{"description":"value of attribute, if no value is\n specified or p5.Element","type":"String|Object/p5.Element"},"example":["\n
\n var myDiv = createDiv(\"I like pandas.\");\n myDiv.attribute(\"align\", \"center\");\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1389,"description":"

Removes an attribute on the specified element.

\n","itemtype":"method","name":"removeAttribute","params":[{"name":"attr","description":"

attribute to remove

\n","type":"String"}],"return":{"description":"","type":"Object/p5.Element"},"example":["\n
\n var button;\n var checkbox;\nfunction setup() {\n checkbox = createCheckbox('enable', true);\n checkbox.changed(enableButton);\n button = createButton('button');\n button.position(10, 10);\n }\nfunction enableButton() {\n if( this.checked() ) {\n // Re-enable the button\n button.removeAttribute('disabled');\n } else {\n // Disable the button\n button.attribute('disabled','');\n }\n }\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1426,"description":"

Either returns the value of the element if no arguments\ngiven, or sets the value of the element.

\n","itemtype":"method","name":"value","params":[{"name":"value","description":"","type":"String|Number","optional":true}],"return":{"description":"value of element if no value is specified or p5.Element","type":"String|Object/p5.Element"},"example":["\n
\n// gets the value\nvar inp;\nfunction setup() {\n inp = createInput('');\n}\n\nfunction mousePressed() {\n print(inp.value());\n}\n
\n
\n// sets the value\nvar inp;\nfunction setup() {\n inp = createInput('myValue');\n}\n\nfunction mousePressed() {\n inp.value(\"myValue\");\n}\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1469,"description":"

Shows the current element. Essentially, setting display:block for the style.

\n","itemtype":"method","name":"show","return":{"description":"","type":"Object/p5.Element"},"example":["\n
\n var div = createDiv('div');\n div.style(\"display\", \"none\");\n div.show(); // turns display to block\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1487,"description":"

Hides the current element. Essentially, setting display:none for the style.

\n","itemtype":"method","name":"hide","return":{"description":"","type":"Object/p5.Element"},"example":["\n
\nvar div = createDiv('this is a div');\ndiv.hide();\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1503,"description":"

Sets the width and height of the element. AUTO can be used to\n only adjust one dimension. If no arguments given returns the width and height\n of the element in an object.

\n","itemtype":"method","name":"size","params":[{"name":"w","description":"

width of the element

\n","type":"Number","optional":true},{"name":"h","description":"

height of the element

\n","type":"Number","optional":true}],"return":{"description":"","type":"Object/p5.Element"},"example":["\n
\n var div = createDiv('this is a div');\n div.size(100, 100);\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1569,"description":"

Removes the element and deregisters all listeners.

\n","itemtype":"method","name":"remove","example":["\n
\nvar myDiv = createDiv('this is some text');\nmyDiv.remove();\n
"],"class":"p5.Element","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1618,"description":"

Path to the media element source.

\n","itemtype":"property","name":"src","return":{"description":"src","type":"String"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1653,"description":"

Play an HTML5 media element.

\n","itemtype":"method","name":"play","return":{"description":"","type":"Object/p5.Element"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1674,"description":"

Stops an HTML5 media element (sets current time to zero).

\n","itemtype":"method","name":"stop","return":{"description":"","type":"Object/p5.Element"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1686,"description":"

Pauses an HTML5 media element.

\n","itemtype":"method","name":"pause","return":{"description":"","type":"Object/p5.Element"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1697,"description":"

Set 'loop' to true for an HTML5 media element, and starts playing.

\n","itemtype":"method","name":"loop","return":{"description":"","type":"Object/p5.Element"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1708,"description":"

Set 'loop' to false for an HTML5 media element. Element will stop\nwhen it reaches the end.

\n","itemtype":"method","name":"noLoop","return":{"description":"","type":"Object/p5.Element"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1721,"description":"

Set HTML5 media element to autoplay or not.

\n","itemtype":"method","name":"autoplay","params":[{"name":"autoplay","description":"

whether the element should autoplay

\n","type":"Boolean"}],"return":{"description":"","type":"Object/p5.Element"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1733,"description":"

Sets volume for this HTML5 media element. If no argument is given,\nreturns the current volume.

\n","params":[{"name":"val","description":"

volume between 0.0 and 1.0

\n","type":"Number","optional":true}],"return":{"description":"current volume or p5.MediaElement","type":"Number|p5.MediaElement"},"itemtype":"method","name":"volume","class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1749,"description":"

If no arguments are given, returns the current playback speed of the\nelement. The speed parameter sets the speed where 2.0 will play the\nelement twice as fast, 0.5 will play at half the speed, and -1 will play\nthe element in normal speed in reverse.(Note that not all browsers support\nbackward playback and even if they do, playback might not be smooth.)

\n","itemtype":"method","name":"speed","params":[{"name":"speed","description":"

speed multiplier for element playback

\n","type":"Number","optional":true}],"return":{"description":"current playback speed or p5.MediaElement","type":"Number|Object/p5.MediaElement"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1768,"description":"

If no arguments are given, returns the current time of the element.\nIf an argument is given the current time of the element is set to it.

\n","itemtype":"method","name":"time","params":[{"name":"time","description":"

time to jump to (in seconds)

\n","type":"Number","optional":true}],"return":{"description":"current time (in seconds)\n or p5.MediaElement","type":"Number|Object/p5.MediaElement"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1785,"description":"

Returns the duration of the HTML5 media element.

\n","itemtype":"method","name":"duration","return":{"description":"duration","type":"Number"},"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1835,"description":"

Schedule an event to be called when the audio or video\nelement reaches the end. If the element is looping,\nthis will not be called. The element is passed in\nas the argument to the onended callback.

\n","itemtype":"method","name":"onended","params":[{"name":"callback","description":"

function to call when the\n soundfile has ended. The\n media element will be passed\n in as the argument to the\n callback.

\n","type":"Function"}],"return":{"description":"","type":"Object/p5.MediaElement"},"example":["\n
\nfunction setup() {\n audioEl = createAudio('assets/beat.mp3');\n audioEl.showControls(true);\n audioEl.onended(sayDone);\n}\n\nfunction sayDone(elt) {\n alert('done playing ' + elt.src );\n}\n
"],"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1867,"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1869,"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 master\noutput. That connection is established when this method is first called.\nAll connections are removed by the .disconnect() method.

\n

This method is meant to be used with the p5.sound.js addon library.

\n","itemtype":"method","name":"connect","params":[{"name":"audioNode","description":"

AudioNode from the Web Audio API,\nor an object from the p5.sound library

\n","type":"AudioNode|p5.sound object"}],"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1921,"description":"

Disconnect all Web Audio routing, including to master output.\nThis is useful if you want to re-route the output through\naudio effects, for example.

\n","itemtype":"method","name":"disconnect","class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1937,"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1939,"description":"

Show the default MediaElement controls, as determined by the web browser.

\n","itemtype":"method","name":"showControls","class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1950,"description":"

Hide the default mediaElement controls.

\n","itemtype":"method","name":"hideControls","class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1959,"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":1961,"description":"

Schedule events to trigger every time a MediaElement\n(audio/video) reaches a playback cue point.

\n

Accepts a callback function, a time (in seconds) at which to trigger\nthe callback, and an optional parameter for the callback.

\n

Time will be passed as the first parameter to the callback function,\nand param will be the second parameter.

\n","itemtype":"method","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}],"return":{"description":"id ID of this cue,\n useful for removeCue(id)","type":"Number"},"example":["\n
\nfunction setup() {\n background(255,255,255);\n\n audioEl = createAudio('assets/beat.mp3');\n audioEl.showControls();\n\n // schedule three calls to changeBackground\n audioEl.addCue(0.5, changeBackground, color(255,0,0) );\n audioEl.addCue(1.0, changeBackground, color(0,255,0) );\n audioEl.addCue(2.5, changeBackground, color(0,0,255) );\n audioEl.addCue(3.0, changeBackground, color(0,255,255) );\n audioEl.addCue(4.2, changeBackground, color(255,255,0) );\n audioEl.addCue(5.0, changeBackground, color(255,255,0) );\n}\n\nfunction changeBackground(val) {\n background(val);\n}\n
"],"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2023,"description":"

Remove a callback based on its ID. The ID is returned by the\naddCue method.

\n","itemtype":"method","name":"removeCue","params":[{"name":"id","description":"

ID of the cue, as returned by addCue

\n","type":"Number"}],"class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2043,"description":"

Remove all of the callbacks that had originally been scheduled\nvia the addCue method.

\n","itemtype":"method","name":"clearCues","class":"p5.MediaElement","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2100,"description":"

Underlying File object. All normal File methods can be called on this.

\n","itemtype":"property","name":"file","class":"p5.File","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2112,"description":"

File type (image, text, etc.)

\n","itemtype":"property","name":"type","class":"p5.File","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2118,"description":"

File subtype (usually the file extension jpg, png, xml, etc.)

\n","itemtype":"property","name":"subtype","class":"p5.File","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2124,"description":"

File name

\n","itemtype":"property","name":"name","class":"p5.File","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2130,"description":"

File size

\n","itemtype":"property","name":"size","class":"p5.File","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.dom.js","line":2137,"description":"

URL string containing image data.

\n","itemtype":"property","name":"data","class":"p5.File","module":"p5.dom","submodule":"p5.dom"},{"file":"lib/addons/p5.sound.js","line":53,"description":"

p5.sound developed by Jason Sigal for the Processing Foundation, Google Summer of Code 2014. The MIT License (MIT).

\n

http://github.com/therewasaguy/p5.sound

\n

Some of the many audio libraries & resources that inspire p5.sound:

\n\n","class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":207,"description":"

Returns the Audio Context for this sketch. Useful for users\nwho would like to dig deeper into the Web Audio API\n.

","itemtype":"method","name":"getAudioContext","return":{"description":"AudioContext for this sketch","type":"Object"},"class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":221,"description":"

Determine which filetypes are supported (inspired by buzz.js)\nThe audio element (el) will only be used to test browser support for various audio formats

\n","class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":288,"description":"

Master contains AudioContext and the master sound output.

\n","class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":323,"description":"

Returns a number representing the master amplitude (volume) for sound \nin this sketch.

\n","itemtype":"method","name":"getMasterVolume","return":{"description":"Master amplitude (volume) for sound in this sketch.\n Should be between 0.0 (silence) and 1.0.","type":"Number"},"class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":334,"description":"

Scale the output of all sound in this sketch

\nScaled between 0.0 (silence) and 1.0 (full volume).\n1.0 is the maximum amplitude of a digital sound, so multiplying\nby greater than 1.0 may cause digital distortion. To\nfade, provide a rampTime parameter. For more\ncomplex fades, see the Env class.\n\nAlternately, you can pass in a signal source such as an\noscillator to modulate the amplitude with an audio signal.\n\n

How This Works: When you load the p5.sound module, it\ncreates a single instance of p5sound. All sound objects in this\nmodule output to p5sound before reaching your computer's output.\nSo if you change the amplitude of p5sound, it impacts all of the\nsound in this module.

\n\n

If no value is provided, returns a Web Audio API Gain Node

","itemtype":"method","name":"masterVolume","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.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":376,"description":"

p5.soundOut is the p5.sound master output. It sends output to\nthe destination of this window's web audio context. It contains \nWeb Audio API nodes including a dyanmicsCompressor (.limiter),\nand Gain Nodes for .input and .output.

\n","itemtype":"property","name":"p5.soundOut","type":"{Object}","class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":386,"description":"

a silent connection to the DesinationNode\nwhich will ensure that anything connected to it\nwill not be garbage collected

\n","access":"private","tagname":"","class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":402,"description":"

Returns a number representing the sample rate, in samples per second,\nof all sound objects in this audio context. It is determined by the\nsampling rate of your operating system's sound card, and it is not\ncurrently possile to change.\nIt is often 44100, or twice the range of human hearing.

\n","itemtype":"method","name":"sampleRate","return":{"description":"samplerate samples per second","type":"Number"},"class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":415,"description":"

Returns the closest MIDI note value for\na given frequency.

\n","params":[{"name":"frequency","description":"

A freqeuncy, for example, the "A"\n above Middle C is 440Hz

\n","type":"Number"}],"return":{"description":"MIDI note value","type":"Number"},"class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":428,"description":"

Returns the frequency value of a MIDI note value.\nGeneral MIDI treats notes as integers where middle C\nis 60, C# is 61, D is 62 etc. Useful for generating\nmusical frequencies with oscillators.

\n","itemtype":"method","name":"midiToFreq","params":[{"name":"midiNote","description":"

The number of a MIDI note

\n","type":"Number"}],"return":{"description":"Frequency value of the given MIDI note","type":"Number"},"example":["\n
\nvar notes = [60, 64, 67, 72];\nvar i = 0;\n\nfunction setup() {\n osc = new p5.Oscillator('Triangle');\n osc.start();\n frameRate(1);\n}\n\nfunction draw() {\n var freq = midiToFreq(notes[i]);\n osc.freq(freq);\n i++;\n if (i >= notes.length){\n i = 0;\n }\n}\n
"],"class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":461,"description":"

List the SoundFile formats that you will include. LoadSound \nwill search your directory for these extensions, and will pick\na format that is compatable with the client's web browser.\nHere is a free online file\nconverter.

\n","itemtype":"method","name":"soundFormats","params":[{"name":"formats","description":"

i.e. 'mp3', 'wav', 'ogg'

\n","type":"String|Strings"}],"example":["\n
\nfunction preload() {\n // set the global sound formats\n soundFormats('mp3', 'ogg');\n \n // load either beatbox.mp3, or .ogg, depending on browser\n mySound = loadSound('../sounds/beatbox.mp3');\n}\n\nfunction setup() {\n mySound.play();\n}\n
"],"class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":575,"description":"

Used by Osc and Env to chain signal math

\n","class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":599,"description":"

Helper function to generate an error\nwith a custom stack trace that points to the sketch\nand removes other parts of the stack trace.

\n","access":"private","tagname":"","itemtype":"property","name":"{String} failedPath path to the file that failed to load","type":"String","return":{"description":"returns a custom Error object","type":"Error"},"class":"p5.sound","module":"p5.sound","submodule":"p5.sound","subprops":[{"name":"name","description":"custom error name","type":"String"},{"name":"errorTrace","description":"custom error trace","type":"String"},{"name":"failedPath","description":"path to the file that failed to load","type":"String"}]},{"file":"lib/addons/p5.sound.js","line":851,"description":"

loadSound() returns a new p5.SoundFile from a specified\npath. If called during preload(), the p5.SoundFile will be ready\nto play in time for setup() and draw(). If called outside of\npreload, the p5.SoundFile will not be ready immediately, so\nloadSound accepts a callback as the second parameter. Using a\n\nlocal server is recommended when loading external files.

\n","itemtype":"method","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}],"return":{"description":"Returns a p5.SoundFile","type":"SoundFile"},"example":[" \n
\nfunction preload() {\n mySound = loadSound('assets/doorbell.mp3');\n}\n\nfunction setup() {\n mySound.setVolume(0.1);\n mySound.play();\n}\n
"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":893,"description":"

This is a helper function that the p5.SoundFile calls to load\nitself. Accepts a callback (the name of another function)\nas an optional parameter.

\n","access":"private","tagname":"","params":[{"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 an error

\n","type":"Function","optional":true}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":986,"description":"

Returns true if the sound file finished loading successfully.

\n","itemtype":"method","name":"isLoaded","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":999,"description":"

Play the p5.SoundFile

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1111,"description":"

p5.SoundFile has two play modes: restart and\nsustain. Play Mode determines what happens to a\np5.SoundFile if it is triggered while in the middle of playback.\nIn sustain mode, playback will continue simultaneous to the\nnew playback. In restart mode, play() will stop playback\nand start over. Sustain is the default mode.

\n","itemtype":"method","name":"playMode","params":[{"name":"str","description":"

'restart' or 'sustain'

\n","type":"String"}],"example":["\n
\nfunction setup(){\n mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n}\nfunction mouseClicked() {\n mySound.playMode('sustain');\n mySound.play();\n}\nfunction keyPressed() {\n mySound.playMode('restart');\n mySound.play();\n}\n \n
"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1153,"description":"

Pauses a file that is currently playing. If the file is not\nplaying, then nothing will happen.

\n

After pausing, .play() will resume from the paused\nposition.\nIf p5.SoundFile had been set to loop before it was paused,\nit will continue to loop after it is unpaused with .play().

\n","itemtype":"method","name":"pause","params":[{"name":"startTime","description":"

(optional) schedule event to occur\n seconds from now

\n","type":"Number","optional":true}],"example":["\n
\nvar soundFile;\n\nfunction preload() {\n soundFormats('ogg', 'mp3');\n soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n}\nfunction setup() {\n background(0, 255, 0);\n soundFile.setVolume(0.1);\n soundFile.loop();\n}\nfunction keyTyped() {\n if (key == 'p') {\n soundFile.pause();\n background(255, 0, 0);\n }\n}\n\nfunction keyReleased() {\n if (key == 'p') {\n soundFile.play();\n background(0, 255, 0);\n }\n\n
"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1208,"description":"

Loop the p5.SoundFile. Accepts optional parameters to set the\nplayback rate, playback volume, loopStart, loopEnd.

\n","itemtype":"method","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":"

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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1224,"description":"

Set a p5.SoundFile's looping flag to true or false. If the sound\nis currently playing, this change will take effect when it\nreaches the end of the current playback.

\n","params":[{"name":"Boolean","description":"

set looping to true or false

\n","type":"Boolean"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1244,"description":"

Returns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.

\n","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1258,"description":"

Returns true if a p5.SoundFile is playing, false if not (i.e.\npaused or stopped).

\n","itemtype":"method","name":"isPlaying","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1268,"description":"

Returns true if a p5.SoundFile is paused, false if not (i.e.\nplaying or stopped).

\n","itemtype":"method","name":"isPaused","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1278,"description":"

Stop soundfile playback.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1302,"description":"

Stop playback on all of this soundfile's sources.

\n","access":"private","tagname":"","class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1324,"description":"

Multiply the output volume (amplitude) of a sound file\nbetween 0.0 (silence) and 1.0 (full volume).\n1.0 is the maximum amplitude of a digital sound, so multiplying\nby greater than 1.0 may cause digital distortion. To\nfade, provide a rampTime parameter. For more\ncomplex fades, see the Env class.

\n

Alternately, you can pass in a signal source such as an\noscillator to modulate the amplitude with an audio signal.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1365,"description":"

Set the stereo panning of a p5.sound object to\na floating point number between -1.0 (left) and 1.0 (right).\nDefault is 0.0 (center).

\n","itemtype":"method","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"}],"example":["\n
\n\n var ball = {};\n var soundFile;\n\n function setup() {\n soundFormats('ogg', 'mp3');\n soundFile = loadSound('assets/beatbox.mp3');\n }\n \n function draw() {\n background(0);\n ball.x = constrain(mouseX, 0, width);\n ellipse(ball.x, height/2, 20, 20)\n }\n \n function mousePressed(){\n // map the ball's x location to a panning degree \n // between -1.0 (left) and 1.0 (right)\n var panning = map(ball.x, 0., width,-1.0, 1.0);\n soundFile.pan(panning);\n soundFile.play();\n }\n
"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1404,"description":"

Returns the current stereo pan position (-1.0 to 1.0)

\n","return":{"description":"Returns the stereo pan setting of the Oscillator\n as a number between -1.0 (left) and 1.0 (right).\n 0.0 is center and default.","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1414,"description":"

Set the playback rate of a sound file. Will change the speed and the pitch.\nValues less than zero will reverse the audio buffer.

\n","itemtype":"method","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 Must be greater than zero.

\n","type":"Number","optional":true}],"example":["\n
\nvar song;\n\nfunction preload() {\n song = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n song.loop();\n}\n\nfunction draw() {\n background(200);\n \n // Set the rate to a range between 0.1 and 4\n // Changing the rate also alters the pitch\n var speed = map(mouseY, 0.1, height, 0, 2);\n speed = constrain(speed, 0.01, 4);\n song.rate(speed);\n \n // Draw a circle to show what is going on\n stroke(0);\n fill(51, 100);\n ellipse(mouseX, 100, 48, 48);\n}\n\n \n
\n"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1491,"description":"

Returns the duration of a sound file in seconds.

\n","itemtype":"method","name":"duration","return":{"description":"The duration of the soundFile in seconds.","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1505,"description":"

Return the current position of the p5.SoundFile playhead, in seconds.\nNote that if you change the playbackRate while the p5.SoundFile is\nplaying, the results may not be accurate.

\n","itemtype":"method","name":"currentTime","return":{"description":"currentTime of the soundFile in seconds.","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1521,"description":"

Move the playhead of the song to a position, in seconds. Start\nand Stop time. If none are given, will reset the file to play\nentire duration from start to finish.

\n","itemtype":"method","name":"jump","params":[{"name":"cueTime","description":"

cueTime of the soundFile in seconds.

\n","type":"Number"},{"name":"uuration","description":"

duration in seconds.

\n","type":"Number"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1544,"description":"

Return the number of channels in a sound file.\nFor example, Mono = 1, Stereo = 2.

\n","itemtype":"method","name":"channels","return":{"description":"[channels]","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1554,"description":"

Return the sample rate of the sound file.

\n","itemtype":"method","name":"sampleRate","return":{"description":"[sampleRate]","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1563,"description":"

Return the number of samples in a sound file.\nEqual to sampleRate * duration.

\n","itemtype":"method","name":"frames","return":{"description":"[sampleCount]","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1573,"description":"

Returns an array of amplitude peaks in a p5.SoundFile that can be\nused to draw a static waveform. Scans through the p5.SoundFile's\naudio buffer to find the greatest amplitudes. Accepts one\nparameter, 'length', which determines size of the array.\nLarger arrays result in more precise waveform visualizations.

\n

Inspired by Wavesurfer.js.

\n","itemtype":"method","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}],"return":{"description":"Array of peaks.","type":"Float32Array"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1625,"description":"

Reverses the p5.SoundFile's buffer source.\nPlayback must be handled separately (see example).

\n","itemtype":"method","name":"reverseBuffer","example":["\n
\nvar drum;\n\nfunction preload() {\n drum = loadSound('assets/drum.mp3');\n}\n\nfunction setup() {\n drum.reverseBuffer();\n drum.play();\n}\n\n \n
"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1662,"description":"

Schedule an event to be called when the soundfile\nreaches the end of a buffer. If the soundfile is\nplaying through once, this will be called when it\nends. If it is looping, it will be called when\nstop is called.

\n","itemtype":"method","name":"onended","params":[{"name":"callback","description":"

function to call when the\n soundfile has ended.

\n","type":"Function"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1714,"description":"

Connects the output of a p5sound object to input of another\np5.sound object. For example, you may connect a p5.SoundFile to an\nFFT or an Effect. If no parameter is given, it will connect to\nthe master output. Most p5sound objects connect to the master\noutput when they are created.

\n","itemtype":"method","name":"connect","params":[{"name":"object","description":"

Audio object that accepts an input

\n","type":"Object","optional":true}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1735,"description":"

Disconnects the output of this p5sound object.

\n","itemtype":"method","name":"disconnect","class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1743,"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1748,"description":"

Reset the source for this SoundFile to a\nnew path (URL).

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1761,"description":"

Replace the current Audio Buffer with a new Buffer.

\n","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":1834,"description":"

processPeaks returns an array of timestamps where it thinks there is a beat.

\n

This is an asynchronous function that processes the soundfile in an offline audio context,\nand sends the results to your callback function.

\n

The process involves running the soundfile through a lowpass filter, and finding all of the\npeaks above the initial threshold. If the total number of peaks are below the minimum number of peaks,\nit decreases the threshold and re-runs the analysis until either minPeaks or minThreshold are reached.

\n","itemtype":"method","name":"processPeaks","params":[{"name":"callback","description":"

a function to call once this data is returned

\n","type":"Function"},{"name":"initThreshold","description":"

initial threshold defaults to 0.9

\n","type":"Number","optional":true},{"name":"minThreshold","description":"

minimum threshold defaults to 0.22

\n","type":"Number","optional":true},{"name":"minPeaks","description":"

minimum number of peaks defaults to 200

\n","type":"Number","optional":true}],"return":{"description":"Array of timestamped peaks","type":"Array"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2027,"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2028,"description":"

Schedule events to trigger every time a MediaElement\n(audio/video) reaches a playback cue point.

\n

Accepts a callback function, a time (in seconds) at which to trigger\nthe callback, and an optional parameter for the callback.

\n

Time will be passed as the first parameter to the callback function,\nand param will be the second parameter.

\n","itemtype":"method","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}],"return":{"description":"id ID of this cue,\n useful for removeCue(id)","type":"Number"},"example":["\n
\nfunction setup() {\n background(0);\n noStroke();\n fill(255);\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n \n mySound = loadSound('assets/beat.mp3');\n\n // schedule calls to changeText\n mySound.addCue(0.50, changeText, \"hello\" );\n mySound.addCue(1.00, changeText, \"p5\" );\n mySound.addCue(1.50, changeText, \"what\" );\n mySound.addCue(2.00, changeText, \"do\" );\n mySound.addCue(2.50, changeText, \"you\" );\n mySound.addCue(3.00, changeText, \"want\" );\n mySound.addCue(4.00, changeText, \"to\" );\n mySound.addCue(5.00, changeText, \"make\" );\n mySound.addCue(6.00, changeText, \"?\" );\n}\n\nfunction changeText(val) {\n background(0);\n text(val, width/2, height/2);\n}\n\nfunction mouseClicked() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n if (mySound.isPlaying() ) {\n mySound.stop();\n } else {\n mySound.play();\n }\n }\n}\n
"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2103,"description":"

Remove a callback based on its ID. The ID is returned by the\naddCue method.

\n","itemtype":"method","name":"removeCue","params":[{"name":"id","description":"

ID of the cue, as returned by addCue

\n","type":"Number"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2121,"description":"

Remove all of the callbacks that had originally been scheduled\nvia the addCue method.

\n","itemtype":"method","name":"clearCues","class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2238,"description":"

Connects to the p5sound instance (master output) by default.\nOptionally, you can pass in a specific source (i.e. a soundfile).

\n","itemtype":"method","name":"setInput","params":[{"name":"snd","description":"

set the sound source\n (optional, defaults to\n master 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}],"example":["\n
\nfunction preload(){\n sound1 = loadSound('assets/beat.mp3');\n sound2 = loadSound('assets/drum.mp3');\n}\nfunction setup(){\n amplitude = new p5.Amplitude();\n sound1.play();\n sound2.play();\n amplitude.setInput(sound2);\n}\nfunction draw() {\n background(0);\n fill(255);\n var level = amplitude.getLevel();\n var size = map(level, 0, 1, 0, 200);\n ellipse(width/2, height/2, size, size);\n}\nfunction mouseClicked(){\n sound1.stop();\n sound2.stop();\n}\n
"],"class":"p5.Amplitude","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2343,"description":"

Returns a single Amplitude reading at the moment it is called.\nFor continuous readings, run in the draw loop.

\n","itemtype":"method","name":"getLevel","params":[{"name":"channel","description":"

Optionally return only channel 0 (left) or 1 (right)

\n","type":"Number","optional":true}],"return":{"description":"Amplitude as a number between 0.0 and 1.0","type":"Number"},"example":["\n
\nfunction preload(){\n sound = loadSound('assets/beat.mp3');\n}\nfunction setup() { \n amplitude = new p5.Amplitude();\n sound.play();\n}\nfunction draw() {\n background(0);\n fill(255);\n var level = amplitude.getLevel();\n var size = map(level, 0, 1, 0, 200);\n ellipse(width/2, height/2, size, size);\n}\nfunction mouseClicked(){\n sound.stop();\n}\n
"],"class":"p5.Amplitude","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2384,"description":"

Determines whether the results of Amplitude.process() will be\nNormalized. To normalize, Amplitude finds the difference the\nloudest reading it has processed and the maximum amplitude of\n1.0. Amplitude adds this difference to all values to produce\nresults that will reliably map between 0.0 and 1.0. However,\nif a louder moment occurs, the amount that Normalize adds to\nall the values will change. Accepts an optional boolean parameter\n(true or false). Normalizing is off by default.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2404,"description":"

Smooth Amplitude analysis by averaging with the last analysis \nframe. Off by default.

\n","itemtype":"method","name":"smooth","params":[{"name":"set","description":"

smoothing from 0.0 <= 1

\n","type":"Number"}],"class":"p5.Amplitude","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2554,"description":"

Set the input source for the FFT analysis. If no source is\nprovided, FFT will analyze all sound in the sketch.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2573,"description":"

Returns an array of amplitude values (between -1.0 and +1.0) that represent\na snapshot of amplitude readings in a single buffer. Length will be\nequal to bins (defaults to 1024). Can be used to draw the waveform\nof a sound.

\n","itemtype":"method","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}],"return":{"description":"Array Array of amplitude values (-1 to 1)\n over time. Array length = bins.","type":"Array"},"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2616,"description":"

Returns an array of amplitude values (between 0 and 255)\nacross the frequency spectrum. Length is equal to FFT bins\n(1024 by default). The array indices correspond to frequencies\n(i.e. pitches), from the lowest to the highest that humans can\nhear. Each value represents amplitude at that slice of the\nfrequency spectrum. Must be called prior to using\ngetEnergy().

\n","itemtype":"method","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}],"return":{"description":"spectrum Array of energy (amplitude/volume)\n values across the frequency spectrum.\n Lowest energy (silence) = 0, highest\n possible is 255.","type":"Array"},"example":["\n
\nvar osc;\nvar fft;\n\nfunction setup(){\n createCanvas(100,100);\n osc = new p5.Oscillator();\n osc.amp(0);\n osc.start();\n fft = new p5.FFT();\n}\n\nfunction draw(){\n background(0);\n\n var freq = map(mouseX, 0, 800, 20, 15000);\n freq = constrain(freq, 1, 20000);\n osc.freq(freq);\n\n var spectrum = fft.analyze(); \n noStroke();\n fill(0,255,0); // spectrum is green\n for (var i = 0; i< spectrum.length; i++){\n var x = map(i, 0, spectrum.length, 0, width);\n var h = -height + map(spectrum[i], 0, 255, height, 0);\n rect(x, height, width / spectrum.length, h );\n }\n\n stroke(255);\n text('Freq: ' + round(freq)+'Hz', 10, 10); \n\n isMouseOverCanvas();\n}\n\n// only play sound when mouse is over canvas\nfunction isMouseOverCanvas() {\n var mX = mouseX, mY = mouseY;\n if (mX > 0 && mX < width && mY < height && mY > 0) {\n osc.amp(0.5, 0.2);\n } else {\n osc.amp(0, 0.2);\n }\n}\n
\n \n"],"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2708,"description":"

Returns the amount of energy (volume) at a specific\n\nfrequency, or the average amount of energy between two\nfrequencies. Accepts Number(s) corresponding\nto frequency (in Hz), or a String corresponding to predefined\nfrequency ranges ("bass", "lowMid", "mid", "highMid", "treble").\nReturns a range between 0 (no energy/volume at that frequency) and\n255 (maximum energy). \nNOTE: analyze() must be called prior to getEnergy(). Analyze()\ntells the FFT to analyze frequency data, and getEnergy() uses\nthe results determine the value at a specific frequency or\nrange of frequencies.

\n","itemtype":"method","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}],"return":{"description":"Energy Energy (volume/amplitude) from\n 0 and 255.","type":"Number"},"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2788,"description":"

Returns the \n\nspectral centroid of the input signal.\nNOTE: analyze() must be called prior to getCentroid(). Analyze()\ntells the FFT to analyze frequency data, and getCentroid() uses\nthe results determine the spectral centroid.

\n","itemtype":"method","name":"getCentroid","return":{"description":"Spectral Centroid Frequency Frequency of the spectral centroid in Hz.","type":"Number"},"example":["\n
\n\n\nfunction setup(){\ncnv = createCanvas(800,400);\nsound = new p5.AudioIn();\nsound.start();\nfft = new p5.FFT();\nsound.connect(fft);\n}\n\n\nfunction draw(){\n\nvar centroidplot = 0.0;\nvar spectralCentroid = 0;\n\n\nbackground(0);\nstroke(0,255,0);\nvar spectrum = fft.analyze(); \nfill(0,255,0); // spectrum is green\n\n//draw the spectrum\n\nfor (var i = 0; i< spectrum.length; i++){\n var x = map(log(i), 0, log(spectrum.length), 0, width);\n var h = map(spectrum[i], 0, 255, 0, height);\n var rectangle_width = (log(i+1)-log(i))*(width/log(spectrum.length));\n rect(x, height, rectangle_width, -h )\n}\n\nvar nyquist = 22050;\n\n// get the centroid\nspectralCentroid = fft.getCentroid();\n\n// the mean_freq_index calculation is for the display.\nvar mean_freq_index = spectralCentroid/(nyquist/spectrum.length);\n\ncentroidplot = map(log(mean_freq_index), 0, log(spectrum.length), 0, width);\n\n\nstroke(255,0,0); // the line showing where the centroid is will be red\n\nrect(centroidplot, 0, width / spectrum.length, height)\nnoStroke();\nfill(255,255,255); // text is white\ntextSize(40);\ntext(\"centroid: \"+round(spectralCentroid)+\" Hz\", 10, 40);\n}\n
"],"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2869,"description":"

Smooth FFT analysis by averaging with the last analysis frame.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":2911,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":3314,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":3335,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":3394,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":3847,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":3984,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4017,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4063,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4084,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4104,"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4206,"description":"

Fade to value, for smooth transitions

\n","itemtype":"method","name":"fade","params":[{"name":"value","description":"

Value to set this signal

\n","type":"Number"},{"name":"secondsFromNow","description":"

Length of fade, in seconds from now

\n","type":"[Number]"}],"class":"p5.Signal","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4217,"description":"

Connect a p5.sound object or Web Audio node to this\np5.Signal so that its amplitude values can be scaled.

\n","params":[{"name":"input","description":"","type":"Object"}],"class":"p5.Signal","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4230,"description":"

Add a constant value to this audio signal,\nand return the resulting audio signal. Does\nnot change the value of the original signal,\ninstead it returns a new p5.SignalAdd.

\n","itemtype":"method","name":"add","params":[{"name":"number","description":"","type":"Number"}],"return":{"description":"object","type":"p5.SignalAdd"},"class":"p5.Signal","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4249,"description":"

Multiply this signal by a constant value,\nand return the resulting audio signal. Does\nnot change the value of the original signal,\ninstead it returns a new p5.SignalMult.

\n","itemtype":"method","name":"mult","params":[{"name":"number","description":"

to multiply

\n","type":"Number"}],"return":{"description":"object","type":"Tone.Multiply"},"class":"p5.Signal","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4268,"description":"

Scale this signal value to a given range,\nand return the result as an audio signal. Does\nnot change the value of the original signal,\ninstead it returns a new p5.SignalScale.

\n","itemtype":"method","name":"scale","params":[{"name":"number","description":"

to multiply

\n","type":"Number"},{"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"}],"return":{"description":"object","type":"p5.SignalScale"},"class":"p5.Signal","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4407,"description":"

Start an oscillator. Accepts an optional parameter to\ndetermine how long (in seconds from now) until the\noscillator starts.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4442,"description":"

Stop an oscillator. Accepts an optional parameter\nto determine how long (in seconds from now) until the\noscillator stops.

\n","itemtype":"method","name":"stop","params":[{"name":"secondsFromNow","description":"

Time, in seconds from now.

\n","type":"Number"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4458,"description":"

Set the amplitude between 0 and 1.0. Or, pass in an object\nsuch as an oscillator to modulate amplitude with an audio signal.

\n","itemtype":"method","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}],"return":{"description":"gain If no value is provided,\n returns the Web Audio API\n AudioParam that controls\n this oscillator's\n gain/amplitude/volume)","type":"AudioParam"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4496,"description":"

Set frequency of an oscillator to a value. Or, pass in an object\nsuch as an oscillator to modulate the frequency with an audio signal.

\n","itemtype":"method","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}],"return":{"description":"Frequency If no value is provided,\n returns the Web Audio API\n AudioParam that controls\n this oscillator's frequency","type":"AudioParam"},"example":["\n
\nvar osc = new p5.Oscillator(300);\nosc.start();\nosc.freq(40, 10);\n
"],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4555,"description":"

Set type to 'sine', 'triangle', 'sawtooth' or 'square'.

\n","itemtype":"method","name":"setType","params":[{"name":"type","description":"

'sine', 'triangle', 'sawtooth' or 'square'.

\n","type":"String"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4567,"description":"

Connect to a p5.sound / Web Audio object.

\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"

A p5.sound or Web Audio object

\n","type":"Object"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4584,"description":"

Disconnect all outputs

\n","itemtype":"method","name":"disconnect","class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4595,"description":"

Pan between Left (-1) and Right (1)

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4628,"description":"

Set the phase of an oscillator between 0.0 and 1.0.\nIn this implementation, phase is a delay time\nbased on the oscillator's current frequency.

\n","itemtype":"method","name":"phase","params":[{"name":"phase","description":"

float between 0.0 and 1.0

\n","type":"Number"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4682,"description":"

Add a value to the p5.Oscillator's output amplitude,\nand return the oscillator. Calling this method again\nwill override the initial add() with a new value.

\n","itemtype":"method","name":"add","params":[{"name":"number","description":"

Constant number to add

\n","type":"Number"}],"return":{"description":"Oscillator Returns this oscillator\n with scaled output","type":"p5.Oscillator"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4699,"description":"

Multiply the p5.Oscillator's output amplitude\nby a fixed value (i.e. turn it up!). Calling this method\nagain will override the initial mult() with a new value.

\n","itemtype":"method","name":"mult","params":[{"name":"number","description":"

Constant number to multiply

\n","type":"Number"}],"return":{"description":"Oscillator Returns this oscillator\n with multiplied output","type":"p5.Oscillator"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4715,"description":"

Scale this oscillator's amplitude values to a given\nrange, and return the oscillator. Calling this method\nagain will override the initial scale() with new values.

\n","itemtype":"method","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"}],"return":{"description":"Oscillator Returns this oscillator\n with scaled output","type":"p5.Oscillator"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4745,"description":"

Constructor: new p5.SinOsc().\nThis creates a Sine Wave Oscillator and is\nequivalent to new p5.Oscillator('sine')\n or creating a p5.Oscillator and then calling\nits method setType('sine').\nSee p5.Oscillator for methods.

\n","itemtype":"method","name":"p5.SinOsc","params":[{"name":"freq","description":"

Set the frequency

\n","type":"[Number]"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4760,"description":"

Constructor: new p5.TriOsc().\nThis creates a Triangle Wave Oscillator and is\nequivalent to new p5.Oscillator('triangle')\n or creating a p5.Oscillator and then calling\nits method setType('triangle').\nSee p5.Oscillator for methods.

\n","itemtype":"method","name":"p5.TriOsc","params":[{"name":"freq","description":"

Set the frequency

\n","type":"[Number]"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4775,"description":"

Constructor: new p5.SawOsc().\nThis creates a SawTooth Wave Oscillator and is\nequivalent to new p5.Oscillator('sawtooth')\n or creating a p5.Oscillator and then calling\nits method setType('sawtooth').\nSee p5.Oscillator for methods.

\n","itemtype":"method","name":"p5.SawOsc","params":[{"name":"freq","description":"

Set the frequency

\n","type":"[Number]"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4790,"description":"

Constructor: new p5.SqrOsc().\nThis creates a Square Wave Oscillator and is\nequivalent to new p5.Oscillator('square')\n or creating a p5.Oscillator and then calling\nits method setType('square').\nSee p5.Oscillator for methods.

\n","itemtype":"method","name":"p5.SqrOsc","params":[{"name":"freq","description":"

Set the frequency

\n","type":"[Number]"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4806,"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":4992,"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5217,"description":"

Time until envelope reaches attackLevel

\n","itemtype":"property","name":"attackTime","class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5222,"description":"

Level once attack is complete.

\n","itemtype":"property","name":"attackLevel","class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5227,"description":"

Time until envelope reaches decayLevel.

\n","itemtype":"property","name":"decayTime","class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5232,"description":"

Level after decay. The envelope will sustain here until it is released.

\n","itemtype":"property","name":"decayLevel","class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5237,"description":"

Duration of the release portion of the envelope.

\n","itemtype":"property","name":"releaseTime","class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5242,"description":"

Level at the end of the release.

\n","itemtype":"property","name":"releaseLevel","class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5278,"description":"

Reset the envelope with a series of time/value pairs.

\n","itemtype":"method","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.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5302,"description":"

Set values like a traditional\n\nADSR envelope\n.

\n","itemtype":"method","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.

\n","type":"Number","optional":true},{"name":"releaseTime","description":"

Time in seconds from now (defaults to 0)

\n","type":"Number","optional":true}],"example":["\n
\nvar attackLevel = 1.0;\nvar releaseLevel = 0;\n\nvar attackTime = 0.001\nvar decayTime = 0.2;\nvar susPercent = 0.2;\nvar releaseTime = 0.5;\n\nvar env, triOsc;\n\nfunction setup() {\n var cnv = createCanvas(100, 100);\n\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n\n env = new p5.Env();\n env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n env.setRange(attackLevel, releaseLevel);\n\n triOsc = new p5.Oscillator('triangle');\n triOsc.amp(env);\n triOsc.start();\n triOsc.freq(220);\n\n cnv.mousePressed(playEnv);\n}\n\nfunction playEnv(){\n env.play();\n}\n
"],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5367,"description":"

Set max (attackLevel) and min (releaseLevel) of envelope.

\n","itemtype":"method","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"}],"example":["\n
\nvar attackLevel = 1.0;\nvar releaseLevel = 0;\n\nvar attackTime = 0.001\nvar decayTime = 0.2;\nvar susPercent = 0.2;\nvar releaseTime = 0.5;\n\nvar env, triOsc;\n\nfunction setup() {\n var cnv = createCanvas(100, 100);\n\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n\n env = new p5.Env();\n env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n env.setRange(attackLevel, releaseLevel);\n\n triOsc = new p5.Oscillator('triangle');\n triOsc.amp(env);\n triOsc.start();\n triOsc.freq(220);\n\n cnv.mousePressed(playEnv);\n}\n\nfunction playEnv(){\n env.play();\n}\n
"],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5446,"description":"

Assign a parameter to be controlled by this envelope.\nIf a p5.Sound object is given, then the p5.Env will control its\noutput gain. If multiple inputs are provided, the env will\ncontrol all of them.

\n","itemtype":"method","name":"setInput","params":[{"name":"unit","description":"

A p5.sound object or\n Web Audio Param.

\n","type":"Object"}],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5461,"description":"

Set whether the envelope ramp is linear (default) or exponential.\nExponential ramps can be useful because we perceive amplitude\nand frequency logarithmically.

\n","itemtype":"method","name":"setExp","params":[{"name":"isExp","description":"

true is exponential, false is linear

\n","type":"Boolean"}],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5479,"description":"

Play tells the envelope to start acting on a given input.\nIf the input is a p5.sound object (i.e. AudioIn, Oscillator,\nSoundFile), then Env will control its output volume.\nEnvelopes can also be used to control any \nWeb Audio Audio Param.

\n","itemtype":"method","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}],"example":["\n
\nvar attackLevel = 1.0;\nvar releaseLevel = 0;\n\nvar attackTime = 0.001\nvar decayTime = 0.2;\nvar susPercent = 0.2;\nvar releaseTime = 0.5;\n\nvar env, triOsc;\n\nfunction setup() {\n var cnv = createCanvas(100, 100);\n\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n\n env = new p5.Env();\n env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n env.setRange(attackLevel, releaseLevel);\n\n triOsc = new p5.Oscillator('triangle');\n triOsc.amp(env);\n triOsc.start();\n triOsc.freq(220);\n\n cnv.mousePressed(playEnv);\n}\n\nfunction playEnv(){\n // trigger env on triOsc, 0 seconds from now\n // After decay, sustain for 0.2 seconds before release\n env.play(triOsc, 0, 0.2);\n}\n
"],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5541,"description":"

Trigger the Attack, and Decay portion of the Envelope.\nSimilar to holding down a key on a piano, but it will\nhold the sustain level until you let go. Input can be\nany p5.sound object, or a \nWeb Audio Param.

\n","itemtype":"method","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"}],"example":["\n
\n\nvar attackLevel = 1.0;\nvar releaseLevel = 0;\n\nvar attackTime = 0.001\nvar decayTime = 0.3;\nvar susPercent = 0.4;\nvar releaseTime = 0.5;\n\nvar env, triOsc;\n\nfunction setup() {\n var cnv = createCanvas(100, 100);\n background(200);\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n\n env = new p5.Env();\n env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n env.setRange(attackLevel, releaseLevel);\n\n triOsc = new p5.Oscillator('triangle');\n triOsc.amp(env);\n triOsc.start();\n triOsc.freq(220);\n\n cnv.mousePressed(envAttack);\n}\n\nfunction envAttack(){\n console.log('trigger attack');\n env.triggerAttack();\n\n background(0,255,0);\n text('attack!', width/2, height/2);\n}\n\nfunction mouseReleased() {\n env.triggerRelease();\n\n background(200);\n text('click to play', width/2, height/2);\n}\n
"],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5650,"description":"

Trigger the Release of the Envelope. This is similar to releasing\nthe key on a piano and letting the sound fade according to the\nrelease level and release time.

\n","itemtype":"method","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"}],"example":["\n
\n\nvar attackLevel = 1.0;\nvar releaseLevel = 0;\n\nvar attackTime = 0.001\nvar decayTime = 0.3;\nvar susPercent = 0.4;\nvar releaseTime = 0.5;\n\nvar env, triOsc;\n\nfunction setup() {\n var cnv = createCanvas(100, 100);\n background(200);\n textAlign(CENTER);\n text('click to play', width/2, height/2);\n\n env = new p5.Env();\n env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n env.setRange(attackLevel, releaseLevel);\n\n triOsc = new p5.Oscillator('triangle');\n triOsc.amp(env);\n triOsc.start();\n triOsc.freq(220);\n\n cnv.mousePressed(envAttack);\n}\n\nfunction envAttack(){\n console.log('trigger attack');\n env.triggerAttack();\n\n background(0,255,0);\n text('attack!', width/2, height/2);\n}\n\nfunction mouseReleased() {\n env.triggerRelease();\n\n background(200);\n text('click to play', width/2, height/2);\n}\n
"],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5749,"description":"

Exponentially ramp to a value using the first two\nvalues from setADSR(attackTime, decayTime)\nas \ntime constants for simple exponential ramps.\nIf the value is higher than current value, it uses attackTime,\nwhile a decrease uses decayTime.

\n","itemtype":"method","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 (optional)

\n","type":"Number","optional":true}],"example":["\n
\nvar env, osc, amp, cnv;\n\nvar attackTime = 0.001;\nvar decayTime = 0.2;\nvar attackLevel = 1;\nvar decayLevel = 0;\n\nfunction setup() {\n cnv = createCanvas(100, 100);\n fill(0,255,0);\n noStroke();\n\n env = new p5.Env();\n env.setADSR(attackTime, decayTime);\n\n osc = new p5.Oscillator();\n osc.amp(env);\n osc.start();\n\n amp = new p5.Amplitude();\n\n cnv.mousePressed(triggerRamp);\n}\n\nfunction triggerRamp() {\n env.ramp(osc, 0, attackLevel, decayLevel);\n}\n\nfunction draw() {\n background(20,20,20);\n text('click me', 10, 20);\n var h = map(amp.getLevel(), 0, 0.4, 0, height);;\n\n rect(0, height, width, -h);\n}\n
"],"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5854,"description":"

Add a value to the p5.Oscillator's output amplitude,\nand return the oscillator. Calling this method\nagain will override the initial add() with new values.

\n","itemtype":"method","name":"add","params":[{"name":"number","description":"

Constant number to add

\n","type":"Number"}],"return":{"description":"Envelope Returns this envelope\n with scaled output","type":"p5.Env"},"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5870,"description":"

Multiply the p5.Env's output amplitude\nby a fixed value. Calling this method\nagain will override the initial mult() with new values.

\n","itemtype":"method","name":"mult","params":[{"name":"number","description":"

Constant number to multiply

\n","type":"Number"}],"return":{"description":"Envelope Returns this envelope\n with scaled output","type":"p5.Env"},"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5886,"description":"

Scale this envelope's amplitude values to a given\nrange, and return the envelope. Calling this method\nagain will override the initial scale() with new values.

\n","itemtype":"method","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"}],"return":{"description":"Envelope Returns this envelope\n with scaled output","type":"p5.Env"},"class":"p5.Env","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":5989,"description":"

Set the width of a Pulse object (an oscillator that implements\nPulse Width Modulation).

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6166,"description":"

Set type of noise to 'white', 'pink' or 'brown'.\nWhite is the default.

\n","itemtype":"method","name":"setType","params":[{"name":"type","description":"

'white', 'pink' or 'brown'

\n","type":"String","optional":true}],"class":"p5.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6196,"description":"

Start the noise

\n","itemtype":"method","name":"start","class":"p5.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6213,"description":"

Stop the noise.

\n","itemtype":"method","name":"stop","class":"p5.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6225,"description":"

Pan the noise.

\n","itemtype":"method","name":"pan","params":[{"name":"panning","description":"

Number between -1 (left)\n and 1 (right)

\n","type":"Number"},{"name":"timeFromNow","description":"

schedule this event to happen\n seconds from now

\n","type":"Number"}],"class":"p5.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6234,"description":"

Set the amplitude of the noise between 0 and 1.0. Or,\nmodulate amplitude with an audio signal such as an oscillator.

\n","params":[{"name":"volume","description":"

amplitude between 0 and 1.0\n or 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.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6244,"description":"

Send output to a p5.sound or web audio object

\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6250,"description":"

Disconnect all output.

\n","itemtype":"method","name":"disconnect","class":"p5.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6319,"description":"

Client must allow browser to access their microphone / audioin source.\nDefault: false. Will become true when the client enables acces.

\n","itemtype":"property","name":"enabled","type":"Boolean","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6340,"description":"

Start processing audio input. This enables the use of other\nAudioIn methods like getLevel(). Note that by default, AudioIn\nis not connected to p5.sound's output. So you won't hear\nanything unless you use the connect() method.

\n","itemtype":"method","name":"start","params":[{"name":"successCallback","description":"

Name of a function to call on\n success.

\n","type":"Function"},{"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"}],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6399,"description":"

Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().

\n","itemtype":"method","name":"stop","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6409,"description":"

Connect to an audio unit. If no parameter is provided, will\nconnect to the master output (i.e. your speakers).

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6430,"description":"

Disconnect the AudioIn from all audio units. For example, if\nconnect() had been called, disconnect() will stop sending \nsignal to your speakers.

\n","itemtype":"method","name":"disconnect","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6442,"description":"

Read the Amplitude (volume level) of an AudioIn. The AudioIn\nclass contains its own instance of the Amplitude class to help\nmake it easy to get a microphone's volume level. Accepts an\noptional smoothing value (0.0 < 1.0). NOTE: AudioIn must\n.start() before using .getLevel().

\n","itemtype":"method","name":"getLevel","params":[{"name":"smoothing","description":"

Smoothing is 0.0 by default.\n Smooths values based on previous values.

\n","type":"Number","optional":true}],"return":{"description":"Volume level (between 0.0 and 1.0)","type":"Number"},"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6460,"description":"

Add input sources to the list of available sources.

\n","access":"private","tagname":"","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6475,"description":"

Set amplitude (volume) of a mic input between 0 and 1.0.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6503,"description":"

Chrome only. Returns a list of available input sources \nand allows the user to set the media source. Firefox allows \nthe user to choose from input sources in the permissions dialogue\ninstead of enumerating available sources and selecting one.\nNote: in order to have descriptive media names your page must be \nserved over a secure (HTTPS) connection and the page should \nrequest user media before enumerating devices. Otherwise device \nID will be a long device ID number and does not specify device \ntype. For example see \nhttps://simpl.info/getusermedia/sources/index.html vs.\nhttp://simpl.info/getusermedia/sources/index.html

\n","itemtype":"method","name":"getSources","params":[{"name":"callback","description":"

a callback to handle the sources \n when they have been enumerated

\n","type":"Function"}],"example":["\n
\n var audiograb;\n \n function setup(){\n //new audioIn\n audioGrab = new p5.AudioIn();\n \n audioGrab.getSources(function(sourceList) {\n //print out the array of available sources\n console.log(sourceList);\n //set the source to the first item in the inputSources array\n audioGrab.setSource(0);\n });\n }\n
"],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6552,"description":"

Set the input source. Accepts a number representing a\nposition in the array returned by listSources().\nThis is only available in browsers that support \nMediaStreamTrack.getSources(). Instead, some browsers\ngive users the option to set their own media source.

\n","itemtype":"method","name":"setSource","params":[{"name":"num","description":"

position of input source in the array

\n","type":"Number"}],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6667,"description":"

The p5.Filter is built with a\n\nWeb Audio BiquadFilter Node.

\n","itemtype":"property","name":"biquadFilter","type":"{Object} Web Audio Delay Node","class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6685,"description":"

Filter an audio signal according to a set\nof filter parameters.

\n","itemtype":"method","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]"},{"name":"res","description":"

Resonance/Width of the filter frequency\n from 0.001 to 1000

\n","type":"[Number]"}],"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6699,"description":"

Set the frequency and the resonance of the filter.

\n","itemtype":"method","name":"set","params":[{"name":"freq","description":"

Frequency in Hz, from 10 to 22050

\n","type":"Number"},{"name":"res","description":"

Resonance (Q) 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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6716,"description":"

Set the filter frequency, in Hz, from 10 to 22050 (the range of\nhuman hearing, although in reality most people hear in a narrower\nrange).

\n","itemtype":"method","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}],"return":{"description":"value Returns the current frequency value","type":"Number"},"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6742,"description":"

Controls either width of a bandpass frequency,\nor the resonance of a low/highpass cutoff frequency.

\n","itemtype":"method","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}],"return":{"description":"value Returns the current res value","type":"Number"},"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6765,"description":"

Set the type of a p5.Filter. Possible types include: \n"lowpass" (default), "highpass", "bandpass", \n"lowshelf", "highshelf", "peaking", "notch",\n"allpass".

\n","itemtype":"method","name":"setType","params":[{"name":"UNKNOWN","description":"","type":"String"}],"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6777,"description":"

Set the output level of the filter.

\n","itemtype":"method","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.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6795,"description":"

Send output to a p5.sound or web audio object

\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6805,"description":"

Disconnect all output.

\n","itemtype":"method","name":"disconnect","class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6824,"description":"

Constructor: new p5.LowPass() Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('lowpass').\nSee p5.Filter for methods.

\n","itemtype":"method","name":"p5.LowPass","class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6836,"description":"

Constructor: new p5.HighPass() Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('highpass').\nSee p5.Filter for methods.

\n","itemtype":"method","name":"p5.HighPass","class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6848,"description":"

Constructor: new p5.BandPass() Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('bandpass').\nSee p5.Filter for methods.

\n","itemtype":"method","name":"p5.BandPass","class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6922,"description":"

The p5.Delay is built with two\n\nWeb Audio Delay Nodes, one for each stereo channel.

\n","itemtype":"property","name":"leftDelay","type":"{Object} Web Audio Delay Node","class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6931,"description":"

The p5.Delay is built with two\n\nWeb Audio Delay Nodes, one for each stereo channel.

\n","itemtype":"property","name":"rightDelay","type":"{Object} Web Audio Delay Node","class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6964,"description":"

Add delay to an audio signal according to a set\nof delay parameters.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":6999,"description":"

Set the delay (echo) time, in seconds. Usually this value will be\na floating point number between 0.0 and 1.0.

\n","itemtype":"method","name":"delayTime","params":[{"name":"delayTime","description":"

Time (in seconds) of the delay

\n","type":"Number"}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7018,"description":"

Feedback occurs when Delay sends its signal back through its input\nin a loop. The feedback amount determines how much signal to send each\ntime through the loop. A feedback greater than 1.0 is not desirable because\nit will increase the overall output each time through the loop,\ncreating an infinite feedback loop.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7042,"description":"

Set a lowpass filter frequency for the delay. A lowpass filter\nwill cut off any frequencies higher than the filter frequency.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7059,"description":"

Choose a preset type of delay. 'pingPong' bounces the signal\nfrom the left to the right channel to produce a stereo effect.\nAny other parameter will revert to the default delay setting.

\n","itemtype":"method","name":"setType","params":[{"name":"type","description":"

'pingPong' (1) or 'default' (0)

\n","type":"String|Number"}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7091,"description":"

Set the output level of the delay effect.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7109,"description":"

Send output to a p5.sound or web audio object

\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7119,"description":"

Disconnect all output.

\n","itemtype":"method","name":"disconnect","class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7204,"description":"

Connect a source to the reverb, and assign reverb parameters.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7233,"description":"

Set the reverb settings. Similar to .process(), but without\nassigning a new input.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7260,"description":"

Set the output level of the delay effect.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7278,"description":"

Send output to a p5.sound or web audio object

\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7288,"description":"

Disconnect all output.

\n","itemtype":"method","name":"disconnect","class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7296,"description":"

Inspired by Simple Reverb by Jordan Santell\nhttps://github.com/web-audio-components/simple-reverb/blob/master/index.js

\n

Utility function for building an impulse response\nbased on the module parameters.

\n","access":"private","tagname":"","class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7394,"description":"

Internally, the p5.Convolver uses the a\n\nWeb Audio Convolver Node.

\n","itemtype":"property","name":"convolverNode","type":"{Object} Web Audio Convolver Node","class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7424,"description":"

Create a p5.Convolver. Accepts a path to a soundfile \nthat will be used to generate an impulse response.

\n","itemtype":"method","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}],"return":{"description":"","type":"p5.Convolver"},"example":["\n
\nvar cVerb, sound;\nfunction preload() {\n // We have both MP3 and OGG versions of all sound assets\n soundFormats('ogg', 'mp3');\n \n // Try replacing 'bx-spring' with other soundfiles like\n // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n cVerb = createConvolver('assets/bx-spring.mp3');\n\n // Try replacing 'Damscray_DancingTiger' with\n // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n sound = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n // disconnect from master output...\n sound.disconnect();\n \n // ...and process with cVerb\n // so that we only hear the convolution\n cVerb.process(sound);\n \n sound.play();\n}\n
"],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7474,"description":"

Private method to load a buffer as an Impulse Response,\nassign it to the convolverNode, and add to the Array of .impulses.

\n","params":[{"name":"path","description":"","type":"String"},{"name":"callback","description":"","type":"Function"},{"name":"errorCallback","description":"","type":"Function"}],"access":"private","tagname":"","class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7540,"description":"

Connect a source to the reverb, and assign reverb parameters.

\n","itemtype":"method","name":"process","params":[{"name":"src","description":"

p5.sound / Web Audio object with a sound\n output.

\n","type":"Object"}],"example":["\n
\nvar cVerb, sound;\nfunction preload() {\n soundFormats('ogg', 'mp3');\n \n cVerb = createConvolver('assets/concrete-tunnel.mp3');\n\n sound = loadSound('assets/beat.mp3');\n}\n\nfunction setup() {\n // disconnect from master output...\n sound.disconnect();\n \n // ...and process with (i.e. connect to) cVerb\n // so that we only hear the convolution\n cVerb.process(sound);\n \n sound.play();\n}\n
"],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7572,"description":"

If you load multiple impulse files using the .addImpulse method,\nthey will be stored as Objects in this Array. Toggle between them\nwith the toggleImpulse(id) method.

\n","itemtype":"property","name":"impulses","type":"{Array} Array of Web Audio Buffers","class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7581,"description":"

Load and assign a new Impulse Response to the p5.Convolver.\nThe impulse is added to the .impulses array. Previous\nimpulses can be accessed with the .toggleImpulse(id)\nmethod.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7599,"description":"

Similar to .addImpulse, except that the .impulses\nArray is reset to save memory. A new .impulses\narray is created with this impulse as the only item.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7617,"description":"

If you have used .addImpulse() to add multiple impulses\nto a p5.Convolver, then you can use this method to toggle between\nthe items in the .impulses Array. Accepts a parameter\nto identify which impulse you wish to use, identified either by its\noriginal filename (String) or by its position in the .impulses\n Array (Number).
\nYou can access the objects in the .impulses Array directly. Each\nObject has two attributes: an .audioBuffer (type:\nWeb Audio \nAudioBuffer) and a .name, a String that corresponds\nwith the original filename.

\n","itemtype":"method","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).

\n","type":"String|Number"}],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7666,"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7691,"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7910,"description":"

Set the global tempo, in beats per minute, for all\np5.Parts. This method will impact all active p5.Parts.

\n","params":[{"name":"BPM","description":"

Beats Per Minute

\n","type":"Number"},{"name":"rampTime","description":"

Seconds from now

\n","type":"Number"}],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":7997,"description":"

Array of values to pass into the callback\nat each step of the phrase. Depending on the callback\nfunction's requirements, these values may be numbers,\nstrings, or an object with multiple parameters.\nZero (0) indicates a rest.

\n","itemtype":"property","name":"sequence","type":"{Array}","class":"p5.Phrase","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8090,"description":"

Set the tempo of this part, in Beats Per Minute.

\n","itemtype":"method","name":"setBPM","params":[{"name":"BPM","description":"

Beats Per Minute

\n","type":"Number"},{"name":"rampTime","description":"

Seconds from now

\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8100,"description":"

Returns the Beats Per Minute of this currently part.

\n","itemtype":"method","name":"getBPM","return":{"description":"","type":"Number"},"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8109,"description":"

Start playback of this part. It will play\nthrough all of its phrases at a speed\ndetermined by setBPM.

\n","itemtype":"method","name":"start","params":[{"name":"time","description":"

seconds from now

\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8125,"description":"

Loop playback of this part. It will begin\nlooping through all of its phrases at a speed\ndetermined by setBPM.

\n","itemtype":"method","name":"loop","params":[{"name":"time","description":"

seconds from now

\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8142,"description":"

Tell the part to stop looping.

\n","itemtype":"method","name":"noLoop","class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8154,"description":"

Stop the part and cue it to step 0.

\n","itemtype":"method","name":"stop","params":[{"name":"time","description":"

seconds from now

\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8164,"description":"

Pause the part. Playback will resume\nfrom the current step.

\n","itemtype":"method","name":"pause","params":[{"name":"time","description":"

seconds from now

\n","type":"Number"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8176,"description":"

Add a p5.Phrase to this Part.

\n","itemtype":"method","name":"addPhrase","params":[{"name":"phrase","description":"

reference to a p5.Phrase

\n","type":"p5.Phrase"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8197,"description":"

Remove a phrase from this part, based on the name it was\ngiven when it was created.

\n","itemtype":"method","name":"removePhrase","params":[{"name":"phraseName","description":"","type":"String"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8211,"description":"

Get a phrase from this part, based on the name it was\ngiven when it was created. Now you can modify its array.

\n","itemtype":"method","name":"getPhrase","params":[{"name":"phraseName","description":"","type":"String"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8225,"description":"

Get a phrase from this part, based on the name it was\ngiven when it was created. Now you can modify its array.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8253,"description":"

Fire a callback function at every step.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8305,"description":"

Start playback of the score.

\n","itemtype":"method","name":"start","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8314,"description":"

Stop playback of the score.

\n","itemtype":"method","name":"stop","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8324,"description":"

Pause playback of the score.

\n","itemtype":"method","name":"pause","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8332,"description":"

Loop playback of the score.

\n","itemtype":"method","name":"loop","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8341,"description":"

Stop looping playback of the score. If it\nis currently playing, this will go into effect\nafter the current round of playback completes.

\n","itemtype":"method","name":"noLoop","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8363,"description":"

Set the tempo for all parts in the score

\n","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8469,"description":"

callback invoked when the recording is over

\n","access":"private","tagname":"","type":"{function(Float32Array)}","class":"p5.SoundRecorder","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8482,"description":"

Connect a specific device to the p5.SoundRecorder.\nIf no parameter is given, p5.SoundRecorer will record\nall audible p5.sound from your sketch.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8503,"description":"

Start recording. To access the recording, provide\na p5.SoundFile as the first parameter. The p5.SoundRecorder\nwill send its recording to that p5.SoundFile for playback once\nrecording is complete. Optional parameters include duration\n(in seconds) of the recording, and a callback function that\nwill be called once the complete recording has been\ntransfered to the p5.SoundFile.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8536,"description":"

Stop the recording. Once the recording is stopped,\nthe results will be sent to the p5.SoundFile that\nwas given on .record(), and if a callback function\nwas provided on record, that function will be called.

\n","itemtype":"method","name":"stop","class":"p5.SoundRecorder","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8555,"description":"

internal method called on audio process

\n","access":"private","tagname":"","params":[{"name":"event","description":"","type":"AudioProcessorEvent"}],"class":"p5.SoundRecorder","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8609,"description":"

Save a p5.SoundFile as a .wav audio file.

\n","itemtype":"method","name":"saveSound","params":[{"name":"soundFile","description":"

p5.SoundFile that you wish to save

\n","type":"p5.SoundFile"},{"name":"name","description":"

name of the resulting .wav file.

\n","type":"String"}],"class":"p5.SoundRecorder","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8781,"description":"

isDetected is set to true when a peak is detected.

\n","itemtype":"attribute","name":"isDetected","type":"{Boolean}","default":"false","class":"p5.PeakDetect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8795,"description":"

The update method is run in the draw loop.

\n

Accepts an FFT object. You must call .analyze()\non the FFT object prior to updating the peakDetect\nbecause it relies on a completed FFT analysis.

\n","itemtype":"method","name":"update","params":[{"name":"fftObject","description":"

A p5.FFT object

\n","type":"p5.FFT"}],"class":"p5.PeakDetect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8826,"description":"

onPeak accepts two arguments: a function to call when\na peak is detected. The value of the peak,\nbetween 0.0 and 1.0, is passed to the callback.

\n","itemtype":"method","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}],"example":["\n
\nvar cnv, soundFile, fft, peakDetect;\nvar ellipseWidth = 0;\n\nfunction setup() {\n cnv = createCanvas(100,100);\n textAlign(CENTER);\n\n soundFile = loadSound('assets/beat.mp3');\n fft = new p5.FFT();\n peakDetect = new p5.PeakDetect();\n\n setupSound();\n\n // when a beat is detected, call triggerBeat()\n peakDetect.onPeak(triggerBeat);\n}\n\nfunction draw() {\n background(0);\n fill(255);\n text('click to play', width/2, height/2);\n\n fft.analyze();\n peakDetect.update(fft);\n\n ellipseWidth *= 0.95;\n ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n}\n\n// this function is called by peakDetect.onPeak\nfunction triggerBeat() {\n ellipseWidth = 50;\n}\n\n// mouseclick starts/stops sound\nfunction setupSound() {\n cnv.mouseClicked( function() {\n if (soundFile.isPlaying() ) {\n soundFile.stop();\n } else {\n soundFile.play();\n }\n });\n}\n
"],"class":"p5.PeakDetect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8972,"description":"

Connect a source to the gain node.

\n","itemtype":"method","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","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8982,"description":"

Send output to a p5.sound or web audio object

\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Gain","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":8992,"description":"

Disconnect all output.

\n","itemtype":"method","name":"disconnect","class":"p5.Gain","module":"p5.sound","submodule":"p5.sound"},{"file":"lib/addons/p5.sound.js","line":9000,"description":"

Set the output level of the gain node.

\n","itemtype":"method","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","submodule":"p5.sound"}],"warnings":[{"message":"unknown tag: alt","line":" src/color/creating_reading.js:95"},{"message":"replacing incorrect tag: returns with return","line":" src/core/environment.js:431"},{"message":"replacing incorrect tag: returns with return","line":" src/core/environment.js:472"},{"message":"param name missing: {Invert}","line":" src/image/filters.js:240"},{"message":"replacing incorrect tag: returns with return","line":" src/image/loading_displaying.js:104"},{"message":"param name missing: {p5.Vector | Array }\n vector to scale by","line":" src/webgl/p5.Matrix.js:439"},{"message":"replacing incorrect tag: params with param","line":" lib/addons/p5.sound.js:1573"},{"message":"replacing incorrect tag: returns with return","line":" lib/addons/p5.sound.js:1573"},{"message":"param name missing: {String}","line":" lib/addons/p5.sound.js:6765"},{"message":"Missing item type\nmodule Conversion\nsubmodule Color Conversion","line":" src/color/color_conversion.js:1"},{"message":"Missing item type\nConversions adapted from .\n\nIn these functions, hue is always in the range [0,1); all other components\nare in the range [0,1]. 'Brightness' and 'value' are used interchangeably.","line":" src/color/color_conversion.js:10"},{"message":"Missing item type\nConvert an HSBA array to HSLA.","line":" src/color/color_conversion.js:20"},{"message":"Missing item type\nConvert an HSBA array to RGBA.","line":" src/color/color_conversion.js:46"},{"message":"Missing item type\nConvert an HSLA array to HSBA.","line":" src/color/color_conversion.js:95"},{"message":"Missing item type\nConvert an HSLA array to RGBA.\n\nWe need to change basis from HSLA to something that can be more easily be\nprojected onto RGBA. We will choose hue and brightness as our first two\ncomponents, and pick a convenient third one ('zest') so that we don't need\nto calculate formal HSBA saturation.","line":" src/color/color_conversion.js:118"},{"message":"Missing item type\nConvert an RGBA array to HSBA.","line":" src/color/color_conversion.js:176"},{"message":"Missing item type\nConvert an RGBA array to HSLA.","line":" src/color/color_conversion.js:211"},{"message":"Missing item type\nHue is the same in HSB and HSL, but the maximum value may be different.\nThis function will return the HSB-normalized saturation when supplied with\nan HSB color object, but will default to the HSL-normalized saturation\notherwise.","line":" src/color/p5.Color.js:79"},{"message":"Missing item type\nSaturation is scaled differently in HSB and HSL. This function will return\nthe HSB saturation when supplied with an HSB color object, but will default\nto the HSL saturation otherwise.","line":" src/color/p5.Color.js:110"},{"message":"Missing item type\nCSS named colors.","line":" src/color/p5.Color.js:129"},{"message":"Missing item type\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.\n\nNote that RGB values of .9 are not parsed by IE, but are supported here for\ncolor string consistency.","line":" src/color/p5.Color.js:282"},{"message":"Missing item type\nFull color string patterns. The capture groups are necessary.","line":" src/color/p5.Color.js:295"},{"message":"Missing item type\nFor a number of different inputs, returns a color formatted as [r, g, b, a]\narrays, with each component normalized between 0 and 1.","line":" src/color/p5.Color.js:402"},{"message":"Missing item type\nFor HSB and HSL, interpret the gray level as a brightness/lightness\nvalue (they are equivalent when chroma is zero). For RGB, normalize the\ngray level according to the blue maximum.","line":" src/color/p5.Color.js:572"},{"message":"Missing item type","line":" src/core/canvas.js:1"},{"message":"Missing item type\nThis is the p5 instance constructor.\n\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(), setup(), and/or\ndraw() properties on it for running a sketch.\n\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","line":" src/core/core.js:15"},{"message":"Missing item type\nSets the resolution at which Beziers display.\n\nThe default value is 20.","line":" src/core/curves.js:106"},{"message":"Missing item type\nSets the resolution at which curves display.\n\nThe default value is 20.","line":" src/core/curves.js:344"},{"message":"Missing item type\nReturns the current framerate.","line":" src/core/environment.js:229"},{"message":"Missing item type\nSpecifies the number of frames to be displayed every second. For example,\nthe function call frameRate(30) will attempt to refresh 30 times a second.\nIf the processor is not fast enough to maintain the specified rate, the\nframe rate will not be achieved. Setting the frame rate within setup() is\nrecommended. The default rate is 60 frames per second.\n\nCalling frameRate() with no arguments returns the current framerate.","line":" src/core/environment.js:238"},{"message":"Missing item type","line":" src/core/error_helpers.js:1"},{"message":"Missing item type\nChecks the definition type against the argument type\nIf any of these passes (in order), it matches:\n\n- p5.* definitions are checked with instanceof\n- Booleans are let through (everything is truthy or falsey)\n- Lowercase of the definition is checked against the js type\n- Number types are checked to see if they are numerically castable","line":" src/core/error_helpers.js:39"},{"message":"Missing item type\nPrints out a fancy, colorful message to the console log","line":" src/core/error_helpers.js:59"},{"message":"Missing item type\nValidate all the parameters of a function for number and type\nNOTE THIS FUNCTION IS TEMPORARILY DISABLED UNTIL FURTHER WORK\nAND UPDATES ARE IMPLEMENTED. -LMCCART","line":" src/core/error_helpers.js:106"},{"message":"Missing item type\nPrints out all the colors in the color pallete with white text.\nFor color blindness testing.","line":" src/core/error_helpers.js:244"},{"message":"Missing item type\nHelper fxn for sharing pixel methods","line":" src/core/p5.Element.js:811"},{"message":"Missing item type\nResize our canvas element.","line":" src/core/p5.Renderer.js:71"},{"message":"Missing item type\nHelper fxn to check font type (system or otf)","line":" src/core/p5.Renderer.js:145"},{"message":"Missing item type\nHelper fxn to measure ascent and descent.\nAdapted from http://stackoverflow.com/a/25355178","line":" src/core/p5.Renderer.js:201"},{"message":"Missing item type\np5.Renderer2D\nThe 2D graphics canvas renderer class.\nextends p5.Renderer","line":" src/core/p5.Renderer2D.js:9"},{"message":"Missing item type\nGenerate a cubic Bezier representing an arc on the unit circle of total\nangle `size` radians, beginning `start` radians above the x-axis. Up to\nfour of these curves are combined to make a full arc.\n\nSee www.joecridge.me/bezier.pdf for an explanation of the method.","line":" src/core/p5.Renderer2D.js:356"},{"message":"Missing item type\nshim for Uint8ClampedArray.slice\n(allows arrayCopy to work with pixels[])\nwith thanks to http://halfpapstudios.com/blog/tag/html5-canvas/\nEnumerable set to false to protect for...in from\nUint8ClampedArray.prototype pollution.","line":" src/core/shim.js:65"},{"message":"Missing item type\n_updatePAccelerations updates the pAcceleration values","line":" src/events/acceleration.js:72"},{"message":"Missing item type\nHolds the key codes of currently pressed keys.","line":" src/events/keyboard.js:12"},{"message":"Missing item type\nThe onblur function is called when the user is no longer focused\non the p5 element. Because the keyup events will not fire if the user is\nnot focused on the element we must assume all keys currently down have\nbeen released.","line":" src/events/keyboard.js:273"},{"message":"Missing item type\nThis module defines the filters for use with image buffers.\n\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.\n\nGenerally speaking users of this module will use the Filters.apply method\non a canvas to create an effect.\n\nA number of functions are borrowed/adapted from\nhttp://www.html5rocks.com/en/tutorials/canvas/imagefilters/\nor the java processing implementation.","line":" src/image/filters.js:3"},{"message":"Missing item type\nReturns the pixel buffer for a canvas","line":" src/image/filters.js:28"},{"message":"Missing item type\nReturns a 32 bit number containing ARGB data at ith pixel in the\n1D array containing pixels data.","line":" src/image/filters.js:51"},{"message":"Missing item type\nModifies pixels RGBA values to values contained in the data object.","line":" src/image/filters.js:70"},{"message":"Missing item type\nReturns the ImageData object for a canvas\nhttps://developer.mozilla.org/en-US/docs/Web/API/ImageData","line":" src/image/filters.js:90"},{"message":"Missing item type\nReturns a blank ImageData object.","line":" src/image/filters.js:113"},{"message":"Missing item type\nApplys a filter function to a canvas.\n\nThe difference between this and the actual filter functions defined below\nis that the filter functions generally modify the pixel buffer but do\nnot actually put that data back to the canvas (where it would actually\nupdate what is visible). By contrast this method does make the changes\nactually visible in the canvas.\n\nThe apply method is the method that callers of this module would generally\nuse. It has been separated from the actual filters to support an advanced\nuse case of creating a filter chain that executes without actually updating\nthe canvas in between everystep.","line":" src/image/filters.js:129"},{"message":"Missing item type\nConverts the image to black and white pixels depending if they are above or\nbelow the threshold defined by the level parameter. The parameter must be\nbetween 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is used.\n\nBorrowed from http://www.html5rocks.com/en/tutorials/canvas/imagefilters/","line":" src/image/filters.js:168"},{"message":"Missing item type\nConverts any colors in the image to grayscale equivalents.\nNo parameter is used.\n\nBorrowed from http://www.html5rocks.com/en/tutorials/canvas/imagefilters/","line":" src/image/filters.js:203"},{"message":"Missing item type\nSets the alpha channel to entirely opaque. No parameter is used.","line":" src/image/filters.js:225"},{"message":"Missing item type\nSets each pixel to its inverse value. No parameter is used.","line":" src/image/filters.js:240"},{"message":"Missing item type\nLimits each channel of the image to the number of colors specified as\nthe parameter. The parameter can be set to values between 2 and 255, but\nresults are most noticeable in the lower ranges.\n\nAdapted from java based processing implementation","line":" src/image/filters.js:256"},{"message":"Missing item type\nreduces the bright areas in an image","line":" src/image/filters.js:287"},{"message":"Missing item type\nincreases the bright areas in an image","line":" src/image/filters.js:368"},{"message":"Missing item type\nThis module defines the p5 methods for the p5.Image class\nfor drawing images to the main display canvas.","line":" src/image/image.js:8"},{"message":"Missing item type\nValidates clipping params. Per drawImage spec sWidth and sHight cannot be\nnegative or greater than image intrinsic width and height","line":" src/image/loading_displaying.js:104"},{"message":"Missing item type\nApply the current tint color to the input image, return the resulting\ncanvas.","line":" src/image/loading_displaying.js:325"},{"message":"Missing item type\nThis module defines the p5.Image class and P5 methods for\ndrawing images to the main display canvas.","line":" src/image/p5.Image.js:9"},{"message":"Missing item type\nHelper fxn for sharing pixel methods","line":" src/image/p5.Image.js:161"},{"message":"Missing item type\nChecks if we are in preload and returns the last arg which will be the\n_decrementPreload function if called from a loadX() function. Should\nonly be used in loadX() functions.","line":" src/io/files.js:16"},{"message":"Missing item type\nGenerate a blob of file data as a url to prepare for download.\nAccepts an array of data, a filename, and an extension (optional).\nThis is a private function because it does not do any formatting,\nbut it is used by saveStrings, saveJSON, saveTable etc.","line":" src/io/files.js:1348"},{"message":"Missing item type\nForces download. Accepts a url to filedata/blob, a filename,\nand an extension (optional).\nThis is a private function because it does not do any formatting,\nbut it is used by saveStrings, saveJSON, saveTable etc.","line":" src/io/files.js:1371"},{"message":"Missing item type\nReturns a file extension, or another string\nif the provided parameter has no extension.","line":" src/io/files.js:1407"},{"message":"Missing item type\nReturns true if the browser is Safari, false if not.\nSafari makes trouble for downloading files.","line":" src/io/files.js:1439"},{"message":"Missing item type\nHelper function, a callback for download that deletes\nan invisible anchor element from the DOM once the file\nhas been automatically downloaded.","line":" src/io/files.js:1451"},{"message":"Missing item type\nTable Options\n

Generic class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.

\n

CSV files are\n\ncomma separated values, often with the data in quotes. TSV\nfiles use tabs as separators, and usually don't bother with the\nquotes.

\n

File names should end with .csv if they're comma separated.

\n

A rough \"spec\" for CSV can be found\nhere.

\n

To load files, use the loadTable method.

\n

To save tables to your computer, use the save method\n or the saveTable method.

\n\nPossible options include:\n
    \n
  • csv - parse the table as comma-separated values\n
  • tsv - parse the table as tab-separated values\n
  • header - this table has a header (title) row\n
","line":" src/io/p5.Table.js:12"},{"message":"Missing item type\nReturns the total number of columns in a Table.","line":" src/io/p5.Table.js:610"},{"message":"Missing item type\nThis method is called while the parsing of XML (when loadXML() is\ncalled). The difference between this method and the setContent()\nmethod defined later is that this one is used to set the content\nwhen the node in question has more nodes under it and so on and\nnot directly text content. While in the other one is used when\nthe node in question directly has text inside it.","line":" src/io/p5.XML.js:763"},{"message":"Missing item type\nThis method is called while the parsing of XML (when loadXML() is\ncalled). The XML node is passed and its attributes are stored in the\np5.XML's attribute Object.","line":" src/io/p5.XML.js:780"},{"message":"Missing item type\nAdds two vectors together and returns a new one.","line":" src/math/p5.Vector.js:870"},{"message":"Missing item type\nSubtracts one p5.Vector from another and returns a new one. The second\nvector (v2) is subtracted from the first (v1), resulting in v1-v2.","line":" src/math/p5.Vector.js:891"},{"message":"Missing item type\nMultiplies a vector by a scalar and returns a new vector.","line":" src/math/p5.Vector.js:913"},{"message":"Missing item type\nDivides a vector by a scalar and returns a new vector.","line":" src/math/p5.Vector.js:932"},{"message":"Missing item type\nCalculates the dot product of two vectors.","line":" src/math/p5.Vector.js:952"},{"message":"Missing item type\nCalculates the cross product of two vectors.","line":" src/math/p5.Vector.js:964"},{"message":"Missing item type\nCalculates the Euclidean distance between two points (considering a\npoint as a vector object).","line":" src/math/p5.Vector.js:976"},{"message":"Missing item type\nLinear interpolate a vector to another vector and return the result as a\nnew vector.","line":" src/math/p5.Vector.js:989"},{"message":"Missing item type","line":" src/math/p5.Vector.js:1038"},{"message":"Missing item type\nReturns the ascent of the current font at its current size. The ascent\nrepresents the distance, in pixels, of the tallest character above\nthe baseline.","line":" src/typography/attributes.js:157"},{"message":"Missing item type\nReturns the descent of the current font at its current size. The descent\nrepresents the distance, in pixels, of the character with the longest\ndescender below the baseline.","line":" src/typography/attributes.js:185"},{"message":"Missing item type\nHelper function to measure ascent and descent.","line":" src/typography/attributes.js:213"},{"message":"Missing item type\nComputes an array of points following the path for specified text","line":" src/typography/p5.Font.js:171"},{"message":"Missing item type\nReturns the set of opentype glyphs for the supplied string.\n\nNote that there is not a strict one-to-one mapping between characters\nand glyphs, so the list of returned glyphs can be larger or smaller\n than the length of the given string.","line":" src/typography/p5.Font.js:219"},{"message":"Missing item type\nReturns an opentype path for the supplied string and position.","line":" src/typography/p5.Font.js:234"},{"message":"Missing item type\nParse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:\n\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\n\nf 4 3 2 1","line":" src/webgl/loading.js:87"},{"message":"Missing item type\nTexture Util functions","line":" src/webgl/material.js:161"},{"message":"Missing item type\nChecks whether val is a pot\nmore info on power of 2 here:\nhttps://www.opengl.org/wiki/NPOT_Texture","line":" src/webgl/material.js:182"},{"message":"Missing item type\nreturns the next highest power of 2 value","line":" src/webgl/material.js:193"},{"message":"Missing item type","line":" src/webgl/material.js:301"},{"message":"Missing item type\np5 Geometry class","line":" src/webgl/p5.Geometry.js:7"},{"message":"Missing item type\ncomputes smooth normals per vertex as an average of each\nface.","line":" src/webgl/p5.Geometry.js:71"},{"message":"Missing item type\nAverages the vertex normals. Used in curved\nsurfaces","line":" src/webgl/p5.Geometry.js:95"},{"message":"Missing item type\nAverages pole normals. Used in spherical primitives","line":" src/webgl/p5.Geometry.js:114"},{"message":"Missing item type\nModifies all vertices to be centered within the range -100 to 100.","line":" src/webgl/p5.Geometry.js:146"},{"message":"Missing item type","line":" src/webgl/p5.Matrix.js:1"},{"message":"Missing item type\nA class to describe a 4x4 matrix\nfor model and view matrix manipulation in the p5js webgl renderer.\nclass p5.Matrix","line":" src/webgl/p5.Matrix.js:19"},{"message":"Missing item type\nSets the x, y, and z component of the vector using two or three separate\nvariables, the data from a p5.Matrix, or the values from a float array.","line":" src/webgl/p5.Matrix.js:74"},{"message":"Missing item type\nGets a copy of the vector, returns a p5.Matrix object.","line":" src/webgl/p5.Matrix.js:93"},{"message":"Missing item type\nreturn a copy of a matrix","line":" src/webgl/p5.Matrix.js:102"},{"message":"Missing item type\nreturn an identity matrix","line":" src/webgl/p5.Matrix.js:127"},{"message":"Missing item type\ntranspose according to a given matrix","line":" src/webgl/p5.Matrix.js:135"},{"message":"Missing item type\ninvert matrix according to a give matrix","line":" src/webgl/p5.Matrix.js:195"},{"message":"Missing item type\nInverts a 3x3 matrix","line":" src/webgl/p5.Matrix.js:280"},{"message":"Missing item type\ntransposes a 3x3 p5.Matrix by a mat3","line":" src/webgl/p5.Matrix.js:316"},{"message":"Missing item type\nconverts a 4x4 matrix to its 3x3 inverse tranform\ncommonly used in MVMatrix to NMatrix conversions.","line":" src/webgl/p5.Matrix.js:332"},{"message":"Missing item type\ninspired by Toji's mat4 determinant","line":" src/webgl/p5.Matrix.js:360"},{"message":"Missing item type\nmultiply two mat4s","line":" src/webgl/p5.Matrix.js:383"},{"message":"Missing item type\nscales a p5.Matrix by scalars or a vector","line":" src/webgl/p5.Matrix.js:439"},{"message":"Missing item type\nrotate our Matrix around an axis by the given angle.","line":" src/webgl/p5.Matrix.js:485"},{"message":"Missing item type","line":" src/webgl/p5.Matrix.js:564"},{"message":"Missing item type\nsets the perspective matrix","line":" src/webgl/p5.Matrix.js:594"},{"message":"Missing item type\nsets the ortho matrix","line":" src/webgl/p5.Matrix.js:628"},{"message":"Missing item type\nPRIVATE","line":" src/webgl/p5.Matrix.js:663"},{"message":"Missing item type\nWelcome to RendererGL Immediate Mode.\nImmediate mode is used for drawing custom shapes\nfrom a set of vertices. Immediate Mode is activated\nwhen you call beginShape() & de-activated when you call endShape().\nImmediate mode is a style of programming borrowed\nfrom OpenGL's (now-deprecated) immediate mode.\nIt differs from p5.js' default, Retained Mode, which caches\ngeometries and buffers on the CPU to reduce the number of webgl\ndraw calls. Retained mode is more efficient & performative,\nhowever, Immediate Mode is useful for sketching quick\ngeometric ideas.","line":" src/webgl/p5.RendererGL.Immediate.js:1"},{"message":"Missing item type\nBegin shape drawing. This is a helpful way of generating\ncustom shapes quickly. However in WEBGL mode, application\nperformance will likely drop as a result of too many calls to\nbeginShape() / endShape(). As a high performance alternative,\nplease use p5.js geometry primitives.","line":" src/webgl/p5.RendererGL.Immediate.js:19"},{"message":"Missing item type\nadds a vertex to be drawn in a custom Shape.","line":" src/webgl/p5.RendererGL.Immediate.js:49"},{"message":"Missing item type\nEnd shape drawing and render vertices to screen.","line":" src/webgl/p5.RendererGL.Immediate.js:68"},{"message":"Missing item type\nBind immediateMode buffers to data,\nthen draw gl arrays","line":" src/webgl/p5.RendererGL.Immediate.js:121"},{"message":"Missing item type\ninitializes buffer defaults. runs each time a new geometry is\nregistered","line":" src/webgl/p5.RendererGL.Retained.js:7"},{"message":"Missing item type\ncreateBuffers description","line":" src/webgl/p5.RendererGL.Retained.js:30"},{"message":"Missing item type\nDraws buffers given a geometry key ID","line":" src/webgl/p5.RendererGL.Retained.js:93"},{"message":"Missing item type\nturn a two dimensional array into one dimensional array","line":" src/webgl/p5.RendererGL.Retained.js:129"},{"message":"Missing item type\nturn a p5.Vector Array into a one dimensional number array","line":" src/webgl/p5.RendererGL.Retained.js:145"},{"message":"Missing item type\nmodel view, projection, & normal\nmatrices","line":" src/webgl/p5.RendererGL.js:43"},{"message":"Missing item type\n[background description]","line":" src/webgl/p5.RendererGL.js:106"},{"message":"Missing item type\n[_initShaders description]","line":" src/webgl/p5.RendererGL.js:130"},{"message":"Missing item type\nSets a shader uniform given a shaderProgram and uniform string","line":" src/webgl/p5.RendererGL.js:205"},{"message":"Missing item type\n[strokeWeight description]","line":" src/webgl/p5.RendererGL.js:353"},{"message":"Missing item type\n[resize description]","line":" src/webgl/p5.RendererGL.js:376"},{"message":"Missing item type\nclears color and depth buffers\nwith r,g,b,a","line":" src/webgl/p5.RendererGL.js:393"},{"message":"Missing item type\n[translate description]","line":" src/webgl/p5.RendererGL.js:410"},{"message":"Missing item type\nScales the Model View Matrix by a vector","line":" src/webgl/p5.RendererGL.js:427"},{"message":"Missing item type\npushes a copy of the model view matrix onto the\nMV Matrix stack.","line":" src/webgl/p5.RendererGL.js:459"},{"message":"Missing item type\n[pop description]","line":" src/webgl/p5.RendererGL.js:467"},{"message":"Missing item type","line":" src/webgl/primitives.js:230"},{"message":"Missing item type\n_globalInit\n\nTODO: ???\nif sketch is on window\nassume \"global\" mode\nand instantiate p5 automatically\notherwise do nothing","line":" src/app.js:62"},{"message":"Missing item type\nHelper function for select and selectAll","line":" lib/addons/p5.dom.js:155"},{"message":"Missing item type\nHelper function for getElement and getElements.","line":" lib/addons/p5.dom.js:171"},{"message":"Missing item type\nHelpers for create methods.","line":" lib/addons/p5.dom.js:221"},{"message":"Missing item type","line":" lib/addons/p5.dom.js:365"},{"message":"Missing item type","line":" lib/addons/p5.dom.js:804"},{"message":"Missing item type","line":" lib/addons/p5.dom.js:867"},{"message":"Missing item type","line":" lib/addons/p5.dom.js:895"},{"message":"Missing item type\nCenters a p5 Element either vertically, horizontally,\nor both, relative to its parent or according to\nthe body if the Element has no parent. If no argument is passed\nthe Element is aligned both vertically and horizontally.","line":" lib/addons/p5.dom.js:1117"},{"message":"Missing item type","line":" lib/addons/p5.dom.js:1867"},{"message":"Missing item type","line":" lib/addons/p5.dom.js:1937"},{"message":"Missing item type","line":" lib/addons/p5.dom.js:1959"},{"message":"Missing item type\np5.sound developed by Jason Sigal for the Processing Foundation, Google Summer of Code 2014. The MIT License (MIT).\n\nhttp://github.com/therewasaguy/p5.sound\n\nSome of the many audio libraries & resources that inspire p5.sound:\n - TONE.js (c) Yotam Mann, 2014. Licensed under The MIT License (MIT). https://github.com/TONEnoTONE/Tone.js\n - buzz.js (c) Jay Salvat, 2013. Licensed under The MIT License (MIT). http://buzz.jaysalvat.com/\n - Boris Smus Web Audio API book, 2013. Licensed under the Apache License http://www.apache.org/licenses/LICENSE-2.0\n - wavesurfer.js https://github.com/katspaugh/wavesurfer.js\n - Web Audio Components by Jordan Santell https://github.com/web-audio-components\n - Wilm Thoben's Sound library for Processing https://github.com/processing/processing/tree/master/java/libraries/sound\n \n Web Audio API: http://w3.org/TR/webaudio/","line":" lib/addons/p5.sound.js:53"},{"message":"Missing item type\nDetermine which filetypes are supported (inspired by buzz.js)\nThe audio element (el) will only be used to test browser support for various audio formats","line":" lib/addons/p5.sound.js:221"},{"message":"Missing item type\nMaster contains AudioContext and the master sound output.","line":" lib/addons/p5.sound.js:288"},{"message":"Missing item type\na silent connection to the DesinationNode\nwhich will ensure that anything connected to it\nwill not be garbage collected","line":" lib/addons/p5.sound.js:386"},{"message":"Missing item type\nReturns the closest MIDI note value for\na given frequency.","line":" lib/addons/p5.sound.js:415"},{"message":"Missing item type\nUsed by Osc and Env to chain signal math","line":" lib/addons/p5.sound.js:575"},{"message":"Missing item type\nThis is a helper function that the p5.SoundFile calls to load\nitself. Accepts a callback (the name of another function)\nas an optional parameter.","line":" lib/addons/p5.sound.js:893"},{"message":"Missing item type\nSet a p5.SoundFile's looping flag to true or false. If the sound\nis currently playing, this change will take effect when it\nreaches the end of the current playback.","line":" lib/addons/p5.sound.js:1224"},{"message":"Missing item type\nReturns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.","line":" lib/addons/p5.sound.js:1244"},{"message":"Missing item type\nStop playback on all of this soundfile's sources.","line":" lib/addons/p5.sound.js:1302"},{"message":"Missing item type\nReturns the current stereo pan position (-1.0 to 1.0)","line":" lib/addons/p5.sound.js:1404"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:1743"},{"message":"Missing item type\nReplace the current Audio Buffer with a new Buffer.","line":" lib/addons/p5.sound.js:1761"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:2027"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:2911"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:3314"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:3335"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:3394"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:3847"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:3984"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:4017"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:4063"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:4084"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:4104"},{"message":"Missing item type\nConnect a p5.sound object or Web Audio node to this\np5.Signal so that its amplitude values can be scaled.","line":" lib/addons/p5.sound.js:4217"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:4806"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:4992"},{"message":"Missing item type\nSet the amplitude of the noise between 0 and 1.0. Or,\nmodulate amplitude with an audio signal such as an oscillator.","line":" lib/addons/p5.sound.js:6234"},{"message":"Missing item type\nAdd input sources to the list of available sources.","line":" lib/addons/p5.sound.js:6460"},{"message":"Missing item type\nInspired by Simple Reverb by Jordan Santell\nhttps://github.com/web-audio-components/simple-reverb/blob/master/index.js\n \nUtility function for building an impulse response\nbased on the module parameters.","line":" lib/addons/p5.sound.js:7296"},{"message":"Missing item type\nPrivate method to load a buffer as an Impulse Response,\nassign it to the convolverNode, and add to the Array of .impulses.","line":" lib/addons/p5.sound.js:7474"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:7666"},{"message":"Missing item type","line":" lib/addons/p5.sound.js:7691"},{"message":"Missing item type\nSet the global tempo, in beats per minute, for all\np5.Parts. This method will impact all active p5.Parts.","line":" lib/addons/p5.sound.js:7910"},{"message":"Missing item type\nSet the tempo for all parts in the score","line":" lib/addons/p5.sound.js:8363"},{"message":"Missing item type\ncallback invoked when the recording is over","line":" lib/addons/p5.sound.js:8469"},{"message":"Missing item type\ninternal method called on audio process","line":" lib/addons/p5.sound.js:8555"}]} diff --git a/static/intercept-p5.js b/static/intercept-p5.js new file mode 100644 index 00000000..2275eba2 --- /dev/null +++ b/static/intercept-p5.js @@ -0,0 +1,52 @@ +var textOutputElement; +var canvasLocation =''; + +funcNames = allData["classitems"].map(function(x){ + if(x["overloads"]) { + tempParam = x["overloads"][0]["params"]; + } else { + tempParam = x["params"]; + } + return { + name: x["name"], + params: tempParam, + class: x["class"], + module: x["module"], + submodule: x["submodule"] + }; +}); +funcNames = funcNames.filter(function(x) { + var className = x["class"]; + return (x["name"] && x["params"] && (className==='p5')); +}) + +funcNames.forEach(function(x){ + var document = parent.document; + var originalFunc = p5.prototype[x.name]; + p5.prototype[x.name] = function(){ + orgArg = arguments; + + if(frameCount == 0) { //for setup + Interceptor.setupObject = Interceptor.populateObject(x,arguments, Interceptor.setupObject, document.getElementById('textOutput-content-details'),false); + Interceptor.getSummary(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary')); + var table = document.getElementById('textOutput-content-details'); + table.innerHTML = ''; + Interceptor.populateTable(table,Interceptor.setupObject.objectArray); + } + + else if(frameCount%100 == 0 ) { + Interceptor.drawObject = Interceptor.populateObject(x,arguments, Interceptor.drawObject, document.getElementById('textOutput-content-details'),true); + Interceptor.isCleared = false; + } + //reset some of the variables + else if(frameCount%100 == 1 ) { + if(!Interceptor.isCleared){ + var table = document.getElementById('textOutput-content-details'); + Interceptor.getSummary(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary')); + Interceptor.populateTable(table,Interceptor.setupObject.objectArray.concat(Interceptor.drawObject.objectArray)); + } + Interceptor.drawObject = Interceptor.clearVariables(Interceptor.drawObject); + } + return originalFunc.apply(this,arguments); + } +}); diff --git a/static/interceptor-functions.js b/static/interceptor-functions.js new file mode 100644 index 00000000..3c4d52fe --- /dev/null +++ b/static/interceptor-functions.js @@ -0,0 +1,327 @@ +String.prototype.paddingLeft = function (paddingValue) { + return String(paddingValue + this).slice(-paddingValue.length); +}; + +function MergeObjRecursive(obj1, obj2) { + var obj3 = {}; + for(p in obj1) { + obj3[p] = obj1[p]; + } + for(p in obj2) { + if(Object.keys(obj3).indexOf(p)<0){ + obj3[p] = obj2[p]; + } + else { + obj3[p] = obj3[p] + obj2[p]; + } + } + return obj3; +} + +if(Array.prototype.equals) +// attach the .equals method to Array's prototype to call it on any array +Array.prototype.equals = function (array) { + // if the other array is a falsy value, return + if (!array) + return false; + + // compare lengths - can save a lot of time + if (this.length != array.length) + return false; + + for (var i = 0, l=this.length; i < l; i++) { + // Check if we have nested arrays + if (this[i] instanceof Array && array[i] instanceof Array) { + // recurse into the nested arrays + if (!this[i].equals(array[i])) + return false; + } + else if (this[i] != array[i]) { + // Warning - two different object instances will never be equal: {x:20} != {x:20} + return false; + } + } + return true; +} +// Hide method from for-in loops +Object.defineProperty(Array.prototype, "equals", {enumerable: false}); + + +var Interceptor = { + prevTotalCount :0, + totalCount : 0, + currentColor : 'white', + bgColor : 'white', + canvasDetails : { + width : 0, + height: 0 + }, + setupObject : { + objectArray : [], + objectCount : 0, + objectTypeCount : {} + }, + drawObject : { + objectArray : [], + objectCount : 0, + objectTypeCount : {} + }, + isCleared : false, + getColorName : function(arguments) { + if(arguments.length==3) { + //assuming that we are doing RGB - convert RGB values to a name + var color = '#' + arguments[0].toString(16).paddingLeft("00") + arguments[1].toString(16).paddingLeft("00") + arguments[2].toString(16).paddingLeft("00"); + var n_match = ntc.name(color); + return n_match[1]; + } + else if(arguments.length==1) { + if(!(typeof(arguments[0])).localeCompare("number")) { + //assuming that we are doing RGB - this would be a grayscale number + if(arguments[0]<10) { + return 'black'; + } + else if(arguments[0]>240) { + return 'white'; + } + else { + return 'grey'; + } + } + else if(!(typeof(arguments[0])).localeCompare("string")) { + if(!arguments[0].charAt(0).localeCompare('#')) { + //if user has entered a hex color + var n_match = ntc.name(arguments[0]); + return n_match[1]; + } + else { + return arguments[0]; + } + } + } + }, + + canvasLocator : function(arguments,canvasX,canvasY){ + var x,y; + var isNum1 = false; + var isNum2 = false; + for(var i=0;i0.6*canvasY) { + return 'bottom left'; + } + else { + return 'mid left'; + } + } + else if(x>0.6*canvasX) { + if(y<0.4*canvasY) { + return 'top right'; + } + else if(y>0.6*canvasY) { + return 'bottom right'; + } + else { + return 'mid right'; + } + } + else { + if(y<0.4*canvasY) { + return 'top middle'; + } + else if(y>0.6*canvasY) { + return 'bottom middle'; + } + else { + return 'middle'; + } + } + }, + clearVariables : function(object) { + object.objectTypeCount = {}; + object.objectCount = 0; + this.isCleared = true; + return object; + }, + + populateObject : function(x,arguments, object ,table, isDraw) { + objectCount = object.objectCount; + objectArray = object.objectArray; + objectTypeCount = object.objectTypeCount; + if(!isDraw) { + //check for special function in setup -> createCanvas + if(!x.name.localeCompare('createCanvas')) { + this.canvasDetails.width = arguments[0]; + this.canvasDetails.height = arguments[1]; + } + } + //check for speacial functions in general -> background/fill + if(!x.name.localeCompare('fill')) { + this.currentColor = this.getColorName(arguments); + } + else if(!x.name.localeCompare('background')) { + this.bgColor = this.getColorName(arguments); + } + else if(!x.module.localeCompare('Shape') || !x.module.localeCompare('Typography') &&((!x.submodule)||(x.submodule.localeCompare('Attributes')!=0)) ){ + + var canvasLocation = this.canvasLocator(arguments ,width,height); + + objectArray[objectCount] = { + 'type' : x.name, + 'location': canvasLocation, + 'colour': this.currentColor + }; + //add the object(shape/text) parameters in objectArray + for(var i=0;i this.totalCount) { + for(var j =0;j 1 ) { + element.innerHTML += ' objects. The objects are '; + } + else { + element.innerHTML += ' object. The object is '; + } + + if(object2.objectCount>0 || object1.objectCount>0 ) { + + totObjectTypeCount = MergeObjRecursive(object1.objectTypeCount, object2.objectTypeCount); + var keys = Object.keys(totObjectTypeCount); + for(var i=0;i7)return["#000000","Invalid Color: "+a,!1];a.length%3==0&&(a="#"+a),4==a.length&&(a="#"+a.substr(1,1)+a.substr(1,1)+a.substr(2,1)+a.substr(2,1)+a.substr(3,1)+a.substr(3,1));var b=ntc.rgb(a),c=b[0],d=b[1],e=b[2],f=ntc.hsl(a),g=f[0],h=f[1],i=f[2],j=0;ndf2=0,ndf=0;for(var k=-1,l=-1,m=0;mndf)&&(l=ndf,k=m)}return k<0?["#000000","Invalid Color: "+a,!1]:["#"+ntc.names[k][0],ntc.names[k][1],!1]},hsl:function(a){var c,d,e,f,g,h,b=[parseInt("0x"+a.substring(1,3))/255,parseInt("0x"+a.substring(3,5))/255,parseInt("0x"+a.substring(5,7))/255],i=b[0],j=b[1],k=b[2];return c=Math.min(i,Math.min(j,k)),d=Math.max(i,Math.max(j,k)),e=d-c,h=(c+d)/2,g=0,h>0&&h<1&&(g=e/(h<.5?2*h:2-2*h)),f=0,e>0&&(d==i&&d!=j&&(f+=(j-k)/e),d==j&&d!=k&&(f+=2+(k-i)/e),d==k&&d!=i&&(f+=4+(i-j)/e),f/=6),[parseInt(255*f),parseInt(255*g),parseInt(255*h)]},rgb:function(a){return[parseInt("0x"+a.substring(1,3)),parseInt("0x"+a.substring(3,5)),parseInt("0x"+a.substring(5,7))]},names:[["000000","Black"],["000080","Navy Blue"],["0000C8","Dark Blue"],["0000FF","Blue"],["000741","Stratos"],["001B1C","Swamp"],["002387","Resolution Blue"],["002900","Deep Fir"],["002E20","Burnham"],["002FA7","International Klein Blue"],["003153","Prussian Blue"],["003366","Midnight Blue"],["003399","Smalt"],["003532","Deep Teal"],["003E40","Cyprus"],["004620","Kaitoke Green"],["0047AB","Cobalt"],["004816","Crusoe"],["004950","Sherpa Blue"],["0056A7","Endeavour"],["00581A","Camarone"],["0066CC","Science Blue"],["0066FF","Blue Ribbon"],["00755E","Tropical Rain Forest"],["0076A3","Allports"],["007BA7","Deep Cerulean"],["007EC7","Lochmara"],["007FFF","Azure Radiance"],["008080","Teal"],["0095B6","Bondi Blue"],["009DC4","Pacific Blue"],["00A693","Persian Green"],["00A86B","Jade"],["00CC99","Caribbean Green"],["00CCCC","Robin's Egg Blue"],["00FF00","Green"],["00FF7F","Spring Green"],["00FFFF","Cyan / Aqua"],["010D1A","Blue Charcoal"],["011635","Midnight"],["011D13","Holly"],["012731","Daintree"],["01361C","Cardin Green"],["01371A","County Green"],["013E62","Astronaut Blue"],["013F6A","Regal Blue"],["014B43","Aqua Deep"],["015E85","Orient"],["016162","Blue Stone"],["016D39","Fun Green"],["01796F","Pine Green"],["017987","Blue Lagoon"],["01826B","Deep Sea"],["01A368","Green Haze"],["022D15","English Holly"],["02402C","Sherwood Green"],["02478E","Congress Blue"],["024E46","Evening Sea"],["026395","Bahama Blue"],["02866F","Observatory"],["02A4D3","Cerulean"],["03163C","Tangaroa"],["032B52","Green Vogue"],["036A6E","Mosque"],["041004","Midnight Moss"],["041322","Black Pearl"],["042E4C","Blue Whale"],["044022","Zuccini"],["044259","Teal Blue"],["051040","Deep Cove"],["051657","Gulf Blue"],["055989","Venice Blue"],["056F57","Watercourse"],["062A78","Catalina Blue"],["063537","Tiber"],["069B81","Gossamer"],["06A189","Niagara"],["073A50","Tarawera"],["080110","Jaguar"],["081910","Black Bean"],["082567","Deep Sapphire"],["088370","Elf Green"],["08E8DE","Bright Turquoise"],["092256","Downriver"],["09230F","Palm Green"],["09255D","Madison"],["093624","Bottle Green"],["095859","Deep Sea Green"],["097F4B","Salem"],["0A001C","Black Russian"],["0A480D","Dark Fern"],["0A6906","Japanese Laurel"],["0A6F75","Atoll"],["0B0B0B","Cod Gray"],["0B0F08","Marshland"],["0B1107","Gordons Green"],["0B1304","Black Forest"],["0B6207","San Felix"],["0BDA51","Malachite"],["0C0B1D","Ebony"],["0C0D0F","Woodsmoke"],["0C1911","Racing Green"],["0C7A79","Surfie Green"],["0C8990","Blue Chill"],["0D0332","Black Rock"],["0D1117","Bunker"],["0D1C19","Aztec"],["0D2E1C","Bush"],["0E0E18","Cinder"],["0E2A30","Firefly"],["0F2D9E","Torea Bay"],["10121D","Vulcan"],["101405","Green Waterloo"],["105852","Eden"],["110C6C","Arapawa"],["120A8F","Ultramarine"],["123447","Elephant"],["126B40","Jewel"],["130000","Diesel"],["130A06","Asphalt"],["13264D","Blue Zodiac"],["134F19","Parsley"],["140600","Nero"],["1450AA","Tory Blue"],["151F4C","Bunting"],["1560BD","Denim"],["15736B","Genoa"],["161928","Mirage"],["161D10","Hunter Green"],["162A40","Big Stone"],["163222","Celtic"],["16322C","Timber Green"],["163531","Gable Green"],["171F04","Pine Tree"],["175579","Chathams Blue"],["182D09","Deep Forest Green"],["18587A","Blumine"],["19330E","Palm Leaf"],["193751","Nile Blue"],["1959A8","Fun Blue"],["1A1A68","Lucky Point"],["1AB385","Mountain Meadow"],["1B0245","Tolopea"],["1B1035","Haiti"],["1B127B","Deep Koamaru"],["1B1404","Acadia"],["1B2F11","Seaweed"],["1B3162","Biscay"],["1B659D","Matisse"],["1C1208","Crowshead"],["1C1E13","Rangoon Green"],["1C39BB","Persian Blue"],["1C402E","Everglade"],["1C7C7D","Elm"],["1D6142","Green Pea"],["1E0F04","Creole"],["1E1609","Karaka"],["1E1708","El Paso"],["1E385B","Cello"],["1E433C","Te Papa Green"],["1E90FF","Dodger Blue"],["1E9AB0","Eastern Blue"],["1F120F","Night Rider"],["1FC2C2","Java"],["20208D","Jacksons Purple"],["202E54","Cloud Burst"],["204852","Blue Dianne"],["211A0E","Eternity"],["220878","Deep Blue"],["228B22","Forest Green"],["233418","Mallard"],["240A40","Violet"],["240C02","Kilamanjaro"],["242A1D","Log Cabin"],["242E16","Black Olive"],["24500F","Green House"],["251607","Graphite"],["251706","Cannon Black"],["251F4F","Port Gore"],["25272C","Shark"],["25311C","Green Kelp"],["2596D1","Curious Blue"],["260368","Paua"],["26056A","Paris M"],["261105","Wood Bark"],["261414","Gondola"],["262335","Steel Gray"],["26283B","Ebony Clay"],["273A81","Bay of Many"],["27504B","Plantation"],["278A5B","Eucalyptus"],["281E15","Oil"],["283A77","Astronaut"],["286ACD","Mariner"],["290C5E","Violent Violet"],["292130","Bastille"],["292319","Zeus"],["292937","Charade"],["297B9A","Jelly Bean"],["29AB87","Jungle Green"],["2A0359","Cherry Pie"],["2A140E","Coffee Bean"],["2A2630","Baltic Sea"],["2A380B","Turtle Green"],["2A52BE","Cerulean Blue"],["2B0202","Sepia Black"],["2B194F","Valhalla"],["2B3228","Heavy Metal"],["2C0E8C","Blue Gem"],["2C1632","Revolver"],["2C2133","Bleached Cedar"],["2C8C84","Lochinvar"],["2D2510","Mikado"],["2D383A","Outer Space"],["2D569B","St Tropaz"],["2E0329","Jacaranda"],["2E1905","Jacko Bean"],["2E3222","Rangitoto"],["2E3F62","Rhino"],["2E8B57","Sea Green"],["2EBFD4","Scooter"],["2F270E","Onion"],["2F3CB3","Governor Bay"],["2F519E","Sapphire"],["2F5A57","Spectra"],["2F6168","Casal"],["300529","Melanzane"],["301F1E","Cocoa Brown"],["302A0F","Woodrush"],["304B6A","San Juan"],["30D5C8","Turquoise"],["311C17","Eclipse"],["314459","Pickled Bluewood"],["315BA1","Azure"],["31728D","Calypso"],["317D82","Paradiso"],["32127A","Persian Indigo"],["32293A","Blackcurrant"],["323232","Mine Shaft"],["325D52","Stromboli"],["327C14","Bilbao"],["327DA0","Astral"],["33036B","Christalle"],["33292F","Thunder"],["33CC99","Shamrock"],["341515","Tamarind"],["350036","Mardi Gras"],["350E42","Valentino"],["350E57","Jagger"],["353542","Tuna"],["354E8C","Chambray"],["363050","Martinique"],["363534","Tuatara"],["363C0D","Waiouru"],["36747D","Ming"],["368716","La Palma"],["370202","Chocolate"],["371D09","Clinker"],["37290E","Brown Tumbleweed"],["373021","Birch"],["377475","Oracle"],["380474","Blue Diamond"],["381A51","Grape"],["383533","Dune"],["384555","Oxford Blue"],["384910","Clover"],["394851","Limed Spruce"],["396413","Dell"],["3A0020","Toledo"],["3A2010","Sambuca"],["3A2A6A","Jacarta"],["3A686C","William"],["3A6A47","Killarney"],["3AB09E","Keppel"],["3B000B","Temptress"],["3B0910","Aubergine"],["3B1F1F","Jon"],["3B2820","Treehouse"],["3B7A57","Amazon"],["3B91B4","Boston Blue"],["3C0878","Windsor"],["3C1206","Rebel"],["3C1F76","Meteorite"],["3C2005","Dark Ebony"],["3C3910","Camouflage"],["3C4151","Bright Gray"],["3C4443","Cape Cod"],["3C493A","Lunar Green"],["3D0C02","Bean "],["3D2B1F","Bistre"],["3D7D52","Goblin"],["3E0480","Kingfisher Daisy"],["3E1C14","Cedar"],["3E2B23","English Walnut"],["3E2C1C","Black Marlin"],["3E3A44","Ship Gray"],["3EABBF","Pelorous"],["3F2109","Bronze"],["3F2500","Cola"],["3F3002","Madras"],["3F307F","Minsk"],["3F4C3A","Cabbage Pont"],["3F583B","Tom Thumb"],["3F5D53","Mineral Green"],["3FC1AA","Puerto Rico"],["3FFF00","Harlequin"],["401801","Brown Pod"],["40291D","Cork"],["403B38","Masala"],["403D19","Thatch Green"],["405169","Fiord"],["40826D","Viridian"],["40A860","Chateau Green"],["410056","Ripe Plum"],["411F10","Paco"],["412010","Deep Oak"],["413C37","Merlin"],["414257","Gun Powder"],["414C7D","East Bay"],["4169E1","Royal Blue"],["41AA78","Ocean Green"],["420303","Burnt Maroon"],["423921","Lisbon Brown"],["427977","Faded Jade"],["431560","Scarlet Gum"],["433120","Iroko"],["433E37","Armadillo"],["434C59","River Bed"],["436A0D","Green Leaf"],["44012D","Barossa"],["441D00","Morocco Brown"],["444954","Mako"],["454936","Kelp"],["456CAC","San Marino"],["45B1E8","Picton Blue"],["460B41","Loulou"],["462425","Crater Brown"],["465945","Gray Asparagus"],["4682B4","Steel Blue"],["480404","Rustic Red"],["480607","Bulgarian Rose"],["480656","Clairvoyant"],["481C1C","Cocoa Bean"],["483131","Woody Brown"],["483C32","Taupe"],["49170C","Van Cleef"],["492615","Brown Derby"],["49371B","Metallic Bronze"],["495400","Verdun Green"],["496679","Blue Bayoux"],["497183","Bismark"],["4A2A04","Bracken"],["4A3004","Deep Bronze"],["4A3C30","Mondo"],["4A4244","Tundora"],["4A444B","Gravel"],["4A4E5A","Trout"],["4B0082","Pigment Indigo"],["4B5D52","Nandor"],["4C3024","Saddle"],["4C4F56","Abbey"],["4D0135","Blackberry"],["4D0A18","Cab Sav"],["4D1E01","Indian Tan"],["4D282D","Cowboy"],["4D282E","Livid Brown"],["4D3833","Rock"],["4D3D14","Punga"],["4D400F","Bronzetone"],["4D5328","Woodland"],["4E0606","Mahogany"],["4E2A5A","Bossanova"],["4E3B41","Matterhorn"],["4E420C","Bronze Olive"],["4E4562","Mulled Wine"],["4E6649","Axolotl"],["4E7F9E","Wedgewood"],["4EABD1","Shakespeare"],["4F1C70","Honey Flower"],["4F2398","Daisy Bush"],["4F69C6","Indigo"],["4F7942","Fern Green"],["4F9D5D","Fruit Salad"],["4FA83D","Apple"],["504351","Mortar"],["507096","Kashmir Blue"],["507672","Cutty Sark"],["50C878","Emerald"],["514649","Emperor"],["516E3D","Chalet Green"],["517C66","Como"],["51808F","Smalt Blue"],["52001F","Castro"],["520C17","Maroon Oak"],["523C94","Gigas"],["533455","Voodoo"],["534491","Victoria"],["53824B","Hippie Green"],["541012","Heath"],["544333","Judge Gray"],["54534D","Fuscous Gray"],["549019","Vida Loca"],["55280C","Cioccolato"],["555B10","Saratoga"],["556D56","Finlandia"],["5590D9","Havelock Blue"],["56B4BE","Fountain Blue"],["578363","Spring Leaves"],["583401","Saddle Brown"],["585562","Scarpa Flow"],["587156","Cactus"],["589AAF","Hippie Blue"],["591D35","Wine Berry"],["592804","Brown Bramble"],["593737","Congo Brown"],["594433","Millbrook"],["5A6E9C","Waikawa Gray"],["5A87A0","Horizon"],["5B3013","Jambalaya"],["5C0120","Bordeaux"],["5C0536","Mulberry Wood"],["5C2E01","Carnaby Tan"],["5C5D75","Comet"],["5D1E0F","Redwood"],["5D4C51","Don Juan"],["5D5C58","Chicago"],["5D5E37","Verdigris"],["5D7747","Dingley"],["5DA19F","Breaker Bay"],["5E483E","Kabul"],["5E5D3B","Hemlock"],["5F3D26","Irish Coffee"],["5F5F6E","Mid Gray"],["5F6672","Shuttle Gray"],["5FA777","Aqua Forest"],["5FB3AC","Tradewind"],["604913","Horses Neck"],["605B73","Smoky"],["606E68","Corduroy"],["6093D1","Danube"],["612718","Espresso"],["614051","Eggplant"],["615D30","Costa Del Sol"],["61845F","Glade Green"],["622F30","Buccaneer"],["623F2D","Quincy"],["624E9A","Butterfly Bush"],["625119","West Coast"],["626649","Finch"],["639A8F","Patina"],["63B76C","Fern"],["6456B7","Blue Violet"],["646077","Dolphin"],["646463","Storm Dust"],["646A54","Siam"],["646E75","Nevada"],["6495ED","Cornflower Blue"],["64CCDB","Viking"],["65000B","Rosewood"],["651A14","Cherrywood"],["652DC1","Purple Heart"],["657220","Fern Frond"],["65745D","Willow Grove"],["65869F","Hoki"],["660045","Pompadour"],["660099","Purple"],["66023C","Tyrian Purple"],["661010","Dark Tan"],["66B58F","Silver Tree"],["66FF00","Bright Green"],["66FF66","Screamin' Green"],["67032D","Black Rose"],["675FA6","Scampi"],["676662","Ironside Gray"],["678975","Viridian Green"],["67A712","Christi"],["683600","Nutmeg Wood Finish"],["685558","Zambezi"],["685E6E","Salt Box"],["692545","Tawny Port"],["692D54","Finn"],["695F62","Scorpion"],["697E9A","Lynch"],["6A442E","Spice"],["6A5D1B","Himalaya"],["6A6051","Soya Bean"],["6B2A14","Hairy Heath"],["6B3FA0","Royal Purple"],["6B4E31","Shingle Fawn"],["6B5755","Dorado"],["6B8BA2","Bermuda Gray"],["6B8E23","Olive Drab"],["6C3082","Eminence"],["6CDAE7","Turquoise Blue"],["6D0101","Lonestar"],["6D5E54","Pine Cone"],["6D6C6C","Dove Gray"],["6D9292","Juniper"],["6D92A1","Gothic"],["6E0902","Red Oxide"],["6E1D14","Moccaccino"],["6E4826","Pickled Bean"],["6E4B26","Dallas"],["6E6D57","Kokoda"],["6E7783","Pale Sky"],["6F440C","Cafe Royale"],["6F6A61","Flint"],["6F8E63","Highland"],["6F9D02","Limeade"],["6FD0C5","Downy"],["701C1C","Persian Plum"],["704214","Sepia"],["704A07","Antique Bronze"],["704F50","Ferra"],["706555","Coffee"],["708090","Slate Gray"],["711A00","Cedar Wood Finish"],["71291D","Metallic Copper"],["714693","Affair"],["714AB2","Studio"],["715D47","Tobacco Brown"],["716338","Yellow Metal"],["716B56","Peat"],["716E10","Olivetone"],["717486","Storm Gray"],["718080","Sirocco"],["71D9E2","Aquamarine Blue"],["72010F","Venetian Red"],["724A2F","Old Copper"],["726D4E","Go Ben"],["727B89","Raven"],["731E8F","Seance"],["734A12","Raw Umber"],["736C9F","Kimberly"],["736D58","Crocodile"],["737829","Crete"],["738678","Xanadu"],["74640D","Spicy Mustard"],["747D63","Limed Ash"],["747D83","Rolling Stone"],["748881","Blue Smoke"],["749378","Laurel"],["74C365","Mantis"],["755A57","Russett"],["7563A8","Deluge"],["76395D","Cosmic"],["7666C6","Blue Marguerite"],["76BD17","Lima"],["76D7EA","Sky Blue"],["770F05","Dark Burgundy"],["771F1F","Crown of Thorns"],["773F1A","Walnut"],["776F61","Pablo"],["778120","Pacifika"],["779E86","Oxley"],["77DD77","Pastel Green"],["780109","Japanese Maple"],["782D19","Mocha"],["782F16","Peanut"],["78866B","Camouflage Green"],["788A25","Wasabi"],["788BBA","Ship Cove"],["78A39C","Sea Nymph"],["795D4C","Roman Coffee"],["796878","Old Lavender"],["796989","Rum"],["796A78","Fedora"],["796D62","Sandstone"],["79DEEC","Spray"],["7A013A","Siren"],["7A58C1","Fuchsia Blue"],["7A7A7A","Boulder"],["7A89B8","Wild Blue Yonder"],["7AC488","De York"],["7B3801","Red Beech"],["7B3F00","Cinnamon"],["7B6608","Yukon Gold"],["7B7874","Tapa"],["7B7C94","Waterloo "],["7B8265","Flax Smoke"],["7B9F80","Amulet"],["7BA05B","Asparagus"],["7C1C05","Kenyan Copper"],["7C7631","Pesto"],["7C778A","Topaz"],["7C7B7A","Concord"],["7C7B82","Jumbo"],["7C881A","Trendy Green"],["7CA1A6","Gumbo"],["7CB0A1","Acapulco"],["7CB7BB","Neptune"],["7D2C14","Pueblo"],["7DA98D","Bay Leaf"],["7DC8F7","Malibu"],["7DD8C6","Bermuda"],["7E3A15","Copper Canyon"],["7F1734","Claret"],["7F3A02","Peru Tan"],["7F626D","Falcon"],["7F7589","Mobster"],["7F76D3","Moody Blue"],["7FFF00","Chartreuse"],["7FFFD4","Aquamarine"],["800000","Maroon"],["800B47","Rose Bud Cherry"],["801818","Falu Red"],["80341F","Red Robin"],["803790","Vivid Violet"],["80461B","Russet"],["807E79","Friar Gray"],["808000","Olive"],["808080","Gray"],["80B3AE","Gulf Stream"],["80B3C4","Glacier"],["80CCEA","Seagull"],["81422C","Nutmeg"],["816E71","Spicy Pink"],["817377","Empress"],["819885","Spanish Green"],["826F65","Sand Dune"],["828685","Gunsmoke"],["828F72","Battleship Gray"],["831923","Merlot"],["837050","Shadow"],["83AA5D","Chelsea Cucumber"],["83D0C6","Monte Carlo"],["843179","Plum"],["84A0A0","Granny Smith"],["8581D9","Chetwode Blue"],["858470","Bandicoot"],["859FAF","Bali Hai"],["85C4CC","Half Baked"],["860111","Red Devil"],["863C3C","Lotus"],["86483C","Ironstone"],["864D1E","Bull Shot"],["86560A","Rusty Nail"],["868974","Bitter"],["86949F","Regent Gray"],["871550","Disco"],["87756E","Americano"],["877C7B","Hurricane"],["878D91","Oslo Gray"],["87AB39","Sushi"],["885342","Spicy Mix"],["886221","Kumera"],["888387","Suva Gray"],["888D65","Avocado"],["893456","Camelot"],["893843","Solid Pink"],["894367","Cannon Pink"],["897D6D","Makara"],["8A3324","Burnt Umber"],["8A73D6","True V"],["8A8360","Clay Creek"],["8A8389","Monsoon"],["8A8F8A","Stack"],["8AB9F1","Jordy Blue"],["8B00FF","Electric Violet"],["8B0723","Monarch"],["8B6B0B","Corn Harvest"],["8B8470","Olive Haze"],["8B847E","Schooner"],["8B8680","Natural Gray"],["8B9C90","Mantle"],["8B9FEE","Portage"],["8BA690","Envy"],["8BA9A5","Cascade"],["8BE6D8","Riptide"],["8C055E","Cardinal Pink"],["8C472F","Mule Fawn"],["8C5738","Potters Clay"],["8C6495","Trendy Pink"],["8D0226","Paprika"],["8D3D38","Sanguine Brown"],["8D3F3F","Tosca"],["8D7662","Cement"],["8D8974","Granite Green"],["8D90A1","Manatee"],["8DA8CC","Polo Blue"],["8E0000","Red Berry"],["8E4D1E","Rope"],["8E6F70","Opium"],["8E775E","Domino"],["8E8190","Mamba"],["8EABC1","Nepal"],["8F021C","Pohutukawa"],["8F3E33","El Salva"],["8F4B0E","Korma"],["8F8176","Squirrel"],["8FD6B4","Vista Blue"],["900020","Burgundy"],["901E1E","Old Brick"],["907874","Hemp"],["907B71","Almond Frost"],["908D39","Sycamore"],["92000A","Sangria"],["924321","Cumin"],["926F5B","Beaver"],["928573","Stonewall"],["928590","Venus"],["9370DB","Medium Purple"],["93CCEA","Cornflower"],["93DFB8","Algae Green"],["944747","Copper Rust"],["948771","Arrowtown"],["950015","Scarlett"],["956387","Strikemaster"],["959396","Mountain Mist"],["960018","Carmine"],["964B00","Brown"],["967059","Leather"],["9678B6","Purple Mountain's Majesty"],["967BB6","Lavender Purple"],["96A8A1","Pewter"],["96BBAB","Summer Green"],["97605D","Au Chico"],["9771B5","Wisteria"],["97CD2D","Atlantis"],["983D61","Vin Rouge"],["9874D3","Lilac Bush"],["98777B","Bazaar"],["98811B","Hacienda"],["988D77","Pale Oyster"],["98FF98","Mint Green"],["990066","Fresh Eggplant"],["991199","Violet Eggplant"],["991613","Tamarillo"],["991B07","Totem Pole"],["996666","Copper Rose"],["9966CC","Amethyst"],["997A8D","Mountbatten Pink"],["9999CC","Blue Bell"],["9A3820","Prairie Sand"],["9A6E61","Toast"],["9A9577","Gurkha"],["9AB973","Olivine"],["9AC2B8","Shadow Green"],["9B4703","Oregon"],["9B9E8F","Lemon Grass"],["9C3336","Stiletto"],["9D5616","Hawaiian Tan"],["9DACB7","Gull Gray"],["9DC209","Pistachio"],["9DE093","Granny Smith Apple"],["9DE5FF","Anakiwa"],["9E5302","Chelsea Gem"],["9E5B40","Sepia Skin"],["9EA587","Sage"],["9EA91F","Citron"],["9EB1CD","Rock Blue"],["9EDEE0","Morning Glory"],["9F381D","Cognac"],["9F821C","Reef Gold"],["9F9F9C","Star Dust"],["9FA0B1","Santas Gray"],["9FD7D3","Sinbad"],["9FDD8C","Feijoa"],["A02712","Tabasco"],["A1750D","Buttered Rum"],["A1ADB5","Hit Gray"],["A1C50A","Citrus"],["A1DAD7","Aqua Island"],["A1E9DE","Water Leaf"],["A2006D","Flirt"],["A23B6C","Rouge"],["A26645","Cape Palliser"],["A2AAB3","Gray Chateau"],["A2AEAB","Edward"],["A3807B","Pharlap"],["A397B4","Amethyst Smoke"],["A3E3ED","Blizzard Blue"],["A4A49D","Delta"],["A4A6D3","Wistful"],["A4AF6E","Green Smoke"],["A50B5E","Jazzberry Jam"],["A59B91","Zorba"],["A5CB0C","Bahia"],["A62F20","Roof Terracotta"],["A65529","Paarl"],["A68B5B","Barley Corn"],["A69279","Donkey Brown"],["A6A29A","Dawn"],["A72525","Mexican Red"],["A7882C","Luxor Gold"],["A85307","Rich Gold"],["A86515","Reno Sand"],["A86B6B","Coral Tree"],["A8989B","Dusty Gray"],["A899E6","Dull Lavender"],["A8A589","Tallow"],["A8AE9C","Bud"],["A8AF8E","Locust"],["A8BD9F","Norway"],["A8E3BD","Chinook"],["A9A491","Gray Olive"],["A9ACB6","Aluminium"],["A9B2C3","Cadet Blue"],["A9B497","Schist"],["A9BDBF","Tower Gray"],["A9BEF2","Perano"],["A9C6C2","Opal"],["AA375A","Night Shadz"],["AA4203","Fire"],["AA8B5B","Muesli"],["AA8D6F","Sandal"],["AAA5A9","Shady Lady"],["AAA9CD","Logan"],["AAABB7","Spun Pearl"],["AAD6E6","Regent St Blue"],["AAF0D1","Magic Mint"],["AB0563","Lipstick"],["AB3472","Royal Heath"],["AB917A","Sandrift"],["ABA0D9","Cold Purple"],["ABA196","Bronco"],["AC8A56","Limed Oak"],["AC91CE","East Side"],["AC9E22","Lemon Ginger"],["ACA494","Napa"],["ACA586","Hillary"],["ACA59F","Cloudy"],["ACACAC","Silver Chalice"],["ACB78E","Swamp Green"],["ACCBB1","Spring Rain"],["ACDD4D","Conifer"],["ACE1AF","Celadon"],["AD781B","Mandalay"],["ADBED1","Casper"],["ADDFAD","Moss Green"],["ADE6C4","Padua"],["ADFF2F","Green Yellow"],["AE4560","Hippie Pink"],["AE6020","Desert"],["AE809E","Bouquet"],["AF4035","Medium Carmine"],["AF4D43","Apple Blossom"],["AF593E","Brown Rust"],["AF8751","Driftwood"],["AF8F2C","Alpine"],["AF9F1C","Lucky"],["AFA09E","Martini"],["AFB1B8","Bombay"],["AFBDD9","Pigeon Post"],["B04C6A","Cadillac"],["B05D54","Matrix"],["B05E81","Tapestry"],["B06608","Mai Tai"],["B09A95","Del Rio"],["B0E0E6","Powder Blue"],["B0E313","Inch Worm"],["B10000","Bright Red"],["B14A0B","Vesuvius"],["B1610B","Pumpkin Skin"],["B16D52","Santa Fe"],["B19461","Teak"],["B1E2C1","Fringy Flower"],["B1F4E7","Ice Cold"],["B20931","Shiraz"],["B2A1EA","Biloba Flower"],["B32D29","Tall Poppy"],["B35213","Fiery Orange"],["B38007","Hot Toddy"],["B3AF95","Taupe Gray"],["B3C110","La Rioja"],["B43332","Well Read"],["B44668","Blush"],["B4CFD3","Jungle Mist"],["B57281","Turkish Rose"],["B57EDC","Lavender"],["B5A27F","Mongoose"],["B5B35C","Olive Green"],["B5D2CE","Jet Stream"],["B5ECDF","Cruise"],["B6316C","Hibiscus"],["B69D98","Thatch"],["B6B095","Heathered Gray"],["B6BAA4","Eagle"],["B6D1EA","Spindle"],["B6D3BF","Gum Leaf"],["B7410E","Rust"],["B78E5C","Muddy Waters"],["B7A214","Sahara"],["B7A458","Husk"],["B7B1B1","Nobel"],["B7C3D0","Heather"],["B7F0BE","Madang"],["B81104","Milano Red"],["B87333","Copper"],["B8B56A","Gimblet"],["B8C1B1","Green Spring"],["B8C25D","Celery"],["B8E0F9","Sail"],["B94E48","Chestnut"],["B95140","Crail"],["B98D28","Marigold"],["B9C46A","Wild Willow"],["B9C8AC","Rainee"],["BA0101","Guardsman Red"],["BA450C","Rock Spray"],["BA6F1E","Bourbon"],["BA7F03","Pirate Gold"],["BAB1A2","Nomad"],["BAC7C9","Submarine"],["BAEEF9","Charlotte"],["BB3385","Medium Red Violet"],["BB8983","Brandy Rose"],["BBD009","Rio Grande"],["BBD7C1","Surf"],["BCC9C2","Powder Ash"],["BD5E2E","Tuscany"],["BD978E","Quicksand"],["BDB1A8","Silk"],["BDB2A1","Malta"],["BDB3C7","Chatelle"],["BDBBD7","Lavender Gray"],["BDBDC6","French Gray"],["BDC8B3","Clay Ash"],["BDC9CE","Loblolly"],["BDEDFD","French Pass"],["BEA6C3","London Hue"],["BEB5B7","Pink Swan"],["BEDE0D","Fuego"],["BF5500","Rose of Sharon"],["BFB8B0","Tide"],["BFBED8","Blue Haze"],["BFC1C2","Silver Sand"],["BFC921","Key Lime Pie"],["BFDBE2","Ziggurat"],["BFFF00","Lime"],["C02B18","Thunderbird"],["C04737","Mojo"],["C08081","Old Rose"],["C0C0C0","Silver"],["C0D3B9","Pale Leaf"],["C0D8B6","Pixie Green"],["C1440E","Tia Maria"],["C154C1","Fuchsia Pink"],["C1A004","Buddha Gold"],["C1B7A4","Bison Hide"],["C1BAB0","Tea"],["C1BECD","Gray Suit"],["C1D7B0","Sprout"],["C1F07C","Sulu"],["C26B03","Indochine"],["C2955D","Twine"],["C2BDB6","Cotton Seed"],["C2CAC4","Pumice"],["C2E8E5","Jagged Ice"],["C32148","Maroon Flush"],["C3B091","Indian Khaki"],["C3BFC1","Pale Slate"],["C3C3BD","Gray Nickel"],["C3CDE6","Periwinkle Gray"],["C3D1D1","Tiara"],["C3DDF9","Tropical Blue"],["C41E3A","Cardinal"],["C45655","Fuzzy Wuzzy Brown"],["C45719","Orange Roughy"],["C4C4BC","Mist Gray"],["C4D0B0","Coriander"],["C4F4EB","Mint Tulip"],["C54B8C","Mulberry"],["C59922","Nugget"],["C5994B","Tussock"],["C5DBCA","Sea Mist"],["C5E17A","Yellow Green"],["C62D42","Brick Red"],["C6726B","Contessa"],["C69191","Oriental Pink"],["C6A84B","Roti"],["C6C3B5","Ash"],["C6C8BD","Kangaroo"],["C6E610","Las Palmas"],["C7031E","Monza"],["C71585","Red Violet"],["C7BCA2","Coral Reef"],["C7C1FF","Melrose"],["C7C4BF","Cloud"],["C7C9D5","Ghost"],["C7CD90","Pine Glade"],["C7DDE5","Botticelli"],["C88A65","Antique Brass"],["C8A2C8","Lilac"],["C8A528","Hokey Pokey"],["C8AABF","Lily"],["C8B568","Laser"],["C8E3D7","Edgewater"],["C96323","Piper"],["C99415","Pizza"],["C9A0DC","Light Wisteria"],["C9B29B","Rodeo Dust"],["C9B35B","Sundance"],["C9B93B","Earls Green"],["C9C0BB","Silver Rust"],["C9D9D2","Conch"],["C9FFA2","Reef"],["C9FFE5","Aero Blue"],["CA3435","Flush Mahogany"],["CABB48","Turmeric"],["CADCD4","Paris White"],["CAE00D","Bitter Lemon"],["CAE6DA","Skeptic"],["CB8FA9","Viola"],["CBCAB6","Foggy Gray"],["CBD3B0","Green Mist"],["CBDBD6","Nebula"],["CC3333","Persian Red"],["CC5500","Burnt Orange"],["CC7722","Ochre"],["CC8899","Puce"],["CCCAA8","Thistle Green"],["CCCCFF","Periwinkle"],["CCFF00","Electric Lime"],["CD5700","Tenn"],["CD5C5C","Chestnut Rose"],["CD8429","Brandy Punch"],["CDF4FF","Onahau"],["CEB98F","Sorrell Brown"],["CEBABA","Cold Turkey"],["CEC291","Yuma"],["CEC7A7","Chino"],["CFA39D","Eunry"],["CFB53B","Old Gold"],["CFDCCF","Tasman"],["CFE5D2","Surf Crest"],["CFF9F3","Humming Bird"],["CFFAF4","Scandal"],["D05F04","Red Stage"],["D06DA1","Hopbush"],["D07D12","Meteor"],["D0BEF8","Perfume"],["D0C0E5","Prelude"],["D0F0C0","Tea Green"],["D18F1B","Geebung"],["D1BEA8","Vanilla"],["D1C6B4","Soft Amber"],["D1D2CA","Celeste"],["D1D2DD","Mischka"],["D1E231","Pear"],["D2691E","Hot Cinnamon"],["D27D46","Raw Sienna"],["D29EAA","Careys Pink"],["D2B48C","Tan"],["D2DA97","Deco"],["D2F6DE","Blue Romance"],["D2F8B0","Gossip"],["D3CBBA","Sisal"],["D3CDC5","Swirl"],["D47494","Charm"],["D4B6AF","Clam Shell"],["D4BF8D","Straw"],["D4C4A8","Akaroa"],["D4CD16","Bird Flower"],["D4D7D9","Iron"],["D4DFE2","Geyser"],["D4E2FC","Hawkes Blue"],["D54600","Grenadier"],["D591A4","Can Can"],["D59A6F","Whiskey"],["D5D195","Winter Hazel"],["D5F6E3","Granny Apple"],["D69188","My Pink"],["D6C562","Tacha"],["D6CEF6","Moon Raker"],["D6D6D1","Quill Gray"],["D6FFDB","Snowy Mint"],["D7837F","New York Pink"],["D7C498","Pavlova"],["D7D0FF","Fog"],["D84437","Valencia"],["D87C63","Japonica"],["D8BFD8","Thistle"],["D8C2D5","Maverick"],["D8FCFA","Foam"],["D94972","Cabaret"],["D99376","Burning Sand"],["D9B99B","Cameo"],["D9D6CF","Timberwolf"],["D9DCC1","Tana"],["D9E4F5","Link Water"],["D9F7FF","Mabel"],["DA3287","Cerise"],["DA5B38","Flame Pea"],["DA6304","Bamboo"],["DA6A41","Red Damask"],["DA70D6","Orchid"],["DA8A67","Copperfield"],["DAA520","Golden Grass"],["DAECD6","Zanah"],["DAF4F0","Iceberg"],["DAFAFF","Oyster Bay"],["DB5079","Cranberry"],["DB9690","Petite Orchid"],["DB995E","Di Serria"],["DBDBDB","Alto"],["DBFFF8","Frosted Mint"],["DC143C","Crimson"],["DC4333","Punch"],["DCB20C","Galliano"],["DCB4BC","Blossom"],["DCD747","Wattle"],["DCD9D2","Westar"],["DCDDCC","Moon Mist"],["DCEDB4","Caper"],["DCF0EA","Swans Down"],["DDD6D5","Swiss Coffee"],["DDF9F1","White Ice"],["DE3163","Cerise Red"],["DE6360","Roman"],["DEA681","Tumbleweed"],["DEBA13","Gold Tips"],["DEC196","Brandy"],["DECBC6","Wafer"],["DED4A4","Sapling"],["DED717","Barberry"],["DEE5C0","Beryl Green"],["DEF5FF","Pattens Blue"],["DF73FF","Heliotrope"],["DFBE6F","Apache"],["DFCD6F","Chenin"],["DFCFDB","Lola"],["DFECDA","Willow Brook"],["DFFF00","Chartreuse Yellow"],["E0B0FF","Mauve"],["E0B646","Anzac"],["E0B974","Harvest Gold"],["E0C095","Calico"],["E0FFFF","Baby Blue"],["E16865","Sunglo"],["E1BC64","Equator"],["E1C0C8","Pink Flare"],["E1E6D6","Periglacial Blue"],["E1EAD4","Kidnapper"],["E1F6E8","Tara"],["E25465","Mandy"],["E2725B","Terracotta"],["E28913","Golden Bell"],["E292C0","Shocking"],["E29418","Dixie"],["E29CD2","Light Orchid"],["E2D8ED","Snuff"],["E2EBED","Mystic"],["E2F3EC","Apple Green"],["E30B5C","Razzmatazz"],["E32636","Alizarin Crimson"],["E34234","Cinnabar"],["E3BEBE","Cavern Pink"],["E3F5E1","Peppermint"],["E3F988","Mindaro"],["E47698","Deep Blush"],["E49B0F","Gamboge"],["E4C2D5","Melanie"],["E4CFDE","Twilight"],["E4D1C0","Bone"],["E4D422","Sunflower"],["E4D5B7","Grain Brown"],["E4D69B","Zombie"],["E4F6E7","Frostee"],["E4FFD1","Snow Flurry"],["E52B50","Amaranth"],["E5841B","Zest"],["E5CCC9","Dust Storm"],["E5D7BD","Stark White"],["E5D8AF","Hampton"],["E5E0E1","Bon Jour"],["E5E5E5","Mercury"],["E5F9F6","Polar"],["E64E03","Trinidad"],["E6BE8A","Gold Sand"],["E6BEA5","Cashmere"],["E6D7B9","Double Spanish White"],["E6E4D4","Satin Linen"],["E6F2EA","Harp"],["E6F8F3","Off Green"],["E6FFE9","Hint of Green"],["E6FFFF","Tranquil"],["E77200","Mango Tango"],["E7730A","Christine"],["E79F8C","Tonys Pink"],["E79FC4","Kobi"],["E7BCB4","Rose Fog"],["E7BF05","Corn"],["E7CD8C","Putty"],["E7ECE6","Gray Nurse"],["E7F8FF","Lily White"],["E7FEFF","Bubbles"],["E89928","Fire Bush"],["E8B9B3","Shilo"],["E8E0D5","Pearl Bush"],["E8EBE0","Green White"],["E8F1D4","Chrome White"],["E8F2EB","Gin"],["E8F5F2","Aqua Squeeze"],["E96E00","Clementine"],["E97451","Burnt Sienna"],["E97C07","Tahiti Gold"],["E9CECD","Oyster Pink"],["E9D75A","Confetti"],["E9E3E3","Ebb"],["E9F8ED","Ottoman"],["E9FFFD","Clear Day"],["EA88A8","Carissma"],["EAAE69","Porsche"],["EAB33B","Tulip Tree"],["EAC674","Rob Roy"],["EADAB8","Raffia"],["EAE8D4","White Rock"],["EAF6EE","Panache"],["EAF6FF","Solitude"],["EAF9F5","Aqua Spring"],["EAFFFE","Dew"],["EB9373","Apricot"],["EBC2AF","Zinnwaldite"],["ECA927","Fuel Yellow"],["ECC54E","Ronchi"],["ECC7EE","French Lilac"],["ECCDB9","Just Right"],["ECE090","Wild Rice"],["ECEBBD","Fall Green"],["ECEBCE","Aths Special"],["ECF245","Starship"],["ED0A3F","Red Ribbon"],["ED7A1C","Tango"],["ED9121","Carrot Orange"],["ED989E","Sea Pink"],["EDB381","Tacao"],["EDC9AF","Desert Sand"],["EDCDAB","Pancho"],["EDDCB1","Chamois"],["EDEA99","Primrose"],["EDF5DD","Frost"],["EDF5F5","Aqua Haze"],["EDF6FF","Zumthor"],["EDF9F1","Narvik"],["EDFC84","Honeysuckle"],["EE82EE","Lavender Magenta"],["EEC1BE","Beauty Bush"],["EED794","Chalky"],["EED9C4","Almond"],["EEDC82","Flax"],["EEDEDA","Bizarre"],["EEE3AD","Double Colonial White"],["EEEEE8","Cararra"],["EEEF78","Manz"],["EEF0C8","Tahuna Sands"],["EEF0F3","Athens Gray"],["EEF3C3","Tusk"],["EEF4DE","Loafer"],["EEF6F7","Catskill White"],["EEFDFF","Twilight Blue"],["EEFF9A","Jonquil"],["EEFFE2","Rice Flower"],["EF863F","Jaffa"],["EFEFEF","Gallery"],["EFF2F3","Porcelain"],["F091A9","Mauvelous"],["F0D52D","Golden Dream"],["F0DB7D","Golden Sand"],["F0DC82","Buff"],["F0E2EC","Prim"],["F0E68C","Khaki"],["F0EEFD","Selago"],["F0EEFF","Titan White"],["F0F8FF","Alice Blue"],["F0FCEA","Feta"],["F18200","Gold Drop"],["F19BAB","Wewak"],["F1E788","Sahara Sand"],["F1E9D2","Parchment"],["F1E9FF","Blue Chalk"],["F1EEC1","Mint Julep"],["F1F1F1","Seashell"],["F1F7F2","Saltpan"],["F1FFAD","Tidal"],["F1FFC8","Chiffon"],["F2552A","Flamingo"],["F28500","Tangerine"],["F2C3B2","Mandys Pink"],["F2F2F2","Concrete"],["F2FAFA","Black Squeeze"],["F34723","Pomegranate"],["F3AD16","Buttercup"],["F3D69D","New Orleans"],["F3D9DF","Vanilla Ice"],["F3E7BB","Sidecar"],["F3E9E5","Dawn Pink"],["F3EDCF","Wheatfield"],["F3FB62","Canary"],["F3FBD4","Orinoco"],["F3FFD8","Carla"],["F400A1","Hollywood Cerise"],["F4A460","Sandy brown"],["F4C430","Saffron"],["F4D81C","Ripe Lemon"],["F4EBD3","Janna"],["F4F2EE","Pampas"],["F4F4F4","Wild Sand"],["F4F8FF","Zircon"],["F57584","Froly"],["F5C85C","Cream Can"],["F5C999","Manhattan"],["F5D5A0","Maize"],["F5DEB3","Wheat"],["F5E7A2","Sandwisp"],["F5E7E2","Pot Pourri"],["F5E9D3","Albescent White"],["F5EDEF","Soft Peach"],["F5F3E5","Ecru White"],["F5F5DC","Beige"],["F5FB3D","Golden Fizz"],["F5FFBE","Australian Mint"],["F64A8A","French Rose"],["F653A6","Brilliant Rose"],["F6A4C9","Illusion"],["F6F0E6","Merino"],["F6F7F7","Black Haze"],["F6FFDC","Spring Sun"],["F7468A","Violet Red"],["F77703","Chilean Fire"],["F77FBE","Persian Pink"],["F7B668","Rajah"],["F7C8DA","Azalea"],["F7DBE6","We Peep"],["F7F2E1","Quarter Spanish White"],["F7F5FA","Whisper"],["F7FAF7","Snow Drift"],["F8B853","Casablanca"],["F8C3DF","Chantilly"],["F8D9E9","Cherub"],["F8DB9D","Marzipan"],["F8DD5C","Energy Yellow"],["F8E4BF","Givry"],["F8F0E8","White Linen"],["F8F4FF","Magnolia"],["F8F6F1","Spring Wood"],["F8F7DC","Coconut Cream"],["F8F7FC","White Lilac"],["F8F8F7","Desert Storm"],["F8F99C","Texas"],["F8FACD","Corn Field"],["F8FDD3","Mimosa"],["F95A61","Carnation"],["F9BF58","Saffron Mango"],["F9E0ED","Carousel Pink"],["F9E4BC","Dairy Cream"],["F9E663","Portica"],["F9EAF3","Amour"],["F9F8E4","Rum Swizzle"],["F9FF8B","Dolly"],["F9FFF6","Sugar Cane"],["FA7814","Ecstasy"],["FA9D5A","Tan Hide"],["FAD3A2","Corvette"],["FADFAD","Peach Yellow"],["FAE600","Turbo"],["FAEAB9","Astra"],["FAECCC","Champagne"],["FAF0E6","Linen"],["FAF3F0","Fantasy"],["FAF7D6","Citrine White"],["FAFAFA","Alabaster"],["FAFDE4","Hint of Yellow"],["FAFFA4","Milan"],["FB607F","Brink Pink"],["FB8989","Geraldine"],["FBA0E3","Lavender Rose"],["FBA129","Sea Buckthorn"],["FBAC13","Sun"],["FBAED2","Lavender Pink"],["FBB2A3","Rose Bud"],["FBBEDA","Cupid"],["FBCCE7","Classic Rose"],["FBCEB1","Apricot Peach"],["FBE7B2","Banana Mania"],["FBE870","Marigold Yellow"],["FBE96C","Festival"],["FBEA8C","Sweet Corn"],["FBEC5D","Candy Corn"],["FBF9F9","Hint of Red"],["FBFFBA","Shalimar"],["FC0FC0","Shocking Pink"],["FC80A5","Tickle Me Pink"],["FC9C1D","Tree Poppy"],["FCC01E","Lightning Yellow"],["FCD667","Goldenrod"],["FCD917","Candlelight"],["FCDA98","Cherokee"],["FCF4D0","Double Pearl Lusta"],["FCF4DC","Pearl Lusta"],["FCF8F7","Vista White"],["FCFBF3","Bianca"],["FCFEDA","Moon Glow"],["FCFFE7","China Ivory"],["FCFFF9","Ceramic"],["FD0E35","Torch Red"],["FD5B78","Wild Watermelon"],["FD7B33","Crusta"],["FD7C07","Sorbus"],["FD9FA2","Sweet Pink"],["FDD5B1","Light Apricot"],["FDD7E4","Pig Pink"],["FDE1DC","Cinderella"],["FDE295","Golden Glow"],["FDE910","Lemon"],["FDF5E6","Old Lace"],["FDF6D3","Half Colonial White"],["FDF7AD","Drover"],["FDFEB8","Pale Prim"],["FDFFD5","Cumulus"],["FE28A2","Persian Rose"],["FE4C40","Sunset Orange"],["FE6F5E","Bittersweet"],["FE9D04","California"],["FEA904","Yellow Sea"],["FEBAAD","Melon"],["FED33C","Bright Sun"],["FED85D","Dandelion"],["FEDB8D","Salomie"],["FEE5AC","Cape Honey"],["FEEBF3","Remy"],["FEEFCE","Oasis"],["FEF0EC","Bridesmaid"],["FEF2C7","Beeswax"],["FEF3D8","Bleach White"],["FEF4CC","Pipi"],["FEF4DB","Half Spanish White"],["FEF4F8","Wisp Pink"],["FEF5F1","Provincial Pink"],["FEF7DE","Half Dutch White"],["FEF8E2","Solitaire"],["FEF8FF","White Pointer"],["FEF9E3","Off Yellow"],["FEFCED","Orange White"],["FF0000","Red"],["FF007F","Rose"],["FF00CC","Purple Pizzazz"],["FF00FF","Magenta / Fuchsia"],["FF2400","Scarlet"],["FF3399","Wild Strawberry"],["FF33CC","Razzle Dazzle Rose"],["FF355E","Radical Red"],["FF3F34","Red Orange"],["FF4040","Coral Red"],["FF4D00","Vermilion"],["FF4F00","International Orange"],["FF6037","Outrageous Orange"],["FF6600","Blaze Orange"],["FF66FF","Pink Flamingo"],["FF681F","Orange"],["FF69B4","Hot Pink"],["FF6B53","Persimmon"],["FF6FFF","Blush Pink"],["FF7034","Burning Orange"],["FF7518","Pumpkin"],["FF7D07","Flamenco"],["FF7F00","Flush Orange"],["FF7F50","Coral"],["FF8C69","Salmon"],["FF9000","Pizazz"],["FF910F","West Side"],["FF91A4","Pink Salmon"],["FF9933","Neon Carrot"],["FF9966","Atomic Tangerine"],["FF9980","Vivid Tangerine"],["FF9E2C","Sunshade"],["FFA000","Orange Peel"],["FFA194","Mona Lisa"],["FFA500","Web Orange"],["FFA6C9","Carnation Pink"],["FFAB81","Hit Pink"],["FFAE42","Yellow Orange"],["FFB0AC","Cornflower Lilac"],["FFB1B3","Sundown"],["FFB31F","My Sin"],["FFB555","Texas Rose"],["FFB7D5","Cotton Candy"],["FFB97B","Macaroni and Cheese"],["FFBA00","Selective Yellow"],["FFBD5F","Koromiko"],["FFBF00","Amber"],["FFC0A8","Wax Flower"],["FFC0CB","Pink"],["FFC3C0","Your Pink"],["FFC901","Supernova"],["FFCBA4","Flesh"],["FFCC33","Sunglow"],["FFCC5C","Golden Tainoi"],["FFCC99","Peach Orange"],["FFCD8C","Chardonnay"],["FFD1DC","Pastel Pink"],["FFD2B7","Romantic"],["FFD38C","Grandis"],["FFD700","Gold"],["FFD800","School bus Yellow"],["FFD8D9","Cosmos"],["FFDB58","Mustard"],["FFDCD6","Peach Schnapps"],["FFDDAF","Caramel"],["FFDDCD","Tuft Bush"],["FFDDCF","Watusi"],["FFDDF4","Pink Lace"],["FFDEAD","Navajo White"],["FFDEB3","Frangipani"],["FFE1DF","Pippin"],["FFE1F2","Pale Rose"],["FFE2C5","Negroni"],["FFE5A0","Cream Brulee"],["FFE5B4","Peach"],["FFE6C7","Tequila"],["FFE772","Kournikova"],["FFEAC8","Sandy Beach"],["FFEAD4","Karry"],["FFEC13","Broom"],["FFEDBC","Colonial White"],["FFEED8","Derby"],["FFEFA1","Vis Vis"],["FFEFC1","Egg White"],["FFEFD5","Papaya Whip"],["FFEFEC","Fair Pink"],["FFF0DB","Peach Cream"],["FFF0F5","Lavender blush"],["FFF14F","Gorse"],["FFF1B5","Buttermilk"],["FFF1D8","Pink Lady"],["FFF1EE","Forget Me Not"],["FFF1F9","Tutu"],["FFF39D","Picasso"],["FFF3F1","Chardon"],["FFF46E","Paris Daisy"],["FFF4CE","Barley White"],["FFF4DD","Egg Sour"],["FFF4E0","Sazerac"],["FFF4E8","Serenade"],["FFF4F3","Chablis"],["FFF5EE","Seashell Peach"],["FFF5F3","Sauvignon"],["FFF6D4","Milk Punch"],["FFF6DF","Varden"],["FFF6F5","Rose White"],["FFF8D1","Baja White"],["FFF9E2","Gin Fizz"],["FFF9E6","Early Dawn"],["FFFACD","Lemon Chiffon"],["FFFAF4","Bridal Heath"],["FFFBDC","Scotch Mist"],["FFFBF9","Soapstone"],["FFFC99","Witch Haze"],["FFFCEA","Buttery White"],["FFFCEE","Island Spice"],["FFFDD0","Cream"],["FFFDE6","Chilean Heath"],["FFFDE8","Travertine"],["FFFDF3","Orchid White"],["FFFDF4","Quarter Pearl Lusta"],["FFFEE1","Half and Half"],["FFFEEC","Apricot White"],["FFFEF0","Rice Cake"],["FFFEF6","Black White"],["FFFEFD","Romance"],["FFFF00","Yellow"],["FFFF66","Laser Lemon"],["FFFF99","Pale Canary"],["FFFFB4","Portafino"],["FFFFF0","Ivory"],["FFFFFF","White"]] +};ntc.init();