18777 lines
905 KiB
JavaScript
18777 lines
905 KiB
JavaScript
var refData = {
|
|
"project": {
|
|
"name": "p5",
|
|
"description": "",
|
|
"version": "0.4.23",
|
|
"url": ""
|
|
},
|
|
"files": {
|
|
"src/3d/3d_primitives.js": {
|
|
"name": "src/3d/3d_primitives.js",
|
|
"modules": {
|
|
"3D Primitives": 1
|
|
},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"namespaces": {}
|
|
},
|
|
"src/3d/camera.js": {
|
|
"name": "src/3d/camera.js",
|
|
"modules": {
|
|
"Camera": 1
|
|
},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"namespaces": {}
|
|
},
|
|
"src/3d/light.js": {
|
|
"name": "src/3d/light.js",
|
|
"modules": {
|
|
"Lights": 1
|
|
},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"namespaces": {}
|
|
},
|
|
"src/3d/material.js": {
|
|
"name": "src/3d/material.js",
|
|
"modules": {
|
|
"Material": 1
|
|
},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"namespaces": {}
|
|
},
|
|
"src/3d/p5.Geometry3D.js": {
|
|
"name": "src/3d/p5.Geometry3D.js",
|
|
"modules": {},
|
|
"classes": {},
|
|
"fors": {},
|
|
"namespaces": {}
|
|
},
|
|
"src/3d/p5.Matrix.js": {
|
|
"name": "src/3d/p5.Matrix.js",
|
|
"modules": {},
|
|
"classes": {},
|
|
"fors": {},
|
|
"namespaces": {}
|
|
},
|
|
"src/3d/p5.Renderer3D.js": {
|
|
"name": "src/3d/p5.Renderer3D.js",
|
|
"modules": {},
|
|
"classes": {},
|
|
"fors": {},
|
|
"namespaces": {}
|
|
},
|
|
"src/3d/retainedMode3D.js": {
|
|
"name": "src/3d/retainedMode3D.js",
|
|
"modules": {},
|
|
"classes": {},
|
|
"fors": {},
|
|
"namespaces": {}
|
|
},
|
|
"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/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/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": {
|
|
"Shape": {
|
|
"name": "Shape",
|
|
"submodules": {
|
|
"2D Primitives": 1,
|
|
"Curves": 1,
|
|
"Vertex": 1
|
|
},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"namespaces": {}
|
|
},
|
|
"3D Primitives": {
|
|
"name": "3D Primitives",
|
|
"submodules": {},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"is_submodule": 1,
|
|
"namespaces": {},
|
|
"module": "IO",
|
|
"namespace": "",
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 1,
|
|
"requires": [
|
|
"core",
|
|
"p5.Geometry3D"
|
|
]
|
|
},
|
|
"Lights, Camera": {
|
|
"name": "Lights, Camera",
|
|
"submodules": {
|
|
"Camera": 1,
|
|
"Lights": 1,
|
|
"Material": 1
|
|
},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"namespaces": {}
|
|
},
|
|
"Camera": {
|
|
"name": "Camera",
|
|
"submodules": {},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"is_submodule": 1,
|
|
"namespaces": {},
|
|
"module": "Lights, Camera",
|
|
"namespace": "",
|
|
"file": "src/3d/camera.js",
|
|
"line": 1,
|
|
"requires": [
|
|
"core"
|
|
]
|
|
},
|
|
"Lights": {
|
|
"name": "Lights",
|
|
"submodules": {},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"is_submodule": 1,
|
|
"namespaces": {},
|
|
"module": "Lights, Camera",
|
|
"namespace": "",
|
|
"file": "src/3d/light.js",
|
|
"line": 1,
|
|
"requires": [
|
|
"core"
|
|
]
|
|
},
|
|
"Material": {
|
|
"name": "Material",
|
|
"submodules": {},
|
|
"classes": {},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"is_submodule": 1,
|
|
"namespaces": {},
|
|
"module": "Lights, Camera",
|
|
"namespace": "",
|
|
"file": "src/3d/material.js",
|
|
"line": 1,
|
|
"requires": [
|
|
"core"
|
|
]
|
|
},
|
|
"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\nInternally 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\nWe 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."
|
|
},
|
|
"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"
|
|
]
|
|
},
|
|
"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 <a href=\"http://p5js.org/libraries/\">p5.dom library</a>.\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."
|
|
},
|
|
"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."
|
|
},
|
|
"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<br><br>\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<br><br>\nThe methods described below allow easy access to the image's pixels and\nalpha channel and simplify the process of compositing.\n<br><br>\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."
|
|
},
|
|
"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": {
|
|
"3D Primitives": 1,
|
|
"Input": 1,
|
|
"Output": 1,
|
|
"Table": 1
|
|
},
|
|
"classes": {
|
|
"p5": 1,
|
|
"p5.Table": 1,
|
|
"p5.TableRow": 1
|
|
},
|
|
"fors": {
|
|
"p5": 1
|
|
},
|
|
"namespaces": {},
|
|
"file": "src/io/p5.TableRow.js",
|
|
"line": 11
|
|
},
|
|
"Input": {
|
|
"name": "Input",
|
|
"submodules": {
|
|
"Time & Date": 1
|
|
},
|
|
"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": 869
|
|
},
|
|
"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."
|
|
},
|
|
"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<br><br>\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<br><br>\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."
|
|
},
|
|
"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.",
|
|
"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": "Input",
|
|
"namespace": "",
|
|
"file": "src/utilities/time_date.js",
|
|
"line": 1,
|
|
"requires": [
|
|
"core"
|
|
]
|
|
},
|
|
"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": 1979,
|
|
"description": "<p>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.</p>\n<p>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<a href=\"https://github.com/processing/p5.js/wiki/Beyond-the-canvas\">\nbeyond the canvas tutorial</a> for a full overview of how this addon works.\n\n<p>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\n<a href=\"http://p5js.org/libraries/#using-a-library\">using a library</a>\nsection for information on how to include this library. p5.dom comes with\n<a href=\"http://p5js.org/download\">p5 complete</a> or you can download the single file\n<a href=\"https://raw.githubusercontent.com/lmccart/p5.js/master/lib/addons/p5.dom.js\">\nhere</a>.</p>\n<p>See <a href=\"https://github.com/processing/p5.js/wiki/Beyond-the-canvas\">tutorial: beyond the canvas</a>\nfor more info on how to use this libary.</a>",
|
|
"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 <a href=\"http://caniuse.com/audio-api\"\ntarget=\"_blank\">Web Audio</a> functionality including audio input,\nplayback, analysis and synthesis.\n<br/><br/>\n<a href=\"#/p5.SoundFile\"><b>p5.SoundFile</b></a>: Load and play sound files.<br/>\n<a href=\"#/p5.Amplitude\"><b>p5.Amplitude</b></a>: Get the current volume of a sound.<br/>\n<a href=\"#/p5.AudioIn\"><b>p5.AudioIn</b></a>: Get sound from an input source, typically\n a computer microphone.<br/>\n<a href=\"#/p5.FFT\"><b>p5.FFT</b></a>: Analyze the frequency of sound. Returns\n results from the frequency spectrum or time domain (waveform).<br/>\n<a href=\"#/p5.Oscillator\"><b>p5.Oscillator</b></a>: Generate Sine,\n Triangle, Square and Sawtooth waveforms. Base class of\n <a href=\"#/p5.Noise\">p5.Noise</a> and <a href=\"#/p5.Pulse\">p5.Pulse</a>.\n <br/>\n<a href=\"#/p5.Env\"><b>p5.Env</b></a>: 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.<br/>\n<a href=\"#/p5.Delay\"><b>p5.Delay</b></a>: A delay effect with\n parameters for feedback, delayTime, and lowpass filter.<br/>\n<a href=\"#/p5.Filter\"><b>p5.Filter</b></a>: Filter the frequency range of a\n sound.\n<br/>\n<a href=\"#/p5.Reverb\"><b>p5.Reverb</b></a>: Add reverb to a sound by specifying\n duration and decay. <br/>\n<b><a href=\"#/p5.Convolver\">p5.Convolver</a>:</b> Extends\n<a href=\"#/p5.Reverb\">p5.Reverb</a> to simulate the sound of real\n physical spaces through convolution.<br/>\n<b><a href=\"#/p5.SoundRecorder\">p5.SoundRecorder</a></b>: Record sound for playback \n / save the .wav file.\n<b><a href=\"#/p5.Phrase\">p5.Phrase</a></b>, <b><a href=\"#/p5.Part\">p5.Part</a></b> and\n<b><a href=\"#/p5.Score\">p5.Score</a></b>: Compose musical sequences.\n<br/><br/>\np5.sound is on <a href=\"https://github.com/therewasaguy/p5.sound/\">GitHub</a>.\nDownload the latest version \n<a href=\"https://github.com/therewasaguy/p5.sound/blob/master/lib/p5.sound.js\">here</a>.",
|
|
"tag": "main",
|
|
"itemtype": "main"
|
|
}
|
|
},
|
|
"classes": {
|
|
"p5": {
|
|
"name": "p5",
|
|
"shortname": "p5",
|
|
"classitems": [],
|
|
"plugins": [],
|
|
"extensions": [],
|
|
"plugin_for": [],
|
|
"extension_for": [],
|
|
"module": "IO",
|
|
"submodule": "Output",
|
|
"namespace": ""
|
|
},
|
|
"p5.Color": {
|
|
"name": "p5.Color",
|
|
"shortname": "p5.Color",
|
|
"classitems": [],
|
|
"plugins": [],
|
|
"extensions": [],
|
|
"plugin_for": [],
|
|
"extension_for": [],
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading",
|
|
"namespace": "",
|
|
"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\nInternally 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\nWe 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.",
|
|
"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 <a href=\"http://p5js.org/libraries/\">p5.dom library</a>.\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.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "elt",
|
|
"description": "DOM node that is wrapped",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "pInst",
|
|
"description": "pointer to p5 instance",
|
|
"type": "Object",
|
|
"optional": true
|
|
}
|
|
]
|
|
},
|
|
"p5.Graphics": {
|
|
"name": "p5.Graphics",
|
|
"shortname": "p5.Graphics",
|
|
"classitems": [],
|
|
"plugins": [],
|
|
"extensions": [],
|
|
"plugin_for": [],
|
|
"extension_for": [],
|
|
"module": "Rendering",
|
|
"submodule": "Rendering",
|
|
"namespace": "",
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"extends": "p5.Element",
|
|
"params": [
|
|
{
|
|
"name": "elt",
|
|
"description": "DOM node that is wrapped",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "pInst",
|
|
"description": "pointer to p5 instance",
|
|
"type": "Object",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "whether",
|
|
"description": "we're using it as main canvas",
|
|
"type": "Boolean"
|
|
}
|
|
]
|
|
},
|
|
"p5.Renderer": {
|
|
"name": "p5.Renderer",
|
|
"shortname": "p5.Renderer",
|
|
"classitems": [],
|
|
"plugins": [],
|
|
"extensions": [],
|
|
"plugin_for": [],
|
|
"extension_for": [],
|
|
"module": "Rendering",
|
|
"submodule": "Rendering",
|
|
"namespace": "",
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"extends": "p5.Element",
|
|
"params": [
|
|
{
|
|
"name": "elt",
|
|
"description": "DOM node that is wrapped",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "pInst",
|
|
"description": "pointer to p5 instance",
|
|
"type": "Object",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "whether",
|
|
"description": "we're using it as main canvas",
|
|
"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<br><br>\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<br><br>\nThe methods described below allow easy access to the image's pixels and\nalpha channel and simplify the process of compositing.\n<br><br>\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.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "width",
|
|
"description": "",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "height",
|
|
"description": "",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "pInst",
|
|
"description": "An instance of a p5 sketch.",
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "rows",
|
|
"description": "An array of p5.TableRow objects",
|
|
"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\nA Table Row contains both an ordered array, and an unordered\nJSON object.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "optional: populate the row with a\n string of values, separated by the\n separator",
|
|
"type": "String",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "separator",
|
|
"description": "comma separated values (csv) by default",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
]
|
|
},
|
|
"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<br><br>\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<br><br>\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.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "z component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
]
|
|
},
|
|
"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",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "pInst",
|
|
"description": "pointer to p5 instance",
|
|
"type": "Object",
|
|
"optional": true
|
|
}
|
|
]
|
|
},
|
|
"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": 1492,
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "elt",
|
|
"description": "DOM node that is wrapped",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "pInst",
|
|
"description": "pointer to p5 instance",
|
|
"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": 1979,
|
|
"description": "Base class for a file\nUsing this for createFileInput",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "file",
|
|
"description": "File that is wrapped",
|
|
"type": "File"
|
|
},
|
|
{
|
|
"name": "pInst",
|
|
"description": "pointer to p5 instance",
|
|
"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": "<p>SoundFile object with a path to a file.</p>\n\n<p>The p5.SoundFile may not be available immediately because\nit loads the file information asynchronously.</p>\n \n<p>To do something with the sound as soon as it loads\npass the name of a function as the second parameter.</p>\n\n<p>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.</p>",
|
|
"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.",
|
|
"type": "String/Array"
|
|
},
|
|
{
|
|
"name": "successCallback",
|
|
"description": "Name of a function to call once file loads",
|
|
"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.",
|
|
"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.",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "p5.SoundFile Object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
" \n<div><code>\n\nfunction preload() {\n mySound = loadSound('assets/doorbell.mp3');\n}\n\nfunction setup() {\n mySound.setVolume(0.1);\n mySound.play();\n}\n \n </code></div>"
|
|
]
|
|
},
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "smoothing",
|
|
"description": "between 0.0 and .999 to smooth\n amplitude readings (defaults to 0)",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Amplitude Object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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": "<p>FFT (Fast Fourier Transform) is an analysis algorithm that\nisolates individual\n<a href=\"https://en.wikipedia.org/wiki/Audio_frequency\">\naudio frequencies</a> within a waveform.</p>\n\n<p>Once instantiated, a p5.FFT object can return an array based on\ntwo types of analyses: <br> • <code>FFT.waveform()</code> 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.<br>\n• <code>FFT.analyze() </code> 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 <code>getEnergy()</code> to measure amplitude at specific\nfrequencies, or within a range of frequencies. </p>\n\n<p>FFT analyzes a very short snapshot of sound called a sample\nbuffer. It returns an array of amplitude measurements, referred\nto as <code>bins</code>. 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.</p>",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "smoothing",
|
|
"description": "Smooth results of Freq Spectrum.\n 0.0 < smoothing < 1.0.\n Defaults to 0.8.",
|
|
"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.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "FFT Object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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": "<p>p5.Signal is a constant audio-rate signal used by p5.Oscillator\nand p5.Envelope for modulation math.</p>\n\n<p>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.</p.\n\n<p>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\n<a href='http://bit.ly/1oIoEng' target=_'blank'>tone.js.</a></p>",
|
|
"is_constructor": 1,
|
|
"return": {
|
|
"description": "A Signal object from the Tone.js library",
|
|
"type": "Tone.Signal"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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": "<p>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).</p> \n\n<p>Set the type of oscillation with setType(), or by creating a\nspecific oscillator.</p> For example:\n<code>new p5.SinOsc(freq)</code>\n<code>new p5.TriOsc(freq)</code>\n<code>new p5.SqrOsc(freq)</code>\n<code>new p5.SawOsc(freq)</code>.\n</p>",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "frequency defaults to 440Hz",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "type",
|
|
"description": "type of oscillator. Options:\n 'sine' (default), 'triangle',\n 'sawtooth', 'square'",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Oscillator object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code> </div>"
|
|
]
|
|
},
|
|
"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": "<p>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 (\n<a href=\"https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg\">ADSR</a>\n). Envelopes can also control other Web Audio Parameters—for example, a p5.Env can \ncontrol an Oscillator's frequency like this: <code>osc.freq(env)</code>.</p>\n<p>Use <code><a href=\"#/p5.Env/setRange\">setRange</a></code> to change the attack/release level.\nUse <code><a href=\"#/p5.Env/setADSR\">setADSR</a></code> to change attackTime, decayTime, sustainPercent and releaseTime.</p>\n<p>Use the <code><a href=\"#/p5.Env/play\">play</a></code> method to play the entire envelope,\nthe <code><a href=\"#/p5.Env/ramp\">ramp</a></code> method for a pingable trigger,\nor <code><a href=\"#/p5.Env/triggerAttack\">triggerAttack</a></code>/\n<code><a href=\"#/p5.Env/triggerRelease\">triggerRelease</a></code> to trigger noteOn/noteOff.</p>",
|
|
"is_constructor": 1,
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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 <a href=\"\nhttp://p5js.org/reference/#/p5.Oscillator\">\n<code>p5.Oscillator</code> for a full list of methods.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "Frequency in oscillations per second (Hz)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "w",
|
|
"description": "Width between the pulses (0 to 1.0,\n defaults to 0)",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "type",
|
|
"description": "Type of noise can be 'white' (default),\n 'brown' or 'pink'.",
|
|
"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": "<p>Get audio from an input, i.e. your computer's microphone.</p>\n\n<p>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.</p>\n\n<p>If you want to hear the AudioIn, use the .connect() method. \nAudioIn does not connect to p5.sound output by default to prevent\nfeedback.</p> \n\n<p><em>Note: This uses the <a href=\"http://caniuse.com/stream\">getUserMedia/\nStream</a> API, which is not supported by certain browsers.</em></p>",
|
|
"is_constructor": 1,
|
|
"return": {
|
|
"description": "AudioIn",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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:<br/>\n* <code>p5.LowPass</code> - allows frequencies below\nthe cutoff frequency to pass through, and attenuates\nfrequencies above the cutoff.<br/>\n* <code>p5.HighPass</code> - the opposite of a lowpass\nfilter. <br/>\n* <code>p5.BandPass</code> - allows a range of\nfrequencies to pass through and attenuates the frequencies\nbelow and above this frequency range.<br/>\n\nThe <code>.res()</code> method controls either width of the\nbandpass, or resonance of the low/highpass cutoff frequency.",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "type",
|
|
"description": "'lowpass' (default), 'highpass', 'bandpass'",
|
|
"type": "[String]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "p5.Filter",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"return": {
|
|
"description": "Returns a p5.Delay object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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": "<p>p5.Convolver extends p5.Reverb. It can emulate the sound of real\nphysical spaces through a process called <a href=\"\nhttps://en.wikipedia.org/wiki/Convolution_reverb#Real_space_simulation\">\nconvolution</a>.</p>\n\n<p>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.</p>\n\n<p>Use the method <code>createConvolution(path)</code> to instantiate a\np5.Convolver with a path to your impulse response audio file.</p>",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "path to a sound file",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to call when loading succeeds",
|
|
"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.",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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": "<p>A phrase is a pattern of musical events over time, i.e.\na series of notes and rests.</p>\n\n<p>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.</p>\n\n<p>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 <code>playNote(value){}</code>. 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).</p>",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "name",
|
|
"description": "Name so that you can access the Phrase.",
|
|
"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.",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "sequence",
|
|
"description": "Array of values to pass into the callback\n at each step of the phrase.",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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": "<p>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.</p>\n\n<p>See p5.Phrase for more about musical timing.</p>",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "steps",
|
|
"description": "Steps in the part",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "tatums",
|
|
"description": "Divisions of a beat (default is 1/16, a quarter note)",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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\n<code>new p5.Score(a, a, b, a, c)</code>",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "part(s)",
|
|
"description": "One or multiple parts, to be played in sequence.",
|
|
"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": "<p>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().</p>\n<p>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.</p>",
|
|
"is_constructor": 1,
|
|
"example": [
|
|
"\n<div><code>\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</div></code>"
|
|
]
|
|
},
|
|
"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": "<p>PeakDetect works in conjunction with p5.FFT to\nlook for onsets in some or all of the frequency spectrum.\n</p>\n<p>\nTo use p5.PeakDetect, call <code>update</code> in the draw loop\nand pass in a p5.FFT object.\n</p>\n<p>\nYou can listen for a specific part of the frequency spectrum by\nsetting the range between <code>freq1</code> and <code>freq2</code>.\n</p>\n\n<p><code>threshold</code> 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.</p>\n\n<p>\nThe update method is meant to be run in the draw loop, and\n<b>frames</b> 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<code> framesPerPeak = 60 / (estimatedBPM / 60 );</code>\n</p>\n\n<p>\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</a>.\n</p>",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "freq1",
|
|
"description": "lowFrequency - defaults to 20Hz",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "freq2",
|
|
"description": "highFrequency - defaults to 20000 Hz",
|
|
"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.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "framesPerPeak",
|
|
"description": "Defaults to 20.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
]
|
|
},
|
|
"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.",
|
|
"is_constructor": 1,
|
|
"example": [
|
|
"\n<div><code>\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</code></div>\n"
|
|
]
|
|
}
|
|
},
|
|
"classitems": [
|
|
{
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 14,
|
|
"description": "Draw a plane with given a width and height",
|
|
"itemtype": "method",
|
|
"name": "plane",
|
|
"params": [
|
|
{
|
|
"name": "width",
|
|
"description": "width of the plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "height",
|
|
"description": "height of the plane",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "3D Primitives"
|
|
},
|
|
{
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 69,
|
|
"description": "Draw a sphere with given raduis",
|
|
"itemtype": "method",
|
|
"name": "sphere",
|
|
"params": [
|
|
{
|
|
"name": "radius",
|
|
"description": "radius of circle",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "detail",
|
|
"description": "number of segments,\n the more segments the smoother geometry\n default is 24. Avoid detail number above\n 150, it may crash the browser.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "3D Primitives"
|
|
},
|
|
{
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 126,
|
|
"description": "Draw an ellipsoid with given radius",
|
|
"itemtype": "method",
|
|
"name": "ellipsoid",
|
|
"params": [
|
|
{
|
|
"name": "radiusx",
|
|
"description": "xradius of circle",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "radiusy",
|
|
"description": "yradius of circle",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "radiusz",
|
|
"description": "zradius of circle",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "detail",
|
|
"description": "Number of segments.\n The more segments, the smoother the\n geometry (default is 24). Avoid detail\n number above 150. It may crash the\n browser.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "3D Primitives"
|
|
},
|
|
{
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 191,
|
|
"description": "Draw a cylinder with given radius and height",
|
|
"itemtype": "method",
|
|
"name": "cylinder",
|
|
"params": [
|
|
{
|
|
"name": "radius",
|
|
"description": "radius of the surface",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "height",
|
|
"description": "height of the cylinder",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "detail",
|
|
"description": "number of segments,\n the more segments the smoother geometry\n default is 24. Avoid detail number above\n 150. It may crash the browser.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "3D Primitives"
|
|
},
|
|
{
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 288,
|
|
"description": "Draw a cone with given radius and height",
|
|
"itemtype": "method",
|
|
"name": "cone",
|
|
"params": [
|
|
{
|
|
"name": "radius",
|
|
"description": "radius of the bottom surface",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "height",
|
|
"description": "height of the cone",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "detail",
|
|
"description": "number of segments,\n the more segments the smoother geometry\n default is 24. Avoid detail number above\n 150. It may crash the browser.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "3D Primitives"
|
|
},
|
|
{
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 361,
|
|
"description": "Draw a torus with given radius and tube radius",
|
|
"itemtype": "method",
|
|
"name": "torus",
|
|
"params": [
|
|
{
|
|
"name": "radius",
|
|
"description": "radius of the whole ring",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "tubeRadius",
|
|
"description": "radius of the tube",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "detail",
|
|
"description": "number of segments,\n the more segments the smoother geometry\n default is 24. Avoid detail number above\n 150. It may crash the browser.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "3D Primitives"
|
|
},
|
|
{
|
|
"file": "src/3d/3d_primitives.js",
|
|
"line": 422,
|
|
"description": "Draw a box with given width, height and depth",
|
|
"itemtype": "method",
|
|
"name": "box",
|
|
"params": [
|
|
{
|
|
"name": "width",
|
|
"description": "width of the box",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "height",
|
|
"description": "height of the box",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "depth",
|
|
"description": "depth of the box",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "3D Primitives"
|
|
},
|
|
{
|
|
"file": "src/3d/camera.js",
|
|
"line": 12,
|
|
"description": "Sets camera position",
|
|
"itemtype": "method",
|
|
"name": "camera",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "camera postion value on x axis",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "camera postion value on y axis",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "camera postion value on z axis",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/camera.js",
|
|
"line": 47,
|
|
"description": "Sets perspective camera",
|
|
"itemtype": "method",
|
|
"name": "perspective",
|
|
"params": [
|
|
{
|
|
"name": "fovy",
|
|
"description": "camera frustum vertical field of view,\n from bottom to top of view, in degrees",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "aspect",
|
|
"description": "camera frustum aspect ratio",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "near",
|
|
"description": "frustum near plane length",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "far",
|
|
"description": "frustum far plane length",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/camera.js",
|
|
"line": 95,
|
|
"description": "Setup ortho camera",
|
|
"itemtype": "method",
|
|
"name": "ortho",
|
|
"params": [
|
|
{
|
|
"name": "left",
|
|
"description": "camera frustum left plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "right",
|
|
"description": "camera frustum right plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "bottom",
|
|
"description": "camera frustum bottom plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "top",
|
|
"description": "camera frustum top plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "near",
|
|
"description": "camera frustum near plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "far",
|
|
"description": "camera frustum far plane",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/light.js",
|
|
"line": 12,
|
|
"description": "Creates an ambient light with a color",
|
|
"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",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "optional: green or saturation value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "optional: blue or brightness value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "optional: opacity",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\nfunction draw(){\n background(0);\n ambientLight(150);\n ambientMaterial(250);\n sphere(200);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Lights"
|
|
},
|
|
{
|
|
"file": "src/3d/light.js",
|
|
"line": 68,
|
|
"description": "Creates a directional light with a color and a direction",
|
|
"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",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "optional: green or saturation value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "optional: blue or brightness value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "optional: opacity",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "x axis direction or a p5.Vector",
|
|
"type": "Number|p5.Vector"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "optional: y axis direction",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "optional: z axis direction",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Lights"
|
|
},
|
|
{
|
|
"file": "src/3d/light.js",
|
|
"line": 188,
|
|
"description": "Creates a point light with a color and a light position",
|
|
"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",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "optional: green or saturation value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "optional: blue or brightness value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "optional: opacity",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "x axis position or a p5.Vector",
|
|
"type": "Number|p5.Vector"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "optional: y axis position",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "optional: z axis position",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Lights"
|
|
},
|
|
{
|
|
"file": "src/3d/material.js",
|
|
"line": 13,
|
|
"description": "Normal material for geometry",
|
|
"itemtype": "method",
|
|
"name": "normalMaterial",
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(0);\n normalMaterial();\n sphere(200);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Material"
|
|
},
|
|
{
|
|
"file": "src/3d/material.js",
|
|
"line": 37,
|
|
"description": "Texture for geometry",
|
|
"itemtype": "method",
|
|
"name": "texture",
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Material"
|
|
},
|
|
{
|
|
"file": "src/3d/material.js",
|
|
"line": 124,
|
|
"description": "Helper functions; Checks whether val is a pot\nmore info on power of 2 here:\nhttps://www.opengl.org/wiki/NPOT_Texture",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Boolean"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Material"
|
|
},
|
|
{
|
|
"file": "src/3d/material.js",
|
|
"line": 135,
|
|
"description": "returns the next highest power of 2 value",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Material"
|
|
},
|
|
{
|
|
"file": "src/3d/material.js",
|
|
"line": 148,
|
|
"description": "Basic material for geometry with a given color",
|
|
"itemtype": "method",
|
|
"name": "basicMaterial",
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "gray value,\nred or hue value (depending on the current color mode),\nor color Array, or CSS color string",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "optional: green or saturation value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "optional: blue or brightness value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "optional: opacity",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nfunction setup(){\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw(){\n background(0);\n basicMaterial(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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Material"
|
|
},
|
|
{
|
|
"file": "src/3d/material.js",
|
|
"line": 196,
|
|
"description": "Ambient material for geometry with a given color",
|
|
"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",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "optional: green or saturation value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "optional: blue or brightness value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "optional: opacity",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Material"
|
|
},
|
|
{
|
|
"file": "src/3d/material.js",
|
|
"line": 247,
|
|
"description": "Specular material for geometry with a given color",
|
|
"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",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "optional: green or saturation value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "optional: blue or brightness value",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "optional: opacity",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera",
|
|
"submodule": "Material"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 7,
|
|
"description": "p5 Geometry3D class",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 29,
|
|
"description": "generate geometriy with parametric method",
|
|
"params": [
|
|
{
|
|
"name": "func",
|
|
"description": "callback function for how to generate geometry",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "detailX",
|
|
"description": "number of vertices on horizontal surface",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "detailY",
|
|
"description": "number of vertices on horizontal surface",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "offset",
|
|
"description": "offset of vertices index",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 80,
|
|
"description": "compute faceNormals for a geometry",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 105,
|
|
"description": "compute vertexNormals for a geometry",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 189,
|
|
"description": "[generateUV description]",
|
|
"params": [
|
|
{
|
|
"name": "faces",
|
|
"description": "[description]",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "uvs",
|
|
"description": "[description]",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 206,
|
|
"description": "generate an object containing information needed to create buffer",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 232,
|
|
"description": "turn a two dimensional array into one dimensional array",
|
|
"params": [
|
|
{
|
|
"name": "arr",
|
|
"description": "2-dimensional array",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "1-dimensional array\n[[1, 2, 3],[4, 5, 6]] -> [1, 2, 3, 4, 5, 6]",
|
|
"type": "Array"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Geometry3D.js",
|
|
"line": 244,
|
|
"description": "turn an array of Vector into a one dimensional array of numbers",
|
|
"params": [
|
|
{
|
|
"name": "arr",
|
|
"description": "an array of p5.Vector",
|
|
"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",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/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",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/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",
|
|
"is_constructor": 1,
|
|
"params": [
|
|
{
|
|
"name": "mat4",
|
|
"description": "array literal of our 4x4 matrix",
|
|
"type": "Array",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 50,
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "inMatrix",
|
|
"description": "the input p5.Matrix or\n an Array of length 16",
|
|
"type": "p5.Matrix|Array",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 69,
|
|
"description": "Gets a copy of the vector, returns a p5.Matrix object.",
|
|
"return": {
|
|
"description": "the copy of the p5.Matrix object",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 78,
|
|
"description": "return a copy of a matrix",
|
|
"return": {
|
|
"description": "the result matrix",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 103,
|
|
"description": "return an identity matrix",
|
|
"return": {
|
|
"description": "the result matrix",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 111,
|
|
"description": "transpose according to a given matrix",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "the matrix to be based on to transpose",
|
|
"type": "p5.Matrix | Typed Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 171,
|
|
"description": "invert matrix according to a give matrix",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "the matrix to be based on to invert",
|
|
"type": "p5.Matrix or Typed Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 256,
|
|
"description": "inspired by Toji's mat4 determinant",
|
|
"return": {
|
|
"description": "Determinant of our 4x4 matrix",
|
|
"type": "Number"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 279,
|
|
"description": "multiply two mat4s",
|
|
"params": [
|
|
{
|
|
"name": "multMatrix",
|
|
"description": "The matrix we want to multiply by",
|
|
"type": "p5.Matrix | Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 335,
|
|
"description": "scales a p5.Matrix by scalars or a vector",
|
|
"params": [
|
|
{
|
|
"name": "UNKNOWN",
|
|
"description": "vector to scale by",
|
|
"type": "p5.Vector | Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 381,
|
|
"description": "rotate our Matrix around an axis by the given angle.",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "The angle of rotation in radians",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "axis",
|
|
"description": "the axis(es) to rotate around",
|
|
"type": "p5.Vector | Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this\ninspired by Toji's gl-matrix lib, mat4 rotation",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 460,
|
|
"todo": [
|
|
"finish implementing this method!\ntranslates"
|
|
],
|
|
"params": [
|
|
{
|
|
"name": "v",
|
|
"description": "vector to translate by",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this",
|
|
"type": "p5.Matrix"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 490,
|
|
"description": "sets the perspective matrix",
|
|
"params": [
|
|
{
|
|
"name": "fovy",
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "aspect",
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "near",
|
|
"description": "near clipping plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "far",
|
|
"description": "far clipping plane",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Void"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 524,
|
|
"description": "sets the ortho matrix",
|
|
"params": [
|
|
{
|
|
"name": "left",
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "right",
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "bottom",
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "top",
|
|
"description": "[description]",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "near",
|
|
"description": "near clipping plane",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "far",
|
|
"description": "far clipping plane",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Void"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Matrix.js",
|
|
"line": 559,
|
|
"description": "PRIVATE",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 20,
|
|
"description": "3D graphics class. Can also be used as an off-screen graphics buffer.\nA p5.Renderer3D object can be constructed",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 89,
|
|
"description": "[resize description]",
|
|
"params": [
|
|
{
|
|
"name": "w",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "[description]",
|
|
"type": "[tyoe]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 101,
|
|
"description": "[background description]",
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 126,
|
|
"description": "[initShaders description]",
|
|
"params": [
|
|
{
|
|
"name": "vertId",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
{
|
|
"name": "fragId",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 316,
|
|
"description": "[translate description]",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"todo": [
|
|
"implement handle for components or vector as args"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 333,
|
|
"description": "Scales the Model View Matrix by a vector",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "[description]",
|
|
"type": "Number | p5.Vector | Array"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-axis scalar",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "z-axis scalar",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "This"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 345,
|
|
"description": "[rotate description]",
|
|
"params": [
|
|
{
|
|
"name": "rad",
|
|
"description": "angle in radians",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "axis",
|
|
"description": "axis to rotate around",
|
|
"type": "p5.Vector | Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "p5.Renderer3D"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 356,
|
|
"description": "[rotateX description]",
|
|
"params": [
|
|
{
|
|
"name": "rad",
|
|
"description": "radians to rotate",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 366,
|
|
"description": "[rotateY description]",
|
|
"params": [
|
|
{
|
|
"name": "rad",
|
|
"description": "rad radians to rotate",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 376,
|
|
"description": "[rotateZ description]",
|
|
"params": [
|
|
{
|
|
"name": "rad",
|
|
"description": "rad radians to rotate",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 386,
|
|
"description": "pushes a copy of the model view matrix onto the\nMV Matrix stack.\nNOTE to self: could probably make this more readable",
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/p5.Renderer3D.js",
|
|
"line": 396,
|
|
"description": "[pop description]",
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/retainedMode3D.js",
|
|
"line": 8,
|
|
"description": "createBuffer",
|
|
"params": [
|
|
{
|
|
"name": "gId",
|
|
"description": "key of the geometry object",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "arr",
|
|
"description": "array holding bject containing geometry information",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/retainedMode3D.js",
|
|
"line": 39,
|
|
"description": "initBuffer description",
|
|
"params": [
|
|
{
|
|
"name": "gId",
|
|
"description": "key of the geometry object",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "arr",
|
|
"description": "array holding bject containing geometry information",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/3d/retainedMode3D.js",
|
|
"line": 79,
|
|
"description": "drawBuffer",
|
|
"params": [
|
|
{
|
|
"name": "gId",
|
|
"description": "key of the geometery object",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 1,
|
|
"description": "module Conversion\nsubmodule Color Conversion",
|
|
"requires": [
|
|
"core"
|
|
],
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 10,
|
|
"description": "Conversions adapted from <http://www.easyrgb.com/math.html>.\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.",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 20,
|
|
"description": "Convert an HSBA array to HSLA.",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 46,
|
|
"description": "Convert an HSBA array to RGBA.",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 95,
|
|
"description": "Convert an HSLA array to HSBA.",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 118,
|
|
"description": "Convert 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.",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 176,
|
|
"description": "Convert an RGBA array to HSBA.",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/color_conversion.js",
|
|
"line": 211,
|
|
"description": "Convert an RGBA array to HSLA.",
|
|
"class": "p5",
|
|
"module": "Lights, Camera"
|
|
},
|
|
{
|
|
"file": "src/color/creating_reading.js",
|
|
"line": 15,
|
|
"description": "Extracts the alpha value from a color or pixel array.",
|
|
"itemtype": "method",
|
|
"name": "alpha",
|
|
"params": [
|
|
{
|
|
"name": "obj",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "blue",
|
|
"params": [
|
|
{
|
|
"name": "obj",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "brightness",
|
|
"params": [
|
|
{
|
|
"name": "color",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\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\nColors are stored as Numbers or Arrays.",
|
|
"itemtype": "method",
|
|
"name": "color",
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "gray value or red or hue value relative to\n the current color range, or a color string",
|
|
"type": "Number|String"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "gray value or green or saturation value\n relative to the current color range (or\n alpha value if first param is gray value)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "gray value or blue or brightness value\n relative to the current color range",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "alpha",
|
|
"description": "alpha value relative to current color range",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "resulting color",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading"
|
|
},
|
|
{
|
|
"file": "src/color/creating_reading.js",
|
|
"line": 263,
|
|
"description": "Extracts the green value from a color or pixel array.",
|
|
"itemtype": "method",
|
|
"name": "green",
|
|
"params": [
|
|
{
|
|
"name": "color",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading"
|
|
},
|
|
{
|
|
"file": "src/color/creating_reading.js",
|
|
"line": 290,
|
|
"description": "Extracts the hue value from a color or pixel array.\n\nHue 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.)",
|
|
"itemtype": "method",
|
|
"name": "hue",
|
|
"params": [
|
|
{
|
|
"name": "color",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading"
|
|
},
|
|
{
|
|
"file": "src/color/creating_reading.js",
|
|
"line": 323,
|
|
"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<br><br>\nThe way that colours are interpolated depends on the current color mode.",
|
|
"itemtype": "method",
|
|
"name": "lerpColor",
|
|
"params": [
|
|
{
|
|
"name": "c1",
|
|
"description": "interpolate from this color",
|
|
"type": "Array|Number|p5.Color"
|
|
},
|
|
{
|
|
"name": "c2",
|
|
"description": "interpolate to this color",
|
|
"type": "Array|Number|p5.Color"
|
|
},
|
|
{
|
|
"name": "amt",
|
|
"description": "number between 0 and 1",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "interpolated color",
|
|
"type": "Array|Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading"
|
|
},
|
|
{
|
|
"file": "src/color/creating_reading.js",
|
|
"line": 406,
|
|
"description": "Extracts the HSL lightness value from a color or pixel array.",
|
|
"itemtype": "method",
|
|
"name": "lightness",
|
|
"params": [
|
|
{
|
|
"name": "color",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading"
|
|
},
|
|
{
|
|
"file": "src/color/creating_reading.js",
|
|
"line": 433,
|
|
"description": "Extracts the red value from a color or pixel array.",
|
|
"itemtype": "method",
|
|
"name": "red",
|
|
"params": [
|
|
{
|
|
"name": "obj",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\ncolorMode(RGB, 255);\nvar c = color(127, 255, 0);\ncolorMode(RGB, 1);\nvar myColor = red(c);\nprint(myColor);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading"
|
|
},
|
|
{
|
|
"file": "src/color/creating_reading.js",
|
|
"line": 470,
|
|
"description": "Extracts the saturation value from a color or pixel array.\n\nSaturation 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.",
|
|
"itemtype": "method",
|
|
"name": "saturation",
|
|
"params": [
|
|
{
|
|
"name": "color",
|
|
"description": "p5.Color object or pixel array",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"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.",
|
|
"class": "p5.Color",
|
|
"module": "Color",
|
|
"submodule": "Creating & Reading"
|
|
},
|
|
{
|
|
"file": "src/color/p5.Color.js",
|
|
"line": 129,
|
|
"description": "CSS named colors.",
|
|
"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\nNote that RGB values of .9 are not parsed by IE, but are supported here for\ncolor string consistency.",
|
|
"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.",
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "args",
|
|
"description": "An 'array-like' object that represents a list of\n arguments",
|
|
"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<div>\n<code>\n// todo\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "background",
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "gray value, red or hue value\n (depending on the current\n color mode), color string,\n p5.Color, or p5.Image",
|
|
"type": "Number|String|p5.Color|p5.Image"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "green or saturation value\n (depending on the current\n color mode)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "blue or brightness value\n (depending on the current\n color mode)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "opacity of the background",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\n// Grayscale integer value\nbackground(51);\n</code>\n</div>\n\n<div>\n<code>\n// R, G & B integer values\nbackground(255, 204, 0);\n</code>\n</div>\n\n<div>\n<code>\n// H, S & B integer values\ncolorMode(HSB);\nbackground(255, 204, 100);\n</code>\n</div>\n\n<div>\n<code>\n// Named SVG/CSS color string\nbackground('red');\n</code>\n</div>\n\n<div>\n<code>\n// three-digit hexadecimal RGB notation\nbackground('#fae');\n</code>\n</div>\n\n<div>\n<code>\n// six-digit hexadecimal RGB notation\nbackground('#222222');\n</code>\n</div>\n\n<div>\n<code>\n// integer RGB notation\nbackground('rgb(0,255,0)');\n</code>\n</div>\n\n<div>\n<code>\n// integer RGBA notation\nbackground('rgba(0,255,0, 0.25)');\n</code>\n</div>\n\n<div>\n<code>\n// percentage RGB notation\nbackground('rgb(100%,0%,10%)');\n</code>\n</div>\n\n<div>\n<code>\n// percentage RGBA notation\nbackground('rgba(100%,0%,100%,0.5)');\n</code>\n</div>\n\n<div>\n<code>\n// p5 Color object\nbackground(color(0, 0, 255));\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Setting"
|
|
},
|
|
{
|
|
"file": "src/color/setting.js",
|
|
"line": 123,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "clear",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Setting"
|
|
},
|
|
{
|
|
"file": "src/color/setting.js",
|
|
"line": 155,
|
|
"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<br><br>\nNote: existing color objects remember the mode that they were created in,\nso you can change modes as you like without affecting their appearance.",
|
|
"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)",
|
|
"type": "Number/Constant"
|
|
},
|
|
{
|
|
"name": "max1",
|
|
"description": "range for the red or hue depending on the\n current color mode, or range for all values",
|
|
"type": "Number/Constant",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "max2",
|
|
"description": "range for the green or saturation depending\n on the current color mode",
|
|
"type": "Number/Constant",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "max3",
|
|
"description": "range for the blue or brightness/lighntess\n depending on the current color mode",
|
|
"type": "Number/Constant",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "maxA",
|
|
"description": "range for the alpha",
|
|
"type": "Number/Constant",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\ncolorMode(RGB, 255);\nvar c = color(127, 255, 0);\n\ncolorMode(RGB, 1);\nvar myColor = c._getRed();\ntext(myColor, 10, 10, 80, 80);\n</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Setting"
|
|
},
|
|
{
|
|
"file": "src/color/setting.js",
|
|
"line": 258,
|
|
"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<br><br>\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.",
|
|
"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",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "green or saturation value\n (depending on the current\n color mode)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "blue or brightness value\n (depending on the current\n color mode)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "opacity of the background",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\n// Grayscale integer value\nfill(51);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// R, G & B integer values\nfill(255, 204, 0);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// H, S & B integer values\ncolorMode(HSB);\nfill(255, 204, 100);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// Named SVG/CSS color string\nfill('red');\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// three-digit hexadecimal RGB notation\nfill('#fae');\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// six-digit hexadecimal RGB notation\nfill('#222222');\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// integer RGB notation\nfill('rgb(0,255,0)');\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// integer RGBA notation\nfill('rgba(0,255,0, 0.25)');\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// percentage RGB notation\nfill('rgb(100%,0%,10%)');\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// percentage RGBA notation\nfill('rgba(100%,0%,100%,0.5)');\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// p5 Color object\nfill(color(0, 0, 255));\nrect(20, 20, 60, 60);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Setting"
|
|
},
|
|
{
|
|
"file": "src/color/setting.js",
|
|
"line": 379,
|
|
"description": "Disables filling geometry. If both noStroke() and noFill() are called,\nnothing will be drawn to the screen.",
|
|
"itemtype": "method",
|
|
"name": "noFill",
|
|
"example": [
|
|
"\n<div>\n<code>\nrect(15, 10, 55, 55);\nnoFill();\nrect(20, 20, 60, 60);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Setting"
|
|
},
|
|
{
|
|
"file": "src/color/setting.js",
|
|
"line": 398,
|
|
"description": "Disables drawing the stroke (outline). If both noStroke() and noFill()\nare called, nothing will be drawn to the screen.",
|
|
"itemtype": "method",
|
|
"name": "noStroke",
|
|
"example": [
|
|
"\n<div>\n<code>\nnoStroke();\nrect(20, 20, 60, 60);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Color",
|
|
"submodule": "Setting"
|
|
},
|
|
{
|
|
"file": "src/color/setting.js",
|
|
"line": 416,
|
|
"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<br><br>\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.",
|
|
"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",
|
|
"type": "Number|Array|String|p5.Color"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "green or saturation value\n (depending on the current\n color mode)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "blue or brightness value\n (depending on the current\n color mode)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "opacity of the background",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\n// Grayscale integer value\nstrokeWeight(4);\nstroke(51);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// R, G & B integer values\nstroke(255, 204, 0);\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// H, S & B integer values\ncolorMode(HSB);\nstrokeWeight(4);\nstroke(255, 204, 100);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// Named SVG/CSS color string\nstroke('red');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// three-digit hexadecimal RGB notation\nstroke('#fae');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// six-digit hexadecimal RGB notation\nstroke('#222222');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// integer RGB notation\nstroke('rgb(0,255,0)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// integer RGBA notation\nstroke('rgba(0,255,0,0.25)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// percentage RGB notation\nstroke('rgb(100%,0%,10%)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// percentage RGBA notation\nstroke('rgba(100%,0%,100%,0.5)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>\n\n<div>\n<code>\n// p5 Color object\nstroke(color(0, 0, 255));\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n</code>\n</div>"
|
|
],
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "arc",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "x-coordinate of the arc's ellipse",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "y-coordinate of the arc's ellipse",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "c",
|
|
"description": "width of the arc's ellipse by default",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "d",
|
|
"description": "height of the arc's ellipse by default",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "start",
|
|
"description": "angle to start the arc, specified in radians",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "stop",
|
|
"description": "angle to stop the arc, specified in radians",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "mode",
|
|
"description": "optional parameter to determine the way of drawing\n the arc",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\narc(50, 50, 80, 80, 0, PI+QUARTER_PI, OPEN);\n</code>\n</div>\n\n<div>\n<code>\narc(50, 50, 80, 80, 0, PI+QUARTER_PI, CHORD);\n</code>\n</div>\n\n<div>\n<code>\narc(50, 50, 80, 80, 0, PI+QUARTER_PI, PIE);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "2D Primitives"
|
|
},
|
|
{
|
|
"file": "src/core/2d_primitives.js",
|
|
"line": 128,
|
|
"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. The\norigin may be changed with the ellipseMode() function.",
|
|
"itemtype": "method",
|
|
"name": "ellipse",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "x-coordinate of the ellipse.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "y-coordinate of the ellipse.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "c",
|
|
"description": "width of the ellipse.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "d",
|
|
"description": "height of the ellipse.",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nellipse(56, 46, 55, 55);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "2D Primitives"
|
|
},
|
|
{
|
|
"file": "src/core/2d_primitives.js",
|
|
"line": 169,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "line",
|
|
"params": [
|
|
{
|
|
"name": "x1",
|
|
"description": "the x-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y1",
|
|
"description": "the y-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x2",
|
|
"description": "the x-coordinate of the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "the y-coordinate of the second point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nline(30, 20, 85, 75);\n</code>\n</div>\n\n<div>\n<code>\nline(30, 20, 85, 20);\nstroke(126);\nline(85, 20, 85, 75);\nstroke(255);\nline(85, 75, 30, 75);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "2D Primitives"
|
|
},
|
|
{
|
|
"file": "src/core/2d_primitives.js",
|
|
"line": 251,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "point",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "the x-coordinate",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "the y-coordinate",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\npoint(30, 20);\npoint(85, 20);\npoint(85, 75);\npoint(30, 75);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "2D Primitives"
|
|
},
|
|
{
|
|
"file": "src/core/2d_primitives.js",
|
|
"line": 310,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "quad",
|
|
"params": [
|
|
{
|
|
"name": "x1",
|
|
"description": "the x-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y1",
|
|
"description": "the y-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x2",
|
|
"description": "the x-coordinate of the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "the y-coordinate of the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x3",
|
|
"description": "the x-coordinate of the third point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y3",
|
|
"description": "the y-coordinate of the third point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x4",
|
|
"description": "the x-coordinate of the fourth point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y4",
|
|
"description": "the y-coordinate of the fourth point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nquad(38, 31, 86, 20, 69, 63, 30, 76);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "2D Primitives"
|
|
},
|
|
{
|
|
"file": "src/core/2d_primitives.js",
|
|
"line": 390,
|
|
"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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "rect",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the rectangle.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the rectangle.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "w",
|
|
"description": "width of the rectangle.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "height of the rectangle.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "tl",
|
|
"description": "optional radius of top-left corner.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "tr",
|
|
"description": "optional radius of top-right corner.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "br",
|
|
"description": "optional radius of bottom-right corner.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "bl",
|
|
"description": "optional radius of bottom-left corner.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object.",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\n// Draw a rectangle at location (30, 20) with a width and height of 55.\nrect(30, 20, 55, 55);\n</code>\n</div>\n\n<div>\n<code>\n// Draw a rectangle with rounded corners, each having a radius of 20.\nrect(30, 20, 55, 55, 20);\n</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "2D Primitives"
|
|
},
|
|
{
|
|
"file": "src/core/2d_primitives.js",
|
|
"line": 458,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "triangle",
|
|
"params": [
|
|
{
|
|
"name": "x1",
|
|
"description": "x-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y1",
|
|
"description": "y-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x2",
|
|
"description": "x-coordinate of the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "y-coordinate of the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x3",
|
|
"description": "x-coordinate of the third point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y3",
|
|
"description": "y-coordinate of the third point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntriangle(30, 75, 58, 20, 86, 75);\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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<br><br>\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<br><br>\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<br><br>\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<br><br>\nThe parameter must be written in ALL CAPS because Javascript is a\ncase-sensitive language.",
|
|
"itemtype": "method",
|
|
"name": "ellipseMode",
|
|
"params": [
|
|
{
|
|
"name": "mode",
|
|
"description": "either CENTER, RADIUS, CORNER, or CORNERS",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "noSmooth",
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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<br><br>\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<br><br>\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<br><br>\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<br><br>\nThe parameter must be written in ALL CAPS because Javascript is a\ncase-sensitive language.",
|
|
"itemtype": "method",
|
|
"name": "rectMode",
|
|
"params": [
|
|
{
|
|
"name": "mode",
|
|
"description": "either CORNER, CORNERS, CENTER, or RADIUS",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "smooth",
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "strokeCap",
|
|
"params": [
|
|
{
|
|
"name": "cap",
|
|
"description": "either SQUARE, PROJECT, or ROUND",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "strokeJoin",
|
|
"params": [
|
|
{
|
|
"name": "join",
|
|
"description": "either MITER, BEVEL, ROUND",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(MITER);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(BEVEL);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(ROUND);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "strokeWeight",
|
|
"params": [
|
|
{
|
|
"name": "weight",
|
|
"description": "the weight (in pixels) of the stroke",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "property",
|
|
"name": "HALF_PI",
|
|
"example": [
|
|
"\n<div><code>\narc(50, 50, 80, 80, 0, HALF_PI);\n</code></div>\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().",
|
|
"itemtype": "property",
|
|
"name": "PI",
|
|
"example": [
|
|
"\n<div><code>\narc(50, 50, 80, 80, 0, PI);\n</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "property",
|
|
"name": "QUARTER_PI",
|
|
"example": [
|
|
"\n<div><code>\narc(50, 50, 80, 80, 0, QUARTER_PI);\n</code></div>\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().",
|
|
"itemtype": "property",
|
|
"name": "TAU",
|
|
"example": [
|
|
"\n<div><code>\narc(50, 50, 80, 80, 0, TAU);\n</code></div>\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().",
|
|
"itemtype": "property",
|
|
"name": "TWO_PI",
|
|
"example": [
|
|
"\n<div><code>\narc(50, 50, 80, 80, 0, TWO_PI);\n</code></div>\n"
|
|
],
|
|
"class": "p5",
|
|
"module": "Constants",
|
|
"submodule": "Constants"
|
|
},
|
|
{
|
|
"file": "src/core/core.js",
|
|
"line": 15,
|
|
"description": "This 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",
|
|
"params": [
|
|
{
|
|
"name": "sketch",
|
|
"description": "a closure that can set optional preload(),\n setup(), and/or draw() properties on the\n given p5 instance",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "node",
|
|
"description": "element to attach canvas to, if a\n boolean is passed in use it as sync",
|
|
"type": "HTMLElement|boolean"
|
|
},
|
|
{
|
|
"name": "sync",
|
|
"description": "start synchronously (optional)",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "preload",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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<br><br>\nNote: Variables declared within setup() are not accessible within other\nfunctions, including draw().",
|
|
"itemtype": "method",
|
|
"name": "setup",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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. draw() is called automatically and should never be\ncalled explicitly.\n<br><br>\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<br><br>\nThe number of times draw() executes in each second may be controlled with\nthe frameRate() function.\n<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "draw",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Structure",
|
|
"submodule": "Structure"
|
|
},
|
|
{
|
|
"file": "src/core/core.js",
|
|
"line": 368,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "remove",
|
|
"example": [
|
|
"\n<div class='norender'><code>\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n</code></div>"
|
|
],
|
|
"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.<br /><br />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().",
|
|
"itemtype": "method",
|
|
"name": "bezier",
|
|
"params": [
|
|
{
|
|
"name": "x1",
|
|
"description": "x-coordinate for the first anchor point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y1",
|
|
"description": "y-coordinate for the first anchor point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x2",
|
|
"description": "x-coordinate for the first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "y-coordinate for the first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x3",
|
|
"description": "x-coordinate for the second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y3",
|
|
"description": "y-coordinate for the second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x4",
|
|
"description": "x-coordinate for the second anchor point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y4",
|
|
"description": "y-coordinate for the second anchor point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 69,
|
|
"description": "Sets the resolution at which Beziers display.\n\nThe default value is 20.",
|
|
"params": [
|
|
{
|
|
"name": "detail",
|
|
"description": "resolution of the curves",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nbackground(204);\nbezierDetail(50);\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 90,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "bezierPoint",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "coordinate of first point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "coordinate of first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "c",
|
|
"description": "coordinate of second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "d",
|
|
"description": "coordinate of second point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "t",
|
|
"description": "value between 0 and 1",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the value of the Bezier at position t",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 131,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "bezierTangent",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "coordinate of first point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "coordinate of first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "c",
|
|
"description": "coordinate of second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "d",
|
|
"description": "coordinate of second point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "t",
|
|
"description": "value between 0 and 1",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the tangent at position t",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 202,
|
|
"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. <br /><br />\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.",
|
|
"itemtype": "method",
|
|
"name": "curve",
|
|
"params": [
|
|
{
|
|
"name": "x1",
|
|
"description": "x-coordinate for the beginning control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y1",
|
|
"description": "y-coordinate for the beginning control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x2",
|
|
"description": "x-coordinate for the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "y-coordinate for the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x3",
|
|
"description": "x-coordinate for the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y3",
|
|
"description": "y-coordinate for the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x4",
|
|
"description": "x-coordinate for the ending control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y4",
|
|
"description": "y-coordinate for the ending control point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 268,
|
|
"description": "Sets the resolution at which curves display.\n\nThe default value is 20.",
|
|
"params": [
|
|
{
|
|
"name": "resolution",
|
|
"description": "of the curves",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nbackground(204);\ncurveDetail(20);\ncurve(5, 26, 5, 26, 73, 24, 73, 61);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 289,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "curveTightness",
|
|
"params": [
|
|
{
|
|
"name": "amount",
|
|
"description": "of deformation from the original vertices",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 331,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "curvePoint",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "coordinate of first point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "coordinate of first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "c",
|
|
"description": "coordinate of second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "d",
|
|
"description": "coordinate of second point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "t",
|
|
"description": "value between 0 and 1",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "bezier value at position t",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/curves.js",
|
|
"line": 376,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "curveTangent",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "coordinate of first point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "coordinate of first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "c",
|
|
"description": "coordinate of second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "d",
|
|
"description": "coordinate of second point on the curve",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "t",
|
|
"description": "value between 0 and 1",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the tangent at position t",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Curves"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 22,
|
|
"description": "The print() 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<br><br>\nWhile print() 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().",
|
|
"itemtype": "method",
|
|
"name": "print",
|
|
"params": [
|
|
{
|
|
"name": "contents",
|
|
"description": "any combination of Number, String, Object, Boolean,\n Array to print",
|
|
"type": "Any"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code class='norender'>\nvar x = 10;\nprint(\"The value of x is \" + x);\n// prints \"The value of x is 10\"\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 62,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "frameCount",
|
|
"example": [
|
|
"\n <div><code>\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 </code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 85,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "focused",
|
|
"example": [
|
|
"\n<div><code>\n// To demonstrate, put two windows side by side.\n// Click on the window that the p5 sketch isn't in!\nfunction draw() {\n if (focused) { // or \"if (focused === true)\"\n noStroke();\n fill(0, 200, 0);\n ellipse(25, 25, 50, 50);\n } else {\n stroke(200,0,0);\n line(0, 0, 100, 100);\n line(100, 0, 0, 100);\n }\n}\n\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 111,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "cursor",
|
|
"params": [
|
|
{
|
|
"name": "type",
|
|
"description": "either ARROW, CROSS, HAND, MOVE, TEXT, or\n WAIT, or path for image",
|
|
"type": "Number/Constant"
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "the horizontal active spot of the cursor",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "the vertical active spot of the cursor",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 165,
|
|
"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<br><br>\nCalling frameRate() with no arguments returns the current framerate. This\nis the same as getFrameRate().\n<br><br>\nCalling frameRate() with arguments that are not of the type numbers\nor are non positive also returns current framerate.",
|
|
"itemtype": "method",
|
|
"name": "frameRate",
|
|
"params": [
|
|
{
|
|
"name": "fps",
|
|
"description": "number of frames to be displayed every second",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "current frameRate",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n\n<div><code>\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</div></code>\n"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 226,
|
|
"description": "Returns the current framerate.",
|
|
"return": {
|
|
"description": "current frameRate",
|
|
"type": "Number"
|
|
},
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 235,
|
|
"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\nCalling frameRate() with no arguments returns the current framerate.",
|
|
"params": [
|
|
{
|
|
"name": "fps",
|
|
"description": "number of frames to be displayed every second",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 250,
|
|
"description": "Hides the cursor from view.",
|
|
"itemtype": "method",
|
|
"name": "noCursor",
|
|
"example": [
|
|
"\n<div><code>\nfunction setup() {\n noCursor();\n}\n\nfunction draw() {\n background(200);\n ellipse(mouseX, mouseY, 10, 10);\n}\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 271,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "displayWidth",
|
|
"example": [
|
|
"\n<div class=\"norender\"><code>\ncreateCanvas(displayWidth, displayHeight);\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 283,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "displayHeight",
|
|
"example": [
|
|
"\n<div class=\"norender\"><code>\ncreateCanvas(displayWidth, displayHeight);\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 295,
|
|
"description": "System variable that stores the width of the inner window, it maps to\nwindow.innerWidth.",
|
|
"itemtype": "property",
|
|
"name": "windowWidth",
|
|
"example": [
|
|
"\n<div class=\"norender\"><code>\ncreateCanvas(windowWidth, windowHeight);\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 306,
|
|
"description": "System variable that stores the height of the inner window, it maps to\nwindow.innerHeight.",
|
|
"itemtype": "property",
|
|
"name": "windowHeight",
|
|
"example": [
|
|
"\n<div class=\"norender\"><code>\ncreateCanvas(windowWidth, windowHeight);\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 318,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "windowResized",
|
|
"example": [
|
|
"\n<div class=\"norender\"><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 352,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "width",
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 363,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "height",
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 374,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "fullscreen",
|
|
"params": [
|
|
{
|
|
"name": "val",
|
|
"description": "whether the sketch should be in fullscreen mode\nor not",
|
|
"type": "Boolean",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "current fullscreen state",
|
|
"type": "Boolean"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 417,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "pixelDensity",
|
|
"params": [
|
|
{
|
|
"name": "val",
|
|
"description": "whether or how much the sketch should scale",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "current pixel density of the sketch",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nfunction setup() {\n pixelDensity(1);\n createCanvas(100, 100);\n background(200);\n ellipse(width/2, height/2, 50, 50);\n}\n</code>\n</div>\n<div>\n<code>\nfunction setup() {\n pixelDensity(3.0);\n createCanvas(100, 100);\n background(200);\n ellipse(width/2, height/2, 50, 50);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 458,
|
|
"description": "Returns the pixel density of the current display the sketch is running on.",
|
|
"itemtype": "method",
|
|
"name": "displayDensity",
|
|
"return": {
|
|
"description": "current pixel density of the display",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 512,
|
|
"description": "Gets the current URL.",
|
|
"itemtype": "method",
|
|
"name": "getURL",
|
|
"return": {
|
|
"description": "url",
|
|
"type": "String"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 539,
|
|
"description": "Gets the current URL path as an array.",
|
|
"itemtype": "method",
|
|
"name": "getURLPath",
|
|
"return": {
|
|
"description": "path components",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Environment",
|
|
"submodule": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/environment.js",
|
|
"line": 556,
|
|
"description": "Gets the current URL params as an Object.",
|
|
"itemtype": "method",
|
|
"name": "getURLParams",
|
|
"return": {
|
|
"description": "URL params",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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",
|
|
"class": "p5",
|
|
"module": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/error_helpers.js",
|
|
"line": 59,
|
|
"description": "Prints out a fancy, colorful message to the console log",
|
|
"params": [
|
|
{
|
|
"name": "message",
|
|
"description": "the words to be said",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "func",
|
|
"description": "the name of the function to link",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "color",
|
|
"description": "CSS color string or error type",
|
|
"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",
|
|
"params": [
|
|
{
|
|
"name": "func",
|
|
"description": "name of function we're checking",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "args",
|
|
"description": "pass of the JS default arguments array",
|
|
"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 ]",
|
|
"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.",
|
|
"class": "p5",
|
|
"module": "Environment"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 24,
|
|
"description": "Underlying HTML element. All normal HTML methods can be called on this.",
|
|
"itemtype": "property",
|
|
"name": "elt",
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 36,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "parent",
|
|
"params": [
|
|
{
|
|
"name": "parent",
|
|
"description": "the ID, DOM node, or p5.Element\n of desired parent element",
|
|
"type": "String|Object"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n <div class=\"norender\"><code>\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 </code></div>\n <div class='norender'><code>\n var div0 = createDiv('this is the parent');\n var div1 = createDiv('this is the child');\n div1.parent(div0); // use p5.Element\n </code></div>\n <div class='norender'><code>\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 </code></div>\n <div class='norender'><code>\n var elt = document.getElementById('myParentDiv');\n var div1 = createDiv('this is the child');\n div1.parent(elt); // use element from page\n </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 88,
|
|
"description": "Sets the ID of the element",
|
|
"itemtype": "method",
|
|
"name": "id",
|
|
"params": [
|
|
{
|
|
"name": "id",
|
|
"description": "ID of the element",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 107,
|
|
"description": "Adds given class to the element",
|
|
"itemtype": "method",
|
|
"name": "class",
|
|
"params": [
|
|
{
|
|
"name": "class",
|
|
"description": "class to add",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 126,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mousePressed",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n pressed over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 171,
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "mouseWheel",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse wheel is\n scrolled over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 225,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mouseReleased",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n released over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 273,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mouseClicked",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n clicked over the element.",
|
|
"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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 318,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mouseMoved",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n moved over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 371,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mouseOver",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n moved over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 410,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "changed",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when the value of an\nelement changes.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 471,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "input",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired on user input.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 500,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mouseOut",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n moved off the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 538,
|
|
"description": "The .touchStarted() function is called once after every time a touch is\nregistered. This can be used to attach element specific event listeners.",
|
|
"itemtype": "method",
|
|
"name": "touchStarted",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when touch is\n started over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 582,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "touchMoved",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when touch is moved\n over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 618,
|
|
"description": "The .touchEnded() function is called once after every time a touch is\nregistered. This can be used to attach element specific event listeners.",
|
|
"itemtype": "method",
|
|
"name": "touchEnded",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when touch is\n ended over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 664,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "dragOver",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n dragged over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 679,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "dragLeave",
|
|
"params": [
|
|
{
|
|
"name": "fxn",
|
|
"description": "function to be fired when mouse is\n dragged over the element.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 694,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "drop",
|
|
"params": [
|
|
{
|
|
"name": "callback",
|
|
"description": "triggered when files are dropped.",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "to receive loaded file.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Element.js",
|
|
"line": 782,
|
|
"description": "Helper fxn for sharing pixel methods",
|
|
"class": "p5.Element",
|
|
"module": "DOM",
|
|
"submodule": "DOM"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Renderer.js",
|
|
"line": 71,
|
|
"description": "Resize our canvas element.",
|
|
"class": "p5.Renderer",
|
|
"module": "Rendering",
|
|
"submodule": "Rendering"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Renderer.js",
|
|
"line": 141,
|
|
"description": "Helper fxn to check font type (system or otf)",
|
|
"class": "p5.Renderer",
|
|
"module": "Rendering",
|
|
"submodule": "Rendering"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Renderer.js",
|
|
"line": 197,
|
|
"description": "Helper fxn to measure ascent and descent.\nAdapted from http://stackoverflow.com/a/25355178",
|
|
"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",
|
|
"class": "p5",
|
|
"module": "Rendering"
|
|
},
|
|
{
|
|
"file": "src/core/p5.Renderer2D.js",
|
|
"line": 350,
|
|
"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\nSee www.joecridge.me/bezier.pdf for an explanation of the method.",
|
|
"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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "createCanvas",
|
|
"params": [
|
|
{
|
|
"name": "w",
|
|
"description": "width of the canvas",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "height of the canvas",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "renderer",
|
|
"description": "'p2d' | 'webgl'",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "canvas generated",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nfunction setup() {\n createCanvas(100, 50);\n background(153);\n line(0, 0, width, height);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Rendering",
|
|
"submodule": "Rendering"
|
|
},
|
|
{
|
|
"file": "src/core/rendering.js",
|
|
"line": 111,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "resizeCanvas",
|
|
"example": [
|
|
"\n<div class=\"norender\"><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Rendering",
|
|
"submodule": "Rendering"
|
|
},
|
|
{
|
|
"file": "src/core/rendering.js",
|
|
"line": 154,
|
|
"description": "Removes the default canvas for a p5 sketch that doesn't\nrequire a canvas",
|
|
"itemtype": "method",
|
|
"name": "noCanvas",
|
|
"example": [
|
|
"\n<div>\n<code>\nfunction setup() {\n noCanvas();\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Rendering",
|
|
"submodule": "Rendering"
|
|
},
|
|
{
|
|
"file": "src/core/rendering.js",
|
|
"line": 173,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createGraphics",
|
|
"params": [
|
|
{
|
|
"name": "w",
|
|
"description": "width of the offscreen graphics buffer",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "height of the offscreen graphics buffer",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "renderer",
|
|
"description": "either 'p2d' or 'webgl'.\nundefined defaults to p2d",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "offscreen graphics buffer",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Rendering",
|
|
"submodule": "Rendering"
|
|
},
|
|
{
|
|
"file": "src/core/rendering.js",
|
|
"line": 207,
|
|
"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<ul>\n<li><code>BLEND</code> - linear interpolation of colours: C =\nA*factor + B. This is the default blending mode.</li>\n<li><code>ADD</code> - sum of A and B</li>\n<li><code>DARKEST</code> - only the darkest colour succeeds: C =\nmin(A*factor, B).</li>\n<li><code>LIGHTEST</code> - only the lightest colour succeeds: C =\nmax(A*factor, B).</li>\n<li><code>DIFFERENCE</code> - subtract colors from underlying image.</li>\n<li><code>EXCLUSION</code> - similar to <code>DIFFERENCE</code>, but less\nextreme.</li>\n<li><code>MULTIPLY</code> - multiply the colors, result will always be\ndarker.</li>\n<li><code>SCREEN</code> - opposite multiply, uses inverse values of the\ncolors.</li>\n<li><code>REPLACE</code> - the pixels entirely replace the others and\ndon't utilize alpha (transparency) values.</li>\n<li><code>OVERLAY</code> - mix of <code>MULTIPLY</code> and <code>SCREEN\n</code>. Multiplies dark values, and screens light values.</li>\n<li><code>HARD_LIGHT</code> - <code>SCREEN</code> when greater than 50%\ngray, <code>MULTIPLY</code> when lower.</li>\n<li><code>SOFT_LIGHT</code> - mix of <code>DARKEST</code> and\n<code>LIGHTEST</code>. Works like <code>OVERLAY</code>, but not as harsh.\n</li>\n<li><code>DODGE</code> - lightens light tones and increases contrast,\nignores darks.</li>\n<li><code>BURN</code> - darker areas are applied, increasing contrast,\nignores lights.</li>\n</ul>",
|
|
"itemtype": "method",
|
|
"name": "blendMode",
|
|
"params": [
|
|
{
|
|
"name": "mode",
|
|
"description": "blend mode to set for canvas",
|
|
"type": "String/Constant"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\nblendMode(LIGHTEST);\nstrokeWeight(30);\nstroke(80, 150, 255);\nline(25, 25, 75, 75);\nstroke(255, 50, 50);\nline(75, 25, 25, 75);\n</code>\n</div>\n<div>\n<code>\nblendMode(MULTIPLY);\nstrokeWeight(30);\nstroke(80, 150, 255);\nline(25, 25, 75, 75);\nstroke(255, 50, 50);\nline(75, 25, 25, 75);\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"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<br><br>\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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "noLoop",
|
|
"example": [
|
|
"\n<div><code>\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n noLoop();\n}\n\nfunction draw() {\n line(10, 10, 90, 90);\n}\n</code></div>\n\n<div><code>\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</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "loop",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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<br><br>\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().",
|
|
"itemtype": "method",
|
|
"name": "push",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Structure",
|
|
"submodule": "Structure"
|
|
},
|
|
{
|
|
"file": "src/core/structure.js",
|
|
"line": 178,
|
|
"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<br><br>\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().",
|
|
"itemtype": "method",
|
|
"name": "pop",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Structure",
|
|
"submodule": "Structure"
|
|
},
|
|
{
|
|
"file": "src/core/structure.js",
|
|
"line": 245,
|
|
"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 <br><br>\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 <br><br>\n The redraw() function does not work properly when called inside draw().\n To enable/disable animations, use loop() and noLoop().",
|
|
"itemtype": "method",
|
|
"name": "redraw",
|
|
"example": [
|
|
"\n <div><code>\n var x = 0;\n function setup() {\n createCanvas(100, 100);\n noLoop();\n }\n function draw() {\n background(204);\n line(x, 0, x, height);\n }\n function mousePressed() {\n x += 1;\n redraw();\n }\n </code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "applyMatrix",
|
|
"params": [
|
|
{
|
|
"name": "n00",
|
|
"description": "numbers which define the 3x2 matrix to be multiplied",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "n01",
|
|
"description": "numbers which define the 3x2 matrix to be multiplied",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "n02",
|
|
"description": "numbers which define the 3x2 matrix to be multiplied",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "n10",
|
|
"description": "numbers which define the 3x2 matrix to be multiplied",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "n11",
|
|
"description": "numbers which define the 3x2 matrix to be multiplied",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "n12",
|
|
"description": "numbers which define the 3x2 matrix to be multiplied",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\n// Example in the works.\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 52,
|
|
"description": "Replaces the current matrix with the identity matrix.",
|
|
"itemtype": "method",
|
|
"name": "resetMatrix",
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\n// Example in the works.\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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<br><br>\nTechnically, rotate() multiplies the current transformation matrix\nby a rotation matrix. This function can be further controlled by\nthe push() and pop().",
|
|
"itemtype": "method",
|
|
"name": "rotate",
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "the angle of rotation, specified in radians\n or degrees, depending on current angleMode",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntranslate(width/2, height/2);\nrotate(PI/3.0);\nrect(-26, -26, 52, 52);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 113,
|
|
"description": "[rotateX description]",
|
|
"params": [
|
|
{
|
|
"name": "rad",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 138,
|
|
"description": "[rotateY description]",
|
|
"params": [
|
|
{
|
|
"name": "rad",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 163,
|
|
"description": "[rotateZ description]",
|
|
"params": [
|
|
{
|
|
"name": "rad",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 188,
|
|
"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<br><br>\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<br><br>\nUsing this fuction with the z parameter requires using P3D as a\nparameter for size(), as shown in the third example above. This function\ncan be further controlled with push() and pop().",
|
|
"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",
|
|
"type": "Number|p5.Vector|Array"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "percent to scale the object in the y-axis",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "percent to scale the object in the z-axis (webgl only)",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntranslate(width/2, height/2);\nrotate(PI/3.0);\nrect(-26, -26, 52, 52);\n</code>\n</div>\n\n<div>\n<code>\nrect(30, 20, 50, 50);\nscale(0.5, 1.3);\nrect(30, 20, 50, 50);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 265,
|
|
"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<br><br>\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<br><br>\nTechnically, shearX() multiplies the current transformation matrix by a\nrotation matrix. This function can be further controlled by the\npush() and pop() functions.",
|
|
"itemtype": "method",
|
|
"name": "shearX",
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "angle of shear specified in radians or degrees,\n depending on current angleMode",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntranslate(width/4, height/4);\nshearX(PI/4.0);\nrect(0, 0, 30, 30);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 302,
|
|
"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<br><br>\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<br><br>\nTechnically, shearY() multiplies the current transformation matrix by a\nrotation matrix. This function can be further controlled by the\npush() and pop() functions.",
|
|
"itemtype": "method",
|
|
"name": "shearY",
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "angle of shear specified in radians or degrees,\n depending on current angleMode",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntranslate(width/4, height/4);\nshearY(PI/4.0);\nrect(0, 0, 30, 30);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/transform.js",
|
|
"line": 339,
|
|
"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<br><br>\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().",
|
|
"itemtype": "method",
|
|
"name": "translate",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "left/right translation",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "up/down translation",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "P5"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntranslate(30, 20);\nrect(0, 0, 55, 55);\n</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Transform",
|
|
"submodule": "Transform"
|
|
},
|
|
{
|
|
"file": "src/core/vertex.js",
|
|
"line": 21,
|
|
"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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "beginContour",
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Vertex"
|
|
},
|
|
{
|
|
"file": "src/core/vertex.js",
|
|
"line": 65,
|
|
"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<br><br>\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<br><br>\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().",
|
|
"itemtype": "method",
|
|
"name": "beginShape",
|
|
"params": [
|
|
{
|
|
"name": "kind",
|
|
"description": "either POINTS, LINES, TRIANGLES,\n TRIANGLE_FAN, TRIANGLE_STRIP, QUADS,\n or QUAD_STRIP",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n</code>\n</div>\n\n<div>\n<code>\n// currently not working\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\nbeginShape(LINES);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n</code>\n</div>\n\n<div>\n<code>\nbeginShape(TRIANGLES);\nvertex(30, 75);\nvertex(40, 20);\nvertex(50, 75);\nvertex(60, 20);\nvertex(70, 75);\nvertex(80, 20);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\nbeginShape();\nvertex(20, 20);\nvertex(40, 20);\nvertex(40, 40);\nvertex(60, 40);\nvertex(60, 60);\nvertex(20, 60);\nendShape(CLOSE);\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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().",
|
|
"itemtype": "method",
|
|
"name": "bezierVertex",
|
|
"params": [
|
|
{
|
|
"name": "x2",
|
|
"description": "x-coordinate for the first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "y-coordinate for the first control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x3",
|
|
"description": "x-coordinate for the second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y3",
|
|
"description": "y-coordinate for the second control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x4",
|
|
"description": "x-coordinate for the anchor point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y4",
|
|
"description": "y-coordinate for the anchor point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nnoFill();\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nbezierVertex(50, 80, 60, 25, 30, 20);\nendShape();\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "curveVertex",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the vertex",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the vertex",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nnoFill();\nbeginShape();\ncurveVertex(84, 91);\ncurveVertex(84, 91);\ncurveVertex(68, 19);\ncurveVertex(21, 17);\ncurveVertex(32, 100);\ncurveVertex(32, 100);\nendShape();\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "endContour",
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Vertex"
|
|
},
|
|
{
|
|
"file": "src/core/vertex.js",
|
|
"line": 399,
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "endShape",
|
|
"params": [
|
|
{
|
|
"name": "mode",
|
|
"description": "use CLOSE to close the shape",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Vertex"
|
|
},
|
|
{
|
|
"file": "src/core/vertex.js",
|
|
"line": 461,
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "quadraticVertex",
|
|
"params": [
|
|
{
|
|
"name": "cx",
|
|
"description": "x-coordinate for the control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "cy",
|
|
"description": "y-coordinate for the control point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x3",
|
|
"description": "x-coordinate for the anchor point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y3",
|
|
"description": "y-coordinate for the anchor point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nnoFill();\nstrokeWeight(4);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nendShape();\n</code>\n</div>\n\n<div>\n<code>\nnoFill();\nstrokeWeight(4);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nquadraticVertex(20, 80, 80, 80);\nvertex(80, 60);\nendShape();\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Shape",
|
|
"submodule": "Vertex"
|
|
},
|
|
{
|
|
"file": "src/core/vertex.js",
|
|
"line": 533,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "vertex",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the vertex",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the vertex",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5 object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n</code>\n</div>"
|
|
],
|
|
"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'.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "pAccelerationZ",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Acceleration"
|
|
},
|
|
{
|
|
"file": "src/events/acceleration.js",
|
|
"line": 72,
|
|
"description": "_updatePAccelerations updates the pAcceleration values",
|
|
"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<br><br>\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.",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\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.",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\nUnlike rotationX and rotationY, this variable is available for devices\nwith a built-in compass only.\n<br><br>\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.",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\npRotationX can also be used with rotationX to determine the rotate\ndirection of the device along the X-axis.",
|
|
"example": [
|
|
"\n<div class='norender'>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\npRotationY can also be used with rotationY to determine the rotate\ndirection of the device along the Y-axis.",
|
|
"example": [
|
|
"\n<div class='norender'>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\npRotationZ can also be used with rotationZ to determine the rotate\ndirection of the device along the Z-axis.",
|
|
"example": [
|
|
"\n<div class='norender'>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setMoveThreshold",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "The threshold value",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setShakeThreshold",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "The threshold value",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "deviceMoved",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\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'.",
|
|
"itemtype": "method",
|
|
"name": "deviceTurned",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "deviceShaken",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Acceleration"
|
|
},
|
|
{
|
|
"file": "src/events/keyboard.js",
|
|
"line": 12,
|
|
"description": "Holds the key codes of currently pressed keys.",
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "keyIsPressed",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "key",
|
|
"example": [
|
|
"\n<div><code>\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</div></code>"
|
|
],
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "keyCode",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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<br><br>\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<br><br>\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<br><br>\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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "keyPressed",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\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</code>\n</div>\n<div class=\"norender\">\n<code>\nfunction keyPressed(){\n // Do something\n return false; // prevent any default behaviour\n}\n</code>\n</div>"
|
|
],
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "keyReleased",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "keyTyped",
|
|
"example": [
|
|
"\n<div>\n<code>\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 return false; // prevent any default behavior\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Keyboard"
|
|
},
|
|
{
|
|
"file": "src/events/keyboard.js",
|
|
"line": 272,
|
|
"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.",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Keyboard"
|
|
},
|
|
{
|
|
"file": "src/events/keyboard.js",
|
|
"line": 282,
|
|
"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\n<a href=\"http://p5js.org/reference/#p5/keyCode\">here</a>.",
|
|
"itemtype": "method",
|
|
"name": "keyIsDown",
|
|
"params": [
|
|
{
|
|
"name": "code",
|
|
"description": "The key to check for.",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "whether key is down or not",
|
|
"type": "Boolean"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Keyboard"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 26,
|
|
"description": "The system variable mouseX always contains the current horizontal\nposition of the mouse, relative to (0, 0) of the canvas.",
|
|
"itemtype": "property",
|
|
"name": "mouseX",
|
|
"example": [
|
|
"\n<div>\n<code>\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(mouseX, 0, mouseX, 100);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 45,
|
|
"description": "The system variable mouseY always contains the current vertical position\nof the mouse, relative to (0, 0) of the canvas.",
|
|
"itemtype": "property",
|
|
"name": "mouseY",
|
|
"example": [
|
|
"\n<div>\n<code>\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(0, mouseY, 100, mouseY);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 64,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "pmouseX",
|
|
"example": [
|
|
"\n<div>\n<code>\n// Move the mouse across the canvas to leave a trail\nfunction setup() {\n //slow down the frameRate to make it more visible\n frameRate(10);\n}\n\nfunction draw() {\n background(244, 248, 252);\n line(mouseX, mouseY, pmouseX, pmouseY);\n print(pmouseX + \" -> \" + mouseX);\n}\n\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 91,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "pmouseY",
|
|
"example": [
|
|
"\n<div>\n<code>\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 print(pmouseY + \" -> \" + mouseY);\n}\n\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 116,
|
|
"description": "The system variable winMouseX always contains the current horizontal\nposition of the mouse, relative to (0, 0) of the window.",
|
|
"itemtype": "property",
|
|
"name": "winMouseX",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 149,
|
|
"description": "The system variable winMouseY always contains the current vertical\nposition of the mouse, relative to (0, 0) of the window.",
|
|
"itemtype": "property",
|
|
"name": "winMouseY",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 182,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "pwinMouseX",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 219,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "pwinMouseY",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 257,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "mouseButton",
|
|
"example": [
|
|
"\n<div>\n<code>\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 print(mouseButton);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 288,
|
|
"description": "The boolean system variable mouseIsPressed is true if the mouse is pressed\nand false if not.",
|
|
"itemtype": "property",
|
|
"name": "mouseIsPressed",
|
|
"example": [
|
|
"\n<div>\n<code>\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 print(mouseIsPressed);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 358,
|
|
"description": "The mouseMoved() function is called every time the mouse moves and a mouse\nbutton is not pressed.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "mouseMoved",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction mouseMoved() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 397,
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "mouseDragged",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction mouseDragged() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 464,
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "mousePressed",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction mousePressed() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 527,
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "mouseReleased",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction mouseReleased() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 590,
|
|
"description": "The mouseClicked() function is called once after a mouse button has been\npressed and then released.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "mouseClicked",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction mouseClicked() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/mouse.js",
|
|
"line": 640,
|
|
"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.<br><br>\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).<br><br>\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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "mouseWheel",
|
|
"example": [
|
|
"\n<div>\n<code>\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 print(event.delta);\n //move the square according to the vertical scroll amount\n pos += event.delta;\n //uncomment to block page scrolling\n //return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Mouse"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 23,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "touchX",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 33,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "touchY",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 43,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "ptouchX",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 52,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "ptouchY",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 61,
|
|
"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.",
|
|
"itemtype": "property",
|
|
"name": "touches[]",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 71,
|
|
"description": "The boolean system variable touchIsDown is true if the screen is\ntouched and false if not.",
|
|
"itemtype": "property",
|
|
"name": "touchIsDown",
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 118,
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "touchStarted",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction touchStarted() {\n ellipse(touchX, touchY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 178,
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "touchMoved",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction touchMoved() {\n ellipse(touchX, touchY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Events",
|
|
"submodule": "Touch"
|
|
},
|
|
{
|
|
"file": "src/events/touch.js",
|
|
"line": 235,
|
|
"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.<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "touchEnded",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div class=\"norender\">\n<code>\nfunction touchEnded() {\n ellipse(touchX, touchY, 5, 5);\n // prevent default\n return false;\n}\n</code>\n</div>"
|
|
],
|
|
"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\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.",
|
|
"class": "p5",
|
|
"module": "Events"
|
|
},
|
|
{
|
|
"file": "src/image/filters.js",
|
|
"line": 28,
|
|
"description": "Returns the pixel buffer for a canvas",
|
|
"access": "private",
|
|
"tagname": "",
|
|
"params": [
|
|
{
|
|
"name": "canvas",
|
|
"description": "the canvas to get pixels from",
|
|
"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.",
|
|
"access": "private",
|
|
"tagname": "",
|
|
"params": [
|
|
{
|
|
"name": "data",
|
|
"description": "array returned by _toPixels()",
|
|
"type": "Uint8ClampedArray"
|
|
},
|
|
{
|
|
"name": "i",
|
|
"description": "index of a 1D Image Array",
|
|
"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.",
|
|
"access": "private",
|
|
"tagname": "",
|
|
"params": [
|
|
{
|
|
"name": "pixels",
|
|
"description": "array returned by _toPixels()",
|
|
"type": "Uint8ClampedArray"
|
|
},
|
|
{
|
|
"name": "data",
|
|
"description": "source 1D array where each value\n represents ARGB values",
|
|
"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",
|
|
"access": "private",
|
|
"tagname": "",
|
|
"params": [
|
|
{
|
|
"name": "canvas",
|
|
"description": "canvas to get image data from",
|
|
"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.",
|
|
"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\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.",
|
|
"params": [
|
|
{
|
|
"name": "func",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
{
|
|
"name": "canvas",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
{
|
|
"name": "level",
|
|
"description": "[description]",
|
|
"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\nBorrowed from http://www.html5rocks.com/en/tutorials/canvas/imagefilters/",
|
|
"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\nBorrowed from http://www.html5rocks.com/en/tutorials/canvas/imagefilters/",
|
|
"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.",
|
|
"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.",
|
|
"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\nAdapted from java based processing implementation",
|
|
"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",
|
|
"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",
|
|
"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.",
|
|
"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<br><br>\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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "createImage",
|
|
"params": [
|
|
{
|
|
"name": "width",
|
|
"description": "width in pixels",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "height",
|
|
"description": "height in pixels",
|
|
"type": "Integer"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5.Image object",
|
|
"type": "p5.Image"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "saveCanvas",
|
|
"params": [
|
|
{
|
|
"name": "canvas",
|
|
"description": "a variable representing a\n specific html5 canvas (optional)",
|
|
"type": "Canvas",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "filename",
|
|
"description": "",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "extension",
|
|
"description": "'jpg' or 'png'",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class='norender'><code>\nfunction setup() {\n var c = createCanvas(100, 100);\n background(255, 0, 0);\n saveCanvas(c, 'myCanvas', 'jpg');\n}\n</code></div>\n<div class='norender'><code>\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</code></div>\n<div class='norender'><code>\n// all of the following are valid\nsaveCanvas(c, 'myCanvas', 'jpg');\nsaveCanvas(c, 'myCanvas');\nsaveCanvas(c);\nsaveCanvas('myCanvas', 'png');\nsaveCanvas('myCanvas');\nsaveCanvas();\n</code></div>"
|
|
],
|
|
"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 attempt to download\nall of the images that have just been created.",
|
|
"itemtype": "method",
|
|
"name": "saveFrames",
|
|
"params": [
|
|
{
|
|
"name": "filename",
|
|
"description": "",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "extension",
|
|
"description": "'jpg' or 'png'",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "duration",
|
|
"description": "Duration in seconds to save the frames for.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "framerate",
|
|
"description": "Framerate to save the frames in.",
|
|
"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 spcecified number of\n frames of objects. Each object have three\n properties: imageData - an\n image/octet-stream, filename and extension.",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"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<br><br>\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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "loadImage",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "Path of the image to be loaded",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "successCallback",
|
|
"description": "Function to be called once\n the image is loaded. Will be passed the\n p5.Image.",
|
|
"type": "Function",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "failureCallback",
|
|
"description": "called with error event if\n the image fails to load.",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5.Image object",
|
|
"type": "p5.Image"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/laDefense.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n}\n</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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",
|
|
"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",
|
|
"itemtype": "method",
|
|
"name": "image",
|
|
"params": [
|
|
{
|
|
"name": "img",
|
|
"description": "the image to display",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "tint",
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "gray value, red or hue value (depending on the\n current color mode), or color Array",
|
|
"type": "Number|Array"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "green or saturation value (depending on the\n current color mode)",
|
|
"type": "Number|Array",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "v3",
|
|
"description": "blue or brightness value (depending on the\n current color mode)",
|
|
"type": "Number|Array",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "opacity of the background",
|
|
"type": "Number|Array",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "noTint",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "The",
|
|
"description": "image to be tinted",
|
|
"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<br><br>\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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "imageMode",
|
|
"params": [
|
|
{
|
|
"name": "m",
|
|
"description": "The mode: either CORNER, CORNERS, or CENTER.",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"class": "p5.Image",
|
|
"module": "Image",
|
|
"submodule": "Image"
|
|
},
|
|
{
|
|
"file": "src/image/p5.Image.js",
|
|
"line": 46,
|
|
"description": "Image width.",
|
|
"itemtype": "property",
|
|
"name": "width",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5.Image",
|
|
"module": "Image",
|
|
"submodule": "Image"
|
|
},
|
|
{
|
|
"file": "src/image/p5.Image.js",
|
|
"line": 68,
|
|
"description": "Image height.",
|
|
"itemtype": "property",
|
|
"name": "height",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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<code><pre>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</pre></code>\n<br><br>\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.",
|
|
"itemtype": "property",
|
|
"name": "pixels[]",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5.Image",
|
|
"module": "Image",
|
|
"submodule": "Image"
|
|
},
|
|
{
|
|
"file": "src/image/p5.Image.js",
|
|
"line": 161,
|
|
"description": "Helper fxn for sharing pixel methods",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "loadPixels",
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "updatePixels",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-offset of the target update area for the\n underlying canvas",
|
|
"type": "Integer|undefined"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-offset of the target update area for the\n underlying canvas",
|
|
"type": "Integer|undefined"
|
|
},
|
|
{
|
|
"name": "w",
|
|
"description": "height of the target update area for the\n underlying canvas",
|
|
"type": "Integer|undefined"
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "height of the target update area for the\n underlying canvas",
|
|
"type": "Integer|undefined"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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\nIf 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\nReturns undefined if the region is outside the bounds of the image",
|
|
"itemtype": "method",
|
|
"name": "get",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the pixel",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the pixel",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "w",
|
|
"description": "width",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "height",
|
|
"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<div><code>\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</code></div>"
|
|
],
|
|
"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\nNote that for a large number of pixels this will\nbe slower than directly manipulating the pixels array\nand then calling updatePixels().",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the pixel",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the pixel",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "a",
|
|
"description": "grayscale value | pixel array |\n a p5.Color | image to copy",
|
|
"type": "Number|Array|Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "resize",
|
|
"params": [
|
|
{
|
|
"name": "width",
|
|
"description": "the resized image width",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "height",
|
|
"description": "the resized image height",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "copy",
|
|
"params": [
|
|
{
|
|
"name": "srcImage",
|
|
"description": "source image",
|
|
"type": "p5.Image|undefined"
|
|
},
|
|
{
|
|
"name": "sx",
|
|
"description": "X coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sy",
|
|
"description": "Y coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sw",
|
|
"description": "source image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sh",
|
|
"description": "source image height",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dx",
|
|
"description": "X coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dy",
|
|
"description": "Y coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dw",
|
|
"description": "destination image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dh",
|
|
"description": "destination image height",
|
|
"type": "Integer"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mask",
|
|
"params": [
|
|
{
|
|
"name": "srcImage",
|
|
"description": "source image",
|
|
"type": "p5.Image"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>\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",
|
|
"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",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "",
|
|
"type": "Number|undefined"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "blend",
|
|
"params": [
|
|
{
|
|
"name": "srcImage",
|
|
"description": "source image",
|
|
"type": "p5.Image|undefined"
|
|
},
|
|
{
|
|
"name": "sx",
|
|
"description": "X coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sy",
|
|
"description": "Y coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sw",
|
|
"description": "source image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sh",
|
|
"description": "source image height",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dx",
|
|
"description": "X coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dy",
|
|
"description": "Y coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dw",
|
|
"description": "destination image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dh",
|
|
"description": "destination image height",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "blendMode",
|
|
"description": "the blend mode\n\nAvailable blend modes are: normal | multiply | screen | overlay |\n darken | lighten | color-dodge | color-burn | hard-light |\n soft-light | difference | exclusion | hue | saturation |\n color | luminosity\n\n\nhttp://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/",
|
|
"type": "Integer"
|
|
}
|
|
],
|
|
"class": "p5.Image",
|
|
"module": "Image",
|
|
"submodule": "Image"
|
|
},
|
|
{
|
|
"file": "src/image/p5.Image.js",
|
|
"line": 544,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "save",
|
|
"params": [
|
|
{
|
|
"name": "filename",
|
|
"description": "give your file a name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "extension",
|
|
"description": "'png' or 'jpg'",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5.Image",
|
|
"module": "Image",
|
|
"submodule": "Image"
|
|
},
|
|
{
|
|
"file": "src/image/p5.Image.js",
|
|
"line": 602,
|
|
"description": "creates a gl texture\nused in WEBGL mode only",
|
|
"params": [
|
|
{
|
|
"name": "tex",
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "[type]"
|
|
},
|
|
"class": "p5.Image",
|
|
"module": "Image",
|
|
"submodule": "Image"
|
|
},
|
|
{
|
|
"file": "src/image/pixels.js",
|
|
"line": 14,
|
|
"description": "<a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference\n/Global_Objects/Uint8ClampedArray' target='_blank'>Uint8ClampedArray</a>\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<br><br>\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<code><pre>\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</pre></code>\n\n<p>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<br><br>\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<br><br>\nNote that this is not a standard javascript array. This means that\nstandard javascript functions such as <code>slice()</code> or\n<code>arrayCopy()</code> do not\nwork.</p>",
|
|
"itemtype": "property",
|
|
"name": "pixels[]",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.<br><br>\nAvailable blend modes are: BLEND | DARKEST | LIGHTEST | DIFFERENCE |\nMULTIPLY| EXCLUSION | SCREEN | REPLACE | OVERLAY | HARD_LIGHT |\nSOFT_LIGHT | DODGE | BURN | ADD | NORMAL",
|
|
"itemtype": "method",
|
|
"name": "blend",
|
|
"params": [
|
|
{
|
|
"name": "srcImage",
|
|
"description": "source image",
|
|
"type": "p5.Image|undefined"
|
|
},
|
|
{
|
|
"name": "sx",
|
|
"description": "X coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sy",
|
|
"description": "Y coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sw",
|
|
"description": "source image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sh",
|
|
"description": "source image height",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dx",
|
|
"description": "X coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dy",
|
|
"description": "Y coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dw",
|
|
"description": "destination image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dh",
|
|
"description": "destination image height",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "blendMode",
|
|
"description": "the blend mode",
|
|
"type": "Integer"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>\n<div><code>\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</code></div>\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Image",
|
|
"submodule": "Pixels"
|
|
},
|
|
{
|
|
"file": "src/image/pixels.js",
|
|
"line": 151,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "copy",
|
|
"params": [
|
|
{
|
|
"name": "srcImage",
|
|
"description": "source image",
|
|
"type": "p5.Image|undefined"
|
|
},
|
|
{
|
|
"name": "sx",
|
|
"description": "X coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sy",
|
|
"description": "Y coordinate of the source's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sw",
|
|
"description": "source image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "sh",
|
|
"description": "source image height",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dx",
|
|
"description": "X coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dy",
|
|
"description": "Y coordinate of the destination's upper left corner",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dw",
|
|
"description": "destination image width",
|
|
"type": "Integer"
|
|
},
|
|
{
|
|
"name": "dh",
|
|
"description": "destination image height",
|
|
"type": "Integer"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Image",
|
|
"submodule": "Pixels"
|
|
},
|
|
{
|
|
"file": "src/image/pixels.js",
|
|
"line": 192,
|
|
"description": "Applies a filter to the canvas.\n<br><br>\n\nThe presets options are:\n<br><br>\n\nTHRESHOLD\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<br><br>\n\nGRAY\nConverts any colors in the image to grayscale equivalents. No parameter\nis used.\n<br><br>\n\nOPAQUE\nSets the alpha channel to entirely opaque. No parameter is used.\n<br><br>\n\nINVERT\nSets each pixel to its inverse value. No parameter is used.\n<br><br>\n\nPOSTERIZE\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<br><br>\n\nBLUR\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<br><br>\n\nERODE\nReduces the light areas. No parameter is used.\n<br><br>\n\nDILATE\nIncreases the light areas. No parameter is used.",
|
|
"itemtype": "method",
|
|
"name": "filter",
|
|
"params": [
|
|
{
|
|
"name": "filterType",
|
|
"description": "",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "filterParam",
|
|
"description": "an optional parameter unique\n to each filter, see above",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(THRESHOLD);\n}\n</code>\n</div>\n\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(GRAY);\n}\n</code>\n</div>\n\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(OPAQUE);\n}\n</code>\n</div>\n\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(INVERT);\n}\n</code>\n</div>\n\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(POSTERIZE,3);\n}\n</code>\n</div>\n\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(DILATE);\n}\n</code>\n</div>\n\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(BLUR,3);\n}\n</code>\n</div>\n\n<div>\n<code>\nvar img;\nfunction preload() {\n img = loadImage(\"assets/bricks.jpg\");\n}\nfunction setup() {\n image(img, 0, 0);\n filter(ERODE);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Image",
|
|
"submodule": "Pixels"
|
|
},
|
|
{
|
|
"file": "src/image/pixels.js",
|
|
"line": 352,
|
|
"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<br><br>\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<br><br>\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<code>[pixels[(y*width*d+x)*d],\npixels[(y*width*d+x)*d+1],\npixels[(y*width*d+x)*d+2],\npixels[(y*width*d+x)*d+3]]</code>.\n<br><br>\nSee the reference for pixels[] for more information.",
|
|
"itemtype": "method",
|
|
"name": "get",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the pixel",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the pixel",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "w",
|
|
"description": "width",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "height",
|
|
"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<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Image",
|
|
"submodule": "Pixels"
|
|
},
|
|
{
|
|
"file": "src/image/pixels.js",
|
|
"line": 416,
|
|
"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[].",
|
|
"itemtype": "method",
|
|
"name": "loadPixels",
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Image",
|
|
"submodule": "Pixels"
|
|
},
|
|
{
|
|
"file": "src/image/pixels.js",
|
|
"line": 447,
|
|
"description": "<p>Changes the color of any pixel, or writes an image directly to the\ndisplay window.</p>\n<p>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</p>\n<p>\nAfter using set(), you must call updatePixels() for your changes to\nappear. This should be called once all pixels have been set.\n</p>\n<p>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.</p>\n<p>See the reference for pixels[] for more information.</p>",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the pixel",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the pixel",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "c",
|
|
"description": "insert a grayscale value | a pixel array |\n a p5.Color object | a p5.Image to copy",
|
|
"type": "Number|Array|Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\nvar black = color(0);\nset(30, 20, black);\nset(85, 20, black);\nset(85, 75, black);\nset(30, 75, black);\nupdatePixels();\n</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>\n\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Image",
|
|
"submodule": "Pixels"
|
|
},
|
|
{
|
|
"file": "src/image/pixels.js",
|
|
"line": 515,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "updatePixels",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the upper-left corner of region\n to update",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the upper-left corner of region\n to update",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "w",
|
|
"description": "width of region to update",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "w",
|
|
"description": "height of region to update",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "loadFont",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "name of the file or url to load",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after\n loadFont()\n completes",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "p5.Font object",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n\n<p>Calling loadFont() inside preload() guarantees that the load\noperation will have completed before setup() and draw() are called.</p>\n\n<div><code>\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</code></div>\n\n<p>Outside of preload(), you may supply a callback function to handle the\nobject:</p>\n\n<div><code>\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</code></div>\n\n<p>You can also use the string name of the font to style other HTML\nelements.</p>\n\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "loadJSON",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "name of the file or url to load",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after\n loadJSON() completes, data is passed\n in as first argument",
|
|
"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",
|
|
"type": "Function",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "datatype",
|
|
"description": "\"json\" or \"jsonp\"",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "JSON data",
|
|
"type": "Object|Array"
|
|
},
|
|
"example": [
|
|
"\n\n<p>Calling loadJSON() inside preload() guarantees to complete the\noperation before setup() and draw() are called.</p>\n\n<div><code>\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</code></div>\n\n\n<p>Outside of preload(), you may supply a callback function to handle the\nobject:</p>\n<div><code>\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</code></div>\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<br><br>\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<br><br>\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed.",
|
|
"itemtype": "method",
|
|
"name": "loadStrings",
|
|
"params": [
|
|
{
|
|
"name": "filename",
|
|
"description": "name of the file or url to load",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after loadStrings()\n completes, Array is passed in as first\n argument",
|
|
"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",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Array of Strings",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n\n<p>Calling loadStrings() inside preload() guarantees to complete the\noperation before setup() and draw() are called.</p>\n\n<div><code>\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</code></div>\n\n<p>Outside of preload(), you may supply a callback function to handle the\nobject:</p>\n\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Input"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 376,
|
|
"description": "<p>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.</p>\n\n<p>Possible options include:\n<ul>\n<li>csv - parse the table as comma-separated values</li>\n<li>tsv - parse the table as tab-separated values</li>\n<li>header - this table has a header (title) row</li>\n</ul>\n</p>\n\n<p>When passing in multiple options, pass them in as separate parameters,\nseperated by commas. For example:\n<br><br>\n<code>\n loadTable(\"my_csv_file.csv\", \"csv\", \"header\")\n</code>\n</p>\n\n<p> All files loaded and saved use UTF-8 encoding.</p>\n\n<p>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<p>Outside of preload(), you may supply a callback function to handle the\nobject:</p>\n</p>",
|
|
"itemtype": "method",
|
|
"name": "loadTable",
|
|
"params": [
|
|
{
|
|
"name": "filename",
|
|
"description": "name of the file or URL to load",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "options",
|
|
"description": "\"header\" \"csv\" \"tsv\"",
|
|
"type": "String|Strings",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after\n loadTable() completes, Table object is\n passed in as first argument",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Table object containing data",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(table.getRowCount() + \" total rows in table\");\n print(table.getColumnCount() + \" total columns in table\");\n\n print(table.getColumn(\"name\"));\n //[\"Goat\", \"Leopard\", \"Zebra\"]\n\n //cycle through the table\n for (var r = 0; r < table.getRowCount(); r++)\n for (var c = 0; c < table.getColumnCount(); c++) {\n print(table.getString(r, c));\n }\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Input"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 657,
|
|
"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<br><br>\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<br><br>\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. Calling loadXML() inside preload()\nguarantees to complete the operation before setup() and draw() are called.\n<br><br>\nOutside 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",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after loadXML()\n completes, XML object is passed in as\n first argument",
|
|
"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",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "XML object containing data",
|
|
"type": "Object"
|
|
},
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Input"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 739,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "httpGet",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "name of the file or url to load",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "data",
|
|
"description": "param data passed sent with request",
|
|
"type": "Object",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "datatype",
|
|
"description": "\"json\", \"jsonp\", \"xml\", or \"text\"",
|
|
"type": "String",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after\n httpGet() completes, data is passed in\n as first argument",
|
|
"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",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Input"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 760,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "httpPost",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "name of the file or url to load",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "data",
|
|
"description": "param data passed sent with request",
|
|
"type": "Object",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "datatype",
|
|
"description": "\"json\", \"jsonp\", \"xml\", or \"text\"",
|
|
"type": "String",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after\n httpGet() completes, data is passed in\n as first argument",
|
|
"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",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Input"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 781,
|
|
"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.<br><br>\nYou may also pass a single object specifying all parameters for the\nrequest following the examples inside the reqwest() calls here:\n<a href='https://github.com/ded/reqwest#api'\n>https://github.com/ded/reqwest#api</a>",
|
|
"itemtype": "method",
|
|
"name": "httpDo",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "name of the file or url to load",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "method",
|
|
"description": "either \"GET\", \"POST\", or \"PUT\",\n defaults to \"GET\"",
|
|
"type": "String",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "data",
|
|
"description": "param data passed sent with request",
|
|
"type": "Object",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "datatype",
|
|
"description": "\"json\", \"jsonp\", \"xml\", or \"text\"",
|
|
"type": "String",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be executed after\n httpGet() completes, data is passed in\n as first argument",
|
|
"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",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Input"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 967,
|
|
"description": "<p>Save an image, text, json, csv, wav, or html. Prompts download to\nthe client's computer. <b>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.</b></p>\n<p>The default behavior is to save the canvas as an image. You can\noptionally specify a filename.\nFor example:</p>\n<pre class='language-javascript'><code>\nsave();\nsave('myCanvas.jpg'); // save a specific canvas with a filename\n</code></pre>\n\n<p>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:</p>\n\n<pre class='language-javascript'><code>\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</code></pre>",
|
|
"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).",
|
|
"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).",
|
|
"type": "[String]"
|
|
},
|
|
{
|
|
"name": "options",
|
|
"description": "Additional options depend on\n filetype. For example, when saving JSON,\n <code>true</code> indicates that the\n output will be optimized for filesize,\n rather than readability.",
|
|
"type": "[Boolean/String]"
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Output"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 1084,
|
|
"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.",
|
|
"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).",
|
|
"type": "Boolean",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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// saveJSONObject(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</div></code>"
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Output"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 1140,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "saveStrings",
|
|
"params": [
|
|
{
|
|
"name": "list",
|
|
"description": "string array to be written",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "filename",
|
|
"description": "filename for output",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Output"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 1205,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "saveTable",
|
|
"params": [
|
|
{
|
|
"name": "Table",
|
|
"description": "the Table object to save to a file",
|
|
"type": "p5.Table"
|
|
},
|
|
{
|
|
"name": "filename",
|
|
"description": "the filename to which the Table should be saved",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "options",
|
|
"description": "can be one of \"tsv\", \"csv\", or \"html\"",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Output"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 1320,
|
|
"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.",
|
|
"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": 1343,
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "href",
|
|
"description": "i.e. an href generated by createObjectURL",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "filename",
|
|
"description": "",
|
|
"type": "[String]"
|
|
},
|
|
{
|
|
"name": "extension",
|
|
"description": "",
|
|
"type": "[String]"
|
|
}
|
|
],
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Output"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 1379,
|
|
"description": "Returns a file extension, or another string\nif the provided parameter has no extension.",
|
|
"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": 1411,
|
|
"description": "Returns true if the browser is Safari, false if not.\nSafari makes trouble for downloading files.",
|
|
"return": {
|
|
"description": "[description]",
|
|
"type": "Boolean"
|
|
},
|
|
"access": "private",
|
|
"tagname": "",
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Output"
|
|
},
|
|
{
|
|
"file": "src/io/files.js",
|
|
"line": 1423,
|
|
"description": "Helper function, a callback for download that deletes\nan invisible anchor element from the DOM once the file\nhas been automatically downloaded.",
|
|
"access": "private",
|
|
"tagname": "",
|
|
"class": "p5",
|
|
"module": "IO",
|
|
"submodule": "Output"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 12,
|
|
"description": "Table Options\n<p>Generic class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.</p>\n<p>CSV files are\n<a href=\"http://en.wikipedia.org/wiki/Comma-separated_values\">\ncomma separated values</a>, often with the data in quotes. TSV\nfiles use tabs as separators, and usually don't bother with the\nquotes.</p>\n<p>File names should end with .csv if they're comma separated.</p>\n<p>A rough \"spec\" for CSV can be found\n<a href=\"http://tools.ietf.org/html/rfc4180\">here</a>.</p>\n<p>To load files, use the loadTable method.</p>\n<p>To save tables to your computer, use the save method\n or the saveTable method.</p>\n\nPossible options include:\n<ul>\n<li>csv - parse the table as comma-separated values\n<li>tsv - parse the table as tab-separated values\n<li>header - this table has a header (title) row\n</ul>",
|
|
"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\nIf a p5.TableRow object is included as a parameter, then that row is\nduplicated and added to the table.",
|
|
"itemtype": "method",
|
|
"name": "addRow",
|
|
"params": [
|
|
{
|
|
"name": "row",
|
|
"description": "row to be added to the table",
|
|
"type": "p5.TableRow",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(table.getString(r, c));\n }\n </code>\n </div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 119,
|
|
"description": "Removes a row from the table object.",
|
|
"itemtype": "method",
|
|
"name": "removeRow",
|
|
"params": [
|
|
{
|
|
"name": "id",
|
|
"description": "ID number of the row to remove",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(table.getString(r, c));\n}\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getRow",
|
|
"params": [
|
|
{
|
|
"name": "rowID",
|
|
"description": "ID number of the row to get",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "p5.TableRow object",
|
|
"type": "TableRow"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(row.getString(c));\n}\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getRows",
|
|
"return": {
|
|
"description": "Array of p5.TableRows",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(table.getString(r, c));\n }\n </code>\n </div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "findRow",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "The value to match",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "ID number or title of the\n column to search",
|
|
"type": "Number|String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "TableRow"
|
|
},
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(row.getString(\"species\"));\n }\n </code>\n </div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "findRows",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "The value to match",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "ID number or title of the\n column to search",
|
|
"type": "Number|String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "An Array of TableRow objects",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(rows.length + \" Goats found\");\n }\n </code>\n </div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "matchRow",
|
|
"params": [
|
|
{
|
|
"name": "regexp",
|
|
"description": "The regular expression to match",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "The column ID (number) or\n title (string)",
|
|
"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 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 specified\nby either its ID or title.",
|
|
"itemtype": "method",
|
|
"name": "matchRows",
|
|
"params": [
|
|
{
|
|
"name": "regexp",
|
|
"description": "The regular expression to match",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "The column ID (number) or\n title (string)",
|
|
"type": "String|Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "An Array of TableRow objects",
|
|
"type": "Array"
|
|
},
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 443,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getColumn",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "String or Number of the column to return",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Array of column values",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(table.getColumn(\"species\"));\n //outputs [\"Capra hircus\", \"Panthera pardus\", \"Equus zebra\"]\n }\n </code>\n </div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 492,
|
|
"description": "Removes all rows from a Table. While all rows are removed,\ncolumns and column titles are maintained.",
|
|
"itemtype": "method",
|
|
"name": "clearRows",
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(table.getRowCount() + \" total rows in table\");\n print(table.getColumnCount() + \" total columns in table\");\n }\n </code>\n </div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 530,
|
|
"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.)",
|
|
"itemtype": "method",
|
|
"name": "addColumn",
|
|
"params": [
|
|
{
|
|
"name": "title",
|
|
"description": "title of the given column",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(table.getString(r, c));\n }\n </code>\n </div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 577,
|
|
"description": "Returns the total number of columns in a Table.",
|
|
"return": {
|
|
"description": "Number of columns in this table",
|
|
"type": "Number"
|
|
},
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 586,
|
|
"description": "Returns the total number of rows in a Table.",
|
|
"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": 597,
|
|
"description": "<p>Removes any of the specified characters (or \"tokens\").</p>\n\n<p>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.</p>",
|
|
"itemtype": "method",
|
|
"name": "removeTokens",
|
|
"params": [
|
|
{
|
|
"name": "chars",
|
|
"description": "String listing characters to be removed",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "Column ID (number)\n or name (string)",
|
|
"type": "String|Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 648,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "trim",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "Column ID (number)\n or name (string)",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 690,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "removeColumn",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "columnName (string) or ID (number)",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n <div class=\"norender\">\n <code>\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 print(table.getColumnCount());\n }\n </code>\n </div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 755,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "column ID (Number)\n or title (String)",
|
|
"type": "String|Number"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(table.getString(r, c));\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 800,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setNum",
|
|
"params": [
|
|
{
|
|
"name": "row",
|
|
"description": "row ID",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "column ID (Number)\n or title (String)",
|
|
"type": "String|Number"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(table.getColumn(0));\n //[\"0\", 1, \"2\"]\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 844,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setString",
|
|
"params": [
|
|
{
|
|
"name": "row",
|
|
"description": "row ID",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "column ID (Number)\n or title (String)",
|
|
"type": "String|Number"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 859,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "get",
|
|
"params": [
|
|
{
|
|
"name": "row",
|
|
"description": "row ID",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "columnName (string) or\n ID (number)",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "String|Number"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(table.get(0, 1));\n //Capra hircus\n print(table.get(0, \"species\"));\n //Capra hircus\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 902,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getNum",
|
|
"params": [
|
|
{
|
|
"name": "row",
|
|
"description": "row ID",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "columnName (string) or\n ID (number)",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(table.getNum(1, 0) + 100);\n //id 1 + 100 = 101\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 943,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getString",
|
|
"params": [
|
|
{
|
|
"name": "row",
|
|
"description": "row ID",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "column",
|
|
"description": "columnName (string) or\n ID (number)",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "String"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(tableArray[i]);\n}\n</code>\n</div>"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 987,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getObject",
|
|
"params": [
|
|
{
|
|
"name": "headerColumn",
|
|
"description": "Name of the column which should be used to\n title each row object (optional)",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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 print(tableObject);\n //outputs an object\n}\n</code>\n</div>\n"
|
|
],
|
|
"class": "p5.Table",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"file": "src/io/p5.Table.js",
|
|
"line": 1048,
|
|
"description": "Retrieves all table data and returns it as a multidimensional array.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "Column ID (Number)\n or Title (String)",
|
|
"type": "String|Number"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "The value to be stored",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setNum",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "Column ID (Number)\n or Title (String)",
|
|
"type": "String|Number"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "The value to be stored\n as a Float",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setString",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "Column ID (Number)\n or Title (String)",
|
|
"type": "String|Number"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "The value to be stored\n as a String",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "get",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "columnName (string) or\n ID (number)",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getNum",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "columnName (string) or\n ID (number)",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getString",
|
|
"params": [
|
|
{
|
|
"name": "column",
|
|
"description": "columnName (string) or\n ID (number)",
|
|
"type": "String|Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "String",
|
|
"type": "String"
|
|
},
|
|
"class": "p5.TableRow",
|
|
"module": "IO",
|
|
"submodule": "Table"
|
|
},
|
|
{
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "abs",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "number to compute",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "absolute value of given number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var x = -3;\n var y = abs(x);\n\n print(x); // -3\n print(y); // 3\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "ceil",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "number to round up",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "rounded up number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Calculation"
|
|
},
|
|
{
|
|
"file": "src/math/calculation.js",
|
|
"line": 68,
|
|
"description": "Constrains a value between a minimum and maximum value.",
|
|
"itemtype": "method",
|
|
"name": "constrain",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "number to constrain",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "low",
|
|
"description": "minimum limit",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "high",
|
|
"description": "maximum limit",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "constrained number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Calculation"
|
|
},
|
|
{
|
|
"file": "src/math/calculation.js",
|
|
"line": 108,
|
|
"description": "Calculates the distance between two points.",
|
|
"itemtype": "method",
|
|
"name": "dist",
|
|
"params": [
|
|
{
|
|
"name": "x1",
|
|
"description": "x-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y1",
|
|
"description": "y-coordinate of the first point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "z1",
|
|
"description": "z-coordinate of the first point",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "x2",
|
|
"description": "x-coordinate of the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "y-coordinate of the second point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "z2",
|
|
"description": "z-coordinate of the second point",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "distance between the two points",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "exp",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "exponent to raise",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "e^n",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "floor",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "number to round down",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "rounded down number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "lerp",
|
|
"params": [
|
|
{
|
|
"name": "start",
|
|
"description": "first value",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "stop",
|
|
"description": "second value",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "amt",
|
|
"description": "number between 0.0 and 1.0",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "lerped value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "log",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "number greater than 0",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "natural logarithm of n",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "mag",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "first value",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "second value",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "magnitude of vector from (0,0) to (a,b)",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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 print(mag(x1, y1)); // Prints \"36.05551\"\n line(0, 0, x2, y1);\n print(mag(x2, y1)); // Prints \"85.44004\"\n line(0, 0, x1, y2);\n print(mag(x1, y2)); // Prints \"72.8011\"\n line(0, 0, x2, y2);\n print(mag(x2, y2)); // Prints \"106.30146\"\n}\n</code></div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Calculation"
|
|
},
|
|
{
|
|
"file": "src/math/calculation.js",
|
|
"line": 364,
|
|
"description": "Re-maps a number from one range to another.\n<br><br>\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).",
|
|
"itemtype": "method",
|
|
"name": "map",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "the incoming value to be converted",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "start1",
|
|
"description": "lower bound of the value's current range",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "stop1",
|
|
"description": "upper bound of the value's current range",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "start2",
|
|
"description": "lower bound of the value's target range",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "stop",
|
|
"description": "upper bound of the value's target range",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "remapped number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n <div><code>\n var value = 25;\n var m = map(value, 0, 100, 0, width);\n ellipse(m, 50, 10, 10);\n </code></div>\n\n <div><code>\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 </code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "max",
|
|
"params": [
|
|
{
|
|
"name": "n0",
|
|
"description": "Numbers to compare",
|
|
"type": "Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "maximum Number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "min",
|
|
"params": [
|
|
{
|
|
"name": "n0",
|
|
"description": "Numbers to compare",
|
|
"type": "Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "minimum Number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.)",
|
|
"itemtype": "method",
|
|
"name": "norm",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "incoming value to be normalized",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "start",
|
|
"description": "lower bound of the value's current range",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "stop",
|
|
"description": "upper bound of the value's current range",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "normalized number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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\n3*3*3*3*3 and pow(3, -5) is equivalent to 1 / 3*3*3*3*3. Maps to\nMath.pow().",
|
|
"itemtype": "method",
|
|
"name": "pow",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "base of the exponential expression",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "e",
|
|
"description": "power by which to raise the base",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "n^e",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "round",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "number to round",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "rounded number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "sq",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "number to square",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "squared number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "sqrt",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "non-negative number to square root",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "square root of number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createVector",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "z component of the vector",
|
|
"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 <b>random()</b> 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.<br /><br /> The main difference to the\n<b>random()</b> 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.<br /><br />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. <br /><br />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 <b>noise()</b> 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.",
|
|
"itemtype": "method",
|
|
"name": "noise",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate in noise space",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate in noise space",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "z-coordinate in noise space",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Perlin noise value (between 0 and 1) at specified\n coordinates",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>var 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</code>\n</div>\n<div>\n<code>var 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</code>\n</div>"
|
|
],
|
|
"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 <br><br>\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 <b>noise()</b>.\n <br><br>\n By changing these parameters, the signal created by the <b>noise()</b>\n function can be adapted to fit very specific needs and characteristics.",
|
|
"itemtype": "method",
|
|
"name": "noiseDetail",
|
|
"params": [
|
|
{
|
|
"name": "lod",
|
|
"description": "number of octaves to be used by the noise",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "falloff",
|
|
"description": "falloff factor for each octave",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n <div>\n <code>\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 </code>\n </div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Noise"
|
|
},
|
|
{
|
|
"file": "src/math/noise.js",
|
|
"line": 223,
|
|
"description": "Sets the seed value for <b>noise()</b>. By default, <b>noise()</b>\nproduces different results each time the program is run. Set the\n<b>value</b> parameter to a constant to return the same pseudo-random\nnumbers each time the software is run.",
|
|
"itemtype": "method",
|
|
"name": "noiseSeed",
|
|
"params": [
|
|
{
|
|
"name": "seed",
|
|
"description": "the seed value",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>var 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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Noise"
|
|
},
|
|
{
|
|
"file": "src/math/p5.Vector.js",
|
|
"line": 65,
|
|
"description": "The x component of the vector",
|
|
"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",
|
|
"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",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "toString",
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var v = createVector(20,30);\n print(String(v)); // prints \"p5.Vector Object : [20, 30, 0]\"\n}\n</div></code>\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.",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "the x component of the vector or a\n p5.Vector or an Array",
|
|
"type": "Number|p5.Vector|Array",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "the y component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "the z component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "copy",
|
|
"return": {
|
|
"description": "the copy of the p5.Vector object",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v1 = createVector(1, 2, 3);\nvar v2 = v.copy();\nprint(v1.x == v2.x && v1.y == v2.y && v1.z == v2.z);\n// Prints \"true\"\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"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",
|
|
"type": "Number|p5.Vector|Array"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "the y component of the vector to be\n added",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "the z component of the vector to be\n added",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the p5.Vector object.",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v = createVector(1, 2, 3);\nv.add(4,5,6);\n// v's compnents are set to [5, 7, 9]\n</code>\n</div>\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "sub",
|
|
"chainable": 1,
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "the x component of the vector or a\n p5.Vector or an Array",
|
|
"type": "Number|p5.Vector|Array"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "the y component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "the z component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "p5.Vector object.",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v = createVector(4, 5, 6);\nv.sub(1, 1, 1);\n// v's compnents are set to [3, 4, 5]\n</code>\n</div>\n\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mult",
|
|
"chainable": 1,
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "the number to multiply with the vector",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "a reference to the p5.Vector object (allow chaining)",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v = createVector(1, 2, 3);\nv.mult(2);\n// v's compnents are set to [2, 4, 6]\n</code>\n</div>\n\n<div class=\"norender\">\n<code>\n// Static method\nvar v1 = createVector(1, 2, 3);\nvar v2 = p5.Vector.mult(v1, 2);\n// v2 has compnents [2, 4, 6]\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "div",
|
|
"chainable": 1,
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "the number to divide the vector by",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "a reference to the p5.Vector object (allow chaining)",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v = createVector(6, 4, 2);\nv.div(2); //v's compnents are set to [3, 2, 1]\n</code>\n</div>\n\n<div class=\"norender\">\n<code>\n// Static method\nvar v1 = createVector(6, 4, 2);\nvar v2 = p5.Vector.div(v, 2);\n// v2 has compnents [3, 2, 1]\n</code>\n</div>"
|
|
],
|
|
"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(x*x + y*y + z*z).)",
|
|
"itemtype": "method",
|
|
"name": "mag",
|
|
"return": {
|
|
"description": "magnitude of the vector",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v = createVector(20.0, 30.0, 40.0);\nvar m = v.mag(10);\nprint(m); // Prints \"53.85164807134504\"\n</code>\n</div>"
|
|
],
|
|
"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 <em>(x*x + y*y + z*z)</em>.)\nFaster if the real length is not required in the\ncase of comparing vectors, etc.",
|
|
"itemtype": "method",
|
|
"name": "magSq",
|
|
"return": {
|
|
"description": "squared magnitude of the vector",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\n// Static method\nvar v1 = createVector(6, 4, 2);\nprint(v1.magSq()); // Prints \"56\"\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "dot",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x component of the vector or a p5.Vector",
|
|
"type": "Number|p5.Vector"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "z component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the dot product",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v1 = createVector(1, 2, 3);\nvar v2 = createVector(2, 3, 4);\n\nprint(v1.dot(v2)); // Prints \"20\"\n</code>\n</div>\n\n<div class=\"norender\">\n<code>\n//Static method\nvar v1 = createVector(1, 2, 3);\nvar v2 = createVector(3, 2, 1);\nprint (p5.Vector.dot(v1, v2)); // Prints \"10\"\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "cross",
|
|
"params": [
|
|
{
|
|
"name": "v",
|
|
"description": "p5.Vector to be crossed",
|
|
"type": "p5.Vector"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "p5.Vector composed of cross product",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v1 = createVector(1, 2, 3);\nvar v2 = createVector(1, 2, 3);\n\nv1.cross(v2); // v's components are [0, 0, 0]\n</code>\n</div>\n\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "dist",
|
|
"params": [
|
|
{
|
|
"name": "v",
|
|
"description": "the x, y, and z coordinates of a p5.Vector",
|
|
"type": "p5.Vector"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the distance",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v1 = createVector(1, 0, 0);\nvar v2 = createVector(0, 1, 0);\n\nvar distance = v1.dist(v2); // distance is 1.4142...\n</code>\n</div>\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "normalize",
|
|
"return": {
|
|
"description": "normalized p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>\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 <b>max</b>\nparameter.",
|
|
"itemtype": "method",
|
|
"name": "limit",
|
|
"params": [
|
|
{
|
|
"name": "max",
|
|
"description": "the maximum magnitude for the vector",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the modified p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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 <b>len</b>\nparameter.",
|
|
"itemtype": "method",
|
|
"name": "setMag",
|
|
"params": [
|
|
{
|
|
"name": "len",
|
|
"description": "the new length for this vector",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the modified p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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)",
|
|
"itemtype": "method",
|
|
"name": "heading",
|
|
"return": {
|
|
"description": "the angle of rotation",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var v1 = createVector(30,50);\n print(v1.heading()); // 1.0303768265243125\n\n var v1 = createVector(40,50);\n print(v1.heading()); // 0.8960553845713439\n\n var v1 = createVector(30,70);\n print(v1.heading()); // 1.1659045405098132\n}\n</div></code>"
|
|
],
|
|
"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",
|
|
"itemtype": "method",
|
|
"name": "rotate",
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "the angle of rotation",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the modified p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5.Vector",
|
|
"module": "Math",
|
|
"submodule": "Math"
|
|
},
|
|
{
|
|
"file": "src/math/p5.Vector.js",
|
|
"line": 624,
|
|
"description": "Linear interpolate the vector to another vector",
|
|
"itemtype": "method",
|
|
"name": "lerp",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "the x component or the p5.Vector to lerp to",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y the y component",
|
|
"type": "p5.Vector",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "z the z component",
|
|
"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.",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the modified p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar v = createVector(1, 1, 0);\n\nv.lerp(3, 3, 0, 0.5); // v now has components [2,2,0]\n</code>\n</div>\n\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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 <b>p5.Vector.copy()</b> method to copy into your own\narray.",
|
|
"itemtype": "method",
|
|
"name": "array",
|
|
"return": {
|
|
"description": "an Array with the 3 values",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var v = createVector(20,30);\n print(v.array()); // Prints : Array [20, 30, 0]\n}\n</div></code>\n<div class=\"norender\">\n<code>\nvar v = createVector(10.0, 20.0, 30.0);\nvar f = v.array();\nprint(f[0]); // Prints \"10.0\"\nprint(f[1]); // Prints \"20.0\"\nprint(f[2]); // Prints \"30.0\"\n</code>\n</div>"
|
|
],
|
|
"class": "p5.Vector",
|
|
"module": "Math",
|
|
"submodule": "Math"
|
|
},
|
|
{
|
|
"file": "src/math/p5.Vector.js",
|
|
"line": 693,
|
|
"description": "Equality check against a p5.Vector",
|
|
"itemtype": "method",
|
|
"name": "equals",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "the x component of the vector or a\n p5.Vector or an Array",
|
|
"type": "Number|p5.Vector|Array",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "the y component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "z",
|
|
"description": "the z component of the vector",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "whether the vectors are equals",
|
|
"type": "Boolean"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nv1 = createVector(5,10,20);\nv2 = createVector(5,10,20);\nv3 = createVector(13,10,19);\n\nprint(v1.equals(v2.x,v2.y,v2.z)); // true\nprint(v1.equals(v3.x,v3.y,v3.z)); // false\n</div></code>\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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",
|
|
"itemtype": "method",
|
|
"name": "fromAngle",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "the desired angle",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the new p5.Vector object",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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",
|
|
"itemtype": "method",
|
|
"name": "random2D",
|
|
"static": 1,
|
|
"return": {
|
|
"description": "the new p5.Vector object",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5.Vector",
|
|
"module": "Math",
|
|
"submodule": "Math"
|
|
},
|
|
{
|
|
"file": "src/math/p5.Vector.js",
|
|
"line": 833,
|
|
"description": "Make a new random 3D unit vector.",
|
|
"itemtype": "method",
|
|
"name": "random3D",
|
|
"static": 1,
|
|
"return": {
|
|
"description": "the new p5.Vector object",
|
|
"type": "p5.Vector"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "a p5.Vector to add",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "a p5.Vector to add",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "target",
|
|
"description": "if undefined a new vector will be created",
|
|
"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.",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "a p5.Vector to subtract from",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "a p5.Vector to subtract",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "target",
|
|
"description": "if undefined a new vector will be created",
|
|
"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.",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v",
|
|
"description": "the p5.Vector to multiply",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "n",
|
|
"description": "the scalar",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "target",
|
|
"description": "if undefined a new vector will be created",
|
|
"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.",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v",
|
|
"description": "the p5.Vector to divide",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "n",
|
|
"description": "the scalar",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "target",
|
|
"description": "if undefined a new vector will be created",
|
|
"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.",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "the first p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "the second p5.Vector",
|
|
"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.",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "the first p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "the second p5.Vector",
|
|
"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).",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "the first p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "the second p5.Vector",
|
|
"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.",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "a starting p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "the p5.Vector to lerp to",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "angleBetween",
|
|
"static": 1,
|
|
"params": [
|
|
{
|
|
"name": "v1",
|
|
"description": "the x, y, and z components of a p5.Vector",
|
|
"type": "p5.Vector"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "the x, y, and z components of a p5.Vector",
|
|
"type": "p5.Vector"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the angle between (in radians)",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5.Vector",
|
|
"module": "Math",
|
|
"submodule": "Math"
|
|
},
|
|
{
|
|
"file": "src/math/random.js",
|
|
"line": 45,
|
|
"description": "Sets the seed value for random().\n\nBy 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.",
|
|
"itemtype": "method",
|
|
"name": "randomSeed",
|
|
"params": [
|
|
{
|
|
"name": "seed",
|
|
"description": "the seed value",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Random"
|
|
},
|
|
{
|
|
"file": "src/math/random.js",
|
|
"line": 71,
|
|
"description": "Return a random number.\n\nTakes either 0, 1 or 2 arguments.\nIf no argument is given, returns a random number between 0 and 1.\nIf one argument is given, returns a random number between 0 and the number.\nIf two arguments are given, returns a random number between them,\ninclusive.",
|
|
"itemtype": "method",
|
|
"name": "random",
|
|
"params": [
|
|
{
|
|
"name": "min",
|
|
"description": "the lower bound",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "max",
|
|
"description": "the upper bound",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the random number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n<div>\n<code>\nfor (var i = 0; i < 100; i++) {\n var r = random(-50, 50);\n line(50,i,50+r,i);\n}\n</code>\n</div>\n<div>\n<code>\n// Get a random element from an array\nvar words = [ \"apple\", \"bear\", \"cat\", \"dog\" ];\nvar index = floor(random(words.length)); // Convert to integer\ntext(words[index],10,50); // Displays one of the four words\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Random"
|
|
},
|
|
{
|
|
"file": "src/math/random.js",
|
|
"line": 138,
|
|
"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 <br><br>\n Takes either 0, 1 or 2 arguments.<br>\n If no args, returns a mean of 0 and standard deviation of 1.<br>\n If one arg, that arg is the mean (standard deviation is 1).<br>\n If two args, first is mean, second is standard deviation.",
|
|
"itemtype": "method",
|
|
"name": "randomGaussian",
|
|
"params": [
|
|
{
|
|
"name": "mean",
|
|
"description": "the mean",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "sd",
|
|
"description": "the standard deviation",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the random number",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n <div>\n <code>for (var y = 0; y < 100; y++) {\n var x = randomGaussian(50,15);\n line(50, y, x, y);\n}\n </code>\n </div>\n <div>\n <code>\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 </code>\n </div>"
|
|
],
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "acos",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "the value whose arc cosine is to be returned",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the arc cosine of the given value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class= “norender\">\n<code>\nvar a = PI;\nvar c = cos(a);\nvar ac = acos(c);\n// Prints: \"3.1415927 : -1.0 : 3.1415927\"\nprintln(a + \" : \" + c + \" : \" + ac);\n</code>\n</div>\n\n<div class= “norender\">\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "asin",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "the value whose arc sine is to be returned",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the arc sine of the given value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class= “norender\">\n<code>\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</code>\n</div>\n\n<div class= “norender\">\n<code>\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</code>\n</div>\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.",
|
|
"itemtype": "method",
|
|
"name": "atan",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "the value whose arc tangent is to be returned",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the arc tangent of the given value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class= “norender\">\n<code>\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</code>\n</div>\n\n<div class= “norender\">\n<code>\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</code>\n</div>\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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "atan2",
|
|
"params": [
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of the point",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of the point",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the arc tangent of the given point",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "cos",
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "the angle",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the cosine of the angle",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\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.",
|
|
"itemtype": "method",
|
|
"name": "sin",
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "the angle",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the sine of the angle",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "tan",
|
|
"params": [
|
|
{
|
|
"name": "angle",
|
|
"description": "the angle",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the tangent of the angle",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\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.",
|
|
"itemtype": "method",
|
|
"name": "degrees",
|
|
"params": [
|
|
{
|
|
"name": "radians",
|
|
"description": "the radians value to convert to degrees",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the converted angle",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class= “norender\">\n<code>\nvar rad = PI/4;\nvar deg = degrees(rad);\nprintln(rad + \" radians is \" + deg + \" degrees\");\n// Prints: 45 degrees is 0.7853981633974483 radians\n</code>\n</div>\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.",
|
|
"itemtype": "method",
|
|
"name": "radians",
|
|
"params": [
|
|
{
|
|
"name": "degrees",
|
|
"description": "the degree value to convert to radians",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the converted angle",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class= “norender\">\n<code>\nvar deg = 45.0;\nvar rad = radians(deg);\nprintln(deg + \" degrees is \" + rad + \" radians\");\n// Prints: 45 degrees is 0.7853981633974483 radians\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "angleMode",
|
|
"params": [
|
|
{
|
|
"name": "mode",
|
|
"description": "either RADIANS or DEGREES",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>\n"
|
|
],
|
|
"class": "p5",
|
|
"module": "Math",
|
|
"submodule": "Trigonometry"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 13,
|
|
"description": "Sets the current alignment for drawing text. The parameters LEFT, CENTER,\nand RIGHT set the alignment of text in relation to the values for\nthe x and y parameters of the text() function.",
|
|
"itemtype": "method",
|
|
"name": "textAlign",
|
|
"params": [
|
|
{
|
|
"name": "horizAlign",
|
|
"description": "horizontal alignment, either LEFT,\n CENTER, or RIGHT",
|
|
"type": "Number/Constant"
|
|
},
|
|
{
|
|
"name": "vertAlign",
|
|
"description": "vertical alignment, either TOP,\n BOTTOM, CENTER, or BASELINE",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntextSize(16);\ntextAlign(RIGHT);\ntext(\"ABCD\", 50, 30);\ntextAlign(CENTER);\ntext(\"EFGH\", 50, 50);\ntextAlign(LEFT);\ntext(\"IJKL\", 50, 70);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Attributes"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 41,
|
|
"description": "Sets/gets the spacing, in pixels, between lines of text. This\nsetting will be used in all subsequent calls to the text() function.",
|
|
"itemtype": "method",
|
|
"name": "textLeading",
|
|
"params": [
|
|
{
|
|
"name": "leading",
|
|
"description": "the size in pixels for spacing between lines",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object|Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Attributes"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 70,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "textSize",
|
|
"params": [
|
|
{
|
|
"name": "theSize",
|
|
"description": "the size of the letters in units of pixels",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object|Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Attributes"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 93,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "textStyle",
|
|
"params": [
|
|
{
|
|
"name": "theStyle",
|
|
"description": "styling for text, either NORMAL,\n ITALIC, or BOLD",
|
|
"type": "Number/Constant"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object|String"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Attributes"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 120,
|
|
"description": "Calculates and returns the width of any character or text string.",
|
|
"itemtype": "method",
|
|
"name": "textWidth",
|
|
"params": [
|
|
{
|
|
"name": "theText",
|
|
"description": "the String of characters to measure",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Attributes"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 147,
|
|
"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.",
|
|
"return": {
|
|
"description": "",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Attributes"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 175,
|
|
"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.",
|
|
"return": {
|
|
"description": "",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Attributes"
|
|
},
|
|
{
|
|
"file": "src/typography/attributes.js",
|
|
"line": 203,
|
|
"description": "Helper function to measure ascent and descent.",
|
|
"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<br><br>\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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "text",
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "the alphanumeric symbols to be displayed",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "x-coordinate of text",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-coordinate of text",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "x2",
|
|
"description": "by default, the width of the text box,\n see rectMode() for more info",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y2",
|
|
"description": "by default, the height of the text box,\n see rectMode() for more info",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\ntextSize(32);\ntext(\"word\", 10, 30);\nfill(0, 102, 153);\ntext(\"word\", 10, 60);\nfill(0, 102, 153, 51);\ntext(\"word\", 10, 90);\n</code>\n</div>\n<div>\n<code>\ns = \"The quick brown fox jumped over the lazy dog.\";\nfill(50);\ntext(s, 10, 10, 70, 80); // Text wraps within text box\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "textFont",
|
|
"params": [
|
|
{
|
|
"name": "f",
|
|
"description": "a font loaded via loadFont(), or a String\n representing a browser-based dfault font.",
|
|
"type": "Object|String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "this",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nfill(0);\ntextSize(12);\ntextFont(\"Georgia\");\ntext(\"Georgia\", 12, 30);\ntextFont(\"Helvetica\");\ntext(\"Helvetica\", 12, 60);\n</code>\n</div>\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Typography",
|
|
"submodule": "Loading & Displaying"
|
|
},
|
|
{
|
|
"file": "src/typography/p5.Font.js",
|
|
"line": 44,
|
|
"description": "Underlying opentype font implementation",
|
|
"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)",
|
|
"itemtype": "method",
|
|
"name": "textBounds",
|
|
"params": [
|
|
{
|
|
"name": "line",
|
|
"description": "a line of text",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "x-position",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-position",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "fontSize",
|
|
"description": "font size to use (optional)",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "options",
|
|
"description": "opentype options (optional)",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "a rectangle object with properties: x, y, w, h",
|
|
"type": "Object"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"class": "p5.Font",
|
|
"module": "Typography",
|
|
"submodule": "Font"
|
|
},
|
|
{
|
|
"file": "src/typography/p5.Font.js",
|
|
"line": 149,
|
|
"description": "Computes an array of points following the path for specified text",
|
|
"params": [
|
|
{
|
|
"name": "txt",
|
|
"description": "a line of text",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "x-position",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-position",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "fontSize",
|
|
"description": "font size to use (optional)",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "options",
|
|
"description": "an (optional) object that can contain:\n\n<br>sampleFactor - the ratio of path-length to number of samples\n(default=.25); higher values yield more points and are therefore\nmore precise\n\n<br>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",
|
|
"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": 197,
|
|
"description": "Returns 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.",
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "the string to be converted",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "the opentype glyphs",
|
|
"type": "Array"
|
|
},
|
|
"class": "p5.Font",
|
|
"module": "Typography",
|
|
"submodule": "Font"
|
|
},
|
|
{
|
|
"file": "src/typography/p5.Font.js",
|
|
"line": 212,
|
|
"description": "Returns an opentype path for the supplied string and position.",
|
|
"params": [
|
|
{
|
|
"name": "line",
|
|
"description": "a line of text",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "x",
|
|
"description": "x-position",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-position",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "options",
|
|
"description": "opentype options (optional)",
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "append",
|
|
"params": [
|
|
{
|
|
"name": "array",
|
|
"description": "Array to append",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "to be added to the Array",
|
|
"type": "Any"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n\nvar myArray = new Array(\"Mango\", \"Apple\", \"Papaya\")\nprint(myArray) // [\"Mango\", \"Apple\", \"Papaya\"]\n\nappend(myArray, \"Peach\")\nprint(myArray) // [\"Mango\", \"Apple\", \"Papaya\", \"Peach\"]\n\n}\n</div></code>"
|
|
],
|
|
"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<br><br>\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<br><br>\nUsing this function is far more efficient for copying array data than\niterating through a for() loop and copying each element individually.",
|
|
"itemtype": "method",
|
|
"name": "arrayCopy",
|
|
"params": [
|
|
{
|
|
"name": "src",
|
|
"description": "the source Array",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "srcPosition",
|
|
"description": "starting position in the source Array",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "dst",
|
|
"description": "the destination Array",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "dstPosition",
|
|
"description": "starting position in the destination Array",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "length",
|
|
"description": "number of Array elements to be copied",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n <div class=\"norender\"><code>\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 print(src); // [\"A\", \"B\", \"C\"]\n print(dst); // [ 1 , 2 , 3 ]\n\n arrayCopy(src, srcPosition, dst, dstPosition, length);\n print(dst); // [\"B\", \"C\", 3]\n\n }\n </div></code>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "concat",
|
|
"params": [
|
|
{
|
|
"name": "a",
|
|
"description": "first Array to concatenate",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "b",
|
|
"description": "second Array to concatenate",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "concatenated array",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var arr1 = new Array(\"A\", \"B\", \"C\");\n var arr2 = new Array( 1 , 2 , 3 );\n\n print(arr1); // [\"A\",\"B\",\"C\"]\n print(arr2); // [1,2,3]\n\n var arr3 = concat(arr1, arr2);\n\n print(arr1); // [\"A\",\"B\",\"C\"]\n print(arr2); // [1,2,3]\n print(arr3); // [\"A\",\"B\",\"C\",1,2,3]\n\n}\n</div></code>"
|
|
],
|
|
"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()",
|
|
"itemtype": "method",
|
|
"name": "reverse",
|
|
"params": [
|
|
{
|
|
"name": "list",
|
|
"description": "Array to reverse",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class=\"norender\"><code>\nfunction setup() {\n var myArray = new Array(\"A\", \"B\", \"C\");\n print(myArray); // [\"A\",\"B\",\"C\"]\n\n reverse(myArray);\n print(myArray); // [\"C\",\"B\",\"A\"]\n}\n</div></code>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "shorten",
|
|
"params": [
|
|
{
|
|
"name": "list",
|
|
"description": "Array to shorten",
|
|
"type": "Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "shortened Array",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var myArray = new Array(\"A\", \"B\", \"C\");\n print(myArray); // [\"A\",\"B\",\"C\"]\n\n var newArray = shorten(myArray);\n print(myArray); // [\"A\",\"B\",\"C\"]\n print(newArray); // [\"A\",\"B\"]\n}\n</div></code>"
|
|
],
|
|
"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<a href=\"http://Bost.Ocks.org/mike/shuffle/\" target=_blank>\nFisher-Yates Shuffle Algorithm</a>.",
|
|
"itemtype": "method",
|
|
"name": "shuffle",
|
|
"params": [
|
|
{
|
|
"name": "array",
|
|
"description": "Array to shuffle",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "bool",
|
|
"description": "modify passed array",
|
|
"type": "Boolean",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "shuffled Array",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\nfunction setup() {\n var regularArr = ['ABC', 'def', createVector(), TAU, Math.E];\n print(regularArr);\n shuffle(regularArr, true); // force modifications to passed array\n print(regularArr);\n\n // By default shuffle() returns a shuffled cloned array:\n var newArr = shuffle(regularArr);\n print(regularArr);\n print(newArr);\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "sort",
|
|
"params": [
|
|
{
|
|
"name": "list",
|
|
"description": "Array to sort",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "count",
|
|
"description": "number of elements to sort, starting from 0",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var words = new Array(\"banana\", \"apple\", \"pear\",\"lime\");\n print(words); // [\"banana\", \"apple\", \"pear\", \"lime\"]\n var count = 4; // length of array\n\n sort(words, count);\n print(words); // [\"apple\", \"banana\", \"lime\", \"pear\"]\n}\n</div></code>\n<div class = \"norender\"><code>\nfunction setup() {\n var numbers = new Array(2,6,1,5,14,9,8,12);\n print(numbers); // [2,6,1,5,14,9,8,12]\n var count = 5; // Less than the length of the array\n\n sort(numbers, count);\n print(numbers); // [1,2,5,6,14,9,8,12]\n}\n</div></code>"
|
|
],
|
|
"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.)",
|
|
"itemtype": "method",
|
|
"name": "splice",
|
|
"params": [
|
|
{
|
|
"name": "list",
|
|
"description": "Array to splice into",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to be spliced in",
|
|
"type": "Any"
|
|
},
|
|
{
|
|
"name": "position",
|
|
"description": "in the array from which to insert data",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var myArray = new Array(0,1,2,3,4);\n var insArray = new Array(\"A\",\"B\",\"C\");\n print(myArray); // [0,1,2,3,4]\n print(insArray); // [\"A\",\"B\",\"C\"]\n\n splice(myArray, insArray, 3);\n print(myArray); // [0,1,2,\"A\",\"B\",\"C\",3,4]\n}\n</div></code>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "subset",
|
|
"params": [
|
|
{
|
|
"name": "list",
|
|
"description": "Array to extract from",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "start",
|
|
"description": "position to begin",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "count",
|
|
"description": "number of values to extract",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Array of extracted elements",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\"><code>\nfunction setup() {\n var myArray = new Array(1,2,3,4,5);\n print(myArray); // [1,2,3,4,5]\n\n var sub1 = subset(myArray, 0, 3);\n var sub2 = subset(myArray, 2, 2);\n print(sub1); // [1,2,3]\n print(sub2); // [3,4]\n}\n</div></code>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "float",
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "float string to parse",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "floating point representation of string",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\nvar str = '20';\nvar diameter = float(str);\nellipse(width/2, height/2, diameter, diameter);\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "int",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "String|Boolean|Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "integer representation of value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(int(\"10\")); // 10\nprint(int(10.31)); // 10\nprint(int(-10)); // -10\nprint(int(true)); // 1\nprint(int(false)); // 0\nprint(int([false, true, \"10.3\", 9.8])); // [0, 1, 10, 9]\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "str",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "String|Boolean|Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "string representation of value",
|
|
"type": "String"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(str(\"10\")); // \"10\"\nprint(str(10.31)); // \"10.31\"\nprint(str(-10)); // \"-10\"\nprint(str(true)); // \"true\"\nprint(str(false)); // \"false\"\nprint(str([true, \"10.3\", 9.8])); // [ \"true\", \"10.3\", \"9.8\" ]\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "boolean",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "String|Boolean|Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "boolean representation of value",
|
|
"type": "Boolean"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(boolean(0)); // false\nprint(boolean(1)); // true\nprint(boolean(\"true\")); // true\nprint(boolean(\"abcd\")); // false\nprint(boolean([0, 12, \"true\"])); // [false, true, false]\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "byte",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "String|Boolean|Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "byte representation of value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(byte(127)); // 127\nprint(byte(128)); // -128\nprint(byte(23.4)); // 23\nprint(byte(\"23.4\")); // 23\nprint(byte(true)); // 1\nprint(byte([0, 255, \"100\"])); // [0, -1, 100]\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "char",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "String|Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "string representation of value",
|
|
"type": "String"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(char(65)); // \"A\"\nprint(char(\"65\")); // \"A\"\nprint(char([65, 66, 67])); // [ \"A\", \"B\", \"C\" ]\nprint(join(char([65, 66, 67]), '')); // \"ABC\"\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "unchar",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "String|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "integer representation of value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(unchar(\"A\")); // 65\nprint(unchar([\"A\", \"B\", \"C\"])); // [ 65, 66, 67 ]\nprint(unchar(split(\"ABC\", \"\"))); // [ 65, 66, 67 ]\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "hex",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "Number|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "hexadecimal string representation of value",
|
|
"type": "String"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(hex(255)); // \"000000FF\"\nprint(hex(255, 6)); // \"0000FF\"\nprint(hex([0, 127, 255], 6)); // [ \"000000\", \"00007F\", \"0000FF\" ]\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "unhex",
|
|
"params": [
|
|
{
|
|
"name": "n",
|
|
"description": "value to parse",
|
|
"type": "String|Array"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "integer representation of hexadecimal value",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nprint(unhex(\"A\")); // 10\nprint(unhex(\"FF\")); // 255\nprint(unhex([\"FF\", \"AA\", \"00\"])); // [ 255, 170, 0 ]\n</code></div>"
|
|
],
|
|
"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().",
|
|
"itemtype": "method",
|
|
"name": "join",
|
|
"params": [
|
|
{
|
|
"name": "list",
|
|
"description": "array of Strings to be joined",
|
|
"type": "Array"
|
|
},
|
|
{
|
|
"name": "separator",
|
|
"description": "String to be placed between each item",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "joined String",
|
|
"type": "String"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar array = [\"Hello\", \"world!\"]\nvar separator = \" \"\nvar message = join(array, separator);\ntext(message, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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<br><br>\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).",
|
|
"itemtype": "method",
|
|
"name": "match",
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "the String to be searched",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "regexp",
|
|
"description": "the regexp to be used for matching",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Array of Strings found",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar string = \"Hello p5js*!\"\nvar regexp = \"p5js\\\\*\"\nvar match = match(string, regexp);\ntext(match, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"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<br><br>\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<br><br>\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).",
|
|
"itemtype": "method",
|
|
"name": "matchAll",
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "the String to be searched",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "regexp",
|
|
"description": "the regexp to be used for matching",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "2d Array of Strings found",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div class=\"norender\">\n<code>\nvar string = \"Hello p5js*! Hello world!\"\nvar regexp = \"Hello\"\nmatchAll(string, regexp);\n</code>\n</div>\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.",
|
|
"itemtype": "method",
|
|
"name": "nf",
|
|
"params": [
|
|
{
|
|
"name": "num",
|
|
"description": "the Number to format",
|
|
"type": "Number|Array"
|
|
},
|
|
{
|
|
"name": "left",
|
|
"description": "number of digits to the left of the\n decimal point",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "right",
|
|
"description": "number of digits to the right of the\n decimal point",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "formatted String",
|
|
"type": "String|Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "nfc",
|
|
"params": [
|
|
{
|
|
"name": "num",
|
|
"description": "the Number to format",
|
|
"type": "Number|Array"
|
|
},
|
|
{
|
|
"name": "right",
|
|
"description": "number of digits to the right of the\n decimal point",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "formatted String",
|
|
"type": "String|Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "nfp",
|
|
"params": [
|
|
{
|
|
"name": "num",
|
|
"description": "the Number to format",
|
|
"type": "Number|Array"
|
|
},
|
|
{
|
|
"name": "left",
|
|
"description": "number of digits to the left of the decimal\n point",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "right",
|
|
"description": "number of digits to the right of the\n decimal point",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "formatted String",
|
|
"type": "String|Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "nfs",
|
|
"params": [
|
|
{
|
|
"name": "num",
|
|
"description": "the Number to format",
|
|
"type": "Number|Array"
|
|
},
|
|
{
|
|
"name": "left",
|
|
"description": "number of digits to the left of the decimal\n point",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "right",
|
|
"description": "number of digits to the right of the\n decimal point",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "formatted String",
|
|
"type": "String|Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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\nThe splitTokens() function works in a similar fashion, except that it\nsplits using a range of characters instead of a specific character or\nsequence.",
|
|
"itemtype": "method",
|
|
"name": "split",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "the String to be split",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "delim",
|
|
"description": "the String used to separate the data",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Array of Strings",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\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</code>\n</div>"
|
|
],
|
|
"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<br><br>\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.",
|
|
"itemtype": "method",
|
|
"name": "splitTokens",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "the String to be split",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "delim",
|
|
"description": "list of individual Strings that will be used as\n separators",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Array of Strings",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div class = \"norender\">\n<code>\nfunction setup() {\n var myStr = \"Mango, Banana, Lime\";\n var myStrArr = splitTokens(myStr, \",\");\n\n print(myStrArr); // prints : [\"Mango\",\" Banana\",\" Lime\"]\n}\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "trim",
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "a String or Array of Strings to be trimmed",
|
|
"type": "String|Array",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "a trimmed String or Array of Strings",
|
|
"type": "String|Array"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar string = trim(\" No new lines\\n \");\ntext(string +\" here\", 2, 50);\n</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "day",
|
|
"return": {
|
|
"description": "the current day",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar day = day();\ntext(\"Current day: \\n\" + day, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Input",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "hour",
|
|
"return": {
|
|
"description": "the current hour",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar hour = hour();\ntext(\"Current hour:\\n\" + hour, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Input",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "minute",
|
|
"return": {
|
|
"description": "the current minute",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar minute = minute();\ntext(\"Current minute: \\n\" + minute, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Input",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "millis",
|
|
"return": {
|
|
"description": "the number of milliseconds since starting the program",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar millisecond = millis();\ntext(\"Milliseconds \\nrunning: \\n\" + millisecond, 5, 40);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Input",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "month",
|
|
"return": {
|
|
"description": "the current month",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar month = month();\ntext(\"Current month: \\n\" + month, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Input",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "second",
|
|
"return": {
|
|
"description": "the current second",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar second = second();\ntext(\"Current second: \\n\" + second, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Input",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "year",
|
|
"return": {
|
|
"description": "the current year",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div>\n<code>\nvar year = year();\ntext(\"Current year: \\n\" + year, 5, 50);\n</code>\n</div>"
|
|
],
|
|
"class": "p5",
|
|
"module": "Input",
|
|
"submodule": "Time & Date"
|
|
},
|
|
{
|
|
"file": "src/app.js",
|
|
"line": 60,
|
|
"description": "_globalInit\n\nTODO: ???\nif sketch is on window\nassume \"global\" mode\nand instantiate p5 automatically\notherwise do nothing",
|
|
"return": {
|
|
"description": "",
|
|
"type": "Undefined"
|
|
},
|
|
"class": "p5.dom",
|
|
"module": "Input"
|
|
},
|
|
{
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "select",
|
|
"params": [
|
|
{
|
|
"name": "name",
|
|
"description": "id, class, or tag name of element to search for",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "container",
|
|
"description": "id, p5.Element, or HTML element to search within",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "p5.Element containing node found",
|
|
"type": "Object/p5.Element|Null"
|
|
},
|
|
"example": [
|
|
"\n<div ><code class='norender'>\nfunction setup() {\n createCanvas(100,100);\n //translates canvas 50px down\n select('canvas').position(100, 100);\n}\n</code></div>\n<div ><code class='norender'>\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</code></div>\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.",
|
|
"itemtype": "method",
|
|
"name": "selectAll",
|
|
"params": [
|
|
{
|
|
"name": "name",
|
|
"description": "class or tag name of elements to search for",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "container",
|
|
"description": "id, p5.Element, or HTML element to search within",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Array of p5.Elements containing nodes found",
|
|
"type": "Array"
|
|
},
|
|
"example": [
|
|
"\n<div ><code class='norender'>\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</code></div>\n<div ><code class='norender'>\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</code></div>\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",
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 171,
|
|
"description": "Helper function for getElement and getElements.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "removeElements",
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 221,
|
|
"description": "Helpers for create methods.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createDiv",
|
|
"params": [
|
|
{
|
|
"name": "html",
|
|
"description": "inner HTML for element created",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar myDiv;\nfunction setup() {\n myDiv = createDiv('this is some text');\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createP",
|
|
"params": [
|
|
{
|
|
"name": "html",
|
|
"description": "inner HTML for element created",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar myP;\nfunction setup() {\n myP = createP('this is some text');\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createSpan",
|
|
"params": [
|
|
{
|
|
"name": "html",
|
|
"description": "inner HTML for element created",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar mySpan;\nfunction setup() {\n mySpan = createSpan('this is some text');\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createImg",
|
|
"params": [
|
|
{
|
|
"name": "src",
|
|
"description": "src path or url for image",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "alt",
|
|
"description": "alternate text to be used if image does not load",
|
|
"type": "String",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "successCallback",
|
|
"description": "callback to be called once image data is loaded",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar img;\nfunction setup() {\n img = createImg('http://p5js.org/img/asterisk-01.png');\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createA",
|
|
"params": [
|
|
{
|
|
"name": "href",
|
|
"description": "url of page to link to",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "html",
|
|
"description": "inner html of link element to display",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "target",
|
|
"description": "target where new link should open,\n could be _blank, _self, _parent, _top.",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar myLink;\nfunction setup() {\n myLink = createA('http://p5js.org/', 'this is a link');\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createSlider",
|
|
"params": [
|
|
{
|
|
"name": "min",
|
|
"description": "minimum value of the slider",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "max",
|
|
"description": "maximum value of the slider",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "default value of the slider",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 404,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createButton",
|
|
"params": [
|
|
{
|
|
"name": "label",
|
|
"description": "label displayed on the button",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value of the button",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 440,
|
|
"description": "Creates a checkbox <input></input> element in the DOM.\nCalling .checked() on a checkbox returns if it is checked or not",
|
|
"itemtype": "method",
|
|
"name": "createCheckbox",
|
|
"params": [
|
|
{
|
|
"name": "label",
|
|
"description": "label displayed after checkbox",
|
|
"type": "String",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value of the checkbox; checked is true, unchecked is false.Unchecked if no value given",
|
|
"type": "Boolean",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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(\"Unchecking!\");\n } else {\n console.log(\"Checking!\");\n }\n\n</code></div>"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 500,
|
|
"description": "Creates a dropdown menu <select></select> element in the DOM.",
|
|
"itemtype": "method",
|
|
"name": "createSelect",
|
|
"params": [
|
|
{
|
|
"name": "multiple",
|
|
"description": "[true if dropdown should support multiple selections]",
|
|
"type": "Boolean",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 565,
|
|
"description": "Creates a radio button <input></input> element in the DOM.",
|
|
"itemtype": "method",
|
|
"name": "createRadio",
|
|
"params": [
|
|
{
|
|
"name": "divId",
|
|
"description": "the id and name of the created div and input field respectively",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 650,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createInput",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "default value of the input box",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 679,
|
|
"description": "Creates an <input></input> element in the DOM of type 'file'.\nThis allows users to select local files for use in a sketch.",
|
|
"itemtype": "method",
|
|
"name": "createFileInput",
|
|
"params": [
|
|
{
|
|
"name": "callback",
|
|
"description": "callback function for when a file loaded",
|
|
"type": "Function",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "multiple",
|
|
"description": "optional to allow multiple files selected",
|
|
"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": 742,
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 776,
|
|
"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 <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats\">this\npage</a> for further information about supported formats.",
|
|
"itemtype": "method",
|
|
"name": "createVideo",
|
|
"params": [
|
|
{
|
|
"name": "src",
|
|
"description": "path to a video file, or array of paths for\n supporting different browsers",
|
|
"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",
|
|
"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": 802,
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 804,
|
|
"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 <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats\">this\npage for further information about supported formats</a>.",
|
|
"itemtype": "method",
|
|
"name": "createAudio",
|
|
"params": [
|
|
{
|
|
"name": "src",
|
|
"description": "path to an audio file, or array of paths for\n supporting different browsers",
|
|
"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",
|
|
"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": 830,
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 840,
|
|
"description": "Creates a new <video> element that contains the audio/video feed\nfrom a webcam. This can be drawn onto the canvas using video(). More\nspecific properties of the stream can be passing in a Constraints object.\nSee the\n<a href=\"http://w3c.github.io/mediacapture-main/getusermedia.html\">W3C\nspec</a> for possible properties. Note that not all of these are supported\nby all browsers.",
|
|
"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",
|
|
"type": "String|Constant|Object"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function to be called once\n stream has loaded",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "capture video p5.Element",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\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</code></div>\n<div class='norender'><code>\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</code></div>"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 938,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createElement",
|
|
"params": [
|
|
{
|
|
"name": "tag",
|
|
"description": "tag for the new element",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "content",
|
|
"description": "html content to be inserted into the element",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element holding created node",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar h2 = createElement('h2','im an h2 p5.element!');\n</code></div>"
|
|
],
|
|
"class": "p5.dom",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 964,
|
|
"description": "Adds specified class to the element.",
|
|
"itemtype": "method",
|
|
"name": "addClass",
|
|
"params": [
|
|
{
|
|
"name": "class",
|
|
"description": "name of class to add",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n <div class='norender'><code>\n var div = createDiv('div');\n div.addClass('myClass');\n </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 991,
|
|
"description": "Removes specified class from the element.",
|
|
"itemtype": "method",
|
|
"name": "removeClass",
|
|
"params": [
|
|
{
|
|
"name": "class",
|
|
"description": "name of class to remove",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1006,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "child",
|
|
"params": [
|
|
{
|
|
"name": "child",
|
|
"description": "the ID, DOM node, or p5.Element\n to add to the current element",
|
|
"type": "String|Object|p5.Element",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Element"
|
|
},
|
|
"example": [
|
|
"\n <div class='norender'><code>\n var div0 = createDiv('this is the parent');\n var div1 = createDiv('this is the child');\n div0.child(div1); // use p5.Element\n </code></div>\n <div class='norender'><code>\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 </code></div>\n <div class='norender'><code>\n var div0 = createDiv('this is the parent');\n var elt = document.getElementById('myChildDiv');\n div0.child(elt); // use element from page\n </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1050,
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "align",
|
|
"description": "passing 'vertical', 'horizontal' aligns element accordingly",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "pointer to p5.Element",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\nfunction setup() {\n var div = createDiv('').size(10,10);\n div.style('background-color','orange');\n div.center();\n\n}\n</code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1103,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "html",
|
|
"params": [
|
|
{
|
|
"name": "html",
|
|
"description": "the HTML to be placed inside the element",
|
|
"type": "String",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element|String"
|
|
},
|
|
"example": [
|
|
"\n <div class='norender'><code>\n var div = createDiv('').size(100,100);\n div.style('background-color','orange');\n div.html('hi');\n </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1129,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "position",
|
|
"params": [
|
|
{
|
|
"name": "x",
|
|
"description": "x-position relative to upper left of window",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "y",
|
|
"description": "y-position relative to upper left of window",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n <div><code class='norender'>\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 </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1210,
|
|
"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);",
|
|
"itemtype": "method",
|
|
"name": "style",
|
|
"params": [
|
|
{
|
|
"name": "property",
|
|
"description": "property to be set",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign to property",
|
|
"type": "String|Number|p5.Color",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign to property (rotate/translate)",
|
|
"type": "String|Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign to property (rotate/translate)",
|
|
"type": "String|Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign to property (translate)",
|
|
"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<div><code class=\"norender\">\nvar myDiv = createDiv(\"I like pandas.\");\nmyDiv.style(\"font-size\", \"18px\");\nmyDiv.style(\"color\", \"#ff0000\");\n</code></div>\n<div><code class=\"norender\">\nvar col = color(25,23,200,50);\nvar button = createButton(\"button\");\nbutton.style(\"background-color\", col);\nbutton.position(10, 10);\n</code></div>\n<div><code class=\"norender\">\nvar myDiv = createDiv(\"I like lizards.\");\nmyDiv.style(\"position\", 20, 20);\nmyDiv.style(\"rotate\", 45);\n</code></div>\n<div><code class=\"norender\">\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</code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1295,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "attribute",
|
|
"params": [
|
|
{
|
|
"name": "attr",
|
|
"description": "attribute to set",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "value to assign to attribute",
|
|
"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 <div class=\"norender\"><code>\n var myDiv = createDiv(\"I like pandas.\");\n myDiv.attribute(\"align\", \"center\");\n </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1322,
|
|
"description": "Either returns the value of the element if no arguments\ngiven, or sets the value of the element.",
|
|
"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<div class='norender'><code>\n// gets the value\nvar inp;\nfunction setup() {\n inp = createInput('');\n}\n\nfunction mousePressed() {\n print(inp.value());\n}\n</code></div>\n<div class='norender'><code>\n// sets the value\nvar inp;\nfunction setup() {\n inp = createInput('myValue');\n}\n\nfunction mousePressed() {\n inp.value(\"myValue\");\n}\n</code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1365,
|
|
"description": "Shows the current element. Essentially, setting display:block for the style.",
|
|
"itemtype": "method",
|
|
"name": "show",
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n <div class='norender'><code>\n var div = createDiv('div');\n div.attribute(\"display\", \"none\");\n div.show(); // turns display to block\n </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1383,
|
|
"description": "Hides the current element. Essentially, setting display:none for the style.",
|
|
"itemtype": "method",
|
|
"name": "hide",
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar div = createDiv('this is a div');\ndiv.hide();\n</code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1399,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "size",
|
|
"params": [
|
|
{
|
|
"name": "w",
|
|
"description": "width of the element",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "h",
|
|
"description": "height of the element",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"example": [
|
|
"\n <div class='norender'><code>\n var div = createDiv('this is a div');\n div.size(100, 100);\n </code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1465,
|
|
"description": "Removes the element and deregisters all listeners.",
|
|
"itemtype": "method",
|
|
"name": "remove",
|
|
"example": [
|
|
"\n<div class='norender'><code>\nvar myDiv = createDiv('this is some text');\nmyDiv.remove();\n</code></div>"
|
|
],
|
|
"class": "p5.Element",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1514,
|
|
"description": "Path to the media element source.",
|
|
"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": 1549,
|
|
"description": "Play an HTML5 media element.",
|
|
"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": 1570,
|
|
"description": "Stops an HTML5 media element (sets current time to zero).",
|
|
"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": 1582,
|
|
"description": "Pauses an HTML5 media element.",
|
|
"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": 1593,
|
|
"description": "Set 'loop' to true for an HTML5 media element, and starts playing.",
|
|
"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": 1604,
|
|
"description": "Set 'loop' to false for an HTML5 media element. Element will stop\nwhen it reaches the end.",
|
|
"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": 1617,
|
|
"description": "Set HTML5 media element to autoplay or not.",
|
|
"itemtype": "method",
|
|
"name": "autoplay",
|
|
"params": [
|
|
{
|
|
"name": "autoplay",
|
|
"description": "whether the element should autoplay",
|
|
"type": "Boolean"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.Element"
|
|
},
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1629,
|
|
"description": "Sets volume for this HTML5 media element. If no argument is given,\nreturns the current volume.",
|
|
"params": [
|
|
{
|
|
"name": "val",
|
|
"description": "volume between 0.0 and 1.0",
|
|
"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": 1645,
|
|
"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.)",
|
|
"itemtype": "method",
|
|
"name": "speed",
|
|
"params": [
|
|
{
|
|
"name": "speed",
|
|
"description": "speed multiplier for element playback",
|
|
"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": 1664,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "time",
|
|
"params": [
|
|
{
|
|
"name": "time",
|
|
"description": "time to jump to (in seconds)",
|
|
"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": 1681,
|
|
"description": "Returns the duration of the HTML5 media element.",
|
|
"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": 1724,
|
|
"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.",
|
|
"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.",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "Object/p5.MediaElement"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1756,
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1758,
|
|
"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\nThis method is meant to be used with the p5.sound.js addon library.",
|
|
"itemtype": "method",
|
|
"name": "connect",
|
|
"params": [
|
|
{
|
|
"name": "audioNode",
|
|
"description": "AudioNode from the Web Audio API,\nor an object from the p5.sound library",
|
|
"type": "AudioNode|p5.sound object"
|
|
}
|
|
],
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1810,
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "disconnect",
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1826,
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1828,
|
|
"description": "Show the default MediaElement controls, as determined by the web browser.",
|
|
"itemtype": "method",
|
|
"name": "showControls",
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1839,
|
|
"description": "Hide the default mediaElement controls.",
|
|
"itemtype": "method",
|
|
"name": "hideControls",
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1848,
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1850,
|
|
"description": "Schedule events to trigger every time a MediaElement\n(audio/video) reaches a playback cue point.\n\nAccepts a callback function, a time (in seconds) at which to trigger\nthe callback, and an optional parameter for the callback.\n\nTime will be passed as the first parameter to the callback function,\nand param will be the second parameter.",
|
|
"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.",
|
|
"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.",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "An object to be passed as the\n second parameter to the\n callback function.",
|
|
"type": "Object",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "id ID of this cue,\n useful for removeCue(id)",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1912,
|
|
"description": "Remove a callback based on its ID. The ID is returned by the\naddCue method.",
|
|
"itemtype": "method",
|
|
"name": "removeCue",
|
|
"params": [
|
|
{
|
|
"name": "id",
|
|
"description": "ID of the cue, as returned by addCue",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1932,
|
|
"description": "Remove all of the callbacks that had originally been scheduled\nvia the addCue method.",
|
|
"itemtype": "method",
|
|
"name": "clearCues",
|
|
"class": "p5.MediaElement",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 1989,
|
|
"description": "Underlying File object. All normal File methods can be called on this.",
|
|
"itemtype": "property",
|
|
"name": "file",
|
|
"class": "p5.File",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 2001,
|
|
"description": "File type (image, text, etc.)",
|
|
"itemtype": "property",
|
|
"name": "type",
|
|
"class": "p5.File",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 2007,
|
|
"description": "File subtype (usually the file extension jpg, png, xml, etc.)",
|
|
"itemtype": "property",
|
|
"name": "subtype",
|
|
"class": "p5.File",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 2013,
|
|
"description": "File name",
|
|
"itemtype": "property",
|
|
"name": "name",
|
|
"class": "p5.File",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 2019,
|
|
"description": "File size",
|
|
"itemtype": "property",
|
|
"name": "size",
|
|
"class": "p5.File",
|
|
"module": "p5.dom",
|
|
"submodule": "p5.dom"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.dom.js",
|
|
"line": 2026,
|
|
"description": "URL string containing image data.",
|
|
"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\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/",
|
|
"class": "p5.sound",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 207,
|
|
"description": "<p>Returns the Audio Context for this sketch. Useful for users\nwho would like to dig deeper into the <a target='_blank' href=\n'http://webaudio.github.io/web-audio-api/'>Web Audio API\n</a>.</p>",
|
|
"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",
|
|
"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.",
|
|
"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.",
|
|
"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": "<p>Scale the output of all sound in this sketch</p>\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 <code>rampTime</code> 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<p><b>How This Works</b>: 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.</p>\n\n<p>If no value is provided, returns a Web Audio API Gain Node</p>",
|
|
"itemtype": "method",
|
|
"name": "masterVolume",
|
|
"params": [
|
|
{
|
|
"name": "volume",
|
|
"description": "Volume (amplitude) between 0.0\n and 1.0 or modulating signal/oscillator",
|
|
"type": "Number|Object"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "Fade for t seconds",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "Schedule this event to happen at\n t seconds in the future",
|
|
"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 (<code>.limiter</code>),\nand Gain Nodes for <code>.input</code> and <code>.output</code>.",
|
|
"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",
|
|
"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.",
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "frequency",
|
|
"description": "A freqeuncy, for example, the \"A\"\n above Middle C is 440Hz",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "midiToFreq",
|
|
"params": [
|
|
{
|
|
"name": "midiNote",
|
|
"description": "The number of a MIDI note",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Frequency value of the given MIDI note",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.\n<a href=\"http://media.io/\">Here</a> is a free online file\nconverter.",
|
|
"itemtype": "method",
|
|
"name": "soundFormats",
|
|
"params": [
|
|
{
|
|
"name": "formats",
|
|
"description": "i.e. 'mp3', 'wav', 'ogg'",
|
|
"type": "String|Strings"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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",
|
|
"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.",
|
|
"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<a href=\"https://github.com/processing/p5.js/wiki/Local-server\">\nlocal server</a> is recommended when loading external files.",
|
|
"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.",
|
|
"type": "String/Array"
|
|
},
|
|
{
|
|
"name": "successCallback",
|
|
"description": "Name of a function to call once file loads",
|
|
"type": "Function",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "errorCallback",
|
|
"description": "Name of a function to call if there is\n an error loading the file.",
|
|
"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.",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Returns a p5.SoundFile",
|
|
"type": "SoundFile"
|
|
},
|
|
"example": [
|
|
" \n<div><code>\nfunction preload() {\n mySound = loadSound('assets/doorbell.mp3');\n}\n\nfunction setup() {\n mySound.setVolume(0.1);\n mySound.play();\n}\n</code></div>"
|
|
],
|
|
"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.",
|
|
"access": "private",
|
|
"tagname": "",
|
|
"params": [
|
|
{
|
|
"name": "successCallback",
|
|
"description": "Name of a function to call once file loads",
|
|
"type": "Function",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "errorCallback",
|
|
"description": "Name of a function to call if there is an error",
|
|
"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.",
|
|
"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",
|
|
"itemtype": "method",
|
|
"name": "play",
|
|
"params": [
|
|
{
|
|
"name": "startTime",
|
|
"description": "(optional) schedule playback to start (in seconds from now).",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "rate",
|
|
"description": "(optional) playback rate",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "amp",
|
|
"description": "(optional) amplitude (volume)\n of playback",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "cueStart",
|
|
"description": "(optional) cue start time in seconds",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "duration",
|
|
"description": "(optional) duration of playback in seconds",
|
|
"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: <code>restart</code> and\n<code>sustain</code>. 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.",
|
|
"itemtype": "method",
|
|
"name": "playMode",
|
|
"params": [
|
|
{
|
|
"name": "str",
|
|
"description": "'restart' or 'sustain'",
|
|
"type": "String"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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 </code></div>"
|
|
],
|
|
"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\nAfter 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().",
|
|
"itemtype": "method",
|
|
"name": "pause",
|
|
"params": [
|
|
{
|
|
"name": "startTime",
|
|
"description": "(optional) schedule event to occur\n seconds from now",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code>\n</div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "loop",
|
|
"params": [
|
|
{
|
|
"name": "startTime",
|
|
"description": "(optional) schedule event to occur\n seconds from now",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "rate",
|
|
"description": "(optional) playback rate",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "amp",
|
|
"description": "(optional) playback volume",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "cueLoopStart",
|
|
"description": "startTime in seconds",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "duration",
|
|
"description": "(optional) loop duration in seconds",
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "Boolean",
|
|
"description": "set looping to true or false",
|
|
"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.",
|
|
"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).",
|
|
"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).",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "stop",
|
|
"params": [
|
|
{
|
|
"name": "startTime",
|
|
"description": "(optional) schedule event to occur\n in seconds from now",
|
|
"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.",
|
|
"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 <code>rampTime</code> 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.",
|
|
"itemtype": "method",
|
|
"name": "setVolume",
|
|
"params": [
|
|
{
|
|
"name": "volume",
|
|
"description": "Volume (amplitude) between 0.0\n and 1.0 or modulating signal/oscillator",
|
|
"type": "Number|Object"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "Fade for t seconds",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "Schedule this event to happen at\n t seconds in the future",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "pan",
|
|
"params": [
|
|
{
|
|
"name": "panValue",
|
|
"description": "Set the stereo panner",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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 </div></code>"
|
|
],
|
|
"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)",
|
|
"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.",
|
|
"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.",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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 </code>\n </div>\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.",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "jump",
|
|
"params": [
|
|
{
|
|
"name": "cueTime",
|
|
"description": "cueTime of the soundFile in seconds.",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "uuration",
|
|
"description": "duration in seconds.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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\nInspired by Wavesurfer.js.",
|
|
"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.",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "reverseBuffer",
|
|
"example": [
|
|
"\n<div><code>\nvar drum;\n\nfunction preload() {\n drum = loadSound('assets/drum.mp3');\n}\n\nfunction setup() {\n drum.reverseBuffer();\n drum.play();\n}\n\n </code>\n </div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "onended",
|
|
"params": [
|
|
{
|
|
"name": "callback",
|
|
"description": "function to call when the\n soundfile has ended.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "connect",
|
|
"params": [
|
|
{
|
|
"name": "object",
|
|
"description": "Audio object that accepts an input",
|
|
"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.",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "setPath",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "path to audio file",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "Callback",
|
|
"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.",
|
|
"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.",
|
|
"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\nThis is an asynchronous function that processes the soundfile in an offline audio context,\nand sends the results to your callback function.\n\nThe 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.",
|
|
"itemtype": "method",
|
|
"name": "processPeaks",
|
|
"params": [
|
|
{
|
|
"name": "callback",
|
|
"description": "a function to call once this data is returned",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "initThreshold",
|
|
"description": "initial threshold defaults to 0.9",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "minThreshold",
|
|
"description": "minimum threshold defaults to 0.22",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "minPeaks",
|
|
"description": "minimum number of peaks defaults to 200",
|
|
"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\nAccepts a callback function, a time (in seconds) at which to trigger\nthe callback, and an optional parameter for the callback.\n\nTime will be passed as the first parameter to the callback function,\nand param will be the second parameter.",
|
|
"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.",
|
|
"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.",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "value",
|
|
"description": "An object to be passed as the\n second parameter to the\n callback function.",
|
|
"type": "Object",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "id ID of this cue,\n useful for removeCue(id)",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "removeCue",
|
|
"params": [
|
|
{
|
|
"name": "id",
|
|
"description": "ID of the cue, as returned by addCue",
|
|
"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.",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "setInput",
|
|
"params": [
|
|
{
|
|
"name": "snd",
|
|
"description": "set the sound source\n (optional, defaults to\n master output)",
|
|
"type": "SoundObject|undefined",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "smoothing",
|
|
"description": "a range between 0.0 and 1.0\n to smooth amplitude readings",
|
|
"type": "Number|undefined",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "getLevel",
|
|
"params": [
|
|
{
|
|
"name": "channel",
|
|
"description": "Optionally return only channel 0 (left) or 1 (right)",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "Amplitude as a number between 0.0 and 1.0",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "toggleNormalize",
|
|
"params": [
|
|
{
|
|
"name": "boolean",
|
|
"description": "set normalize to true (1) or false (0)",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "smooth",
|
|
"params": [
|
|
{
|
|
"name": "set",
|
|
"description": "smoothing from 0.0 <= 1",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setInput",
|
|
"params": [
|
|
{
|
|
"name": "source",
|
|
"description": "p5.sound object (or web audio API source node)",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "waveform",
|
|
"params": [
|
|
{
|
|
"name": "bins",
|
|
"description": "Must be a power of two between\n 16 and 1024. Defaults to 1024.",
|
|
"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.",
|
|
"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\n<code>getEnergy()</code>.",
|
|
"itemtype": "method",
|
|
"name": "analyze",
|
|
"params": [
|
|
{
|
|
"name": "bins",
|
|
"description": "Must be a power of two between\n 16 and 1024. Defaults to 1024.",
|
|
"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.",
|
|
"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<div><code>\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</code></div>\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<a href=\"en.wikipedia.org/wiki/Audio_frequency\" target=\"_blank\">\nfrequency</a>, 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). \n<em>NOTE: 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.</em></p>",
|
|
"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.",
|
|
"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.",
|
|
"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<a href=\"http://en.wikipedia.org/wiki/Spectral_centroid\" target=\"_blank\">\nspectral centroid</a> of the input signal.\n<em>NOTE: analyze() must be called prior to getCentroid(). Analyze()\ntells the FFT to analyze frequency data, and getCentroid() uses\nthe results determine the spectral centroid.</em></p>",
|
|
"itemtype": "method",
|
|
"name": "getCentroid",
|
|
"return": {
|
|
"description": "Spectral Centroid Frequency Frequency of the spectral centroid in Hz.",
|
|
"type": "Number"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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 </code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "smooth",
|
|
"params": [
|
|
{
|
|
"name": "smoothing",
|
|
"description": "0.0 < smoothing < 1.0.\n Defaults to 0.8.",
|
|
"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",
|
|
"itemtype": "method",
|
|
"name": "fade",
|
|
"params": [
|
|
{
|
|
"name": "value",
|
|
"description": "Value to set this signal",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "secondsFromNow",
|
|
"description": "Length of fade, in seconds from now",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mult",
|
|
"params": [
|
|
{
|
|
"name": "number",
|
|
"description": "to multiply",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "scale",
|
|
"params": [
|
|
{
|
|
"name": "number",
|
|
"description": "to multiply",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "inMin",
|
|
"description": "input range minumum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "inMax",
|
|
"description": "input range maximum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "outMin",
|
|
"description": "input range minumum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "outMax",
|
|
"description": "input range maximum",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "start",
|
|
"params": [
|
|
{
|
|
"name": "time",
|
|
"description": "startTime in seconds from now.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "frequency",
|
|
"description": "frequency in Hz.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "stop",
|
|
"params": [
|
|
{
|
|
"name": "secondsFromNow",
|
|
"description": "Time, in seconds from now.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "amp",
|
|
"params": [
|
|
{
|
|
"name": "vol",
|
|
"description": "between 0 and 1.0\n or a modulating signal/oscillator",
|
|
"type": "Number|Object"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "create a fade that lasts rampTime",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "freq",
|
|
"params": [
|
|
{
|
|
"name": "Frequency",
|
|
"description": "Frequency in Hz\n or modulating signal/oscillator",
|
|
"type": "Number|Object"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "Ramp time (in seconds)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "Schedule this event to happen\n at x seconds from now",
|
|
"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<div><code>\nvar osc = new p5.Oscillator(300);\nosc.start();\nosc.freq(40, 10);\n</code></div>"
|
|
],
|
|
"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'.",
|
|
"itemtype": "method",
|
|
"name": "setType",
|
|
"params": [
|
|
{
|
|
"name": "type",
|
|
"description": "'sine', 'triangle', 'sawtooth' or 'square'.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "connect",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "A p5.sound or Web Audio object",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"class": "p5.Oscillator",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 4584,
|
|
"description": "Disconnect all outputs",
|
|
"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)",
|
|
"itemtype": "method",
|
|
"name": "pan",
|
|
"params": [
|
|
{
|
|
"name": "panning",
|
|
"description": "Number between -1 and 1",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "phase",
|
|
"params": [
|
|
{
|
|
"name": "phase",
|
|
"description": "float between 0.0 and 1.0",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "add",
|
|
"params": [
|
|
{
|
|
"name": "number",
|
|
"description": "Constant number to add",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mult",
|
|
"params": [
|
|
{
|
|
"name": "number",
|
|
"description": "Constant number to multiply",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "scale",
|
|
"params": [
|
|
{
|
|
"name": "inMin",
|
|
"description": "input range minumum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "inMax",
|
|
"description": "input range maximum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "outMin",
|
|
"description": "input range minumum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "outMax",
|
|
"description": "input range maximum",
|
|
"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: <code>new p5.SinOsc()</code>.\nThis creates a Sine Wave Oscillator and is\nequivalent to <code> new p5.Oscillator('sine')\n</code> or creating a p5.Oscillator and then calling\nits method <code>setType('sine')</code>.\nSee p5.Oscillator for methods.",
|
|
"itemtype": "method",
|
|
"name": "p5.SinOsc",
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "Set the frequency",
|
|
"type": "[Number]"
|
|
}
|
|
],
|
|
"class": "p5.Oscillator",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 4760,
|
|
"description": "Constructor: <code>new p5.TriOsc()</code>.\nThis creates a Triangle Wave Oscillator and is\nequivalent to <code>new p5.Oscillator('triangle')\n</code> or creating a p5.Oscillator and then calling\nits method <code>setType('triangle')</code>.\nSee p5.Oscillator for methods.",
|
|
"itemtype": "method",
|
|
"name": "p5.TriOsc",
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "Set the frequency",
|
|
"type": "[Number]"
|
|
}
|
|
],
|
|
"class": "p5.Oscillator",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 4775,
|
|
"description": "Constructor: <code>new p5.SawOsc()</code>.\nThis creates a SawTooth Wave Oscillator and is\nequivalent to <code> new p5.Oscillator('sawtooth')\n</code> or creating a p5.Oscillator and then calling\nits method <code>setType('sawtooth')</code>.\nSee p5.Oscillator for methods.",
|
|
"itemtype": "method",
|
|
"name": "p5.SawOsc",
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "Set the frequency",
|
|
"type": "[Number]"
|
|
}
|
|
],
|
|
"class": "p5.Oscillator",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 4790,
|
|
"description": "Constructor: <code>new p5.SqrOsc()</code>.\nThis creates a Square Wave Oscillator and is\nequivalent to <code> new p5.Oscillator('square')\n</code> or creating a p5.Oscillator and then calling\nits method <code>setType('square')</code>.\nSee p5.Oscillator for methods.",
|
|
"itemtype": "method",
|
|
"name": "p5.SqrOsc",
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "Set the frequency",
|
|
"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",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "attackTime",
|
|
"description": "Time (in seconds) before level\n reaches attackLevel",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "attackLevel",
|
|
"description": "Typically an amplitude between\n 0.0 and 1.0",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "decayTime",
|
|
"description": "Time",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "decayLevel",
|
|
"description": "Amplitude (In a standard ADSR envelope,\n decayLevel = sustainLevel)",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "releaseTime",
|
|
"description": "Release Time (in seconds)",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "releaseLevel",
|
|
"description": "Amplitude",
|
|
"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<a href=\"https://en.wikipedia.org/wiki/Synthesizer#/media/File:ADSR_parameter.svg\">\nADSR envelope\n</a>.",
|
|
"itemtype": "method",
|
|
"name": "setADSR",
|
|
"params": [
|
|
{
|
|
"name": "attackTime",
|
|
"description": "Time (in seconds before envelope\n reaches Attack Level",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "decayTime",
|
|
"description": "Time (in seconds) before envelope\n reaches Decay/Sustain Level",
|
|
"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 <code>setRange</code>),\n then decayLevel would increase proportionally, to become 0.5.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "releaseTime",
|
|
"description": "Time in seconds from now (defaults to 0)",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setRange",
|
|
"params": [
|
|
{
|
|
"name": "aLevel",
|
|
"description": "attack level (defaults to 1)",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rLevel",
|
|
"description": "release level (defaults to 0)",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setInput",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "A p5.sound object or\n Web Audio Param.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setExp",
|
|
"params": [
|
|
{
|
|
"name": "isExp",
|
|
"description": "true is exponential, false is linear",
|
|
"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 <a href=\"\nhttp://docs.webplatform.org/wiki/apis/webaudio/AudioParam\">\nWeb Audio Audio Param.</a>",
|
|
"itemtype": "method",
|
|
"name": "play",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "A p5.sound object or\n Web Audio Param.",
|
|
"type": "Object"
|
|
},
|
|
{
|
|
"name": "startTime",
|
|
"description": "time from now (in seconds) at which to play",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "sustainTime",
|
|
"description": "time to sustain before releasing the envelope",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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 <a href=\"\nhttp://docs.webplatform.org/wiki/apis/webaudio/AudioParam\">\nWeb Audio Param</a>.",
|
|
"itemtype": "method",
|
|
"name": "triggerAttack",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "p5.sound Object or Web Audio Param",
|
|
"type": "Object"
|
|
},
|
|
{
|
|
"name": "secondsFromNow",
|
|
"description": "time from now (in seconds)",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "triggerRelease",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "p5.sound Object or Web Audio Param",
|
|
"type": "Object"
|
|
},
|
|
{
|
|
"name": "secondsFromNow",
|
|
"description": "time to trigger the release",
|
|
"type": "Number"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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 <code><a href=\"#/p5.Env/setADSR\">setADSR(attackTime, decayTime)</a></code>\nas <a href=\"https://en.wikipedia.org/wiki/RC_time_constant\">\ntime constants</a> for simple exponential ramps.\nIf the value is higher than current value, it uses attackTime,\nwhile a decrease uses decayTime.",
|
|
"itemtype": "method",
|
|
"name": "ramp",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "p5.sound Object or Web Audio Param",
|
|
"type": "Object"
|
|
},
|
|
{
|
|
"name": "secondsFromNow",
|
|
"description": "When to trigger the ramp",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "v",
|
|
"description": "Target value",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "v2",
|
|
"description": "Second target value (optional)",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "add",
|
|
"params": [
|
|
{
|
|
"name": "number",
|
|
"description": "Constant number to add",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "mult",
|
|
"params": [
|
|
{
|
|
"name": "number",
|
|
"description": "Constant number to multiply",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "scale",
|
|
"params": [
|
|
{
|
|
"name": "inMin",
|
|
"description": "input range minumum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "inMax",
|
|
"description": "input range maximum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "outMin",
|
|
"description": "input range minumum",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "outMax",
|
|
"description": "input range maximum",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "width",
|
|
"params": [
|
|
{
|
|
"name": "width",
|
|
"description": "Width between the pulses (0 to 1.0,\n defaults to 0)",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setType",
|
|
"params": [
|
|
{
|
|
"name": "type",
|
|
"description": "'white', 'pink' or 'brown'",
|
|
"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",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "pan",
|
|
"params": [
|
|
{
|
|
"name": "panning",
|
|
"description": "Number between -1 (left)\n and 1 (right)",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "volume",
|
|
"description": "amplitude between 0 and 1.0\n or modulating signal/oscillator",
|
|
"type": "Number|Object"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "create a fade that lasts rampTime",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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",
|
|
"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.",
|
|
"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.",
|
|
"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.<br/>",
|
|
"itemtype": "method",
|
|
"name": "start",
|
|
"params": [
|
|
{
|
|
"name": "successCallback",
|
|
"description": "Name of a function to call on\n success.",
|
|
"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.",
|
|
"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().<br/>",
|
|
"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).<br/>",
|
|
"itemtype": "method",
|
|
"name": "connect",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "An object that accepts audio input,\n such as an FFT",
|
|
"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.<br/>",
|
|
"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). <em>NOTE: AudioIn must\n.start() before using .getLevel().</em><br/>",
|
|
"itemtype": "method",
|
|
"name": "getLevel",
|
|
"params": [
|
|
{
|
|
"name": "smoothing",
|
|
"description": "Smoothing is 0.0 by default.\n Smooths values based on previous values.",
|
|
"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.",
|
|
"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. <br/>",
|
|
"itemtype": "method",
|
|
"name": "amp",
|
|
"params": [
|
|
{
|
|
"name": "vol",
|
|
"description": "between 0 and 1.0",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "time",
|
|
"description": "ramp time (optional)",
|
|
"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",
|
|
"itemtype": "method",
|
|
"name": "getSources",
|
|
"params": [
|
|
{
|
|
"name": "callback",
|
|
"description": "a callback to handle the sources \n when they have been enumerated",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n <div><code>\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 </code></div>"
|
|
],
|
|
"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.<br/>",
|
|
"itemtype": "method",
|
|
"name": "setSource",
|
|
"params": [
|
|
{
|
|
"name": "num",
|
|
"description": "position of input source in the array",
|
|
"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<a href=\"http://www.w3.org/TR/webaudio/#BiquadFilterNode\">\nWeb Audio BiquadFilter Node</a>.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "process",
|
|
"params": [
|
|
{
|
|
"name": "Signal",
|
|
"description": "An object that outputs audio",
|
|
"type": "Object"
|
|
},
|
|
{
|
|
"name": "freq",
|
|
"description": "Frequency in Hz, from 10 to 22050",
|
|
"type": "[Number]"
|
|
},
|
|
{
|
|
"name": "res",
|
|
"description": "Resonance/Width of the filter frequency\n from 0.001 to 1000",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "Frequency in Hz, from 10 to 22050",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "res",
|
|
"description": "Resonance (Q) from 0.001 to 1000",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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).",
|
|
"itemtype": "method",
|
|
"name": "freq",
|
|
"params": [
|
|
{
|
|
"name": "freq",
|
|
"description": "Filter Frequency",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "res",
|
|
"params": [
|
|
{
|
|
"name": "res",
|
|
"description": "Resonance/Width of filter freq\n from 0.001 to 1000",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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\".",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "amp",
|
|
"params": [
|
|
{
|
|
"name": "volume",
|
|
"description": "amplitude between 0 and 1.0",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "create a fade that lasts rampTime",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "disconnect",
|
|
"class": "p5.Filter",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 6824,
|
|
"description": "Constructor: <code>new p5.LowPass()</code> Filter.\nThis is the same as creating a p5.Filter and then calling\nits method <code>setType('lowpass')</code>.\nSee p5.Filter for methods.",
|
|
"itemtype": "method",
|
|
"name": "p5.LowPass",
|
|
"class": "p5.Filter",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 6836,
|
|
"description": "Constructor: <code>new p5.HighPass()</code> Filter.\nThis is the same as creating a p5.Filter and then calling\nits method <code>setType('highpass')</code>.\nSee p5.Filter for methods.",
|
|
"itemtype": "method",
|
|
"name": "p5.HighPass",
|
|
"class": "p5.Filter",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 6848,
|
|
"description": "Constructor: <code>new p5.BandPass()</code> Filter.\nThis is the same as creating a p5.Filter and then calling\nits method <code>setType('bandpass')</code>.\nSee p5.Filter for methods.",
|
|
"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<a href=\"http://www.w3.org/TR/webaudio/#DelayNode\">\nWeb Audio Delay Nodes</a>, one for each stereo channel.",
|
|
"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<a href=\"http://www.w3.org/TR/webaudio/#DelayNode\">\nWeb Audio Delay Nodes</a>, one for each stereo channel.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "process",
|
|
"params": [
|
|
{
|
|
"name": "Signal",
|
|
"description": "An object that outputs audio",
|
|
"type": "Object"
|
|
},
|
|
{
|
|
"name": "delayTime",
|
|
"description": "Time (in seconds) of the delay/echo.\n Some browsers limit delayTime to\n 1 second.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "feedback",
|
|
"description": "sends the delay back through itself\n in a loop that decreases in volume\n each time.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "lowPass",
|
|
"description": "Cutoff frequency. Only frequencies\n below the lowPass will be part of the\n delay.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "delayTime",
|
|
"params": [
|
|
{
|
|
"name": "delayTime",
|
|
"description": "Time (in seconds) of the delay",
|
|
"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.",
|
|
"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",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "filter",
|
|
"params": [
|
|
{
|
|
"name": "cutoffFreq",
|
|
"description": "A lowpass filter will cut off any \n frequencies higher than the filter frequency.",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setType",
|
|
"params": [
|
|
{
|
|
"name": "type",
|
|
"description": "'pingPong' (1) or 'default' (0)",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "amp",
|
|
"params": [
|
|
{
|
|
"name": "volume",
|
|
"description": "amplitude between 0 and 1.0",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "create a fade that lasts rampTime",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "process",
|
|
"params": [
|
|
{
|
|
"name": "src",
|
|
"description": "p5.sound / Web Audio object with a sound\n output.",
|
|
"type": "Object"
|
|
},
|
|
{
|
|
"name": "seconds",
|
|
"description": "Duration of the reverb, in seconds.\n Min: 0, Max: 10. Defaults to 3.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "decayRate",
|
|
"description": "Percentage of decay with each echo.\n Min: 0, Max: 100. Defaults to 2.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "reverse",
|
|
"description": "Play the reverb backwards or forwards.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "set",
|
|
"params": [
|
|
{
|
|
"name": "seconds",
|
|
"description": "Duration of the reverb, in seconds.\n Min: 0, Max: 10. Defaults to 3.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "decayRate",
|
|
"description": "Percentage of decay with each echo.\n Min: 0, Max: 100. Defaults to 2.",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "reverse",
|
|
"description": "Play the reverb backwards or forwards.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "amp",
|
|
"params": [
|
|
{
|
|
"name": "volume",
|
|
"description": "amplitude between 0 and 1.0",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "create a fade that lasts rampTime",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"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",
|
|
"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.",
|
|
"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 \nUtility function for building an impulse response\nbased on the module parameters.",
|
|
"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<a href=\"http://www.w3.org/TR/webaudio/#ConvolverNode\">\nWeb Audio Convolver Node</a>.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "createConvolver",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "path to a sound file",
|
|
"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.",
|
|
"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.",
|
|
"type": "Function",
|
|
"optional": true
|
|
}
|
|
],
|
|
"return": {
|
|
"description": "",
|
|
"type": "p5.Convolver"
|
|
},
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "process",
|
|
"params": [
|
|
{
|
|
"name": "src",
|
|
"description": "p5.sound / Web Audio object with a sound\n output.",
|
|
"type": "Object"
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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 <code>toggleImpulse(id)</code> method.",
|
|
"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 <code>.impulses</code> array. Previous\nimpulses can be accessed with the <code>.toggleImpulse(id)</code>\nmethod.",
|
|
"itemtype": "method",
|
|
"name": "addImpulse",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "path to a sound file",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function (optional)",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "errorCallback",
|
|
"description": "function (optional)",
|
|
"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 <code>.impulses</code>\nArray is reset to save memory. A new <code>.impulses</code>\narray is created with this impulse as the only item.",
|
|
"itemtype": "method",
|
|
"name": "resetImpulse",
|
|
"params": [
|
|
{
|
|
"name": "path",
|
|
"description": "path to a sound file",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "function (optional)",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "errorCallback",
|
|
"description": "function (optional)",
|
|
"type": "Function"
|
|
}
|
|
],
|
|
"class": "p5.Convolver",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
},
|
|
{
|
|
"file": "lib/addons/p5.sound.js",
|
|
"line": 7617,
|
|
"description": "If you have used <code>.addImpulse()</code> to add multiple impulses\nto a p5.Convolver, then you can use this method to toggle between\nthe items in the <code>.impulses</code> 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 <code>.impulses\n</code> Array (Number).<br/>\nYou can access the objects in the .impulses Array directly. Each\nObject has two attributes: an <code>.audioBuffer</code> (type:\nWeb Audio <a href=\"\nhttp://webaudio.github.io/web-audio-api/#the-audiobuffer-interface\">\nAudioBuffer)</a> and a <code>.name</code>, a String that corresponds\nwith the original filename.",
|
|
"itemtype": "method",
|
|
"name": "toggleImpulse",
|
|
"params": [
|
|
{
|
|
"name": "id",
|
|
"description": "Identify the impulse by its original filename\n (String), or by its position in the\n <code>.impulses</code> Array (Number).",
|
|
"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.",
|
|
"params": [
|
|
{
|
|
"name": "BPM",
|
|
"description": "Beats Per Minute",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "Seconds from now",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setBPM",
|
|
"params": [
|
|
{
|
|
"name": "BPM",
|
|
"description": "Beats Per Minute",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "Seconds from now",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "start",
|
|
"params": [
|
|
{
|
|
"name": "time",
|
|
"description": "seconds from now",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "loop",
|
|
"params": [
|
|
{
|
|
"name": "time",
|
|
"description": "seconds from now",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "stop",
|
|
"params": [
|
|
{
|
|
"name": "time",
|
|
"description": "seconds from now",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "pause",
|
|
"params": [
|
|
{
|
|
"name": "time",
|
|
"description": "seconds from now",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "addPhrase",
|
|
"params": [
|
|
{
|
|
"name": "phrase",
|
|
"description": "reference to a p5.Phrase",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "onStep",
|
|
"params": [
|
|
{
|
|
"name": "callback",
|
|
"description": "The name of the callback\n you want to fire\n on every beat/tatum.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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.",
|
|
"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",
|
|
"params": [
|
|
{
|
|
"name": "BPM",
|
|
"description": "Beats Per Minute",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "Seconds from now",
|
|
"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",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setInput",
|
|
"params": [
|
|
{
|
|
"name": "unit",
|
|
"description": "p5.sound object or a web audio unit\n that outputs sound",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "record",
|
|
"params": [
|
|
{
|
|
"name": "soundFile",
|
|
"description": "p5.SoundFile",
|
|
"type": "p5.SoundFile"
|
|
},
|
|
{
|
|
"name": "duration",
|
|
"description": "Time (in seconds)",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "callback",
|
|
"description": "The name of a function that will be\n called once the recording completes",
|
|
"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.",
|
|
"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",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "saveSound",
|
|
"params": [
|
|
{
|
|
"name": "soundFile",
|
|
"description": "p5.SoundFile that you wish to save",
|
|
"type": "p5.SoundFile"
|
|
},
|
|
{
|
|
"name": "name",
|
|
"description": "name of the resulting .wav file.",
|
|
"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.",
|
|
"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\nAccepts an FFT object. You must call .analyze()\non the FFT object prior to updating the peakDetect\nbecause it relies on a completed FFT analysis.",
|
|
"itemtype": "method",
|
|
"name": "update",
|
|
"params": [
|
|
{
|
|
"name": "fftObject",
|
|
"description": "A p5.FFT object",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "onPeak",
|
|
"params": [
|
|
{
|
|
"name": "callback",
|
|
"description": "Name of a function that will\n be called when a peak is\n detected.",
|
|
"type": "Function"
|
|
},
|
|
{
|
|
"name": "val",
|
|
"description": "Optional value to pass\n into the function when\n a peak is detected.",
|
|
"type": "Object",
|
|
"optional": true
|
|
}
|
|
],
|
|
"example": [
|
|
"\n<div><code>\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</code></div>"
|
|
],
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "setInput",
|
|
"params": [
|
|
{
|
|
"name": "src",
|
|
"description": "p5.sound / Web Audio object with a sound\n output.",
|
|
"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",
|
|
"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.",
|
|
"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.",
|
|
"itemtype": "method",
|
|
"name": "amp",
|
|
"params": [
|
|
{
|
|
"name": "volume",
|
|
"description": "amplitude between 0 and 1.0",
|
|
"type": "Number"
|
|
},
|
|
{
|
|
"name": "rampTime",
|
|
"description": "create a fade that lasts rampTime",
|
|
"type": "Number",
|
|
"optional": true
|
|
},
|
|
{
|
|
"name": "timeFromNow",
|
|
"description": "schedule this event to happen\n seconds from now",
|
|
"type": "Number",
|
|
"optional": true
|
|
}
|
|
],
|
|
"class": "p5.Gain",
|
|
"module": "p5.sound",
|
|
"submodule": "p5.sound"
|
|
}
|
|
],
|
|
"warnings": [
|
|
{
|
|
"message": "param name missing: {p5.Vector | Array }\n vector to scale by",
|
|
"line": " src/3d/p5.Matrix.js:335"
|
|
},
|
|
{
|
|
"message": "replacing incorrect tag: returns with return",
|
|
"line": " src/core/environment.js:417"
|
|
},
|
|
{
|
|
"message": "replacing incorrect tag: returns with return",
|
|
"line": " src/core/environment.js:458"
|
|
},
|
|
{
|
|
"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": "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\nHelper functions; Checks whether val is a pot\nmore info on power of 2 here:\nhttps://www.opengl.org/wiki/NPOT_Texture",
|
|
"line": " src/3d/material.js:124"
|
|
},
|
|
{
|
|
"message": "Missing item type\nreturns the next highest power of 2 value",
|
|
"line": " src/3d/material.js:135"
|
|
},
|
|
{
|
|
"message": "Missing item type\np5 Geometry3D class",
|
|
"line": " src/3d/p5.Geometry3D.js:7"
|
|
},
|
|
{
|
|
"message": "Missing item type\ngenerate geometriy with parametric method",
|
|
"line": " src/3d/p5.Geometry3D.js:29"
|
|
},
|
|
{
|
|
"message": "Missing item type\ncompute faceNormals for a geometry",
|
|
"line": " src/3d/p5.Geometry3D.js:80"
|
|
},
|
|
{
|
|
"message": "Missing item type\ncompute vertexNormals for a geometry",
|
|
"line": " src/3d/p5.Geometry3D.js:105"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[generateUV description]",
|
|
"line": " src/3d/p5.Geometry3D.js:189"
|
|
},
|
|
{
|
|
"message": "Missing item type\ngenerate an object containing information needed to create buffer",
|
|
"line": " src/3d/p5.Geometry3D.js:206"
|
|
},
|
|
{
|
|
"message": "Missing item type\nturn a two dimensional array into one dimensional array",
|
|
"line": " src/3d/p5.Geometry3D.js:232"
|
|
},
|
|
{
|
|
"message": "Missing item type\nturn an array of Vector into a one dimensional array of numbers",
|
|
"line": " src/3d/p5.Geometry3D.js:244"
|
|
},
|
|
{
|
|
"message": "Missing item type",
|
|
"line": " src/3d/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/3d/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/3d/p5.Matrix.js:50"
|
|
},
|
|
{
|
|
"message": "Missing item type\nGets a copy of the vector, returns a p5.Matrix object.",
|
|
"line": " src/3d/p5.Matrix.js:69"
|
|
},
|
|
{
|
|
"message": "Missing item type\nreturn a copy of a matrix",
|
|
"line": " src/3d/p5.Matrix.js:78"
|
|
},
|
|
{
|
|
"message": "Missing item type\nreturn an identity matrix",
|
|
"line": " src/3d/p5.Matrix.js:103"
|
|
},
|
|
{
|
|
"message": "Missing item type\ntranspose according to a given matrix",
|
|
"line": " src/3d/p5.Matrix.js:111"
|
|
},
|
|
{
|
|
"message": "Missing item type\ninvert matrix according to a give matrix",
|
|
"line": " src/3d/p5.Matrix.js:171"
|
|
},
|
|
{
|
|
"message": "Missing item type\ninspired by Toji's mat4 determinant",
|
|
"line": " src/3d/p5.Matrix.js:256"
|
|
},
|
|
{
|
|
"message": "Missing item type\nmultiply two mat4s",
|
|
"line": " src/3d/p5.Matrix.js:279"
|
|
},
|
|
{
|
|
"message": "Missing item type\nscales a p5.Matrix by scalars or a vector",
|
|
"line": " src/3d/p5.Matrix.js:335"
|
|
},
|
|
{
|
|
"message": "Missing item type\nrotate our Matrix around an axis by the given angle.",
|
|
"line": " src/3d/p5.Matrix.js:381"
|
|
},
|
|
{
|
|
"message": "Missing item type",
|
|
"line": " src/3d/p5.Matrix.js:460"
|
|
},
|
|
{
|
|
"message": "Missing item type\nsets the perspective matrix",
|
|
"line": " src/3d/p5.Matrix.js:490"
|
|
},
|
|
{
|
|
"message": "Missing item type\nsets the ortho matrix",
|
|
"line": " src/3d/p5.Matrix.js:524"
|
|
},
|
|
{
|
|
"message": "Missing item type\nPRIVATE",
|
|
"line": " src/3d/p5.Matrix.js:559"
|
|
},
|
|
{
|
|
"message": "Missing item type\n3D graphics class. Can also be used as an off-screen graphics buffer.\nA p5.Renderer3D object can be constructed",
|
|
"line": " src/3d/p5.Renderer3D.js:20"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[resize description]",
|
|
"line": " src/3d/p5.Renderer3D.js:89"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[background description]",
|
|
"line": " src/3d/p5.Renderer3D.js:101"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[initShaders description]",
|
|
"line": " src/3d/p5.Renderer3D.js:126"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[translate description]",
|
|
"line": " src/3d/p5.Renderer3D.js:316"
|
|
},
|
|
{
|
|
"message": "Missing item type\nScales the Model View Matrix by a vector",
|
|
"line": " src/3d/p5.Renderer3D.js:333"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[rotate description]",
|
|
"line": " src/3d/p5.Renderer3D.js:345"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[rotateX description]",
|
|
"line": " src/3d/p5.Renderer3D.js:356"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[rotateY description]",
|
|
"line": " src/3d/p5.Renderer3D.js:366"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[rotateZ description]",
|
|
"line": " src/3d/p5.Renderer3D.js:376"
|
|
},
|
|
{
|
|
"message": "Missing item type\npushes a copy of the model view matrix onto the\nMV Matrix stack.\nNOTE to self: could probably make this more readable",
|
|
"line": " src/3d/p5.Renderer3D.js:386"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[pop description]",
|
|
"line": " src/3d/p5.Renderer3D.js:396"
|
|
},
|
|
{
|
|
"message": "Missing item type\ncreateBuffer",
|
|
"line": " src/3d/retainedMode3D.js:8"
|
|
},
|
|
{
|
|
"message": "Missing item type\ninitBuffer description",
|
|
"line": " src/3d/retainedMode3D.js:39"
|
|
},
|
|
{
|
|
"message": "Missing item type\ndrawBuffer",
|
|
"line": " src/3d/retainedMode3D.js:79"
|
|
},
|
|
{
|
|
"message": "Missing item type\nmodule Conversion\nsubmodule Color Conversion",
|
|
"line": " src/color/color_conversion.js:1"
|
|
},
|
|
{
|
|
"message": "Missing item type\nConversions adapted from <http://www.easyrgb.com/math.html>.\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:69"
|
|
},
|
|
{
|
|
"message": "Missing item type\nSets the resolution at which curves display.\n\nThe default value is 20.",
|
|
"line": " src/core/curves.js:268"
|
|
},
|
|
{
|
|
"message": "Missing item type\nReturns the current framerate.",
|
|
"line": " src/core/environment.js:226"
|
|
},
|
|
{
|
|
"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:235"
|
|
},
|
|
{
|
|
"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:782"
|
|
},
|
|
{
|
|
"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:141"
|
|
},
|
|
{
|
|
"message": "Missing item type\nHelper fxn to measure ascent and descent.\nAdapted from http://stackoverflow.com/a/25355178",
|
|
"line": " src/core/p5.Renderer.js:197"
|
|
},
|
|
{
|
|
"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:350"
|
|
},
|
|
{
|
|
"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[rotateX description]",
|
|
"line": " src/core/transform.js:113"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[rotateY description]",
|
|
"line": " src/core/transform.js:138"
|
|
},
|
|
{
|
|
"message": "Missing item type\n[rotateZ description]",
|
|
"line": " src/core/transform.js:163"
|
|
},
|
|
{
|
|
"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:272"
|
|
},
|
|
{
|
|
"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\ncreates a gl texture\nused in WEBGL mode only",
|
|
"line": " src/image/p5.Image.js:602"
|
|
},
|
|
{
|
|
"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:1320"
|
|
},
|
|
{
|
|
"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:1343"
|
|
},
|
|
{
|
|
"message": "Missing item type\nReturns a file extension, or another string\nif the provided parameter has no extension.",
|
|
"line": " src/io/files.js:1379"
|
|
},
|
|
{
|
|
"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:1411"
|
|
},
|
|
{
|
|
"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:1423"
|
|
},
|
|
{
|
|
"message": "Missing item type\nTable Options\n<p>Generic class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.</p>\n<p>CSV files are\n<a href=\"http://en.wikipedia.org/wiki/Comma-separated_values\">\ncomma separated values</a>, often with the data in quotes. TSV\nfiles use tabs as separators, and usually don't bother with the\nquotes.</p>\n<p>File names should end with .csv if they're comma separated.</p>\n<p>A rough \"spec\" for CSV can be found\n<a href=\"http://tools.ietf.org/html/rfc4180\">here</a>.</p>\n<p>To load files, use the loadTable method.</p>\n<p>To save tables to your computer, use the save method\n or the saveTable method.</p>\n\nPossible options include:\n<ul>\n<li>csv - parse the table as comma-separated values\n<li>tsv - parse the table as tab-separated values\n<li>header - this table has a header (title) row\n</ul>",
|
|
"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:577"
|
|
},
|
|
{
|
|
"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\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:147"
|
|
},
|
|
{
|
|
"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:175"
|
|
},
|
|
{
|
|
"message": "Missing item type\nHelper function to measure ascent and descent.",
|
|
"line": " src/typography/attributes.js:203"
|
|
},
|
|
{
|
|
"message": "Missing item type\nComputes an array of points following the path for specified text",
|
|
"line": " src/typography/p5.Font.js:149"
|
|
},
|
|
{
|
|
"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:197"
|
|
},
|
|
{
|
|
"message": "Missing item type\nReturns an opentype path for the supplied string and position.",
|
|
"line": " src/typography/p5.Font.js:212"
|
|
},
|
|
{
|
|
"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:60"
|
|
},
|
|
{
|
|
"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:742"
|
|
},
|
|
{
|
|
"message": "Missing item type",
|
|
"line": " lib/addons/p5.dom.js:802"
|
|
},
|
|
{
|
|
"message": "Missing item type",
|
|
"line": " lib/addons/p5.dom.js:830"
|
|
},
|
|
{
|
|
"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:1050"
|
|
},
|
|
{
|
|
"message": "Missing item type",
|
|
"line": " lib/addons/p5.dom.js:1756"
|
|
},
|
|
{
|
|
"message": "Missing item type",
|
|
"line": " lib/addons/p5.dom.js:1826"
|
|
},
|
|
{
|
|
"message": "Missing item type",
|
|
"line": " lib/addons/p5.dom.js:1848"
|
|
},
|
|
{
|
|
"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"
|
|
}
|
|
]
|
|
}
|