{"project":{"name":"p5","description":"[![npm version](https:\/\/badge.fury.io\/js\/p5.svg)](https:\/\/www.npmjs.com\/package\/p5)","version":"1.11.13","url":"https:\/\/github.com\/processing\/p5.js#readme"},"files":{"src\/accessibility\/color_namer.js":{"name":"src\/accessibility\/color_namer.js","modules":{"Environment":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/accessibility\/describe.js":{"name":"src\/accessibility\/describe.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/accessibility\/gridOutput.js":{"name":"src\/accessibility\/gridOutput.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/accessibility\/outputs.js":{"name":"src\/accessibility\/outputs.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/accessibility\/textOutput.js":{"name":"src\/accessibility\/textOutput.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/color\/color_conversion.js":{"name":"src\/color\/color_conversion.js","modules":{"Color Conversion":1},"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\/friendly_errors\/fes_core.js":{"name":"src\/core\/friendly_errors\/fes_core.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/friendly_errors\/file_errors.js":{"name":"src\/core\/friendly_errors\/file_errors.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/friendly_errors\/sketch_reader.js":{"name":"src\/core\/friendly_errors\/sketch_reader.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/friendly_errors\/stacktrace.js":{"name":"src\/core\/friendly_errors\/stacktrace.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/friendly_errors\/validate_params.js":{"name":"src\/core\/friendly_errors\/validate_params.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/shape\/2d_primitives.js":{"name":"src\/core\/shape\/2d_primitives.js","modules":{"2D Primitives":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/shape\/attributes.js":{"name":"src\/core\/shape\/attributes.js","modules":{"Attributes":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/shape\/curves.js":{"name":"src\/core\/shape\/curves.js","modules":{"Curves":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/shape\/vertex.js":{"name":"src\/core\/shape\/vertex.js","modules":{"Vertex":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/constants.js":{"name":"src\/core\/constants.js","modules":{"Constants":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/environment.js":{"name":"src\/core\/environment.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/helpers.js":{"name":"src\/core\/helpers.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/core\/init.js":{"name":"src\/core\/init.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/core\/internationalization.js":{"name":"src\/core\/internationalization.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/core\/legacy.js":{"name":"src\/core\/legacy.js","modules":{},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/main.js":{"name":"src\/core\/main.js","modules":{"Structure":1},"classes":{"p5":1},"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":{},"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\/reference.js":{"name":"src\/core\/reference.js","modules":{"Foundation":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/core\/rendering.js":{"name":"src\/core\/rendering.js","modules":{},"classes":{},"fors":{"p5":1},"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\/data\/local_storage.js":{"name":"src\/data\/local_storage.js","modules":{"LocalStorage":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/data\/p5.TypedDict.js":{"name":"src\/data\/p5.TypedDict.js","modules":{"Dictionary":1},"classes":{"p5.TypedDict":1,"p5.StringDict":1,"p5.NumberDict":1},"fors":{"p5.TypedDict":1,"p5":1},"namespaces":{}},"src\/dom\/dom.js":{"name":"src\/dom\/dom.js","modules":{},"classes":{"p5.MediaElement":1,"p5.File":1},"fors":{"p5":1,"p5.Element":1},"namespaces":{}},"src\/events\/acceleration.js":{"name":"src\/events\/acceleration.js","modules":{"Events":1,"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":{"p5.PrintWriter":1},"fors":{"p5":1},"namespaces":{}},"src\/io\/p5.Table.js":{"name":"src\/io\/p5.Table.js","modules":{"Table":1},"classes":{"p5.Table":1},"fors":{},"namespaces":{}},"src\/io\/p5.TableRow.js":{"name":"src\/io\/p5.TableRow.js","modules":{},"classes":{"p5.TableRow":1},"fors":{},"namespaces":{}},"src\/io\/p5.XML.js":{"name":"src\/io\/p5.XML.js","modules":{},"classes":{"p5.XML":1},"fors":{},"namespaces":{}},"src\/math\/calculation.js":{"name":"src\/math\/calculation.js","modules":{"Calculation":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/math\/math.js":{"name":"src\/math\/math.js","modules":{"Vector":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":{},"classes":{"p5.Font":1},"fors":{},"namespaces":{}},"src\/utilities\/array_functions.js":{"name":"src\/utilities\/array_functions.js","modules":{"Array Functions":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/utilities\/conversion.js":{"name":"src\/utilities\/conversion.js","modules":{"Conversion":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/utilities\/string_functions.js":{"name":"src\/utilities\/string_functions.js","modules":{"String Functions":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/utilities\/time_date.js":{"name":"src\/utilities\/time_date.js","modules":{"Time & Date":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/3d_primitives.js":{"name":"src\/webgl\/3d_primitives.js","modules":{"3D Primitives":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/GeometryBuilder.js":{"name":"src\/webgl\/GeometryBuilder.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/webgl\/interaction.js":{"name":"src\/webgl\/interaction.js","modules":{"Interaction":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/light.js":{"name":"src\/webgl\/light.js","modules":{"Lights":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/loading.js":{"name":"src\/webgl\/loading.js","modules":{"3D Models":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/material.js":{"name":"src\/webgl\/material.js","modules":{"Material":1},"classes":{},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/p5.Camera.js":{"name":"src\/webgl\/p5.Camera.js","modules":{"Camera":1},"classes":{"p5.Camera":1},"fors":{"p5":1,"p5.Camera":1},"namespaces":{}},"src\/webgl\/p5.DataArray.js":{"name":"src\/webgl\/p5.DataArray.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/webgl\/p5.Framebuffer.js":{"name":"src\/webgl\/p5.Framebuffer.js","modules":{"Rendering":1},"classes":{"p5.FramebufferCamera":1,"p5.FramebufferTexture":1,"p5.Framebuffer":1},"fors":{"p5.Framebuffer":1},"namespaces":{}},"src\/webgl\/p5.Geometry.js":{"name":"src\/webgl\/p5.Geometry.js","modules":{},"classes":{"p5.Geometry":1},"fors":{"p5":1,"p5.Geometry":1},"namespaces":{}},"src\/webgl\/p5.Matrix.js":{"name":"src\/webgl\/p5.Matrix.js","modules":{},"classes":{"p5.Matrix":1},"fors":{},"namespaces":{}},"src\/webgl\/p5.Quat.js":{"name":"src\/webgl\/p5.Quat.js","modules":{"Quaternion":1},"classes":{"p5.Quat":1},"fors":{},"namespaces":{}},"src\/webgl\/p5.RenderBuffer.js":{"name":"src\/webgl\/p5.RenderBuffer.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/webgl\/p5.RendererGL.Immediate.js":{"name":"src\/webgl\/p5.RendererGL.Immediate.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/webgl\/p5.RendererGL.Retained.js":{"name":"src\/webgl\/p5.RendererGL.Retained.js","modules":{},"classes":{},"fors":{},"namespaces":{}},"src\/webgl\/p5.RendererGL.js":{"name":"src\/webgl\/p5.RendererGL.js","modules":{},"classes":{"p5.RendererGL":1},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/p5.Shader.js":{"name":"src\/webgl\/p5.Shader.js","modules":{},"classes":{"p5.Shader":1},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/p5.Texture.js":{"name":"src\/webgl\/p5.Texture.js","modules":{},"classes":{"p5.Texture":1},"fors":{"p5":1},"namespaces":{}},"src\/webgl\/text.js":{"name":"src\/webgl\/text.js","modules":{},"classes":{"ImageInfos":1,"FontInfo":1,"Cubic":1},"fors":{},"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.Oscillator":1,"p5.SinOsc":1,"p5.TriOsc":1,"p5.SawOsc":1,"p5.SqrOsc":1,"p5.Envelope":1,"p5.Noise":1,"p5.Pulse":1,"p5.AudioIn":1,"p5.Effect":1,"p5.Filter":1,"p5.LowPass":1,"p5.HighPass":1,"p5.BandPass":1,"p5.EQ":1,"p5.Panner3D":1,"p5.Delay":1,"p5.Reverb":1,"p5.Convolver":1,"p5.Phrase":1,"p5.Part":1,"p5.Score":1,"p5.SoundLoop":1,"p5.Compressor":1,"p5.PeakDetect":1,"p5.SoundRecorder":1,"p5.Distortion":1,"p5.Gain":1,"p5.AudioVoice":1,"p5.MonoSynth":1,"p5.OnsetDetect":1,"p5.PolySynth":1},"fors":{"p5.sound":1,"p5":1,"p5.SoundFile":1,"p5.Amplitude":1,"p5.FFT":1,"p5.Oscillator":1,"p5.Envelope":1,"p5.AudioIn":1,"p5.Effect":1,"p5.EQ":1,"p5.Panner3D":1,"p5.Delay":1,"p5.Reverb":1,"p5.Convolver":1,"p5.Part":1,"p5.Score":1,"p5.SoundLoop":1,"p5.Compressor":1,"p5.SoundRecorder":1,"p5.Distortion":1,"p5.Gain":1,"p5.AudioVoice":1,"p5.MonoSynth":1,"p5.PolySynth":1},"namespaces":{}},"lib\/addons\/p5.sound.min.js":{"name":"lib\/addons\/p5.sound.min.js","modules":{},"classes":{},"fors":{},"namespaces":{}}},"modules":{"Environment":{"name":"Environment","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Environment","file":"src\/accessibility\/color_namer.js","line":1,"requires":["core"]},"Color":{"name":"Color","submodules":{"Color Conversion":1,"Creating & Reading":1,"Setting":1},"elements":{},"classes":{"p5.Color":1},"fors":{"p5":1},"namespaces":{},"file":"src\/color\/p5.Color.js","line":318},"Color Conversion":{"name":"Color Conversion","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Color","namespace":"","file":"src\/color\/color_conversion.js","line":1,"requires":["core"]},"Creating & Reading":{"name":"Creating & Reading","submodules":{},"elements":{},"classes":{"p5.Color":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Color","namespace":"","file":"src\/color\/p5.Color.js","line":318,"requires":["core","constants"],"description":"<p>A class to describe a color.<\/p>\n<p>Each <code>p5.Color<\/code> object stores the color mode\nand level maxes that were active during its construction. These values are\nused to interpret the arguments passed to the object's constructor. They\nalso determine output formatting such as when\n<a href=\"#\/p5\/saturation\">saturation()<\/a> is called.<\/p>\n<p>Color is stored internally as an array of ideal RGBA values in floating\npoint form, normalized from 0 to 1. These values are used to calculate the\nclosest screen colors, which are RGBA levels from 0 to 255. Screen colors\nare sent to the renderer.<\/p>\n<p>When different color representations are calculated, the results are cached\nfor performance. These values are normalized, floating-point numbers.<\/p>\n<p>Note: <a href=\"#\/p5\/color\">color()<\/a> is the recommended way to create an\ninstance of this class.<\/p>\n"},"Setting":{"name":"Setting","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Color","namespace":"","file":"src\/color\/setting.js","line":1,"requires":["core","constants"]},"Shape":{"name":"Shape","submodules":{"2D Primitives":1,"Curves":1,"Vertex":1,"3D Primitives":1,"3D Models":1},"elements":{},"classes":{"p5.Geometry":1,"p5.Matrix":1},"fors":{"p5":1,"p5.Geometry":1},"namespaces":{},"file":"src\/webgl\/p5.Matrix.js","line":19},"2D Primitives":{"name":"2D Primitives","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src\/core\/shape\/2d_primitives.js","line":1,"requires":["core","constants"]},"Attributes":{"name":"Attributes","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Typography","namespace":"","file":"src\/core\/shape\/attributes.js","line":1,"requires":["core","constants"]},"Curves":{"name":"Curves","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src\/core\/shape\/curves.js","line":1,"requires":["core"]},"Vertex":{"name":"Vertex","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src\/core\/shape\/vertex.js","line":1,"requires":["core","constants"]},"Constants":{"name":"Constants","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Constants","file":"src\/core\/constants.js","line":1},"Structure":{"name":"Structure","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"IO","file":"src\/core\/main.js","line":1,"requires":["constants"]},"DOM":{"name":"DOM","submodules":{},"elements":{},"classes":{"p5.Element":1,"p5.MediaElement":1,"p5.File":1},"fors":{"p5.Element":1,"p5":1},"namespaces":{},"module":"DOM","file":"src\/dom\/dom.js","line":5482,"description":"<p>The web is much more than just canvas and the DOM functionality makes it easy to interact\nwith other HTML5 objects, including text, hyperlink, image, input, video,\naudio, and webcam.\nThere is a set of creation methods, DOM manipulation methods, and\nan extended <a href=\"#\/p5.Element\">p5.Element<\/a> 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.<\/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 library.<\/a><\/p>\n","requires":["p5"]},"Rendering":{"name":"Rendering","submodules":{},"elements":{},"classes":{"p5.Graphics":1,"p5.Renderer":1,"p5.FramebufferCamera":1,"p5.FramebufferTexture":1,"p5.Framebuffer":1,"p5.RendererGL":1},"fors":{"p5":1,"p5.Framebuffer":1},"namespaces":{},"module":"Rendering","file":"src\/webgl\/p5.RendererGL.js","line":1102,"tag":"module","description":"<p>A class to describe a drawing surface that's separate from the main canvas.<\/p>\n<p>Each <code>p5.Graphics<\/code> object provides a dedicated drawing surface called a\n<em>graphics buffer<\/em>. Graphics buffers are helpful when drawing should happen\noffscreen. For example, separate scenes can be drawn offscreen and\ndisplayed only when needed.<\/p>\n<p><code>p5.Graphics<\/code> objects have nearly all the drawing features of the main\ncanvas. For example, calling the method <code>myGraphics.circle(50, 50, 20)<\/code>\ndraws to the graphics buffer. The resulting image can be displayed on the\nmain canvas by passing the <code>p5.Graphics<\/code> object to the\n<a href=\"#\/p5\/image\">image()<\/a> function, as in <code>image(myGraphics, 0, 0)<\/code>.<\/p>\n<p>Note: <a href=\"#\/p5\/createGraphics\">createGraphics()<\/a> is the recommended\nway to create an instance of this class.<\/p>\n","requires":["constants"]},"Foundation":{"name":"Foundation","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Foundation","file":"src\/core\/reference.js","line":1},"Transform":{"name":"Transform","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"namespaces":{},"module":"Transform","file":"src\/core\/transform.js","line":1,"requires":["core","constants"]},"Data":{"name":"Data","submodules":{"LocalStorage":1,"Dictionary":1,"Array Functions":1,"Conversion":1,"String Functions":1},"elements":{},"classes":{"p5.TypedDict":1,"p5.StringDict":1,"p5.NumberDict":1},"fors":{"p5":1,"p5.TypedDict":1},"namespaces":{},"file":"src\/data\/p5.TypedDict.js","line":415},"LocalStorage":{"name":"LocalStorage","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Data","namespace":"","file":"src\/data\/local_storage.js","line":1,"requires":["core\n\nThis module defines the p5 methods for working with local storage"]},"Dictionary":{"name":"Dictionary","submodules":{},"elements":{},"classes":{"p5.TypedDict":1,"p5.StringDict":1,"p5.NumberDict":1},"fors":{"p5.TypedDict":1,"p5":1},"is_submodule":1,"namespaces":{},"module":"Data","namespace":"","file":"src\/data\/p5.TypedDict.js","line":415,"requires":["core\n\nThis module defines the p5 methods for the p5 Dictionary classes.\nThe classes StringDict and NumberDict are for storing and working\nwith key-value pairs."],"description":"<p>Base class for all p5.Dictionary types. Specifically\n typed Dictionary classes inherit from this class.<\/p>\n"},"Events":{"name":"Events","submodules":{"Acceleration":1,"Keyboard":1,"Mouse":1,"Touch":1},"elements":{},"classes":{},"fors":{"p5":1},"namespaces":{},"file":"src\/events\/acceleration.js","line":1,"requires":["core"],"tag":"main","itemtype":"main"},"Acceleration":{"name":"Acceleration","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Events","namespace":"","file":"src\/events\/acceleration.js","line":1,"requires":["core"],"tag":"main","itemtype":"main"},"Keyboard":{"name":"Keyboard","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Events","namespace":"","file":"src\/events\/keyboard.js","line":1,"requires":["core"]},"Mouse":{"name":"Mouse","submodules":{},"elements":{},"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":{},"elements":{},"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},"elements":{},"classes":{"p5.Image":1},"fors":{"p5":1},"namespaces":{},"module":"Image","file":"src\/image\/p5.Image.js","line":21,"requires":["core"],"description":"<p>A class to describe an image.<\/p>\n<p>Images are rectangular grids of pixels that can be displayed and modified.<\/p>\n<p>Existing images can be loaded by calling\n<a href=\"#\/p5\/loadImage\">loadImage()<\/a>. Blank images can be created by\ncalling <a href=\"#\/p5\/createImage\">createImage()<\/a>. <code>p5.Image<\/code> objects\nhave methods for common tasks such as applying filters and modifying\npixel values.<\/p>\n"},"Loading & Displaying":{"name":"Loading & Displaying","submodules":{},"elements":{},"classes":{"p5.Font":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Typography","namespace":"","file":"src\/typography\/p5.Font.js","line":13,"requires":["core"],"description":"<p>This module defines the <a href=\"#\/p5.Font\">p5.Font<\/a> class and functions for\ndrawing text to the display canvas.<\/p>\n"},"Pixels":{"name":"Pixels","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Image","namespace":"","file":"src\/image\/pixels.js","line":1,"requires":["core"]},"IO":{"name":"IO","submodules":{"Structure":1,"Input":1,"Output":1,"Table":1,"Time & Date":1},"elements":{},"classes":{"p5":1,"p5.PrintWriter":1,"p5.Table":1,"p5.TableRow":1,"p5.XML":1},"fors":{"p5":1},"namespaces":{},"file":"src\/io\/p5.XML.js","line":9},"Input":{"name":"Input","submodules":{},"elements":{},"classes":{"p5.XML":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src\/io\/p5.XML.js","line":9,"requires":["core"],"description":"<p>A class to describe an XML object.<\/p>\n<p>Each <code>p5.XML<\/code> object provides an easy way to interact with XML data.\nExtensible Markup Language\n(<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/XML\/XML_introduction\" target=\"_blank\">XML<\/a>)\nis a standard format for sending data between applications. Like HTML, the\nXML format is based on tags and attributes, as in\n<code>&lt;time units=\"s\"&gt;1234&lt;\/time&gt;<\/code>.<\/p>\n<p>Note: Use <a href=\"#\/p5\/loadXML\">loadXML()<\/a> to load external XML files.<\/p>\n"},"Output":{"name":"Output","submodules":{},"elements":{},"classes":{"p5":1,"p5.PrintWriter":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src\/io\/files.js","line":1565,"description":"<p>This is the p5 instance constructor.<\/p>\n<p>A p5 instance holds all the properties and methods related to\na p5 sketch.  It expects an incoming sketch closure and it can also\ntake an optional node parameter for attaching the generated p5 canvas\nto a node.  The sketch closure takes the newly created p5 instance as\nits sole argument and may optionally set <a href=\"#\/p5\/preload\">preload()<\/a>,\n<a href=\"#\/p5\/setup\">setup()<\/a>, and\/or\n<a href=\"#\/p5\/draw\">draw()<\/a> properties on it for running a sketch.<\/p>\n<p>A p5 sketch can run in \"global\" or \"instance\" mode:\n\"global\"   - all properties and methods are attached to the window\n\"instance\" - all properties and methods are bound to this p5 object<\/p>\n"},"Table":{"name":"Table","submodules":{},"elements":{},"classes":{"p5.Table":1,"p5.TableRow":1},"fors":{},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src\/io\/p5.TableRow.js","line":9,"requires":["core"],"description":"<p><a href=\"#\/p5.Table\">Table<\/a> 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.<\/p>\n"},"Math":{"name":"Math","submodules":{"Calculation":1,"Vector":1,"Noise":1,"Random":1,"Trigonometry":1,"Quaternion":1},"elements":{},"classes":{"p5.Vector":1,"p5.Quat":1},"fors":{"p5":1},"namespaces":{},"file":"src\/webgl\/p5.Quat.js","line":8},"Calculation":{"name":"Calculation","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src\/math\/calculation.js","line":1,"requires":["core"]},"Vector":{"name":"Vector","submodules":{},"elements":{},"classes":{"p5.Vector":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src\/math\/p5.Vector.js","line":11,"requires":["core"],"description":"<p>A class to describe a two or three-dimensional vector.<\/p>\n<p>A vector can be thought of in different ways. In one view, a vector is like\nan arrow pointing in space. Vectors have both magnitude (length) and\ndirection.<\/p>\n<p><code>p5.Vector<\/code> objects are often used to program motion because they simplify\nthe math. For example, a moving ball has a position and a velocity.\nPosition describes where the ball is in space. The ball's position vector\nextends from the origin to the ball's center. Velocity describes the ball's\nspeed and the direction it's moving. If the ball is moving straight up, its\nvelocity vector points straight up. Adding the ball's velocity vector to\nits position vector moves it, as in <code>pos.add(vel)<\/code>. Vector math relies on\nmethods inside the <code>p5.Vector<\/code> class.<\/p>\n<p>Note: <a href=\"#\/p5\/createVector\">createVector()<\/a> is the recommended way\nto make an instance of this class.<\/p>\n"},"Noise":{"name":"Noise","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src\/math\/noise.js","line":14,"requires":["core"]},"Random":{"name":"Random","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src\/math\/random.js","line":1,"requires":["core"]},"Trigonometry":{"name":"Trigonometry","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src\/math\/trigonometry.js","line":1,"requires":["core","constants"]},"Typography":{"name":"Typography","submodules":{"Attributes":1,"Loading & Displaying":1},"elements":{},"classes":{"p5.Font":1},"fors":{"p5":1},"namespaces":{},"file":"src\/typography\/p5.Font.js","line":13},"Array Functions":{"name":"Array Functions","submodules":{},"elements":{},"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":{},"elements":{},"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":{},"elements":{},"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":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"IO","namespace":"","file":"src\/utilities\/time_date.js","line":1,"requires":["core"]},"3D Primitives":{"name":"3D Primitives","submodules":{},"elements":{},"classes":{"p5.Geometry":1},"fors":{"p5":1,"p5.Geometry":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src\/webgl\/p5.Geometry.js","line":13,"requires":["core","p5.Geometry"],"description":"<p>A class to describe a 3D shape.<\/p>\n<p>Each <code>p5.Geometry<\/code> object represents a 3D shape as a set of connected\npoints called <em>vertices<\/em>. All 3D shapes are made by connecting vertices to\nform triangles that are stitched together. Each triangular patch on the\ngeometry's surface is called a <em>face<\/em>. The geometry stores information\nabout its vertices and faces for use with effects such as lighting and\ntexture mapping.<\/p>\n<p>The first parameter, <code>detailX<\/code>, is optional. If a number is passed, as in\n<code>new p5.Geometry(24)<\/code>, it sets the number of triangle subdivisions to use\nalong the geometry's x-axis. By default, <code>detailX<\/code> is 1.<\/p>\n<p>The second parameter, <code>detailY<\/code>, is also optional. If a number is passed,\nas in <code>new p5.Geometry(24, 16)<\/code>, it sets the number of triangle\nsubdivisions to use along the geometry's y-axis. By default, <code>detailX<\/code> is\n1.<\/p>\n<p>The third parameter, <code>callback<\/code>, is also optional. If a function is passed,\nas in <code>new p5.Geometry(24, 16, createShape)<\/code>, it will be called once to add\nvertices to the new 3D shape.<\/p>\n"},"3D":{"name":"3D","submodules":{"Interaction":1,"Lights":1,"Material":1,"Camera":1},"elements":{},"classes":{"p5.Camera":1,"p5.Shader":1,"p5.Texture":1,"ImageInfos":1,"FontInfo":1,"Cubic":1},"fors":{"p5":1,"p5.Camera":1},"namespaces":{},"file":"src\/webgl\/text.js","line":279},"Interaction":{"name":"Interaction","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"3D","namespace":"","file":"src\/webgl\/interaction.js","line":1,"requires":["core"]},"Lights":{"name":"Lights","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"3D","namespace":"","file":"src\/webgl\/light.js","line":1,"requires":["core"]},"3D Models":{"name":"3D Models","submodules":{},"elements":{},"classes":{},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"Shape","namespace":"","file":"src\/webgl\/loading.js","line":1,"requires":["core","p5.Geometry"]},"Material":{"name":"Material","submodules":{},"elements":{},"classes":{"p5.Shader":1,"p5.Texture":1},"fors":{"p5":1},"is_submodule":1,"namespaces":{},"module":"3D","namespace":"","file":"src\/webgl\/p5.Texture.js","line":12,"requires":["core"],"description":"<p>This module defines the p5.Shader class<\/p>\n"},"Camera":{"name":"Camera","submodules":{},"elements":{},"classes":{"p5.Camera":1},"fors":{"p5":1,"p5.Camera":1},"is_submodule":1,"namespaces":{},"module":"3D","namespace":"","file":"src\/webgl\/p5.Camera.js","line":723,"requires":["core"],"description":"<p>A class to describe a camera for viewing a 3D sketch.<\/p>\n<p>Each <code>p5.Camera<\/code> object represents a camera that views a section of 3D\nspace. It stores information about the camera\u2019s position, orientation, and\nprojection.<\/p>\n<p>In WebGL mode, the default camera is a <code>p5.Camera<\/code> object that can be\ncontrolled with the <a href=\"#\/p5\/camera\">camera()<\/a>,\n<a href=\"#\/p5\/perspective\">perspective()<\/a>,\n<a href=\"#\/p5\/ortho\">ortho()<\/a>, and\n<a href=\"#\/p5\/frustum\">frustum()<\/a> functions. Additional cameras can be\ncreated with <a href=\"#\/p5\/createCamera\">createCamera()<\/a> and activated\nwith <a href=\"#\/p5\/setCamera\">setCamera()<\/a>.<\/p>\n<p>Note: <code>p5.Camera<\/code>\u2019s methods operate in two coordinate systems:<\/p>\n<ul>\n<li>The \u201cworld\u201d coordinate system describes positions in terms of their\nrelationship to the origin along the x-, y-, and z-axes. For example,\ncalling <code>myCamera.setPosition()<\/code> places the camera in 3D space using\n\"world\" coordinates.<\/li>\n<li>The \"local\" coordinate system describes positions from the camera's point\nof view: left-right, up-down, and forward-backward. For example, calling\n<code>myCamera.move()<\/code> moves the camera along its own axes.<\/li>\n<\/ul>\n"},"Quaternion":{"name":"Quaternion","submodules":{},"elements":{},"classes":{"p5.Quat":1},"fors":{},"is_submodule":1,"namespaces":{},"module":"Math","namespace":"","file":"src\/webgl\/p5.Quat.js","line":8,"description":"<p>A class to describe a Quaternion\nfor vector rotations in the p5js webgl renderer.\nPlease refer the following link for details on the implementation\n<a href=\"https:\/\/danceswithcode.net\/engineeringnotes\/quaternions\/quaternions.html\">https:\/\/danceswithcode.net\/engineeringnotes\/quaternions\/quaternions.html<\/a><\/p>\n"},"p5.sound":{"name":"p5.sound","submodules":{},"elements":{},"classes":{"p5.sound":1,"p5.SoundFile":1,"p5.Amplitude":1,"p5.FFT":1,"p5.Oscillator":1,"p5.SinOsc":1,"p5.TriOsc":1,"p5.SawOsc":1,"p5.SqrOsc":1,"p5.Envelope":1,"p5.Noise":1,"p5.Pulse":1,"p5.AudioIn":1,"p5.Effect":1,"p5.Filter":1,"p5.LowPass":1,"p5.HighPass":1,"p5.BandPass":1,"p5.EQ":1,"p5.Panner3D":1,"p5.Delay":1,"p5.Reverb":1,"p5.Convolver":1,"p5.Phrase":1,"p5.Part":1,"p5.Score":1,"p5.SoundLoop":1,"p5.Compressor":1,"p5.PeakDetect":1,"p5.SoundRecorder":1,"p5.Distortion":1,"p5.Gain":1,"p5.AudioVoice":1,"p5.MonoSynth":1,"p5.OnsetDetect":1,"p5.PolySynth":1},"fors":{"p5.sound":1,"p5":1,"p5.SoundFile":1,"p5.Amplitude":1,"p5.FFT":1,"p5.Oscillator":1,"p5.Envelope":1,"p5.AudioIn":1,"p5.Effect":1,"p5.EQ":1,"p5.Panner3D":1,"p5.Delay":1,"p5.Reverb":1,"p5.Convolver":1,"p5.Part":1,"p5.Score":1,"p5.SoundLoop":1,"p5.Compressor":1,"p5.SoundRecorder":1,"p5.Distortion":1,"p5.Gain":1,"p5.AudioVoice":1,"p5.MonoSynth":1,"p5.PolySynth":1},"namespaces":{},"module":"p5.sound","file":"lib\/addons\/p5.sound.js","line":11691,"description":"<p>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<\/p>\n<ul>\n<li><a href=\"#\/p5.SoundFile\"><b>p5.SoundFile<\/b><\/a>: Load and play sound files.<\/li>\n<li><a href=\"#\/p5.Amplitude\"><b>p5.Amplitude<\/b><\/a>: Get the current volume of a sound.<\/li>\n<li><a href=\"#\/p5.AudioIn\"><b>p5.AudioIn<\/b><\/a>: Get sound from an input source, typically\n  a computer microphone.<\/li>\n<li><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).<\/li>\n<li><a href=\"#\/p5.Oscillator\"><b>p5.Oscillator<\/b><\/a>: Generate Sine,\n  Triangle, Square and Sawtooth waveforms. Base class of\n  <li><a href=\"#\/p5.Noise\">p5.Noise<\/a> and <a href=\"#\/p5.Pulse\">p5.Pulse<\/a>.\n  <\/li>\n<li>\n  <a href=\"#\/p5.MonoSynth\">p5.MonoSynth<\/a> and <a href=\"#\/p5.PolySynth\">p5.PolySynth<\/a>: Play musical notes\n<\/li>\n<li><a href=\"#\/p5.Envelope\"><b>p5.Envelope<\/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.<\/li>\n<li><a href=\"#\/p5.Delay\"><b>p5.Delay<\/b><\/a>: A delay effect with\n  parameters for feedback, delayTime, and lowpass filter.<\/li>\n<li><a href=\"#\/p5.Filter\"><b>p5.Filter<\/b><\/a>: Filter the frequency range of a\n  sound.\n<\/li>\n<li><a href=\"#\/p5.Reverb\"><b>p5.Reverb<\/b><\/a>: Add reverb to a sound by specifying\n  duration and decay. <\/li>\n<b><li><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.<\/li>\n<b><li><a href=\"#\/p5.SoundRecorder\">p5.SoundRecorder<\/a><\/b>: Record sound for playback\n  \/ save the .wav file.\n<b><li><a href=\"#\/p5.SoundLoop\">p5.SoundLoop<\/a>, <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<\/li>\n<li><a href=\"#\/p5\/userStartAudio\">userStartAudio<\/a>: Enable audio in a\nbrowser- and user-friendly way.<\/a>\n<p>p5.sound is on <a href=\"https:\/\/github.com\/processing\/p5.js-sound\/\">GitHub<\/a>.\nDownload the latest version\n<a href=\"https:\/\/github.com\/processing\/p5.js-sound\/blob\/master\/lib\/p5.sound.js\">here<\/a>.<\/p>","tag":"main","itemtype":"main"}},"classes":{"p5":{"name":"p5","shortname":"p5","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"IO","submodule":"Output","namespace":"","file":"src\/core\/main.js","line":12,"description":"<p>This is the p5 instance constructor.<\/p>\n<p>A p5 instance holds all the properties and methods related to\na p5 sketch.  It expects an incoming sketch closure and it can also\ntake an optional node parameter for attaching the generated p5 canvas\nto a node.  The sketch closure takes the newly created p5 instance as\nits sole argument and may optionally set <a href=\"#\/p5\/preload\">preload()<\/a>,\n<a href=\"#\/p5\/setup\">setup()<\/a>, and\/or\n<a href=\"#\/p5\/draw\">draw()<\/a> properties on it for running a sketch.<\/p>\n<p>A p5 sketch can run in \"global\" or \"instance\" mode:\n\"global\"   - all properties and methods are attached to the window\n\"instance\" - all properties and methods are bound to this p5 object<\/p>\n","is_constructor":1,"params":[{"name":"sketch","description":"<p>a closure that can set optional <a href=\"#\/p5\/preload\">preload()<\/a>,\n                             <a href=\"#\/p5\/setup\">setup()<\/a>, and\/or <a href=\"#\/p5\/draw\">draw()<\/a> properties on the\n                             given p5 instance<\/p>\n","type":"Function(p5)"},{"name":"node","description":"<p>element to attach canvas to<\/p>\n","type":"HTMLElement","optional":true}],"return":{"description":"a p5 instance","type":"P5"}},"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":318,"description":"<p>A class to describe a color.<\/p>\n<p>Each <code>p5.Color<\/code> object stores the color mode\nand level maxes that were active during its construction. These values are\nused to interpret the arguments passed to the object's constructor. They\nalso determine output formatting such as when\n<a href=\"#\/p5\/saturation\">saturation()<\/a> is called.<\/p>\n<p>Color is stored internally as an array of ideal RGBA values in floating\npoint form, normalized from 0 to 1. These values are used to calculate the\nclosest screen colors, which are RGBA levels from 0 to 255. Screen colors\nare sent to the renderer.<\/p>\n<p>When different color representations are calculated, the results are cached\nfor performance. These values are normalized, floating-point numbers.<\/p>\n<p>Note: <a href=\"#\/p5\/color\">color()<\/a> is the recommended way to create an\ninstance of this class.<\/p>\n","is_constructor":1,"params":[{"name":"pInst","description":"<p>pointer to p5 instance.<\/p>\n","type":"P5","optional":true},{"name":"vals","description":"<p>an array containing the color values\n                                         for red, green, blue and alpha channel\n                                         or CSS color.<\/p>\n","type":"Number[]|String"}]},"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":"<p>A class to describe an\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/HTML\/Introduction_to_HTML\/Getting_started\" target=\"_blank\">HTML element<\/a>.<\/p>\n<p>Sketches can use many elements. Common elements include the drawing canvas,\nbuttons, sliders, webcam feeds, and so on.<\/p>\n<p>All elements share the methods of the <code>p5.Element<\/code> class. They're created\nwith functions such as <a href=\"#\/p5\/createCanvas\">createCanvas()<\/a> and\n<a href=\"#\/p5\/createButton\">createButton()<\/a>.<\/p>\n","is_constructor":1,"params":[{"name":"elt","description":"<p>wrapped DOM element.<\/p>\n","type":"HTMLElement"},{"name":"pInst","description":"<p>pointer to p5 instance.<\/p>\n","type":"P5","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a button element and\n  \/\/ place it beneath the canvas.\n  let btn = createButton('change');\n  btn.position(0, 100);\n\n  \/\/ Call randomColor() when\n  \/\/ the button is pressed.\n  btn.mousePressed(randomColor);\n\n  describe('A gray square with a button that says \"change\" beneath it. The square changes color when the user presses the button.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"]},"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":"<p>A class to describe a drawing surface that's separate from the main canvas.<\/p>\n<p>Each <code>p5.Graphics<\/code> object provides a dedicated drawing surface called a\n<em>graphics buffer<\/em>. Graphics buffers are helpful when drawing should happen\noffscreen. For example, separate scenes can be drawn offscreen and\ndisplayed only when needed.<\/p>\n<p><code>p5.Graphics<\/code> objects have nearly all the drawing features of the main\ncanvas. For example, calling the method <code>myGraphics.circle(50, 50, 20)<\/code>\ndraws to the graphics buffer. The resulting image can be displayed on the\nmain canvas by passing the <code>p5.Graphics<\/code> object to the\n<a href=\"#\/p5\/image\">image()<\/a> function, as in <code>image(myGraphics, 0, 0)<\/code>.<\/p>\n<p>Note: <a href=\"#\/p5\/createGraphics\">createGraphics()<\/a> is the recommended\nway to create an instance of this class.<\/p>\n","is_constructor":1,"extends":"p5.Element","params":[{"name":"width","description":"<p>width of the graphics buffer in pixels.<\/p>\n","type":"Number"},{"name":"height","description":"<p>height of the graphics buffer in pixels.<\/p>\n","type":"Number"},{"name":"renderer","description":"<p>renderer to use, either P2D or WEBGL.<\/p>\n","type":"Constant"},{"name":"pInst","description":"<p>sketch instance.<\/p>\n","type":"P5","optional":true},{"name":"canvas","description":"<p>existing <code>&lt;canvas&gt;<\/code> element to use.<\/p>\n","type":"HTMLCanvasElement","optional":true}],"example":["\n<div>\n<code>\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object.\n  pg = createGraphics(50, 50);\n\n  \/\/ Draw to the p5.Graphics object.\n  pg.background(100);\n  pg.circle(25, 25, 20);\n\n  describe('A dark gray square with a white circle at its center drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Display the p5.Graphics object.\n  image(pg, 25, 25);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the canvas to display the graphics buffer.\n\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object.\n  pg = createGraphics(50, 50);\n\n  describe('A square appears on a gray background when the user presses the mouse. The square cycles between white and black.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the background color.\n  let bg = frameCount % 255;\n\n  \/\/ Draw to the p5.Graphics object.\n  pg.background(bg);\n\n  \/\/ Display the p5.Graphics object while\n  \/\/ the user presses the mouse.\n  if (mouseIsPressed === true) {\n    image(pg, 25, 25);\n  }\n}\n<\/code>\n<\/div>"]},"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":"<p>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, respectively.<\/p>\n","is_constructor":1,"extends":"p5.Element","params":[{"name":"elt","description":"<p>DOM node that is wrapped<\/p>\n","type":"HTMLElement"},{"name":"pInst","description":"<p>pointer to p5 instance<\/p>\n","type":"P5","optional":true},{"name":"isMainCanvas","description":"<p>whether we're using it as main canvas<\/p>\n","type":"Boolean","optional":true}]},"p5.TypedDict":{"name":"p5.TypedDict","shortname":"p5.TypedDict","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Data","submodule":"Dictionary","namespace":"","file":"src\/data\/p5.TypedDict.js","line":82,"description":"<p>Base class for all p5.Dictionary types. Specifically\n typed Dictionary classes inherit from this class.<\/p>\n","is_constructor":1},"p5.StringDict":{"name":"p5.StringDict","shortname":"p5.StringDict","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Data","submodule":"Dictionary","namespace":"","file":"src\/data\/p5.TypedDict.js","line":397,"description":"<p>A simple Dictionary class for Strings.<\/p>\n","extends":"p5.TypedDict"},"p5.NumberDict":{"name":"p5.NumberDict","shortname":"p5.NumberDict","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Data","submodule":"Dictionary","namespace":"","file":"src\/data\/p5.TypedDict.js","line":415,"description":"<p>A simple Dictionary class for Numbers.<\/p>\n","is_constructor":1,"extends":"p5.TypedDict"},"p5.MediaElement":{"name":"p5.MediaElement","shortname":"p5.MediaElement","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"DOM","submodule":"DOM","namespace":"","file":"src\/dom\/dom.js","line":4099,"description":"<p>A class to handle audio and video.<\/p>\n<p><code>p5.MediaElement<\/code> extends <a href=\"#\/p5.Element\">p5.Element<\/a> with\nmethods to handle audio and video. <code>p5.MediaElement<\/code> objects are created by\ncalling <a href=\"#\/p5\/createVideo\">createVideo<\/a>,\n<a href=\"#\/p5\/createAudio\">createAudio<\/a>, and\n<a href=\"#\/p5\/createCapture\">createCapture<\/a>.<\/p>\n","is_constructor":1,"params":[{"name":"elt","description":"<p>DOM node that is wrapped<\/p>\n","type":"String"}],"extends":"p5.Element","example":["\n<div class='notest'>\n<code>\nlet capture;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createCapture().\n  capture = createCapture(VIDEO);\n  capture.hide();\n\n  describe('A webcam feed with inverted colors.');\n}\n\nfunction draw() {\n  \/\/ Display the video stream and invert the colors.\n  image(capture, 0, 0, width, width * capture.height \/ capture.width);\n  filter(INVERT);\n}\n<\/code>\n<\/div>"]},"p5.File":{"name":"p5.File","shortname":"p5.File","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"DOM","submodule":"DOM","namespace":"","file":"src\/dom\/dom.js","line":5482,"description":"<p>A class to describe a file.<\/p>\n<p><code>p5.File<\/code> objects are used by\n<a href=\"#\/p5.Element\/drop\">myElement.drop()<\/a> and\ncreated by\n<a href=\"#\/p5\/createFileInput\">createFileInput<\/a>.<\/p>\n","is_constructor":1,"params":[{"name":"file","description":"<p>wrapped file.<\/p>\n","type":"File"}],"example":["\n<div>\n<code>\n\/\/ Use the file input to load a\n\/\/ file and display its info.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call displayInfo() when the file loads.\n  let input = createFileInput(displayInfo);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.');\n}\n\n\/\/ Display the p5.File's info once it loads.\nfunction displayInfo(file) {\n  background(200);\n\n  \/\/ Display the p5.File's name.\n  text(file.name, 10, 10, 80, 40);\n\n  \/\/ Display the p5.File's type and subtype.\n  text(`${file.type}\/${file.subtype}`, 10, 70);\n\n  \/\/ Display the p5.File's size in bytes.\n  text(file.size, 10, 90);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Use the file input to select an image to\n\/\/ load and display.\nlet img;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call handleImage() when the file image loads.\n  let input = createFileInput(handleImage);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the image if it's ready.\n  if (img) {\n    image(img, 0, 0, width, height);\n  }\n}\n\n\/\/ Use the p5.File's data once it loads.\nfunction handleImage(file) {\n  \/\/ Check the p5.File's type.\n  if (file.type === 'image') {\n    \/\/ Create an image using using the p5.File's data.\n    img = createImg(file.data, '');\n\n    \/\/ Hide the image element so it doesn't appear twice.\n    img.hide();\n  } else {\n    img = null;\n  }\n}\n<\/code>\n<\/div>"]},"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":21,"description":"<p>A class to describe an image.<\/p>\n<p>Images are rectangular grids of pixels that can be displayed and modified.<\/p>\n<p>Existing images can be loaded by calling\n<a href=\"#\/p5\/loadImage\">loadImage()<\/a>. Blank images can be created by\ncalling <a href=\"#\/p5\/createImage\">createImage()<\/a>. <code>p5.Image<\/code> objects\nhave methods for common tasks such as applying filters and modifying\npixel values.<\/p>\n","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('An image of a brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the GRAY filter.\n  img.filter(GRAY);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A grayscale image of a brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels.\n  img.loadPixels();\n\n  \/\/ Set the pixels to black.\n  for (let x = 0; x < img.width; x += 1) {\n    for (let y = 0; y < img.height; y += 1) {\n      img.set(x, y, 0);\n    }\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"is_constructor":1,"params":[{"name":"width","description":"","type":"Number"},{"name":"height","description":"","type":"Number"}]},"p5.PrintWriter":{"name":"p5.PrintWriter","shortname":"p5.PrintWriter","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"IO","submodule":"Output","namespace":"","file":"src\/io\/files.js","line":1565,"description":"<p>A class to describe a print stream.<\/p>\n<p>Each <code>p5.PrintWriter<\/code> object provides a way to save a sequence of text\ndata, called the <em>print stream<\/em>, to the user's computer. It's a low-level\nobject that enables precise control of text output. Functions such as\n<a href=\"#\/p5\/saveStrings\">saveStrings()<\/a> and\n<a href=\"#\/p5\/saveJSON\">saveJSON()<\/a> are easier to use for simple file\nsaving.<\/p>\n<p>Note: <a href=\"#\/p5\/createWriter\">createWriter()<\/a> is the recommended way\nto make an instance of this class.<\/p>\n","params":[{"name":"filename","description":"<p>name of the file to create.<\/p>\n","type":"String"},{"name":"extension","description":"<p>format to use for the file.<\/p>\n","type":"String","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Create a p5.PrintWriter object.\n  let myWriter = createWriter('xo.txt');\n\n  \/\/ Add some lines to the print stream.\n  myWriter.print('XOO');\n  myWriter.print('OXO');\n  myWriter.print('OOX');\n\n  \/\/ Save the file and close the print stream.\n  myWriter.close();\n}\n<\/code>\n<\/div>"]},"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":33,"description":"<p><a href=\"#\/p5.Table\">Table<\/a> 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.<\/p>\n","is_constructor":1,"params":[{"name":"rows","description":"<p>An array of p5.TableRow objects<\/p>\n","type":"p5.TableRow[]","optional":true}]},"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":9,"description":"<p>A TableRow object represents a single row of data values,\nstored in columns, from a table.<\/p>\n<p>A Table Row contains both an ordered array, and an unordered\nJSON object.<\/p>\n","is_constructor":1,"params":[{"name":"str","description":"<p>optional: populate the row with a\n                            string of values, separated by the\n                            separator<\/p>\n","type":"String","optional":true},{"name":"separator","description":"<p>comma separated values (csv) by default<\/p>\n","type":"String","optional":true}]},"p5.XML":{"name":"p5.XML","shortname":"p5.XML","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"IO","submodule":"Input","namespace":"","file":"src\/io\/p5.XML.js","line":9,"description":"<p>A class to describe an XML object.<\/p>\n<p>Each <code>p5.XML<\/code> object provides an easy way to interact with XML data.\nExtensible Markup Language\n(<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/XML\/XML_introduction\" target=\"_blank\">XML<\/a>)\nis a standard format for sending data between applications. Like HTML, the\nXML format is based on tags and attributes, as in\n<code>&lt;time units=\"s\"&gt;1234&lt;\/time&gt;<\/code>.<\/p>\n<p>Note: Use <a href=\"#\/p5\/loadXML\">loadXML()<\/a> to load external XML files.<\/p>\n","is_constructor":1,"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get an array with all mammal tags.\n  let mammals = myXML.getChildren('mammal');\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Iterate over the mammals array.\n  for (let i = 0; i < mammals.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Get the mammal's common name.\n    let name = mammals[i].getContent();\n\n    \/\/ Display the mammal's name.\n    text(name, 20, y);\n  }\n\n  describe(\n    'The words \"Goat\", \"Leopard\", and \"Zebra\" written on three separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"]},"p5.Vector":{"name":"p5.Vector","shortname":"p5.Vector","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Math","submodule":"Vector","namespace":"","file":"src\/math\/p5.Vector.js","line":11,"description":"<p>A class to describe a two or three-dimensional vector.<\/p>\n<p>A vector can be thought of in different ways. In one view, a vector is like\nan arrow pointing in space. Vectors have both magnitude (length) and\ndirection.<\/p>\n<p><code>p5.Vector<\/code> objects are often used to program motion because they simplify\nthe math. For example, a moving ball has a position and a velocity.\nPosition describes where the ball is in space. The ball's position vector\nextends from the origin to the ball's center. Velocity describes the ball's\nspeed and the direction it's moving. If the ball is moving straight up, its\nvelocity vector points straight up. Adding the ball's velocity vector to\nits position vector moves it, as in <code>pos.add(vel)<\/code>. Vector math relies on\nmethods inside the <code>p5.Vector<\/code> class.<\/p>\n<p>Note: <a href=\"#\/p5\/createVector\">createVector()<\/a> is the recommended way\nto make an instance of this class.<\/p>\n","is_constructor":1,"params":[{"name":"x","description":"<p>x component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z component of the vector.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let p1 = createVector(25, 25);\n  let p2 = createVector(75, 75);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Draw the first point using a p5.Vector.\n  point(p1);\n\n  \/\/ Draw the second point using a p5.Vector's components.\n  point(p2.x, p2.y);\n\n  describe('Two black dots on a gray square, one at the top left and the other at the bottom right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet pos;\nlet vel;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create p5.Vector objects.\n  pos = createVector(50, 100);\n  vel = createVector(0, -1);\n\n  describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Add velocity to position.\n  pos.add(vel);\n\n  \/\/ If the dot reaches the top of the canvas,\n  \/\/ restart from the bottom.\n  if (pos.y < 0) {\n    pos.y = 100;\n  }\n\n  \/\/ Draw the dot.\n  strokeWeight(5);\n  point(pos);\n}\n<\/code>\n<\/div>"]},"p5.Font":{"name":"p5.Font","shortname":"p5.Font","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Typography","submodule":"Loading & Displaying","namespace":"","file":"src\/typography\/p5.Font.js","line":13,"description":"<p>A class to describe fonts.<\/p>\n","is_constructor":1,"params":[{"name":"pInst","description":"<p>pointer to p5 instance.<\/p>\n","type":"P5","optional":true}],"example":["\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  \/\/ Creates a p5.Font object.\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Style the text.\n  fill('deeppink');\n  textFont(font);\n  textSize(36);\n\n  \/\/ Display the text.\n  text('p5*js', 10, 50);\n\n  describe('The text \"p5*js\" written in pink on a gray background.');\n}\n<\/code>\n<\/div>"]},"p5.Camera":{"name":"p5.Camera","shortname":"p5.Camera","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"3D","submodule":"Camera","namespace":"","file":"src\/webgl\/p5.Camera.js","line":723,"description":"<p>A class to describe a camera for viewing a 3D sketch.<\/p>\n<p>Each <code>p5.Camera<\/code> object represents a camera that views a section of 3D\nspace. It stores information about the camera\u2019s position, orientation, and\nprojection.<\/p>\n<p>In WebGL mode, the default camera is a <code>p5.Camera<\/code> object that can be\ncontrolled with the <a href=\"#\/p5\/camera\">camera()<\/a>,\n<a href=\"#\/p5\/perspective\">perspective()<\/a>,\n<a href=\"#\/p5\/ortho\">ortho()<\/a>, and\n<a href=\"#\/p5\/frustum\">frustum()<\/a> functions. Additional cameras can be\ncreated with <a href=\"#\/p5\/createCamera\">createCamera()<\/a> and activated\nwith <a href=\"#\/p5\/setCamera\">setCamera()<\/a>.<\/p>\n<p>Note: <code>p5.Camera<\/code>\u2019s methods operate in two coordinate systems:<\/p>\n<ul>\n<li>The \u201cworld\u201d coordinate system describes positions in terms of their\nrelationship to the origin along the x-, y-, and z-axes. For example,\ncalling <code>myCamera.setPosition()<\/code> places the camera in 3D space using\n\"world\" coordinates.<\/li>\n<li>The \"local\" coordinate system describes positions from the camera's point\nof view: left-right, up-down, and forward-backward. For example, calling\n<code>myCamera.move()<\/code> moves the camera along its own axes.<\/li>\n<\/ul>\n","is_constructor":1,"params":[{"name":"rendererGL","description":"<p>instance of WebGL renderer<\/p>\n","type":"RendererGL"}],"example":["\n<div>\n<code>\nlet cam;\nlet delta = 0.001;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The cube goes in and out of view as the camera pans left and right.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Turn the camera left and right, called \"panning\".\n  cam.pan(delta);\n\n  \/\/ Switch directions every 120 frames.\n  if (frameCount % 120 === 0) {\n    delta *= -1;\n  }\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  \/\/ Place it at the top-left.\n  \/\/ Point it at the origin.\n  cam2 = createCamera();\n  cam2.setPosition(400, -400, 800);\n  cam2.lookAt(0, 0, 0);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe(\n    'A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>"]},"p5.Framebuffer":{"name":"p5.Framebuffer","shortname":"p5.Framebuffer","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Rendering","namespace":"","file":"src\/webgl\/p5.Framebuffer.js","line":76,"description":"<p>A class to describe a high-performance drawing surface for textures.<\/p>\n<p>Each <code>p5.Framebuffer<\/code> object provides a dedicated drawing surface called\na <em>framebuffer<\/em>. They're similar to\n<a href=\"#\/p5.Graphics\">p5.Graphics<\/a> objects but can run much faster.\nPerformance is improved because the framebuffer shares the same WebGL\ncontext as the canvas used to create it.<\/p>\n<p><code>p5.Framebuffer<\/code> objects have all the drawing features of the main\ncanvas. Drawing instructions meant for the framebuffer must be placed\nbetween calls to\n<a href=\"#\/p5.Framebuffer\/begin\">myBuffer.begin()<\/a> and\n<a href=\"#\/p5.Framebuffer\/end\">myBuffer.end()<\/a>. The resulting image\ncan be applied as a texture by passing the <code>p5.Framebuffer<\/code> object to the\n<a href=\"#\/p5\/texture\">texture()<\/a> function, as in <code>texture(myBuffer)<\/code>.\nIt can also be displayed on the main canvas by passing it to the\n<a href=\"#\/p5\/image\">image()<\/a> function, as in <code>image(myBuffer, 0, 0)<\/code>.<\/p>\n<p>Note: <a href=\"#\/p5\/createFramebuffer\">createFramebuffer()<\/a> is the\nrecommended way to create an instance of this class.<\/p>\n","is_constructor":1,"params":[{"name":"target","description":"<p>sketch instance or\n                               <a href=\"#\/p5.Graphics\">p5.Graphics<\/a>\n                               object.<\/p>\n","type":"p5.Graphics|p5"},{"name":"settings","description":"<p>configuration options.<\/p>\n","type":"Object","optional":true}]},"p5.Geometry":{"name":"p5.Geometry","shortname":"p5.Geometry","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"Shape","submodule":"3D Primitives","namespace":"","file":"src\/webgl\/p5.Geometry.js","line":13,"description":"<p>A class to describe a 3D shape.<\/p>\n<p>Each <code>p5.Geometry<\/code> object represents a 3D shape as a set of connected\npoints called <em>vertices<\/em>. All 3D shapes are made by connecting vertices to\nform triangles that are stitched together. Each triangular patch on the\ngeometry's surface is called a <em>face<\/em>. The geometry stores information\nabout its vertices and faces for use with effects such as lighting and\ntexture mapping.<\/p>\n<p>The first parameter, <code>detailX<\/code>, is optional. If a number is passed, as in\n<code>new p5.Geometry(24)<\/code>, it sets the number of triangle subdivisions to use\nalong the geometry's x-axis. By default, <code>detailX<\/code> is 1.<\/p>\n<p>The second parameter, <code>detailY<\/code>, is also optional. If a number is passed,\nas in <code>new p5.Geometry(24, 16)<\/code>, it sets the number of triangle\nsubdivisions to use along the geometry's y-axis. By default, <code>detailX<\/code> is\n1.<\/p>\n<p>The third parameter, <code>callback<\/code>, is also optional. If a function is passed,\nas in <code>new p5.Geometry(24, 16, createShape)<\/code>, it will be called once to add\nvertices to the new 3D shape.<\/p>\n","is_constructor":1,"params":[{"name":"detailX","description":"<p>number of vertices along the x-axis.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of vertices along the y-axis.<\/p>\n","type":"Integer","optional":true},{"name":"callback","description":"<p>function to call once the geometry is created.<\/p>\n","type":"Function","optional":true}],"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  myGeometry = new p5.Geometry();\n\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(40, 0, 0);\n\n  \/\/ Add the vertices to the p5.Geometry object's vertices array.\n  myGeometry.vertices.push(v0, v1, v2);\n\n  describe('A white triangle drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object using a callback function.\n  myGeometry = new p5.Geometry(1, 1, createShape);\n\n  describe('A white triangle drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n\nfunction createShape() {\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(40, 0, 0);\n\n  \/\/ \"this\" refers to the p5.Geometry object being created.\n\n  \/\/ Add the vertices to the p5.Geometry object's vertices array.\n  this.vertices.push(v0, v1, v2);\n\n  \/\/ Add an array to list which vertices belong to the face.\n  \/\/ Vertices are listed in clockwise \"winding\" order from\n  \/\/ left to top to right.\n  this.faces.push([0, 1, 2]);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object using a callback function.\n  myGeometry = new p5.Geometry(1, 1, createShape);\n\n  describe('A white triangle drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n\nfunction createShape() {\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(40, 0, 0);\n\n  \/\/ \"this\" refers to the p5.Geometry object being created.\n\n  \/\/ Add the vertices to the p5.Geometry object's vertices array.\n  this.vertices.push(v0, v1, v2);\n\n  \/\/ Add an array to list which vertices belong to the face.\n  \/\/ Vertices are listed in clockwise \"winding\" order from\n  \/\/ left to top to right.\n  this.faces.push([0, 1, 2]);\n\n  \/\/ Compute the surface normals to help with lighting.\n  this.computeNormals();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\n\/\/ Adapted from Paul Wheeler's wonderful p5.Geometry tutorial.\n\/\/ https:\/\/www.paulwheeler.us\/articles\/custom-3d-geometry-in-p5js\/\n\/\/ CC-BY-SA 4.0\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Geometry object.\n  \/\/ Set detailX to 48 and detailY to 2.\n  \/\/ >>> try changing them.\n  myGeometry = new p5.Geometry(48, 2, createShape);\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the p5.Geometry object.\n  strokeWeight(0.2);\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n\nfunction createShape() {\n  \/\/ \"this\" refers to the p5.Geometry object being created.\n\n  \/\/ Define the M\u00f6bius strip with a few parameters.\n  let spread = 0.1;\n  let radius = 30;\n  let stripWidth = 15;\n  let xInterval = 4 * PI \/ this.detailX;\n  let yOffset = -stripWidth \/ 2;\n  let yInterval = stripWidth \/ this.detailY;\n\n  for (let j = 0; j <= this.detailY; j += 1) {\n    \/\/ Calculate the \"vertical\" point along the strip.\n    let v = yOffset + yInterval * j;\n\n    for (let i = 0; i <= this.detailX; i += 1) {\n      \/\/ Calculate the angle of rotation around the strip.\n      let u = i * xInterval;\n\n      \/\/ Calculate the coordinates of the vertex.\n      let x = (radius + v * cos(u \/ 2)) * cos(u) - sin(u \/ 2) * 2 * spread;\n      let y = (radius + v * cos(u \/ 2)) * sin(u);\n      if (u < TWO_PI) {\n        y += sin(u) * spread;\n      } else {\n        y -= sin(u) * spread;\n      }\n      let z = v * sin(u \/ 2) + sin(u \/ 4) * 4 * spread;\n\n      \/\/ Create a p5.Vector object to position the vertex.\n      let vert = createVector(x, y, z);\n\n      \/\/ Add the vertex to the p5.Geometry object's vertices array.\n      this.vertices.push(vert);\n    }\n  }\n\n  \/\/ Compute the faces array.\n  this.computeFaces();\n\n  \/\/ Compute the surface normals to help with lighting.\n  this.computeNormals();\n}\n<\/code>\n<\/div>"]},"p5.Shader":{"name":"p5.Shader","shortname":"p5.Shader","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"3D","submodule":"Material","namespace":"","file":"src\/webgl\/p5.Shader.js","line":11,"description":"<p>A class to describe a shader program.<\/p>\n<p>Each <code>p5.Shader<\/code> object contains a shader program that runs on the graphics\nprocessing unit (GPU). Shaders can process many pixels or vertices at the\nsame time, making them fast for many graphics tasks. They\u2019re written in a\nlanguage called\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Games\/Techniques\/3D_on_the_web\/GLSL_Shaders\" target=\"_blank\">GLSL<\/a>\nand run along with the rest of the code in a sketch.<\/p>\n<p>A shader program consists of two files, a vertex shader and a fragment\nshader. The vertex shader affects where 3D geometry is drawn on the screen\nand the fragment shader affects color. Once the <code>p5.Shader<\/code> object is\ncreated, it can be used with the <a href=\"#\/p5\/shader\">shader()<\/a>\nfunction, as in <code>shader(myShader)<\/code>.<\/p>\n<p>A shader can optionally describe <em>hooks,<\/em> which are functions in GLSL that\nusers may choose to provide to customize the behavior of the shader. For the\nvertex or the fragment shader, users can pass in an object where each key is\nthe type and name of a hook function, and each value is a string with the\nparameter list and default implementation of the hook. For example, to let users\noptionally run code at the start of the vertex shader, the options object could\ninclude:<\/p>\n<pre><code class=\"language-js\">{\n  vertex: {\n    'void beforeVertex': '() {}'\n  }\n}\n<\/code><\/pre>\n<p>Then, in your vertex shader source, you can run a hook by calling a function\nwith the same name prefixed by <code>HOOK_<\/code>:<\/p>\n<pre><code class=\"language-glsl\">void main() {\n  HOOK_beforeVertex();\n  \/\/ Add the rest of your shader code here!\n}\n<\/code><\/pre>\n<p>Note: <a href=\"#\/p5\/createShader\">createShader()<\/a>,\n<a href=\"#\/p5\/createFilterShader\">createFilterShader()<\/a>, and\n<a href=\"#\/p5\/loadShader\">loadShader()<\/a> are the recommended ways to\ncreate an instance of this class.<\/p>\n","is_constructor":1,"params":[{"name":"renderer","description":"<p>WebGL context for this shader.<\/p>\n","type":"p5.RendererGL"},{"name":"vertSrc","description":"<p>source code for the vertex shader program.<\/p>\n","type":"String"},{"name":"fragSrc","description":"<p>source code for the fragment shader program.<\/p>\n","type":"String"},{"name":"options","description":"<p>An optional object describing how this shader can\nbe augmented with hooks. It can include:<\/p>\n<ul>\n<li><code>vertex<\/code>: An object describing the available vertex shader hooks.<\/li>\n<li><code>fragment<\/code>: An object describing the available frament shader hooks.<\/li>\n<\/ul>\n","type":"Object","optional":true}],"example":["\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision highp float;\n\nvoid main() {\n  \/\/ Set each pixel's RGBA value to yellow.\n  gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);\n}\n`;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  let myShader = createShader(vertSrc, fragSrc);\n\n  \/\/ Apply the p5.Shader object.\n  shader(myShader);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a plane as a drawing surface.\n  plane(100, 100);\n\n  describe('A yellow square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\nlet mandelbrot;\n\n\/\/ Load the shader and create a p5.Shader object.\nfunction preload() {\n  mandelbrot = loadShader('assets\/shader.vert', 'assets\/shader.frag');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Use the p5.Shader object.\n  shader(mandelbrot);\n\n  \/\/ Set the shader uniform p to an array.\n  mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]);\n\n  describe('A fractal image zooms in and out of focus.');\n}\n\nfunction draw() {\n  \/\/ Set the shader uniform r to a value that oscillates between 0 and 2.\n  mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1);\n\n  \/\/ Add a quad as a display surface for the shader.\n  quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n<\/code>\n<\/div>"]},"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":1405,"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":"<p>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.<\/p>\n","type":"String|Array"},{"name":"successCallback","description":"<p>Name of a function to call once file loads<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>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.<\/p>\n","type":"Function","optional":true},{"name":"whileLoadingCallback","description":"<p>Name of a function to call while file\n                                           is loading. That function will\n                                           receive progress of the request to\n                                           load the sound file\n                                           (between 0 and 1) as its first\n                                           parameter. This progress\n                                           does not account for the additional\n                                           time needed to decode the audio data.<\/p>\n","type":"Function","optional":true}],"example":["\n<div><code>\nlet mySound;\nfunction preload() {\n  soundFormats('mp3', 'ogg');\n  mySound = loadSound('assets\/doorbell');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n  background(220);\n  text('tap here to play', 10, 20);\n}\n\nfunction canvasPressed() {\n  \/\/ playing a sound file on a user gesture\n  \/\/ is equivalent to `userStartAudio()`\n  mySound.play();\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":3022,"description":"<p>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.<\/p>\n","is_constructor":1,"params":[{"name":"smoothing","description":"<p>between 0.0 and .999 to smooth\n                           amplitude readings (defaults to 0)<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet sound, amplitude;\n\nfunction preload(){\n  sound = loadSound('assets\/beat.mp3');\n}\nfunction setup() {\n  let cnv = createCanvas(100,100);\n  cnv.mouseClicked(togglePlay);\n  amplitude = new p5.Amplitude();\n}\n\nfunction draw() {\n  background(220);\n  text('tap to play', 20, 20);\n\n  let level = amplitude.getLevel();\n  let size = map(level, 0, 1, 0, 200);\n  ellipse(width\/2, height\/2, size, size);\n}\n\nfunction togglePlay() {\n  if (sound.isPlaying() ){\n    sound.pause();\n  } else {\n    sound.loop();\n\t\tamplitude = new p5.Amplitude();\n\t\tamplitude.setInput(sound);\n  }\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":3347,"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> \u2022 <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\u2022 <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":"<p>Smooth results of Freq Spectrum.\n                              0.0 < smoothing < 1.0.\n                              Defaults to 0.8.<\/p>\n","type":"Number","optional":true},{"name":"bins","description":"<p>Length of resulting array.\n                          Must be a power of two between\n                          16 and 1024. Defaults to 1024.<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nfunction preload(){\n  sound = loadSound('assets\/Damscray_DancingTiger.mp3');\n}\n\nfunction setup(){\n  let cnv = createCanvas(100,100);\n  cnv.mouseClicked(togglePlay);\n  fft = new p5.FFT();\n  sound.amp(0.2);\n}\n\nfunction draw(){\n  background(220);\n\n  let spectrum = fft.analyze();\n  noStroke();\n  fill(255, 0, 255);\n  for (let i = 0; i< spectrum.length; i++){\n    let x = map(i, 0, spectrum.length, 0, width);\n    let h = -height + map(spectrum[i], 0, 255, height, 0);\n    rect(x, height, width \/ spectrum.length, h )\n  }\n\n  let waveform = fft.waveform();\n  noFill();\n  beginShape();\n  stroke(20);\n  for (let i = 0; i < waveform.length; i++){\n    let x = map(i, 0, waveform.length, 0, width);\n    let y = map( waveform[i], -1, 1, 0, height);\n    vertex(x,y);\n  }\n  endShape();\n\n  text('tap to play', 20, 20);\n}\n\nfunction togglePlay() {\n  if (sound.isPlaying()) {\n    sound.pause();\n  } else {\n    sound.loop();\n  }\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":4060,"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 instantiating a\nspecific oscillator: <a href=\"\/reference\/#\/p5.SinOsc\">p5.SinOsc<\/a>, <a\nhref=\"\/reference\/#\/p5.TriOsc\">p5.TriOsc<\/a>, <a\nhref=\"\/reference\/#\/p5.SqrOsc\">p5.SqrOsc<\/a>, or <a\nhref=\"\/reference\/#\/p5.SawOsc\">p5.SawOsc<\/a>.\n<\/p>","is_constructor":1,"params":[{"name":"freq","description":"<p>frequency defaults to 440Hz<\/p>\n","type":"Number","optional":true},{"name":"type","description":"<p>type of oscillator. Options:\n                       'sine' (default), 'triangle',\n                       'sawtooth', 'square'<\/p>\n","type":"String","optional":true}],"example":["\n<div><code>\nlet osc, playing, freq, amp;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playOscillator);\n  osc = new p5.Oscillator('sine');\n}\n\nfunction draw() {\n  background(220)\n  freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\n  amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\n\n  text('tap to play', 20, 20);\n  text('freq: ' + freq, 20, 40);\n  text('amp: ' + amp, 20, 60);\n\n  if (playing) {\n    \/\/ smooth the transitions by 0.1 seconds\n    osc.freq(freq, 0.1);\n    osc.amp(amp, 0.1);\n  }\n}\n\nfunction playOscillator() {\n  \/\/ starting an oscillator on a user gesture will enable audio\n  \/\/ in browsers that have a strict autoplay policy.\n  \/\/ See also: userStartAudio();\n  osc.start();\n  playing = true;\n}\n\nfunction mouseReleased() {\n  \/\/ ramp amplitude to 0 over 0.5 seconds\n  osc.amp(0, 0.5);\n  playing = false;\n}\n<\/code> <\/div>"]},"p5.SinOsc":{"name":"p5.SinOsc","shortname":"p5.SinOsc","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":4602,"description":"<p>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.<\/p>\n","is_constructor":1,"extends":"p5.Oscillator","params":[{"name":"freq","description":"<p>Set the frequency<\/p>\n","type":"Number","optional":true}]},"p5.TriOsc":{"name":"p5.TriOsc","shortname":"p5.TriOsc","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":4629,"description":"<p>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.<\/p>\n","is_constructor":1,"extends":"p5.Oscillator","params":[{"name":"freq","description":"<p>Set the frequency<\/p>\n","type":"Number","optional":true}]},"p5.SawOsc":{"name":"p5.SawOsc","shortname":"p5.SawOsc","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":4656,"description":"<p>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.<\/p>\n","is_constructor":1,"extends":"p5.Oscillator","params":[{"name":"freq","description":"<p>Set the frequency<\/p>\n","type":"Number","optional":true}]},"p5.SqrOsc":{"name":"p5.SqrOsc","shortname":"p5.SqrOsc","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":4683,"description":"<p>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.<\/p>\n","is_constructor":1,"extends":"p5.Oscillator","params":[{"name":"freq","description":"<p>Set the frequency<\/p>\n","type":"Number","optional":true}]},"p5.Envelope":{"name":"p5.Envelope","shortname":"p5.Envelope","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":4721,"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\u2014for example, a p5.Envelope can\ncontrol an Oscillator's frequency like this: <code>osc.freq(env)<\/code>.<\/p>\n<p>Use <code><a href=\"#\/p5.Envelope\/setRange\">setRange<\/a><\/code> to change the attack\/release level.\nUse <code><a href=\"#\/p5.Envelope\/setADSR\">setADSR<\/a><\/code> to change attackTime, decayTime, sustainPercent and releaseTime.<\/p>\n<p>Use the <code><a href=\"#\/p5.Envelope\/play\">play<\/a><\/code> method to play the entire envelope,\nthe <code><a href=\"#\/p5.Envelope\/ramp\">ramp<\/a><\/code> method for a pingable trigger,\nor <code><a href=\"#\/p5.Envelope\/triggerAttack\">triggerAttack<\/a><\/code>\/\n<code><a href=\"#\/p5.Envelope\/triggerRelease\">triggerRelease<\/a><\/code> to trigger noteOn\/noteOff.<\/p>","is_constructor":1,"example":["\n<div><code>\nlet t1 = 0.1; \/\/ attack time in seconds\nlet l1 = 0.7; \/\/ attack level 0.0 to 1.0\nlet t2 = 0.3; \/\/ decay time in seconds\nlet l2 = 0.1; \/\/ decay level  0.0 to 1.0\n\nlet env;\nlet triOsc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  background(220);\n  text('tap to play', 20, 20);\n  cnv.mousePressed(playSound);\n\n  env = new p5.Envelope(t1, l1, t2, l2);\n  triOsc = new p5.Oscillator('triangle');\n}\n\nfunction playSound() {\n  \/\/ starting the oscillator ensures that audio is enabled.\n  triOsc.start();\n  env.play(triOsc);\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":5620,"description":"<p>Noise is a type of oscillator that generates a buffer with random values.<\/p>\n","extends":"p5.Oscillator","is_constructor":1,"params":[{"name":"type","description":"<p>Type of noise can be 'white' (default),\n                     'brown' or 'pink'.<\/p>\n","type":"String"}]},"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":5779,"description":"<p>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.<\/p>\n","extends":"p5.Oscillator","is_constructor":1,"params":[{"name":"freq","description":"<p>Frequency in oscillations per second (Hz)<\/p>\n","type":"Number","optional":true},{"name":"w","description":"<p>Width between the pulses (0 to 1.0,\n                       defaults to 0)<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet pulse;\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(startPulse);\n  background(220);\n\n  pulse = new p5.Pulse();\n  pulse.amp(0.5);\n  pulse.freq(220);\n}\nfunction startPulse() {\n  pulse.start();\n  pulse.amp(0.5, 0.02);\n}\nfunction mouseReleased() {\n  pulse.amp(0, 0.2);\n}\nfunction draw() {\n  background(220);\n  text('tap to play', 5, 20, width - 20);\n  let w = map(mouseX, 0, width, 0, 1);\n  w = constrain(w, 0, 1);\n  pulse.width(w);\n  text('pulse width: ' + w, 5, height - 20);\n}\n<\/code><\/div>"]},"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":6015,"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. Access in Chrome browser\nis limited to localhost and https, but access over http may be limited.<\/em><\/p>","is_constructor":1,"params":[{"name":"errorCallback","description":"<p>A function to call if there is an error\n                                  accessing the AudioIn. For example,\n                                  Safari and iOS devices do not\n                                  currently allow microphone access.<\/p>\n","type":"Function","optional":true}],"example":["\n<div><code>\nlet mic;\n\n function setup(){\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(userStartAudio);\n  textAlign(CENTER);\n  mic = new p5.AudioIn();\n  mic.start();\n}\n\nfunction draw(){\n  background(0);\n  fill(255);\n  text('tap to start', width\/2, 20);\n\n  micLevel = mic.getLevel();\n  let y = height - micLevel * height;\n  ellipse(width\/2, y, 10, 10);\n}\n<\/code><\/div>"]},"p5.Effect":{"name":"p5.Effect","shortname":"p5.Effect","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":6423,"description":"<p>Effect is a base class for audio effects in p5. <br>\nThis module handles the nodes and methods that are\ncommon and useful for current and future effects.<\/p>\n<p>This class is extended by <a href=\"\/reference\/#\/p5.Distortion\">p5.Distortion<\/a>,\n<a href=\"\/reference\/#\/p5.Compressor\">p5.Compressor<\/a>,\n<a href=\"\/reference\/#\/p5.Delay\">p5.Delay<\/a>,\n<a href=\"\/reference\/#\/p5.Filter\">p5.Filter<\/a>,\n<a href=\"\/reference\/#\/p5.Reverb\">p5.Reverb<\/a>.<\/p>\n","is_constructor":1,"params":[{"name":"ac","description":"<p>Reference to the audio context of the p5 object<\/p>\n","type":"Object","optional":true},{"name":"input","description":"<p>Gain Node effect wrapper<\/p>\n","type":"AudioNode","optional":true},{"name":"output","description":"<p>Gain Node effect wrapper<\/p>\n","type":"AudioNode","optional":true},{"name":"_drywet","description":"<p>Tone.JS CrossFade node (defaults to value: 1)<\/p>\n","type":"Object","optional":true},{"name":"wet","description":"<p>Effects that extend this class should connect\n                             to the wet signal to this gain node, so that dry and wet\n                             signals are mixed properly.<\/p>\n","type":"AudioNode","optional":true}]},"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":6628,"description":"<p>A p5.Filter uses a Web Audio Biquad Filter to filter\nthe frequency response of an input source. Subclasses\ninclude:<\/p>\n<a href=\"\/reference\/#\/p5.LowPass\"><code>p5.LowPass<\/code><\/a>:\nAllows frequencies below the cutoff frequency to pass through,\nand attenuates frequencies above the cutoff.<br\/>\n<a href=\"\/reference\/#\/p5.HighPass\"><code>p5.HighPass<\/code><\/a>:\nThe opposite of a lowpass filter. <br\/>\n<a href=\"\/reference\/#\/p5.BandPass\"><code>p5.BandPass<\/code><\/a>:\nAllows a range of frequencies to pass through and attenuates\nthe frequencies below and above this frequency range.<br\/>\n\n<p>The <code>.res()<\/code> method controls either width of the\nbandpass, or resonance of the low\/highpass cutoff frequency.<\/p>\n<p>This class extends <a href = \"\/reference\/#\/p5.Effect\">p5.Effect<\/a>.\nMethods <a href = \"\/reference\/#\/p5.Effect\/amp\">amp()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/chain\">chain()<\/a>,\n<a href = \"\/reference\/#\/p5.Effect\/drywet\">drywet()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/connect\">connect()<\/a>, and\n<a href = \"\/reference\/#\/p5.Effect\/disconnect\">disconnect()<\/a> are available.<\/p>\n","extends":"p5.Effect","is_constructor":1,"params":[{"name":"type","description":"<p>'lowpass' (default), 'highpass', 'bandpass'<\/p>\n","type":"String","optional":true}],"example":["\n<div><code>\nlet fft, noise, filter;\n\nfunction setup() {\n  let cnv = createCanvas(100,100);\n  cnv.mousePressed(makeNoise);\n  fill(255, 0, 255);\n\n  filter = new p5.BandPass();\n  noise = new p5.Noise();\n  noise.disconnect();\n  noise.connect(filter);\n\n  fft = new p5.FFT();\n}\n\nfunction draw() {\n  background(220);\n\n  \/\/ set the BandPass frequency based on mouseX\n  let freq = map(mouseX, 0, width, 20, 10000);\n  freq = constrain(freq, 0, 22050);\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  let spectrum = fft.analyze();\n  noStroke();\n  for (let i = 0; i < spectrum.length; i++) {\n    let x = map(i, 0, spectrum.length, 0, width);\n    let h = -height + map(spectrum[i], 0, 255, height, 0);\n    rect(x, height, width\/spectrum.length, h);\n  }\n  if (!noise.started) {\n    text('tap here and drag to change frequency', 10, 20, width - 20);\n  } else {\n    text('Frequency: ' + round(freq)+'Hz', 20, 20, width - 20);\n  }\n}\n\nfunction makeNoise() {\n  \/\/ see also: `userStartAudio()`\n  noise.start();\n  noise.amp(0.5, 0.2);\n}\n\nfunction mouseReleased() {\n  noise.amp(0, 0.2);\n}\n\n<\/code><\/div>"]},"p5.LowPass":{"name":"p5.LowPass","shortname":"p5.LowPass","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":6914,"description":"<p>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.<\/p>\n","is_constructor":1,"extends":"p5.Filter"},"p5.HighPass":{"name":"p5.HighPass","shortname":"p5.HighPass","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":6938,"description":"<p>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.<\/p>\n","is_constructor":1,"extends":"p5.Filter"},"p5.BandPass":{"name":"p5.BandPass","shortname":"p5.BandPass","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":6962,"description":"<p>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.<\/p>\n","is_constructor":1,"extends":"p5.Filter"},"p5.EQ":{"name":"p5.EQ","shortname":"p5.EQ","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":7105,"description":"<p>p5.EQ is an audio effect that performs the function of a multiband\naudio equalizer. Equalization is used to adjust the balance of\nfrequency compoenents of an audio signal. This process is commonly used\nin sound production and recording to change the waveform before it reaches\na sound output device. EQ can also be used as an audio effect to create\ninteresting distortions by filtering out parts of the spectrum. p5.EQ is\nbuilt using a chain of Web Audio Biquad Filter Nodes and can be\ninstantiated with 3 or 8 bands. Bands can be added or removed from\nthe EQ by directly modifying p5.EQ.bands (the array that stores filters).<\/p>\n<p>This class extends <a href = \"\/reference\/#\/p5.Effect\">p5.Effect<\/a>.\nMethods <a href = \"\/reference\/#\/p5.Effect\/amp\">amp()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/chain\">chain()<\/a>,\n<a href = \"\/reference\/#\/p5.Effect\/drywet\">drywet()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/connect\">connect()<\/a>, and\n<a href = \"\/reference\/#\/p5.Effect\/disconnect\">disconnect()<\/a> are available.<\/p>\n","is_constructor":1,"extends":"p5.Effect","params":[{"name":"_eqsize","description":"<p>Constructor will accept 3 or 8, defaults to 3<\/p>\n","type":"Number","optional":true}],"return":{"description":"p5.EQ object","type":"Object"},"example":["\n<div><code>\nlet eq, soundFile\nlet eqBandIndex = 0;\nlet eqBandNames = ['lows', 'mids', 'highs'];\n\nfunction preload() {\n  soundFormats('mp3', 'ogg');\n  soundFile = loadSound('assets\/beat');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(toggleSound);\n\n  eq = new p5.EQ(eqBandNames.length);\n  soundFile.disconnect();\n  eq.process(soundFile);\n}\n\nfunction draw() {\n  background(30);\n  noStroke();\n  fill(255);\n  textAlign(CENTER);\n  text('filtering ', 50, 25);\n\n  fill(255, 40, 255);\n  textSize(26);\n  text(eqBandNames[eqBandIndex], 50, 55);\n\n  fill(255);\n  textSize(9);\n\n  if (!soundFile.isPlaying()) {\n    text('tap to play', 50, 80);\n  } else {\n    text('tap to filter next band', 50, 80)\n  }\n}\n\nfunction toggleSound() {\n  if (!soundFile.isPlaying()) {\n    soundFile.play();\n  } else {\n    eqBandIndex = (eqBandIndex + 1) % eq.bands.length;\n  }\n\n  for (let i = 0; i < eq.bands.length; i++) {\n    eq.bands[i].gain(0);\n  }\n  \/\/ filter the band we want to filter\n  eq.bands[eqBandIndex].gain(-40);\n}\n<\/code><\/div>"]},"p5.Panner3D":{"name":"p5.Panner3D","shortname":"p5.Panner3D","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":7602,"description":"<p>Panner3D is based on the <a title=\"Web Audio Panner docs\"  href=\n\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/PannerNode\">\nWeb Audio Spatial Panner Node<\/a>.\nThis panner is a spatial processing node that allows audio to be positioned\nand oriented in 3D space.<\/p>\n<p>The position is relative to an <a title=\"Web Audio Listener docs\" href=\n\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/AudioListener\">\nAudio Context Listener<\/a>, which can be accessed\nby <code>p5.soundOut.audiocontext.listener<\/code><\/p>\n","is_constructor":1},"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":7926,"description":"<p>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 (the\ndefault value) will produce a looping delay that decreases in\nvolume by 50% each repeat. A filter will cut out the high\nfrequencies so that the delay does not sound as piercing as the\noriginal source.<\/p>\n<p>This class extends <a href = \"\/reference\/#\/p5.Effect\">p5.Effect<\/a>.\nMethods <a href = \"\/reference\/#\/p5.Effect\/amp\">amp()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/chain\">chain()<\/a>,\n<a href = \"\/reference\/#\/p5.Effect\/drywet\">drywet()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/connect\">connect()<\/a>, and\n<a href = \"\/reference\/#\/p5.Effect\/disconnect\">disconnect()<\/a> are available.<\/p>\n","extends":"p5.Effect","is_constructor":1,"example":["\n<div><code>\nlet osc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  background(220);\n  textAlign(CENTER);\n  text('tap to play', width\/2, height\/2);\n\n  osc = new p5.Oscillator('square');\n  osc.amp(0.5);\n  delay = new p5.Delay();\n\n  \/\/ delay.process() accepts 4 parameters:\n  \/\/ source, delayTime (in seconds), feedback, filter frequency\n  delay.process(osc, 0.12, .7, 2300);\n\n  cnv.mousePressed(oscStart);\n}\n\nfunction oscStart() {\n  osc.start();\n}\n\nfunction mouseReleased() {\n  osc.stop();\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":8308,"description":"<p>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 parameters 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.<\/p>\n<p>This class extends <a href = \"\/reference\/#\/p5.Effect\">p5.Effect<\/a>.\nMethods <a href = \"\/reference\/#\/p5.Effect\/amp\">amp()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/chain\">chain()<\/a>,\n<a href = \"\/reference\/#\/p5.Effect\/drywet\">drywet()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/connect\">connect()<\/a>, and\n<a href = \"\/reference\/#\/p5.Effect\/disconnect\">disconnect()<\/a> are available.<\/p>\n","extends":"p5.Effect","is_constructor":1,"example":["\n<div><code>\nlet soundFile, reverb;\nfunction preload() {\n  soundFile = loadSound('assets\/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSound);\n\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}\n\nfunction draw() {\n  let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\n  \/\/ 1 = all reverb, 0 = no reverb\n  reverb.drywet(dryWet);\n\n  background(220);\n  text('tap to play', 10, 20);\n  text('dry\/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\n}\n\nfunction playSound() {\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":8549,"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>","extends":"p5.Effect","is_constructor":1,"params":[{"name":"path","description":"<p>path to a sound file<\/p>\n","type":"String"},{"name":"callback","description":"<p>function to call when loading succeeds<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to call if loading fails.\n                                   This function will receive an error or\n                                   XMLHttpRequest object with information\n                                   about what went wrong.<\/p>\n","type":"Function","optional":true}],"example":["\n<div><code>\nlet 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  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSound);\n  background(220);\n  text('tap to play', 20, 20);\n\n  \/\/ disconnect from main output...\n  sound.disconnect();\n\n  \/\/ ...and process with cVerb\n  \/\/ so that we only hear the convolution\n  cVerb.process(sound);\n}\n\nfunction playSound() {\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":9103,"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\u2014for 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":"<p>Name so that you can access the Phrase.<\/p>\n","type":"String"},{"name":"callback","description":"<p>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.<\/p>\n","type":"Function"},{"name":"sequence","description":"<p>Array of values to pass into the callback\n                          at each step of the phrase.<\/p>\n","type":"Array"}],"example":["\n<div><code>\nlet mySound, myPhrase, myPart;\nlet pattern = [1,0,0,2,0,2,0,0];\n\nfunction preload() {\n  mySound = loadSound('assets\/beatbox.mp3');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playMyPart);\n  background(220);\n  text('tap to play', width\/2, height\/2);\n  textAlign(CENTER, CENTER);\n\n  myPhrase = new p5.Phrase('bbox', onEachStep, pattern);\n  myPart = new p5.Part();\n  myPart.addPhrase(myPhrase);\n  myPart.setBPM(60);\n}\n\nfunction onEachStep(time, playbackRate) {\n  mySound.rate(playbackRate);\n  mySound.play(time);\n}\n\nfunction playMyPart() {\n  userStartAudio();\n  myPart.start();\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":9185,"description":"<p>A p5.Part plays back one or more p5.Phrases. Instantiate a part\nwith steps and tatums. By default, each step represents a 1\/16th note.<\/p>\n\n<p>See p5.Phrase for more about musical timing.<\/p>","is_constructor":1,"params":[{"name":"steps","description":"<p>Steps in the part<\/p>\n","type":"Number","optional":true},{"name":"tatums","description":"<p>Divisions of a beat, e.g. use 1\/4, or 0.25 for a quater note (default is 1\/16, a sixteenth note)<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet box, drum, myPart;\nlet boxPat = [1,0,0,2,0,2,0,0];\nlet drumPat = [0,1,1,0,2,0,1,0];\n\nfunction preload() {\n  box = loadSound('assets\/beatbox.mp3');\n  drum = loadSound('assets\/drum.mp3');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playMyPart);\n  background(220);\n  textAlign(CENTER, CENTER);\n  text('tap to play', width\/2, height\/2);\n\n  let boxPhrase = new p5.Phrase('box', playBox, boxPat);\n  let 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}\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 playMyPart() {\n  userStartAudio();\n\n  myPart.start();\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":9493,"description":"<p>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><\/p>\n","is_constructor":1,"params":[{"name":"parts","description":"<p>One or multiple parts, to be played in sequence.<\/p>\n","type":"p5.Part","optional":true,"multiple":true}]},"p5.SoundLoop":{"name":"p5.SoundLoop","shortname":"p5.SoundLoop","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":9673,"description":"<p>SoundLoop<\/p>\n","is_constructor":1,"params":[{"name":"callback","description":"<p>this function will be called on each iteration of theloop<\/p>\n","type":"Function"},{"name":"interval","description":"<p>amount of time (if a number) or beats (if a string, following <a href = \"https:\/\/github.com\/Tonejs\/Tone.js\/wiki\/Time\">Tone.Time<\/a> convention) for each iteration of the loop. Defaults to 1 second.<\/p>\n","type":"Number|String","optional":true}],"example":["\n<div><code>\n let synth, soundLoop;\n let notePattern = [60, 62, 64, 67, 69, 72];\n\n function setup() {\n   let cnv = createCanvas(100, 100);\n   cnv.mousePressed(canvasPressed);\n   colorMode(HSB);\n   background(0, 0, 86);\n   text('tap to start\/stop', 10, 20);\n\n   \/\/the looper's callback is passed the timeFromNow\n   \/\/this value should be used as a reference point from\n   \/\/which to schedule sounds\n   let intervalInSeconds = 0.2;\n   soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);\n\n   synth = new p5.MonoSynth();\n}\n\nfunction canvasPressed() {\n  \/\/ ensure audio is enabled\n  userStartAudio();\n\n  if (soundLoop.isPlaying) {\n    soundLoop.stop();\n  } else {\n    \/\/ start the loop\n    soundLoop.start();\n  }\n}\n\nfunction onSoundLoop(timeFromNow) {\n  let noteIndex = (soundLoop.iterations - 1) % notePattern.length;\n  let note = midiToFreq(notePattern[noteIndex]);\n  synth.play(note, 0.5, timeFromNow);\n  background(noteIndex * 360 \/ notePattern.length, 50, 100);\n}\n<\/code><\/div>"]},"p5.Compressor":{"name":"p5.Compressor","shortname":"p5.Compressor","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":10036,"description":"<p>Compressor is an audio effect class that performs dynamics compression\non an audio input source. This is a very commonly used technique in music\nand sound production. Compression creates an overall louder, richer,\nand fuller sound by lowering the volume of louds and raising that of softs.\nCompression can be used to avoid clipping (sound distortion due to\npeaks in volume) and is especially useful when many sounds are played\nat once. Compression can be used on indivudal sound sources in addition\nto the main output.<\/p>\n<p>This class extends <a href = \"\/reference\/#\/p5.Effect\">p5.Effect<\/a>.\nMethods <a href = \"\/reference\/#\/p5.Effect\/amp\">amp()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/chain\">chain()<\/a>,\n<a href = \"\/reference\/#\/p5.Effect\/drywet\">drywet()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/connect\">connect()<\/a>, and\n<a href = \"\/reference\/#\/p5.Effect\/disconnect\">disconnect()<\/a> are available.<\/p>\n","is_constructor":1,"extends":"p5.Effect"},"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":10312,"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":"<p>lowFrequency - defaults to 20Hz<\/p>\n","type":"Number","optional":true},{"name":"freq2","description":"<p>highFrequency - defaults to 20000 Hz<\/p>\n","type":"Number","optional":true},{"name":"threshold","description":"<p>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.<\/p>\n","type":"Number","optional":true},{"name":"framesPerPeak","description":"<p>Defaults to 20.<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\n\nvar cnv, soundFile, fft, peakDetect;\nvar ellipseWidth = 10;\n\nfunction preload() {\n  soundFile = loadSound('assets\/beat.mp3');\n}\n\nfunction setup() {\n  background(0);\n  noStroke();\n  fill(255);\n  textAlign(CENTER);\n\n  \/\/ p5.PeakDetect requires a p5.FFT\n  fft = new p5.FFT();\n  peakDetect = new p5.PeakDetect();\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.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":10559,"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>\nlet mic, recorder, soundFile;\nlet state = 0;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n  background(220);\n  textAlign(CENTER, CENTER);\n\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('tap to record', width\/2, height\/2);\n}\n\nfunction canvasPressed() {\n  \/\/ ensure audio is enabled\n  userStartAudio();\n\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!', width\/2, height\/2);\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('Done! Tap to play and download', width\/2, height\/2, width - 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.Distortion":{"name":"p5.Distortion","shortname":"p5.Distortion","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":10816,"description":"<p>A Distortion effect created with a Waveshaper Node,\nwith an approach adapted from\n<a href=\"http:\/\/stackoverflow.com\/questions\/22312841\/waveshaper-node-in-webaudio-how-to-emulate-distortion\">Kevin Ennis<\/a><\/p>\n<p>This class extends <a href = \"\/reference\/#\/p5.Effect\">p5.Effect<\/a>.\nMethods <a href = \"\/reference\/#\/p5.Effect\/amp\">amp()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/chain\">chain()<\/a>,\n<a href = \"\/reference\/#\/p5.Effect\/drywet\">drywet()<\/a>, <a href = \"\/reference\/#\/p5.Effect\/connect\">connect()<\/a>, and\n<a href = \"\/reference\/#\/p5.Effect\/disconnect\">disconnect()<\/a> are available.<\/p>\n","extends":"p5.Effect","is_constructor":1,"params":[{"name":"amount","description":"<p>Unbounded distortion amount.\n                               Normal values range from 0-1.<\/p>\n","type":"Number","optional":true,"optdefault":"0.25"},{"name":"oversample","description":"<p>'none', '2x', or '4x'.<\/p>\n","type":"String","optional":true,"optdefault":"'none'"}]},"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":10973,"description":"<p>A gain node is usefull to set the relative volume of sound.\nIt's typically used to build mixers.<\/p>\n","is_constructor":1,"example":["\n<div><code>\n\n\/\/ load two soundfile and crossfade between them\nlet sound1,sound2;\nlet sound1Gain, sound2Gain, mixGain;\nfunction preload(){\n  soundFormats('ogg', 'mp3');\n  sound1 = loadSound('assets\/Damscray_-_Dancing_Tiger_01');\n  sound2 = loadSound('assets\/beat');\n}\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(startSound);\n  \/\/ create a 'mix' gain bus to which we will connect both soundfiles\n  mixGain = new p5.Gain();\n  mixGain.connect();\n  sound1.disconnect(); \/\/ diconnect from p5 output\n  sound1Gain = new p5.Gain(); \/\/ setup a gain node\n  sound1Gain.setInput(sound1); \/\/ connect the first sound to its input\n  sound1Gain.connect(mixGain); \/\/ connect its output to the final mix bus\n  sound2.disconnect();\n  sound2Gain = new p5.Gain();\n  sound2Gain.setInput(sound2);\n  sound2Gain.connect(mixGain);\n}\nfunction startSound() {\n  sound1.loop();\n  sound2.loop();\n  loop();\n}\nfunction mouseReleased() {\n  sound1.stop();\n  sound2.stop();\n}\nfunction draw(){\n  background(220);\n  textAlign(CENTER);\n  textSize(11);\n  fill(0);\n  if (!sound1.isPlaying()) {\n    text('tap and drag to play', width\/2, height\/2);\n    return;\n  }\n  \/\/ map the horizontal position of the mouse to values useable for volume    *  control of sound1\n  var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\n  var sound2Volume = 1-sound1Volume;\n  sound1Gain.amp(sound1Volume);\n  sound2Gain.amp(sound2Volume);\n  \/\/ map the vertical position of the mouse to values useable for 'output    *  volume control'\n  var outputVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\n  mixGain.amp(outputVolume);\n  text('output', width\/2, height - outputVolume * height * 0.9)\n  fill(255, 0, 255);\n  textAlign(LEFT);\n  text('sound1', 5, height - sound1Volume * height * 0.9);\n  textAlign(RIGHT);\n  text('sound2', width - 5, height - sound2Volume * height * 0.9);\n}\n<\/code><\/div>"]},"p5.AudioVoice":{"name":"p5.AudioVoice","shortname":"p5.AudioVoice","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":11149,"description":"<p>Base class for monophonic synthesizers. Any extensions of this class\nshould follow the API and implement the methods below in order to\nremain compatible with p5.PolySynth();<\/p>\n","is_constructor":1},"p5.MonoSynth":{"name":"p5.MonoSynth","shortname":"p5.MonoSynth","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":11247,"description":"<p>A MonoSynth is used as a single voice for sound synthesis.\nThis is a class to be used in conjunction with the PolySynth\nclass. Custom synthetisers should be built inheriting from\nthis class.<\/p>\n","is_constructor":1,"example":["\n<div><code>\nlet monoSynth;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSynth);\n  background(220);\n  textAlign(CENTER);\n  text('tap to play', width\/2, height\/2);\n\n  monoSynth = new p5.MonoSynth();\n}\n\nfunction playSynth() {\n  userStartAudio();\n\n  let note = random(['Fb4', 'G4']);\n  \/\/ note velocity (volume, from 0 to 1)\n  let velocity = random();\n  \/\/ time from now (in seconds)\n  let time = 0;\n  \/\/ note duration (in seconds)\n  let dur = 1\/6;\n\n  monoSynth.play(note, velocity, time, dur);\n}\n<\/code><\/div>"]},"p5.OnsetDetect":{"name":"p5.OnsetDetect","shortname":"p5.OnsetDetect","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":11624,"description":"<p>Listen for onsets (a sharp increase in volume) within a given\nfrequency range.<\/p>\n","is_constructor":1,"params":[{"name":"freqLow","description":"<p>Low frequency<\/p>\n","type":"Number"},{"name":"freqHigh","description":"<p>High frequency<\/p>\n","type":"Number"},{"name":"threshold","description":"<p>Amplitude threshold between 0 (no energy) and 1 (maximum)<\/p>\n","type":"Number"},{"name":"callback","description":"<p>Function to call when an onset is detected<\/p>\n","type":"Function"}]},"p5.PolySynth":{"name":"p5.PolySynth","shortname":"p5.PolySynth","classitems":[],"plugins":[],"extensions":[],"plugin_for":[],"extension_for":[],"module":"p5.sound","submodule":"p5.sound","namespace":"","file":"lib\/addons\/p5.sound.js","line":11691,"description":"<p>An AudioVoice is used as a single voice for sound synthesis.\nThe PolySynth class holds an array of AudioVoice, and deals\nwith voices allocations, with setting notes to be played, and\nparameters to be set.<\/p>\n","is_constructor":1,"params":[{"name":"synthVoice","description":"<p>A monophonic synth voice inheriting\n                               the AudioVoice class. Defaults to p5.MonoSynth<\/p>\n","type":"Number","optional":true},{"name":"maxVoices","description":"<p>Number of voices, defaults to 8;<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet polySynth;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSynth);\n  background(220);\n  text('click to play', 20, 20);\n\n  polySynth = new p5.PolySynth();\n}\n\nfunction playSynth() {\n  userStartAudio();\n\n  \/\/ note duration (in seconds)\n  let dur = 1.5;\n\n  \/\/ time from now (in seconds)\n  let time = 0;\n\n  \/\/ velocity (volume, from 0 to 1)\n  let vel = 0.1;\n\n  \/\/ notes can overlap with each other\n  polySynth.play('G2', vel, 0, dur);\n  polySynth.play('C3', vel, time += 1\/3, dur);\n  polySynth.play('G3', vel, time += 1\/3, dur);\n}\n<\/code><\/div>"]}},"elements":{},"classitems":[{"file":"src\/accessibility\/describe.js","line":18,"description":"<p>Creates a screen reader-accessible description of the canvas.<\/p>\n<p>The first parameter, <code>text<\/code>, is the description of the canvas.<\/p>\n<p>The second parameter, <code>display<\/code>, is optional. It determines how the\ndescription is displayed. If <code>LABEL<\/code> is passed, as in\n<code>describe('A description.', LABEL)<\/code>, the description will be visible in\na div element next to the canvas. If <code>FALLBACK<\/code> is passed, as in\n<code>describe('A description.', FALLBACK)<\/code>, the description will only be\nvisible to screen readers. This is the default mode.<\/p>\n<p>Read\n<a href=\"https:\/\/p5js.org\/tutorials\/writing-accessible-canvas-descriptions\/\">Writing accessible canvas descriptions<\/a>\nto learn more about making sketches accessible.<\/p>\n","itemtype":"method","name":"describe","params":[{"name":"text","description":"<p>description of the canvas.<\/p>\n","type":"String"},{"name":"display","description":"<p>either LABEL or FALLBACK.<\/p>\n","type":"Constant","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  background('pink');\n\n  \/\/ Draw a heart.\n  fill('red');\n  noStroke();\n  circle(67, 67, 20);\n  circle(83, 67, 20);\n  triangle(91, 73, 75, 95, 59, 73);\n\n  \/\/ Add a general description of the canvas.\n  describe('A pink square with a red heart in the bottom-right corner.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background('pink');\n\n  \/\/ Draw a heart.\n  fill('red');\n  noStroke();\n  circle(67, 67, 20);\n  circle(83, 67, 20);\n  triangle(91, 73, 75, 95, 59, 73);\n\n  \/\/ Add a general description of the canvas\n  \/\/ and display it for debugging.\n  describe('A pink square with a red heart in the bottom-right corner.', LABEL);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction draw() {\n  background(200);\n\n  \/\/ The expression\n  \/\/ frameCount % 100\n  \/\/ causes x to increase from 0\n  \/\/ to 99, then restart from 0.\n  let x = frameCount % 100;\n\n  \/\/ Draw the circle.\n  fill(0, 255, 0);\n  circle(x, 50, 40);\n\n  \/\/ Add a general description of the canvas.\n  describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction draw() {\n  background(200);\n\n  \/\/ The expression\n  \/\/ frameCount % 100\n  \/\/ causes x to increase from 0\n  \/\/ to 99, then restart from 0.\n  let x = frameCount % 100;\n\n  \/\/ Draw the circle.\n  fill(0, 255, 0);\n  circle(x, 50, 40);\n\n  \/\/ Add a general description of the canvas\n  \/\/ and display it for debugging.\n  describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`, LABEL);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/accessibility\/describe.js","line":162,"description":"<p>Creates a screen reader-accessible description of elements in the canvas.<\/p>\n<p>Elements are shapes or groups of shapes that create meaning together. For\nexample, a few overlapping circles could make an \"eye\" element.<\/p>\n<p>The first parameter, <code>name<\/code>, is the name of the element.<\/p>\n<p>The second parameter, <code>text<\/code>, is the description of the element.<\/p>\n<p>The third parameter, <code>display<\/code>, is optional. It determines how the\ndescription is displayed. If <code>LABEL<\/code> is passed, as in\n<code>describe('A description.', LABEL)<\/code>, the description will be visible in\na div element next to the canvas. Using <code>LABEL<\/code> creates unhelpful\nduplicates for screen readers. Only use <code>LABEL<\/code> during development. If\n<code>FALLBACK<\/code> is passed, as in <code>describe('A description.', FALLBACK)<\/code>, the\ndescription will only be visible to screen readers. This is the default\nmode.<\/p>\n<p>Read\n<a href=\"https:\/\/p5js.org\/tutorials\/writing-accessible-canvas-descriptions\/\">Writing accessible canvas descriptions<\/a>\nto learn more about making sketches accessible.<\/p>\n","itemtype":"method","name":"describeElement","params":[{"name":"name","description":"<p>name of the element.<\/p>\n","type":"String"},{"name":"text","description":"<p>description of the element.<\/p>\n","type":"String"},{"name":"display","description":"<p>either LABEL or FALLBACK.<\/p>\n","type":"Constant","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  background('pink');\n\n  \/\/ Describe the first element\n  \/\/ and draw it.\n  describeElement('Circle', 'A yellow circle in the top-left corner.');\n  noStroke();\n  fill('yellow');\n  circle(25, 25, 40);\n\n  \/\/ Describe the second element\n  \/\/ and draw it.\n  describeElement('Heart', 'A red heart in the bottom-right corner.');\n  fill('red');\n  circle(66.6, 66.6, 20);\n  circle(83.2, 66.6, 20);\n  triangle(91.2, 72.6, 75, 95, 58.6, 72.6);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red heart and yellow circle over a pink background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background('pink');\n\n  \/\/ Describe the first element\n  \/\/ and draw it. Display the\n  \/\/ description for debugging.\n  describeElement('Circle', 'A yellow circle in the top-left corner.', LABEL);\n  noStroke();\n  fill('yellow');\n  circle(25, 25, 40);\n\n  \/\/ Describe the second element\n  \/\/ and draw it. Display the\n  \/\/ description for debugging.\n  describeElement('Heart', 'A red heart in the bottom-right corner.', LABEL);\n  fill('red');\n  circle(66.6, 66.6, 20);\n  circle(83.2, 66.6, 20);\n  triangle(91.2, 72.6, 75, 95, 58.6, 72.6);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red heart and yellow circle over a pink background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/accessibility\/outputs.js","line":10,"description":"<p>Creates a screen reader-accessible description of shapes on the canvas.<\/p>\n<p><code>textOutput()<\/code> adds a general description, list of shapes, and\ntable of shapes to the web page. The general description includes the\ncanvas size, canvas color, and number of shapes. For example,\n<code>Your output is a, 100 by 100 pixels, gray canvas containing the following 2 shapes:<\/code>.<\/p>\n<p>A list of shapes follows the general description. The list describes the\ncolor, location, and area of each shape. For example,\n<code>a red circle at middle covering 3% of the canvas<\/code>. Each shape can be\nselected to get more details.<\/p>\n<p><code>textOutput()<\/code> uses its table of shapes as a list. The table describes the\nshape, color, location, coordinates and area. For example,\n<code>red circle location = middle area = 3%<\/code>. This is different from\n<a href=\"#\/p5\/gridOutput\">gridOutput()<\/a>, which uses its table as a grid.<\/p>\n<p>The <code>display<\/code> parameter is optional. It determines how the description is\ndisplayed. If <code>LABEL<\/code> is passed, as in <code>textOutput(LABEL)<\/code>, the description\nwill be visible in a div element next to the canvas. Using <code>LABEL<\/code> creates\nunhelpful duplicates for screen readers. Only use <code>LABEL<\/code> during\ndevelopment. If <code>FALLBACK<\/code> is passed, as in <code>textOutput(FALLBACK)<\/code>, the\ndescription will only be visible to screen readers. This is the default\nmode.<\/p>\n<p>Read\n<a href=\"https:\/\/p5js.org\/tutorials\/writing-accessible-canvas-descriptions\/\">Writing accessible canvas descriptions<\/a>\nto learn more about making sketches accessible.<\/p>\n<p><code>textOutput()<\/code> generates descriptions in English only. Text drawn with\n<a href=\"#\/p5\/text\">text()<\/a> is not described. Shapes created with\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> are not described. WEBGL mode\nand 3D shapes are not supported.<\/p>\n<p>Use <a href=\"#\/p5\/describe\">describe()<\/a> and\n<a href=\"#\/p5\/describeElement\">describeElement()<\/a> for more control\nover canvas descriptions.<\/p>\n","itemtype":"method","name":"textOutput","params":[{"name":"display","description":"<p>either FALLBACK or LABEL.<\/p>\n","type":"Constant","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Add the text description.\n  textOutput();\n\n  \/\/ Draw a couple of shapes.\n  background(200);\n  fill(255, 0, 0);\n  circle(20, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle and a blue square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Add the text description and\n  \/\/ display it for debugging.\n  textOutput(LABEL);\n\n  \/\/ Draw a couple of shapes.\n  background(200);\n  fill(255, 0, 0);\n  circle(20, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle and a blue square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n}\n\nfunction draw() {\n  \/\/ Add the text description.\n  textOutput();\n\n  \/\/ Draw a moving circle.\n  background(200);\n  let x = frameCount * 0.1;\n  fill(255, 0, 0);\n  circle(x, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle moves from left to right above a blue square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n}\n\nfunction draw() {\n  \/\/ Add the text description and\n  \/\/ display it for debugging.\n  textOutput(LABEL);\n\n  \/\/ Draw a moving circle.\n  background(200);\n  let x = frameCount * 0.1;\n  fill(255, 0, 0);\n  circle(x, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle moves from left to right above a blue square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/accessibility\/outputs.js","line":161,"description":"<p>Creates a screen reader-accessible description of shapes on the canvas.<\/p>\n<p><code>gridOutput()<\/code> adds a general description, table of shapes, and list of\nshapes to the web page. The general description includes the canvas size,\ncanvas color, and number of shapes. For example,\n<code>gray canvas, 100 by 100 pixels, contains 2 shapes:  1 circle 1 square<\/code>.<\/p>\n<p><code>gridOutput()<\/code> uses its table of shapes as a grid. Each shape in the grid\nis placed in a cell whose row and column correspond to the shape's location\non the canvas. The grid cells describe the color and type of shape at that\nlocation. For example, <code>red circle<\/code>. These descriptions can be selected\nindividually to get more details. This is different from\n<a href=\"#\/p5\/textOutput\">textOutput()<\/a>, which uses its table as a list.<\/p>\n<p>A list of shapes follows the table. The list describes the color, type,\nlocation, and area of each shape. For example,\n<code>red circle, location = middle, area = 3 %<\/code>.<\/p>\n<p>The <code>display<\/code> parameter is optional. It determines how the description is\ndisplayed. If <code>LABEL<\/code> is passed, as in <code>gridOutput(LABEL)<\/code>, the description\nwill be visible in a div element next to the canvas. Using <code>LABEL<\/code> creates\nunhelpful duplicates for screen readers. Only use <code>LABEL<\/code> during\ndevelopment. If <code>FALLBACK<\/code> is passed, as in <code>gridOutput(FALLBACK)<\/code>, the\ndescription will only be visible to screen readers. This is the default\nmode.<\/p>\n<p>Read\n<a href=\"https:\/\/p5js.org\/tutorials\/writing-accessible-canvas-descriptions\/\">Writing accessible canvas descriptions<\/a>\nto learn more about making sketches accessible.<\/p>\n<p><code>gridOutput()<\/code> generates descriptions in English only. Text drawn with\n<a href=\"#\/p5\/text\">text()<\/a> is not described. Shapes created with\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> are not described. WEBGL mode\nand 3D shapes are not supported.<\/p>\n<p>Use <a href=\"#\/p5\/describe\">describe()<\/a> and\n<a href=\"#\/p5\/describeElement\">describeElement()<\/a> for more control\nover canvas descriptions.<\/p>\n","itemtype":"method","name":"gridOutput","params":[{"name":"display","description":"<p>either FALLBACK or LABEL.<\/p>\n","type":"Constant","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Add the grid description.\n  gridOutput();\n\n  \/\/ Draw a couple of shapes.\n  background(200);\n  fill(255, 0, 0);\n  circle(20, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle and a blue square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Add the grid description and\n  \/\/ display it for debugging.\n  gridOutput(LABEL);\n\n  \/\/ Draw a couple of shapes.\n  background(200);\n  fill(255, 0, 0);\n  circle(20, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle and a blue square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n}\n\nfunction draw() {\n  \/\/ Add the grid description.\n  gridOutput();\n\n  \/\/ Draw a moving circle.\n  background(200);\n  let x = frameCount * 0.1;\n  fill(255, 0, 0);\n  circle(x, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle moves from left to right above a blue square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n}\n\nfunction draw() {\n  \/\/ Add the grid description and\n  \/\/ display it for debugging.\n  gridOutput(LABEL);\n\n  \/\/ Draw a moving circle.\n  background(200);\n  let x = frameCount * 0.1;\n  fill(255, 0, 0);\n  circle(x, 20, 20);\n  fill(0, 0, 255);\n  square(50, 50, 50);\n\n  \/\/ Add a general description of the canvas.\n  describe('A red circle moves from left to right above a blue square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/color\/color_conversion.js","line":8,"description":"<p>Conversions adapted from <a href=\"http:\/\/www.easyrgb.com\/en\/math.php\">http:\/\/www.easyrgb.com\/en\/math.php<\/a>.<\/p>\n<p>In these functions, hue is always in the range [0, 1], just like all other\ncomponents are in the range [0, 1]. 'Brightness' and 'value' are used\ninterchangeably.<\/p>\n","class":"p5","module":"Color","submodule":"Color Conversion"},{"file":"src\/color\/color_conversion.js","line":18,"description":"<p>Convert an HSBA array to HSLA.<\/p>\n","class":"p5","module":"Color","submodule":"Color Conversion"},{"file":"src\/color\/color_conversion.js","line":44,"description":"<p>Convert an HSBA array to RGBA.<\/p>\n","class":"p5","module":"Color","submodule":"Color Conversion"},{"file":"src\/color\/color_conversion.js","line":99,"description":"<p>Convert an HSLA array to HSBA.<\/p>\n","class":"p5","module":"Color","submodule":"Color Conversion"},{"file":"src\/color\/color_conversion.js","line":122,"description":"<p>Convert an HSLA array to RGBA.<\/p>\n<p>We need to change basis from HSLA to something that can be more easily be\nprojected onto RGBA. We will choose hue and brightness as our first two\ncomponents, and pick a convenient third one ('zest') so that we don't need\nto calculate formal HSBA saturation.<\/p>\n","class":"p5","module":"Color","submodule":"Color Conversion"},{"file":"src\/color\/color_conversion.js","line":186,"description":"<p>Convert an RGBA array to HSBA.<\/p>\n","class":"p5","module":"Color","submodule":"Color Conversion"},{"file":"src\/color\/color_conversion.js","line":225,"description":"<p>Convert an RGBA array to HSLA.<\/p>\n","class":"p5","module":"Color","submodule":"Color Conversion"},{"file":"src\/color\/creating_reading.js","line":16,"description":"<p>Gets the alpha (transparency) value of a color.<\/p>\n<p><code>alpha()<\/code> extracts the alpha value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n","itemtype":"method","name":"alpha","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the alpha value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color(0, 126, 255, 102);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'alphaValue' to 102.\n  let alphaValue = alpha(c);\n\n  \/\/ Draw the right rectangle.\n  fill(alphaValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light blue and the right one is charcoal gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a color array.\n  let c = [0, 126, 255, 102];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'alphaValue' to 102.\n  let alphaValue = alpha(c);\n\n  \/\/ Draw the left rectangle.\n  fill(alphaValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light blue and the right one is charcoal gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgba(0, 126, 255, 0.4)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'alphaValue' to 102.\n  let alphaValue = alpha(c);\n\n  \/\/ Draw the right rectangle.\n  fill(alphaValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light blue and the right one is charcoal gray.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":117,"description":"<p>Gets the blue value of a color.<\/p>\n<p><code>blue()<\/code> extracts the blue value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n<p>By default, <code>blue()<\/code> returns a color's blue value in the range 0\nto 255. If the <a href=\"#\/p5\/colorMode\">colorMode()<\/a> is set to RGB, it\nreturns the blue value in the given range.<\/p>\n","itemtype":"method","name":"blue","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the blue value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using RGB values.\n  let c = color(175, 100, 220);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'blueValue' to 220.\n  let blueValue = blue(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, 0, blueValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is royal blue.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a color array.\n  let c = [175, 100, 220];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'blueValue' to 220.\n  let blueValue = blue(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, 0, blueValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is royal blue.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgb(175, 100, 220)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'blueValue' to 220.\n  let blueValue = blue(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, 0, blueValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is royal blue.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use RGB color with values in the range 0-100.\n  colorMode(RGB, 100);\n\n  \/\/ Create a p5.Color object using RGB values.\n  let c = color(69, 39, 86);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'blueValue' to 86.\n  let blueValue = blue(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, 0, blueValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is royal blue.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":253,"description":"<p>Gets the brightness value of a color.<\/p>\n<p><code>brightness()<\/code> extracts the HSB brightness value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n<p>By default, <code>brightness()<\/code> returns a color's HSB brightness in the range 0\nto 100. If the <a href=\"#\/p5\/colorMode\">colorMode()<\/a> is set to HSB, it\nreturns the brightness value in the given range.<\/p>\n","itemtype":"method","name":"brightness","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the brightness value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ Create a p5.Color object.\n  let c = color(0, 50, 100);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'brightValue' to 100.\n  let brightValue = brightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(brightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is white.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ Create a color array.\n  let c = [0, 50, 100];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'brightValue' to 100.\n  let brightValue = brightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(brightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is white.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgb(255, 128, 128)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'brightValue' to 100.\n  let brightValue = brightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(brightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is white.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSB color with values in the range 0-255.\n  colorMode(HSB, 255);\n\n  \/\/ Create a p5.Color object.\n  let c = color(0, 127, 255);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'brightValue' to 255.\n  let brightValue = brightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(brightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is white.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":398,"description":"<p>Creates a <a href=\"#\/p5\/p5.Color\">p5.Color<\/a> object.<\/p>\n<p>By default, the parameters are interpreted as RGB values. Calling\n<code>color(255, 204, 0)<\/code> will return a bright yellow color. The way these\nparameters are interpreted may be changed with the\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a> function.<\/p>\n<p>The version of <code>color()<\/code> with one parameter interprets the value one of two\nways. If the parameter is a number, it's interpreted as a grayscale value.\nIf the parameter is a string, it's interpreted as a CSS color string.<\/p>\n<p>The version of <code>color()<\/code> with two parameters interprets the first one as a\ngrayscale value. The second parameter sets the alpha (transparency) value.<\/p>\n<p>The version of <code>color()<\/code> with three parameters interprets them as RGB, HSB,\nor HSL colors, depending on the current <code>colorMode()<\/code>.<\/p>\n<p>The version of <code>color()<\/code> with four parameters interprets them as RGBA, HSBA,\nor HSLA colors, depending on the current <code>colorMode()<\/code>. The last parameter\nsets the alpha (transparency) value.<\/p>\n","itemtype":"method","name":"color","return":{"description":"resulting color.","type":"p5.Color"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using RGB values.\n  let c = color(255, 204, 0);\n\n  \/\/ Draw the square.\n  fill(c);\n  noStroke();\n  square(30, 20, 55);\n\n  describe('A yellow square on a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using RGB values.\n  let c1 = color(255, 204, 0);\n\n  \/\/ Draw the left circle.\n  fill(c1);\n  noStroke();\n  circle(25, 25, 80);\n\n  \/\/ Create a p5.Color object using a grayscale value.\n  let c2 = color(65);\n\n  \/\/ Draw the right circle.\n  fill(c2);\n  circle(75, 75, 80);\n\n  describe(\n    'Two circles on a gray canvas. The circle in the top-left corner is yellow and the one at the bottom-right is gray.'\n  );\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using a named color.\n  let c = color('magenta');\n\n  \/\/ Draw the square.\n  fill(c);\n  noStroke();\n  square(20, 20, 60);\n\n  describe('A magenta square on a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using a hex color code.\n  let c1 = color('#0f0');\n\n  \/\/ Draw the left rectangle.\n  fill(c1);\n  noStroke();\n  rect(0, 10, 45, 80);\n\n  \/\/ Create a p5.Color object using a hex color code.\n  let c2 = color('#00ff00');\n\n  \/\/ Draw the right rectangle.\n  fill(c2);\n  rect(55, 10, 45, 80);\n\n  describe('Two bright green rectangles on a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using a RGB color string.\n  let c1 = color('rgb(0, 0, 255)');\n\n  \/\/ Draw the top-left square.\n  fill(c1);\n  square(10, 10, 35);\n\n  \/\/ Create a p5.Color object using a RGB color string.\n  let c2 = color('rgb(0%, 0%, 100%)');\n\n  \/\/ Draw the top-right square.\n  fill(c2);\n  square(55, 10, 35);\n\n  \/\/ Create a p5.Color object using a RGBA color string.\n  let c3 = color('rgba(0, 0, 255, 1)');\n\n  \/\/ Draw the bottom-left square.\n  fill(c3);\n  square(10, 55, 35);\n\n  \/\/ Create a p5.Color object using a RGBA color string.\n  let c4 = color('rgba(0%, 0%, 100%, 1)');\n\n  \/\/ Draw the bottom-right square.\n  fill(c4);\n  square(55, 55, 35);\n\n  describe('Four blue squares in the corners of a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using a HSL color string.\n  let c1 = color('hsl(160, 100%, 50%)');\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c1);\n  rect(0, 10, 45, 80);\n\n  \/\/ Create a p5.Color object using a HSLA color string.\n  let c2 = color('hsla(160, 100%, 50%, 0.5)');\n\n  \/\/ Draw the right rectangle.\n  fill(c2);\n  rect(55, 10, 45, 80);\n\n  describe('Two sea green rectangles. A darker rectangle on the left and a brighter one on the right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using a HSB color string.\n  let c1 = color('hsb(160, 100%, 50%)');\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c1);\n  rect(0, 10, 45, 80);\n\n  \/\/ Create a p5.Color object using a HSBA color string.\n  let c2 = color('hsba(160, 100%, 50%, 0.5)');\n\n  \/\/ Draw the right rectangle.\n  fill(c2);\n  rect(55, 10, 45, 80);\n\n  describe('Two green rectangles. A darker rectangle on the left and a brighter one on the right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object using RGB values.\n  let c1 = color(50, 55, 100);\n\n  \/\/ Draw the left rectangle.\n  fill(c1);\n  rect(0, 10, 45, 80);\n\n  \/\/ Switch the color mode to HSB.\n  colorMode(HSB, 100);\n\n  \/\/ Create a p5.Color object using HSB values.\n  let c2 = color(50, 55, 100);\n\n  \/\/ Draw the right rectangle.\n  fill(c2);\n  rect(55, 10, 45, 80);\n\n  describe('Two blue rectangles. A darker rectangle on the left and a brighter one on the right.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading","overloads":[{"line":398,"params":[{"name":"gray","description":"<p>number specifying value between white and black.<\/p>\n","type":"Number"},{"name":"alpha","description":"<p>alpha value relative to current color range\n                                (default is 0-255).<\/p>\n","type":"Number","optional":true}],"return":{"description":"resulting color.","type":"p5.Color"}},{"line":652,"params":[{"name":"v1","description":"<p>red or hue value relative to\n                                the current color range.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value\n                                relative to the current color range.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue or brightness value\n                                relative to the current color range.<\/p>\n","type":"Number"},{"name":"alpha","description":"","type":"Number","optional":true}],"return":{"description":"","type":"p5.Color"}},{"line":664,"params":[{"name":"value","description":"<p>a color string.<\/p>\n","type":"String"}],"return":{"description":"","type":"p5.Color"}},{"line":670,"params":[{"name":"values","description":"<p>an array containing the red, green, blue,\n                                and alpha components of the color.<\/p>\n","type":"Number[]"}],"return":{"description":"","type":"p5.Color"}},{"line":677,"params":[{"name":"color","description":"","type":"p5.Color"}],"return":{"description":"","type":"p5.Color"}}]},{"file":"src\/color\/creating_reading.js","line":692,"description":"<p>Gets the green value of a color.<\/p>\n<p><code>green()<\/code> extracts the green value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n<p>By default, <code>green()<\/code> returns a color's green value in the range 0\nto 255. If the <a href=\"#\/p5\/colorMode\">colorMode()<\/a> is set to RGB, it\nreturns the green value in the given range.<\/p>\n","itemtype":"method","name":"green","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the green value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color(175, 100, 220);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'greenValue' to 100.\n  let greenValue = green(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, greenValue, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is dark green.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a color array.\n  let c = [175, 100, 220];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'greenValue' to 100.\n  let greenValue = green(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, greenValue, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is dark green.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgb(175, 100, 220)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'greenValue' to 100.\n  let greenValue = green(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, greenValue, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is dark green.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use RGB color with values in the range 0-100.\n  colorMode(RGB, 100);\n\n  \/\/ Create a p5.Color object using RGB values.\n  let c = color(69, 39, 86);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'greenValue' to 39.\n  let greenValue = green(c);\n\n  \/\/ Draw the right rectangle.\n  fill(0, greenValue, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is dark green.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":828,"description":"<p>Gets the hue value of a color.<\/p>\n<p><code>hue()<\/code> extracts the hue value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n<p>Hue describes a color's position on the color wheel. By default, <code>hue()<\/code>\nreturns a color's HSL hue in the range 0 to 360. If the\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a> is set to HSB or HSL, it returns the hue\nvalue in the given mode.<\/p>\n","itemtype":"method","name":"hue","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the hue value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Create a p5.Color object.\n  let c = color(0, 50, 100);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 20, 35, 60);\n\n  \/\/ Set 'hueValue' to 0.\n  let hueValue = hue(c);\n\n  \/\/ Draw the right rectangle.\n  fill(hueValue);\n  rect(50, 20, 35, 60);\n\n  describe(\n    'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.'\n  );\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Create a color array.\n  let c = [0, 50, 100];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 20, 35, 60);\n\n  \/\/ Set 'hueValue' to 0.\n  let hueValue = hue(c);\n\n  \/\/ Draw the right rectangle.\n  fill(hueValue);\n  rect(50, 20, 35, 60);\n\n  describe(\n    'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.'\n  );\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgb(255, 128, 128)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 20, 35, 60);\n\n  \/\/ Set 'hueValue' to 0.\n  let hueValue = hue(c);\n\n  \/\/ Draw the right rectangle.\n  fill(hueValue);\n  rect(50, 20, 35, 60);\n\n  describe(\n    'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":949,"description":"<p>Blends two colors to find a third color between them.<\/p>\n<p>The <code>amt<\/code> parameter specifies the amount to interpolate between the two\nvalues. 0 is equal to the first color, 0.1 is very near the first color,\n0.5 is halfway between the two colors, and so on. Negative numbers are set\nto 0. Numbers greater than 1 are set to 1. This differs from the behavior of\n<a href=\"#\/p5\/lerp\">lerp<\/a>. It's necessary because numbers outside of the\ninterval [0, 1] will produce strange and unexpected colors.<\/p>\n<p>The way that colors are interpolated depends on the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","itemtype":"method","name":"lerpColor","params":[{"name":"c1","description":"<p>interpolate from this color (any value created by the color() function).<\/p>\n","type":"p5.Color"},{"name":"c2","description":"<p>interpolate to this color (any value created by the color() function).<\/p>\n","type":"p5.Color"},{"name":"amt","description":"<p>number between 0 and 1.<\/p>\n","type":"Number"}],"return":{"description":"interpolated color.","type":"p5.Color"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create p5.Color objects to interpolate between.\n  let from = color(218, 165, 32);\n  let to = color(72, 61, 139);\n\n  \/\/ Create intermediate colors.\n  let interA = lerpColor(from, to, 0.33);\n  let interB = lerpColor(from, to, 0.66);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(from);\n  rect(10, 20, 20, 60);\n\n  \/\/ Draw the left-center rectangle.\n  fill(interA);\n  rect(30, 20, 20, 60);\n\n  \/\/ Draw the right-center rectangle.\n  fill(interB);\n  rect(50, 20, 20, 60);\n\n  \/\/ Draw the right rectangle.\n  fill(to);\n  rect(70, 20, 20, 60);\n\n  describe(\n    'Four rectangles. From left to right, the rectangles are tan, brown, brownish purple, and purple.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":1079,"description":"<p>Blends multiple colors to find a color between them.<\/p>\n<p>The <code>amt<\/code> parameter specifies the amount to interpolate between the color\nstops which are colors at each <code>amt<\/code> value \"location\" with <code>amt<\/code> values\nthat are between 2 color stops interpolating between them based on its relative\ndistance to both.<\/p>\n<p>The way that colors are interpolated depends on the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","itemtype":"method","name":"paletteLerp","params":[{"name":"colors_stops","description":"<p>color stops to interpolate from<\/p>\n","type":"[p5.Color, Number][]"},{"name":"amt","description":"<p>number to use to interpolate relative to color stops<\/p>\n","type":"Number"}],"return":{"description":"interpolated color.","type":"p5.Color"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(400, 400);\n}\n\nfunction draw() {\n  \/\/ The background goes from white to red to green to blue fill\n  background(paletteLerp([\n    ['white', 0],\n    ['red', 0.05],\n    ['green', 0.25],\n    ['blue', 1]\n  ], millis() \/ 10000 % 1));\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":1134,"description":"<p>Gets the lightness value of a color.<\/p>\n<p><code>lightness()<\/code> extracts the HSL lightness value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n<p>By default, <code>lightness()<\/code> returns a color's HSL lightness in the range 0\nto 100. If the <a href=\"#\/p5\/colorMode\">colorMode()<\/a> is set to HSL, it\nreturns the lightness value in the given range.<\/p>\n","itemtype":"method","name":"lightness","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the lightness value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Create a p5.Color object using HSL values.\n  let c = color(0, 100, 75);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'lightValue' to 75.\n  let lightValue = lightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(lightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Create a color array.\n  let c = [0, 100, 75];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'lightValue' to 75.\n  let lightValue = lightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(lightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgb(255, 128, 128)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'lightValue' to 75.\n  let lightValue = lightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(lightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSL color with values in the range 0-255.\n  colorMode(HSL, 255);\n\n  \/\/ Create a p5.Color object using HSL values.\n  let c = color(0, 255, 191.5);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'lightValue' to 191.5.\n  let lightValue = lightness(c);\n\n  \/\/ Draw the right rectangle.\n  fill(lightValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is gray.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":1279,"description":"<p>Gets the red value of a color.<\/p>\n<p><code>red()<\/code> extracts the red value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n<p>By default, <code>red()<\/code> returns a color's red value in the range 0\nto 255. If the <a href=\"#\/p5\/colorMode\">colorMode()<\/a> is set to RGB, it\nreturns the red value in the given range.<\/p>\n","itemtype":"method","name":"red","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the red value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color(175, 100, 220);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'redValue' to 175.\n  let redValue = red(c);\n\n  \/\/ Draw the right rectangle.\n  fill(redValue, 0, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is red.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a color array.\n  let c = [175, 100, 220];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'redValue' to 175.\n  let redValue = red(c);\n\n  \/\/ Draw the right rectangle.\n  fill(redValue, 0, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is red.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgb(175, 100, 220)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'redValue' to 175.\n  let redValue = red(c);\n\n  \/\/ Draw the right rectangle.\n  fill(redValue, 0, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is red.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use RGB color with values in the range 0-100.\n  colorMode(RGB, 100);\n\n  \/\/ Create a p5.Color object.\n  let c = color(69, 39, 86);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'redValue' to 69.\n  let redValue = red(c);\n\n  \/\/ Draw the right rectangle.\n  fill(redValue, 0, 0);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is light purple and the right one is red.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/creating_reading.js","line":1415,"description":"<p>Gets the saturation value of a color.<\/p>\n<p><code>saturation()<\/code> extracts the saturation value from a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color components, or\na CSS color string.<\/p>\n<p>Saturation is scaled differently in HSB and HSL. By default, <code>saturation()<\/code>\nreturns a color's HSL saturation in the range 0 to 100. If the\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a> is set to HSB or HSL, it returns the\nsaturation value in the given mode.<\/p>\n","itemtype":"method","name":"saturation","params":[{"name":"color","description":"<p><a href=\"#\/p5.Color\">p5.Color<\/a> object, array of\n                                        color components, or CSS color string.<\/p>\n","type":"p5.Color|Number[]|String"}],"return":{"description":"the saturation value","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ Create a p5.Color object.\n  let c = color(0, 50, 100);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'satValue' to 50.\n  let satValue = saturation(c);\n\n  \/\/ Draw the right rectangle.\n  fill(satValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is dark gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ Create a color array.\n  let c = [0, 50, 100];\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'satValue' to 100.\n  let satValue = saturation(c);\n\n  \/\/ Draw the right rectangle.\n  fill(satValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ Create a CSS color string.\n  let c = 'rgb(255, 128, 128)';\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'satValue' to 100.\n  let satValue = saturation(c);\n\n  \/\/ Draw the right rectangle.\n  fill(satValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is gray.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Create a p5.Color object.\n  let c = color(0, 100, 75);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'satValue' to 100.\n  let satValue = saturation(c);\n\n  \/\/ Draw the right rectangle.\n  fill(satValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is white.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use HSL color with values in the range 0-255.\n  colorMode(HSL, 255);\n\n  \/\/ Create a p5.Color object.\n  let c = color(0, 255, 191.5);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 15, 35, 70);\n\n  \/\/ Set 'satValue' to 255.\n  let satValue = saturation(c);\n\n  \/\/ Draw the right rectangle.\n  fill(satValue);\n  rect(50, 15, 35, 70);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is white.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":14,"description":"<p>CSS named colors.<\/p>\n","class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":168,"description":"<p>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.<\/p>\n<p>Note that RGB values of .9 are not parsed by IE, but are supported here for\ncolor string consistency.<\/p>\n","class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":181,"description":"<p>Full color string patterns. The capture groups are necessary.<\/p>\n","class":"p5","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":362,"description":"<p>Returns the color formatted as a <code>String<\/code>.<\/p>\n<p>Calling <code>myColor.toString()<\/code> can be useful for debugging, as in\n<code>print(myColor.toString())<\/code>. It's also helpful for using p5.js with other\nlibraries.<\/p>\n<p>The parameter, <code>format<\/code>, is optional. If a format string is passed, as in\n<code>myColor.toString('#rrggbb')<\/code>, it will determine how the color string is\nformatted. By default, color strings are formatted as <code>'rgba(r, g, b, a)'<\/code>.<\/p>\n","itemtype":"method","name":"toString","params":[{"name":"format","description":"<p>how the color string will be formatted.\nLeaving this empty formats the string as rgba(r, g, b, a).\n'#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes.\n'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode.\n'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels.\n'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.<\/p>\n","type":"String","optional":true}],"return":{"description":"the formatted string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let myColor = color('darkorchid');\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the text.\n  text(myColor.toString('#rrggbb'), 50, 50);\n\n  describe('The text \"#9932cc\" written in purple on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":572,"description":"<p>Sets the red component of a color.<\/p>\n<p>The range depends on the <a href=\"#\/p5\/colorMode\">colorMode()<\/a>. In the\ndefault RGB mode it's between 0 and 255.<\/p>\n","itemtype":"method","name":"setRed","params":[{"name":"red","description":"<p>the new red value.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color(255, 128, 128);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 20, 35, 60);\n\n  \/\/ Change the red value.\n  c.setRed(64);\n\n  \/\/ Draw the right rectangle.\n  fill(c);\n  rect(50, 20, 35, 60);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is teal.');\n}\n<\/code>\n<\/div>"],"class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":614,"description":"<p>Sets the green component of a color.<\/p>\n<p>The range depends on the <a href=\"#\/p5\/colorMode\">colorMode()<\/a>. In the\ndefault RGB mode it's between 0 and 255.<\/p>\n","itemtype":"method","name":"setGreen","params":[{"name":"green","description":"<p>the new green value.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color(255, 128, 128);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 20, 35, 60);\n\n  \/\/ Change the green value.\n  c.setGreen(255);\n\n  \/\/ Draw the right rectangle.\n  fill(c);\n  rect(50, 20, 35, 60);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is yellow.');\n}\n<\/code>\n<\/div>"],"class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":656,"description":"<p>Sets the blue component of a color.<\/p>\n<p>The range depends on the <a href=\"#\/p5\/colorMode\">colorMode()<\/a>. In the\ndefault RGB mode it's between 0 and 255.<\/p>\n","itemtype":"method","name":"setBlue","params":[{"name":"blue","description":"<p>the new blue value.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color(255, 128, 128);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 20, 35, 60);\n\n  \/\/ Change the blue value.\n  c.setBlue(255);\n\n  \/\/ Draw the right rectangle.\n  fill(c);\n  rect(50, 20, 35, 60);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is pale fuchsia.');\n}\n<\/code>\n<\/div>"],"class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":698,"description":"<p>Sets the alpha (transparency) value of a color.<\/p>\n<p>The range depends on the\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>. In the default RGB mode it's\nbetween 0 and 255.<\/p>\n","itemtype":"method","name":"setAlpha","params":[{"name":"alpha","description":"<p>the new alpha value.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color(255, 128, 128);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(c);\n  rect(15, 20, 35, 60);\n\n  \/\/ Change the alpha value.\n  c.setAlpha(128);\n\n  \/\/ Draw the right rectangle.\n  fill(c);\n  rect(50, 20, 35, 60);\n\n  describe('Two rectangles. The left one is salmon pink and the right one is faded pink.');\n}\n<\/code>\n<\/div>"],"class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":789,"description":"<p>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.<\/p>\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":820,"description":"<p>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.<\/p>\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/p5.Color.js","line":1048,"description":"<p>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.<\/p>\n","class":"p5.Color","module":"Color","submodule":"Creating & Reading"},{"file":"src\/color\/setting.js","line":13,"description":"<p>Starts defining a shape that will mask any shapes drawn afterward.<\/p>\n<p>Any shapes drawn between <code>beginClip()<\/code> and\n<a href=\"#\/p5\/endClip\">endClip()<\/a> will add to the mask shape. The mask\nwill apply to anything drawn after <a href=\"#\/p5\/endClip\">endClip()<\/a>.<\/p>\n<p>The parameter, <code>options<\/code>, is optional. If an object with an <code>invert<\/code>\nproperty is passed, as in <code>beginClip({ invert: true })<\/code>, it will be used to\nset the masking mode. <code>{ invert: true }<\/code> inverts the mask, creating holes\nin shapes that are masked. <code>invert<\/code> is <code>false<\/code> by default.<\/p>\n<p>Masks can be contained between the\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions.\nDoing so allows unmasked shapes to be drawn after masked shapes.<\/p>\n<p>Masks can also be defined in a callback function that's passed to\n<a href=\"#\/p5\/clip\">clip()<\/a>.<\/p>\n","itemtype":"method","name":"beginClip","params":[{"name":"options","description":"<p>an object containing clip settings.<\/p>\n","type":"Object","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a mask.\n  beginClip();\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n  endClip();\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n\n  describe('A white triangle and circle on a gray background.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an inverted mask.\n  beginClip({ invert: true });\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n  endClip();\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n\n  describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  noStroke();\n\n  \/\/ Draw a masked shape.\n  push();\n  \/\/ Create a mask.\n  beginClip();\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n  endClip();\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n  pop();\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw an inverted masked shape.\n  push();\n  \/\/ Create an inverted mask.\n  beginClip({ invert: true });\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n  endClip();\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n  pop();\n\n  describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A silhouette of a rotating torus colored fuchsia.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create a mask.\n  beginClip();\n  push();\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  scale(0.5);\n  torus(30, 15);\n  pop();\n  endClip();\n\n  \/\/ Draw a backing shape.\n  noStroke();\n  fill('fuchsia');\n  plane(100);\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create a mask.\n  beginClip();\n  push();\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  scale(0.5);\n  torus(30, 15);\n  pop();\n  endClip();\n\n  \/\/ Draw a backing shape.\n  noStroke();\n  beginShape(QUAD_STRIP);\n  fill(0, 255, 255);\n  vertex(-width \/ 2, -height \/ 2);\n  vertex(width \/ 2, -height \/ 2);\n  fill(100, 0, 100);\n  vertex(-width \/ 2, height \/ 2);\n  vertex(width \/ 2, height \/ 2);\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/color\/setting.js","line":190,"description":"<p>Ends defining a mask that was started with\n<a href=\"#\/p5\/beginClip\">beginClip()<\/a>.<\/p>\n","itemtype":"method","name":"endClip","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a mask.\n  beginClip();\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n  endClip();\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n\n  describe('A white triangle and circle on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/color\/setting.js","line":222,"description":"<p>Defines a shape that will mask any shapes drawn afterward.<\/p>\n<p>The first parameter, <code>callback<\/code>, is a function that defines the mask.\nAny shapes drawn in  <code>callback<\/code> will add to the mask shape. The mask\nwill apply to anything drawn after <code>clip()<\/code> is called.<\/p>\n<p>The second parameter, <code>options<\/code>, is optional. If an object with an <code>invert<\/code>\nproperty is passed, as in <code>beginClip({ invert: true })<\/code>, it will be used to\nset the masking mode. <code>{ invert: true }<\/code> inverts the mask, creating holes\nin shapes that are masked. <code>invert<\/code> is <code>false<\/code> by default.<\/p>\n<p>Masks can be contained between the\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions.\nDoing so allows unmasked shapes to be drawn after masked shapes.<\/p>\n<p>Masks can also be defined with <a href=\"#\/p5\/beginClip\">beginClip()<\/a>\nand <a href=\"#\/p5\/endClip\">endClip()<\/a>.<\/p>\n","itemtype":"method","name":"clip","params":[{"name":"callback","description":"<p>a function that draws the mask shape.<\/p>\n","type":"Function"},{"name":"options","description":"<p>an object containing clip settings.<\/p>\n","type":"Object","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a mask.\n  clip(mask);\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n\n  describe('A white triangle and circle on a gray background.');\n}\n\n\/\/ Declare a function that defines the mask.\nfunction mask() {\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an inverted mask.\n  clip(mask, { invert: true });\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n\n  describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.');\n}\n\n\/\/ Declare a function that defines the mask.\nfunction mask() {\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  noStroke();\n\n  \/\/ Draw a masked shape.\n  push();\n  \/\/ Create a mask.\n  clip(mask);\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n  pop();\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw an inverted masked shape.\n  push();\n  \/\/ Create an inverted mask.\n  clip(mask, { invert: true });\n\n  \/\/ Draw a backing shape.\n  square(5, 5, 45);\n  pop();\n\n  describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.');\n}\n\n\/\/ Declare a function that defines the mask.\nfunction mask() {\n  triangle(15, 37, 30, 13, 43, 37);\n  circle(45, 45, 7);\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A silhouette of a rotating torus colored fuchsia.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create a mask.\n  clip(mask);\n\n  \/\/ Draw a backing shape.\n  noStroke();\n  fill('fuchsia');\n  plane(100);\n}\n\n\/\/ Declare a function that defines the mask.\nfunction mask() {\n  push();\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  scale(0.5);\n  torus(30, 15);\n  pop();\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create a mask.\n  clip(mask);\n\n  \/\/ Draw a backing shape.\n  noStroke();\n  beginShape(QUAD_STRIP);\n  fill(0, 255, 255);\n  vertex(-width \/ 2, -height \/ 2);\n  vertex(width \/ 2, -height \/ 2);\n  fill(100, 0, 100);\n  vertex(-width \/ 2, height \/ 2);\n  vertex(width \/ 2, height \/ 2);\n  endShape();\n}\n\n\/\/ Declare a function that defines the mask.\nfunction mask() {\n  push();\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  scale(0.5);\n  torus(30, 15);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/color\/setting.js","line":414,"description":"<p>Sets the color used for the background of the canvas.<\/p>\n<p>By default, the background is transparent. <code>background()<\/code> is typically used\nwithin <a href=\"#\/p5\/draw\">draw()<\/a> to clear the display window at the\nbeginning of each frame. It can also be used inside\n<a href=\"#\/p5\/setup\">setup()<\/a> to set the background on the first frame\nof animation.<\/p>\n<p>The version of <code>background()<\/code> with one parameter interprets the value one\nof four ways. If the parameter is a <code>Number<\/code>, it's interpreted as a grayscale\nvalue. If the parameter is a <code>String<\/code>, it's interpreted as a CSS color string.\nRGB, RGBA, HSL, HSLA, hex, and named color strings are supported. If the\nparameter is a <a href=\"#\/p5.Color\">p5.Color<\/a> object, it will be used as\nthe background color. If the parameter is a\n<a href=\"#\/p5.Image\">p5.Image<\/a> object, it will be used as the background\nimage.<\/p>\n<p>The version of <code>background()<\/code> with two parameters interprets the first one\nas a grayscale value. The second parameter sets the alpha (transparency)\nvalue.<\/p>\n<p>The version of <code>background()<\/code> with three parameters interprets them as RGB,\nHSB, or HSL colors, depending on the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>. By default, colors are specified\nin RGB values. Calling <code>background(255, 204, 0)<\/code> sets the background a bright\nyellow color.<\/p>\n<p>The version of <code>background()<\/code> with four parameters interprets them as RGBA,\nHSBA, or HSLA colors, depending on the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The last parameter sets the alpha\n(transparency) value.<\/p>\n","itemtype":"method","name":"background","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ A grayscale value.\n  background(51);\n\n  describe('A canvas with a dark charcoal gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ A grayscale value and an alpha value.\n  background(51, 0.4);\n  describe('A canvas with a transparent gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ R, G & B values.\n  background(255, 204, 0);\n\n  describe('A canvas with a yellow background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ R, G, B, and Alpha values.\n  background(255, 0, 0, 128);\n\n  describe('A canvas with a semi-transparent red background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ H, S & B values.\n  background(255, 204, 100);\n\n  describe('A canvas with a royal blue background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ A CSS named color.\n  background('red');\n\n  describe('A canvas with a red background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Three-digit hex RGB notation.\n  background('#fae');\n\n  describe('A canvas with a pink background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Six-digit hex RGB notation.\n  background('#222222');\n\n  describe('A canvas with a black background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Integer RGB notation.\n  background('rgb(0, 255, 0)');\n\n  describe('A canvas with a bright green background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Integer RGBA notation.\n  background('rgba(0, 255, 0, 0.25)');\n\n  describe('A canvas with a transparent green background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Percentage RGB notation.\n  background('rgb(100%, 0%, 10%)');\n\n  describe('A canvas with a red background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Percentage RGBA notation.\n  background('rgba(100%, 0%, 100%, 0.5)');\n\n  describe('A canvas with a transparent purple background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ A p5.Color object.\n  let c = color(0, 0, 255);\n  background(c);\n\n  describe('A canvas with a blue background.');\n}\n<\/code>\n<\/div>\n"],"class":"p5","module":"Color","submodule":"Setting","overloads":[{"line":414,"params":[{"name":"color","description":"<p>any value created by the <a href=\"#\/p5\/color\">color()<\/a> function<\/p>\n","type":"p5.Color"}],"chainable":1},{"line":626,"params":[{"name":"colorstring","description":"<p>color string, possible formats include: integer\n                        rgb() or rgba(), percentage rgb() or rgba(),\n                        3-digit hex, 6-digit hex.<\/p>\n","type":"String"},{"name":"a","description":"<p>opacity of the background relative to current\n                            color range (default is 0-255).<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":636,"params":[{"name":"gray","description":"<p>specifies a value between white and black.<\/p>\n","type":"Number"},{"name":"a","description":"","type":"Number","optional":true}],"chainable":1},{"line":643,"params":[{"name":"v1","description":"<p>red value if color mode is RGB, or hue value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green value if color mode is RGB, or saturation value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue value if color mode is RGB, or brightness value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"a","description":"","type":"Number","optional":true}],"chainable":1},{"line":652,"params":[{"name":"values","description":"<p>an array containing the red, green, blue\n                                and alpha components of the color.<\/p>\n","type":"Number[]"}],"chainable":1},{"line":659,"params":[{"name":"image","description":"<p>image created with <a href=\"#\/p5\/loadImage\">loadImage()<\/a>\n                            or <a href=\"#\/p5\/createImage\">createImage()<\/a>,\n                            to set as background.\n                            (must be same size as the sketch window).<\/p>\n","type":"p5.Image"},{"name":"a","description":"","type":"Number","optional":true}],"chainable":1}]},{"file":"src\/color\/setting.js","line":673,"description":"<p>Clears the pixels on the canvas.<\/p>\n<p><code>clear()<\/code> makes every pixel 100% transparent. Calling <code>clear()<\/code> doesn't\nclear objects created by <code>createX()<\/code> functions such as\n<a href=\"#\/p5\/createGraphics\">createGraphics()<\/a>,\n<a href=\"#\/p5\/createVideo\">createVideo()<\/a>, and\n<a href=\"#\/p5\/createImg\">createImg()<\/a>. These objects will remain\nunchanged after calling <code>clear()<\/code> and can be redrawn.<\/p>\n<p>In WebGL mode, this function can clear the screen to a specific color. It\ninterprets four numeric parameters as normalized RGBA color values. It also\nclears the depth buffer. If you are not using the WebGL renderer, these\nparameters will have no effect.<\/p>\n","itemtype":"method","name":"clear","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A gray square. White circles are drawn as the user moves the mouse. The circles disappear when the user presses the mouse.');\n}\n\nfunction draw() {\n  circle(mouseX, mouseY, 20);\n}\n\nfunction mousePressed() {\n  clear();\n  background(200);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n  background(200);\n\n  pg = createGraphics(60, 60);\n  pg.background(200);\n  pg.noStroke();\n  pg.circle(pg.width \/ 2, pg.height \/ 2, 15);\n  image(pg, 20, 20);\n\n  describe('A white circle drawn on a gray square. The square gets smaller when the mouse is pressed.');\n}\n\nfunction mousePressed() {\n  clear();\n  image(pg, 20, 20);\n}\n<\/code>\n<\/div>"],"params":[{"name":"r","description":"<p>normalized red value.<\/p>\n","type":"Number","optional":true},{"name":"g","description":"<p>normalized green value.<\/p>\n","type":"Number","optional":true},{"name":"b","description":"<p>normalized blue value.<\/p>\n","type":"Number","optional":true},{"name":"a","description":"<p>normalized alpha value.<\/p>\n","type":"Number","optional":true}],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/color\/setting.js","line":751,"description":"<p>Changes the way color values are interpreted.<\/p>\n<p>By default, the <code>Number<\/code> parameters for <a href=\"#\/p5\/fill\">fill()<\/a>,\n<a href=\"#\/p5\/stroke\">stroke()<\/a>,\n<a href=\"#\/p5\/background\">background()<\/a>, and\n<a href=\"#\/p5\/color\">color()<\/a> are defined by values between 0 and 255\nusing the RGB color model. This is equivalent to calling\n<code>colorMode(RGB, 255)<\/code>. Pure red is <code>color(255, 0, 0)<\/code> in this model.<\/p>\n<p>Calling <code>colorMode(RGB, 100)<\/code> sets colors to use RGB color values\nbetween 0 and 100. Pure red is <code>color(100, 0, 0)<\/code> in this model.<\/p>\n<p>Calling <code>colorMode(HSB)<\/code> or <code>colorMode(HSL)<\/code> changes to HSB or HSL system\ninstead of RGB. Pure red is <code>color(0, 100, 100)<\/code> in HSB and\n<code>color(0, 100, 50)<\/code> in HSL.<\/p>\n<p><a href=\"#\/p5.Color\">p5.Color<\/a> objects remember the mode that they were\ncreated in. Changing modes doesn't affect their appearance.<\/p>\n","itemtype":"method","name":"colorMode","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Fill with pure red.\n  fill(255, 0, 0);\n\n  circle(50, 50, 25);\n\n  describe('A gray square with a red circle at its center.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use RGB color with values in the range 0-100.\n  colorMode(RGB, 100);\n\n  \/\/ Fill with pure red.\n  fill(100, 0, 0);\n\n  circle(50, 50, 25);\n\n  describe('A gray square with a red circle at its center.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ Fill with pure red.\n  fill(0, 100, 100);\n\n  circle(50, 50, 25);\n\n  describe('A gray square with a red circle at its center.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSL color.\n  colorMode(HSL);\n\n  \/\/ Fill with pure red.\n  fill(0, 100, 50);\n\n  circle(50, 50, 25);\n\n  describe('A gray square with a red circle at its center.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use RGB color with values in the range 0-100.\n  colorMode(RGB, 100);\n\n  for (let x = 0; x < 100; x += 1) {\n    for (let y = 0; y < 100; y += 1) {\n      stroke(x, y, 0);\n      point(x, y);\n    }\n  }\n\n  describe(\n    'A diagonal green to red gradient from bottom-left to top-right with shading transitioning to black at top-left corner.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use HSB color with values in the range 0-100.\n  colorMode(HSB, 100);\n\n  for (let x = 0; x < 100; x += 1) {\n    for (let y = 0; y < 100; y += 1) {\n      stroke(x, y, 100);\n      point(x, y);\n    }\n  }\n\n  describe('A rainbow gradient from left-to-right. Brightness transitions to white at the top.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Color object.\n  let myColor = color(180, 175, 230);\n  background(myColor);\n\n  \/\/ Use RGB color with values in the range 0-1.\n  colorMode(RGB, 1);\n\n  \/\/ Get the red, green, and blue color components.\n  let redValue = red(myColor);\n  let greenValue = green(myColor);\n  let blueValue = blue(myColor);\n\n  \/\/ Round the color components for display.\n  redValue = round(redValue, 2);\n  greenValue = round(greenValue, 2);\n  blueValue = round(blueValue, 2);\n\n  \/\/ Display the color components.\n  text(`Red: ${redValue}`, 10, 10, 80, 80);\n  text(`Green: ${greenValue}`, 10, 40, 80, 80);\n  text(`Blue: ${blueValue}`, 10, 70, 80, 80);\n\n  describe('A purple canvas with the red, green, and blue decimal values of the color written on it.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(255);\n\n  \/\/ Use RGB color with alpha values in the range 0-1.\n  colorMode(RGB, 255, 255, 255, 1);\n\n  noFill();\n  strokeWeight(4);\n  stroke(255, 0, 10, 0.3);\n  circle(40, 40, 50);\n  circle(50, 60, 50);\n\n  describe('Two overlapping translucent pink circle outlines.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting","overloads":[{"line":751,"params":[{"name":"mode","description":"<p>either RGB, HSB or HSL, corresponding to\n                         Red\/Green\/Blue and Hue\/Saturation\/Brightness\n                         (or Lightness).<\/p>\n","type":"Constant"},{"name":"max","description":"<p>range for all values.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":956,"params":[{"name":"mode","description":"","type":"Constant"},{"name":"max1","description":"<p>range for the red or hue depending on the\n                             current color mode.<\/p>\n","type":"Number"},{"name":"max2","description":"<p>range for the green or saturation depending\n                             on the current color mode.<\/p>\n","type":"Number"},{"name":"max3","description":"<p>range for the blue or brightness\/lightness\n                             depending on the current color mode.<\/p>\n","type":"Number"},{"name":"maxA","description":"<p>range for the alpha.<\/p>\n","type":"Number","optional":true}],"chainable":1}]},{"file":"src\/color\/setting.js","line":1000,"description":"<p>Sets the color used to fill shapes.<\/p>\n<p>Calling <code>fill(255, 165, 0)<\/code> or <code>fill('orange')<\/code> means all shapes drawn\nafter the fill command will be filled with the color orange.<\/p>\n<p>The version of <code>fill()<\/code> with one parameter interprets the value one of\nthree ways. If the parameter is a <code>Number<\/code>, it's interpreted as a grayscale\nvalue. If the parameter is a <code>String<\/code>, it's interpreted as a CSS color\nstring. A <a href=\"#\/p5.Color\">p5.Color<\/a> object can also be provided to\nset the fill color.<\/p>\n<p>The version of <code>fill()<\/code> with three parameters interprets them as RGB, HSB,\nor HSL colors, depending on the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The default color space is RGB,\nwith each value in the range from 0 to 255.<\/p>\n<p>The version of <code>fill()<\/code> with four parameters interprets them as <code>RGBA<\/code>, <code>HSBA<\/code>,\nor <code>HSLA<\/code> colors, depending on the current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The last parameter\nsets the alpha (transparency) value.<\/p>\n","itemtype":"method","name":"fill","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ A grayscale value.\n  fill(51);\n  square(20, 20, 60);\n\n  describe('A dark charcoal gray square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ R, G & B values.\n  fill(255, 204, 0);\n  square(20, 20, 60);\n\n  describe('A yellow square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ R, G, B, and Alpha values.\n  fill(255, 0, 0, 128);\n  square(20, 20, 60);\n\n  describe('A semi-transparent red square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(100);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ H, S & B values.\n  fill(255, 204, 100);\n  square(20, 20, 60);\n\n  describe('A royal blue square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ A CSS named color.\n  fill('red');\n  square(20, 20, 60);\n\n  describe('A red square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Three-digit hex RGB notation.\n  fill('#fae');\n  square(20, 20, 60);\n\n  describe('A pink square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Six-digit hex RGB notation.\n  fill('#A251FA');\n  square(20, 20, 60);\n\n  describe('A purple square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Integer RGB notation.\n  fill('rgb(0, 255, 0)');\n  square(20, 20, 60);\n\n  describe('A bright green square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Integer RGBA notation.\n  fill('rgba(0, 255, 0, 0.25)');\n  square(20, 20, 60);\n\n  describe('A soft green rectange with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Percentage RGB notation.\n  fill('rgb(100%, 0%, 10%)');\n  square(20, 20, 60);\n\n  describe('A red square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Percentage RGBA notation.\n  fill('rgba(100%, 0%, 100%, 0.5)');\n  square(20, 20, 60);\n\n  describe('A dark fuchsia square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ A p5.Color object.\n  let c = color(0, 0, 255);\n  fill(c);\n  square(20, 20, 60);\n\n  describe('A blue square with a black outline.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting","overloads":[{"line":1000,"params":[{"name":"v1","description":"<p>red value if color mode is RGB or hue value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green value if color mode is RGB or saturation value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue value if color mode is RGB or brightness value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"alpha","description":"<p>alpha value, controls transparency (0 - transparent, 255 - opaque).<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1225,"params":[{"name":"value","description":"<p>a color string.<\/p>\n","type":"String"}],"chainable":1},{"line":1231,"params":[{"name":"gray","description":"<p>a grayscale value.<\/p>\n","type":"Number"},{"name":"alpha","description":"","type":"Number","optional":true}],"chainable":1},{"line":1238,"params":[{"name":"values","description":"<p>an array containing the red, green, blue &\n                                and alpha components of the color.<\/p>\n","type":"Number[]"}],"chainable":1},{"line":1245,"params":[{"name":"color","description":"<p>the fill color.<\/p>\n","type":"p5.Color"}],"chainable":1}]},{"file":"src\/color\/setting.js","line":1257,"description":"<p>Disables setting the fill color for shapes.<\/p>\n<p>Calling <code>noFill()<\/code> is the same as making the fill completely transparent,\nas in <code>fill(0, 0)<\/code>. If both <a href=\"#\/p5\/noStroke\">noStroke()<\/a> and\n<code>noFill()<\/code> are called, nothing will be drawn to the screen.<\/p>\n","itemtype":"method","name":"noFill","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the top square.\n  square(32, 10, 35);\n\n  \/\/ Draw the bottom square.\n  noFill();\n  square(32, 55, 35);\n\n  describe('A white square on above an empty square. Both squares have black outlines.');\n}\n<\/code>\n<\/div>\n\n<div modernizr='webgl'>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A purple cube wireframe spinning on a black canvas.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Style the box.\n  noFill();\n  stroke(100, 100, 240);\n\n  \/\/ Rotate the coordinates.\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the box.\n  box(45);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/color\/setting.js","line":1317,"description":"<p>Disables drawing points, lines, and the outlines of shapes.<\/p>\n<p>Calling <code>noStroke()<\/code> is the same as making the stroke completely transparent,\nas in <code>stroke(0, 0)<\/code>. If both <code>noStroke()<\/code> and\n<a href=\"#\/p5\/noFill\">noFill()<\/a> are called, nothing will be drawn to the\nscreen.<\/p>\n","itemtype":"method","name":"noStroke","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  noStroke();\n  square(20, 20, 60);\n\n  describe('A white square with no outline.');\n}\n<\/code>\n<\/div>\n\n<div modernizr='webgl'>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A pink cube with no edge outlines spinning on a black canvas.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Style the box.\n  noStroke();\n  fill(240, 150, 150);\n\n  \/\/ Rotate the coordinates.\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the box.\n  box(45);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/color\/setting.js","line":1373,"description":"<p>Sets the color used to draw points, lines, and the outlines of shapes.<\/p>\n<p>Calling <code>stroke(255, 165, 0)<\/code> or <code>stroke('orange')<\/code> means all shapes drawn\nafter calling <code>stroke()<\/code> will be outlined with the color orange. The way\nthese parameters are interpreted may be changed with the\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a> function.<\/p>\n<p>The version of <code>stroke()<\/code> with one parameter interprets the value one of\nthree ways. If the parameter is a <code>Number<\/code>, it's interpreted as a grayscale\nvalue. If the parameter is a <code>String<\/code>, it's interpreted as a CSS color\nstring. A <a href=\"#\/p5.Color\">p5.Color<\/a> object can also be provided to\nset the stroke color.<\/p>\n<p>The version of <code>stroke()<\/code> with two parameters interprets the first one as a\ngrayscale value. The second parameter sets the alpha (transparency) value.<\/p>\n<p>The version of <code>stroke()<\/code> with three parameters interprets them as RGB, HSB,\nor HSL colors, depending on the current <code>colorMode()<\/code>.<\/p>\n<p>The version of <code>stroke()<\/code> with four parameters interprets them as RGBA, HSBA,\nor HSLA colors, depending on the current <code>colorMode()<\/code>. The last parameter\nsets the alpha (transparency) value.<\/p>\n","itemtype":"method","name":"stroke","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ A grayscale value.\n  strokeWeight(4);\n  stroke(51);\n  square(20, 20, 60);\n\n  describe('A white square with a dark charcoal gray outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ R, G & B values.\n  stroke(255, 204, 0);\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a yellow outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use HSB color.\n  colorMode(HSB);\n\n  \/\/ H, S & B values.\n  strokeWeight(4);\n  stroke(255, 204, 100);\n  square(20, 20, 60);\n\n  describe('A white square with a royal blue outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ A CSS named color.\n  stroke('red');\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a red outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Three-digit hex RGB notation.\n  stroke('#fae');\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a pink outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Six-digit hex RGB notation.\n  stroke('#222222');\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Integer RGB notation.\n  stroke('rgb(0, 255, 0)');\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A whiite square with a bright green outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Integer RGBA notation.\n  stroke('rgba(0, 255, 0, 0.25)');\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a soft green outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Percentage RGB notation.\n  stroke('rgb(100%, 0%, 10%)');\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a red outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Percentage RGBA notation.\n  stroke('rgba(100%, 0%, 100%, 0.5)');\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a dark fuchsia outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ A p5.Color object.\n  stroke(color(0, 0, 255));\n  strokeWeight(4);\n  square(20, 20, 60);\n\n  describe('A white square with a blue outline.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting","overloads":[{"line":1373,"params":[{"name":"v1","description":"<p>red value if color mode is RGB or hue value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green value if color mode is RGB or saturation value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue value if color mode is RGB or brightness value if color mode is HSB.<\/p>\n","type":"Number"},{"name":"alpha","description":"<p>alpha value, controls transparency (0 - transparent, 255 - opaque).<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1596,"params":[{"name":"value","description":"<p>a color string.<\/p>\n","type":"String"}],"chainable":1},{"line":1602,"params":[{"name":"gray","description":"<p>a grayscale value.<\/p>\n","type":"Number"},{"name":"alpha","description":"","type":"Number","optional":true}],"chainable":1},{"line":1609,"params":[{"name":"values","description":"<p>an array containing the red, green, blue,\n                                and alpha components of the color.<\/p>\n","type":"Number[]"}],"chainable":1},{"line":1616,"params":[{"name":"color","description":"<p>the stroke color.<\/p>\n","type":"p5.Color"}],"chainable":1}]},{"file":"src\/color\/setting.js","line":1629,"description":"<p>Starts using shapes to erase parts of the canvas.<\/p>\n<p>All drawing that follows <code>erase()<\/code> will subtract from the canvas, revealing\nthe web page underneath. The erased areas will become transparent, allowing\nthe content behind the canvas to show through. The\n<a href=\"#\/p5\/fill\">fill()<\/a>, <a href=\"#\/p5\/stroke\">stroke()<\/a>, and\n<a href=\"#\/p5\/blendMode\">blendMode()<\/a> have no effect once <code>erase()<\/code> is\ncalled.<\/p>\n<p>The <code>erase()<\/code> function has two optional parameters. The first parameter\nsets the strength of erasing by the shape's interior. A value of 0 means\nthat no erasing will occur. A value of 255 means that the shape's interior\nwill fully erase the content underneath. The default value is 255\n(full strength).<\/p>\n<p>The second parameter sets the strength of erasing by the shape's edge. A\nvalue of 0 means that no erasing will occur. A value of 255 means that the\nshape's edge will fully erase the content underneath. The default value is\n255 (full strength).<\/p>\n<p>To cancel the erasing effect, use the <a href=\"#\/p5\/noErase\">noErase()<\/a>\nfunction.<\/p>\n<p><code>erase()<\/code> has no effect on drawing done with the\n<a href=\"#\/p5\/image\">image()<\/a> and\n<a href=\"#\/p5\/background\">background()<\/a> functions.<\/p>\n","itemtype":"method","name":"erase","params":[{"name":"strengthFill","description":"<p>a number (0-255) for the strength of erasing under a shape's interior.\n                                       Defaults to 255, which is full strength.<\/p>\n","type":"Number","optional":true},{"name":"strengthStroke","description":"<p>a number (0-255) for the strength of erasing under a shape's edge.\n                                       Defaults to 255, which is full strength.<\/p>\n","type":"Number","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(100, 100, 250);\n\n  \/\/ Draw a pink square.\n  fill(250, 100, 100);\n  square(20, 20, 60);\n\n  \/\/ Erase a circular area.\n  erase();\n  circle(25, 30, 30);\n  noErase();\n\n  describe('A purple canvas with a pink square in the middle. A circle is erased from the top-left, leaving a hole.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(100, 100, 250);\n\n  \/\/ Draw a pink square.\n  fill(250, 100, 100);\n  square(20, 20, 60);\n\n  \/\/ Erase a circular area.\n  strokeWeight(5);\n  erase(150, 255);\n  circle(25, 30, 30);\n  noErase();\n\n  describe('A purple canvas with a pink square in the middle. A circle at the top-left partially erases its interior and a fully erases its outline.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/color\/setting.js","line":1716,"description":"<p>Ends erasing that was started with <a href=\"#\/p5\/erase\">erase()<\/a>.<\/p>\n<p>The <a href=\"#\/p5\/fill\">fill()<\/a>, <a href=\"#\/p5\/stroke\">stroke()<\/a>, and\n<a href=\"#\/p5\/blendMode\">blendMode()<\/a> settings will return to what they\nwere prior to calling <a href=\"#\/p5\/erase\">erase()<\/a>.<\/p>\n","itemtype":"method","name":"noErase","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(235, 145, 15);\n\n  \/\/ Draw the left rectangle.\n  noStroke();\n  fill(30, 45, 220);\n  rect(30, 10, 10, 80);\n\n  \/\/ Erase a circle.\n  erase();\n  circle(50, 50, 60);\n  noErase();\n\n  \/\/ Draw the right rectangle.\n  rect(70, 10, 10, 80);\n\n  describe('An orange canvas with two tall blue rectangles. A circular hole in the center erases the rectangle on the left but not the one on the right.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Color","submodule":"Setting"},{"file":"src\/core\/friendly_errors\/fes_core.js","line":1,"requires":["core\n\nThis is the main file for the Friendly Error System (FES)","containing\nthe core as well as miscellaneous functionality of the FES. Here is a\nbrief outline of the functions called in this system.\n\nThe FES may be invoked by a call to either\n(1) _validateParameters","(2) _friendlyFileLoadError","(3) _friendlyError","(4) helpForMisusedAtTopLevelCode","or (5) _fesErrorMonitor.\n\n_validateParameters is located in validate_params.js along with other code\nused for parameter validation.\n_friendlyFileLoadError is located in file_errors.js along with other code\nused for dealing with file load errors.\nApart from this","there's also a file stacktrace.js","which contains the code\nto parse the error stack","borrowed from:\nhttps:\/\/github.com\/stacktracejs\/stacktrace.js\n\nFor more detailed information on the FES functions","including the call\nsequence of each function","please look at the FES Reference + Dev Notes:\nhttps:\/\/github.com\/processing\/p5.js\/blob\/main\/contributor_docs\/fes_reference_dev_notes.md"],"class":"p5","module":"Color"},{"file":"src\/core\/friendly_errors\/fes_core.js","line":932,"description":"<p>Prints out all the colors in the color pallete with white text.\nFor color blindness testing.<\/p>\n","class":"p5","module":"Color"},{"file":"src\/core\/friendly_errors\/file_errors.js","line":1,"requires":["core"],"class":"p5","module":"Color"},{"file":"src\/core\/friendly_errors\/sketch_reader.js","line":1,"requires":["core"],"class":"p5","module":"Color"},{"file":"src\/core\/friendly_errors\/stacktrace.js","line":1,"requires":["core"],"class":"p5","module":"Color"},{"file":"src\/core\/friendly_errors\/validate_params.js","line":1,"requires":["core"],"class":"p5","module":"Color"},{"file":"src\/core\/shape\/2d_primitives.js","line":16,"description":"<p>This function does 3 things:<\/p>\n<ol>\n<li><p>Bounds the desired start\/stop angles for an arc (in radians) so that:<\/p>\n<pre><code>0 <= start < TWO_PI ;    start <= stop < start + TWO_PI\n<\/code><\/pre>\n<p>This means that the arc rendering functions don't have to be concerned\nwith what happens if stop is smaller than start, or if the arc 'goes\nround more than once', etc.: they can just start at start and increase\nuntil stop and the correct arc will be drawn.<\/p>\n<\/li>\n<li><p>Optionally adjusts the angles within each quadrant to counter the naive\nscaling of the underlying ellipse up from the unit circle.  Without\nthis, the angles become arbitrary when width != height: 45 degrees\nmight be drawn at 5 degrees on a 'wide' ellipse, or at 85 degrees on\na 'tall' ellipse.<\/p>\n<\/li>\n<li><p>Flags up when start and stop correspond to the same place on the\nunderlying ellipse.  This is useful if you want to do something special\nthere (like rendering a whole ellipse instead).<\/p>\n<\/li>\n<\/ol>\n","class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src\/core\/shape\/2d_primitives.js","line":102,"description":"<p>Draws an arc.<\/p>\n<p>An arc is a section of an ellipse defined by the <code>x<\/code>, <code>y<\/code>, <code>w<\/code>, and\n<code>h<\/code> parameters. <code>x<\/code> and <code>y<\/code> set the location of the arc's center. <code>w<\/code> and\n<code>h<\/code> set the arc's width and height. See\n<a href=\"#\/p5\/ellipse\">ellipse()<\/a> and\n<a href=\"#\/p5\/ellipseMode\">ellipseMode()<\/a> for more details.<\/p>\n<p>The fifth and sixth parameters, <code>start<\/code> and <code>stop<\/code>, set the angles\nbetween which to draw the arc. Arcs are always drawn clockwise from\n<code>start<\/code> to <code>stop<\/code>. The fifth and sixth parameters, start and stop, set the\nangles between which to draw the arc. By default, angles are given in radians, but if angleMode\n(DEGREES) is set, the function interprets the values in degrees.<\/p>\n<p>The seventh parameter, <code>mode<\/code>, is optional. It determines the arc's fill\nstyle. The fill modes are a semi-circle (<code>OPEN<\/code>), a closed semi-circle\n(<code>CHORD<\/code>), or a closed pie segment (<code>PIE<\/code>).<\/p>\n<p>The eighth parameter, <code>detail<\/code>, is also optional. It determines how many\nvertices are used to draw the arc in WebGL mode. The default value is 25.<\/p>\n","itemtype":"method","name":"arc","params":[{"name":"x","description":"<p>x-coordinate of the arc's ellipse.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the arc's ellipse.<\/p>\n","type":"Number"},{"name":"w","description":"<p>width of the arc's ellipse by default.<\/p>\n","type":"Number"},{"name":"h","description":"<p>height of the arc's ellipse by default.<\/p>\n","type":"Number"},{"name":"start","description":"<p>angle to start the arc, specified in radians.<\/p>\n","type":"Number"},{"name":"stop","description":"<p>angle to stop the arc, specified in radians.<\/p>\n","type":"Number"},{"name":"mode","description":"<p>optional parameter to determine the way of drawing\n                        the arc. either CHORD, PIE, or OPEN.<\/p>\n","type":"Constant","optional":true},{"name":"detail","description":"<p>optional parameter for WebGL mode only. This is to\n                        specify the number of vertices that makes up the\n                        perimeter of the arc. Default value is 25. Won't\n                        draw a stroke for a detail of more than 50.<\/p>\n","type":"Integer","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  arc(50, 50, 80, 80, 0, PI + HALF_PI);\n\n  describe('A white circle on a gray canvas. The top-right quarter of the circle is missing.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  arc(50, 50, 80, 40, 0, PI + HALF_PI);\n\n  describe('A white ellipse on a gray canvas. The top-right quarter of the ellipse is missing.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Bottom-right.\n  arc(50, 55, 50, 50, 0, HALF_PI);\n\n  noFill();\n\n  \/\/ Bottom-left.\n  arc(50, 55, 60, 60, HALF_PI, PI);\n\n  \/\/ Top-left.\n  arc(50, 55, 70, 70, PI, PI + QUARTER_PI);\n\n  \/\/ Top-right.\n  arc(50, 55, 80, 80, PI + QUARTER_PI, TWO_PI);\n\n  describe(\n    'A shattered outline of an circle with a quarter of a white circle at the bottom-right.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Default fill mode.\n  arc(50, 50, 80, 80, 0, PI + QUARTER_PI);\n\n  describe('A white circle with the top-right third missing. The bottom is outlined in black.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ OPEN fill mode.\n  arc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN);\n\n  describe(\n    'A white circle missing a section from the top-right. The bottom is outlined in black.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ CHORD fill mode.\n  arc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD);\n\n  describe('A white circle with a black outline missing a section from the top-right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ PIE fill mode.\n  arc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE);\n\n  describe('A white circle with a black outline. The top-right third is missing.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ PIE fill mode.\n  arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE);\n\n  describe('A white circle with a black outline. The top-right third is missing.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ PIE fill mode with 5 vertices.\n  arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE, 5);\n\n  describe('A white circle with a black outline. The top-right third is missing.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A yellow circle on a black background. The circle opens and closes its mouth.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Style the arc.\n  noStroke();\n  fill(255, 255, 0);\n\n  \/\/ Update start and stop angles.\n  let biteSize = PI \/ 16;\n  let startAngle = biteSize * sin(frameCount * 0.1) + biteSize;\n  let endAngle = TWO_PI - startAngle;\n\n  \/\/ Draw the arc.\n  arc(50, 50, 80, 80, startAngle, endAngle, PIE);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src\/core\/shape\/2d_primitives.js","line":371,"description":"<p>Draws an ellipse (oval).<\/p>\n<p>An ellipse is a round shape defined by the <code>x<\/code>, <code>y<\/code>, <code>w<\/code>, and\n<code>h<\/code> parameters. <code>x<\/code> and <code>y<\/code> set the location of its center. <code>w<\/code> and\n<code>h<\/code> set its width and height. See\n<a href=\"#\/p5\/ellipseMode\">ellipseMode()<\/a> for other ways to set\nits position.<\/p>\n<p>If no height is set, the value of width is used for both the width and\nheight. If a negative height or width is specified, the absolute value is\ntaken.<\/p>\n<p>The fifth parameter, <code>detail<\/code>, is also optional. It determines how many\nvertices are used to draw the ellipse in WebGL mode. The default value is\n25.<\/p>\n","itemtype":"method","name":"ellipse","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  ellipse(50, 50, 80, 80);\n\n  describe('A white circle on a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  ellipse(50, 50, 80);\n\n  describe('A white circle on a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  ellipse(50, 50, 80, 40);\n\n  describe('A white ellipse on a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  ellipse(0, 0, 80, 40);\n\n  describe('A white ellipse on a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Use 6 vertices.\n  ellipse(0, 0, 80, 40, 6);\n\n  describe('A white hexagon on a gray canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":371,"params":[{"name":"x","description":"<p>x-coordinate of the center of the ellipse.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the center of the ellipse.<\/p>\n","type":"Number"},{"name":"w","description":"<p>width of the ellipse.<\/p>\n","type":"Number"},{"name":"h","description":"<p>height of the ellipse.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":472,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"w","description":"","type":"Number"},{"name":"h","description":"","type":"Number"},{"name":"detail","description":"<p>optional parameter for WebGL mode only. This is to\n                        specify the number of vertices that makes up the\n                        perimeter of the ellipse. Default value is 25. Won't\n                        draw a stroke for a detail of more than 50.<\/p>\n","type":"Integer","optional":true}]}]},{"file":"src\/core\/shape\/2d_primitives.js","line":488,"description":"<p>Draws a circle.<\/p>\n<p>A circle is a round shape defined by the <code>x<\/code>, <code>y<\/code>, and <code>d<\/code> parameters.\n<code>x<\/code> and <code>y<\/code> set the location of its center. <code>d<\/code> sets its width and height (diameter).\nEvery point on the circle's edge is the same distance, <code>0.5 * d<\/code>, from its center.\n<code>0.5 * d<\/code> (half the diameter) is the circle's radius.\nSee <a href=\"#\/p5\/ellipseMode\">ellipseMode()<\/a> for other ways to set its position.<\/p>\n","itemtype":"method","name":"circle","params":[{"name":"x","description":"<p>x-coordinate of the center of the circle.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the center of the circle.<\/p>\n","type":"Number"},{"name":"d","description":"<p>diameter of the circle.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  circle(50, 50, 25);\n\n  describe('A white circle with black outline in the middle of a gray canvas.');\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  circle(0, 0, 25);\n\n  describe('A white circle with black outline in the middle of a gray canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src\/core\/shape\/2d_primitives.js","line":564,"description":"<p>Draws a straight line between two points.<\/p>\n<p>A line's default width is one pixel. The version of <code>line()<\/code> with four\nparameters draws the line in 2D. To color a line, use the\n<a href=\"#\/p5\/stroke\">stroke()<\/a> function. To change its width, use the\n<a href=\"#\/p5\/strokeWeight\">strokeWeight()<\/a> function. A line\ncan't be filled, so the <a href=\"#\/p5\/fill\">fill()<\/a> function won't\naffect the line's color.<\/p>\n<p>The version of <code>line()<\/code> with six parameters allows the line to be drawn in\n3D space. Doing so requires adding the <code>WEBGL<\/code> argument to\n<a href=\"#\/p5\/createCanvas\">createCanvas()<\/a>.<\/p>\n","itemtype":"method","name":"line","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  line(30, 20, 85, 75);\n\n  describe(\n    'A black line on a gray canvas running from top-center to bottom-right.'\n  );\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the line.\n  stroke('magenta');\n  strokeWeight(5);\n\n  line(30, 20, 85, 75);\n\n  describe(\n    'A thick, magenta line on a gray canvas running from top-center to bottom-right.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top.\n  line(30, 20, 85, 20);\n\n  \/\/ Right.\n  stroke(126);\n  line(85, 20, 85, 75);\n\n  \/\/ Bottom.\n  stroke(255);\n  line(85, 75, 30, 75);\n\n  describe(\n    'Three lines drawn in grayscale on a gray canvas. They form the top, right, and bottom sides of a square.'\n  );\n}\n<\/code>\n<\/div>","\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  line(-20, -30, 35, 25);\n\n  describe(\n    'A black line on a gray canvas running from top-center to bottom-right.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A black line connecting two spheres. The scene spins slowly.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw a line.\n  line(0, 0, 0, 30, 20, -10);\n\n  \/\/ Draw the center sphere.\n  sphere(10);\n\n  \/\/ Translate to the second point.\n  translate(30, 20, -10);\n\n  \/\/ Draw the bottom-right sphere.\n  sphere(10);\n}\n<\/code>\n<\/div>\n"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":564,"params":[{"name":"x1","description":"<p>the x-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"y1","description":"<p>the y-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"x2","description":"<p>the x-coordinate of the second point.<\/p>\n","type":"Number"},{"name":"y2","description":"<p>the y-coordinate of the second point.<\/p>\n","type":"Number"}],"chainable":1},{"line":696,"params":[{"name":"x1","description":"","type":"Number"},{"name":"y1","description":"","type":"Number"},{"name":"z1","description":"<p>the z-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"x2","description":"","type":"Number"},{"name":"y2","description":"","type":"Number"},{"name":"z2","description":"<p>the z-coordinate of the second point.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/core\/shape\/2d_primitives.js","line":721,"description":"<p>Draws a single point in space.<\/p>\n<p>A point's default width is one pixel. To color a point, use the\n<a href=\"#\/p5\/stroke\">stroke()<\/a> function. To change its width, use the\n<a href=\"#\/p5\/strokeWeight\">strokeWeight()<\/a> function. A point\ncan't be filled, so the <a href=\"#\/p5\/fill\">fill()<\/a> function won't\naffect the point's color.<\/p>\n<p>The version of <code>point()<\/code> with two parameters allows the point's location to\nbe set with its x- and y-coordinates, as in <code>point(10, 20)<\/code>.<\/p>\n<p>The version of <code>point()<\/code> with three parameters allows the point to be drawn\nin 3D space with x-, y-, and z-coordinates, as in <code>point(10, 20, 30)<\/code>.\nDoing so requires adding the <code>WEBGL<\/code> argument to\n<a href=\"#\/p5\/createCanvas\">createCanvas()<\/a>.<\/p>\n<p>The version of <code>point()<\/code> with one parameter allows the point's location to\nbe set with a <a href=\"#\/p5\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","itemtype":"method","name":"point","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n\n  \/\/ Making point to 5 pixels\n  strokeWeight(5);\n\n\n  \/\/ Top-left.\n  point(30, 20);\n\n  \/\/ Top-right.\n  point(85, 20);\n\n  \/\/ Bottom-right.\n  point(85, 75);\n\n  \/\/ Bottom-left.\n  point(30, 75);\n\n  describe(\n    'Four small, black points drawn on a gray canvas. The points form the corners of a square.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n\n  \/\/ Making point to 5 pixels.\n  strokeWeight(5);\n\n\n  \/\/ Top-left.\n  point(30, 20);\n\n  \/\/ Top-right.\n  point(70, 20);\n\n  \/\/ Style the next points.\n  stroke('purple');\n  strokeWeight(10);\n\n  \/\/ Bottom-right.\n  point(70, 80);\n\n  \/\/ Bottom-left.\n  point(30, 80);\n\n  describe(\n    'Four points drawn on a gray canvas. Two are black and two are purple. The points form the corners of a square.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n\n  \/\/ Making point to 5 pixels.\n  strokeWeight(5);\n\n\n  \/\/ Top-left.\n  let a = createVector(30, 20);\n  point(a);\n\n  \/\/ Top-right.\n  let b = createVector(70, 20);\n  point(b);\n\n  \/\/ Bottom-right.\n  let c = createVector(70, 80);\n  point(c);\n\n  \/\/ Bottom-left.\n  let d = createVector(30, 80);\n  point(d);\n\n  describe(\n    'Four small, black points drawn on a gray canvas. The points form the corners of a square.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('Two purple points drawn on a gray canvas.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the points.\n  stroke('purple');\n  strokeWeight(10);\n\n  \/\/ Top-left.\n  point(-20, -30);\n\n  \/\/ Bottom-right.\n  point(20, 30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('Two purple points drawn on a gray canvas. The scene spins slowly.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Style the points.\n  stroke('purple');\n  strokeWeight(10);\n\n  \/\/ Top-left.\n  point(-20, -30, 0);\n\n  \/\/ Bottom-right.\n  point(20, 30, -50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":721,"params":[{"name":"x","description":"<p>the x-coordinate.<\/p>\n","type":"Number"},{"name":"y","description":"<p>the y-coordinate.<\/p>\n","type":"Number"},{"name":"z","description":"<p>the z-coordinate (for WebGL mode).<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":900,"params":[{"name":"coordinateVector","description":"<p>the coordinate vector.<\/p>\n","type":"p5.Vector"}],"chainable":1}]},{"file":"src\/core\/shape\/2d_primitives.js","line":928,"description":"<p>Draws a quadrilateral (four-sided shape).<\/p>\n<p>Quadrilaterals include rectangles, squares, rhombuses, and trapezoids. The\nfirst pair of parameters <code>(x1, y1)<\/code> sets the quad's first point. The next\nthree pairs of parameters set the coordinates for its next three points\n<code>(x2, y2)<\/code>, <code>(x3, y3)<\/code>, and <code>(x4, y4)<\/code>. Points should be added in either\nclockwise or counter-clockwise order.<\/p>\n<p>The version of <code>quad()<\/code> with twelve parameters allows the quad to be drawn\nin 3D space. Doing so requires adding the <code>WEBGL<\/code> argument to\n<a href=\"#\/p5\/createCanvas\">createCanvas()<\/a>.<\/p>\n<p>The thirteenth and fourteenth parameters are optional. In WebGL mode, they\nset the number of segments used to draw the quadrilateral in the x- and\ny-directions. They're both 2 by default.<\/p>\n","itemtype":"method","name":"quad","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  quad(20, 20, 80, 20, 80, 80, 20, 80);\n\n  describe('A white square with a black outline drawn on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  quad(20, 30, 80, 30, 80, 70, 20, 70);\n\n  describe('A white rectangle with a black outline drawn on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  quad(50, 62, 86, 50, 50, 38, 14, 50);\n\n  describe('A white rhombus with a black outline drawn on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  quad(20, 50, 80, 30, 80, 70, 20, 70);\n\n  describe('A white trapezoid with a black outline drawn on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  quad(-30, -30, 30, -30, 30, 30, -30, 30);\n\n  describe('A white square with a black outline drawn on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A wavy white surface spins around on gray canvas.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the quad.\n  quad(-30, -30, 0, 30, -30, 0, 30, 30, 20, -30, 30, -20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":928,"params":[{"name":"x1","description":"<p>the x-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"y1","description":"<p>the y-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"x2","description":"<p>the x-coordinate of the second point.<\/p>\n","type":"Number"},{"name":"y2","description":"<p>the y-coordinate of the second point.<\/p>\n","type":"Number"},{"name":"x3","description":"<p>the x-coordinate of the third point.<\/p>\n","type":"Number"},{"name":"y3","description":"<p>the y-coordinate of the third point.<\/p>\n","type":"Number"},{"name":"x4","description":"<p>the x-coordinate of the fourth point.<\/p>\n","type":"Number"},{"name":"y4","description":"<p>the y-coordinate of the fourth point.<\/p>\n","type":"Number"},{"name":"detailX","description":"<p>number of segments in the x-direction.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of segments in the y-direction.<\/p>\n","type":"Integer","optional":true}],"chainable":1},{"line":1048,"params":[{"name":"x1","description":"","type":"Number"},{"name":"y1","description":"","type":"Number"},{"name":"z1","description":"<p>the z-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"x2","description":"","type":"Number"},{"name":"y2","description":"","type":"Number"},{"name":"z2","description":"<p>the z-coordinate of the second point.<\/p>\n","type":"Number"},{"name":"x3","description":"","type":"Number"},{"name":"y3","description":"","type":"Number"},{"name":"z3","description":"<p>the z-coordinate of the third point.<\/p>\n","type":"Number"},{"name":"x4","description":"","type":"Number"},{"name":"y4","description":"","type":"Number"},{"name":"z4","description":"<p>the z-coordinate of the fourth point.<\/p>\n","type":"Number"},{"name":"detailX","description":"","type":"Integer","optional":true},{"name":"detailY","description":"","type":"Integer","optional":true}],"chainable":1}]},{"file":"src\/core\/shape\/2d_primitives.js","line":1091,"description":"<p>Draws a rectangle.<\/p>\n<p>A rectangle is a four-sided shape defined by the <code>x<\/code>, <code>y<\/code>, <code>w<\/code>, and <code>h<\/code>\nparameters. <code>x<\/code> and <code>y<\/code> set the location of its top-left corner. <code>w<\/code> sets\nits width and <code>h<\/code> sets its height. Every angle in the rectangle measures\n90\u02da. See <a href=\"#\/p5\/rectMode\">rectMode()<\/a> for other ways to define\nrectangles.<\/p>\n<p>The version of <code>rect()<\/code> with five parameters creates a rounded rectangle. The\nfifth parameter sets the radius for all four corners.<\/p>\n<p>The version of <code>rect()<\/code> with eight parameters also creates a rounded\nrectangle. Each of the last four parameters set the radius of a corner. The\nradii start with the top-left corner and move clockwise around the\nrectangle. If any of these parameters are omitted, they are set to the\nvalue of the last radius that was set.<\/p>\n","itemtype":"method","name":"rect","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  rect(30, 20, 55, 55);\n\n  describe('A white square with a black outline on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  rect(30, 20, 55, 40);\n\n  describe('A white rectangle with a black outline on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Give all corners a radius of 20.\n  rect(30, 20, 55, 50, 20);\n\n  describe('A white rectangle with a black outline and round edges on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Give each corner a unique radius.\n  rect(30, 20, 55, 50, 20, 15, 10, 5);\n\n  describe('A white rectangle with a black outline and round edges of different radii.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  rect(-20, -30, 55, 55);\n\n  describe('A white square with a black outline on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white square spins around on gray canvas.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the rectangle.\n  rect(-20, -30, 55, 55);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives","overloads":[{"line":1091,"params":[{"name":"x","description":"<p>x-coordinate of the rectangle.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the rectangle.<\/p>\n","type":"Number"},{"name":"w","description":"<p>width of the rectangle.<\/p>\n","type":"Number"},{"name":"h","description":"<p>height of the rectangle.<\/p>\n","type":"Number","optional":true},{"name":"tl","description":"<p>optional radius of top-left corner.<\/p>\n","type":"Number","optional":true},{"name":"tr","description":"<p>optional radius of top-right corner.<\/p>\n","type":"Number","optional":true},{"name":"br","description":"<p>optional radius of bottom-right corner.<\/p>\n","type":"Number","optional":true},{"name":"bl","description":"<p>optional radius of bottom-left corner.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1214,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"w","description":"","type":"Number"},{"name":"h","description":"","type":"Number"},{"name":"detailX","description":"<p>number of segments in the x-direction (for WebGL mode).<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of segments in the y-direction (for WebGL mode).<\/p>\n","type":"Integer","optional":true}],"chainable":1}]},{"file":"src\/core\/shape\/2d_primitives.js","line":1229,"description":"<p>Draws a square.<\/p>\n<p>A square is a four-sided shape defined by the <code>x<\/code>, <code>y<\/code>, and <code>s<\/code>\nparameters. <code>x<\/code> and <code>y<\/code> set the location of its top-left corner. <code>s<\/code> sets\nits width and height. Every angle in the square measures 90\u02da and all its\nsides are the same length. See <a href=\"#\/p5\/rectMode\">rectMode()<\/a> for\nother ways to define squares.<\/p>\n<p>The version of <code>square()<\/code> with four parameters creates a rounded square.\nThe fourth parameter sets the radius for all four corners.<\/p>\n<p>The version of <code>square()<\/code> with seven parameters also creates a rounded\nsquare. Each of the last four parameters set the radius of a corner. The\nradii start with the top-left corner and move clockwise around the\nsquare. If any of these parameters are omitted, they are set to the\nvalue of the last radius that was set.<\/p>\n","itemtype":"method","name":"square","params":[{"name":"x","description":"<p>x-coordinate of the square.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the square.<\/p>\n","type":"Number"},{"name":"s","description":"<p>side size of the square.<\/p>\n","type":"Number"},{"name":"tl","description":"<p>optional radius of top-left corner.<\/p>\n","type":"Number","optional":true},{"name":"tr","description":"<p>optional radius of top-right corner.<\/p>\n","type":"Number","optional":true},{"name":"br","description":"<p>optional radius of bottom-right corner.<\/p>\n","type":"Number","optional":true},{"name":"bl","description":"<p>optional radius of bottom-left corner.<\/p>\n","type":"Number","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  square(30, 20, 55);\n\n  describe('A white square with a black outline in on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Give all corners a radius of 20.\n  square(30, 20, 55, 20);\n\n  describe(\n    'A white square with a black outline and round edges on a gray canvas.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Give each corner a unique radius.\n  square(30, 20, 55, 20, 15, 10, 5);\n\n  describe('A white square with a black outline and round edges of different radii.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  square(-20, -30, 55);\n\n  describe('A white square with a black outline in on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white square spins around on gray canvas.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the square.\n  square(-20, -30, 55);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src\/core\/shape\/2d_primitives.js","line":1385,"description":"<p>Draws a triangle.<\/p>\n<p>A triangle is a three-sided shape defined by three points. The\nfirst two parameters specify the triangle's first point <code>(x1, y1)<\/code>. The\nmiddle two parameters specify its second point <code>(x2, y2)<\/code>. And the last two\nparameters specify its third point <code>(x3, y3)<\/code>.<\/p>\n","itemtype":"method","name":"triangle","params":[{"name":"x1","description":"<p>x-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"y1","description":"<p>y-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"x2","description":"<p>x-coordinate of the second point.<\/p>\n","type":"Number"},{"name":"y2","description":"<p>y-coordinate of the second point.<\/p>\n","type":"Number"},{"name":"x3","description":"<p>x-coordinate of the third point.<\/p>\n","type":"Number"},{"name":"y3","description":"<p>y-coordinate of the third point.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  triangle(30, 75, 58, 20, 86, 75);\n\n  describe('A white triangle with a black outline on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  triangle(-20, 25, 8, -30, 36, 25);\n\n  describe('A white triangle with a black outline on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white triangle spins around on a gray canvas.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the triangle.\n  triangle(-20, 25, 8, -30, 36, 25);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"2D Primitives"},{"file":"src\/core\/shape\/attributes.js","line":12,"description":"<p>Changes where ellipses, circles, and arcs are drawn.<\/p>\n<p>By default, the first two parameters of\n<a href=\"#\/p5\/ellipse\">ellipse()<\/a>, <a href=\"#\/p5\/circle\">circle()<\/a>,\nand <a href=\"#\/p5\/arc\">arc()<\/a>\nare the x- and y-coordinates of the shape's center. The next parameters set\nthe shape's width and height. This is the same as calling\n<code>ellipseMode(CENTER)<\/code>.<\/p>\n<p><code>ellipseMode(RADIUS)<\/code> also uses the first two parameters to set the x- and\ny-coordinates of the shape's center. The next parameters are half of the\nshapes's width and height. Calling <code>ellipse(0, 0, 10, 15)<\/code> draws a shape\nwith a width of 20 and height of 30.<\/p>\n<p><code>ellipseMode(CORNER)<\/code> uses the first two parameters as the upper-left\ncorner of the shape. The next parameters are its width and height.<\/p>\n<p><code>ellipseMode(CORNERS)<\/code> uses the first two parameters as the location of one\ncorner of the ellipse's bounding box. The next parameters are the location\nof the opposite corner.<\/p>\n<p>The argument passed to <code>ellipseMode()<\/code> must be written in ALL CAPS because\nthe constants <code>CENTER<\/code>, <code>RADIUS<\/code>, <code>CORNER<\/code>, and <code>CORNERS<\/code> are defined this\nway. JavaScript is a case-sensitive language.<\/p>\n","itemtype":"method","name":"ellipseMode","params":[{"name":"mode","description":"<p>either CENTER, RADIUS, CORNER, or CORNERS<\/p>\n","type":"Constant"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ White ellipse.\n  ellipseMode(RADIUS);\n  fill(255);\n  ellipse(50, 50, 30, 30);\n\n  \/\/ Gray ellipse.\n  ellipseMode(CENTER);\n  fill(100);\n  ellipse(50, 50, 30, 30);\n\n  describe('A white circle with a gray circle at its center. Both circles have black outlines.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ White ellipse.\n  ellipseMode(CORNER);\n  fill(255);\n  ellipse(25, 25, 50, 50);\n\n  \/\/ Gray ellipse.\n  ellipseMode(CORNERS);\n  fill(100);\n  ellipse(25, 25, 50, 50);\n\n  describe('A white circle with a gray circle at its top-left corner. Both circles have black outlines.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src\/core\/shape\/attributes.js","line":100,"description":"<p>Draws certain features with jagged (aliased) edges.<\/p>\n<p><a href=\"#\/p5\/smooth\">smooth()<\/a> is active by default. In 2D mode,\n<code>noSmooth()<\/code> is helpful for scaling up images without blurring. The\nfunctions don't affect shapes or fonts.<\/p>\n<p>In WebGL mode, <code>noSmooth()<\/code> causes all shapes to be drawn with jagged\n(aliased) edges. The functions don't affect images or fonts.<\/p>\n","itemtype":"method","name":"noSmooth","chainable":1,"example":["\n<div>\n<code>\nlet heart;\n\n\/\/ Load a pixelated heart image from an image data string.\nfunction preload() {\n  heart = loadImage('data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx\/KGPMtcAAAAASUVORK5CYII=');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Antialiased hearts.\n  image(heart, 10, 10);\n  image(heart, 20, 10, 16, 16);\n  image(heart, 40, 10, 32, 32);\n\n  \/\/ Aliased hearts.\n  noSmooth();\n  image(heart, 10, 60);\n  image(heart, 20, 60, 16, 16);\n  image(heart, 40, 60, 32, 32);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  circle(0, 0, 80);\n\n  describe('A white circle on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Disable smoothing.\n  noSmooth();\n\n  background(200);\n\n  circle(0, 0, 80);\n\n  describe('A pixelated white circle on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src\/core\/shape\/attributes.js","line":184,"description":"<p>Changes where rectangles and squares are drawn.<\/p>\n<p>By default, the first two parameters of\n<a href=\"#\/p5\/rect\">rect()<\/a> and <a href=\"#\/p5\/square\">square()<\/a>,\nare the x- and y-coordinates of the shape's upper left corner. The next parameters set\nthe shape's width and height. This is the same as calling\n<code>rectMode(CORNER)<\/code>.<\/p>\n<p><code>rectMode(CORNERS)<\/code> also uses the first two parameters as the location of\none of the corners. The next parameters are the location of the opposite\ncorner. This mode only works for <a href=\"#\/p5\/rect\">rect()<\/a>.<\/p>\n<p><code>rectMode(CENTER)<\/code> uses the first two parameters as the x- and\ny-coordinates of the shape's center. The next parameters are its width and\nheight.<\/p>\n<p><code>rectMode(RADIUS)<\/code> also uses the first two parameters as the x- and\ny-coordinates of the shape's center. The next parameters are\nhalf of the shape's width and height.<\/p>\n<p>The argument passed to <code>rectMode()<\/code> must be written in ALL CAPS because the\nconstants <code>CENTER<\/code>, <code>RADIUS<\/code>, <code>CORNER<\/code>, and <code>CORNERS<\/code> are defined this way.\nJavaScript is a case-sensitive language.<\/p>\n","itemtype":"method","name":"rectMode","params":[{"name":"mode","description":"<p>either CORNER, CORNERS, CENTER, or RADIUS<\/p>\n","type":"Constant"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  rectMode(CORNER);\n  fill(255);\n  rect(25, 25, 50, 50);\n\n  rectMode(CORNERS);\n  fill(100);\n  rect(25, 25, 50, 50);\n\n  describe('A small gray square drawn at the top-left corner of a white square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  rectMode(RADIUS);\n  fill(255);\n  rect(50, 50, 30, 30);\n\n  rectMode(CENTER);\n  fill(100);\n  rect(50, 50, 30, 30);\n\n  describe('A small gray square drawn at the center of a white square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  rectMode(CORNER);\n  fill(255);\n  square(25, 25, 50);\n\n  describe('A white square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  rectMode(RADIUS);\n  fill(255);\n  square(50, 50, 30);\n\n  rectMode(CENTER);\n  fill(100);\n  square(50, 50, 30);\n\n  describe('A small gray square drawn at the center of a white square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src\/core\/shape\/attributes.js","line":303,"description":"<p>Draws certain features with smooth (antialiased) edges.<\/p>\n<p><code>smooth()<\/code> is active by default. In 2D mode,\n<a href=\"#\/p5\/noSmooth\">noSmooth()<\/a> is helpful for scaling up images\nwithout blurring. The functions don't affect shapes or fonts.<\/p>\n<p>In WebGL mode, <a href=\"#\/p5\/noSmooth\">noSmooth()<\/a> causes all shapes to\nbe drawn with jagged (aliased) edges. The functions don't affect images or\nfonts.<\/p>\n","itemtype":"method","name":"smooth","chainable":1,"example":["\n<div>\n<code>\nlet heart;\n\n\/\/ Load a pixelated heart image from an image data string.\nfunction preload() {\n  heart = loadImage('data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx\/KGPMtcAAAAASUVORK5CYII=');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Antialiased hearts.\n  image(heart, 10, 10);\n  image(heart, 20, 10, 16, 16);\n  image(heart, 40, 10, 32, 32);\n\n  \/\/ Aliased hearts.\n  noSmooth();\n  image(heart, 10, 60);\n  image(heart, 20, 60, 16, 16);\n  image(heart, 40, 60, 32, 32);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  circle(0, 0, 80);\n\n  describe('A white circle on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Disable smoothing.\n  noSmooth();\n\n  background(200);\n\n  circle(0, 0, 80);\n\n  describe('A pixelated white circle on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src\/core\/shape\/attributes.js","line":388,"description":"<p>Sets the style for rendering the ends of lines.<\/p>\n<p>The caps for line endings are either rounded (<code>ROUND<\/code>), squared\n(<code>SQUARE<\/code>), or extended (<code>PROJECT<\/code>). The default cap is <code>ROUND<\/code>.<\/p>\n<p>The argument passed to <code>strokeCap()<\/code> must be written in ALL CAPS because\nthe constants <code>ROUND<\/code>, <code>SQUARE<\/code>, and <code>PROJECT<\/code> are defined this way.\nJavaScript is a case-sensitive language.<\/p>\n","itemtype":"method","name":"strokeCap","params":[{"name":"cap","description":"<p>either ROUND, SQUARE, or PROJECT<\/p>\n","type":"Constant"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  strokeWeight(12);\n\n  \/\/ Top.\n  strokeCap(ROUND);\n  line(20, 30, 80, 30);\n\n  \/\/ Middle.\n  strokeCap(SQUARE);\n  line(20, 50, 80, 50);\n\n  \/\/ Bottom.\n  strokeCap(PROJECT);\n  line(20, 70, 80, 70);\n\n  describe(\n    'Three horizontal lines. The top line has rounded ends, the middle line has squared ends, and the bottom line has longer, squared ends.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src\/core\/shape\/attributes.js","line":442,"description":"<p>Sets the style of the joints that connect line segments.<\/p>\n<p>Joints are either mitered (<code>MITER<\/code>), beveled (<code>BEVEL<\/code>), or rounded\n(<code>ROUND<\/code>). The default joint is <code>MITER<\/code> in 2D mode and <code>ROUND<\/code> in WebGL\nmode.<\/p>\n<p>The argument passed to <code>strokeJoin()<\/code> must be written in ALL CAPS because\nthe constants <code>MITER<\/code>, <code>BEVEL<\/code>, and <code>ROUND<\/code> are defined this way.\nJavaScript is a case-sensitive language.<\/p>\n","itemtype":"method","name":"strokeJoin","params":[{"name":"join","description":"<p>either MITER, BEVEL, or ROUND<\/p>\n","type":"Constant"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the line.\n  noFill();\n  strokeWeight(10);\n  strokeJoin(MITER);\n\n  \/\/ Draw the line.\n  beginShape();\n  vertex(35, 20);\n  vertex(65, 50);\n  vertex(35, 80);\n  endShape();\n\n  describe('A right-facing arrowhead shape with a pointed tip in center of canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the line.\n  noFill();\n  strokeWeight(10);\n  strokeJoin(BEVEL);\n\n  \/\/ Draw the line.\n  beginShape();\n  vertex(35, 20);\n  vertex(65, 50);\n  vertex(35, 80);\n  endShape();\n\n  describe('A right-facing arrowhead shape with a flat tip in center of canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the line.\n  noFill();\n  strokeWeight(10);\n  strokeJoin(ROUND);\n\n  \/\/ Draw the line.\n  beginShape();\n  vertex(35, 20);\n  vertex(65, 50);\n  vertex(35, 80);\n  endShape();\n\n  describe('A right-facing arrowhead shape with a rounded tip in center of canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src\/core\/shape\/attributes.js","line":541,"description":"<p>Sets the width of the stroke used for points, lines, and the outlines of\nshapes.<\/p>\n<p>Note: <code>strokeWeight()<\/code> is affected by transformations, especially calls to\n<a href=\"#\/p5\/scale\">scale()<\/a>.<\/p>\n","itemtype":"method","name":"strokeWeight","params":[{"name":"weight","description":"<p>the weight of the stroke (in pixels).<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top.\n  line(20, 20, 80, 20);\n\n  \/\/ Middle.\n  strokeWeight(4);\n  line(20, 40, 80, 40);\n\n  \/\/ Bottom.\n  strokeWeight(10);\n  line(20, 70, 80, 70);\n\n  describe('Three horizontal black lines. The top line is thin, the middle is medium, and the bottom is thick.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top.\n  line(20, 20, 80, 20);\n\n  \/\/ Scale by a factor of 5.\n  scale(5);\n\n  \/\/ Bottom. Coordinates are adjusted for scaling.\n  line(4, 8, 16, 8);\n\n  describe('Two horizontal black lines. The top line is thin and the bottom is five times thicker than the top.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Attributes"},{"file":"src\/core\/shape\/curves.js","line":13,"description":"<p>Draws a B\u00e9zier curve.<\/p>\n<p>B\u00e9zier curves can form shapes and curves that slope gently. They're defined\nby two anchor points and two control points. B\u00e9zier curves provide more\ncontrol than the spline curves created with the\n<a href=\"#\/p5\/curve\">curve()<\/a> function.<\/p>\n<p>The first two parameters, <code>x1<\/code> and <code>y1<\/code>, set the first anchor point. The\nfirst anchor point is where the curve starts.<\/p>\n<p>The next four parameters, <code>x2<\/code>, <code>y2<\/code>, <code>x3<\/code>, and <code>y3<\/code>, set the two control\npoints. The control points \"pull\" the curve towards them.<\/p>\n<p>The seventh and eighth parameters, <code>x4<\/code> and <code>y4<\/code>, set the last anchor\npoint. The last anchor point is where the curve ends.<\/p>\n<p>B\u00e9zier curves can also be drawn in 3D using WebGL mode. The 3D version of\n<code>bezier()<\/code> has twelve arguments because each point has x-, y-,\nand z-coordinates.<\/p>\n","itemtype":"method","name":"bezier","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  strokeWeight(5);\n  point(85, 20);\n  point(15, 80);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(10, 10);\n  point(90, 90);\n\n  \/\/ Draw a black bezier curve.\n  noFill();\n  stroke(0);\n  strokeWeight(1);\n  bezier(85, 20, 10, 10, 90, 90, 15, 80);\n\n  \/\/ Draw red lines from the anchor points to the control points.\n  stroke(255, 0, 0);\n  line(85, 20, 10, 10);\n  line(15, 80, 90, 90);\n\n  describe(\n    'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the mouse near the red dot in the top-left corner\n\/\/ and drag to change the curve's shape.\n\nlet x2 = 10;\nlet y2 = 10;\nlet isChanging = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  strokeWeight(5);\n  point(85, 20);\n  point(15, 80);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(x2, y2);\n  point(90, 90);\n\n  \/\/ Draw a black bezier curve.\n  noFill();\n  stroke(0);\n  strokeWeight(1);\n  bezier(85, 20, x2, y2, 90, 90, 15, 80);\n\n  \/\/ Draw red lines from the anchor points to the control points.\n  stroke(255, 0, 0);\n  line(85, 20, x2, y2);\n  line(15, 80, 90, 90);\n}\n\n\/\/ Start changing the first control point if the user clicks near it.\nfunction mousePressed() {\n  if (dist(mouseX, mouseY, x2, y2) < 20) {\n    isChanging = true;\n  }\n}\n\n\/\/ Stop changing the first control point when the user releases the mouse.\nfunction mouseReleased() {\n  isChanging = false;\n}\n\n\/\/ Update the first control point while the user drags the mouse.\nfunction mouseDragged() {\n  if (isChanging === true) {\n    x2 = mouseX;\n    y2 = mouseY;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background('skyblue');\n\n  \/\/ Draw the red balloon.\n  fill('red');\n  bezier(50, 60, 5, 15, 95, 15, 50, 60);\n\n  \/\/ Draw the balloon string.\n  line(50, 60, 50, 80);\n\n  describe('A red balloon in a blue sky.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A red balloon in a blue sky. The balloon rotates slowly, revealing that it is flat.');\n}\n\nfunction draw() {\n  background('skyblue');\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the red balloon.\n  fill('red');\n  bezier(0, 0, 0, -45, -45, 0, 45, -45, 0, 0, 0, 0);\n\n  \/\/ Draw the balloon string.\n  line(0, 0, 0, 0, 20, 0);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves","overloads":[{"line":13,"params":[{"name":"x1","description":"<p>x-coordinate of the first anchor point.<\/p>\n","type":"Number"},{"name":"y1","description":"<p>y-coordinate of the first anchor point.<\/p>\n","type":"Number"},{"name":"x2","description":"<p>x-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"y2","description":"<p>y-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"x3","description":"<p>x-coordinate of the second control point.<\/p>\n","type":"Number"},{"name":"y3","description":"<p>y-coordinate of the second control point.<\/p>\n","type":"Number"},{"name":"x4","description":"<p>x-coordinate of the second anchor point.<\/p>\n","type":"Number"},{"name":"y4","description":"<p>y-coordinate of the second anchor point.<\/p>\n","type":"Number"}],"chainable":1},{"line":191,"params":[{"name":"x1","description":"","type":"Number"},{"name":"y1","description":"","type":"Number"},{"name":"z1","description":"<p>z-coordinate of the first anchor point.<\/p>\n","type":"Number"},{"name":"x2","description":"","type":"Number"},{"name":"y2","description":"","type":"Number"},{"name":"z2","description":"<p>z-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"x3","description":"","type":"Number"},{"name":"y3","description":"","type":"Number"},{"name":"z3","description":"<p>z-coordinate of the second control point.<\/p>\n","type":"Number"},{"name":"x4","description":"","type":"Number"},{"name":"y4","description":"","type":"Number"},{"name":"z4","description":"<p>z-coordinate of the second anchor point.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/core\/shape\/curves.js","line":221,"description":"<p>Sets the number of segments used to draw B\u00e9zier curves in WebGL mode.<\/p>\n<p>In WebGL mode, smooth shapes are drawn using many flat segments. Adding\nmore flat segments makes shapes appear smoother.<\/p>\n<p>The parameter, <code>detail<\/code>, is the number of segments to use while drawing a\nB\u00e9zier curve. For example, calling <code>bezierDetail(5)<\/code> will use 5 segments to\ndraw curves with the <a href=\"#\/p5\/bezier\">bezier()<\/a> function. By\ndefault,<code>detail<\/code> is 20.<\/p>\n<p>Note: <code>bezierDetail()<\/code> has no effect in 2D mode.<\/p>\n","itemtype":"method","name":"bezierDetail","params":[{"name":"detail","description":"<p>number of segments to use. Defaults to 20.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Draw the original curve.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  strokeWeight(5);\n  point(85, 20);\n  point(15, 80);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(10, 10);\n  point(90, 90);\n\n  \/\/ Draw a black bezier curve.\n  noFill();\n  stroke(0);\n  strokeWeight(1);\n  bezier(85, 20, 10, 10, 90, 90, 15, 80);\n\n  \/\/ Draw red lines from the anchor points to the control points.\n  stroke(255, 0, 0);\n  line(85, 20, 10, 10);\n  line(15, 80, 90, 90);\n\n  describe(\n    'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Draw the curve with less detail.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Set the curveDetail() to 5.\n  bezierDetail(5);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  strokeWeight(5);\n  point(35, -30, 0);\n  point(-35, 30, 0);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(-40, -40, 0);\n  point(40, 40, 0);\n\n  \/\/ Draw a black bezier curve.\n  noFill();\n  stroke(0);\n  strokeWeight(1);\n  bezier(35, -30, 0, -40, -40, 0, 40, 40, 0, -35, 30, 0);\n\n  \/\/ Draw red lines from the anchor points to the control points.\n  stroke(255, 0, 0);\n  line(35, -30, -40, -40);\n  line(-35, 30, 40, 40);\n\n  describe(\n    'A gray square with three curves. A black s-curve is drawn with jagged segments. Two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src\/core\/shape\/curves.js","line":324,"description":"<p>Calculates coordinates along a B\u00e9zier curve using interpolation.<\/p>\n<p><code>bezierPoint()<\/code> calculates coordinates along a B\u00e9zier curve using the\nanchor and control points. It expects points in the same order as the\n<a href=\"#\/p5\/bezier\">bezier()<\/a> function. <code>bezierPoint()<\/code> works one axis\nat a time. Passing the anchor and control points' x-coordinates will\ncalculate the x-coordinate of a point on the curve. Passing the anchor and\ncontrol points' y-coordinates will calculate the y-coordinate of a point on\nthe curve.<\/p>\n<p>The first parameter, <code>a<\/code>, is the coordinate of the first anchor point.<\/p>\n<p>The second and third parameters, <code>b<\/code> and <code>c<\/code>, are the coordinates of the\ncontrol points.<\/p>\n<p>The fourth parameter, <code>d<\/code>, is the coordinate of the last anchor point.<\/p>\n<p>The fifth parameter, <code>t<\/code>, is the amount to interpolate along the curve. 0\nis the first anchor point, 1 is the second anchor point, and 0.5 is halfway\nbetween them.<\/p>\n","itemtype":"method","name":"bezierPoint","params":[{"name":"a","description":"<p>coordinate of first anchor point.<\/p>\n","type":"Number"},{"name":"b","description":"<p>coordinate of first control point.<\/p>\n","type":"Number"},{"name":"c","description":"<p>coordinate of second control point.<\/p>\n","type":"Number"},{"name":"d","description":"<p>coordinate of second anchor point.<\/p>\n","type":"Number"},{"name":"t","description":"<p>amount to interpolate between 0 and 1.<\/p>\n","type":"Number"}],"return":{"description":"coordinate of the point on the curve.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the coordinates for the curve's anchor and control points.\n  let x1 = 85;\n  let x2 = 10;\n  let x3 = 90;\n  let x4 = 15;\n  let y1 = 20;\n  let y2 = 10;\n  let y3 = 90;\n  let y4 = 80;\n\n  \/\/ Style the curve.\n  noFill();\n\n  \/\/ Draw the curve.\n  bezier(x1, y1, x2, y2, x3, y3, x4, y4);\n\n  \/\/ Draw circles along the curve's path.\n  fill(255);\n\n  \/\/ Top-right.\n  let x = bezierPoint(x1, x2, x3, x4, 0);\n  let y = bezierPoint(y1, y2, y3, y4, 0);\n  circle(x, y, 5);\n\n  \/\/ Center.\n  x = bezierPoint(x1, x2, x3, x4, 0.5);\n  y = bezierPoint(y1, y2, y3, y4, 0.5);\n  circle(x, y, 5);\n\n  \/\/ Bottom-left.\n  x = bezierPoint(x1, x2, x3, x4, 1);\n  y = bezierPoint(y1, y2, y3, y4, 1);\n  circle(x, y, 5);\n\n  describe('A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black s-curve on a gray square. A white circle moves back and forth along the curve.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the coordinates for the curve's anchor and control points.\n  let x1 = 85;\n  let x2 = 10;\n  let x3 = 90;\n  let x4 = 15;\n  let y1 = 20;\n  let y2 = 10;\n  let y3 = 90;\n  let y4 = 80;\n\n  \/\/ Draw the curve.\n  noFill();\n  bezier(x1, y1, x2, y2, x3, y3, x4, y4);\n\n  \/\/ Calculate the circle's coordinates.\n  let t = 0.5 * sin(frameCount * 0.01) + 0.5;\n  let x = bezierPoint(x1, x2, x3, x4, t);\n  let y = bezierPoint(y1, y2, y3, y4, t);\n\n  \/\/ Draw the circle.\n  fill(255);\n  circle(x, y, 5);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src\/core\/shape\/curves.js","line":450,"description":"<p>Calculates coordinates along a line that's tangent to a B\u00e9zier curve.<\/p>\n<p>Tangent lines skim the surface of a curve. A tangent line's slope equals\nthe curve's slope at the point where it intersects.<\/p>\n<p><code>bezierTangent()<\/code> calculates coordinates along a tangent line using the\nB\u00e9zier curve's anchor and control points. It expects points in the same\norder as the <a href=\"#\/p5\/bezier\">bezier()<\/a> function. <code>bezierTangent()<\/code>\nworks one axis at a time. Passing the anchor and control points'\nx-coordinates will calculate the x-coordinate of a point on the tangent\nline. Passing the anchor and control points' y-coordinates will calculate\nthe y-coordinate of a point on the tangent line.<\/p>\n<p>The first parameter, <code>a<\/code>, is the coordinate of the first anchor point.<\/p>\n<p>The second and third parameters, <code>b<\/code> and <code>c<\/code>, are the coordinates of the\ncontrol points.<\/p>\n<p>The fourth parameter, <code>d<\/code>, is the coordinate of the last anchor point.<\/p>\n<p>The fifth parameter, <code>t<\/code>, is the amount to interpolate along the curve. 0\nis the first anchor point, 1 is the second anchor point, and 0.5 is halfway\nbetween them.<\/p>\n","itemtype":"method","name":"bezierTangent","params":[{"name":"a","description":"<p>coordinate of first anchor point.<\/p>\n","type":"Number"},{"name":"b","description":"<p>coordinate of first control point.<\/p>\n","type":"Number"},{"name":"c","description":"<p>coordinate of second control point.<\/p>\n","type":"Number"},{"name":"d","description":"<p>coordinate of second anchor point.<\/p>\n","type":"Number"},{"name":"t","description":"<p>amount to interpolate between 0 and 1.<\/p>\n","type":"Number"}],"return":{"description":"coordinate of a point on the tangent line.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the coordinates for the curve's anchor and control points.\n  let x1 = 85;\n  let x2 = 10;\n  let x3 = 90;\n  let x4 = 15;\n  let y1 = 20;\n  let y2 = 10;\n  let y3 = 90;\n  let y4 = 80;\n\n  \/\/ Style the curve.\n  noFill();\n\n  \/\/ Draw the curve.\n  bezier(x1, y1, x2, y2, x3, y3, x4, y4);\n\n  \/\/ Draw tangents along the curve's path.\n  fill(255);\n\n  \/\/ Top-right circle.\n  stroke(0);\n  let x = bezierPoint(x1, x2, x3, x4, 0);\n  let y = bezierPoint(y1, y2, y3, y4, 0);\n  circle(x, y, 5);\n\n  \/\/ Top-right tangent line.\n  \/\/ Scale the tangent point to draw a shorter line.\n  stroke(255, 0, 0);\n  let tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0);\n  let ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0);\n  line(x + tx, y + ty, x - tx, y - ty);\n\n  \/\/ Center circle.\n  stroke(0);\n  x = bezierPoint(x1, x2, x3, x4, 0.5);\n  y = bezierPoint(y1, y2, y3, y4, 0.5);\n  circle(x, y, 5);\n\n  \/\/ Center tangent line.\n  \/\/ Scale the tangent point to draw a shorter line.\n  stroke(255, 0, 0);\n  tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0.5);\n  ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0.5);\n  line(x + tx, y + ty, x - tx, y - ty);\n\n  \/\/ Bottom-left circle.\n  stroke(0);\n  x = bezierPoint(x1, x2, x3, x4, 1);\n  y = bezierPoint(y1, y2, y3, y4, 1);\n  circle(x, y, 5);\n\n  \/\/ Bottom-left tangent.\n  \/\/ Scale the tangent point to draw a shorter line.\n  stroke(255, 0, 0);\n  tx = 0.1 * bezierTangent(x1, x2, x3, x4, 1);\n  ty = 0.1 * bezierTangent(y1, y2, y3, y4, 1);\n  line(x + tx, y + ty, x - tx, y - ty);\n\n  describe(\n    'A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles. Red tangent lines extend from the white circles.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src\/core\/shape\/curves.js","line":570,"description":"<p>Draws a curve using a Catmull-Rom spline.<\/p>\n<p>Spline curves can form shapes and curves that slope gently. They\u2019re like\ncables that are attached to a set of points. Splines are defined by two\nanchor points and two control points.<\/p>\n<p>The first two parameters, <code>x1<\/code> and <code>y1<\/code>, set the first control point. This\npoint isn\u2019t drawn and can be thought of as the curve\u2019s starting point.<\/p>\n<p>The next four parameters, <code>x2<\/code>, <code>y2<\/code>, <code>x3<\/code>, and <code>y3<\/code>, set the two anchor\npoints. The anchor points are the start and end points of the curve\u2019s\nvisible segment.<\/p>\n<p>The seventh and eighth parameters, <code>x4<\/code> and <code>y4<\/code>, set the last control\npoint. This point isn\u2019t drawn and can be thought of as the curve\u2019s ending\npoint.<\/p>\n<p>Spline curves can also be drawn in 3D using WebGL mode. The 3D version of\n<code>curve()<\/code> has twelve arguments because each point has x-, y-, and\nz-coordinates.<\/p>\n","itemtype":"method","name":"curve","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw a black spline curve.\n  noFill();\n  strokeWeight(1);\n  stroke(0);\n  curve(5, 26, 73, 24, 73, 61, 15, 65);\n\n  \/\/ Draw red spline curves from the anchor points to the control points.\n  stroke(255, 0, 0);\n  curve(5, 26, 5, 26, 73, 24, 73, 61);\n  curve(73, 24, 73, 61, 15, 65, 15, 65);\n\n  \/\/ Draw the anchor points in black.\n  strokeWeight(5);\n  stroke(0);\n  point(73, 24);\n  point(73, 61);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(5, 26);\n  point(15, 65);\n\n  describe(\n    'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet x1 = 5;\nlet y1 = 26;\nlet isChanging = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a black spline curve.\n  noFill();\n  strokeWeight(1);\n  stroke(0);\n  curve(x1, y1, 73, 24, 73, 61, 15, 65);\n\n  \/\/ Draw red spline curves from the anchor points to the control points.\n  stroke(255, 0, 0);\n  curve(x1, y1, x1, y1, 73, 24, 73, 61);\n  curve(73, 24, 73, 61, 15, 65, 15, 65);\n\n  \/\/ Draw the anchor points in black.\n  strokeWeight(5);\n  stroke(0);\n  point(73, 24);\n  point(73, 61);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(x1, y1);\n  point(15, 65);\n}\n\n\/\/ Start changing the first control point if the user clicks near it.\nfunction mousePressed() {\n  if (dist(mouseX, mouseY, x1, y1) < 20) {\n    isChanging = true;\n  }\n}\n\n\/\/ Stop changing the first control point when the user releases the mouse.\nfunction mouseReleased() {\n  isChanging = false;\n}\n\n\/\/ Update the first control point while the user drags the mouse.\nfunction mouseDragged() {\n  if (isChanging === true) {\n    x1 = mouseX;\n    y1 = mouseY;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background('skyblue');\n\n  \/\/ Draw the red balloon.\n  fill('red');\n  curve(-150, 275, 50, 60, 50, 60, 250, 275);\n\n  \/\/ Draw the balloon string.\n  line(50, 60, 50, 80);\n\n  describe('A red balloon in a blue sky.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A red balloon in a blue sky.');\n}\n\nfunction draw() {\n  background('skyblue');\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Draw the red balloon.\n  fill('red');\n  curve(-200, 225, 0, 0, 10, 0, 0, 10, 0, 200, 225, 0);\n\n  \/\/ Draw the balloon string.\n  line(0, 10, 0, 0, 30, 0);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves","overloads":[{"line":570,"params":[{"name":"x1","description":"<p>x-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"y1","description":"<p>y-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"x2","description":"<p>x-coordinate of the first anchor point.<\/p>\n","type":"Number"},{"name":"y2","description":"<p>y-coordinate of the first anchor point.<\/p>\n","type":"Number"},{"name":"x3","description":"<p>x-coordinate of the second anchor point.<\/p>\n","type":"Number"},{"name":"y3","description":"<p>y-coordinate of the second anchor point.<\/p>\n","type":"Number"},{"name":"x4","description":"<p>x-coordinate of the second control point.<\/p>\n","type":"Number"},{"name":"y4","description":"<p>y-coordinate of the second control point.<\/p>\n","type":"Number"}],"chainable":1},{"line":746,"params":[{"name":"x1","description":"","type":"Number"},{"name":"y1","description":"","type":"Number"},{"name":"z1","description":"<p>z-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"x2","description":"","type":"Number"},{"name":"y2","description":"","type":"Number"},{"name":"z2","description":"<p>z-coordinate of the first anchor point.<\/p>\n","type":"Number"},{"name":"x3","description":"","type":"Number"},{"name":"y3","description":"","type":"Number"},{"name":"z3","description":"<p>z-coordinate of the second anchor point.<\/p>\n","type":"Number"},{"name":"x4","description":"","type":"Number"},{"name":"y4","description":"","type":"Number"},{"name":"z4","description":"<p>z-coordinate of the second control point.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/core\/shape\/curves.js","line":772,"description":"<p>Sets the number of segments used to draw spline curves in WebGL mode.<\/p>\n<p>In WebGL mode, smooth shapes are drawn using many flat segments. Adding\nmore flat segments makes shapes appear smoother.<\/p>\n<p>The parameter, <code>detail<\/code>, is the number of segments to use while drawing a\nspline curve. For example, calling <code>curveDetail(5)<\/code> will use 5 segments to\ndraw curves with the <a href=\"#\/p5\/curve\">curve()<\/a> function. By\ndefault,<code>detail<\/code> is 20.<\/p>\n<p>Note: <code>curveDetail()<\/code> has no effect in 2D mode.<\/p>\n","itemtype":"method","name":"curveDetail","params":[{"name":"resolution","description":"<p>number of segments to use. Defaults to 20.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw a black spline curve.\n  noFill();\n  strokeWeight(1);\n  stroke(0);\n  curve(5, 26, 73, 24, 73, 61, 15, 65);\n\n  \/\/ Draw red spline curves from the anchor points to the control points.\n  stroke(255, 0, 0);\n  curve(5, 26, 5, 26, 73, 24, 73, 61);\n  curve(73, 24, 73, 61, 15, 65, 15, 65);\n\n  \/\/ Draw the anchor points in black.\n  strokeWeight(5);\n  stroke(0);\n  point(73, 24);\n  point(73, 61);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(5, 26);\n  point(15, 65);\n\n  describe(\n    'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Set the curveDetail() to 3.\n  curveDetail(3);\n\n  \/\/ Draw a black spline curve.\n  noFill();\n  strokeWeight(1);\n  stroke(0);\n  curve(-45, -24, 0, 23, -26, 0, 23, 11, 0, -35, 15, 0);\n\n  \/\/ Draw red spline curves from the anchor points to the control points.\n  stroke(255, 0, 0);\n  curve(-45, -24, 0, -45, -24, 0, 23, -26, 0, 23, 11, 0);\n  curve(23, -26, 0, 23, 11, 0, -35, 15, 0, -35, 15, 0);\n\n  \/\/ Draw the anchor points in black.\n  strokeWeight(5);\n  stroke(0);\n  point(23, -26);\n  point(23, 11);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(-45, -24);\n  point(-35, 15);\n\n  describe(\n    'A gray square with a jagged curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src\/core\/shape\/curves.js","line":875,"description":"<p>Adjusts the way <a href=\"#\/p5\/curve\">curve()<\/a> and\n<a href=\"#\/p5\/curveVertex\">curveVertex()<\/a> draw.<\/p>\n<p>Spline curves are like cables that are attached to a set of points.\n<code>curveTightness()<\/code> adjusts how tightly the cable is attached to the points.<\/p>\n<p>The parameter, <code>tightness<\/code>, determines how the curve fits to the vertex\npoints. By default, <code>tightness<\/code> is set to 0. Setting tightness to 1,\nas in <code>curveTightness(1)<\/code>, connects the curve's points using straight\nlines. Values in the range from \u20135 to  5 deform curves while leaving them\nrecognizable.<\/p>\n","itemtype":"method","name":"curveTightness","params":[{"name":"amount","description":"<p>amount of tightness.<\/p>\n","type":"Number"}],"chainable":1,"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\n  describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the curve's tightness using the mouse.\n  let t = map(mouseX, 0, 100, -5, 5, true);\n  curveTightness(t);\n\n  \/\/ Draw the curve.\n  noFill();\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\/shape\/curves.js","line":930,"description":"<p>Calculates coordinates along a spline curve using interpolation.<\/p>\n<p><code>curvePoint()<\/code> calculates coordinates along a spline curve using the\nanchor and control points. It expects points in the same order as the\n<a href=\"#\/p5\/curve\">curve()<\/a> function. <code>curvePoint()<\/code> works one axis\nat a time. Passing the anchor and control points' x-coordinates will\ncalculate the x-coordinate of a point on the curve. Passing the anchor and\ncontrol points' y-coordinates will calculate the y-coordinate of a point on\nthe curve.<\/p>\n<p>The first parameter, <code>a<\/code>, is the coordinate of the first control point.<\/p>\n<p>The second and third parameters, <code>b<\/code> and <code>c<\/code>, are the coordinates of the\nanchor points.<\/p>\n<p>The fourth parameter, <code>d<\/code>, is the coordinate of the last control point.<\/p>\n<p>The fifth parameter, <code>t<\/code>, is the amount to interpolate along the curve. 0\nis the first anchor point, 1 is the second anchor point, and 0.5 is halfway\nbetween them.<\/p>\n","itemtype":"method","name":"curvePoint","params":[{"name":"a","description":"<p>coordinate of first control point.<\/p>\n","type":"Number"},{"name":"b","description":"<p>coordinate of first anchor point.<\/p>\n","type":"Number"},{"name":"c","description":"<p>coordinate of second anchor point.<\/p>\n","type":"Number"},{"name":"d","description":"<p>coordinate of second control point.<\/p>\n","type":"Number"},{"name":"t","description":"<p>amount to interpolate between 0 and 1.<\/p>\n","type":"Number"}],"return":{"description":"coordinate of a point on the curve.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the coordinates for the curve's anchor and control points.\n  let x1 = 5;\n  let y1 = 26;\n  let x2 = 73;\n  let y2 = 24;\n  let x3 = 73;\n  let y3 = 61;\n  let x4 = 15;\n  let y4 = 65;\n\n  \/\/ Draw the curve.\n  noFill();\n  curve(x1, y1, x2, y2, x3, y3, x4, y4);\n\n  \/\/ Draw circles along the curve's path.\n  fill(255);\n\n  \/\/ Top.\n  let x = curvePoint(x1, x2, x3, x4, 0);\n  let y = curvePoint(y1, y2, y3, y4, 0);\n  circle(x, y, 5);\n\n  \/\/ Center.\n  x = curvePoint(x1, x2, x3, x4, 0.5);\n  y = curvePoint(y1, y2, y3, y4, 0.5);\n  circle(x, y, 5);\n\n  \/\/ Bottom.\n  x = curvePoint(x1, x2, x3, x4, 1);\n  y = curvePoint(y1, y2, y3, y4, 1);\n  circle(x, y, 5);\n\n  describe('A black curve on a gray square. The endpoints and center of the curve are marked with white circles.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black curve on a gray square. A white circle moves back and forth along the curve.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the coordinates for the curve's anchor and control points.\n  let x1 = 5;\n  let y1 = 26;\n  let x2 = 73;\n  let y2 = 24;\n  let x3 = 73;\n  let y3 = 61;\n  let x4 = 15;\n  let y4 = 65;\n\n  \/\/ Draw the curve.\n  noFill();\n  curve(x1, y1, x2, y2, x3, y3, x4, y4);\n\n  \/\/ Calculate the circle's coordinates.\n  let t = 0.5 * sin(frameCount * 0.01) + 0.5;\n  let x = curvePoint(x1, x2, x3, x4, t);\n  let y = curvePoint(y1, y2, y3, y4, t);\n\n  \/\/ Draw the circle.\n  fill(255);\n  circle(x, y, 5);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src\/core\/shape\/curves.js","line":1054,"description":"<p>Calculates coordinates along a line that's tangent to a spline curve.<\/p>\n<p>Tangent lines skim the surface of a curve. A tangent line's slope equals\nthe curve's slope at the point where it intersects.<\/p>\n<p><code>curveTangent()<\/code> calculates coordinates along a tangent line using the\nspline curve's anchor and control points. It expects points in the same\norder as the <a href=\"#\/p5\/curve\">curve()<\/a> function. <code>curveTangent()<\/code>\nworks one axis at a time. Passing the anchor and control points'\nx-coordinates will calculate the x-coordinate of a point on the tangent\nline. Passing the anchor and control points' y-coordinates will calculate\nthe y-coordinate of a point on the tangent line.<\/p>\n<p>The first parameter, <code>a<\/code>, is the coordinate of the first control point.<\/p>\n<p>The second and third parameters, <code>b<\/code> and <code>c<\/code>, are the coordinates of the\nanchor points.<\/p>\n<p>The fourth parameter, <code>d<\/code>, is the coordinate of the last control point.<\/p>\n<p>The fifth parameter, <code>t<\/code>, is the amount to interpolate along the curve. 0\nis the first anchor point, 1 is the second anchor point, and 0.5 is halfway\nbetween them.<\/p>\n","itemtype":"method","name":"curveTangent","params":[{"name":"a","description":"<p>coordinate of first control point.<\/p>\n","type":"Number"},{"name":"b","description":"<p>coordinate of first anchor point.<\/p>\n","type":"Number"},{"name":"c","description":"<p>coordinate of second anchor point.<\/p>\n","type":"Number"},{"name":"d","description":"<p>coordinate of second control point.<\/p>\n","type":"Number"},{"name":"t","description":"<p>amount to interpolate between 0 and 1.<\/p>\n","type":"Number"}],"return":{"description":"coordinate of a point on the tangent line.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the coordinates for the curve's anchor and control points.\n  let x1 = 5;\n  let y1 = 26;\n  let x2 = 73;\n  let y2 = 24;\n  let x3 = 73;\n  let y3 = 61;\n  let x4 = 15;\n  let y4 = 65;\n\n  \/\/ Draw the curve.\n  noFill();\n  curve(x1, y1, x2, y2, x3, y3, x4, y4);\n\n  \/\/ Draw tangents along the curve's path.\n  fill(255);\n\n  \/\/ Top circle.\n  stroke(0);\n  let x = curvePoint(x1, x2, x3, x4, 0);\n  let y = curvePoint(y1, y2, y3, y4, 0);\n  circle(x, y, 5);\n\n  \/\/ Top tangent line.\n  \/\/ Scale the tangent point to draw a shorter line.\n  stroke(255, 0, 0);\n  let tx = 0.2 * curveTangent(x1, x2, x3, x4, 0);\n  let ty = 0.2 * curveTangent(y1, y2, y3, y4, 0);\n  line(x + tx, y + ty, x - tx, y - ty);\n\n  \/\/ Center circle.\n  stroke(0);\n  x = curvePoint(x1, x2, x3, x4, 0.5);\n  y = curvePoint(y1, y2, y3, y4, 0.5);\n  circle(x, y, 5);\n\n  \/\/ Center tangent line.\n  \/\/ Scale the tangent point to draw a shorter line.\n  stroke(255, 0, 0);\n  tx = 0.2 * curveTangent(x1, x2, x3, x4, 0.5);\n  ty = 0.2 * curveTangent(y1, y2, y3, y4, 0.5);\n  line(x + tx, y + ty, x - tx, y - ty);\n\n  \/\/ Bottom circle.\n  stroke(0);\n  x = curvePoint(x1, x2, x3, x4, 1);\n  y = curvePoint(y1, y2, y3, y4, 1);\n  circle(x, y, 5);\n\n  \/\/ Bottom tangent line.\n  \/\/ Scale the tangent point to draw a shorter line.\n  stroke(255, 0, 0);\n  tx = 0.2 * curveTangent(x1, x2, x3, x4, 1);\n  ty = 0.2 * curveTangent(y1, y2, y3, y4, 1);\n  line(x + tx, y + ty, x - tx, y - ty);\n\n  describe(\n    'A black curve on a gray square. A white circle moves back and forth along the curve.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Curves"},{"file":"src\/core\/shape\/vertex.js","line":20,"description":"<p>Begins creating a hole within a flat shape.<\/p>\n<p>The <code>beginContour()<\/code> and <a href=\"#\/p5\/endContour\">endContour()<\/a>\nfunctions allow for creating negative space within custom shapes that are\nflat. <code>beginContour()<\/code> begins adding vertices to a negative space and\n<a href=\"#\/p5\/endContour\">endContour()<\/a> stops adding them.\n<code>beginContour()<\/code> and <a href=\"#\/p5\/endContour\">endContour()<\/a> must be\ncalled between <a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a>.<\/p>\n<p>Transformations such as <a href=\"#\/p5\/translate\">translate()<\/a>,\n<a href=\"#\/p5\/rotate\">rotate()<\/a>, and <a href=\"#\/p5\/scale\">scale()<\/a>\ndon't work between <code>beginContour()<\/code> and\n<a href=\"#\/p5\/endContour\">endContour()<\/a>. It's also not possible to use\nother shapes, such as <a href=\"#\/p5\/ellipse\">ellipse()<\/a> or\n<a href=\"#\/p5\/rect\">rect()<\/a>, between <code>beginContour()<\/code> and\n<a href=\"#\/p5\/endContour\">endContour()<\/a>.<\/p>\n<p>Note: The vertices that define a negative space must \"wind\" in the opposite\ndirection from the outer shape. First, draw vertices for the outer shape\nclockwise order. Then, draw vertices for the negative space in\ncounter-clockwise order.<\/p>\n","itemtype":"method","name":"beginContour","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Exterior vertices, clockwise winding.\n  vertex(10, 10);\n  vertex(90, 10);\n  vertex(90, 90);\n  vertex(10, 90);\n\n  \/\/ Interior vertices, counter-clockwise winding.\n  beginContour();\n  vertex(30, 30);\n  vertex(30, 70);\n  vertex(70, 70);\n  vertex(70, 30);\n  endContour();\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n\n  describe('A white square with a square hole in its center drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white square with a square hole in its center drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Exterior vertices, clockwise winding.\n  vertex(-40, -40);\n  vertex(40, -40);\n  vertex(40, 40);\n  vertex(-40, 40);\n\n  \/\/ Interior vertices, counter-clockwise winding.\n  beginContour();\n  vertex(-20, -20);\n  vertex(-20, 20);\n  vertex(20, 20);\n  vertex(20, -20);\n  endContour();\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src\/core\/shape\/vertex.js","line":129,"description":"<p>Begins adding vertices to a custom shape.<\/p>\n<p>The <code>beginShape()<\/code> and <a href=\"#\/p5\/endShape\">endShape()<\/a> functions\nallow for creating custom shapes in 2D or 3D. <code>beginShape()<\/code> begins adding\nvertices to a custom shape and <a href=\"#\/p5\/endShape\">endShape()<\/a> stops\nadding them.<\/p>\n<p>The parameter, <code>kind<\/code>, sets the kind of shape to make. By default, any\nirregular polygon can be drawn. The available modes for kind are:<\/p>\n<ul>\n<li><code>POINTS<\/code> to draw a series of points.<\/li>\n<li><code>LINES<\/code> to draw a series of unconnected line segments.<\/li>\n<li><code>TRIANGLES<\/code> to draw a series of separate triangles.<\/li>\n<li><code>TRIANGLE_FAN<\/code> to draw a series of connected triangles sharing the first vertex in a fan-like fashion.<\/li>\n<li><code>TRIANGLE_STRIP<\/code> to draw a series of connected triangles in strip fashion.<\/li>\n<li><code>QUADS<\/code> to draw a series of separate quadrilaterals (quads).<\/li>\n<li><code>QUAD_STRIP<\/code> to draw quad strip using adjacent edges to form the next quad.<\/li>\n<li><code>TESS<\/code> to create a filling curve by explicit tessellation (WebGL only).<\/li>\n<\/ul>\n<p>After calling <code>beginShape()<\/code>, shapes can be built by calling\n<a href=\"#\/p5\/vertex\">vertex()<\/a>,\n<a href=\"#\/p5\/bezierVertex\">bezierVertex()<\/a>,\n<a href=\"#\/p5\/quadraticVertex\">quadraticVertex()<\/a>, and\/or\n<a href=\"#\/p5\/curveVertex\">curveVertex()<\/a>. Calling\n<a href=\"#\/p5\/endShape\">endShape()<\/a> will stop adding vertices to the\nshape. Each shape will be outlined with the current stroke color and filled\nwith the current fill color.<\/p>\n<p>Transformations such as <a href=\"#\/p5\/translate\">translate()<\/a>,\n<a href=\"#\/p5\/rotate\">rotate()<\/a>, and\n<a href=\"#\/p5\/scale\">scale()<\/a> don't work between <code>beginShape()<\/code> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a>. It's also not possible to use\nother shapes, such as <a href=\"#\/p5\/ellipse\">ellipse()<\/a> or\n<a href=\"#\/p5\/rect\">rect()<\/a>, between <code>beginShape()<\/code> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a>.<\/p>\n","itemtype":"method","name":"beginShape","params":[{"name":"kind","description":"<p>either POINTS, LINES, TRIANGLES, TRIANGLE_FAN\n                               TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS.<\/p>\n","type":"Constant","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add vertices.\n  vertex(30, 20);\n  vertex(85, 20);\n  vertex(85, 75);\n  vertex(30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n\n  describe('A white square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Only draw the vertices (points).\n  beginShape(POINTS);\n\n  \/\/ Add vertices.\n  vertex(30, 20);\n  vertex(85, 20);\n  vertex(85, 75);\n  vertex(30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Four black dots that form a square are drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Only draw lines between alternating pairs of vertices.\n  beginShape(LINES);\n\n  \/\/ Add vertices.\n  vertex(30, 20);\n  vertex(85, 20);\n  vertex(85, 75);\n  vertex(30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Two horizontal black lines on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shape.\n  noFill();\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add vertices.\n  vertex(30, 20);\n  vertex(85, 20);\n  vertex(85, 75);\n  vertex(30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Three black lines form a sideways U shape on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shape.\n  noFill();\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add vertices.\n  vertex(30, 20);\n  vertex(85, 20);\n  vertex(85, 75);\n  vertex(30, 75);\n\n  \/\/ Stop drawing the shape.\n  \/\/ Connect the first and last vertices.\n  endShape(CLOSE);\n\n  describe('A black outline of a square drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Draw a series of triangles.\n  beginShape(TRIANGLES);\n\n  \/\/ Left triangle.\n  vertex(30, 75);\n  vertex(40, 20);\n  vertex(50, 75);\n\n  \/\/ Right triangle.\n  vertex(60, 20);\n  vertex(70, 75);\n  vertex(80, 20);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Two white triangles drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Draw a series of triangles.\n  beginShape(TRIANGLE_STRIP);\n\n  \/\/ Add vertices.\n  vertex(30, 75);\n  vertex(40, 20);\n  vertex(50, 75);\n  vertex(60, 20);\n  vertex(70, 75);\n  vertex(80, 20);\n  vertex(90, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Five white triangles that are interleaved drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Draw a series of triangles that share their first vertex.\n  beginShape(TRIANGLE_FAN);\n\n  \/\/ Add vertices.\n  vertex(57.5, 50);\n  vertex(57.5, 15);\n  vertex(92, 50);\n  vertex(57.5, 85);\n  vertex(22, 50);\n  vertex(57.5, 15);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Four white triangles form a square are drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Draw a series of quadrilaterals.\n  beginShape(QUADS);\n\n  \/\/ Left rectangle.\n  vertex(30, 20);\n  vertex(30, 75);\n  vertex(50, 75);\n  vertex(50, 20);\n\n  \/\/ Right rectangle.\n  vertex(65, 20);\n  vertex(65, 75);\n  vertex(85, 75);\n  vertex(85, 20);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Two white rectangles drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Draw a series of quadrilaterals.\n  beginShape(QUAD_STRIP);\n\n  \/\/ Add vertices.\n  vertex(30, 20);\n  vertex(30, 75);\n  vertex(50, 20);\n  vertex(50, 75);\n  vertex(65, 20);\n  vertex(65, 75);\n  vertex(85, 20);\n  vertex(85, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Three white rectangles that share edges are drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  \/\/ Draw a series of quadrilaterals.\n  beginShape(TESS);\n\n  \/\/ Add the vertices.\n  vertex(-30, -30, 0);\n  vertex(30, -30, 0);\n  vertex(30, -10, 0);\n  vertex(-10, -10, 0);\n  vertex(-10, 10, 0);\n  vertex(30, 10, 0);\n  vertex(30, 30, 0);\n  vertex(-30, 30, 0);\n\n  \/\/ Stop drawing the shape.\n  \/\/ Connect the first and last vertices.\n  endShape(CLOSE);\n\n  describe('A blocky C shape drawn in white on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag with the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A blocky C shape drawn in red, blue, and green on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Start drawing the shape.\n  \/\/ Draw a series of quadrilaterals.\n  beginShape(TESS);\n\n  \/\/ Add the vertices.\n  fill('red');\n  stroke('red');\n  vertex(-30, -30, 0);\n  vertex(30, -30, 0);\n  vertex(30, -10, 0);\n  fill('green');\n  stroke('green');\n  vertex(-10, -10, 0);\n  vertex(-10, 10, 0);\n  vertex(30, 10, 0);\n  fill('blue');\n  stroke('blue');\n  vertex(30, 30, 0);\n  vertex(-30, 30, 0);\n\n  \/\/ Stop drawing the shape.\n  \/\/ Connect the first and last vertices.\n  endShape(CLOSE);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src\/core\/shape\/vertex.js","line":543,"description":"<p>Adds a B\u00e9zier curve segment to a custom shape.<\/p>\n<p><code>bezierVertex()<\/code> adds a curved segment to custom shapes. The B\u00e9zier curves\nit creates are defined like those made by the\n<a href=\"#\/p5\/bezier\">bezier()<\/a> function. <code>bezierVertex()<\/code> must be\ncalled between the\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a> functions. The curved segment uses\nthe previous vertex as the first anchor point, so there must be at least\none call to <a href=\"#\/p5\/vertex\">vertex()<\/a> before <code>bezierVertex()<\/code> can\nbe used.<\/p>\n<p>The first four parameters, <code>x2<\/code>, <code>y2<\/code>, <code>x3<\/code>, and <code>y3<\/code>, set the curve\u2019s two\ncontrol points. The control points \"pull\" the curve towards them.<\/p>\n<p>The fifth and sixth parameters, <code>x4<\/code>, and <code>y4<\/code>, set the last anchor point.\nThe last anchor point is where the curve ends.<\/p>\n<p>B\u00e9zier curves can also be drawn in 3D using WebGL mode. The 3D version of\n<code>bezierVertex()<\/code> has eight arguments because each point has x-, y-, and\nz-coordinates.<\/p>\n<p>Note: <code>bezierVertex()<\/code> won\u2019t work when an argument is passed to\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a>.<\/p>\n","itemtype":"method","name":"bezierVertex","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shape.\n  noFill();\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first anchor point.\n  vertex(30, 20);\n\n  \/\/ Add the B\u00e9zier vertex.\n  bezierVertex(80, 0, 80, 75, 30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('A black C curve on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  strokeWeight(5);\n  point(30, 20);\n  point(30, 75);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(80, 0);\n  point(80, 75);\n\n  \/\/ Style the shape.\n  noFill();\n  stroke(0);\n  strokeWeight(1);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first anchor point.\n  vertex(30, 20);\n\n  \/\/ Add the B\u00e9zier vertex.\n  bezierVertex(80, 0, 80, 75, 30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  \/\/ Draw red lines from the anchor points to the control points.\n  stroke(255, 0, 0);\n  line(30, 20, 80, 0);\n  line(30, 75, 80, 75);\n\n  describe(\n    'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the mouse near the red dot in the top-right corner\n\/\/ and drag to change the curve's shape.\n\nlet x2 = 80;\nlet y2 = 0;\nlet isChanging = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  strokeWeight(5);\n  point(30, 20);\n  point(30, 75);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(x2, y2);\n  point(80, 75);\n\n  \/\/ Style the shape.\n  noFill();\n  stroke(0);\n  strokeWeight(1);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first anchor point.\n  vertex(30, 20);\n\n  \/\/ Add the B\u00e9zier vertex.\n  bezierVertex(x2, y2, 80, 75, 30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  \/\/ Draw red lines from the anchor points to the control points.\n  stroke(255, 0, 0);\n  line(30, 20, x2, y2);\n  line(30, 75, 80, 75);\n}\n\n\/\/ Start changing the first control point if the user clicks near it.\nfunction mousePressed() {\n  if (dist(mouseX, mouseY, x2, y2) < 20) {\n    isChanging = true;\n  }\n}\n\n\/\/ Stop changing the first control point when the user releases the mouse.\nfunction mouseReleased() {\n  isChanging = false;\n}\n\n\/\/ Update the first control point while the user drags the mouse.\nfunction mouseDragged() {\n  if (isChanging === true) {\n    x2 = mouseX;\n    y2 = mouseY;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first anchor point.\n  vertex(30, 20);\n\n  \/\/ Add the B\u00e9zier vertices.\n  bezierVertex(80, 0, 80, 75, 30, 75);\n  bezierVertex(50, 80, 60, 25, 30, 20);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('A crescent moon shape drawn in white on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A crescent moon shape drawn in white on a blue background. When the user drags the mouse, the scene rotates and a second moon is revealed.');\n}\n\nfunction draw() {\n  background('midnightblue');\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the moons.\n  noStroke();\n  fill('lemonchiffon');\n\n  \/\/ Draw the first moon.\n  beginShape();\n  vertex(-20, -30, 0);\n  bezierVertex(30, -50, 0, 30, 25, 0, -20, 25, 0);\n  bezierVertex(0, 30, 0, 10, -25, 0, -20, -30, 0);\n  endShape();\n\n  \/\/ Draw the second moon.\n  beginShape();\n  vertex(-20, -30, -20);\n  bezierVertex(30, -50, -20, 30, 25, -20, -20, 25, -20);\n  bezierVertex(0, 30, -20, 10, -25, -20, -20, -30, -20);\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex","overloads":[{"line":543,"params":[{"name":"x2","description":"<p>x-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"y2","description":"<p>y-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"x3","description":"<p>x-coordinate of the second control point.<\/p>\n","type":"Number"},{"name":"y3","description":"<p>y-coordinate of the second control point.<\/p>\n","type":"Number"},{"name":"x4","description":"<p>x-coordinate of the anchor point.<\/p>\n","type":"Number"},{"name":"y4","description":"<p>y-coordinate of the anchor point.<\/p>\n","type":"Number"}],"chainable":1},{"line":792,"params":[{"name":"x2","description":"","type":"Number"},{"name":"y2","description":"","type":"Number"},{"name":"z2","description":"<p>z-coordinate of the first control point.<\/p>\n","type":"Number"},{"name":"x3","description":"","type":"Number"},{"name":"y3","description":"","type":"Number"},{"name":"z3","description":"<p>z-coordinate of the second control point.<\/p>\n","type":"Number"},{"name":"x4","description":"","type":"Number"},{"name":"y4","description":"","type":"Number"},{"name":"z4","description":"<p>z-coordinate of the anchor point.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/core\/shape\/vertex.js","line":832,"description":"<p>Adds a spline curve segment to a custom shape.<\/p>\n<p><code>curveVertex()<\/code> adds a curved segment to custom shapes. The spline curves\nit creates are defined like those made by the\n<a href=\"#\/p5\/curve\">curve()<\/a> function. <code>curveVertex()<\/code> must be called\nbetween the <a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a> functions.<\/p>\n<p>Spline curves can form shapes and curves that slope gently. They\u2019re like\ncables that are attached to a set of points. Splines are defined by two\nanchor points and two control points. <code>curveVertex()<\/code> must be called at\nleast four times between\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a> in order to draw a curve:<\/p>\n<pre><code class=\"language-js\">beginShape();\n\n\/\/ Add the first control point.\ncurveVertex(84, 91);\n\n\/\/ Add the anchor points to draw between.\ncurveVertex(68, 19);\ncurveVertex(21, 17);\n\n\/\/ Add the second control point.\ncurveVertex(32, 91);\n\nendShape();\n<\/code><\/pre>\n<p>The code snippet above would only draw the curve between the anchor points,\nsimilar to the <a href=\"#\/p5\/curve\">curve()<\/a> function. The segments\nbetween the control and anchor points can be drawn by calling\n<code>curveVertex()<\/code> with the coordinates of the control points:<\/p>\n<pre><code class=\"language-js\">beginShape();\n\n\/\/ Add the first control point and draw a segment to it.\ncurveVertex(84, 91);\ncurveVertex(84, 91);\n\n\/\/ Add the anchor points to draw between.\ncurveVertex(68, 19);\ncurveVertex(21, 17);\n\n\/\/ Add the second control point.\ncurveVertex(32, 91);\n\n\/\/ Uncomment the next line to draw the segment to the second control point.\n\/\/ curveVertex(32, 91);\n\nendShape();\n<\/code><\/pre>\n<p>The first two parameters, <code>x<\/code> and <code>y<\/code>, set the vertex\u2019s location. For\nexample, calling <code>curveVertex(10, 10)<\/code> adds a point to the curve at\n<code>(10, 10)<\/code>.<\/p>\n<p>Spline curves can also be drawn in 3D using WebGL mode. The 3D version of\n<code>curveVertex()<\/code> has three arguments because each point has x-, y-, and\nz-coordinates. By default, the vertex\u2019s z-coordinate is set to 0.<\/p>\n<p>Note: <code>curveVertex()<\/code> won\u2019t work when an argument is passed to\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a>.<\/p>\n","itemtype":"method","name":"curveVertex","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shape.\n  noFill();\n  strokeWeight(1);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first control point.\n  curveVertex(32, 91);\n\n  \/\/ Add the anchor points.\n  curveVertex(21, 17);\n  curveVertex(68, 19);\n\n  \/\/ Add the second control point.\n  curveVertex(84, 91);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  \/\/ Style the anchor and control points.\n  strokeWeight(5);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  point(21, 17);\n  point(68, 19);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(32, 91);\n  point(84, 91);\n\n  describe(\n    'A black curve drawn on a gray background. The curve has black dots at its ends. Two red dots appear near the bottom of the canvas.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shape.\n  noFill();\n  strokeWeight(1);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first control point and draw a segment to it.\n  curveVertex(32, 91);\n  curveVertex(32, 91);\n\n  \/\/ Add the anchor points.\n  curveVertex(21, 17);\n  curveVertex(68, 19);\n\n  \/\/ Add the second control point.\n  curveVertex(84, 91);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  \/\/ Style the anchor and control points.\n  strokeWeight(5);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  point(21, 17);\n  point(68, 19);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(32, 91);\n  point(84, 91);\n\n  describe(\n    'A black curve drawn on a gray background. The curve passes through one red dot and two black dots. Another red dot appears near the bottom of the canvas.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shape.\n  noFill();\n  strokeWeight(1);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first control point and draw a segment to it.\n  curveVertex(32, 91);\n  curveVertex(32, 91);\n\n  \/\/ Add the anchor points.\n  curveVertex(21, 17);\n  curveVertex(68, 19);\n\n  \/\/ Add the second control point and draw a segment to it.\n  curveVertex(84, 91);\n  curveVertex(84, 91);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  \/\/ Style the anchor and control points.\n  strokeWeight(5);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  point(21, 17);\n  point(68, 19);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(32, 91);\n  point(84, 91);\n\n  describe(\n    'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the mouse near the red dot in the bottom-left corner\n\/\/ and drag to change the curve's shape.\n\nlet x1 = 32;\nlet y1 = 91;\nlet isChanging = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the shape.\n  noFill();\n  stroke(0);\n  strokeWeight(1);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first control point and draw a segment to it.\n  curveVertex(x1, y1);\n  curveVertex(x1, y1);\n\n  \/\/ Add the anchor points.\n  curveVertex(21, 17);\n  curveVertex(68, 19);\n\n  \/\/ Add the second control point and draw a segment to it.\n  curveVertex(84, 91);\n  curveVertex(84, 91);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  \/\/ Style the anchor and control points.\n  strokeWeight(5);\n\n  \/\/ Draw the anchor points in black.\n  stroke(0);\n  point(21, 17);\n  point(68, 19);\n\n  \/\/ Draw the control points in red.\n  stroke(255, 0, 0);\n  point(x1, y1);\n  point(84, 91);\n}\n\n\/\/ Start changing the first control point if the user clicks near it.\nfunction mousePressed() {\n  if (dist(mouseX, mouseY, x1, y1) < 20) {\n    isChanging = true;\n  }\n}\n\n\/\/ Stop changing the first control point when the user releases the mouse.\nfunction mouseReleased() {\n  isChanging = false;\n}\n\n\/\/ Update the first control point while the user drags the mouse.\nfunction mouseDragged() {\n  if (isChanging === true) {\n    x1 = mouseX;\n    y1 = mouseY;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the first control point and draw a segment to it.\n  curveVertex(32, 91);\n  curveVertex(32, 91);\n\n  \/\/ Add the anchor points.\n  curveVertex(21, 17);\n  curveVertex(68, 19);\n\n  \/\/ Add the second control point.\n  curveVertex(84, 91);\n  curveVertex(84, 91);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('A ghost shape drawn in white on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex","overloads":[{"line":832,"params":[{"name":"x","description":"<p>x-coordinate of the vertex<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the vertex<\/p>\n","type":"Number"}],"chainable":1},{"line":1160,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"<p>z-coordinate of the vertex.<\/p>\n","type":"Number","optional":true}],"chainable":1}]},{"file":"src\/core\/shape\/vertex.js","line":1224,"description":"<p>Stops creating a hole within a flat shape.<\/p>\n<p>The <a href=\"#\/p5\/beginContour\">beginContour()<\/a> and <code>endContour()<\/code>\nfunctions allow for creating negative space within custom shapes that are\nflat. <a href=\"#\/p5\/beginContour\">beginContour()<\/a> begins adding vertices\nto a negative space and <code>endContour()<\/code> stops adding them.\n<a href=\"#\/p5\/beginContour\">beginContour()<\/a> and <code>endContour()<\/code> must be\ncalled between <a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a>.<\/p>\n<p>Transformations such as <a href=\"#\/p5\/translate\">translate()<\/a>,\n<a href=\"#\/p5\/rotate\">rotate()<\/a>, and <a href=\"#\/p5\/scale\">scale()<\/a>\ndon't work between <a href=\"#\/p5\/beginContour\">beginContour()<\/a> and\n<code>endContour()<\/code>. It's also not possible to use other shapes, such as\n<a href=\"#\/p5\/ellipse\">ellipse()<\/a> or <a href=\"#\/p5\/rect\">rect()<\/a>,\nbetween <a href=\"#\/p5\/beginContour\">beginContour()<\/a> and <code>endContour()<\/code>.<\/p>\n<p>Note: The vertices that define a negative space must \"wind\" in the opposite\ndirection from the outer shape. First, draw vertices for the outer shape\nclockwise order. Then, draw vertices for the negative space in\ncounter-clockwise order.<\/p>\n","itemtype":"method","name":"endContour","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Exterior vertices, clockwise winding.\n  vertex(10, 10);\n  vertex(90, 10);\n  vertex(90, 90);\n  vertex(10, 90);\n\n  \/\/ Interior vertices, counter-clockwise winding.\n  beginContour();\n  vertex(30, 30);\n  vertex(30, 70);\n  vertex(70, 70);\n  vertex(70, 30);\n  endContour();\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n\n  describe('A white square with a square hole in its center drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white square with a square hole in its center drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Exterior vertices, clockwise winding.\n  vertex(-40, -40);\n  vertex(40, -40);\n  vertex(40, 40);\n  vertex(-40, 40);\n\n  \/\/ Interior vertices, counter-clockwise winding.\n  beginContour();\n  vertex(-20, -20);\n  vertex(-20, 20);\n  vertex(20, 20);\n  vertex(20, -20);\n  endContour();\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src\/core\/shape\/vertex.js","line":1344,"description":"<p>Stops adding vertices to a custom shape.<\/p>\n<p>The <a href=\"#\/p5\/beginShape\">beginShape()<\/a> and <code>endShape()<\/code> functions\nallow for creating custom shapes in 2D or 3D.\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> begins adding vertices to a\ncustom shape and <code>endShape()<\/code> stops adding them.<\/p>\n<p>The first parameter, <code>mode<\/code>, is optional. By default, the first and last\nvertices of a shape aren't connected. If the constant <code>CLOSE<\/code> is passed, as\nin <code>endShape(CLOSE)<\/code>, then the first and last vertices will be connected.<\/p>\n<p>The second parameter, <code>count<\/code>, is also optional. In WebGL mode, it\u2019s more\nefficient to draw many copies of the same shape using a technique called\n<a href=\"https:\/\/webglfundamentals.org\/webgl\/lessons\/webgl-instanced-drawing.html\" target=\"_blank\">instancing<\/a>.\nThe <code>count<\/code> parameter tells WebGL mode how many copies to draw. For\nexample, calling <code>endShape(CLOSE, 400)<\/code> after drawing a custom shape will\nmake it efficient to draw 400 copies. This feature requires\n<a href=\"https:\/\/p5js.org\/tutorials\/intro-to-shaders\/\" target=\"_blank\">writing a custom shader<\/a>.<\/p>\n<p>After calling <a href=\"#\/p5\/beginShape\">beginShape()<\/a>, shapes can be\nbuilt by calling <a href=\"#\/p5\/vertex\">vertex()<\/a>,\n<a href=\"#\/p5\/bezierVertex\">bezierVertex()<\/a>,\n<a href=\"#\/p5\/quadraticVertex\">quadraticVertex()<\/a>, and\/or\n<a href=\"#\/p5\/curveVertex\">curveVertex()<\/a>. Calling\n<code>endShape()<\/code> will stop adding vertices to the\nshape. Each shape will be outlined with the current stroke color and filled\nwith the current fill color.<\/p>\n<p>Transformations such as <a href=\"#\/p5\/translate\">translate()<\/a>,\n<a href=\"#\/p5\/rotate\">rotate()<\/a>, and\n<a href=\"#\/p5\/scale\">scale()<\/a> don't work between\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> and <code>endShape()<\/code>. It's also not\npossible to use other shapes, such as <a href=\"#\/p5\/ellipse\">ellipse()<\/a> or\n<a href=\"#\/p5\/rect\">rect()<\/a>, between\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> and <code>endShape()<\/code>.<\/p>\n","itemtype":"method","name":"endShape","params":[{"name":"mode","description":"<p>use CLOSE to close the shape<\/p>\n","type":"Constant","optional":true},{"name":"count","description":"<p>number of times you want to draw\/instance the shape (for WebGL mode).<\/p>\n","type":"Integer","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shapes.\n  noFill();\n\n  \/\/ Left triangle.\n  beginShape();\n  vertex(20, 20);\n  vertex(45, 20);\n  vertex(45, 80);\n  endShape(CLOSE);\n\n  \/\/ Right triangle.\n  beginShape();\n  vertex(50, 20);\n  vertex(75, 20);\n  vertex(75, 80);\n  endShape();\n\n  describe(\n    'Two sets of black lines drawn on a gray background. The three lines on the left form a right triangle. The two lines on the right form a right angle.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(200, 100);\n\n  background(240);\n\n  noFill();\n  stroke(0);\n\n  \/\/ Open shape (left)\n  beginShape();\n  vertex(20, 20);\n  vertex(80, 20);\n  vertex(80, 80);\n  endShape();  \/\/ Not closed\n\n  \/\/ Closed shape (right)\n  beginShape();\n  vertex(120, 20);\n  vertex(180, 20);\n  vertex(180, 80);\n  endShape(CLOSE);  \/\/ Closed\n\n  describe(\n    'Two right-angled shapes on a light gray background. The left shape is open with three lines. The right shape is closed, forming a triangle.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `#version 300 es\n\nprecision mediump float;\n\nin vec3 aPosition;\nflat out int instanceID;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvoid main() {\n\n  \/\/ Copy the instance ID to the fragment shader.\n  instanceID = gl_InstanceID;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n\n  \/\/ gl_InstanceID represents a numeric value for each instance.\n  \/\/ Using gl_InstanceID allows us to move each instance separately.\n  \/\/ Here we move each instance horizontally by ID * 23.\n  float xOffset = float(gl_InstanceID) * 23.0;\n\n  \/\/ Apply the offset to the final position.\n  gl_Position = uProjectionMatrix * uModelViewMatrix * (positionVec4 -\n    vec4(xOffset, 0.0, 0.0, 0.0));\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `#version 300 es\n\nprecision mediump float;\n\nout vec4 outColor;\nflat in int instanceID;\nuniform float numInstances;\n\nvoid main() {\n  vec4 red = vec4(1.0, 0.0, 0.0, 1.0);\n  vec4 blue = vec4(0.0, 0.0, 1.0, 1.0);\n\n  \/\/ Normalize the instance ID.\n  float normId = float(instanceID) \/ numInstances;\n\n  \/\/ Mix between two colors using the normalized instance ID.\n  outColor = mix(red, blue, normId);\n}\n`;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  let myShader = createShader(vertSrc, fragSrc);\n\n  background(220);\n\n  \/\/ Compile and apply the p5.Shader.\n  shader(myShader);\n\n  \/\/ Set the numInstances uniform.\n  myShader.setUniform('numInstances', 4);\n\n  \/\/ Translate the origin to help align the drawing.\n  translate(25, -10);\n\n  \/\/ Style the shapes.\n  noStroke();\n\n  \/\/ Draw the shapes.\n  beginShape();\n  vertex(0, 0);\n  vertex(0, 20);\n  vertex(20, 20);\n  vertex(20, 0);\n  vertex(0, 0);\n  endShape(CLOSE, 4);\n\n  describe('A row of four squares. Their colors transition from purple on the left to red on the right');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex"},{"file":"src\/core\/shape\/vertex.js","line":1600,"description":"<p>Adds a quadratic B\u00e9zier curve segment to a custom shape.<\/p>\n<p><code>quadraticVertex()<\/code> adds a curved segment to custom shapes. The B\u00e9zier\ncurve segments it creates are similar to those made by the\n<a href=\"#\/p5\/bezierVertex\">bezierVertex()<\/a> function.\n<code>quadraticVertex()<\/code> must be called between the\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a> functions. The curved segment uses\nthe previous vertex as the first anchor point, so there must be at least\none call to <a href=\"#\/p5\/vertex\">vertex()<\/a> before <code>quadraticVertex()<\/code> can\nbe used.<\/p>\n<p>The first two parameters, <code>cx<\/code> and <code>cy<\/code>, set the curve\u2019s control point.\nThe control point \"pulls\" the curve towards its.<\/p>\n<p>The last two parameters, <code>x3<\/code>, and <code>y3<\/code>, set the last anchor point. The\nlast anchor point is where the curve ends.<\/p>\n<p>B\u00e9zier curves can also be drawn in 3D using WebGL mode. The 3D version of\n<code>bezierVertex()<\/code> has eight arguments because each point has x-, y-, and\nz-coordinates.<\/p>\n<p>Note: <code>quadraticVertex()<\/code> won\u2019t work when an argument is passed to\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a>.<\/p>\n","itemtype":"method","name":"quadraticVertex","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the curve.\n  noFill();\n\n  \/\/ Draw the curve.\n  beginShape();\n  vertex(20, 20);\n  quadraticVertex(80, 20, 50, 50);\n  endShape();\n\n  describe('A black curve drawn on a gray square. The curve starts at the top-left corner and ends at the center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the curve.\n  noFill();\n  beginShape();\n  vertex(20, 20);\n  quadraticVertex(80, 20, 50, 50);\n  endShape();\n\n  \/\/ Draw red lines from the anchor points to the control point.\n  stroke(255, 0, 0);\n  line(20, 20, 80, 20);\n  line(50, 50, 80, 20);\n\n  \/\/ Draw the anchor points in black.\n  strokeWeight(5);\n  stroke(0);\n  point(20, 20);\n  point(50, 50);\n\n  \/\/ Draw the control point in red.\n  stroke(255, 0, 0);\n  point(80, 20);\n\n  describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the mouse near the red dot in the top-right corner\n\/\/ and drag to change the curve's shape.\n\nlet x2 = 80;\nlet y2 = 20;\nlet isChanging = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the curve.\n  noFill();\n  strokeWeight(1);\n  stroke(0);\n\n  \/\/ Draw the curve.\n  beginShape();\n  vertex(20, 20);\n  quadraticVertex(x2, y2, 50, 50);\n  endShape();\n\n  \/\/ Draw red lines from the anchor points to the control point.\n  stroke(255, 0, 0);\n  line(20, 20, x2, y2);\n  line(50, 50, x2, y2);\n\n  \/\/ Draw the anchor points in black.\n  strokeWeight(5);\n  stroke(0);\n  point(20, 20);\n  point(50, 50);\n\n  \/\/ Draw the control point in red.\n  stroke(255, 0, 0);\n  point(x2, y2);\n}\n\n\/\/ Start changing the first control point if the user clicks near it.\nfunction mousePressed() {\n  if (dist(mouseX, mouseY, x2, y2) < 20) {\n    isChanging = true;\n  }\n}\n\n\/\/ Stop changing the first control point when the user releases the mouse.\nfunction mouseReleased() {\n  isChanging = false;\n}\n\n\/\/ Update the first control point while the user drags the mouse.\nfunction mouseDragged() {\n  if (isChanging === true) {\n    x2 = mouseX;\n    y2 = mouseY;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add the curved segments.\n  vertex(20, 20);\n  quadraticVertex(80, 20, 50, 50);\n  quadraticVertex(20, 80, 80, 80);\n\n  \/\/ Add the straight segments.\n  vertex(80, 10);\n  vertex(20, 10);\n  vertex(20, 20);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('A white puzzle piece drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the and drag the mouse to view the scene from a different angle.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white puzzle piece on a dark gray background. When the user clicks and drags the scene, the outline of a second puzzle piece is revealed.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the first puzzle piece.\n  noStroke();\n  fill(255);\n\n  \/\/ Draw the first puzzle piece.\n  beginShape();\n  vertex(-30, -30, 0);\n  quadraticVertex(30, -30, 0, 0, 0, 0);\n  quadraticVertex(-30, 30, 0, 30, 30, 0);\n  vertex(30, -40, 0);\n  vertex(-30, -40, 0);\n  vertex(-30, -30, 0);\n  endShape();\n\n  \/\/ Style the second puzzle piece.\n  stroke(255);\n  noFill();\n\n  \/\/ Draw the second puzzle piece.\n  beginShape();\n  vertex(-30, -30, -20);\n  quadraticVertex(30, -30, -20, 0, 0, -20);\n  quadraticVertex(-30, 30, -20, 30, 30, -20);\n  vertex(30, -40, -20);\n  vertex(-30, -40, -20);\n  vertex(-30, -30, -20);\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex","overloads":[{"line":1600,"params":[{"name":"cx","description":"<p>x-coordinate of the control point.<\/p>\n","type":"Number"},{"name":"cy","description":"<p>y-coordinate of the control point.<\/p>\n","type":"Number"},{"name":"x3","description":"<p>x-coordinate of the anchor point.<\/p>\n","type":"Number"},{"name":"y3","description":"<p>y-coordinate of the anchor point.<\/p>\n","type":"Number"}],"chainable":1},{"line":1832,"params":[{"name":"cx","description":"","type":"Number"},{"name":"cy","description":"","type":"Number"},{"name":"cz","description":"<p>z-coordinate of the control point.<\/p>\n","type":"Number"},{"name":"x3","description":"","type":"Number"},{"name":"y3","description":"","type":"Number"},{"name":"z3","description":"<p>z-coordinate of the anchor point.<\/p>\n","type":"Number"}]}]},{"file":"src\/core\/shape\/vertex.js","line":1881,"description":"<p>Adds a vertex to a custom shape.<\/p>\n<p><code>vertex()<\/code> sets the coordinates of vertices drawn between the\n<a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a> functions.<\/p>\n<p>The first two parameters, <code>x<\/code> and <code>y<\/code>, set the x- and y-coordinates of the\nvertex.<\/p>\n<p>The third parameter, <code>z<\/code>, is optional. It sets the z-coordinate of the\nvertex in WebGL mode. By default, <code>z<\/code> is 0.<\/p>\n<p>The fourth and fifth parameters, <code>u<\/code> and <code>v<\/code>, are also optional. They set\nthe u- and v-coordinates for the vertex\u2019s texture when used with\n<a href=\"#\/p5\/endShape\">endShape()<\/a>. By default, <code>u<\/code> and <code>v<\/code> are both 0.<\/p>\n","itemtype":"method","name":"vertex","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the shape.\n  strokeWeight(3);\n\n  \/\/ Start drawing the shape.\n  \/\/ Only draw the vertices.\n  beginShape(POINTS);\n\n  \/\/ Add the vertices.\n  vertex(30, 20);\n  vertex(85, 20);\n  vertex(85, 75);\n  vertex(30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n\n  describe('Four black dots that form a square are drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add vertices.\n  vertex(30, 20);\n  vertex(85, 20);\n  vertex(85, 75);\n  vertex(30, 75);\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n\n  describe('A white square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add vertices.\n  vertex(-20, -30, 0);\n  vertex(35, -30, 0);\n  vertex(35, 25, 0);\n  vertex(-20, 25, 0);\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n\n  describe('A white square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white square spins around slowly on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Start drawing the shape.\n  beginShape();\n\n  \/\/ Add vertices.\n  vertex(-20, -30, 0);\n  vertex(35, -30, 0);\n  vertex(35, 25, 0);\n  vertex(-20, 25, 0);\n\n  \/\/ Stop drawing the shape.\n  endShape(CLOSE);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load an image to apply as a texture.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A photograph of a ceiling rotates slowly against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Style the shape.\n  noStroke();\n\n  \/\/ Apply the texture.\n  texture(img);\n  textureMode(NORMAL);\n\n  \/\/ Start drawing the shape\n  beginShape();\n\n  \/\/ Add vertices.\n  vertex(-20, -30, 0, 0, 0);\n  vertex(35, -30, 0, 1, 0);\n  vertex(35, 25, 0, 1, 1);\n  vertex(-20, 25, 0, 0, 1);\n\n  \/\/ Stop drawing the shape.\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex","overloads":[{"line":1881,"params":[{"name":"x","description":"<p>x-coordinate of the vertex.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the vertex.<\/p>\n","type":"Number"}],"chainable":1},{"line":2052,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"<p>z-coordinate of the vertex. Defaults to 0.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":2059,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number","optional":true},{"name":"u","description":"<p>u-coordinate of the vertex's texture. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"v","description":"<p>v-coordinate of the vertex's texture. Defaults to 0.<\/p>\n","type":"Number","optional":true}],"chainable":1}]},{"file":"src\/core\/shape\/vertex.js","line":2097,"description":"<p>Sets the normal vector for vertices in a custom 3D shape.<\/p>\n<p>3D shapes created with <a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a> are made by connecting sets of\npoints called vertices. Each vertex added with\n<a href=\"#\/p5\/vertex\">vertex()<\/a> has a normal vector that points away\nfrom it. The normal vector controls how light reflects off the shape.<\/p>\n<p><code>normal()<\/code> can be called two ways with different parameters to define the\nnormal vector's components.<\/p>\n<p>The first way to call <code>normal()<\/code> has three parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>.\nIf <code>Number<\/code>s are passed, as in <code>normal(1, 2, 3)<\/code>, they set the x-, y-, and\nz-components of the normal vector.<\/p>\n<p>The second way to call <code>normal()<\/code> has one parameter, <code>vector<\/code>. If a\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object is passed, as in\n<code>normal(myVector)<\/code>, its components will be used to set the normal vector.<\/p>\n<p><code>normal()<\/code> changes the normal vector of vertices added to a custom shape\nwith <a href=\"#\/p5\/vertex\">vertex()<\/a>. <code>normal()<\/code> must be called between\nthe <a href=\"#\/p5\/beginShape\">beginShape()<\/a> and\n<a href=\"#\/p5\/endShape\">endShape()<\/a> functions, just like\n<a href=\"#\/p5\/vertex\">vertex()<\/a>. The normal vector set by calling\n<code>normal()<\/code> will affect all following vertices until <code>normal()<\/code> is called\nagain:<\/p>\n<pre><code class=\"language-js\">beginShape();\n\n\/\/ Set the vertex normal.\nnormal(-0.4, -0.4, 0.8);\n\n\/\/ Add a vertex.\nvertex(-30, -30, 0);\n\n\/\/ Set the vertex normal.\nnormal(0, 0, 1);\n\n\/\/ Add vertices.\nvertex(30, -30, 0);\nvertex(30, 30, 0);\n\n\/\/ Set the vertex normal.\nnormal(0.4, -0.4, 0.8);\n\n\/\/ Add a vertex.\nvertex(-30, 30, 0);\n\nendShape();\n<\/code><\/pre>\n","itemtype":"method","name":"normal","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click the and drag the mouse to view the scene from a different angle.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.'\n  );\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the shape.\n  normalMaterial();\n  noStroke();\n\n  \/\/ Draw the shape.\n  beginShape();\n  vertex(-30, -30, 0);\n  vertex(30, -30, 0);\n  vertex(30, 30, 0);\n  vertex(-30, 30, 0);\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the and drag the mouse to view the scene from a different angle.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.'\n  );\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the shape.\n  normalMaterial();\n  noStroke();\n\n  \/\/ Draw the shape.\n  \/\/ Use normal() to set vertex normals.\n  beginShape();\n  normal(-0.4, -0.4, 0.8);\n  vertex(-30, -30, 0);\n\n  normal(0, 0, 1);\n  vertex(30, -30, 0);\n  vertex(30, 30, 0);\n\n  normal(0.4, -0.4, 0.8);\n  vertex(-30, 30, 0);\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\n\/\/ Click the and drag the mouse to view the scene from a different angle.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.'\n  );\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the shape.\n  normalMaterial();\n  noStroke();\n\n  \/\/ Create p5.Vector objects.\n  let n1 = createVector(-0.4, -0.4, 0.8);\n  let n2 = createVector(0, 0, 1);\n  let n3 = createVector(0.4, -0.4, 0.8);\n\n  \/\/ Draw the shape.\n  \/\/ Use normal() to set vertex normals.\n  beginShape();\n  normal(n1);\n  vertex(-30, -30, 0);\n\n  normal(n2);\n  vertex(30, -30, 0);\n  vertex(30, 30, 0);\n\n  normal(n3);\n  vertex(-30, 30, 0);\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"Vertex","overloads":[{"line":2097,"params":[{"name":"vector","description":"<p>vertex normal as a <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","type":"p5.Vector"}],"chainable":1},{"line":2272,"params":[{"name":"x","description":"<p>x-component of the vertex normal.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-component of the vertex normal.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z-component of the vertex normal.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/core\/constants.js","line":9,"description":"<p>Version of this p5.js.<\/p>\n","itemtype":"property","name":"VERSION","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":18,"description":"<p>The default, two-dimensional renderer.<\/p>\n","itemtype":"property","name":"P2D","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":24,"description":"<p>One of the two render modes in p5.js, used for computationally intensive tasks like 3D rendering and shaders.<\/p>\n<p><code>WEBGL<\/code> differs from the default <a href=\"\/reference\/p5\/P2D\"><code>P2D<\/code><\/a> renderer in the following ways:<\/p>\n<ul>\n<li><strong>Coordinate System<\/strong> - When drawing in <code>WEBGL<\/code> mode, the origin point (0,0,0) is located at the center of the screen, not the top-left corner. See <a href=\"https:\/\/p5js.org\/tutorials\/coordinates-and-transformations\/\">the tutorial page about coordinates and transformations<\/a>.<\/li>\n<li><strong>3D Shapes<\/strong> - <code>WEBGL<\/code> mode can be used to draw 3-dimensional shapes like <a href=\"#\/p5\/box\">box()<\/a>, <a href=\"#\/p5\/sphere\">sphere()<\/a>, <a href=\"#\/p5\/cone\">cone()<\/a>, and <a href=\"https:\/\/p5js.org\/reference\/#3D%20Primitives\">more<\/a>. See <a href=\"https:\/\/p5js.org\/tutorials\/custom-geometry\/\">the tutorial page about custom geometry<\/a> to make more complex objects.<\/li>\n<li><strong>Shape Detail<\/strong> - When drawing in <code>WEBGL<\/code> mode, you can specify how smooth curves should be drawn by using a <code>detail<\/code> parameter. See <a href=\"https:\/\/github.com\/processing\/p5.js\/wiki\/Getting-started-with-WebGL-in-p5#3d-primitives-shapes\">the wiki section about shapes<\/a> for a more information and an example.<\/li>\n<li><strong>Textures<\/strong> - A texture is like a skin that wraps onto a shape. See <a href=\"https:\/\/github.com\/processing\/p5.js\/wiki\/Getting-started-with-WebGL-in-p5#textures\">the wiki section about textures<\/a> for examples of mapping images onto surfaces with textures.<\/li>\n<li><strong>Materials and Lighting<\/strong> - <code>WEBGL<\/code> offers different types of lights like <a href=\"#\/p5\/ambientLight\">ambientLight()<\/a> to place around a scene. Materials like <a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a> reflect the lighting to convey shape and depth. See <a href=\"https:\/\/p5js.org\/tutorials\/lights-camera-materials\/\">the tutorial page for styling and appearance<\/a> to experiment with different combinations.<\/li>\n<li><strong>Camera<\/strong> - The viewport of a <code>WEBGL<\/code> sketch can be adjusted by changing camera attributes. See <a href=\"https:\/\/p5js.org\/tutorials\/lights-camera-materials#camera-and-view\">the tutorial page section about cameras<\/a> for an explanation of camera controls.<\/li>\n<li><strong>Text<\/strong> - <code>WEBGL<\/code> requires opentype\/truetype font files to be preloaded using <a href=\"#\/p5\/loadFont\">loadFont()<\/a>. See <a href=\"https:\/\/github.com\/processing\/p5.js\/wiki\/Getting-started-with-WebGL-in-p5#text\">the wiki section about text<\/a> for details, along with a workaround.<\/li>\n<li><strong>Shaders<\/strong> - Shaders are hardware accelerated programs that can be used for a variety of effects and graphics. See the <a href=\"https:\/\/p5js.org\/tutorials\/intro-to-shaders\/\">introduction to shaders<\/a> to get started with shaders in p5.js.<\/li>\n<li><strong>Graphics Acceleration<\/strong> - <code>WEBGL<\/code> mode uses the graphics card instead of the CPU, so it may help boost the performance of your sketch (example: drawing more shapes on the screen at once).<\/li>\n<\/ul>\n<p>To learn more about WEBGL mode, check out <a href=\"https:\/\/p5js.org\/tutorials\/#webgl\">all the interactive WEBGL tutorials<\/a> in the \"Tutorials\" section of this website, or read the wiki article <a href=\"https:\/\/github.com\/processing\/p5.js\/wiki\/Getting-started-with-WebGL-in-p5\">\"Getting started with WebGL in p5\"<\/a>.<\/p>\n","itemtype":"property","name":"WEBGL","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":45,"description":"<p>One of the two possible values of a WebGL canvas (either WEBGL or WEBGL2),\nwhich can be used to determine what capabilities the rendering environment\nhas.<\/p>\n","itemtype":"property","name":"WEBGL2","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":55,"itemtype":"property","name":"ARROW","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":60,"itemtype":"property","name":"CROSS","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":65,"itemtype":"property","name":"HAND","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":70,"itemtype":"property","name":"MOVE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":75,"itemtype":"property","name":"TEXT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":80,"itemtype":"property","name":"WAIT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":88,"description":"<p>A <code>Number<\/code> constant that's approximately 1.5708.<\/p>\n<p><code>HALF_PI<\/code> is half the value of the mathematical constant \u03c0. It's useful for\nmany tasks that involve rotation and oscillation. For example, calling\n<code>rotate(HALF_PI)<\/code> rotates the coordinate system <code>HALF_PI<\/code> radians, which is\na quarter turn (90\u02da).<\/p>\n<p>Note: <code>TWO_PI<\/code> radians equals 360\u02da, <code>PI<\/code> radians equals 180\u02da, <code>HALF_PI<\/code>\nradians equals 90\u02da, and <code>QUARTER_PI<\/code> radians equals 45\u02da.<\/p>\n","itemtype":"property","name":"HALF_PI","type":"Number","final":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw an arc from 0 to HALF_PI.\n  arc(50, 50, 80, 80, 0, HALF_PI);\n\n  describe('The bottom-right quarter of a circle drawn in white on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw a line.\n  line(0, 0, 40, 0);\n\n  \/\/ Rotate a quarter turn.\n  rotate(HALF_PI);\n\n  \/\/ Draw the same line, rotated.\n  line(0, 0, 40, 0);\n\n  describe('Two black lines on a gray background. One line extends from the center to the right. The other line extends from the center to the bottom.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Calculate the x-coordinates.\n  let x1 = 40 * sin(frameCount * 0.05);\n  let x2 = 40 * sin(frameCount * 0.05 + HALF_PI);\n\n  \/\/ Style the oscillators.\n  noStroke();\n\n  \/\/ Draw the red oscillator.\n  fill(255, 0, 0);\n  circle(x1, 0, 20);\n\n  \/\/ Draw the blue oscillator.\n  fill(0, 0, 255);\n  circle(x2, 0, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":178,"description":"<p>A <code>Number<\/code> constant that's approximately 3.1416.<\/p>\n<p><code>PI<\/code> is the mathematical constant \u03c0. It's useful for many tasks that\ninvolve rotation and oscillation. For example, calling <code>rotate(PI)<\/code> rotates\nthe coordinate system <code>PI<\/code> radians, which is a half turn (180\u02da).<\/p>\n<p>Note: <code>TWO_PI<\/code> radians equals 360\u02da, <code>PI<\/code> radians equals 180\u02da, <code>HALF_PI<\/code>\nradians equals 90\u02da, and <code>QUARTER_PI<\/code> radians equals 45\u02da.<\/p>\n","itemtype":"property","name":"PI","type":"Number","final":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw an arc from 0 to PI.\n  arc(50, 50, 80, 80, 0, PI);\n\n  describe('The bottom half of a circle drawn in white on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw a line.\n  line(0, 0, 40, 0);\n\n  \/\/ Rotate a half turn.\n  rotate(PI);\n\n  \/\/ Draw the same line, rotated.\n  line(0, 0, 40, 0);\n\n  describe('A horizontal black line on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A red circle and a blue circle oscillate from left to right on a gray background. The circles drift apart, then meet in the middle, over and over again.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Calculate the x-coordinates.\n  let x1 = 40 * sin(frameCount * 0.05);\n  let x2 = 40 * sin(frameCount * 0.05 + PI);\n\n  \/\/ Style the oscillators.\n  noStroke();\n\n  \/\/ Draw the red oscillator.\n  fill(255, 0, 0);\n  circle(x1, 0, 20);\n\n  \/\/ Draw the blue oscillator.\n  fill(0, 0, 255);\n  circle(x2, 0, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":267,"description":"<p>A <code>Number<\/code> constant that's approximately 0.7854.<\/p>\n<p><code>QUARTER_PI<\/code> is one-fourth the value of the mathematical constant \u03c0. It's\nuseful for many tasks that involve rotation and oscillation. For example,\ncalling <code>rotate(QUARTER_PI)<\/code> rotates the coordinate system <code>QUARTER_PI<\/code>\nradians, which is an eighth of a turn (45\u02da).<\/p>\n<p>Note: <code>TWO_PI<\/code> radians equals 360\u02da, <code>PI<\/code> radians equals 180\u02da, <code>HALF_PI<\/code>\nradians equals 90\u02da, and <code>QUARTER_PI<\/code> radians equals 45\u02da.<\/p>\n","itemtype":"property","name":"QUARTER_PI","type":"Number","final":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw an arc from 0 to QUARTER_PI.\n  arc(50, 50, 80, 80, 0, QUARTER_PI);\n\n  describe('A one-eighth slice of a circle drawn in white on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw a line.\n  line(0, 0, 40, 0);\n\n  \/\/ Rotate an eighth turn.\n  rotate(QUARTER_PI);\n\n  \/\/ Draw the same line, rotated.\n  line(0, 0, 40, 0);\n\n  describe('Two black lines that form a \"V\" opening towards the bottom-right corner of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Calculate the x-coordinates.\n  let x1 = 40 * sin(frameCount * 0.05);\n  let x2 = 40 * sin(frameCount * 0.05 + QUARTER_PI);\n\n  \/\/ Style the oscillators.\n  noStroke();\n\n  \/\/ Draw the red oscillator.\n  fill(255, 0, 0);\n  circle(x1, 0, 20);\n\n  \/\/ Draw the blue oscillator.\n  fill(0, 0, 255);\n  circle(x2, 0, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":357,"description":"<p>A <code>Number<\/code> constant that's approximately 6.2382.<\/p>\n<p><code>TAU<\/code> is twice the value of the mathematical constant \u03c0. It's useful for\nmany tasks that involve rotation and oscillation. For example, calling\n<code>rotate(TAU)<\/code> rotates the coordinate system <code>TAU<\/code> radians, which is one\nfull turn (360\u02da). <code>TAU<\/code> and <code>TWO_PI<\/code> are equal.<\/p>\n<p>Note: <code>TAU<\/code> radians equals 360\u02da, <code>PI<\/code> radians equals 180\u02da, <code>HALF_PI<\/code>\nradians equals 90\u02da, and <code>QUARTER_PI<\/code> radians equals 45\u02da.<\/p>\n","itemtype":"property","name":"TAU","type":"Number","final":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw an arc from 0 to TAU.\n  arc(50, 50, 80, 80, 0, TAU);\n\n  describe('A white circle drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw a line.\n  line(0, 0, 40, 0);\n\n  \/\/ Rotate a full turn.\n  rotate(TAU);\n\n  \/\/ Style the second line.\n  strokeWeight(5);\n\n  \/\/ Draw the same line, shorter and rotated.\n  line(0, 0, 20, 0);\n\n  describe(\n    'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A red circle with a blue center oscillates from left to right on a gray background.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Calculate the x-coordinates.\n  let x1 = 40 * sin(frameCount * 0.05);\n  let x2 = 40 * sin(frameCount * 0.05 + TAU);\n\n  \/\/ Style the oscillators.\n  noStroke();\n\n  \/\/ Draw the red oscillator.\n  fill(255, 0, 0);\n  circle(x1, 0, 20);\n\n  \/\/ Draw the blue oscillator, smaller.\n  fill(0, 0, 255);\n  circle(x2, 0, 10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":452,"description":"<p>A <code>Number<\/code> constant that's approximately 6.2382.<\/p>\n<p><code>TWO_PI<\/code> is twice the value of the mathematical constant \u03c0. It's useful for\nmany tasks that involve rotation and oscillation. For example, calling\n<code>rotate(TWO_PI)<\/code> rotates the coordinate system <code>TWO_PI<\/code> radians, which is\none full turn (360\u02da). <code>TWO_PI<\/code> and <code>TAU<\/code> are equal.<\/p>\n<p>Note: <code>TWO_PI<\/code> radians equals 360\u02da, <code>PI<\/code> radians equals 180\u02da, <code>HALF_PI<\/code>\nradians equals 90\u02da, and <code>QUARTER_PI<\/code> radians equals 45\u02da.<\/p>\n","itemtype":"property","name":"TWO_PI","type":"Number","final":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw an arc from 0 to TWO_PI.\n  arc(50, 50, 80, 80, 0, TWO_PI);\n\n  describe('A white circle drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw a line.\n  line(0, 0, 40, 0);\n\n  \/\/ Rotate a full turn.\n  rotate(TWO_PI);\n\n  \/\/ Style the second line.\n  strokeWeight(5);\n\n  \/\/ Draw the same line, shorter and rotated.\n  line(0, 0, 20, 0);\n\n  describe(\n    'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A red circle with a blue center oscillates from left to right on a gray background.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Calculate the x-coordinates.\n  let x1 = 40 * sin(frameCount * 0.05);\n  let x2 = 40 * sin(frameCount * 0.05 + TWO_PI);\n\n  \/\/ Style the oscillators.\n  noStroke();\n\n  \/\/ Draw the red oscillator.\n  fill(255, 0, 0);\n  circle(x1, 0, 20);\n\n  \/\/ Draw the blue oscillator, smaller.\n  fill(0, 0, 255);\n  circle(x2, 0, 10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":547,"description":"<p>A <code>String<\/code> constant that's used to set the\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>By default, functions such as <a href=\"#\/p5\/rotate\">rotate()<\/a> and\n<a href=\"#\/p5\/sin\">sin()<\/a> expect angles measured in units of radians.\nCalling <code>angleMode(DEGREES)<\/code> ensures that angles are measured in units of\ndegrees.<\/p>\n<p>Note: <code>TWO_PI<\/code> radians equals 360\u02da.<\/p>\n","itemtype":"property","name":"DEGREES","type":"String","final":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw a red arc from 0 to HALF_PI radians.\n  fill(255, 0, 0);\n  arc(50, 50, 80, 80, 0, HALF_PI);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Draw a blue arc from 90\u02da to 180\u02da.\n  fill(0, 0, 255);\n  arc(50, 50, 80, 80, 90, 180);\n\n  describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":587,"description":"<p>A <code>String<\/code> constant that's used to set the\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>By default, functions such as <a href=\"#\/p5\/rotate\">rotate()<\/a> and\n<a href=\"#\/p5\/sin\">sin()<\/a> expect angles measured in units of radians.\nCalling <code>angleMode(RADIANS)<\/code> ensures that angles are measured in units of\nradians. Doing so can be useful if the\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a> has been set to\n<a href=\"#\/p5\/DEGREES\">DEGREES<\/a>.<\/p>\n<p>Note: <code>TWO_PI<\/code> radians equals 360\u02da.<\/p>\n","itemtype":"property","name":"RADIANS","type":"String","final":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Draw a red arc from 0\u02da to 90\u02da.\n  fill(255, 0, 0);\n  arc(50, 50, 80, 80, 0, 90);\n\n  \/\/ Use radians.\n  angleMode(RADIANS);\n\n  \/\/ Draw a blue arc from HALF_PI to PI.\n  fill(0, 0, 255);\n  arc(50, 50, 80, 80, HALF_PI, PI);\n\n  describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":635,"itemtype":"property","name":"CORNER","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":640,"itemtype":"property","name":"CORNERS","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":645,"itemtype":"property","name":"RADIUS","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":650,"itemtype":"property","name":"RIGHT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":655,"itemtype":"property","name":"LEFT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":660,"itemtype":"property","name":"CENTER","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":665,"itemtype":"property","name":"TOP","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":670,"itemtype":"property","name":"BOTTOM","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":675,"itemtype":"property","name":"BASELINE","type":"String","final":1,"default":"alphabetic","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":681,"itemtype":"property","name":"POINTS","type":"Number","final":1,"default":"0x0000","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":687,"itemtype":"property","name":"LINES","type":"Number","final":1,"default":"0x0001","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":693,"itemtype":"property","name":"LINE_STRIP","type":"Number","final":1,"default":"0x0003","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":699,"itemtype":"property","name":"LINE_LOOP","type":"Number","final":1,"default":"0x0002","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":705,"itemtype":"property","name":"TRIANGLES","type":"Number","final":1,"default":"0x0004","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":711,"itemtype":"property","name":"TRIANGLE_FAN","type":"Number","final":1,"default":"0x0006","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":717,"itemtype":"property","name":"TRIANGLE_STRIP","type":"Number","final":1,"default":"0x0005","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":723,"itemtype":"property","name":"QUADS","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":728,"itemtype":"property","name":"QUAD_STRIP","type":"String","final":1,"default":"quad_strip","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":734,"itemtype":"property","name":"TESS","type":"String","final":1,"default":"tess","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":740,"itemtype":"property","name":"CLOSE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":745,"itemtype":"property","name":"OPEN","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":750,"itemtype":"property","name":"CHORD","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":755,"itemtype":"property","name":"PIE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":760,"itemtype":"property","name":"PROJECT","type":"String","final":1,"default":"square","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":766,"itemtype":"property","name":"SQUARE","type":"String","final":1,"default":"butt","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":772,"itemtype":"property","name":"ROUND","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":777,"itemtype":"property","name":"BEVEL","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":782,"itemtype":"property","name":"MITER","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":789,"itemtype":"property","name":"RGB","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":794,"description":"<p>HSB (hue, saturation, brightness) is a type of color model.\nYou can learn more about it at\n<a href=\"https:\/\/learnui.design\/blog\/the-hsb-color-system-practicioners-primer.html\">HSB<\/a>.<\/p>\n","itemtype":"property","name":"HSB","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":803,"itemtype":"property","name":"HSL","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":810,"description":"<p>AUTO allows us to automatically set the width or height of an element (but not both),\nbased on the current height and width of the element. Only one parameter can\nbe passed to the <a href=\"\/reference\/p5.Element\/size\">size<\/a> function as AUTO, at a time.<\/p>\n","itemtype":"property","name":"AUTO","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":820,"itemtype":"property","name":"ALT","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":826,"itemtype":"property","name":"BACKSPACE","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":831,"itemtype":"property","name":"CONTROL","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":836,"itemtype":"property","name":"DELETE","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":841,"itemtype":"property","name":"DOWN_ARROW","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":846,"itemtype":"property","name":"ENTER","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":851,"itemtype":"property","name":"ESCAPE","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":856,"itemtype":"property","name":"LEFT_ARROW","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":861,"itemtype":"property","name":"OPTION","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":866,"itemtype":"property","name":"RETURN","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":871,"itemtype":"property","name":"RIGHT_ARROW","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":876,"itemtype":"property","name":"SHIFT","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":881,"itemtype":"property","name":"TAB","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":886,"itemtype":"property","name":"UP_ARROW","type":"Number","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":893,"itemtype":"property","name":"BLEND","type":"String","final":1,"default":"source-over","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":899,"itemtype":"property","name":"REMOVE","type":"String","final":1,"default":"destination-out","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":905,"itemtype":"property","name":"ADD","type":"String","final":1,"default":"lighter","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":913,"itemtype":"property","name":"DARKEST","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":918,"itemtype":"property","name":"LIGHTEST","type":"String","final":1,"default":"lighten","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":924,"itemtype":"property","name":"DIFFERENCE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":929,"itemtype":"property","name":"SUBTRACT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":934,"itemtype":"property","name":"EXCLUSION","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":939,"itemtype":"property","name":"MULTIPLY","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":944,"itemtype":"property","name":"SCREEN","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":949,"itemtype":"property","name":"REPLACE","type":"String","final":1,"default":"copy","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":955,"itemtype":"property","name":"OVERLAY","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":960,"itemtype":"property","name":"HARD_LIGHT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":965,"itemtype":"property","name":"SOFT_LIGHT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":970,"itemtype":"property","name":"DODGE","type":"String","final":1,"default":"color-dodge","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":976,"itemtype":"property","name":"BURN","type":"String","final":1,"default":"color-burn","class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":984,"itemtype":"property","name":"THRESHOLD","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":989,"itemtype":"property","name":"GRAY","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":994,"itemtype":"property","name":"OPAQUE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":999,"itemtype":"property","name":"INVERT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1004,"itemtype":"property","name":"POSTERIZE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1009,"itemtype":"property","name":"DILATE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1014,"itemtype":"property","name":"ERODE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1019,"itemtype":"property","name":"BLUR","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1026,"itemtype":"property","name":"NORMAL","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1031,"itemtype":"property","name":"ITALIC","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1036,"itemtype":"property","name":"BOLD","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1041,"itemtype":"property","name":"BOLDITALIC","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1046,"itemtype":"property","name":"CHAR","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1051,"itemtype":"property","name":"WORD","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1063,"itemtype":"property","name":"LINEAR","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1068,"itemtype":"property","name":"QUADRATIC","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1073,"itemtype":"property","name":"BEZIER","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1078,"itemtype":"property","name":"CURVE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1085,"itemtype":"property","name":"STROKE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1090,"itemtype":"property","name":"FILL","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1095,"itemtype":"property","name":"TEXTURE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1100,"itemtype":"property","name":"IMMEDIATE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1108,"itemtype":"property","name":"IMAGE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1116,"itemtype":"property","name":"NEAREST","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1121,"itemtype":"property","name":"REPEAT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1126,"itemtype":"property","name":"CLAMP","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1131,"itemtype":"property","name":"MIRROR","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1138,"itemtype":"property","name":"FLAT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1143,"itemtype":"property","name":"SMOOTH","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1150,"itemtype":"property","name":"LANDSCAPE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1155,"itemtype":"property","name":"PORTRAIT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1165,"itemtype":"property","name":"GRID","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1171,"itemtype":"property","name":"AXES","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1177,"itemtype":"property","name":"LABEL","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1182,"itemtype":"property","name":"FALLBACK","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1188,"itemtype":"property","name":"CONTAIN","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1194,"itemtype":"property","name":"COVER","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1200,"itemtype":"property","name":"UNSIGNED_BYTE","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1206,"itemtype":"property","name":"UNSIGNED_INT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1212,"itemtype":"property","name":"FLOAT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1218,"itemtype":"property","name":"HALF_FLOAT","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/constants.js","line":1224,"itemtype":"property","name":"RGBA","type":"String","final":1,"class":"p5","module":"Constants","submodule":"Constants"},{"file":"src\/core\/environment.js","line":21,"description":"<p>Displays text in the web browser's console.<\/p>\n<p><code>print()<\/code> is helpful for printing values while debugging. Each call to\n<code>print()<\/code> creates a new line of text.<\/p>\n<p>Note: Call <code>print('\\n')<\/code> to print a blank line. Calling <code>print()<\/code> without\nan argument opens the browser's dialog for printing documents.<\/p>\n","itemtype":"method","name":"print","params":[{"name":"contents","description":"<p>content to print to the console.<\/p>\n","type":"Any"}],"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Prints \"hello, world\" to the console.\n  print('hello, world');\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let name = 'ada';\n  \/\/ Prints \"hello, ada\" to the console.\n  print(`hello, ${name}`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":69,"description":"<p>A <code>Number<\/code> variable that tracks the number of frames drawn since the sketch\nstarted.<\/p>\n<p><code>frameCount<\/code>'s value is 0 inside <a href=\"#\/p5\/setup\">setup()<\/a>. It\nincrements by 1 each time the code in <a href=\"#\/p5\/draw\">draw()<\/a>\nfinishes executing.<\/p>\n","itemtype":"property","name":"frameCount","type":"Integer","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Display the value of\n  \/\/ frameCount.\n  textSize(30);\n  textAlign(CENTER, CENTER);\n  text(frameCount, 50, 50);\n\n  describe('The number 0 written in black in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Set the frameRate to 30.\n  frameRate(30);\n\n  textSize(30);\n  textAlign(CENTER, CENTER);\n\n  describe('A number written in black in the middle of a gray square. Its value increases rapidly.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Display the value of\n  \/\/ frameCount.\n  text(frameCount, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":124,"description":"<p>A <code>Number<\/code> variable that tracks the number of milliseconds it took to draw\nthe last frame.<\/p>\n<p><code>deltaTime<\/code> contains the amount of time it took\n<a href=\"#\/p5\/draw\">draw()<\/a> to execute during the previous frame. It's\nuseful for simulating physics.<\/p>\n","itemtype":"property","name":"deltaTime","type":"Integer","readonly":"","example":["\n<div>\n<code>\nlet x = 0;\nlet speed = 0.05;\n\nfunction setup()  {\n  createCanvas(100, 100);\n\n  \/\/ Set the frameRate to 30.\n  frameRate(30);\n\n  describe('A white circle moves from left to right on a gray background. It reappears on the left side when it reaches the right side.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Use deltaTime to calculate\n  \/\/ a change in position.\n  let deltaX = speed * deltaTime;\n\n  \/\/ Update the x variable.\n  x += deltaX;\n\n  \/\/ Reset x to 0 if it's\n  \/\/ greater than 100.\n  if (x > 100)  {\n    x = 0;\n  }\n\n  \/\/ Use x to set the circle's\n  \/\/ position.\n  circle(x, 50, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":174,"description":"<p>A <code>Boolean<\/code> variable that's <code>true<\/code> if the browser is focused and <code>false<\/code> if\nnot.<\/p>\n<p>Note: The browser window can only receive input if it's focused.<\/p>\n","itemtype":"property","name":"focused","type":"Boolean","readonly":"","example":["\n<div>\n<code>\n\/\/ Open this example in two separate browser\n\/\/ windows placed side-by-side to demonstrate.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A square changes color from green to red when the browser window is out of focus.');\n}\n\nfunction draw() {\n  \/\/ Change the background color\n  \/\/ when the browser window\n  \/\/ goes in\/out of focus.\n  if (focused === true) {\n    background(0, 255, 0);\n  } else {\n    background(255, 0, 0);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":209,"description":"<p>Changes the cursor's appearance.<\/p>\n<p>The first parameter, <code>type<\/code>, sets the type of cursor to display. The\nbuilt-in options are <code>ARROW<\/code>, <code>CROSS<\/code>, <code>HAND<\/code>, <code>MOVE<\/code>, <code>TEXT<\/code>, and <code>WAIT<\/code>.\n<code>cursor()<\/code> also recognizes standard CSS cursor properties passed as\nstrings: <code>'help'<\/code>, <code>'wait'<\/code>, <code>'crosshair'<\/code>, <code>'not-allowed'<\/code>, <code>'zoom-in'<\/code>,\nand <code>'grab'<\/code>. If the path to an image is passed, as in\n<code>cursor('assets\/target.png')<\/code>, then the image will be used as the cursor.\nImages must be in .cur, .gif, .jpg, .jpeg, or .png format and should be <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/cursor#icon_size_limits\">at most 32 by 32 pixels large.<\/a><\/p>\n<p>The parameters <code>x<\/code> and <code>y<\/code> are optional. If an image is used for the\ncursor, <code>x<\/code> and <code>y<\/code> set the location pointed to within the image. They are\nboth 0 by default, so the cursor points to the image's top-left corner. <code>x<\/code>\nand <code>y<\/code> must be less than the image's width and height, respectively.<\/p>\n","itemtype":"method","name":"cursor","params":[{"name":"type","description":"<p>Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT.\n                              Native CSS properties: 'grab', 'progress', and so on.\n                              Path to cursor image.<\/p>\n","type":"String|Constant"},{"name":"x","description":"<p>horizontal active spot of the cursor.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>vertical active spot of the cursor.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A gray square. The cursor appears as crosshairs.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the cursor to crosshairs: +\n  cursor(CROSS);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A gray square divided into quadrants. The cursor image changes when the mouse moves to each quadrant.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Divide the canvas into quadrants.\n  line(50, 0, 50, 100);\n  line(0, 50, 100, 50);\n\n  \/\/ Change cursor based on mouse position.\n  if (mouseX < 50 && mouseY < 50) {\n    cursor(CROSS);\n  } else if (mouseX > 50 && mouseY < 50) {\n    cursor('progress');\n  } else if (mouseX > 50 && mouseY > 50) {\n    cursor('https:\/\/avatars0.githubusercontent.com\/u\/1617169?s=16');\n  } else {\n    cursor('grab');\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('An image of three purple curves follows the mouse. The image shifts when the mouse is pressed.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Change the cursor's active spot\n  \/\/ when the mouse is pressed.\n  if (mouseIsPressed === true) {\n    cursor('https:\/\/avatars0.githubusercontent.com\/u\/1617169?s=16', 8, 8);\n  } else {\n    cursor('https:\/\/avatars0.githubusercontent.com\/u\/1617169?s=16');\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":330,"description":"<p>Sets the number of frames to draw per second.<\/p>\n<p>Calling <code>frameRate()<\/code> with one numeric argument, as in <code>frameRate(30)<\/code>,\nattempts to draw 30 frames per second (FPS). The target frame rate may not\nbe achieved depending on the sketch's processing needs. Most computers\ndefault to a frame rate of 60 FPS. Frame rates of 24 FPS and above are\nfast enough for smooth animations.<\/p>\n<p>Calling <code>frameRate()<\/code> without an argument returns the current frame rate.\nThe value returned is an approximation.<\/p>\n","itemtype":"method","name":"frameRate","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the x variable based\n  \/\/ on the current frameCount.\n  let x = frameCount % 100;\n\n  \/\/ If the mouse is pressed,\n  \/\/ decrease the frame rate.\n  if (mouseIsPressed === true) {\n    frameRate(10);\n  } else {\n    frameRate(60);\n  }\n\n  \/\/ Use x to set the circle's\n  \/\/ position.\n  circle(x, 50, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A number written in black on a gray background. The number decreases when the mouse is pressed.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ If the mouse is pressed, do lots\n  \/\/ of math to slow down drawing.\n  if (mouseIsPressed === true) {\n    for (let i = 0; i < 1000000; i += 1) {\n      random();\n    }\n  }\n\n  \/\/ Get the current frame rate\n  \/\/ and display it.\n  let fps = frameRate();\n  text(fps, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment","overloads":[{"line":330,"params":[{"name":"fps","description":"<p>number of frames to draw per second.<\/p>\n","type":"Number"}],"chainable":1},{"line":404,"params":[],"return":{"description":"current frame rate.","type":"Number"}}]},{"file":"src\/core\/environment.js","line":447,"description":"<p>Returns the target frame rate.<\/p>\n<p>The value is either the system frame rate or the last value passed to\n<a href=\"#\/p5\/frameRate\">frameRate()<\/a>.<\/p>\n","itemtype":"method","name":"getTargetFrameRate","return":{"description":"_targetFrameRate","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('The number 20 written in black on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the frame rate to 20.\n  frameRate(20);\n\n  \/\/ Get the target frame rate and\n  \/\/ display it.\n  let fps = getTargetFrameRate();\n  text(fps, 43, 54);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":482,"description":"<p>Hides the cursor from view.<\/p>\n","itemtype":"method","name":"noCursor","example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Hide the cursor.\n  noCursor();\n}\n\nfunction draw() {\n  background(200);\n\n  circle(mouseX, mouseY, 10);\n\n  describe('A white circle on a gray background. The circle follows the mouse as it moves. The cursor is hidden.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":508,"description":"<p>A <code>String<\/code> variable with the WebGL version in use.<\/p>\n<p><code>webglVersion<\/code>'s value equals one of the following string constants:<\/p>\n<ul>\n<li><code>WEBGL2<\/code> whose value is <code>'webgl2'<\/code>,<\/li>\n<li><code>WEBGL<\/code> whose value is <code>'webgl'<\/code>, or<\/li>\n<li><code>P2D<\/code> whose value is <code>'p2d'<\/code>. This is the default for 2D sketches.<\/li>\n<\/ul>\n<p>See <a href=\"#\/p5\/setAttributes\">setAttributes()<\/a> for ways to set the\nWebGL version.<\/p>\n","itemtype":"property","name":"webglVersion","type":"String","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  \/\/ Display the current WebGL version.\n  text(webglVersion, 42, 54);\n\n  describe('The text \"p2d\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  \/\/ Load a font to use.\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  \/\/ Create a canvas using WEBGL mode.\n  createCanvas(100, 50, WEBGL);\n  background(200);\n\n  \/\/ Display the current WebGL version.\n  fill(0);\n  textFont(font);\n  text(webglVersion, -15, 5);\n\n  describe('The text \"webgl2\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  \/\/ Load a font to use.\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  \/\/ Create a canvas using WEBGL mode.\n  createCanvas(100, 50, WEBGL);\n\n  \/\/ Set WebGL to version 1.\n  setAttributes({ version: 1 });\n\n  background(200);\n\n  \/\/ Display the current WebGL version.\n  fill(0);\n  textFont(font);\n  text(webglVersion, -14, 5);\n\n  describe('The text \"webgl\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":590,"description":"<p>A <code>Number<\/code> variable that stores the width of the screen display.<\/p>\n<p><code>displayWidth<\/code> is useful for running full-screen programs. Its value\ndepends on the current <a href=\"#\/p5\/pixelDensity\">pixelDensity()<\/a>.<\/p>\n<p>Note: The actual screen width can be computed as\n<code>displayWidth * pixelDensity()<\/code>.<\/p>\n","itemtype":"property","name":"displayWidth","type":"Number","readonly":"","example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Set the canvas' width and height\n  \/\/ using the display's dimensions.\n  createCanvas(displayWidth, displayHeight);\n\n  background(200);\n\n  describe('A gray canvas that is the same size as the display.');\n}\n<\/code>\n<\/div>"],"alt":"This example does not render anything.","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":621,"description":"<p>A <code>Number<\/code> variable that stores the height of the screen display.<\/p>\n<p><code>displayHeight<\/code> is useful for running full-screen programs. Its value\ndepends on the current <a href=\"#\/p5\/pixelDensity\">pixelDensity()<\/a>.<\/p>\n<p>Note: The actual screen height can be computed as\n<code>displayHeight * pixelDensity()<\/code>.<\/p>\n","itemtype":"property","name":"displayHeight","type":"Number","readonly":"","example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Set the canvas' width and height\n  \/\/ using the display's dimensions.\n  createCanvas(displayWidth, displayHeight);\n\n  background(200);\n\n  describe('A gray canvas that is the same size as the display.');\n}\n<\/code>\n<\/div>"],"alt":"This example does not render anything.","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":652,"description":"<p>A <code>Number<\/code> variable that stores the width of the browser's viewport.<\/p>\n<p>The <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/Layout_viewport\" target=\"_blank\">layout viewport<\/a>\nis the area within the browser that's available for drawing.<\/p>\n","itemtype":"property","name":"windowWidth","type":"Number","readonly":"","example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Set the canvas' width and height\n  \/\/ using the browser's dimensions.\n  createCanvas(windowWidth, windowHeight);\n\n  background(200);\n\n  describe('A gray canvas that takes up the entire browser window.');\n}\n<\/code>\n<\/div>"],"alt":"This example does not render anything.","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":680,"description":"<p>A <code>Number<\/code> variable that stores the height of the browser's viewport.<\/p>\n<p>The <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/Layout_viewport\" target=\"_blank\">layout viewport<\/a>\nis the area within the browser that's available for drawing.<\/p>\n","itemtype":"property","name":"windowHeight","type":"Number","readonly":"","example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Set the canvas' width and height\n  \/\/ using the browser's dimensions.\n  createCanvas(windowWidth, windowHeight);\n\n  background(200);\n\n  describe('A gray canvas that takes up the entire browser window.');\n}\n<\/code>\n<\/div>"],"alt":"This example does not render anything.","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":708,"description":"<p>A function that's called when the browser window is resized.<\/p>\n<p>Code placed in the body of <code>windowResized()<\/code> will run when the\nbrowser window's size changes. It's a good place to call\n<a href=\"#\/p5\/resizeCanvas\">resizeCanvas()<\/a> or make other\nadjustments to accommodate the new window size.<\/p>\n<p>The <code>event<\/code> parameter is optional. If added to the function declaration, it\ncan be used for debugging or other purposes.<\/p>\n","itemtype":"method","name":"windowResized","params":[{"name":"event","description":"<p>optional resize Event.<\/p>\n","type":"Event","optional":true}],"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  createCanvas(windowWidth, windowHeight);\n\n  describe('A gray canvas with a white circle at its center. The canvas takes up the entire browser window. It changes size to match the browser window.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a circle at the center.\n  circle(width \/ 2, height \/ 2, 50);\n}\n\n\/\/ Resize the canvas when the\n\/\/ browser's size changes.\nfunction windowResized() {\n  resizeCanvas(windowWidth, windowHeight);\n}\n<\/code>\n<\/div>"],"alt":"This example does not render anything.","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":803,"description":"<p>Called upon each p5 instantiation instead of module import due to the\npossibility of the window being resized when no sketch is active.<\/p>\n","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":812,"description":"<p>A <code>Number<\/code> variable that stores the width of the canvas in pixels.<\/p>\n<p><code>width<\/code>'s default value is 100. Calling\n<a href=\"#\/p5\/createCanvas\">createCanvas()<\/a> or\n<a href=\"#\/p5\/resizeCanvas\">resizeCanvas()<\/a> changes the value of\n<code>width<\/code>. Calling <a href=\"#\/p5\/noCanvas\">noCanvas()<\/a> sets its value to\n0.<\/p>\n","example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  \/\/ Display the canvas' width.\n  text(width, 42, 54);\n\n  describe('The number 100 written in black on a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(50, 100);\n\n  background(200);\n\n  \/\/ Display the canvas' width.\n  text(width, 21, 54);\n\n  describe('The number 50 written in black on a gray rectangle.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Display the canvas' width.\n  text(width, 42, 54);\n\n  describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.');\n}\n\n\/\/ If the mouse is pressed, reisze\n\/\/ the canvas and display its new\n\/\/ width.\nfunction mousePressed() {\n  if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n    resizeCanvas(50, 100);\n    background(200);\n    text(width, 21, 54);\n  }\n}\n<\/code>\n<\/div>"],"itemtype":"property","name":"width","type":"Number","readonly":"","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":881,"description":"<p>A <code>Number<\/code> variable that stores the height of the canvas in pixels.<\/p>\n<p><code>height<\/code>'s default value is 100. Calling\n<a href=\"#\/p5\/createCanvas\">createCanvas()<\/a> or\n<a href=\"#\/p5\/resizeCanvas\">resizeCanvas()<\/a> changes the value of\n<code>height<\/code>. Calling <a href=\"#\/p5\/noCanvas\">noCanvas()<\/a> sets its value to\n0.<\/p>\n","example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  \/\/ Display the canvas' height.\n  text(height, 42, 54);\n\n  describe('The number 100 written in black on a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 50);\n\n  background(200);\n\n  \/\/ Display the canvas' height.\n  text(height, 42, 27);\n\n  describe('The number 50 written in black on a gray rectangle.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Display the canvas' height.\n  text(height, 42, 54);\n\n  describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.');\n}\n\n\/\/ If the mouse is pressed, reisze\n\/\/ the canvas and display its new\n\/\/ height.\nfunction mousePressed() {\n  if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n    resizeCanvas(100, 50);\n    background(200);\n    text(height, 42, 27);\n  }\n}\n<\/code>\n<\/div>"],"itemtype":"property","name":"height","type":"Number","readonly":"","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":950,"description":"<p>Toggles full-screen mode or returns the current mode.<\/p>\n<p>Calling <code>fullscreen(true)<\/code> makes the sketch full-screen. Calling\n<code>fullscreen(false)<\/code> makes the sketch its original size.<\/p>\n<p>Calling <code>fullscreen()<\/code> without an argument returns <code>true<\/code> if the sketch\nis in full-screen mode and <code>false<\/code> if not.<\/p>\n<p>Note: Due to browser restrictions, <code>fullscreen()<\/code> can only be called with\nuser input such as a mouse press.<\/p>\n","itemtype":"method","name":"fullscreen","params":[{"name":"val","description":"<p>whether the sketch should be in fullscreen mode.<\/p>\n","type":"Boolean","optional":true}],"return":{"description":"current fullscreen state.","type":"Boolean"},"example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  describe('A gray canvas that switches between default and full-screen display when clicked.');\n}\n\n\/\/ If the mouse is pressed,\n\/\/ toggle full-screen mode.\nfunction mousePressed() {\n  if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n    let fs = fullscreen();\n    fullscreen(!fs);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":1005,"description":"<p>Sets the pixel density or returns the current density.<\/p>\n<p>Computer displays are grids of little lights called <em>pixels<\/em>. A\ndisplay's <em>pixel density<\/em> describes how many pixels it packs into an\narea. Displays with smaller pixels have a higher pixel density and create\nsharper images.<\/p>\n<p><code>pixelDensity()<\/code> sets the pixel scaling for high pixel density displays.\nBy default, the pixel density is set to match the display's density.\nCalling <code>pixelDensity(1)<\/code> turn this off.<\/p>\n<p>Calling <code>pixelDensity()<\/code> without an argument returns the current pixel\ndensity.<\/p>\n","itemtype":"method","name":"pixelDensity","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Set the pixel density to 1.\n  pixelDensity(1);\n\n  \/\/ Create a canvas and draw\n  \/\/ a circle.\n  createCanvas(100, 100);\n  background(200);\n  circle(50, 50, 70);\n\n  describe('A fuzzy white circle on a gray canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Set the pixel density to 3.\n  pixelDensity(3);\n\n  \/\/ Create a canvas, paint the\n  \/\/ background, and draw a\n  \/\/ circle.\n  createCanvas(100, 100);\n  background(200);\n  circle(50, 50, 70);\n\n  describe('A sharp white circle on a gray canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment","overloads":[{"line":1005,"params":[{"name":"val","description":"<p>desired pixel density.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1059,"params":[],"return":{"description":"current pixel density of the sketch.","type":"Number"}}]},{"file":"src\/core\/environment.js","line":1078,"description":"<p>Returns the display's current pixel density.<\/p>\n","itemtype":"method","name":"displayDensity","return":{"description":"current pixel density of the display.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Set the pixel density to 1.\n  pixelDensity(1);\n\n  \/\/ Create a canvas and draw\n  \/\/ a circle.\n  createCanvas(100, 100);\n  background(200);\n  circle(50, 50, 70);\n\n  describe('A fuzzy white circle drawn on a gray background. The circle becomes sharper when the mouse is pressed.');\n}\n\nfunction mousePressed() {\n  \/\/ Get the current display density.\n  let d = displayDensity();\n\n  \/\/ Use the display density to set\n  \/\/ the sketch's pixel density.\n  pixelDensity(d);\n\n  \/\/ Paint the background and\n  \/\/ draw a circle.\n  background(200);\n  circle(50, 50, 70);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":1149,"description":"<p>Returns the sketch's current\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/Common_questions\/Web_mechanics\/What_is_a_URL\" target=\"_blank\">URL<\/a>\nas a <code>String<\/code>.<\/p>\n","itemtype":"method","name":"getURL","return":{"description":"url","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  \/\/ Get the sketch's URL\n  \/\/ and display it.\n  let url = getURL();\n  textWrap(CHAR);\n  text(url, 0, 40, 100);\n\n  describe('The URL \"https:\/\/p5js.org\/reference\/p5\/getURL\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":1175,"description":"<p>Returns the current\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/Common_questions\/Web_mechanics\/What_is_a_URL#path_to_resource\" target=\"_blank\">URL<\/a>\npath as an <code>Array<\/code> of <code>String<\/code>s.<\/p>\n<p>For example, consider a sketch hosted at the URL\n<code>https:\/\/example.com\/sketchbook<\/code>. Calling <code>getURLPath()<\/code> returns\n<code>['sketchbook']<\/code>. For a sketch hosted at the URL\n<code>https:\/\/example.com\/sketchbook\/monday<\/code>, <code>getURLPath()<\/code> returns\n<code>['sketchbook', 'monday']<\/code>.<\/p>\n","itemtype":"method","name":"getURLPath","return":{"description":"path components.","type":"String[]"},"example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  \/\/ Get the sketch's URL path\n  \/\/ and display the first\n  \/\/ part.\n  let path = getURLPath();\n  text(path[0], 25, 54);\n\n  describe('The word \"reference\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/environment.js","line":1208,"description":"<p>Returns the current\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/Common_questions\/Web_mechanics\/What_is_a_URL#parameters\" target=\"_blank\">URL parameters<\/a>\nin an <code>Object<\/code>.<\/p>\n<p>For example, calling <code>getURLParams()<\/code> in a sketch hosted at the URL\n<code>https:\/\/p5js.org?year=2014&month=May&day=15<\/code> returns\n<code>{ year: 2014, month: 'May', day: 15 }<\/code>.<\/p>\n","itemtype":"method","name":"getURLParams","return":{"description":"URL params","type":"Object"},"example":["\n<div class='norender notest'>\n<code>\n\/\/ Imagine this sketch is hosted at the following URL:\n\/\/ https:\/\/p5js.org?year=2014&month=May&day=15\n\nfunction setup() {\n  background(200);\n\n  \/\/ Get the sketch's URL\n  \/\/ parameters and display\n  \/\/ them.\n  let params = getURLParams();\n  text(params.day, 10, 20);\n  text(params.month, 10, 40);\n  text(params.year, 10, 60);\n\n  describe('The text \"15\", \"May\", and \"2014\" written in black on separate lines.');\n}\n<\/code>\n<\/div>"],"alt":"This example does not render anything.","class":"p5","module":"Environment","submodule":"Environment"},{"file":"src\/core\/helpers.js","line":1,"requires":["constants"],"class":"p5","module":"Environment"},{"file":"src\/core\/internationalization.js","line":32,"description":"<p>This is our i18next \"backend\" plugin. It tries to fetch languages\nfrom a CDN.<\/p>\n","class":"p5","module":"Environment"},{"file":"src\/core\/internationalization.js","line":128,"description":"<p>Set up our translation function, with loaded languages<\/p>\n","class":"p5","module":"Environment"},{"file":"src\/core\/internationalization.js","line":177,"description":"<p>Returns a list of languages we have translations loaded for<\/p>\n","class":"p5","module":"Environment"},{"file":"src\/core\/internationalization.js","line":184,"description":"<p>Returns the current language selected for translation<\/p>\n","class":"p5","module":"Environment"},{"file":"src\/core\/internationalization.js","line":191,"description":"<p>Sets the current language for translation\nReturns a promise that resolved when loading is finished,\nor rejects if it fails.<\/p>\n","class":"p5","module":"Environment"},{"file":"src\/core\/legacy.js","line":1,"requires":["core\nThese are functions that are part of the Processing API but are not part of\nthe p5.js API. In some cases they have a new name","in others","they are\nremoved completely. Not all unsupported Processing functions are listed here\nbut we try to include ones that a user coming from Processing might likely\ncall."],"class":"p5","module":"Environment"},{"file":"src\/core\/main.js","line":41,"description":"<p>A function that's called once to load assets before the sketch runs.<\/p>\n<p>Declaring the function <code>preload()<\/code> sets a code block to run once\nautomatically before <a href=\"#\/p5\/setup\">setup()<\/a> or\n<a href=\"#\/p5\/draw\">draw()<\/a>. It's used to load assets including\nmultimedia files, fonts, data, and 3D models:<\/p>\n<pre><code class=\"language-js\">function preload() {\n  \/\/ Code to run before the rest of the sketch.\n}\n<\/code><\/pre>\n<p>Functions such as <a href=\"#\/p5\/loadImage\">loadImage()<\/a>,\n<a href=\"#\/p5\/loadFont\">loadFont()<\/a>,\n<a href=\"#\/p5\/loadJSON\">loadJSON()<\/a>, and\n<a href=\"#\/p5\/loadModel\">loadModel()<\/a> are guaranteed to either\nfinish loading or raise an error if they're called within <code>preload()<\/code>.\nDoing so ensures that assets are available when the sketch begins\nrunning.<\/p>\n","itemtype":"method","name":"preload","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load an image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Draw the image.\n  image(img, 0, 0);\n\n  describe('A red brick wall.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/main.js","line":87,"description":"<p>A function that's called once when the sketch begins running.<\/p>\n<p>Declaring the function <code>setup()<\/code> sets a code block to run once\nautomatically when the sketch starts running. It's used to perform\nsetup tasks such as creating the canvas and initializing variables:<\/p>\n<pre><code class=\"language-js\">function setup() {\n  \/\/ Code to run once at the start of the sketch.\n}\n<\/code><\/pre>\n<p>Code placed in <code>setup()<\/code> will run once before code placed in\n<a href=\"#\/p5\/draw\">draw()<\/a> begins looping. If the\n<a href=\"#\/p5\/preload\">preload()<\/a> is declared, then <code>setup()<\/code> will\nrun immediately after <a href=\"#\/p5\/preload\">preload()<\/a> finishes\nloading assets.<\/p>\n<p>Note: <code>setup()<\/code> doesn\u2019t have to be declared, but it\u2019s common practice to do so.<\/p>\n","itemtype":"method","name":"setup","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 40);\n\n  describe('A white circle on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Paint the background once.\n  background(200);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.'\n  );\n}\n\nfunction draw() {\n  \/\/ Draw circles repeatedly.\n  circle(mouseX, mouseY, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Draw the image.\n  image(img, 0, 0);\n\n  describe(\n    'A white circle on a brick wall. The circle follows the mouse as the user moves, leaving a trail.'\n  );\n}\n\nfunction draw() {\n  \/\/ Style the circle.\n  noStroke();\n\n  \/\/ Draw the circle.\n  circle(mouseX, mouseY, 10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/main.js","line":176,"description":"<p>A function that's called repeatedly while the sketch runs.<\/p>\n<p>Declaring the function <code>draw()<\/code> sets a code block to run repeatedly\nonce the sketch starts. It\u2019s used to create animations and respond to\nuser inputs:<\/p>\n<pre><code class=\"language-js\">function draw() {\n  \/\/ Code to run repeatedly.\n}\n<\/code><\/pre>\n<p>This is often called the \"draw loop\" because p5.js calls the code in\n<code>draw()<\/code> in a loop behind the scenes. By default, <code>draw()<\/code> tries to run\n60 times per second. The actual rate depends on many factors. The\ndrawing rate, called the \"frame rate\", can be controlled by calling\n<a href=\"#\/p5\/frameRate\">frameRate()<\/a>. The number of times <code>draw()<\/code>\nhas run is stored in the system variable\n<a href=\"#\/p5\/frameCount\">frameCount()<\/a>.<\/p>\n<p>Code placed within <code>draw()<\/code> begins looping after\n<a href=\"#\/p5\/setup\">setup()<\/a> runs. <code>draw()<\/code> will run until the user\ncloses the sketch. <code>draw()<\/code> can be stopped by calling the\n<a href=\"#\/p5\/noLoop\">noLoop()<\/a> function. <code>draw()<\/code> can be resumed by\ncalling the <a href=\"#\/p5\/loop\">loop()<\/a> function.<\/p>\n","itemtype":"method","name":"draw","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Paint the background once.\n  background(200);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.'\n  );\n}\n\nfunction draw() {\n  \/\/ Draw circles repeatedly.\n  circle(mouseX, mouseY, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse as the user moves.'\n  );\n}\n\nfunction draw() {\n  \/\/ Paint the background repeatedly.\n  background(200);\n\n  \/\/ Draw circles repeatedly.\n  circle(mouseX, mouseY, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click the canvas to change the circle's color.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse as the user moves. The circle changes color to pink when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  \/\/ Paint the background repeatedly.\n  background(200);\n\n  \/\/ Draw circles repeatedly.\n  circle(mouseX, mouseY, 40);\n}\n\n\/\/ Change the fill color when the user double-clicks.\nfunction doubleClicked() {\n  fill('deeppink');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/main.js","line":559,"description":"<p>Removes the sketch from the web page.<\/p>\n<p>Calling <code>remove()<\/code> stops the draw loop and removes any HTML elements\ncreated by the sketch, including the canvas. A new sketch can be\ncreated by using the <a href=\"#\/p5\/p5\">p5()<\/a> constructor, as in\n<code>new p5()<\/code>.<\/p>\n","itemtype":"method","name":"remove","example":["\n<div>\n<code>\n\/\/ Double-click to remove the canvas.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse as the user moves. The sketch disappears when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  \/\/ Paint the background repeatedly.\n  background(200);\n\n  \/\/ Draw circles repeatedly.\n  circle(mouseX, mouseY, 40);\n}\n\n\/\/ Remove the sketch when the user double-clicks.\nfunction doubleClicked() {\n  remove();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/main.js","line":872,"description":"<p>Turns off the parts of the Friendly Error System (FES) that impact performance.<\/p>\n<p>The <a href=\"https:\/\/github.com\/processing\/p5.js\/blob\/main\/contributor_docs\/friendly_error_system.md\" target=\"_blank\">FES<\/a>\ncan cause sketches to draw slowly because it does extra work behind the\nscenes. For example, the FES checks the arguments passed to functions,\nwhich takes time to process. Disabling the FES can significantly improve\nperformance by turning off these checks.<\/p>\n","itemtype":"property","name":"disableFriendlyErrors","type":"Boolean","example":["\n<div>\n<code>\n\/\/ Disable the FES.\np5.disableFriendlyErrors = true;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ The circle() function requires three arguments. The\n  \/\/ next line would normally display a friendly error that\n  \/\/ points this out. Instead, nothing happens and it fails\n  \/\/ silently.\n  circle(50, 50);\n\n  describe('A gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/p5.Element.js","line":56,"description":"<p>The element's underlying <code>HTMLElement<\/code> object.<\/p>\n<p>The\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLElement\" target=\"_blank\">HTMLElement<\/a>\nobject's properties and methods can be used directly.<\/p>\n","example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the border style for the\n  \/\/ canvas.\n  cnv.elt.style.border = '5px dashed deeppink';\n\n  describe('A gray square with a pink border drawn with dashed lines.');\n}\n<\/code>\n<\/div>"],"itemtype":"property","name":"elt","readonly":"","class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":94,"description":"<p>A <code>Number<\/code> property that stores the element's width.<\/p>\n","type":"{Number}","itemtype":"property","name":"width","class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":102,"description":"<p>A <code>Number<\/code> property that stores the element's height.<\/p>\n","type":"{Number}","itemtype":"property","name":"height","class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":112,"description":"<p>Attaches the element to a parent element.<\/p>\n<p>For example, a <code>&lt;div&gt;&lt;\/div&gt;<\/code> element may be used as a box to\nhold two pieces of text, a header and a paragraph. The\n<code>&lt;div&gt;&lt;\/div&gt;<\/code> is the parent element of both the header and\nparagraph.<\/p>\n<p>The parameter <code>parent<\/code> can have one of three types. <code>parent<\/code> can be a\nstring with the parent element's ID, as in\n<code>myElement.parent('container')<\/code>. It can also be another\n<a href=\"#\/p5.Element\">p5.Element<\/a> object, as in\n<code>myElement.parent(myDiv)<\/code>. Finally, <code>parent<\/code> can be an <code>HTMLElement<\/code>\nobject, as in <code>myElement.parent(anotherElement)<\/code>.<\/p>\n<p>Calling <code>myElement.parent()<\/code> without an argument returns the element's\nparent.<\/p>\n","itemtype":"method","name":"parent","chainable":1,"example":["\n<div>\n<code>\nfunction setup()  {\n  background(200);\n\n  \/\/ Create a div element.\n  let div = createDiv();\n\n  \/\/ Place the div in the top-left corner.\n  div.position(10, 20);\n\n  \/\/ Set its width and height.\n  div.size(80, 60);\n\n  \/\/ Set its background color to white\n  div.style('background-color', 'white');\n\n  \/\/ Align any text to the center.\n  div.style('text-align', 'center');\n\n  \/\/ Set its ID to \"container\".\n  div.id('container');\n\n  \/\/ Create a paragraph element.\n  let p = createP('p5*js');\n\n  \/\/ Make the div its parent\n  \/\/ using its ID \"container\".\n  p.parent('container');\n\n  describe('The text \"p5*js\" written in black at the center of a white rectangle. The rectangle is inside a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup()  {\n  background(200);\n\n  \/\/ Create rectangular div element.\n  let div = createDiv();\n\n  \/\/ Place the div in the top-left corner.\n  div.position(10, 20);\n\n  \/\/ Set its width and height.\n  div.size(80, 60);\n\n  \/\/ Set its background color and align\n  \/\/ any text to the center.\n  div.style('background-color', 'white');\n  div.style('text-align', 'center');\n\n  \/\/ Create a paragraph element.\n  let p = createP('p5*js');\n\n  \/\/ Make the div its parent.\n  p.parent(div);\n\n  describe('The text \"p5*js\" written in black at the center of a white rectangle. The rectangle is inside a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup()  {\n  background(200);\n\n  \/\/ Create rectangular div element.\n  let div = createDiv();\n\n  \/\/ Place the div in the top-left corner.\n  div.position(10, 20);\n\n  \/\/ Set its width and height.\n  div.size(80, 60);\n\n  \/\/ Set its background color and align\n  \/\/ any text to the center.\n  div.style('background-color', 'white');\n  div.style('text-align', 'center');\n\n  \/\/ Create a paragraph element.\n  let p = createP('p5*js');\n\n  \/\/ Make the div its parent\n  \/\/ using the underlying\n  \/\/ HTMLElement.\n  p.parent(div.elt);\n\n  describe('The text \"p5*js\" written in black at the center of a white rectangle. The rectangle is inside a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":112,"params":[{"name":"parent","description":"<p>ID, <a href=\"#\/p5.Element\">p5.Element<\/a>,\n                                          or HTMLElement of desired parent element.<\/p>\n","type":"String|p5.Element|Object"}],"chainable":1},{"line":233,"params":[],"return":{"description":"","type":"p5.Element"}}]},{"file":"src\/core\/p5.Element.js","line":254,"description":"<p>Sets the element's ID using a given string.<\/p>\n<p>Calling <code>myElement.id()<\/code> without an argument returns its ID as a string.<\/p>\n","itemtype":"method","name":"id","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the canvas' ID\n  \/\/ to \"mycanvas\".\n  cnv.id('mycanvas');\n\n  \/\/ Get the canvas' ID.\n  let id = cnv.id();\n  text(id, 24, 54);\n\n  describe('The text \"mycanvas\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":254,"params":[{"name":"id","description":"<p>ID of the element.<\/p>\n","type":"String"}],"chainable":1},{"line":286,"params":[],"return":{"description":"ID of the element.","type":"String"}}]},{"file":"src\/core\/p5.Element.js","line":301,"description":"<p>Adds a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Global_attributes\/class\" target=\"_blank\">class attribute<\/a>\nto the element using a given string.<\/p>\n<p>Calling <code>myElement.class()<\/code> without an argument returns a string with its current classes.<\/p>\n","itemtype":"method","name":"class","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Add the class \"small\" to the\n  \/\/ canvas element.\n  cnv.class('small');\n\n  \/\/ Get the canvas element's class\n  \/\/ and display it.\n  let c = cnv.class();\n  text(c, 35, 54);\n\n  describe('The word \"small\" written in black on a gray canvas.');\n\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":301,"params":[{"name":"class","description":"<p>class to add.<\/p>\n","type":"String"}],"chainable":1},{"line":337,"params":[],"return":{"description":"element's classes, if any.","type":"String"}}]},{"file":"src\/core\/p5.Element.js","line":350,"description":"<p>Calls a function when the mouse is pressed over the element.<\/p>\n<p>Calling <code>myElement.mousePressed(false)<\/code> disables the function.<\/p>\n<p>Note: Some mobile browsers may also trigger this event when the element\nreceives a quick tap.<\/p>\n","itemtype":"method","name":"mousePressed","params":[{"name":"fxn","description":"<p>function to call when the mouse is\n                               pressed over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the canvas\n  \/\/ is pressed.\n  cnv.mousePressed(randomColor);\n\n  describe('A gray square changes color when the mouse is pressed.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":405,"description":"<p>Calls a function when the mouse is pressed twice over the element.<\/p>\n<p>Calling <code>myElement.doubleClicked(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"doubleClicked","params":[{"name":"fxn","description":"<p>function to call when the mouse is\n                               double clicked over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ canvas is double-clicked.\n  cnv.doubleClicked(randomColor);\n\n  describe('A gray square changes color when the user double-clicks the canvas.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":447,"description":"<p>Calls a function when the mouse wheel scrolls over the element.<\/p>\n<p>The callback function, <code>fxn<\/code>, is passed an <code>event<\/code> object. <code>event<\/code> has\ntwo numeric properties, <code>deltaY<\/code> and <code>deltaX<\/code>. <code>event.deltaY<\/code> is\nnegative if the mouse wheel rotates away from the user. It's positive if\nthe mouse wheel rotates toward the user. <code>event.deltaX<\/code> is positive if\nthe mouse wheel moves to the right. It's negative if the mouse wheel moves\nto the left.<\/p>\n<p>Calling <code>myElement.mouseWheel(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"mouseWheel","params":[{"name":"fxn","description":"<p>function to call when the mouse wheel is\n                               scrolled over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ mouse wheel moves.\n  cnv.mouseWheel(randomColor);\n\n  describe('A gray square changes color when the user scrolls the mouse wheel over the canvas.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call changeBackground() when the\n  \/\/ mouse wheel moves.\n  cnv.mouseWheel(changeBackground);\n\n  describe('A gray square. When the mouse wheel scrolls over the square, it changes color and displays shapes.');\n}\n\nfunction changeBackground(event) {\n  \/\/ Change the background color\n  \/\/ based on deltaY.\n  if (event.deltaY > 0) {\n    background('deeppink');\n  } else if (event.deltaY < 0) {\n    background('cornflowerblue');\n  } else {\n    background(200);\n  }\n\n  \/\/ Draw a shape based on deltaX.\n  if (event.deltaX > 0) {\n    circle(50, 50, 20);\n  } else if (event.deltaX < 0) {\n    square(40, 40, 20);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":533,"description":"<p>Calls a function when the mouse is released over the element.<\/p>\n<p>Calling <code>myElement.mouseReleased(false)<\/code> disables the function.<\/p>\n<p>Note: Some mobile browsers may also trigger this event when the element\nreceives a quick tap.<\/p>\n","itemtype":"method","name":"mouseReleased","params":[{"name":"fxn","description":"<p>function to call when the mouse is\n                               pressed over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when a\n  \/\/ mouse press ends.\n  cnv.mouseReleased(randomColor);\n\n  describe('A gray square changes color when the user releases a mouse press.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":578,"description":"<p>Calls a function when the mouse is pressed and released over the element.<\/p>\n<p>Calling <code>myElement.mouseReleased(false)<\/code> disables the function.<\/p>\n<p>Note: Some mobile browsers may also trigger this event when the element\nreceives a quick tap.<\/p>\n","itemtype":"method","name":"mouseClicked","params":[{"name":"fxn","description":"<p>function to call when the mouse is\n                               pressed and released over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when a\n  \/\/ mouse press ends.\n  cnv.mouseClicked(randomColor);\n\n  describe('A gray square changes color when the user releases a mouse press.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":623,"description":"<p>Calls a function when the mouse moves over the element.<\/p>\n<p>Calling <code>myElement.mouseMoved(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"mouseMoved","params":[{"name":"fxn","description":"<p>function to call when the mouse\n                               moves over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ mouse moves.\n  cnv.mouseMoved(randomColor);\n\n  describe('A gray square changes color when the mouse moves over the canvas.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":665,"description":"<p>Calls a function when the mouse moves onto the element.<\/p>\n<p>Calling <code>myElement.mouseOver(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"mouseOver","params":[{"name":"fxn","description":"<p>function to call when the mouse\n                               moves onto the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ mouse moves onto the canvas.\n  cnv.mouseOver(randomColor);\n\n  describe('A gray square changes color when the mouse moves onto the canvas.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":707,"description":"<p>Calls a function when the mouse moves off the element.<\/p>\n<p>Calling <code>myElement.mouseOut(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"mouseOut","params":[{"name":"fxn","description":"<p>function to call when the mouse\n                               moves off the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ mouse moves off the canvas.\n  cnv.mouseOut(randomColor);\n\n  describe('A gray square changes color when the mouse moves off the canvas.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":749,"description":"<p>Calls a function when the element is touched.<\/p>\n<p>Calling <code>myElement.touchStarted(false)<\/code> disables the function.<\/p>\n<p>Note: Touch functions only work on mobile devices.<\/p>\n","itemtype":"method","name":"touchStarted","params":[{"name":"fxn","description":"<p>function to call when the touch\n                               starts.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ user touches the canvas.\n  cnv.touchStarted(randomColor);\n\n  describe('A gray square changes color when the user touches the canvas.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":793,"description":"<p>Calls a function when the user touches the element and moves.<\/p>\n<p>Calling <code>myElement.touchMoved(false)<\/code> disables the function.<\/p>\n<p>Note: Touch functions only work on mobile devices.<\/p>\n","itemtype":"method","name":"touchMoved","params":[{"name":"fxn","description":"<p>function to call when the touch\n                               moves over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ user touches the canvas\n  \/\/ and moves.\n  cnv.touchMoved(randomColor);\n\n  describe('A gray square changes color when the user touches the canvas and moves.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":837,"description":"<p>Calls a function when the user stops touching the element.<\/p>\n<p>Calling <code>myElement.touchMoved(false)<\/code> disables the function.<\/p>\n<p>Note: Touch functions only work on mobile devices.<\/p>\n","itemtype":"method","name":"touchEnded","params":[{"name":"fxn","description":"<p>function to call when the touch\n                               ends.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call randomColor() when the\n  \/\/ user touches the canvas,\n  \/\/ then lifts their finger.\n  cnv.touchEnded(randomColor);\n\n  describe('A gray square changes color when the user touches the canvas, then lifts their finger.');\n}\n\n\/\/ Paint the background either\n\/\/ red, yellow, blue, or green.\nfunction randomColor() {\n  let c = random(['red', 'yellow', 'blue', 'green']);\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":881,"description":"<p>Calls a function when a file is dragged over the element.<\/p>\n<p>Calling <code>myElement.dragOver(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"dragOver","params":[{"name":"fxn","description":"<p>function to call when the file is\n                               dragged over the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Drag a file over the canvas to test.\n\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call helloFile() when a\n  \/\/ file is dragged over\n  \/\/ the canvas.\n  cnv.dragOver(helloFile);\n\n  describe('A gray square. The text \"hello, file\" appears when a file is dragged over the square.');\n}\n\nfunction helloFile() {\n  text('hello, file', 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":923,"description":"<p>Calls a function when a file is dragged off the element.<\/p>\n<p>Calling <code>myElement.dragLeave(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"dragLeave","params":[{"name":"fxn","description":"<p>function to call when the file is\n                               dragged off the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Drag a file over, then off\n\/\/ the canvas to test.\n\nfunction setup() {\n  \/\/ Create a canvas element and\n  \/\/ assign it to cnv.\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call byeFile() when a\n  \/\/ file is dragged over,\n  \/\/ then off the canvas.\n  cnv.dragLeave(byeFile);\n\n  describe('A gray square. The text \"bye, file\" appears when a file is dragged over, then off the square.');\n}\n\nfunction byeFile() {\n  text('bye, file', 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Element.js","line":1015,"description":"<p>Helper fxn for sharing pixel methods<\/p>\n","class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/core\/p5.Graphics.js","line":153,"description":"<p>Resets the graphics buffer's transformations and lighting.<\/p>\n<p>By default, the main canvas resets certain transformation and lighting\nvalues each time <a href=\"#\/p5\/draw\">draw()<\/a> executes. <code>p5.Graphics<\/code>\nobjects must reset these values manually by calling <code>myGraphics.reset()<\/code>.<\/p>\n","itemtype":"method","name":"reset","example":["\n<div>\n<code>\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object.\n  pg = createGraphics(60, 60);\n\n  describe('A white circle moves downward slowly within a dark square. The circle resets at the top of the dark square when the user presses the mouse.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the p5.Graphics object's coordinate system.\n  \/\/ The translation accumulates; the white circle moves.\n  pg.translate(0, 0.1);\n\n  \/\/ Draw to the p5.Graphics object.\n  pg.background(100);\n  pg.circle(30, 0, 10);\n\n  \/\/ Display the p5.Graphics object.\n  image(pg, 20, 20);\n\n  \/\/ Translate the main canvas' coordinate system.\n  \/\/ The translation doesn't accumulate; the dark\n  \/\/ square is always in the same place.\n  translate(0, 0.1);\n\n  \/\/ Reset the p5.Graphics object when the\n  \/\/ user presses the mouse.\n  if (mouseIsPressed === true) {\n    pg.reset();\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object.\n  pg = createGraphics(60, 60);\n\n  describe('A white circle at the center of a dark gray square. The image is drawn on a light gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the p5.Graphics object's coordinate system.\n  pg.translate(30, 30);\n\n  \/\/ Draw to the p5.Graphics object.\n  pg.background(100);\n  pg.circle(0, 0, 10);\n\n  \/\/ Display the p5.Graphics object.\n  image(pg, 20, 20);\n\n  \/\/ Reset the p5.Graphics object automatically.\n  pg.reset();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object using WebGL mode.\n  pg = createGraphics(100, 100, WEBGL);\n\n  describe(\"A sphere lit from above with a red light. The sphere's surface becomes glossy while the user clicks and holds the mouse.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Add a red point light from the top-right.\n  pg.pointLight(255, 0, 0, 50, -100, 50);\n\n  \/\/ Style the sphere.\n  \/\/ It should appear glossy when the\n  \/\/ lighting values are reset.\n  pg.noStroke();\n  pg.specularMaterial(255);\n  pg.shininess(100);\n\n  \/\/ Draw the sphere.\n  pg.sphere(30);\n\n  \/\/ Display the p5.Graphics object.\n  image(pg, -50, -50);\n\n  \/\/ Reset the p5.Graphics object when\n  \/\/ the user presses the mouse.\n  if (mouseIsPressed === true) {\n    pg.reset();\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object using WebGL mode.\n  pg = createGraphics(100, 100, WEBGL);\n\n  describe('A sphere with a glossy surface is lit from the top-right by a red light.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Add a red point light from the top-right.\n  pg.pointLight(255, 0, 0, 50, -100, 50);\n\n  \/\/ Style the sphere.\n  pg.noStroke();\n  pg.specularMaterial(255);\n  pg.shininess(100);\n\n  \/\/ Draw the sphere.\n  pg.sphere(30);\n\n  \/\/ Display the p5.Graphics object.\n  image(pg, 0, 0);\n\n  \/\/ Reset the p5.Graphics object automatically.\n  pg.reset();\n}\n<\/code>\n<\/div>"],"class":"p5.Graphics","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/p5.Graphics.js","line":320,"description":"<p>Removes the graphics buffer from the web page.<\/p>\n<p>Calling <code>myGraphics.remove()<\/code> removes the graphics buffer's\n<code>&lt;canvas&gt;<\/code> element from the web page. The graphics buffer also uses\na bit of memory on the CPU that can be freed like so:<\/p>\n<pre><code class=\"language-js\">\/\/ Remove the graphics buffer from the web page.\nmyGraphics.remove();\n\n\/\/ Delete the graphics buffer from CPU memory.\nmyGraphics = undefined;\n<\/code><\/pre>\n<p>Note: All variables that reference the graphics buffer must be assigned\nthe value <code>undefined<\/code> to delete the graphics buffer from CPU memory. If any\nvariable still refers to the graphics buffer, then it won't be garbage\ncollected.<\/p>\n","itemtype":"method","name":"remove","example":["\n<div>\n<code>\n\/\/ Double-click to remove the p5.Graphics object.\n\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object.\n  pg = createGraphics(60, 60);\n\n  \/\/ Draw to the p5.Graphics object.\n  pg.background(100);\n  pg.circle(30, 30, 20);\n\n  describe('A white circle at the center of a dark gray square disappears when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Display the p5.Graphics object if\n  \/\/ it's available.\n  if (pg) {\n    image(pg, 20, 20);\n  }\n}\n\n\/\/ Remove the p5.Graphics object when the\n\/\/ the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Remove the p5.Graphics object from the web page.\n  pg.remove();\n  pg = undefined;\n}\n<\/code>\n<\/div>"],"class":"p5.Graphics","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/p5.Graphics.js","line":406,"description":"<p>Creates a new <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object with\nthe same WebGL context as the graphics buffer.<\/p>\n<p><a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> objects are separate drawing\nsurfaces that can be used as textures in WebGL mode. They're similar to\n<a href=\"#\/p5.Graphics\">p5.Graphics<\/a> objects and generally run much\nfaster when used as textures. Creating a\n<a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object in the same context\nas the graphics buffer makes this speedup possible.<\/p>\n<p>The parameter, <code>options<\/code>, is optional. An object can be passed to configure\nthe <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. The available\nproperties are:<\/p>\n<ul>\n<li><code>format<\/code>: data format of the texture, either <code>UNSIGNED_BYTE<\/code>, <code>FLOAT<\/code>, or <code>HALF_FLOAT<\/code>. Default is <code>UNSIGNED_BYTE<\/code>.<\/li>\n<li><code>channels<\/code>: whether to store <code>RGB<\/code> or <code>RGBA<\/code> color channels. Default is to match the graphics buffer which is <code>RGBA<\/code>.<\/li>\n<li><code>depth<\/code>: whether to include a depth buffer. Default is <code>true<\/code>.<\/li>\n<li><code>depthFormat<\/code>: data format of depth information, either <code>UNSIGNED_INT<\/code> or <code>FLOAT<\/code>. Default is <code>FLOAT<\/code>.<\/li>\n<li><code>stencil<\/code>: whether to include a stencil buffer for masking. <code>depth<\/code> must be <code>true<\/code> for this feature to work. Defaults to the value of <code>depth<\/code> which is <code>true<\/code>.<\/li>\n<li><code>antialias<\/code>: whether to perform anti-aliasing. If set to <code>true<\/code>, as in <code>{ antialias: true }<\/code>, 2 samples will be used by default. The number of samples can also be set, as in <code>{ antialias: 4 }<\/code>. Default is to match <a href=\"#\/p5\/setAttributes\">setAttributes()<\/a> which is <code>false<\/code> (<code>true<\/code> in Safari).<\/li>\n<li><code>width<\/code>: width of the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Default is to always match the graphics buffer width.<\/li>\n<li><code>height<\/code>: height of the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Default is to always match the graphics buffer height.<\/li>\n<li><code>density<\/code>: pixel density of the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Default is to always match the graphics buffer pixel density.<\/li>\n<li><code>textureFiltering<\/code>: how to read values from the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Either <code>LINEAR<\/code> (nearby pixels will be interpolated) or <code>NEAREST<\/code> (no interpolation). Generally, use <code>LINEAR<\/code> when using the texture as an image and <code>NEAREST<\/code> if reading the texture as data. Default is <code>LINEAR<\/code>.<\/li>\n<\/ul>\n<p>If the <code>width<\/code>, <code>height<\/code>, or <code>density<\/code> attributes are set, they won't\nautomatically match the graphics buffer and must be changed manually.<\/p>\n","itemtype":"method","name":"createFramebuffer","params":[{"name":"options","description":"<p>configuration options.<\/p>\n","type":"Object","optional":true}],"return":{"description":"new framebuffer.","type":"p5.Framebuffer"},"example":["\n<div>\n<code>\n\/\/ Click and hold a mouse button to change shapes.\n\nlet pg;\nlet torusLayer;\nlet boxLayer;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Graphics object using WebGL mode.\n  pg = createGraphics(100, 100, WEBGL);\n\n  \/\/ Create the p5.Framebuffer objects.\n  torusLayer = pg.createFramebuffer();\n  boxLayer = pg.createFramebuffer();\n\n  describe('A grid of white toruses rotating against a dark gray background. The shapes become boxes while the user holds a mouse button.');\n}\n\nfunction draw() {\n  \/\/ Update and draw the layers offscreen.\n  drawTorus();\n  drawBox();\n\n  \/\/ Choose the layer to display.\n  let layer;\n  if (mouseIsPressed === true) {\n    layer = boxLayer;\n  } else {\n    layer = torusLayer;\n  }\n\n  \/\/ Draw to the p5.Graphics object.\n  pg.background(50);\n\n  \/\/ Iterate from left to right.\n  for (let x = -50; x < 50; x += 25) {\n    \/\/ Iterate from top to bottom.\n    for (let y = -50; y < 50; y += 25) {\n      \/\/ Draw the layer to the p5.Graphics object\n      pg.image(layer, x, y, 25, 25);\n    }\n  }\n\n  \/\/ Display the p5.Graphics object.\n  image(pg, 0, 0);\n}\n\n\/\/ Update and draw the torus layer offscreen.\nfunction drawTorus() {\n  \/\/ Start drawing to the torus p5.Framebuffer.\n  torusLayer.begin();\n\n  \/\/ Clear the drawing surface.\n  pg.clear();\n\n  \/\/ Turn on the lights.\n  pg.lights();\n\n  \/\/ Rotate the coordinate system.\n  pg.rotateX(frameCount * 0.01);\n  pg.rotateY(frameCount * 0.01);\n\n  \/\/ Style the torus.\n  pg.noStroke();\n\n  \/\/ Draw the torus.\n  pg.torus(20);\n\n  \/\/ Start drawing to the torus p5.Framebuffer.\n  torusLayer.end();\n}\n\n\/\/ Update and draw the box layer offscreen.\nfunction drawBox() {\n  \/\/ Start drawing to the box p5.Framebuffer.\n  boxLayer.begin();\n\n  \/\/ Clear the drawing surface.\n  pg.clear();\n\n  \/\/ Turn on the lights.\n  pg.lights();\n\n  \/\/ Rotate the coordinate system.\n  pg.rotateX(frameCount * 0.01);\n  pg.rotateY(frameCount * 0.01);\n\n  \/\/ Style the box.\n  pg.noStroke();\n\n  \/\/ Draw the box.\n  pg.box(30);\n\n  \/\/ Start drawing to the box p5.Framebuffer.\n  boxLayer.end();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and hold a mouse button to change shapes.\n\nlet pg;\nlet torusLayer;\nlet boxLayer;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create an options object.\n  let options = { width: 25, height: 25 };\n\n  \/\/ Create a p5.Graphics object using WebGL mode.\n  pg = createGraphics(100, 100, WEBGL);\n\n  \/\/ Create the p5.Framebuffer objects.\n  \/\/ Use options for configuration.\n  torusLayer = pg.createFramebuffer(options);\n  boxLayer = pg.createFramebuffer(options);\n\n  describe('A grid of white toruses rotating against a dark gray background. The shapes become boxes while the user holds a mouse button.');\n}\n\nfunction draw() {\n  \/\/ Update and draw the layers offscreen.\n  drawTorus();\n  drawBox();\n\n  \/\/ Choose the layer to display.\n  let layer;\n  if (mouseIsPressed === true) {\n    layer = boxLayer;\n  } else {\n    layer = torusLayer;\n  }\n\n  \/\/ Draw to the p5.Graphics object.\n  pg.background(50);\n\n  \/\/ Iterate from left to right.\n  for (let x = -50; x < 50; x += 25) {\n    \/\/ Iterate from top to bottom.\n    for (let y = -50; y < 50; y += 25) {\n      \/\/ Draw the layer to the p5.Graphics object\n      pg.image(layer, x, y);\n    }\n  }\n\n  \/\/ Display the p5.Graphics object.\n  image(pg, 0, 0);\n}\n\n\/\/ Update and draw the torus layer offscreen.\nfunction drawTorus() {\n  \/\/ Start drawing to the torus p5.Framebuffer.\n  torusLayer.begin();\n\n  \/\/ Clear the drawing surface.\n  pg.clear();\n\n  \/\/ Turn on the lights.\n  pg.lights();\n\n  \/\/ Rotate the coordinate system.\n  pg.rotateX(frameCount * 0.01);\n  pg.rotateY(frameCount * 0.01);\n\n  \/\/ Style the torus.\n  pg.noStroke();\n\n  \/\/ Draw the torus.\n  pg.torus(5, 2.5);\n\n  \/\/ Start drawing to the torus p5.Framebuffer.\n  torusLayer.end();\n}\n\n\/\/ Update and draw the box layer offscreen.\nfunction drawBox() {\n  \/\/ Start drawing to the box p5.Framebuffer.\n  boxLayer.begin();\n\n  \/\/ Clear the drawing surface.\n  pg.clear();\n\n  \/\/ Turn on the lights.\n  pg.lights();\n\n  \/\/ Rotate the coordinate system.\n  pg.rotateX(frameCount * 0.01);\n  pg.rotateY(frameCount * 0.01);\n\n  \/\/ Style the box.\n  pg.noStroke();\n\n  \/\/ Draw the box.\n  pg.box(7.5);\n\n  \/\/ Start drawing to the box p5.Framebuffer.\n  boxLayer.end();\n}\n<\/code>\n<\/div>"],"class":"p5.Graphics","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/p5.Renderer.js","line":120,"description":"<p>Resize our canvas element.<\/p>\n","class":"p5.Renderer","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/p5.Renderer.js","line":468,"description":"<p>Helper function to check font type (system or otf)<\/p>\n","class":"p5.Renderer","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/p5.Renderer.js","line":520,"description":"<p>Helper fxn to measure ascent and descent.\nAdapted from <a href=\"http:\/\/stackoverflow.com\/a\/25355178\">http:\/\/stackoverflow.com\/a\/25355178<\/a><\/p>\n","class":"p5.Renderer","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/p5.Renderer2D.js","line":6,"description":"<p>p5.Renderer2D\nThe 2D graphics canvas renderer class.\nextends p5.Renderer<\/p>\n","class":"p5","module":"Rendering"},{"file":"src\/core\/reference.js","line":7,"description":"<p>Declares a new variable.<\/p>\n<p>A variable is a container for a value. For example, a variable might\ncontain a creature's x-coordinate as a <code>Number<\/code> or its name as a\n<code>String<\/code>. Variables can change value by reassigning them as follows:<\/p>\n<pre><code class=\"language-js\">\/\/ Declare the variable x and assign it the value 10.\nlet x = 10;\n\n\/\/ Reassign x to 50.\nx = 50;\n<\/code><\/pre>\n<p>Variables have block scope. When a variable is declared between curly\nbraces <code>{}<\/code>, it only exists within the block defined by those braces. For\nexample, the following code would throw a <code>ReferenceError<\/code> because <code>x<\/code> is\ndeclared within the <code>setup()<\/code> function's block:<\/p>\n<pre><code class=\"language-js\">function setup() {\n  createCanvas(100, 100);\n\n  let x = 50;\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ x was declared in setup(), so it can't be referenced here.\n  circle(x, 50, 20);\n}\n<\/code><\/pre>\n<p>Variables declared outside of all curly braces <code>{}<\/code> are in the global\nscope. A variable that's in the global scope can be used and changed\nanywhere in a sketch:<\/p>\n<pre><code class=\"language-js\">let x = 50;\n\nfunction setup() {\n  createCanvas(100, 100);\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Change the value of x.\n  x += 10;\n\n  circle(x, 50, 20);\n}\n<\/code><\/pre>\n","itemtype":"property","name":"let","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(220);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Create the message variable.\n  let message = 'Hello, \ud83c\udf0d!';\n\n  \/\/ Display the message.\n  text(message, 50, 50);\n\n  describe('The text \"Hello, \ud83c\udf0d!\" written on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet x = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle moves from left to right against a gray background.');\n}\n\nfunction draw() {\n  background(220);\n\n  \/\/ Change the value of x.\n  x += 1;\n\n  circle(x, 50, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":110,"description":"<p>A way to choose whether to run a block of code.<\/p>\n<p><code>if<\/code> statements are helpful for running a block of code based on a\ncondition. For example, an <code>if<\/code> statement makes it easy to express the\nidea \"Draw a circle if the mouse is pressed.\":<\/p>\n<pre><code class=\"language-js\">if (mouseIsPressed === true) {\n  circle(mouseX, mouseY, 20);\n}\n<\/code><\/pre>\n<p>The statement header begins with the keyword <code>if<\/code>. The expression in\nparentheses <code>mouseIsPressed === true<\/code> is a <code>Boolean<\/code> expression that's\neither <code>true<\/code> or <code>false<\/code>. The code between the curly braces <code>{}<\/code> is the if\nstatement's body. The body only runs if the <code>Boolean<\/code> expression is <code>true<\/code>.<\/p>\n<p>The <a href=\"#\/p5\/mouseIsPressed\">mouseIsPressed<\/a> system variable is\nalways <code>true<\/code> or <code>false<\/code>, so the code snippet above could also be written\nas follows:<\/p>\n<pre><code class=\"language-js\">if (mouseIsPressed) {\n  circle(mouseX, mouseY, 20);\n}\n<\/code><\/pre>\n<p>An <code>if<\/code>-<code>else<\/code> statement adds a block of code that runs if the <code>Boolean<\/code>\nexpression is <code>false<\/code>. For example, here's an <code>if<\/code>-<code>else<\/code> statement that\nexpresses the idea \"Draw a circle if the mouse is pressed. Otherwise,\ndisplay a message.\":<\/p>\n<pre><code class=\"language-js\">if (mouseIsPressed === true) {\n  \/\/ When true.\n  circle(mouseX, mouseY, 20);\n} else {\n  \/\/ When false.\n  text('Click me!', 50, 50);\n}\n<\/code><\/pre>\n<p>There are two possible paths, or branches, in this code snippet. The\nprogram must follow one branch or the other.<\/p>\n<p>An <code>else<\/code>-<code>if<\/code> statement makes it possible to add more branches.\n<code>else<\/code>-<code>if<\/code> statements run different blocks of code under different\nconditions. For example, an <code>else<\/code>-<code>if<\/code> statement makes it easy to express\nthe idea \"If the mouse is on the left, paint the canvas white. If the mouse\nis in the middle, paint the canvas gray. Otherwise, paint the canvas\nblack.\":<\/p>\n<pre><code class=\"language-js\">if (mouseX < 33) {\n  background(255);\n} else if (mouseX < 67) {\n  background(200);\n} else {\n  background(0);\n}\n<\/code><\/pre>\n<p><code>if<\/code> statements can add as many <code>else<\/code>-<code>if<\/code> statements as needed. However,\nthere can only be one <code>else<\/code> statement and it must be last.<\/p>\n<p><code>if<\/code> statements can also check for multiple conditions at once. For\nexample, the <code>Boolean<\/code> operator <code>&&<\/code> (AND) checks whether two expressions\nare both <code>true<\/code>:<\/p>\n<pre><code class=\"language-js\">if (keyIsPressed === true && key === 'p') {\n  text('You pressed the \"p\" key!', 50, 50);\n}\n<\/code><\/pre>\n<p>If the user is pressing a key AND that key is <code>'p'<\/code>, then a message will\ndisplay.<\/p>\n<p>The <code>Boolean<\/code> operator <code>||<\/code> (OR) checks whether at least one of two\nexpressions is <code>true<\/code>:<\/p>\n<pre><code class=\"language-js\">if (keyIsPressed === true || mouseIsPressed === true) {\n  text('You did something!', 50, 50);\n}\n<\/code><\/pre>\n<p>If the user presses a key, or presses a mouse button, or both, then a\nmessage will display.<\/p>\n<p>The body of an <code>if<\/code> statement can contain another <code>if<\/code> statement. This is\ncalled a \"nested <code>if<\/code> statement.\" For example, nested <code>if<\/code> statements make\nit easy to express the idea \"If a key is pressed, then check if the key is\n<code>'r'<\/code>. If it is, then set the fill to red.\":<\/p>\n<pre><code class=\"language-js\">if (keyIsPressed === true) {\n  if (key === 'r') {\n    fill('red');\n  }\n}\n<\/code><\/pre>\n<p>See <a href=\"#\/p5\/Boolean\">Boolean<\/a> and <a href=\"#\/p5\/Number\">Number<\/a>\nto learn more about these data types and the operations they support.<\/p>\n","itemtype":"property","name":"if","example":["\n<div>\n<code>\n\/\/ Click the mouse to show the circle.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (mouseIsPressed === true) {\n    circle(mouseX, mouseY, 20);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the mouse to show different shapes.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (mouseIsPressed === true) {\n    circle(50, 50, 20);\n  } else {\n    ellipse(50, 50, 20, 50);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Move the mouse to change the background color.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A square changes color from white to black as the user moves the mouse from left to right.'\n  );\n}\n\nfunction draw() {\n  if (mouseX < 33) {\n    background(255);\n  } else if (mouseX < 67) {\n    background(200);\n  } else {\n    background(0);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle drawn on a gray background. The circle changes color to red when the user presses the \"r\" key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (keyIsPressed === true) {\n    if (key === 'r') {\n      fill('red');\n    }\n  }\n\n  circle(50, 50, 40);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":317,"description":"<p>A named group of statements.<\/p>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Functions\" target=\"_blank\">Functions<\/a>\nhelp with organizing and reusing code. For example, functions make it easy\nto express the idea \"Draw a flower.\":<\/p>\n<pre><code class=\"language-js\">function drawFlower() {\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  \/\/ Draw a flower emoji.\n  text('\ud83c\udf38', 50, 50);\n}\n<\/code><\/pre>\n<p>The function header begins with the keyword <code>function<\/code>. The function's\nname, <code>drawFlower<\/code>, is followed by parentheses <code>()<\/code> and curly braces <code>{}<\/code>.\nThe code between the curly braces is called the function's body. The\nfunction's body runs when the function is called like so:<\/p>\n<pre><code class=\"language-js\">drawFlower();\n<\/code><\/pre>\n<p>Functions can accept inputs by adding parameters to their headers.\nParameters are placeholders for values that will be provided when the\nfunction is called. For example, the <code>drawFlower()<\/code> function could include\na parameter for the flower's size:<\/p>\n<pre><code class=\"language-js\">function drawFlower(size) {\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n\n  \/\/ Use the size parameter.\n  textSize(size);\n\n  \/\/ Draw a flower emoji.\n  text('\ud83c\udf38', 50, 50);\n}\n<\/code><\/pre>\n<p>Parameters are part of the function's declaration. Arguments are provided\nby the code that calls a function. When a function is called, arguments are\nassigned to parameters:<\/p>\n<pre><code class=\"language-js\">\/\/ The argument 20 is assigned to the parameter size.\ndrawFlower(20);\n<\/code><\/pre>\n<p>Functions can have multiple parameters separated by commas. Parameters\ncan have any type. For example, the <code>drawFlower()<\/code> function could accept\n<code>Number<\/code> parameters for the flower's x- and y-coordinates along with its\nsize:<\/p>\n<pre><code class=\"language-js\">function drawFlower(x, y, size) {\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n\n  \/\/ Use the size parameter.\n  textSize(size);\n\n  \/\/ Draw a flower emoji.\n  \/\/ Use the x and y parameters.\n  text('\ud83c\udf38', x, y);\n}\n<\/code><\/pre>\n<p>Functions can also produce outputs by adding a <code>return<\/code> statement:<\/p>\n<pre><code class=\"language-js\">function double(x) {\n  let answer = 2 * x;\n  return answer;\n}\n<\/code><\/pre>\n<p>The expression following <code>return<\/code> can produce an output that's used\nelsewhere. For example, the output of the <code>double()<\/code> function can be\nassigned to a variable:<\/p>\n<pre><code class=\"language-js\">let six = double(3);\ntext(`3 x 2 = ${six}`, 50, 50);\n<\/code><\/pre>\n","itemtype":"property","name":"function","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Call the drawFlower() function.\n  drawFlower();\n}\n\n\/\/ Declare a function that draws a flower at the\n\/\/ center of the canvas.\nfunction drawFlower() {\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  \/\/ Draw a flower emoji.\n  text('\ud83c\udf38', 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Call the drawFlower() function and pass values for\n  \/\/ its position and size.\n  drawFlower(50, 50, 20);\n}\n\n\/\/ Declare a function that draws a flower at the\n\/\/ center of the canvas.\nfunction drawFlower(x, y, size) {\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n\n  \/\/ Use the size parameter.\n  textSize(size);\n\n  \/\/ Draw a flower emoji.\n  \/\/ Use the x and y parameters.\n  text('\ud83c\udf38', x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('The message \"Hello, \ud83c\udf0d!\" written on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create a greeting.\n  let greeting = createGreeting('\ud83c\udf0d');\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the greeting.\n  text(greeting, 50, 50);\n}\n\n\/\/ Return a string with a personalized greeting.\nfunction createGreeting(name) {\n  let message = `Hello, ${name}!`;\n  return message;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":502,"description":"<p>A value that's either <code>true<\/code> or <code>false<\/code>.<\/p>\n<p><code>Boolean<\/code> values help to make decisions in code. They appear any time a\nlogical condition is checked. For example, the condition\n\"Is a mouse button being pressed?\" must be either <code>true<\/code> or\n<code>false<\/code>:<\/p>\n<pre><code class=\"language-js\">\/\/ If the user presses the mouse, draw a circle at\n\/\/ the mouse's location.\nif (mouseIsPressed === true) {\n  circle(mouseX, mouseY, 20);\n}\n<\/code><\/pre>\n<p>The <code>if<\/code> statement checks whether\n<a href=\"#\/p5\/mouseIsPressed\">mouseIsPressed<\/a> is <code>true<\/code> and draws a\ncircle if it is. <code>Boolean<\/code> expressions such as <code>mouseIsPressed === true<\/code>\nevaluate to one of the two possible <code>Boolean<\/code> values: <code>true<\/code> or <code>false<\/code>.<\/p>\n<p>The <code>===<\/code> operator (EQUAL) checks whether two values are equal. If they\nare, the expression evaluates to <code>true<\/code>. Otherwise, it evaluates to\n<code>false<\/code>.<\/p>\n<p>Note: There's also a <code>==<\/code> operator with two <code>=<\/code> instead of three. Don't use\nit.<\/p>\n<p>The <a href=\"#\/p5\/mouseIsPressed\">mouseIsPressed<\/a> system variable is\nalways <code>true<\/code> or <code>false<\/code>, so the code snippet above could also be written\nas follows:<\/p>\n<pre><code class=\"language-js\">if (mouseIsPressed) {\n  circle(mouseX, mouseY, 20);\n}\n<\/code><\/pre>\n<p>The <code>!==<\/code> operator (NOT EQUAL) checks whether two values are not equal, as\nin the following example:<\/p>\n<pre><code class=\"language-js\">if (2 + 2 !== 4) {\n  text('War is peace.', 50, 50);\n}\n<\/code><\/pre>\n<p>Starting from the left, the arithmetic expression <code>2 + 2<\/code> produces the\nvalue <code>4<\/code>. The <code>Boolean<\/code> expression <code>4 !== 4<\/code> evaluates to <code>false<\/code> because\n<code>4<\/code> is equal to itself. As a result, the <code>if<\/code> statement's body is skipped.<\/p>\n<p>Note: There's also a <code>!=<\/code> operator with one <code>=<\/code> instead of two. Don't use\nit.<\/p>\n<p>The <code>Boolean<\/code> operator <code>&&<\/code> (AND) checks whether two expressions are both\n<code>true<\/code>:<\/p>\n<pre><code class=\"language-js\">if (keyIsPressed === true && key === 'p') {\n  text('You pressed the \"p\" key!', 50, 50);\n}\n<\/code><\/pre>\n<p>If the user is pressing a key AND that key is <code>'p'<\/code>, then a message will\ndisplay.<\/p>\n<p>The <code>Boolean<\/code> operator <code>||<\/code> (OR) checks whether at least one of two\nexpressions is <code>true<\/code>:<\/p>\n<pre><code class=\"language-js\">if (keyIsPressed === true || mouseIsPressed === true) {\n  text('You did something!', 50, 50);\n}\n<\/code><\/pre>\n<p>If the user presses a key, or presses a mouse button, or both, then a\nmessage will display.<\/p>\n<p>The following truth table summarizes a few common scenarios with <code>&&<\/code> and\n<code>||<\/code>:<\/p>\n<pre><code class=\"language-js\">true && true  \/\/ true\ntrue && false \/\/ false\nfalse && false \/\/ false\ntrue || true  \/\/ true\ntrue || false \/\/ true\nfalse || false \/\/ false\n<\/code><\/pre>\n<p>The relational operators <code>><\/code>, <code><<\/code>, <code>>=<\/code>, and <code><=<\/code> also produce <code>Boolean<\/code>\nvalues:<\/p>\n<pre><code class=\"language-js\">2 > 1 \/\/ true\n2 < 1 \/\/ false\n2 >= 2 \/\/ true\n2 <= 2 \/\/ true\n<\/code><\/pre>\n<p>See <a href=\"#\/p5\/if\">if<\/a> for more information about <code>if<\/code> statements and\n<a href=\"#\/p5\/Number\">Number<\/a> for more information about <code>Number<\/code>s.<\/p>\n","itemtype":"property","name":"Boolean","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A gray square. When the user presses the mouse, a circle appears at that location.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ If the user presses the mouse, draw a circle at that location.\n  if (mouseIsPressed) {\n    circle(mouseX, mouseY, 20);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A gray square. When the user presses the mouse, a circle appears at that location.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ If the user presses the mouse, draw a circle at that location.\n  if (mouseIsPressed === true) {\n    circle(mouseX, mouseY, 20);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A gray square that turns pink when the user presses the mouse or a key.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ If the user presses the mouse, change the background color.\n  if (mouseIsPressed === true || keyIsPressed === true) {\n    background('deeppink');\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click the canvas to begin detecting key presses.\n\n\/\/ Create a Boolean variable.\nlet isPlaying = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'The message \"Begin?\\nY or N\" written in green on a black background. The message \"Good luck!\" appears when they press the \"y\" key.'\n  );\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(16);\n  fill(0, 255, 0);\n\n  \/\/ Display a different message when the user begins playing.\n  if (isPlaying === false) {\n    text('Begin?', 50, 40);\n    text('Y or N', 50, 60);\n  } else {\n    text('Good luck!', 50, 50);\n  }\n}\n\n\/\/ Start playing when the user presses the 'y' key.\nfunction keyPressed() {\n  if (key === 'y') {\n    isPlaying = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":710,"description":"<p>A sequence of text characters.<\/p>\n<p>The <code>String<\/code> data type is helpful for working with text. For example, a\nstring could contain a welcome message:<\/p>\n<pre><code class=\"language-js\">\/\/ Use a string literal.\ntext('Hello!', 10, 10);\n<\/code><\/pre>\n<pre><code class=\"language-js\">\/\/ Create a string variable.\nlet message = 'Hello!';\n\n\/\/ Use the string variable.\ntext(message, 10, 10);\n<\/code><\/pre>\n<p>The most common way to create strings is to use some form of quotations as\nfollows:<\/p>\n<pre><code class=\"language-js\">text(\"hi\", 50, 50);\n<\/code><\/pre>\n<pre><code class=\"language-js\">text('hi', 50, 50);\n<\/code><\/pre>\n<pre><code class=\"language-js\">text(`hi`, 50, 50);\n<\/code><\/pre>\n<p><code>\"hi\"<\/code>, <code>'hi'<\/code>, and <code>hi<\/code> are all string literals. A \"literal\" means a\nvalue was actually written, as in <code>text('hi', 50, 50)<\/code>. By contrast,\n<code>text(message, 50, 50)<\/code> uses the variable <code>message<\/code>, so it isn't a string\nliteral.<\/p>\n<p>Single quotes <code>''<\/code> and double quotes <code>\"\"<\/code> mean the same thing. It's nice to\nhave the option for cases when a string contains one type of quote:<\/p>\n<pre><code class=\"language-js\">text(\"What's up?\", 50, 50);\n<\/code><\/pre>\n<pre><code class=\"language-js\">text('Air quotes make you look \"cool.\"', 50, 50);\n<\/code><\/pre>\n<p>Backticks <code>``<\/code> create template literals. Template literals have many uses.\nFor example, they can contain both single and double quotes as needed:<\/p>\n<pre><code class=\"language-js\">text(`\"Don't you forget about me\"`,  10, 10);\n<\/code><\/pre>\n<p>Template literals are helpful when strings are created from variables like\nso:<\/p>\n<pre><code class=\"language-js\">let size = random(10, 20);\ncircle(50, 50, size);\n\ntext(`The circle's diameter is ${size} pixels.`,  10, 10);\n<\/code><\/pre>\n<p>The <code>size<\/code> variable's value will replace <code>${size}<\/code> when the string is\ncreated. <code>${}<\/code> is a placeholder for any value. That means an expression can\nbe used, as in <code>${round(PI, 3)}<\/code>. All of the following are valid template\nliterals:<\/p>\n<pre><code class=\"language-js\">text(`\u03c0 is about ${round(PI, 2)} pixels.`,  10, 10);\ntext(`It's ${mouseX < width \/ 2} that I'm on the left half of the canvas.`,  10, 30);\n<\/code><\/pre>\n<p>Template literals can include several variables:<\/p>\n<pre><code class=\"language-js\">let x = random(0, 100);\nlet y = random(0, 100);\nlet size = random(10, 20);\ncircle(x, y, size);\n\ntext(`The circle at (${x}, ${y}) has a diameter of ${size} pixels.`,  10, 10);\n<\/code><\/pre>\n<p>Template literals are also helpful for creating multi-line text like so:<\/p>\n<pre><code class=\"language-js\">let poem = `My sketch doesn't run;\nit waits for me patiently\nwhile bugs point the way.`;\n\ntext(poem, 10, 10);\n<\/code><\/pre>\n","itemtype":"property","name":"String","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  \/\/ Display a welcome message.\n  text('Hello!', 50, 50);\n\n  describe('The text \"Hello!\" written on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  \/\/ Create a string variable.\n  let world = '\ud83c\udf0d';\n\n  \/\/ Display a welcome message using a template string.\n  text(`Hello, ${world}!`, 50, 50);\n\n  describe('The text \"Hello, \ud83c\udf0d!\" written on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":853,"description":"<p>A number that can be positive, negative, or zero.<\/p>\n<p>The <code>Number<\/code> data type is useful for describing values such as position,\nsize, and color. A number can be an integer such as 20 or a decimal number\nsuch as 12.34. For example, a circle's position and size can be described\nby three numbers:<\/p>\n<pre><code class=\"language-js\">circle(50, 50, 20);\n<\/code><\/pre>\n<pre><code class=\"language-js\">circle(50, 50, 12.34);\n<\/code><\/pre>\n<p>Numbers support basic arithmetic and follow the standard order of\noperations: Parentheses, Exponents, Multiplication, Division, Addition,\nand Subtraction (PEMDAS). For example, it's common to use arithmetic\noperators with p5.js' system variables that are numbers:<\/p>\n<pre><code class=\"language-js\">\/\/ Draw a circle at the center.\ncircle(width \/ 2, height \/ 2, 20);\n<\/code><\/pre>\n<pre><code class=\"language-js\">\/\/ Draw a circle that moves from left to right.\ncircle(frameCount * 0.01, 50, 20);\n<\/code><\/pre>\n<p>Here's a quick overview of the arithmetic operators:<\/p>\n<pre><code class=\"language-js\">1 + 2 \/\/ Add\n1 - 2 \/\/ Subtract\n1 * 2 \/\/ Multiply\n1 \/ 2 \/\/ Divide\n1 % 2 \/\/ Remainder\n1 ** 2 \/\/ Exponentiate\n<\/code><\/pre>\n<p>It's common to update a number variable using arithmetic. For example, an\nobject's location can be updated like so:<\/p>\n<pre><code class=\"language-js\">x = x + 1;\n<\/code><\/pre>\n<p>The statement above adds 1 to a variable <code>x<\/code> using the <code>+<\/code> operator. The\naddition assignment operator <code>+=<\/code> expresses the same idea:<\/p>\n<pre><code class=\"language-js\">x += 1;\n<\/code><\/pre>\n<p>Here's a quick overview of the assignment operators:<\/p>\n<pre><code class=\"language-js\">x += 2 \/\/ Addition assignment\nx -= 2 \/\/ Subtraction assignment\nx *= 2 \/\/ Multiplication assignment\nx \/= 2 \/\/ Division assignment\nx %= 2 \/\/ Remainder assignment\n<\/code><\/pre>\n<p>Numbers can be compared using the\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators#relational_operators\" target=\"_blank\">relational operators<\/a>\n<code>><\/code>, <code><<\/code>, <code>>=<\/code>, <code><=<\/code>, <code>===<\/code>, and <code>!==<\/code>.  For example, a sketch's\n<a href=\"#\/p5\/frameCount\">frameCount<\/a> can be used as a timer:<\/p>\n<pre><code class=\"language-js\">if (frameCount > 1000) {\n  text('Game over!', 50, 50);\n}\n<\/code><\/pre>\n<p>An expression such as <code>frameCount > 1000<\/code> evaluates to a <code>Boolean<\/code> value\nthat's either <code>true<\/code> or <code>false<\/code>. The relational operators all produce\n<code>Boolean<\/code> values:<\/p>\n<pre><code class=\"language-js\">2 > 1 \/\/ true\n2 < 1 \/\/ false\n2 >= 2 \/\/ true\n2 <= 2 \/\/ true\n2 === 2 \/\/ true\n2 !== 2 \/\/ false\n<\/code><\/pre>\n<p>See <a href=\"#\/p5\/Boolean\">Boolean<\/a> for more information about comparisons and conditions.<\/p>\n<p>Note: There are also <code>==<\/code> and <code>!=<\/code> operators with one fewer <code>=<\/code>. Don't use them.<\/p>\n<p>Expressions with numbers can also produce special values when something\ngoes wrong:<\/p>\n<pre><code class=\"language-js\">sqrt(-1) \/\/ NaN\n1 \/ 0 \/\/ Infinity\n<\/code><\/pre>\n<p>The value <code>NaN<\/code> stands for\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/NaN\" target=\"_blank\">Not-A-Number<\/a>.\n<code>NaN<\/code> appears when calculations or conversions don't work. <code>Infinity<\/code> is a\nvalue that's larger than any number. It appears during certain\ncalculations.<\/p>\n","itemtype":"property","name":"Number","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw a circle at the center.\n  circle(50, 50, 70);\n\n  \/\/ Draw a smaller circle at the center.\n  circle(width \/ 2, height \/ 2, 30);\n\n  describe('Two concentric, white circles drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle travels from left to right on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  circle(frameCount * 0.05, 50, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":999,"description":"<p>A container for data that's stored as key-value pairs.<\/p>\n<p>Objects help to organize related data of any type, including other objects.\nA value stored in an object can be accessed by name, called its key. Each\nkey-value pair is called a \"property.\" Objects are similar to dictionaries\nin Python and maps in Java and Ruby.<\/p>\n<p>For example, an object could contain the location, size, and appearance of\na dog:<\/p>\n<pre><code class=\"language-js\">\/\/ Declare the dog variable and assign it an object.\nlet dog = { x: 50, y: 50, size: 20, emoji: '\ud83d\udc36' };\n\n\/\/ Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(dog.size);\n\n\/\/ Draw the dog.\ntext(dog.emoji, dog.x, dog.y);\n<\/code><\/pre>\n<p>The variable <code>dog<\/code> is assigned an object with four properties. Objects\nare declared with curly braces <code>{}<\/code>. Values can be accessed using the dot\noperator, as in <code>dog.size<\/code>. In the example above, the key <code>size<\/code>\ncorresponds to the value <code>20<\/code>. Objects can also be empty to start:<\/p>\n<pre><code class=\"language-js\">\/\/ Declare a cat variable and assign it an empty object.\nlet cat = {};\n\n\/\/ Add properties to the object.\ncat.x = 50;\ncat.y = 50;\ncat.size = 20;\ncat.emoji = '\ud83d\udc31';\n\n\/\/ Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(cat.size);\n\n\/\/ Draw the cat.\ntext(cat.emoji, cat.x, cat.y);\n<\/code><\/pre>\n<p>An object's data can be updated while a sketch runs. For example, the <code>cat<\/code>\ncould run away from the <code>dog<\/code> by updating its location:<\/p>\n<pre><code class=\"language-js\">\/\/ Run to the right.\ncat.x += 5;\n<\/code><\/pre>\n<p>If needed, an object's values can be accessed using square brackets <code>[]<\/code>\nand strings instead of dot notation:<\/p>\n<pre><code class=\"language-js\">\/\/ Run to the right.\ncat[\"x\"] += 5;\n<\/code><\/pre>\n<p>This syntax can be helpful when the key's name has spaces, as in\n<code>cat['height (m)']<\/code>.<\/p>\n","itemtype":"property","name":"Object","example":["\n<div>\n<code>\n\/\/ Declare the variable data and assign it an object with three properties.\nlet data = { x: 50, y: 50, d: 20 };\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access the object's values using the . operator.\n  circle(data.x, data.y, data.d);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable data and assign it an object with three properties.\nlet data = { x: 50, y: 50, d: 20 };\n\n\/\/ Add another property for color.\ndata.color = 'deeppink';\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A pink circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access the object's values using the . operator.\n  fill(data.color);\n  circle(data.x, data.y, data.d);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable data and assign it an object with three properties.\nlet data = { x: 50, y: 50, d: 20 };\n\n\/\/ Add another property for color.\ndata.color = 'deeppink';\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access the object's values using the . operator.\n  fill(data.color);\n  circle(data.x, data.y, data.d);\n\n  \/\/ Update the object's x and y properties.\n  data.x += random(-1, 1);\n  data.y += random(-1, 1);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":1140,"description":"<p>A list that keeps several pieces of data in order.<\/p>\n<p>Arrays are helpful for storing related data. They can contain data of any\ntype. For example, an array could contain a list of someone's favorite\ncolors as strings. Arrays are created as follows:<\/p>\n<pre><code class=\"language-js\">let myArray = ['deeppink', 'darkorchid', 'magenta'];\n<\/code><\/pre>\n<p>Each piece of data in an array is called an element. Each element has an\naddress, or index, within its array. The variable <code>myArray<\/code> refers to an\narray with three <a href=\"#\/p5\/String\">String<\/a> elements, <code>'deeppink'<\/code>,\n<code>'darkorchid'<\/code>, and <code>'magenta'<\/code>. Arrays are zero-indexed, which means\nthat <code>'deeppink'<\/code> is at index 0, <code>'darkorchid'<\/code> is at index 1, and\n'<code>magenta'<\/code> is at index 2. Array elements can be accessed using their\nindices as follows:<\/p>\n<pre><code class=\"language-js\">let zeroth = myArray[0]; \/\/ 'deeppink'\nlet first = myArray[1]; \/\/ 'darkorchid'\nlet second = myArray[2]; \/\/ 'magenta'\n<\/code><\/pre>\n<p>Elements can be added to the end of an array by calling the\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/push\" target=\"_blank\">push()<\/a>\nmethod as follows:<\/p>\n<pre><code class=\"language-js\">myArray.push('lavender');\n\nlet third = myArray[3]; \/\/ 'lavender'\n<\/code><\/pre>\n<p>See <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/First_steps\/Arrays\" target=\"_blank\">MDN<\/a>\nfor more information about arrays.<\/p>\n","itemtype":"property","name":"Array","example":["\n<div>\n<code>\n\/\/ Declare the variable xCoordinates and assign it an array\n\/\/ with three numeric elements.\nlet xCoordinates = [25, 50, 75];\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'Three white circles drawn in a horizontal line on a gray background.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access the element at index 0, which is 25.\n  circle(xCoordinates[0], 50, 20);\n\n  \/\/ Access the element at index 1, which is 50.\n  circle(xCoordinates[1], 50, 20);\n\n  \/\/ Access the element at index 2, which is 75.\n  circle(xCoordinates[2], 50, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable xCoordinates and assign it an array with three numeric elements.\nlet xCoordinates = [20, 40, 60];\n\n\/\/ Add another element to the end of the array.\nxCoordinates.push(80);\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Four white circles drawn in a horizontal line on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access the element at index 0, which is 20.\n  circle(xCoordinates[0], 50, 20);\n\n  \/\/ Access the element at index 1, which is 40.\n  circle(xCoordinates[1], 50, 20);\n\n  \/\/ Access the element at index 2, which is 60.\n  circle(xCoordinates[2], 50, 20);\n\n  \/\/ Access the element at index 3, which is 80.\n  circle(xCoordinates[3], 50, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable xCoordinates and assign it an empty array.\nlet xCoordinates = [];\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Add elements to the array using a loop.\n  for (let x = 20; x < 100; x += 20) {\n    xCoordinates.push(x);\n  }\n\n  describe('Four white circles drawn in a horizontal line on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access the element at index i and use it to draw a circle.\n  for (let i = 0; i < xCoordinates.length; i += 1) {\n    circle(xCoordinates[i], 50, 20);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable xCoordinates and assign it an empty array.\nlet xCoordinates = [];\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Add elements to the array using a loop.\n  for (let x = 20; x < 100; x += 20) {\n    xCoordinates.push(x);\n  }\n\n  describe('Four white circles drawn in a horizontal line on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access each element of the array and use it to draw a circle.\n  for (let x of xCoordinates) {\n    circle(x, 50, 20);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable xCoordinates and assign it an empty array.\nlet xCoordinates = [];\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Add elements to the array using a loop.\n  for (let x = 20; x < 100; x += 20) {\n    xCoordinates.push(x);\n  }\n\n  describe(\n    'Four white circles in a horizontal line on a gray background. The circles move randomly.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  for (let i = 0; i < xCoordinates.length; i += 1) {\n    \/\/ Update the element at index i.\n    xCoordinates[i] += random(-1, 1);\n\n    \/\/ Use the element at index i to draw a circle.\n    circle(xCoordinates[i], 50, 20);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":1329,"description":"<p>A template for creating objects of a particular type.<\/p>\n<p>Classes can make it easier to program with objects. For example, a <code>Frog<\/code>\nclass could create objects that behave like frogs. Each object created\nusing a class is called an instance of that class. All instances of a class\nare the same type. Here's an example of creating an instance of a <code>Frog<\/code>\nclass:<\/p>\n<pre><code class=\"language-js\">let fifi = new Frog(50, 50, 20);\n<\/code><\/pre>\n<p>The variable <code>fifi<\/code> refers to an instance of the <code>Frog<\/code> class. The keyword\n<code>new<\/code> is used to call the <code>Frog<\/code> class' constructor in the statement\n<code>new Frog()<\/code>. Altogether, a new <code>Frog<\/code> object was created and assigned to\nthe variable <code>fifi<\/code>. Classes are templates, so they can be used to create\nmore than one instance:<\/p>\n<pre><code class=\"language-js\">\/\/ First Frog instance.\nlet frog1 = new Frog(25, 50, 10);\n\n\/\/ Second Frog instance.\nlet frog2 = new Frog(75, 50, 10);\n<\/code><\/pre>\n<p>A simple <code>Frog<\/code> class could be declared as follows:<\/p>\n<pre><code class=\"language-js\">class Frog {\n  constructor(x, y, size) {\n    \/\/ This code runs once when an instance is created.\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    \/\/ This code runs once when myFrog.show() is called.\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\ud83d\udc38', this.x, this.y);\n  }\n\n  hop() {\n    \/\/ This code runs once when myFrog.hop() is called.\n    this.x += random(-10, 10);\n    this.y += random(-10, 10);\n  }\n}\n<\/code><\/pre>\n<p>Class declarations begin with the keyword <code>class<\/code> followed by the class\nname, such as <code>Frog<\/code>, and curly braces <code>{}<\/code>. Class names should use\n<code>PascalCase<\/code> and can't have spaces in their names. For example, naming a\nclass <code>Kermit The Frog<\/code> with spaces between each word would throw a\n<code>SyntaxError<\/code>. The code between the curly braces <code>{}<\/code> defines the class.<\/p>\n<p>Functions that belong to a class are called methods. <code>constructor()<\/code>,\n<code>show()<\/code>, and <code>hop()<\/code> are methods in the <code>Frog<\/code> class. Methods define an\nobject's behavior. Methods can accept parameters and return values, just\nlike functions. Note that methods don't use the <code>function<\/code> keyword.<\/p>\n<p><code>constructor()<\/code> is a special method that's called once when an instance of\nthe class is created. The statement <code>new Frog()<\/code> calls the <code>Frog<\/code> class'\n<code>constructor()<\/code> method.<\/p>\n<p>A class definition is a template for instances. The keyword <code>this<\/code> refers\nto an instance's data and methods. For example, each <code>Frog<\/code> instance has\nunique coordinates stored in <code>this.x<\/code> and <code>this.y<\/code>. The <code>show()<\/code> method\nuses those coordinates to draw the frog. The <code>hop()<\/code> method updates those\ncoordinates when called. Once a <code>Frog<\/code> instance is created, its data and\nmethods can be accessed using the dot operator <code>.<\/code> as follows:<\/p>\n<pre><code class=\"language-js\">\/\/ Draw a lily pad.\nfill('green');\nstroke('green');\ncircle(fifi.x, fifi.y, 2 * fifi.size);\n\n\/\/ Show the Frog.\nfifi.show();\n\n\/\/ Hop.\nfifi.hop();\n<\/code><\/pre>\n","itemtype":"property","name":"class","example":["\n<div>\n<code>\n\/\/ Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Assign the frog variable a new Frog object.\n  fifi = new Frog(50, 50, 20);\n\n  describe('A frog face drawn on a blue background.');\n}\n\nfunction draw() {\n  background('cornflowerblue');\n\n  \/\/ Show the frog.\n  fifi.show();\n}\n\nclass Frog {\n  constructor(x, y, size) {\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\ud83d\udc38', this.x, this.y);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Assign the frog variables a new Frog object.\n  frog1 = new Frog(25, 50, 10);\n  frog2 = new Frog(75, 50, 20);\n\n  describe('Two frog faces drawn next to each other on a blue background.');\n}\n\nfunction draw() {\n  background('cornflowerblue');\n\n  \/\/ Show the frogs.\n  frog1.show();\n  frog2.show();\n}\n\nclass Frog {\n  constructor(x, y, size) {\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\ud83d\udc38', this.x, this.y);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Assign the frog variables a new Frog object.\n  frog1 = new Frog(25, 50, 10);\n  frog2 = new Frog(75, 50, 20);\n\n  \/\/ Slow the frame rate.\n  frameRate(1);\n\n  describe('Two frog faces on a blue background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n  background('cornflowerblue');\n\n  \/\/ Show the frogs.\n  frog1.show();\n  frog2.show();\n\n  \/\/ Move the frogs.\n  frog1.hop();\n  frog2.hop();\n\n  \/\/ Wrap around if they've hopped off the edge.\n  frog1.checkEdges();\n  frog2.checkEdges();\n}\n\nclass Frog {\n  constructor(x, y, size) {\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\ud83d\udc38', this.x, this.y);\n  }\n\n  hop() {\n    this.x += random(-10, 10);\n    this.y += random(-10, 10);\n  }\n\n  checkEdges() {\n    if (this.x > width) {\n      this.x = this.x - width;\n    } else if (this.x < 0) {\n      this.x = width - this.x;\n    }\n\n    if (this.y > height) {\n      this.y = this.y - height;\n    } else if (this.y < 0) {\n      this.y = height - this.y;\n    }\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Add Frog objects to the array.\n  for (let i = 0; i < 5; i += 1) {\n    \/\/ Calculate random coordinates and size.\n    let x = random(0, 100);\n    let y = random(0, 100);\n    let s = random(2, 20);\n\n    \/\/ Create a new Frog object.\n    let frog = new Frog(x, y, s);\n\n    \/\/ Add the Frog to the array.\n    frogs.push(frog);\n  }\n\n  \/\/ Slow the frame rate.\n  frameRate(1);\n\n  describe(\n    'Five frog faces on a blue background. The frogs hop around randomly.'\n  );\n}\n\nfunction draw() {\n  background('cornflowerblue');\n\n  for (let frog of frogs) {\n    \/\/ Show the frog.\n    frog.show();\n\n    \/\/ Move the frog.\n    frog.hop();\n\n    \/\/ Wrap around if they've hopped off the edge.\n    frog.checkEdges();\n  }\n}\n\nclass Frog {\n  constructor(x, y, size) {\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\ud83d\udc38', this.x, this.y);\n  }\n\n  hop() {\n    this.x += random(-10, 10);\n    this.y += random(-10, 10);\n  }\n\n  checkEdges() {\n    if (this.x > width) {\n      this.x = this.x - width;\n    } else if (this.x < 0) {\n      this.x = width - this.x;\n    }\n\n    if (this.y > height) {\n      this.y = this.y - height;\n    } else if (this.y < 0) {\n      this.y = height - this.y;\n    }\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":1648,"description":"<p>A way to repeat a block of code when the number of iterations is known.<\/p>\n<p><code>for<\/code> loops are helpful for repeating statements a certain number of times.\nFor example, a <code>for<\/code> loop makes it easy to express the idea\n\"draw five lines\" like so:<\/p>\n<pre><code class=\"language-js\">for (let x = 10; x < 100; x += 20) {\n  line(x, 25, x, 75);\n}\n<\/code><\/pre>\n<p>The loop's header begins with the keyword <code>for<\/code>. Loops generally count up\nor count down as they repeat, or iterate. The statements in parentheses\n<code>let x = 10; x < 100; x += 20<\/code> tell the loop how it should repeat:<\/p>\n<ul>\n<li><code>let x = 10<\/code> tells the loop to start counting at <code>10<\/code> and keep track of iterations using the variable <code>x<\/code>.<\/li>\n<li><code>x < 100<\/code> tells the loop to count up to, but not including, <code>100<\/code>.<\/li>\n<li><code>x += 20<\/code>  tells the loop to count up by <code>20<\/code> at the end of each iteration.<\/li>\n<\/ul>\n<p>The code between the curly braces <code>{}<\/code> is the loop's body. Statements in the\nloop body are repeated during each iteration of the loop.<\/p>\n<p>It's common to create infinite loops accidentally. When this happens,\nsketches may become unresponsive and the web browser may display a warning.\nFor example, the following loop never stops iterating because it doesn't\ncount up:<\/p>\n<pre><code class=\"language-js\">for (let x = 10; x < 100; x = 20) {\n  line(x, 25, x, 75);\n}\n<\/code><\/pre>\n<p>The statement <code>x = 20<\/code> keeps the variable <code>x<\/code> stuck at <code>20<\/code>, which is\nalways less than <code>100<\/code>.<\/p>\n<p><code>for<\/code> loops can also count down:<\/p>\n<pre><code class=\"language-js\">for (let d = 100; d > 0; d -= 10) {\n  circle(50, 50, d);\n}\n<\/code><\/pre>\n<p><code>for<\/code> loops can also contain other loops. The following nested loop draws a\ngrid of points:<\/p>\n<pre><code class=\"language-js\">\/\/ Loop from left to right.\nfor (let x = 10; x < 100; x += 10) {\n\n  \/\/ Loop from top to bottom.\n  for (let y = 10; y < 100; y += 10) {\n    point(x, y);\n  }\n\n}\n<\/code><\/pre>\n<p><code>for<\/code> loops are also helpful for iterating through the elements of an\narray. For example, it's common to iterate through an array that contains\ninformation about where or what to draw:<\/p>\n<pre><code class=\"language-js\">\/\/ Create an array of x-coordinates.\nlet xCoordinates = [20, 40, 60];\n\nfor (let i = 0; i < xCoordinates.length; i += 1) {\n  \/\/ Update the element.\n  xCoordinates[i] += random(-1, 1);\n\n  \/\/ Draw a circle.\n  circle(xCoordinates[i], 50, 20);\n}\n<\/code><\/pre>\n<p>If the array's values aren't modified, the <code>for...of<\/code> statement can\nsimplify the code. They're similar to <code>for<\/code> loops in Python and <code>for-each<\/code>\nloops in C++ and Java. The following loops have the same effect:<\/p>\n<pre><code class=\"language-js\">\/\/ Draw circles with a for loop.\nlet xCoordinates = [20, 40, 60];\n\nfor (let i = 0; i < xCoordinates.length; i += 1) {\n  circle(xCoordinates[i], 50, 20);\n}\n<\/code><\/pre>\n<pre><code class=\"language-js\">\/\/ Draw circles with a for...of statement.\nlet xCoordinates = [20, 40, 60];\n\nfor (let x of xCoordinates) {\n  circle(x, 50, 20);\n}\n<\/code><\/pre>\n<p>In the code snippets above, the variables <code>i<\/code> and <code>x<\/code> have different roles.<\/p>\n<p>In the first snippet, <code>i<\/code> counts from <code>0<\/code> up to <code>2<\/code>, which is one less than\n<code>xCoordinates.length<\/code>. <code>i<\/code> is used to access the element in <code>xCoordinates<\/code>\nat index <code>i<\/code>.<\/p>\n<p>In the second code snippet, <code>x<\/code> isn't keeping track of the loop's progress\nor an index. During each iteration, <code>x<\/code> contains the next element of\n<code>xCoordinates<\/code>. <code>x<\/code> starts from the beginning of <code>xCoordinates<\/code> (<code>20<\/code>) and\nupdates its value to <code>40<\/code> and then <code>60<\/code> during the next iterations.<\/p>\n","itemtype":"property","name":"for","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Five black vertical lines on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw vertical lines using a loop.\n  for (let x = 10; x < 100; x += 20) {\n    line(x, 25, x, 75);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Five white concentric circles drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw concentric circles using a loop.\n  for (let d = 100; d > 0; d -= 20) {\n    circle(50, 50, d);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A grid of black dots on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the spacing for points on the grid.\n  let space = 10;\n\n  \/\/ Increase the stroke weight.\n  strokeWeight(3);\n\n  \/\/ Loop from the left to the right.\n  for (let x = space; x < 100; x += space) {\n    \/\/ Loop from the top to the bottom.\n    for (let y = space; y < 100; y += space) {\n      point(x, y);\n    }\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable xCoordinates and assign it an array of numbers.\nlet xCoordinates = [20, 40, 60, 80];\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Four white circles drawn in a horizontal line on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access the element at index i and use it to draw a circle.\n  for (let i = 0; i < xCoordinates.length; i += 1) {\n    circle(xCoordinates[i], 50, 20);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Declare the variable xCoordinates and assign it an array of numbers.\nlet xCoordinates = [20, 40, 60, 80];\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Four white circles drawn in a horizontal line on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Access each element of the array and use it to draw a circle.\n  for (let x of xCoordinates) {\n    circle(x, 50, 20);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":1872,"description":"<p>A way to repeat a block of code.<\/p>\n<p><code>while<\/code> loops are helpful for repeating statements while a condition is\n<code>true<\/code>. They're like <code>if<\/code> statements that repeat. For example, a <code>while<\/code>\nloop makes it easy to express the idea \"draw several lines\" like so:<\/p>\n<pre><code class=\"language-js\">\/\/ Declare a variable to keep track of iteration.\nlet x = 10;\n\n\/\/ Repeat as long as x < 100\nwhile (x < 100) {\n  line(x, 25, x, 75);\n\n  \/\/ Increment by 20.\n  x += 20;\n}\n<\/code><\/pre>\n<p>The loop's header begins with the keyword <code>while<\/code>. Loops generally count up\nor count down as they repeat, or iterate. The statement in parentheses\n<code>x < 100<\/code> is a condition the loop checks each time it iterates. If the\ncondition is <code>true<\/code>, the loop runs the code between the curly braces <code>{}<\/code>,\nThe code between the curly braces is called the loop's body. If the\ncondition is <code>false<\/code>, the body is skipped and the loop is stopped.<\/p>\n<p>It's common to create infinite loops accidentally. For example, the\nfollowing loop never stops iterating because it doesn't count up:<\/p>\n<pre><code class=\"language-js\">\/\/ Declare a variable to keep track of iteration.\nlet x = 10;\n\n\/\/ Repeat as long as x < 100\nwhile (x < 100) {\n  line(x, 25, x, 75);\n}\n\n\/\/ This should be in the loop's body!\nx += 20;\n<\/code><\/pre>\n<p>The statement <code>x += 20<\/code> appears after the loop's body. That means the\nvariable <code>x<\/code> is stuck at <code>10<\/code>,  which is always less than <code>100<\/code>.<\/p>\n<p><code>while<\/code> loops are useful when the number of iterations isn't known in\nadvance. For example, concentric circles could be drawn at random\nincrements:<\/p>\n<pre><code class=\"language-js\">let d = 100;\nlet minSize = 5;\n\nwhile (d > minSize) {\n  circle(50, 50, d);\n  d -= random(10);\n}\n<\/code><\/pre>\n","itemtype":"property","name":"while","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Five black vertical lines on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Declare a variable to keep track of iteration.\n  let x = 10;\n\n  \/\/ Repeat as long as x < 100\n  while (x < 100) {\n    line(x, 25, x, 75);\n\n    \/\/ Increment by 20.\n    x += 20;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(5);\n\n  describe(\n    \"A gray square with several concentric circles at the center. The circles' sizes decrease at random increments.\"\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  let d = 100;\n  let minSize = 5;\n\n  while (d > minSize) {\n    circle(50, 50, d);\n    d -= random(5, 15);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/reference.js","line":1988,"description":"<p>Prints a message to the web browser's console.<\/p>\n<p>The <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/console\" target=\"_blank\">console<\/a>\nobject is helpful for printing messages while debugging. For example, it's\ncommon to add a <code>console.log()<\/code> statement while studying how a section of\ncode works:<\/p>\n<pre><code class=\"language-js\">if (isPlaying === true) {\n  \/\/ Add a console.log() statement to make sure this block of code runs.\n  console.log('Got here!');\n\n  \/\/ Game logic.\n}\n<\/code><\/pre>\n<p><code>console.error()<\/code> is helpful for tracking errors because it prints\nformatted messages. For example, it's common to encounter errors when\nloading media assets:<\/p>\n<pre><code class=\"language-js\">\/\/ Logs an error message with special formatting.\nfunction handleFailure(error) {\n  console.error('Oops!', error);\n}\n\n\/\/ Try to load an image and call handleError() if it fails.\nloadImage('https:\/\/example.com\/cat.jpg', handleImage, handleError);\n<\/code><\/pre>\n","itemtype":"property","name":"console","example":["\n<div>\n<code>\nfunction setup() {\n  noCanvas();\n\n  \/\/ Prints \"Hello!\" to the console.\n  console.log('Hello!');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Try to load an image from a fake URL.\n  \/\/ Call handleError() if the image fails to load.\n  loadImage('https:\/\/example.com\/cat.jpg', handleImage, handleError);\n}\n\n\/\/ Displays the image.\nfunction handleImage(img) {\n  image(img, 0, 0);\n\n  describe('A cat on a gray background.');\n}\n\n\/\/ Prints the error.\nfunction handleError(error) {\n  console.error('Oops!', error);\n\n  describe('A gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Foundation","submodule":"Foundation"},{"file":"src\/core\/rendering.js","line":15,"description":"<p>Creates a canvas element on the web page.<\/p>\n<p><code>createCanvas()<\/code> creates the main drawing canvas for a sketch. It should\nonly be called once at the beginning of <a href=\"#\/p5\/setup\">setup()<\/a>.\nCalling <code>createCanvas()<\/code> more than once causes unpredictable behavior.<\/p>\n<p>The first two parameters, <code>width<\/code> and <code>height<\/code>, are optional. They set the\ndimensions of the canvas and the values of the\n<a href=\"#\/p5\/width\">width<\/a> and <a href=\"#\/p5\/height\">height<\/a> system\nvariables. For example, calling <code>createCanvas(900, 500)<\/code> creates a canvas\nthat's 900\u00d7500 pixels. By default, <code>width<\/code> and <code>height<\/code> are both 100.<\/p>\n<p>The third parameter is also optional. If either of the constants <code>P2D<\/code> or\n<code>WEBGL<\/code> is passed, as in <code>createCanvas(900, 500, WEBGL)<\/code>, then it will set\nthe sketch's rendering mode. If an existing\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLCanvasElement\" target=\"_blank\">HTMLCanvasElement<\/a>\nis passed, as in <code>createCanvas(900, 500, myCanvas)<\/code>, then it will be used\nby the sketch.<\/p>\n<p>The fourth parameter is also optional. If an existing\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLCanvasElement\" target=\"_blank\">HTMLCanvasElement<\/a>\nis passed, as in <code>createCanvas(900, 500, WEBGL, myCanvas)<\/code>, then it will be\nused by the sketch.<\/p>\n<p>Note: In WebGL mode, the canvas will use a WebGL2 context if it's supported\nby the browser. Check the <a href=\"#\/p5\/webglVersion\">webglVersion<\/a>\nsystem variable to check what version is being used, or call\n<code>setAttributes({ version: 1 })<\/code> to create a WebGL1 context.<\/p>\n","itemtype":"method","name":"createCanvas","return":{"description":"new `p5.Renderer` that holds the canvas.","type":"p5.Renderer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Draw a diagonal line.\n  line(0, 0, width, height);\n\n  describe('A diagonal line drawn from top-left to bottom-right on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 50);\n\n  background(180);\n\n  \/\/ Draw a diagonal line.\n  line(0, 0, width, height);\n\n  describe('A diagonal line drawn from top-left to bottom-right on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Use WebGL mode.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(180);\n\n  \/\/ Draw a diagonal line.\n  line(-width \/ 2, -height \/ 2, width \/ 2, height \/ 2);\n\n  describe('A diagonal line drawn from top-left to bottom-right on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a p5.Renderer object.\n  let cnv = createCanvas(50, 50);\n\n  \/\/ Position the canvas.\n  cnv.position(10, 20);\n\n  background(180);\n\n  \/\/ Draw a diagonal line.\n  line(0, 0, width, height);\n\n  describe('A diagonal line drawn from top-left to bottom-right on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Rendering","submodule":"Rendering","overloads":[{"line":15,"params":[{"name":"width","description":"<p>width of the canvas. Defaults to 100.<\/p>\n","type":"Number","optional":true},{"name":"height","description":"<p>height of the canvas. Defaults to 100.<\/p>\n","type":"Number","optional":true},{"name":"renderer","description":"<p>either P2D or WEBGL. Defaults to <code>P2D<\/code>.<\/p>\n","type":"Constant","optional":true},{"name":"canvas","description":"<p>existing canvas element that should be used for the sketch.<\/p>\n","type":"HTMLCanvasElement","optional":true}],"return":{"description":"new `p5.Renderer` that holds the canvas.","type":"p5.Renderer"}},{"line":119,"params":[{"name":"width","description":"","type":"Number","optional":true},{"name":"height","description":"","type":"Number","optional":true},{"name":"canvas","description":"","type":"HTMLCanvasElement","optional":true}],"return":{"description":"","type":"p5.Renderer"}}]},{"file":"src\/core\/rendering.js","line":221,"description":"<p>Resizes the canvas to a given width and height.<\/p>\n<p><code>resizeCanvas()<\/code> immediately clears the canvas and calls\n<a href=\"#\/p5\/redraw\">redraw()<\/a>. It's common to call <code>resizeCanvas()<\/code>\nwithin the body of <a href=\"#\/p5\/windowResized\">windowResized()<\/a> like\nso:<\/p>\n<pre><code class=\"language-js\">function windowResized() {\n  resizeCanvas(windowWidth, windowHeight);\n}\n<\/code><\/pre>\n<p>The first two parameters, <code>width<\/code> and <code>height<\/code>, set the dimensions of the\ncanvas. They also the values of the <a href=\"#\/p5\/width\">width<\/a> and\n<a href=\"#\/p5\/height\">height<\/a> system variables. For example, calling\n<code>resizeCanvas(300, 500)<\/code> resizes the canvas to 300\u00d7500 pixels, then sets\n<a href=\"#\/p5\/width\">width<\/a> to 300 and\n<a href=\"#\/p5\/height\">height<\/a> 500.<\/p>\n<p>The third parameter, <code>noRedraw<\/code>, is optional. If <code>true<\/code> is passed, as in\n<code>resizeCanvas(300, 500, true)<\/code>, then the canvas will be canvas to 300\u00d7500\npixels but the <a href=\"#\/p5\/redraw\">redraw()<\/a> function won't be called\nimmediately. By default, <a href=\"#\/p5\/redraw\">redraw()<\/a> is called\nimmediately when <code>resizeCanvas()<\/code> finishes executing.<\/p>\n","itemtype":"method","name":"resizeCanvas","params":[{"name":"width","description":"<p>width of the canvas.<\/p>\n","type":"Number"},{"name":"height","description":"<p>height of the canvas.<\/p>\n","type":"Number"},{"name":"noRedraw","description":"<p>whether to delay calling\n                             <a href=\"#\/p5\/redraw\">redraw()<\/a>. Defaults\n                             to <code>false<\/code>.<\/p>\n","type":"Boolean","optional":true}],"example":["\n<div>\n<code>\n\/\/ Double-click to resize the canvas.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle drawn on a gray background. The canvas shrinks by half the first time the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(180);\n\n  \/\/ Draw a circle at the center of the canvas.\n  circle(width \/ 2, height \/ 2, 20);\n}\n\n\/\/ Resize the canvas when the user double-clicks.\nfunction doubleClicked() {\n  resizeCanvas(50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Resize the web browser to change the canvas size.\n\nfunction setup() {\n  createCanvas(windowWidth, windowHeight);\n\n  describe('A white circle drawn on a gray background.');\n}\n\nfunction draw() {\n  background(180);\n\n  \/\/ Draw a circle at the center of the canvas.\n  circle(width \/ 2, height \/ 2, 20);\n}\n\n\/\/ Always resize the canvas to fill the browser window.\nfunction windowResized() {\n  resizeCanvas(windowWidth, windowHeight);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/rendering.js","line":346,"description":"<p>Removes the default canvas.<\/p>\n<p>By default, a 100\u00d7100 pixels canvas is created without needing to call\n<a href=\"#\/p5\/createCanvas\">createCanvas()<\/a>. <code>noCanvas()<\/code> removes the\ndefault canvas for sketches that don't need it.<\/p>\n","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":370,"description":"<p>Creates a <a href=\"#\/p5.Graphics\">p5.Graphics<\/a> object.<\/p>\n<p><code>createGraphics()<\/code> creates an offscreen drawing canvas (graphics buffer)\nand returns it as a <a href=\"#\/p5.Graphics\">p5.Graphics<\/a> object. Drawing\nto a separate graphics buffer can be helpful for performance and for\norganizing code.<\/p>\n<p>The first two parameters, <code>width<\/code> and <code>height<\/code>, are optional. They set the\ndimensions of the <a href=\"#\/p5.Graphics\">p5.Graphics<\/a> object. For\nexample, calling <code>createGraphics(900, 500)<\/code> creates a graphics buffer\nthat's 900\u00d7500 pixels.<\/p>\n<p>The third parameter is also optional. If either of the constants <code>P2D<\/code> or\n<code>WEBGL<\/code> is passed, as in <code>createGraphics(900, 500, WEBGL)<\/code>, then it will set\nthe <a href=\"#\/p5.Graphics\">p5.Graphics<\/a> object's rendering mode. If an\nexisting\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLCanvasElement\" target=\"_blank\">HTMLCanvasElement<\/a>\nis passed, as in <code>createGraphics(900, 500, myCanvas)<\/code>, then it will be used\nby the graphics buffer.<\/p>\n<p>The fourth parameter is also optional. If an existing\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLCanvasElement\" target=\"_blank\">HTMLCanvasElement<\/a>\nis passed, as in <code>createGraphics(900, 500, WEBGL, myCanvas)<\/code>, then it will be\nused by the graphics buffer.<\/p>\n<p>Note: In WebGL mode, the <a href=\"#\/p5.Graphics\">p5.Graphics<\/a> object\nwill use a WebGL2 context if it's supported by the browser. Check the\n<a href=\"#\/p5\/webglVersion\">webglVersion<\/a> system variable to check what\nversion is being used, or call <code>setAttributes({ version: 1 })<\/code> to create a\nWebGL1 context.<\/p>\n","itemtype":"method","name":"createGraphics","return":{"description":"new graphics buffer.","type":"p5.Graphics"},"example":["\n<div>\n<code>\n\/\/  Double-click to draw the contents of the graphics buffer.\n\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Create the p5.Graphics object.\n  pg = createGraphics(50, 50);\n\n  \/\/ Draw to the graphics buffer.\n  pg.background(100);\n  pg.circle(pg.width \/ 2, pg.height \/ 2, 20);\n\n  describe('A gray square. A smaller, darker square with a white circle at its center appears when the user double-clicks.');\n}\n\n\/\/ Display the graphics buffer when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    image(pg, 25, 25);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/  Double-click to draw the contents of the graphics buffer.\n\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Create the p5.Graphics object in WebGL mode.\n  pg = createGraphics(50, 50, WEBGL);\n\n  \/\/ Draw to the graphics buffer.\n  pg.background(100);\n  pg.lights();\n  pg.noStroke();\n  pg.rotateX(QUARTER_PI);\n  pg.rotateY(QUARTER_PI);\n  pg.torus(15, 5);\n\n  describe('A gray square. A smaller, darker square with a white torus at its center appears when the user double-clicks.');\n}\n\n\/\/ Display the graphics buffer when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    image(pg, 25, 25);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Rendering","submodule":"Rendering","overloads":[{"line":370,"params":[{"name":"width","description":"<p>width of the graphics buffer.<\/p>\n","type":"Number"},{"name":"height","description":"<p>height of the graphics buffer.<\/p>\n","type":"Number"},{"name":"renderer","description":"<p>either P2D or WEBGL. Defaults to P2D.<\/p>\n","type":"Constant","optional":true},{"name":"canvas","description":"<p>existing canvas element that should be\n                                     used for the graphics buffer..<\/p>\n","type":"HTMLCanvasElement","optional":true}],"return":{"description":"new graphics buffer.","type":"p5.Graphics"}},{"line":475,"params":[{"name":"width","description":"","type":"Number"},{"name":"height","description":"","type":"Number"},{"name":"canvas","description":"","type":"HTMLCanvasElement","optional":true}],"return":{"description":"","type":"p5.Graphics"}}]},{"file":"src\/core\/rendering.js","line":483,"description":"<p>args[0] is expected to be renderer\nargs[1] is expected to be canvas<\/p>\n","class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/rendering.js","line":495,"description":"<p>Creates and a new <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object.<\/p>\n<p><a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> objects are separate drawing\nsurfaces that can be used as textures in WebGL mode. They're similar to\n<a href=\"#\/p5.Graphics\">p5.Graphics<\/a> objects and generally run much\nfaster when used as textures.<\/p>\n<p>The parameter, <code>options<\/code>, is optional. An object can be passed to configure\nthe <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. The available\nproperties are:<\/p>\n<ul>\n<li><code>format<\/code>: data format of the texture, either <code>UNSIGNED_BYTE<\/code>, <code>FLOAT<\/code>, or <code>HALF_FLOAT<\/code>. Default is <code>UNSIGNED_BYTE<\/code>.<\/li>\n<li><code>channels<\/code>: whether to store <code>RGB<\/code> or <code>RGBA<\/code> color channels. Default is to match the main canvas which is <code>RGBA<\/code>.<\/li>\n<li><code>depth<\/code>: whether to include a depth buffer. Default is <code>true<\/code>.<\/li>\n<li><code>depthFormat<\/code>: data format of depth information, either <code>UNSIGNED_INT<\/code> or <code>FLOAT<\/code>. Default is <code>FLOAT<\/code>.<\/li>\n<li><code>stencil<\/code>: whether to include a stencil buffer for masking. <code>depth<\/code> must be <code>true<\/code> for this feature to work. Defaults to the value of <code>depth<\/code> which is <code>true<\/code>.<\/li>\n<li><code>antialias<\/code>: whether to perform anti-aliasing. If set to <code>true<\/code>, as in <code>{ antialias: true }<\/code>, 2 samples will be used by default. The number of samples can also be set, as in <code>{ antialias: 4 }<\/code>. Default is to match <a href=\"#\/p5\/setAttributes\">setAttributes()<\/a> which is <code>false<\/code> (<code>true<\/code> in Safari).<\/li>\n<li><code>width<\/code>: width of the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Default is to always match the main canvas width.<\/li>\n<li><code>height<\/code>: height of the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Default is to always match the main canvas height.<\/li>\n<li><code>density<\/code>: pixel density of the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Default is to always match the main canvas pixel density.<\/li>\n<li><code>textureFiltering<\/code>: how to read values from the <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> object. Either <code>LINEAR<\/code> (nearby pixels will be interpolated) or <code>NEAREST<\/code> (no interpolation). Generally, use <code>LINEAR<\/code> when using the texture as an image and <code>NEAREST<\/code> if reading the texture as data. Default is <code>LINEAR<\/code>.<\/li>\n<\/ul>\n<p>If the <code>width<\/code>, <code>height<\/code>, or <code>density<\/code> attributes are set, they won't automatically match the main canvas and must be changed manually.<\/p>\n<p>Note: <code>createFramebuffer()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"createFramebuffer","params":[{"name":"options","description":"<p>configuration options.<\/p>\n","type":"Object","optional":true}],"return":{"description":"new framebuffer.","type":"p5.Framebuffer"},"example":["\n<div>\n<code>\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  describe('A grid of white toruses rotating against a dark gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Start drawing to the p5.Framebuffer object.\n  myBuffer.begin();\n\n  \/\/ Clear the drawing surface.\n  clear();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n\n  \/\/ Style the torus.\n  noStroke();\n\n  \/\/ Draw the torus.\n  torus(20);\n\n  \/\/ Stop drawing to the p5.Framebuffer object.\n  myBuffer.end();\n\n  \/\/ Iterate from left to right.\n  for (let x = -50; x < 50; x += 25) {\n    \/\/ Iterate from top to bottom.\n    for (let y = -50; y < 50; y += 25) {\n      \/\/ Draw the p5.Framebuffer object to the canvas.\n      image(myBuffer, x, y, 25, 25);\n    }\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create an options object.\n  let options = { width: 25, height: 25 };\n\n  \/\/ Create a p5.Framebuffer object.\n  \/\/ Use options for configuration.\n  myBuffer = createFramebuffer(options);\n\n  describe('A grid of white toruses rotating against a dark gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Start drawing to the p5.Framebuffer object.\n  myBuffer.begin();\n\n  \/\/ Clear the drawing surface.\n  clear();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n\n  \/\/ Style the torus.\n  noStroke();\n\n  \/\/ Draw the torus.\n  torus(5, 2.5);\n\n  \/\/ Stop drawing to the p5.Framebuffer object.\n  myBuffer.end();\n\n  \/\/ Iterate from left to right.\n  for (let x = -50; x < 50; x += 25) {\n    \/\/ Iterate from top to bottom.\n    for (let y = -50; y < 50; y += 25) {\n      \/\/ Draw the p5.Framebuffer object to the canvas.\n      image(myBuffer, x, y);\n    }\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/rendering.js","line":635,"description":"<p>Clears the depth buffer in WebGL mode.<\/p>\n<p><code>clearDepth()<\/code> clears information about how far objects are from the camera\nin 3D space. This information is stored in an object called the\n<em>depth buffer<\/em>. Clearing the depth buffer ensures new objects aren't drawn\nbehind old ones. Doing so can be useful for feedback effects in which the\nprevious frame serves as the background for the current frame.<\/p>\n<p>The parameter, <code>depth<\/code>, is optional. If a number is passed, as in\n<code>clearDepth(0.5)<\/code>, it determines the range of objects to clear from the\ndepth buffer. 0 doesn't clear any depth information, 0.5 clears depth\ninformation halfway between the near and far clipping planes, and 1 clears\ndepth information all the way to the far clipping plane. By default,\n<code>depth<\/code> is 1.<\/p>\n<p>Note: <code>clearDepth()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"clearDepth","params":[{"name":"depth","description":"<p>amount of the depth buffer to clear between 0\n                        (none) and 1 (far clipping plane). Defaults to 1.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\nlet previous;\nlet current;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Framebuffer objects.\n  previous = createFramebuffer({ format: FLOAT });\n  current = createFramebuffer({ format: FLOAT });\n\n  describe(\n    'A multicolor box drifts from side to side on a white background. It leaves a trail that fades over time.'\n  );\n}\n\nfunction draw() {\n  \/\/ Swap the previous p5.Framebuffer and the\n  \/\/ current one so it can be used as a texture.\n  [previous, current] = [current, previous];\n\n  \/\/ Start drawing to the current p5.Framebuffer.\n  current.begin();\n\n  \/\/ Paint the background.\n  background(255);\n\n  \/\/ Draw the previous p5.Framebuffer.\n  \/\/ Clear the depth buffer so the previous\n  \/\/ frame doesn't block the current one.\n  push();\n  tint(255, 250);\n  image(previous, -50, -50);\n  clearDepth();\n  pop();\n\n  \/\/ Draw the box on top of the previous frame.\n  push();\n  let x = 25 * sin(frameCount * 0.01);\n  let y = 25 * sin(frameCount * 0.02);\n  translate(x, y, 0);\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  normalMaterial();\n  box(12);\n  pop();\n\n  \/\/ Stop drawing to the current p5.Framebuffer.\n  current.end();\n\n  \/\/ Display the current p5.Framebuffer.\n  image(current, -50, -50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/rendering.js","line":720,"description":"<p>Sets the way colors blend when added to the canvas.<\/p>\n<p>By default, drawing with a solid color paints over the current pixel values\non the canvas. <code>blendMode()<\/code> offers many options for blending colors.<\/p>\n<p>Shapes, images, and text can be used as sources for drawing to the canvas.\nA source pixel changes the color of the canvas pixel where it's drawn. The\nfinal color results from blending the source pixel's color with the canvas\npixel's color. RGB color values from the source and canvas pixels are\ncompared, added, subtracted, multiplied, and divided to create different\neffects. Red values with red values, greens with greens, and blues with\nblues.<\/p>\n<p>The parameter, <code>mode<\/code>, sets the blend mode. For example, calling\n<code>blendMode(ADD)<\/code> sets the blend mode to <code>ADD<\/code>. The following blend modes\nare available in both 2D and WebGL mode:<\/p>\n<ul>\n<li><code>BLEND<\/code>: color values from the source overwrite the canvas. This is the default mode.<\/li>\n<li><code>ADD<\/code>: color values from the source are added to values from the canvas.<\/li>\n<li><code>DARKEST<\/code>: keeps the darkest color value.<\/li>\n<li><code>LIGHTEST<\/code>: keeps the lightest color value.<\/li>\n<li><code>EXCLUSION<\/code>: similar to <code>DIFFERENCE<\/code> but with less contrast.<\/li>\n<li><code>MULTIPLY<\/code>: color values from the source are multiplied with values from the canvas. The result is always darker.<\/li>\n<li><code>SCREEN<\/code>: all color values are inverted, then multiplied, then inverted again. The result is always lighter. (Opposite of <code>MULTIPLY<\/code>)<\/li>\n<li><code>REPLACE<\/code>: the last source drawn completely replaces the rest of the canvas.<\/li>\n<li><code>REMOVE<\/code>: overlapping pixels are removed by making them completely transparent.<\/li>\n<\/ul>\n<p>The following blend modes are only available in 2D mode:<\/p>\n<ul>\n<li><code>DIFFERENCE<\/code>: color values from the source are subtracted from the values from the canvas. If the difference is a negative number, it's made positive.<\/li>\n<li><code>OVERLAY<\/code>: combines <code>MULTIPLY<\/code> and <code>SCREEN<\/code>. Dark values in the canvas get darker and light values get lighter.<\/li>\n<li><code>HARD_LIGHT<\/code>: combines <code>MULTIPLY<\/code> and <code>SCREEN<\/code>. Dark values in the source get darker and light values get lighter.<\/li>\n<li><code>SOFT_LIGHT<\/code>: a softer version of <code>HARD_LIGHT<\/code>.<\/li>\n<li><code>DODGE<\/code>: lightens light tones and increases contrast. Divides the canvas color values by the inverted color values from the source.<\/li>\n<li><code>BURN<\/code>: darkens dark tones and increases contrast. Divides the source color values by the inverted color values from the canvas, then inverts the result.<\/li>\n<\/ul>\n<p>The following blend modes are only available in WebGL mode:<\/p>\n<ul>\n<li><code>SUBTRACT<\/code>: RGB values from the source are subtracted from the values from the canvas. If the difference is a negative number, it's made positive. Alpha (transparency) values from the source and canvas are added.<\/li>\n<\/ul>\n","itemtype":"method","name":"blendMode","params":[{"name":"mode","description":"<p>blend mode to set.\n               either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY,\n               EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n               SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT<\/p>\n","type":"Constant"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Use the default blend mode.\n  blendMode(BLEND);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A Sky Blue line and a Deep Rose line form an X on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(HARD_LIGHT);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('An ocean blue line and a hot pink line form an X on a gray background. The area where they overlap is Magenta purple.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(ADD);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('An icy blue line and a light lavender line form an X on a gray background. The area where they overlap is white.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(DARKEST);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A steel blue line and a cranberry line form an X on a gray background. The area where they overlap is deep purple.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(BURN);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A cobalt blue line and a burgundy line form an X on a gray background. The area where they overlap is black.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(LIGHTEST);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A pale lavender line and a soft beige line form an X on a gray background. The area where they overlap is pale lilac.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(EXCLUSION);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('An earthy brown line and a muted sage line form an X on a gray background. The area where they overlap is sage green.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(MULTIPLY);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A slate blue line and a plum line form an X on a gray background. The area where they overlap is dark Indigo.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(SCREEN);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A baby blue line and a peach pink line form an X on a gray background. The area where they overlap is misty lilac.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(REPLACE);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A diagonal deep rose line.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(REMOVE);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('The silhouette of an X is missing from a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(DIFFERENCE);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A light burgundy line and a forest green line form an X on a gray background. The area where they overlap is dark cocoa.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(OVERLAY);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A cornflower blue line and a light rose line form an X on a gray background. The area where they overlap is violet.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(SOFT_LIGHT);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('A pale sky line and a rose blush line form an X on a gray background. The area where they overlap is lavender.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Set the blend mode.\n  blendMode(DODGE);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the first line.\n  stroke('#1a85ff');\n  line(25, 25, 75, 75);\n\n  \/\/ Draw the second line.\n  stroke('#d41159');\n  line(75, 25, 25, 75);\n\n  describe('An aqua blue line and a light pink line form an X on a gray background. The area where they overlap is white.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Create a canvas with WEBGL mode.\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Set the background color.\n  background(180);\n\n  \/\/ Set the blend mode to SUBTRACT.\n  blendMode(SUBTRACT);\n\n  \/\/ Style the lines.\n  strokeWeight(30);\n\n  \/\/ Draw the blue line.\n  stroke('#1a85ff');\n  line(-25, -25, 25, 25);\n\n  \/\/ Draw the red line.\n  stroke('#d41159');\n  line(25, -25, -25, 25);\n\n  describe('A burnt orange and a sea green line form an X on a gray background. The area where they overlap is forest green.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/rendering.js","line":1198,"description":"<p>A system variable that provides direct access to the sketch's\n<code>&lt;canvas&gt;<\/code> element.<\/p>\n<p>The <code>&lt;canvas&gt;<\/code> element provides many specialized features that aren't\nincluded in the p5.js library. The <code>drawingContext<\/code> system variable\nprovides access to these features by exposing the sketch's\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CanvasRenderingContext2D\">CanvasRenderingContext2D<\/a>\nobject.<\/p>\n","itemtype":"property","name":"drawingContext","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(180);\n\n  \/\/ Style the circle using shadows.\n  drawingContext.shadowOffsetX = 5;\n  drawingContext.shadowOffsetY = -5;\n  drawingContext.shadowBlur = 10;\n  drawingContext.shadowColor = 'black';\n\n  \/\/ Draw the circle.\n  circle(50, 50, 40);\n\n  describe(\"A white circle on a gray background. The circle's edges are shadowy.\");\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background('skyblue');\n\n  \/\/ Style the circle using a color gradient.\n  let myGradient = drawingContext.createRadialGradient(50, 50, 3, 50, 50, 40);\n  myGradient.addColorStop(0, 'yellow');\n  myGradient.addColorStop(0.6, 'orangered');\n  myGradient.addColorStop(1, 'yellow');\n  drawingContext.fillStyle = myGradient;\n  drawingContext.strokeStyle = 'rgba(0, 0, 0, 0)';\n\n  \/\/ Draw the circle.\n  circle(50, 50, 40);\n\n  describe('A fiery sun drawn on a light blue background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Rendering","submodule":"Rendering"},{"file":"src\/core\/structure.js","line":9,"description":"<p>Stops the code in <a href=\"#\/p5\/draw\">draw()<\/a> from running repeatedly.<\/p>\n<p>By default, <a href=\"#\/p5\/draw\">draw()<\/a> tries to run 60 times per\nsecond. Calling <code>noLoop()<\/code> stops <a href=\"#\/p5\/draw\">draw()<\/a> from\nrepeating. The draw loop can be restarted by calling\n<a href=\"#\/p5\/loop\">loop()<\/a>. <a href=\"#\/p5\/draw\">draw()<\/a> can be run\nonce by calling <a href=\"#\/p5\/redraw\">redraw()<\/a>.<\/p>\n<p>The <a href=\"#\/p5\/isLooping\">isLooping()<\/a> function can be used to check\nwhether a sketch is looping, as in <code>isLooping() === true<\/code>.<\/p>\n","itemtype":"method","name":"noLoop","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Turn off the draw loop.\n  noLoop();\n\n  describe('A white half-circle on the left edge of a gray square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the circle's x-coordinate.\n  let x = frameCount;\n\n  \/\/ Draw the circle.\n  \/\/ Normally, the circle would move from left to right.\n  circle(x, 50, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click to stop the draw loop.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(5);\n\n  describe('A white circle moves randomly on a gray background. It stops moving when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the circle's coordinates.\n  let x = random(0, 100);\n  let y = random(0, 100);\n\n  \/\/ Draw the circle.\n  \/\/ Normally, the circle would move from left to right.\n  circle(x, y, 20);\n}\n\n\/\/ Stop the draw loop when the user double-clicks.\nfunction doubleClicked() {\n  noLoop();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet startButton;\nlet stopButton;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create the button elements and place them\n  \/\/ beneath the canvas.\n  startButton = createButton('\u25b6');\n  startButton.position(0, 100);\n  startButton.size(50, 20);\n  stopButton = createButton('\u25fe');\n  stopButton.position(50, 100);\n  stopButton.size(50, 20);\n\n  \/\/ Set functions to call when the buttons are pressed.\n  startButton.mousePressed(loop);\n  stopButton.mousePressed(noLoop);\n\n  \/\/ Slow the frame rate.\n  frameRate(5);\n\n  describe(\n    'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the circle's coordinates.\n  let x = random(0, 100);\n  let y = random(0, 100);\n\n  \/\/ Draw the circle.\n  \/\/ Normally, the circle would move from left to right.\n  circle(x, y, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/structure.js","line":127,"description":"<p>Resumes the draw loop after <a href=\"#\/p5\/noLoop\">noLoop()<\/a> has been\ncalled.<\/p>\n<p>By default, <a href=\"#\/p5\/draw\">draw()<\/a> tries to run 60 times per\nsecond. Calling <a href=\"#\/p5\/noLoop\">noLoop()<\/a> stops\n<a href=\"#\/p5\/draw\">draw()<\/a> from repeating. The draw loop can be\nrestarted by calling <code>loop()<\/code>.<\/p>\n<p>The <a href=\"#\/p5\/isLooping\">isLooping()<\/a> function can be used to check\nwhether a sketch is looping, as in <code>isLooping() === true<\/code>.<\/p>\n","itemtype":"method","name":"loop","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Turn off the draw loop.\n  noLoop();\n\n  describe(\n    'A white half-circle on the left edge of a gray square. The circle starts moving to the right when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the circle's x-coordinate.\n  let x = frameCount;\n\n  \/\/ Draw the circle.\n  circle(x, 50, 20);\n}\n\n\/\/ Resume the draw loop when the user double-clicks.\nfunction doubleClicked() {\n  loop();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet startButton;\nlet stopButton;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create the button elements and place them\n  \/\/ beneath the canvas.\n  startButton = createButton('\u25b6');\n  startButton.position(0, 100);\n  startButton.size(50, 20);\n  stopButton = createButton('\u25fe');\n  stopButton.position(50, 100);\n  stopButton.size(50, 20);\n\n  \/\/ Set functions to call when the buttons are pressed.\n  startButton.mousePressed(loop);\n  stopButton.mousePressed(noLoop);\n\n  \/\/ Slow the frame rate.\n  frameRate(5);\n\n  describe(\n    'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the circle's coordinates.\n  let x = random(0, 100);\n  let y = random(0, 100);\n\n  \/\/ Draw the circle.\n  \/\/ Normally, the circle would move from left to right.\n  circle(x, y, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/structure.js","line":224,"description":"<p>Returns <code>true<\/code> if the draw loop is running and <code>false<\/code> if not.<\/p>\n<p>By default, <a href=\"#\/p5\/draw\">draw()<\/a> tries to run 60 times per\nsecond. Calling <a href=\"#\/p5\/noLoop\">noLoop()<\/a> stops\n<a href=\"#\/p5\/draw\">draw()<\/a> from repeating. The draw loop can be\nrestarted by calling <a href=\"#\/p5\/loop\">loop()<\/a>.<\/p>\n<p>The <code>isLooping()<\/code> function can be used to check whether a sketch is\nlooping, as in <code>isLooping() === true<\/code>.<\/p>\n","itemtype":"method","name":"isLooping","return":{"description":"","type":"Boolean"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle drawn against a gray background. When the user double-clicks, the circle stops or resumes following the mouse.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the circle at the mouse's position.\n  circle(mouseX, mouseY, 20);\n}\n\n\/\/ Toggle the draw loop when the user double-clicks.\nfunction doubleClicked() {\n  if (isLooping() === true) {\n    noLoop();\n  } else {\n    loop();\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/structure.js","line":269,"description":"<p>Begins a drawing group that contains its own styles and transformations.<\/p>\n<p>By default, styles such as <a href=\"#\/p5\/fill\">fill()<\/a> and\ntransformations such as <a href=\"#\/p5\/rotate\">rotate()<\/a> are applied to\nall drawing that follows. The <code>push()<\/code> and <a href=\"#\/p5\/pop\">pop()<\/a>\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:<\/p>\n<pre><code class=\"language-js\">\/\/ Begin the drawing group.\npush();\n\n\/\/ Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n\/\/ Style the face.\nnoStroke();\nfill('green');\n\n\/\/ Draw the face.\ncircle(0, 0, 60);\n\n\/\/ Style the eyes.\nfill('white');\n\n\/\/ Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n\/\/ Draw the right eye.\nellipse(20, -20, 30, 20);\n\n\/\/ End the drawing group.\npop();\n\n\/\/ Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\ud83e\udd9f', x, y);\n<\/code><\/pre>\n<p>In the code snippet above, the bug's position isn't affected by\n<code>translate(mouseX, mouseY)<\/code> because that transformation is contained\nbetween <code>push()<\/code> and <a href=\"#\/p5\/pop\">pop()<\/a>. The bug moves around\nthe entire canvas as expected.<\/p>\n<p>Note: <code>push()<\/code> and <a href=\"#\/p5\/pop\">pop()<\/a> are always called as a\npair. Both functions are required to begin and end a drawing group.<\/p>\n<p><code>push()<\/code> and <a href=\"#\/p5\/pop\">pop()<\/a> can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog\u2019s eyes:<\/p>\n<pre><code class=\"language-js\">\/\/ Begin the drawing group.\npush();\n\n\/\/ Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n\/\/ Style the face.\nnoStroke();\nfill('green');\n\n\/\/ Draw a face.\ncircle(0, 0, 60);\n\n\/\/ Style the eyes.\nfill('white');\n\n\/\/ Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n\/\/ Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n\/\/ End the drawing group.\npop();\n\n\/\/ Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\ud83e\udd9f', x, y);\n<\/code><\/pre>\n<p>In this version, the code to draw each eye is contained between its own\n<code>push()<\/code> and <a href=\"#\/p5\/pop\">pop()<\/a> functions. Doing so makes it\neasier to add details in the correct part of a drawing.<\/p>\n<p><code>push()<\/code> and <a href=\"#\/p5\/pop\">pop()<\/a> contain the effects of the\nfollowing functions:<\/p>\n<ul>\n<li><a href=\"#\/p5\/fill\">fill()<\/a><\/li>\n<li><a href=\"#\/p5\/noFill\">noFill()<\/a><\/li>\n<li><a href=\"#\/p5\/noStroke\">noStroke()<\/a><\/li>\n<li><a href=\"#\/p5\/stroke\">stroke()<\/a><\/li>\n<li><a href=\"#\/p5\/tint\">tint()<\/a><\/li>\n<li><a href=\"#\/p5\/noTint\">noTint()<\/a><\/li>\n<li><a href=\"#\/p5\/strokeWeight\">strokeWeight()<\/a><\/li>\n<li><a href=\"#\/p5\/strokeCap\">strokeCap()<\/a><\/li>\n<li><a href=\"#\/p5\/strokeJoin\">strokeJoin()<\/a><\/li>\n<li><a href=\"#\/p5\/imageMode\">imageMode()<\/a><\/li>\n<li><a href=\"#\/p5\/rectMode\">rectMode()<\/a><\/li>\n<li><a href=\"#\/p5\/ellipseMode\">ellipseMode()<\/a><\/li>\n<li><a href=\"#\/p5\/colorMode\">colorMode()<\/a><\/li>\n<li><a href=\"#\/p5\/textAlign\">textAlign()<\/a><\/li>\n<li><a href=\"#\/p5\/textFont\">textFont()<\/a><\/li>\n<li><a href=\"#\/p5\/textSize\">textSize()<\/a><\/li>\n<li><a href=\"#\/p5\/textLeading\">textLeading()<\/a><\/li>\n<li><a href=\"#\/p5\/applyMatrix\">applyMatrix()<\/a><\/li>\n<li><a href=\"#\/p5\/resetMatrix\">resetMatrix()<\/a><\/li>\n<li><a href=\"#\/p5\/rotate\">rotate()<\/a><\/li>\n<li><a href=\"#\/p5\/scale\">scale()<\/a><\/li>\n<li><a href=\"#\/p5\/shearX\">shearX()<\/a><\/li>\n<li><a href=\"#\/p5\/shearY\">shearY()<\/a><\/li>\n<li><a href=\"#\/p5\/translate\">translate()<\/a><\/li>\n<\/ul>\n<p>In WebGL mode, <code>push()<\/code> and <a href=\"#\/p5\/pop\">pop()<\/a> contain the\neffects of a few additional styles:<\/p>\n<ul>\n<li><a href=\"#\/p5\/setCamera\">setCamera()<\/a><\/li>\n<li><a href=\"#\/p5\/ambientLight\">ambientLight()<\/a><\/li>\n<li><a href=\"#\/p5\/directionalLight\">directionalLight()<\/a><\/li>\n<li><a href=\"#\/p5\/pointLight\">pointLight()<\/a> <a href=\"#\/p5\/texture\">texture()<\/a><\/li>\n<li><a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a><\/li>\n<li><a href=\"#\/p5\/shininess\">shininess()<\/a><\/li>\n<li><a href=\"#\/p5\/normalMaterial\">normalMaterial()<\/a><\/li>\n<li><a href=\"#\/p5\/shader\">shader()<\/a><\/li>\n<\/ul>\n","itemtype":"method","name":"push","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the left circle.\n  circle(25, 50, 20);\n\n  \/\/ Begin the drawing group.\n  push();\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Style the circle.\n  strokeWeight(5);\n  stroke('royalblue');\n  fill('orange');\n\n  \/\/ Draw the circle.\n  circle(0, 0, 20);\n\n  \/\/ End the drawing group.\n  pop();\n\n  \/\/ Draw the right circle.\n  circle(75, 50, 20);\n\n  describe(\n    'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(24);\n\n  describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Begin the drawing group.\n  push();\n\n  \/\/ Translate the origin to the mouse's position.\n  translate(mouseX, mouseY);\n\n  \/\/ Style the face.\n  noStroke();\n  fill('green');\n\n  \/\/ Draw a face.\n  circle(0, 0, 60);\n\n  \/\/ Style the eyes.\n  fill('white');\n\n  \/\/ Draw the left eye.\n  push();\n  translate(-20, -20);\n  ellipse(0, 0, 30, 20);\n  fill('black');\n  circle(0, 0, 8);\n  pop();\n\n  \/\/ Draw the right eye.\n  push();\n  translate(20, -20);\n  ellipse(0, 0, 30, 20);\n  fill('black');\n  circle(0, 0, 8);\n  pop();\n\n  \/\/ End the drawing group.\n  pop();\n\n  \/\/ Draw a bug.\n  let x = random(0, 100);\n  let y = random(0, 100);\n  text('\ud83e\udd9f', x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the red sphere.\n  push();\n  translate(-25, 0, 0);\n  noStroke();\n  directionalLight(255, 0, 0, 0, 0, -1);\n  sphere(20);\n  pop();\n\n  \/\/ Draw the blue sphere.\n  push();\n  translate(25, 0, 0);\n  strokeWeight(0.3);\n  stroke(0, 0, 255);\n  noFill();\n  sphere(20);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/structure.js","line":553,"description":"<p>Ends a drawing group that contains its own styles and transformations.<\/p>\n<p>By default, styles such as <a href=\"#\/p5\/fill\">fill()<\/a> and\ntransformations such as <a href=\"#\/p5\/rotate\">rotate()<\/a> are applied to\nall drawing that follows. The <a href=\"#\/p5\/push\">push()<\/a> and <code>pop()<\/code>\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:<\/p>\n<pre><code class=\"language-js\">\/\/ Begin the drawing group.\npush();\n\n\/\/ Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n\/\/ Style the face.\nnoStroke();\nfill('green');\n\n\/\/ Draw the face.\ncircle(0, 0, 60);\n\n\/\/ Style the eyes.\nfill('white');\n\n\/\/ Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n\/\/ Draw the right eye.\nellipse(20, -20, 30, 20);\n\n\/\/ End the drawing group.\npop();\n\n\/\/ Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\ud83e\udd9f', x, y);\n<\/code><\/pre>\n<p>In the code snippet above, the bug's position isn't affected by\n<code>translate(mouseX, mouseY)<\/code> because that transformation is contained\nbetween <a href=\"#\/p5\/push\">push()<\/a> and <code>pop()<\/code>. The bug moves around\nthe entire canvas as expected.<\/p>\n<p>Note: <a href=\"#\/p5\/push\">push()<\/a> and <code>pop()<\/code> are always called as a\npair. Both functions are required to begin and end a drawing group.<\/p>\n<p><a href=\"#\/p5\/push\">push()<\/a> and <code>pop()<\/code> can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog\u2019s eyes:<\/p>\n<pre><code class=\"language-js\">\/\/ Begin the drawing group.\npush();\n\n\/\/ Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n\/\/ Style the face.\nnoStroke();\nfill('green');\n\n\/\/ Draw a face.\ncircle(0, 0, 60);\n\n\/\/ Style the eyes.\nfill('white');\n\n\/\/ Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n\/\/ Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n\/\/ End the drawing group.\npop();\n\n\/\/ Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\ud83e\udd9f', x, y);\n<\/code><\/pre>\n<p>In this version, the code to draw each eye is contained between its own\n<a href=\"#\/p5\/push\">push()<\/a> and <code>pop()<\/code> functions. Doing so makes it\neasier to add details in the correct part of a drawing.<\/p>\n<p><a href=\"#\/p5\/push\">push()<\/a> and <code>pop()<\/code> contain the effects of the\nfollowing functions:<\/p>\n<ul>\n<li><a href=\"#\/p5\/fill\">fill()<\/a><\/li>\n<li><a href=\"#\/p5\/noFill\">noFill()<\/a><\/li>\n<li><a href=\"#\/p5\/noStroke\">noStroke()<\/a><\/li>\n<li><a href=\"#\/p5\/stroke\">stroke()<\/a><\/li>\n<li><a href=\"#\/p5\/tint\">tint()<\/a><\/li>\n<li><a href=\"#\/p5\/noTint\">noTint()<\/a><\/li>\n<li><a href=\"#\/p5\/strokeWeight\">strokeWeight()<\/a><\/li>\n<li><a href=\"#\/p5\/strokeCap\">strokeCap()<\/a><\/li>\n<li><a href=\"#\/p5\/strokeJoin\">strokeJoin()<\/a><\/li>\n<li><a href=\"#\/p5\/imageMode\">imageMode()<\/a><\/li>\n<li><a href=\"#\/p5\/rectMode\">rectMode()<\/a><\/li>\n<li><a href=\"#\/p5\/ellipseMode\">ellipseMode()<\/a><\/li>\n<li><a href=\"#\/p5\/colorMode\">colorMode()<\/a><\/li>\n<li><a href=\"#\/p5\/textAlign\">textAlign()<\/a><\/li>\n<li><a href=\"#\/p5\/textFont\">textFont()<\/a><\/li>\n<li><a href=\"#\/p5\/textSize\">textSize()<\/a><\/li>\n<li><a href=\"#\/p5\/textLeading\">textLeading()<\/a><\/li>\n<li><a href=\"#\/p5\/applyMatrix\">applyMatrix()<\/a><\/li>\n<li><a href=\"#\/p5\/resetMatrix\">resetMatrix()<\/a><\/li>\n<li><a href=\"#\/p5\/rotate\">rotate()<\/a><\/li>\n<li><a href=\"#\/p5\/scale\">scale()<\/a><\/li>\n<li><a href=\"#\/p5\/shearX\">shearX()<\/a><\/li>\n<li><a href=\"#\/p5\/shearY\">shearY()<\/a><\/li>\n<li><a href=\"#\/p5\/translate\">translate()<\/a><\/li>\n<\/ul>\n<p>In WebGL mode, <a href=\"#\/p5\/push\">push()<\/a> and <code>pop()<\/code> contain the\neffects of a few additional styles:<\/p>\n<ul>\n<li><a href=\"#\/p5\/setCamera\">setCamera()<\/a><\/li>\n<li><a href=\"#\/p5\/ambientLight\">ambientLight()<\/a><\/li>\n<li><a href=\"#\/p5\/directionalLight\">directionalLight()<\/a><\/li>\n<li><a href=\"#\/p5\/pointLight\">pointLight()<\/a> <a href=\"#\/p5\/texture\">texture()<\/a><\/li>\n<li><a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a><\/li>\n<li><a href=\"#\/p5\/shininess\">shininess()<\/a><\/li>\n<li><a href=\"#\/p5\/normalMaterial\">normalMaterial()<\/a><\/li>\n<li><a href=\"#\/p5\/shader\">shader()<\/a><\/li>\n<\/ul>\n","itemtype":"method","name":"pop","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the left circle.\n  circle(25, 50, 20);\n\n  \/\/ Begin the drawing group.\n  push();\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Style the circle.\n  strokeWeight(5);\n  stroke('royalblue');\n  fill('orange');\n\n  \/\/ Draw the circle.\n  circle(0, 0, 20);\n\n  \/\/ End the drawing group.\n  pop();\n\n  \/\/ Draw the right circle.\n  circle(75, 50, 20);\n\n  describe(\n    'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(24);\n\n  describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Begin the drawing group.\n  push();\n\n  \/\/ Translate the origin to the mouse's position.\n  translate(mouseX, mouseY);\n\n  \/\/ Style the face.\n  noStroke();\n  fill('green');\n\n  \/\/ Draw a face.\n  circle(0, 0, 60);\n\n  \/\/ Style the eyes.\n  fill('white');\n\n  \/\/ Draw the left eye.\n  push();\n  translate(-20, -20);\n  ellipse(0, 0, 30, 20);\n  fill('black');\n  circle(0, 0, 8);\n  pop();\n\n  \/\/ Draw the right eye.\n  push();\n  translate(20, -20);\n  ellipse(0, 0, 30, 20);\n  fill('black');\n  circle(0, 0, 8);\n  pop();\n\n  \/\/ End the drawing group.\n  pop();\n\n  \/\/ Draw a bug.\n  let x = random(0, 100);\n  let y = random(0, 100);\n  text('\ud83e\udd9f', x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the red sphere.\n  push();\n  translate(-25, 0, 0);\n  noStroke();\n  directionalLight(255, 0, 0, 0, 0, -1);\n  sphere(20);\n  pop();\n\n  \/\/ Draw the blue sphere.\n  push();\n  translate(25, 0, 0);\n  strokeWeight(0.3);\n  stroke(0, 0, 255);\n  noFill();\n  sphere(20);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/structure.js","line":838,"description":"<p>Runs the code in <a href=\"#\/p5\/draw\">draw()<\/a> once.<\/p>\n<p>By default, <a href=\"#\/p5\/draw\">draw()<\/a> tries to run 60 times per\nsecond. Calling <a href=\"#\/p5\/noLoop\">noLoop()<\/a> stops\n<a href=\"#\/p5\/draw\">draw()<\/a> from repeating. Calling <code>redraw()<\/code> will\nexecute the code in the <a href=\"#\/p5\/draw\">draw()<\/a> function a set\nnumber of times.<\/p>\n<p>The parameter, <code>n<\/code>, is optional. If a number is passed, as in <code>redraw(5)<\/code>,\nthen the draw loop will run the given number of times. By default, <code>n<\/code> is\n1.<\/p>\n","itemtype":"method","name":"redraw","params":[{"name":"n","description":"<p>number of times to run <a href=\"#\/p5\/draw\">draw()<\/a>. Defaults to 1.<\/p>\n","type":"Integer","optional":true}],"example":["\n<div>\n<code>\n\/\/ Double-click the canvas to move the circle.\n\nlet x = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Turn off the draw loop.\n  noLoop();\n\n  describe(\n    'A white half-circle on the left edge of a gray square. The circle moves a little to the right when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the circle.\n  circle(x, 50, 20);\n\n  \/\/ Increment x.\n  x += 5;\n}\n\n\/\/ Run the draw loop when the user double-clicks.\nfunction doubleClicked() {\n  redraw();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click the canvas to move the circle.\n\nlet x = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Turn off the draw loop.\n  noLoop();\n\n  describe(\n    'A white half-circle on the left edge of a gray square. The circle hops to the right when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the circle.\n  circle(x, 50, 20);\n\n  \/\/ Increment x.\n  x += 5;\n}\n\n\/\/ Run the draw loop three times when the user double-clicks.\nfunction doubleClicked() {\n  redraw(3);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/structure.js","line":959,"description":"<p>Creates a new sketch in \"instance\" mode.<\/p>\n<p>All p5.js sketches are instances of the <code>p5<\/code> class. Put another way, all\np5.js sketches are objects with methods including <code>pInst.setup()<\/code>,\n<code>pInst.draw()<\/code>, <code>pInst.circle()<\/code>, and <code>pInst.fill()<\/code>. By default, sketches\nrun in \"global mode\" to hide some of this complexity.<\/p>\n<p>In global mode, a default instance of the <code>p5<\/code> class is created\nautomatically. The default <code>p5<\/code> instance searches the web page's source\ncode for declarations of system functions such as <code>setup()<\/code>, <code>draw()<\/code>,\nand <code>mousePressed()<\/code>, then attaches those functions to itself as methods.\nCalling a function such as <code>circle()<\/code> in global mode actually calls the\ndefault <code>p5<\/code> object's <code>pInst.circle()<\/code> method.<\/p>\n<p>It's often helpful to isolate the code within sketches from the rest of the\ncode on a web page. Two common use cases are web pages that use other\nJavaScript libraries and web pages with multiple sketches. \"Instance mode\"\nmakes it easy to support both of these scenarios.<\/p>\n<p>Instance mode sketches support the same API as global mode sketches. They\nuse a function to bundle, or encapsulate, an entire sketch. The function\ncontaining the sketch is then passed to the <code>p5()<\/code> constructor.<\/p>\n<p>The first parameter, <code>sketch<\/code>, is a function that contains the sketch. For\nexample, the statement <code>new p5(mySketch)<\/code> would create a new instance mode\nsketch from a function named <code>mySketch<\/code>. The function should have one\nparameter, <code>p<\/code>, that's a <code>p5<\/code> object.<\/p>\n<p>The second parameter, <code>node<\/code>, is optional. If a string is passed, as in\n<code>new p5(mySketch, 'sketch-one')<\/code> the new instance mode sketch will become a\nchild of the HTML element with the id <code>sketch-one<\/code>. If an HTML element is\npassed, as in <code>new p5(mySketch, myElement)<\/code>, then the new instance mode\nsketch will become a child of the <code>Element<\/code> object called <code>myElement<\/code>.<\/p>\n","itemtype":"method","name":"p5","params":[{"name":"sketch","description":"<p>function containing the sketch.<\/p>\n","type":"Object"},{"name":"node","description":"<p>ID or reference to the HTML element that will contain the sketch.<\/p>\n","type":"String|HTMLElement"}],"example":["\n<div class='norender notest'>\n<code>\n\/\/ Declare the function containing the sketch.\nfunction sketch(p) {\n\n  \/\/ Declare the setup() method.\n  p.setup = function () {\n    p.createCanvas(100, 100);\n\n    p.describe('A white circle drawn on a gray background.');\n  };\n\n  \/\/ Declare the draw() method.\n  p.draw = function () {\n    p.background(200);\n\n    \/\/ Draw the circle.\n    p.circle(50, 50, 20);\n  };\n}\n\n\/\/ Initialize the sketch.\nnew p5(sketch);\n<\/code>\n<\/div>\n\n<div class='norender notest'>\n<code>\n\/\/ Declare the function containing the sketch.\nfunction sketch(p) {\n  \/\/ Create the sketch's variables within its scope.\n  let x = 50;\n  let y = 50;\n\n  \/\/ Declare the setup() method.\n  p.setup = function () {\n    p.createCanvas(100, 100);\n\n    p.describe('A white circle moves randomly on a gray background.');\n  };\n\n  \/\/ Declare the draw() method.\n  p.draw = function () {\n    p.background(200);\n\n    \/\/ Update x and y.\n    x += p.random(-1, 1);\n    y += p.random(-1, 1);\n\n    \/\/ Draw the circle.\n    p.circle(x, y, 20);\n  };\n}\n\n\/\/ Initialize the sketch.\nnew p5(sketch);\n<\/code>\n<\/div>\n\n<div class='norender notest'>\n<code>\n\/\/ Declare the function containing the sketch.\nfunction sketch(p) {\n\n  \/\/ Declare the setup() method.\n  p.setup = function () {\n    p.createCanvas(100, 100);\n\n    p.describe('A white circle drawn on a gray background.');\n  };\n\n  \/\/ Declare the draw() method.\n  p.draw = function () {\n    p.background(200);\n\n    \/\/ Draw the circle.\n    p.circle(50, 50, 20);\n  };\n}\n\n\/\/ Select the web page's body element.\nlet body = document.querySelector('body');\n\n\/\/ Initialize the sketch and attach it to the web page's body.\nnew p5(sketch, body);\n<\/code>\n<\/div>\n\n<div class='norender notest'>\n<code>\n\/\/ Declare the function containing the sketch.\nfunction sketch(p) {\n\n  \/\/ Declare the setup() method.\n  p.setup = function () {\n    p.createCanvas(100, 100);\n\n    p.describe(\n      'A white circle drawn on a gray background. The circle follows the mouse as the user moves.'\n    );\n  };\n\n  \/\/ Declare the draw() method.\n  p.draw = function () {\n    p.background(200);\n\n    \/\/ Draw the circle.\n    p.circle(p.mouseX, p.mouseY, 20);\n  };\n}\n\n\/\/ Initialize the sketch.\nnew p5(sketch);\n<\/code>\n<\/div>\n\n<div class='norender notest'>\n<code>\n\/\/ Declare the function containing the sketch.\nfunction sketch(p) {\n\n  \/\/ Declare the setup() method.\n  p.setup = function () {\n    p.createCanvas(100, 100);\n\n    p.describe(\n      'A white circle drawn on a gray background. The circle follows the mouse as the user moves. The circle becomes black when the user double-clicks.'\n    );\n  };\n\n  \/\/ Declare the draw() method.\n  p.draw = function () {\n    p.background(200);\n\n    \/\/ Draw the circle.\n    p.circle(p.mouseX, p.mouseY, 20);\n  };\n\n  \/\/ Declare the doubleClicked() method.\n  p.doubleClicked = function () {\n    \/\/ Change the fill color when the user double-clicks.\n    p.fill(0);\n  };\n}\n\n\/\/ Initialize the sketch.\nnew p5(sketch);\n<\/code>\n<\/div>"],"class":"p5","module":"Structure","submodule":"Structure"},{"file":"src\/core\/transform.js","line":11,"description":"<p>Applies a transformation matrix to the coordinate system.<\/p>\n<p>Transformations such as\n<a href=\"#\/p5\/translate\">translate()<\/a>,\n<a href=\"#\/p5\/rotate\">rotate()<\/a>, and\n<a href=\"#\/p5\/scale\">scale()<\/a>\nuse matrix-vector multiplication behind the scenes. A table of numbers,\ncalled a matrix, encodes each transformation. The values in the matrix\nthen multiply each point on the canvas, which is represented by a vector.<\/p>\n<p><code>applyMatrix()<\/code> allows for many transformations to be applied at once. See\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Transformation_matrix\" target=\"_blank\">Wikipedia<\/a>\nand <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/WebGL_API\/Matrix_math_for_the_web\" target=\"_blank\">MDN<\/a>\nfor more details about transformations.<\/p>\n<p>There are two ways to call <code>applyMatrix()<\/code> in two and three dimensions.<\/p>\n<p>In 2D mode, the parameters <code>a<\/code>, <code>b<\/code>, <code>c<\/code>, <code>d<\/code>, <code>e<\/code>, and <code>f<\/code>, correspond to\nelements in the following transformation matrix:<\/p>\n<blockquote>\n<p><img style=\"max-width: 150px\" src=\"assets\/transformation-matrix.png\"\nalt=\"The transformation matrix used when applyMatrix is called in 2D mode.\"\/><\/p>\n<\/blockquote>\n<p>The numbers can be passed individually, as in\n<code>applyMatrix(2, 0, 0, 0, 2, 0)<\/code>. They can also be passed in an array, as in\n<code>applyMatrix([2, 0, 0, 0, 2, 0])<\/code>.<\/p>\n<p>In 3D mode, the parameters <code>a<\/code>, <code>b<\/code>, <code>c<\/code>, <code>d<\/code>, <code>e<\/code>, <code>f<\/code>, <code>g<\/code>, <code>h<\/code>, <code>i<\/code>,\n<code>j<\/code>, <code>k<\/code>, <code>l<\/code>, <code>m<\/code>, <code>n<\/code>, <code>o<\/code>, and <code>p<\/code> correspond to elements in the\nfollowing transformation matrix:<\/p>\n<p><img style=\"max-width: 300px\" src=\"assets\/transformation-matrix-4-4.png\"\nalt=\"The transformation matrix used when applyMatrix is called in 3D mode.\"\/><\/p>\n<p>The numbers can be passed individually, as in\n<code>applyMatrix(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)<\/code>. They can\nalso be passed in an array, as in\n<code>applyMatrix([2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1])<\/code>.<\/p>\n<p>By default, transformations accumulate. The\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions\ncan be used to isolate transformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>applyMatrix()<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't\ncause shapes to transform continuously.<\/p>\n","itemtype":"method","name":"applyMatrix","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  applyMatrix(1, 0, 0, 1, 50, 50);\n\n  \/\/ Draw the circle at coordinates (0, 0).\n  circle(0, 0, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  let m = [1, 0, 0, 1, 50, 50];\n  applyMatrix(m);\n\n  \/\/ Draw the circle at coordinates (0, 0).\n  circle(0, 0, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  let angle = QUARTER_PI;\n  let ca = cos(angle);\n  let sa = sin(angle);\n  applyMatrix(ca, sa, -sa, ca, 0, 0);\n\n  \/\/ Draw a rectangle at coordinates (50, 0).\n  rect(50, 0, 40, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a square at (30, 20).\n  square(30, 20, 40);\n\n  \/\/ Scale the coordinate system by a factor of 0.5.\n  applyMatrix(0.5, 0, 0, 0.5, 0, 0);\n\n  \/\/ Draw a square at (30, 20).\n  \/\/ It appears at (15, 10) after scaling.\n  square(30, 20, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white quadrilateral on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the shear factor.\n  let angle = QUARTER_PI;\n  let shearFactor = 1 \/ tan(HALF_PI - angle);\n\n  \/\/ Shear the coordinate system along the x-axis.\n  applyMatrix(1, 0, shearFactor, 1, 0, 0);\n\n  \/\/ Draw the square.\n  square(0, 0, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube rotates slowly against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system a little more each frame.\n  let angle = frameCount * 0.01;\n  let ca = cos(angle);\n  let sa = sin(angle);\n  applyMatrix(ca, 0, sa, 0, 0, 1, 0, 0, -sa, 0, ca, 0, 0, 0, 0, 1);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform","overloads":[{"line":11,"params":[{"name":"arr","description":"<p>an array containing the elements of the transformation matrix. Its length should be either 6 (2D) or 16 (3D).<\/p>\n","type":"Array"}],"chainable":1},{"line":206,"params":[{"name":"a","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"b","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"c","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"d","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"e","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"f","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"}],"chainable":1},{"line":216,"params":[{"name":"a","description":"","type":"Number"},{"name":"b","description":"","type":"Number"},{"name":"c","description":"","type":"Number"},{"name":"d","description":"","type":"Number"},{"name":"e","description":"","type":"Number"},{"name":"f","description":"","type":"Number"},{"name":"g","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"h","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"i","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"j","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"k","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"l","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"m","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"n","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"o","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"},{"name":"p","description":"<p>an element of the transformation matrix.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/core\/transform.js","line":246,"description":"<p>Clears all transformations applied to the coordinate system.<\/p>\n","itemtype":"method","name":"resetMatrix","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'Two circles drawn on a gray background. A blue circle is at the top-left and a red circle is at the bottom-right.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw a blue circle at the coordinates (25, 25).\n  fill('blue');\n  circle(25, 25, 20);\n\n  \/\/ Clear all transformations.\n  \/\/ The origin is now at the top-left corner.\n  resetMatrix();\n\n  \/\/ Draw a red circle at the coordinates (25, 25).\n  fill('red');\n  circle(25, 25, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src\/core\/transform.js","line":289,"description":"<p>Rotates the coordinate system.<\/p>\n<p>By default, the positive x-axis points to the right and the positive y-axis\npoints downward. The <code>rotate()<\/code> function changes this orientation by\nrotating the coordinate system about the origin. Everything drawn after\n<code>rotate()<\/code> is called will appear to be rotated.<\/p>\n<p>The first parameter, <code>angle<\/code>, is the amount to rotate. For example, calling\n<code>rotate(1)<\/code> rotates the coordinate system clockwise 1 radian which is\nnearly 57\u02da. <code>rotate()<\/code> interprets angle values using the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>The second parameter, <code>axis<\/code>, is optional. It's used to orient 3D rotations\nin WebGL mode. If a <a href=\"#\/p5.Vector\">p5.Vector<\/a> is passed, as in\n<code>rotate(QUARTER_PI, myVector)<\/code>, then the coordinate system will rotate\n<code>QUARTER_PI<\/code> radians about <code>myVector<\/code>. If an array of vector components is\npassed, as in <code>rotate(QUARTER_PI, [1, 0, 0])<\/code>, then the coordinate system\nwill rotate <code>QUARTER_PI<\/code> radians about a vector with the components\n<code>[1, 0, 0]<\/code>.<\/p>\n<p>By default, transformations accumulate. For example, calling <code>rotate(1)<\/code>\ntwice has the same effect as calling <code>rotate(2)<\/code> once. The\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions\ncan be used to isolate transformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>rotate(1)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't cause\nshapes to spin.<\/p>\n","itemtype":"method","name":"rotate","params":[{"name":"angle","description":"<p>angle of rotation in the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"},{"name":"axis","description":"<p>axis to rotate about in 3D.<\/p>\n","type":"p5.Vector|Number[]","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    \"A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right.\"\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotate(QUARTER_PI);\n\n  \/\/ Draw a rectangle at coordinates (50, 0).\n  rect(50, 0, 40, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    \"A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right.\"\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate the coordinate system 1\/16 turn.\n  rotate(QUARTER_PI \/ 2);\n\n  \/\/ Rotate the coordinate system another 1\/16 turn.\n  rotate(QUARTER_PI \/ 2);\n\n  \/\/ Draw a rectangle at coordinates (50, 0).\n  rect(50, 0, 40, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  describe(\n    \"A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right.\"\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotate(45);\n\n  \/\/ Draw a rectangle at coordinates (50, 0).\n  rect(50, 0, 40, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white rectangle on a gray background. The rectangle rotates slowly about the top-left corner. It disappears and reappears periodically.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate the coordinate system a little more each frame.\n  let angle = frameCount * 0.01;\n  rotate(angle);\n\n  \/\/ Draw a rectangle at coordinates (50, 0).\n  rect(50, 0, 40, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\"A cube on a gray background. The cube's front face points to the top-right.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate the coordinate system 1\/8 turn about\n  \/\/ the axis [1, 1, 0].\n  let axis = createVector(1, 1, 0);\n  rotate(QUARTER_PI, axis);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\"A cube on a gray background. The cube's front face points to the top-right.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate the coordinate system 1\/8 turn about\n  \/\/ the axis [1, 1, 0].\n  let axis = [1, 1, 0];\n  rotate(QUARTER_PI, axis);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src\/core\/transform.js","line":470,"description":"<p>Rotates the coordinate system about the x-axis in WebGL mode.<\/p>\n<p>The parameter, <code>angle<\/code>, is the amount to rotate. For example, calling\n<code>rotateX(1)<\/code> rotates the coordinate system about the x-axis by 1 radian.\n<code>rotateX()<\/code> interprets angle values using the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>By default, transformations accumulate. For example, calling <code>rotateX(1)<\/code>\ntwice has the same effect as calling <code>rotateX(2)<\/code> once. The\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions\ncan be used to isolate transformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>rotateX(1)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't cause\nshapes to spin.<\/p>\n","itemtype":"method","name":"rotateX","params":[{"name":"angle","description":"<p>angle of rotation in the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotateX(QUARTER_PI);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/16 turn.\n  rotateX(QUARTER_PI \/ 2);\n\n  \/\/ Rotate the coordinate system 1\/16 turn.\n  rotateX(QUARTER_PI \/ 2);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotateX(45);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube rotates slowly against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system a little more each frame.\n  let angle = frameCount * 0.01;\n  rotateX(angle);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src\/core\/transform.js","line":606,"description":"<p>Rotates the coordinate system about the y-axis in WebGL mode.<\/p>\n<p>The parameter, <code>angle<\/code>, is the amount to rotate. For example, calling\n<code>rotateY(1)<\/code> rotates the coordinate system about the y-axis by 1 radian.\n<code>rotateY()<\/code> interprets angle values using the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>By default, transformations accumulate. For example, calling <code>rotateY(1)<\/code>\ntwice has the same effect as calling <code>rotateY(2)<\/code> once. The\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions\ncan be used to isolate transformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>rotateY(1)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't cause\nshapes to spin.<\/p>\n","itemtype":"method","name":"rotateY","params":[{"name":"angle","description":"<p>angle of rotation in the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotateY(QUARTER_PI);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/16 turn.\n  rotateY(QUARTER_PI \/ 2);\n\n  \/\/ Rotate the coordinate system 1\/16 turn.\n  rotateY(QUARTER_PI \/ 2);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotateY(45);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube rotates slowly against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system a little more each frame.\n  let angle = frameCount * 0.01;\n  rotateY(angle);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src\/core\/transform.js","line":742,"description":"<p>Rotates the coordinate system about the z-axis in WebGL mode.<\/p>\n<p>The parameter, <code>angle<\/code>, is the amount to rotate. For example, calling\n<code>rotateZ(1)<\/code> rotates the coordinate system about the z-axis by 1 radian.\n<code>rotateZ()<\/code> interprets angle values using the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>By default, transformations accumulate. For example, calling <code>rotateZ(1)<\/code>\ntwice has the same effect as calling <code>rotateZ(2)<\/code> once. The\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions\ncan be used to isolate transformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>rotateZ(1)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't cause\nshapes to spin.<\/p>\n","itemtype":"method","name":"rotateZ","params":[{"name":"angle","description":"<p>angle of rotation in the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotateZ(QUARTER_PI);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/16 turn.\n  rotateZ(QUARTER_PI \/ 2);\n\n  \/\/ Rotate the coordinate system 1\/16 turn.\n  rotateZ(QUARTER_PI \/ 2);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system 1\/8 turn.\n  rotateZ(45);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube rotates slowly against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rotate the coordinate system a little more each frame.\n  let angle = frameCount * 0.01;\n  rotateZ(angle);\n\n  \/\/ Draw a box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src\/core\/transform.js","line":878,"description":"<p>Scales the coordinate system.<\/p>\n<p>By default, shapes are drawn at their original scale. A rectangle that's 50\npixels wide appears to take up half the width of a 100 pixel-wide canvas.\nThe <code>scale()<\/code> function can shrink or stretch the coordinate system so that\nshapes appear at different sizes. There are two ways to call <code>scale()<\/code> with\nparameters that set the scale factor(s).<\/p>\n<p>The first way to call <code>scale()<\/code> uses numbers to set the amount of scaling.\nThe first parameter, <code>s<\/code>, sets the amount to scale each axis. For example,\ncalling <code>scale(2)<\/code> stretches the x-, y-, and z-axes by a factor of 2. The\nnext two parameters, <code>y<\/code> and <code>z<\/code>, are optional. They set the amount to\nscale the y- and z-axes. For example, calling <code>scale(2, 0.5, 1)<\/code> stretches\nthe x-axis by a factor of 2, shrinks the y-axis by a factor of 0.5, and\nleaves the z-axis unchanged.<\/p>\n<p>The second way to call <code>scale()<\/code> uses a <a href=\"#\/p5.Vector\">p5.Vector<\/a>\nobject to set the scale factors. For example, calling <code>scale(myVector)<\/code>\nuses the x-, y-, and z-components of <code>myVector<\/code> to set the amount of\nscaling along the x-, y-, and z-axes. Doing so is the same as calling\n<code>scale(myVector.x, myVector.y, myVector.z)<\/code>.<\/p>\n<p>By default, transformations accumulate. For example, calling <code>scale(1)<\/code>\ntwice has the same effect as calling <code>scale(2)<\/code> once. The\n<a href=\"#\/p5\/push\">push()<\/a> and <a href=\"#\/p5\/pop\">pop()<\/a> functions\ncan be used to isolate transformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>scale(2)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't cause\nshapes to grow continuously.<\/p>\n","itemtype":"method","name":"scale","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a square at (30, 20).\n  square(30, 20, 40);\n\n  \/\/ Scale the coordinate system by a factor of 0.5.\n  scale(0.5);\n\n  \/\/ Draw a square at (30, 20).\n  \/\/ It appears at (15, 10) after scaling.\n  square(30, 20, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A rectangle and a square drawn in white on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a square at (30, 20).\n  square(30, 20, 40);\n\n  \/\/ Scale the coordinate system by factors of\n  \/\/ 0.5 along the x-axis and\n  \/\/ 1.3 along the y-axis.\n  scale(0.5, 1.3);\n\n  \/\/ Draw a square at (30, 20).\n  \/\/ It appears as a rectangle at (15, 26) after scaling.\n  square(30, 20, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A rectangle and a square drawn in white on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a square at (30, 20).\n  square(30, 20, 40);\n\n  \/\/ Create a p5.Vector object.\n  let v = createVector(0.5, 1.3);\n\n  \/\/ Scale the coordinate system by factors of\n  \/\/ 0.5 along the x-axis and\n  \/\/ 1.3 along the y-axis.\n  scale(v);\n\n  \/\/ Draw a square at (30, 20).\n  \/\/ It appears as a rectangle at (15, 26) after scaling.\n  square(30, 20, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A red box and a blue box drawn on a gray background. The red box appears embedded in the blue box.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the spheres.\n  noStroke();\n\n  \/\/ Draw the red sphere.\n  fill('red');\n  box();\n\n  \/\/ Scale the coordinate system by factors of\n  \/\/ 0.5 along the x-axis and\n  \/\/ 1.3 along the y-axis and\n  \/\/ 2 along the z-axis.\n  scale(0.5, 1.3, 2);\n\n  \/\/ Draw the blue sphere.\n  fill('blue');\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform","overloads":[{"line":878,"params":[{"name":"s","description":"<p>amount to scale along the positive x-axis.<\/p>\n","type":"Number|p5.Vector|Number[]"},{"name":"y","description":"<p>amount to scale along the positive y-axis. Defaults to <code>s<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>amount to scale along the positive z-axis. Defaults to <code>y<\/code>.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1039,"params":[{"name":"scales","description":"<p>vector whose components should be used to scale.<\/p>\n","type":"p5.Vector|Number[]"}],"chainable":1}]},{"file":"src\/core\/transform.js","line":1069,"description":"<p>Shears the x-axis so that shapes appear skewed.<\/p>\n<p>By default, the x- and y-axes are perpendicular. The <code>shearX()<\/code> function\ntransforms the coordinate system so that x-coordinates are translated while\ny-coordinates are fixed.<\/p>\n<p>The first parameter, <code>angle<\/code>, is the amount to shear. For example, calling\n<code>shearX(1)<\/code> transforms all x-coordinates using the formula\n<code>x = x + y * tan(angle)<\/code>. <code>shearX()<\/code> interprets angle values using the\ncurrent <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>By default, transformations accumulate. For example, calling\n<code>shearX(1)<\/code> twice has the same effect as calling <code>shearX(2)<\/code> once. The\n<a href=\"#\/p5\/push\">push()<\/a> and\n<a href=\"#\/p5\/pop\">pop()<\/a> functions can be used to isolate\ntransformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>shearX(1)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't\ncause shapes to shear continuously.<\/p>\n","itemtype":"method","name":"shearX","params":[{"name":"angle","description":"<p>angle to shear by in the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white quadrilateral on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Shear the coordinate system along the x-axis.\n  shearX(QUARTER_PI);\n\n  \/\/ Draw the square.\n  square(0, 0, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  describe('A white quadrilateral on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Shear the coordinate system along the x-axis.\n  shearX(45);\n\n  \/\/ Draw the square.\n  square(0, 0, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src\/core\/transform.js","line":1146,"description":"<p>Shears the y-axis so that shapes appear skewed.<\/p>\n<p>By default, the x- and y-axes are perpendicular. The <code>shearY()<\/code> function\ntransforms the coordinate system so that y-coordinates are translated while\nx-coordinates are fixed.<\/p>\n<p>The first parameter, <code>angle<\/code>, is the amount to shear. For example, calling\n<code>shearY(1)<\/code> transforms all y-coordinates using the formula\n<code>y = y + x * tan(angle)<\/code>. <code>shearY()<\/code> interprets angle values using the\ncurrent <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>By default, transformations accumulate. For example, calling\n<code>shearY(1)<\/code> twice has the same effect as calling <code>shearY(2)<\/code> once. The\n<a href=\"#\/p5\/push\">push()<\/a> and\n<a href=\"#\/p5\/pop\">pop()<\/a> functions can be used to isolate\ntransformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>shearY(1)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't\ncause shapes to shear continuously.<\/p>\n","itemtype":"method","name":"shearY","params":[{"name":"angle","description":"<p>angle to shear by in the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white quadrilateral on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Shear the coordinate system along the y-axis.\n  shearY(QUARTER_PI);\n\n  \/\/ Draw the square.\n  square(0, 0, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  describe('A white quadrilateral on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Shear the coordinate system along the y-axis.\n  shearY(45);\n\n  \/\/ Draw the square.\n  square(0, 0, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform"},{"file":"src\/core\/transform.js","line":1223,"description":"<p>Translates the coordinate system.<\/p>\n<p>By default, the origin <code>(0, 0)<\/code> is at the sketch's top-left corner in 2D\nmode and center in WebGL mode. The <code>translate()<\/code> function shifts the origin\nto a different position. Everything drawn after <code>translate()<\/code> is called\nwill appear to be shifted. There are two ways to call <code>translate()<\/code> with\nparameters that set the origin's position.<\/p>\n<p>The first way to call <code>translate()<\/code> uses numbers to set the amount of\ntranslation. The first two parameters, <code>x<\/code> and <code>y<\/code>, set the amount to\ntranslate along the positive x- and y-axes. For example, calling\n<code>translate(20, 30)<\/code> translates the origin 20 pixels along the x-axis and 30\npixels along the y-axis. The third parameter, <code>z<\/code>, is optional. It sets the\namount to translate along the positive z-axis. For example, calling\n<code>translate(20, 30, 40)<\/code> translates the origin 20 pixels along the x-axis,\n30 pixels along the y-axis, and 40 pixels along the z-axis.<\/p>\n<p>The second way to call <code>translate()<\/code> uses a\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object to set the amount of\ntranslation. For example, calling <code>translate(myVector)<\/code> uses the x-, y-,\nand z-components of <code>myVector<\/code> to set the amount to translate along the x-,\ny-, and z-axes. Doing so is the same as calling\n<code>translate(myVector.x, myVector.y, myVector.z)<\/code>.<\/p>\n<p>By default, transformations accumulate. For example, calling\n<code>translate(10, 0)<\/code> twice has the same effect as calling\n<code>translate(20, 0)<\/code> once. The <a href=\"#\/p5\/push\">push()<\/a> and\n<a href=\"#\/p5\/pop\">pop()<\/a> functions can be used to isolate\ntransformations within distinct drawing groups.<\/p>\n<p>Note: Transformations are reset at the beginning of the draw loop. Calling\n<code>translate(10, 0)<\/code> inside the <a href=\"#\/p5\/draw\">draw()<\/a> function won't\ncause shapes to move continuously.<\/p>\n","itemtype":"method","name":"translate","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw a circle at coordinates (0, 0).\n  circle(0, 0, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'Two circles drawn on a gray background. The blue circle on the right overlaps the red circle at the center.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Draw the red circle.\n  fill('red');\n  circle(0, 0, 40);\n\n  \/\/ Translate the origin to the right.\n  translate(25, 0);\n\n  \/\/ Draw the blue circle.\n  fill('blue');\n  circle(0, 0, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle moves slowly from left to right on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the x-coordinate.\n  let x = frameCount * 0.2;\n\n  \/\/ Translate the origin.\n  translate(x, 50);\n\n  \/\/ Draw a circle at coordinates (0, 0).\n  circle(0, 0, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create a p5.Vector object.\n  let v = createVector(50, 50);\n\n  \/\/ Translate the origin by the vector.\n  translate(v);\n\n  \/\/ Draw a circle at coordinates (0, 0).\n  circle(0, 0, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'Two spheres sitting side-by-side on gray background. The sphere at the center is red. The sphere on the right is blue.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the spheres.\n  noStroke();\n\n  \/\/ Draw the red sphere.\n  fill('red');\n  sphere(10);\n\n  \/\/ Translate the origin to the right.\n  translate(30, 0, 0);\n\n  \/\/ Draw the blue sphere.\n  fill('blue');\n  sphere(10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Transform","submodule":"Transform","overloads":[{"line":1223,"params":[{"name":"x","description":"<p>amount to translate along the positive x-axis.<\/p>\n","type":"Number"},{"name":"y","description":"<p>amount to translate along the positive y-axis.<\/p>\n","type":"Number"},{"name":"z","description":"<p>amount to translate along the positive z-axis.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1394,"params":[{"name":"vector","description":"<p>vector by which to translate.<\/p>\n","type":"p5.Vector"}],"chainable":1}]},{"file":"src\/data\/local_storage.js","line":10,"description":"<p>Stores a value in the web browser's local storage.<\/p>\n<p>Web browsers can save small amounts of data using the built-in\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/localStorage\" target=\"_blank\">localStorage object<\/a>.\nData stored in <code>localStorage<\/code> can be retrieved at any point, even after\nrefreshing a page or restarting the browser. Data are stored as key-value\npairs.<\/p>\n<p><code>storeItem()<\/code> makes it easy to store values in <code>localStorage<\/code> and\n<a href=\"#\/p5\/getItem\">getItem()<\/a> makes it easy to retrieve them.<\/p>\n<p>The first parameter, <code>key<\/code>, is the name of the value to be stored as a\nstring.<\/p>\n<p>The second parameter, <code>value<\/code>, is the value to be stored. Values can have\nany type.<\/p>\n<p>Note: Sensitive data such as passwords or personal information shouldn't be\nstored in <code>localStorage<\/code>.<\/p>\n","itemtype":"method","name":"storeItem","params":[{"name":"key","description":"<p>name of the value.<\/p>\n","type":"String"},{"name":"value","description":"<p>value to be stored.<\/p>\n","type":"String|Number|Boolean|Object|Array"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Store the player's name.\n  storeItem('name', 'Feist');\n\n  \/\/ Store the player's score.\n  storeItem('score', 1234);\n\n  describe('The text \"Feist: 1234\" written in black on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Retrieve the name.\n  let name = getItem('name');\n\n  \/\/ Retrieve the score.\n  let score = getItem('score');\n\n  \/\/ Display the score.\n  text(`${name}: ${score}`, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create an object.\n  let p = { x: 50, y: 50 };\n\n  \/\/ Store the object.\n  storeItem('position', p);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Retrieve the object.\n  let p = getItem('position');\n\n  \/\/ Draw the circle.\n  circle(p.x, p.y, 30);\n}\n<\/code>\n<\/div>\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Color object.\n  let c = color('deeppink');\n\n  \/\/ Store the object.\n  storeItem('color', c);\n\n  describe('A pink circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Retrieve the object.\n  let c = getItem('color');\n\n  \/\/ Style the circle.\n  fill(c);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"LocalStorage"},{"file":"src\/data\/local_storage.js","line":164,"description":"<p>Returns a value in the web browser's local storage.<\/p>\n<p>Web browsers can save small amounts of data using the built-in\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/localStorage\" target=\"_blank\">localStorage object<\/a>.\nData stored in <code>localStorage<\/code> can be retrieved at any point, even after\nrefreshing a page or restarting the browser. Data are stored as key-value\npairs.<\/p>\n<p><a href=\"#\/p5\/storeItem\">storeItem()<\/a> makes it easy to store values in\n<code>localStorage<\/code> and <code>getItem()<\/code> makes it easy to retrieve them.<\/p>\n<p>The first parameter, <code>key<\/code>, is the name of the value to be stored as a\nstring.<\/p>\n<p>The second parameter, <code>value<\/code>, is the value to be retrieved a string. For\nexample, calling <code>getItem('size')<\/code> retrieves the value with the key <code>size<\/code>.<\/p>\n<p>Note: Sensitive data such as passwords or personal information shouldn't be\nstored in <code>localStorage<\/code>.<\/p>\n","itemtype":"method","name":"getItem","params":[{"name":"key","description":"<p>name of the value.<\/p>\n","type":"String"}],"return":{"description":"stored item.","type":"String|Number|Boolean|Object|Array"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Store the player's name.\n  storeItem('name', 'Feist');\n\n  \/\/ Store the player's score.\n  storeItem('score', 1234);\n\n  describe('The text \"Feist: 1234\" written in black on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Retrieve the name.\n  let name = getItem('name');\n\n  \/\/ Retrieve the score.\n  let score = getItem('score');\n\n  \/\/ Display the score.\n  text(`${name}: ${score}`, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create an object.\n  let p = { x: 50, y: 50 };\n\n  \/\/ Store the object.\n  storeItem('position', p);\n\n  describe('A white circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Retrieve the object.\n  let p = getItem('position');\n\n  \/\/ Draw the circle.\n  circle(p.x, p.y, 30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Color object.\n  let c = color('deeppink');\n\n  \/\/ Store the object.\n  storeItem('color', c);\n\n  describe('A pink circle on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Retrieve the object.\n  let c = getItem('color');\n\n  \/\/ Style the circle.\n  fill(c);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"LocalStorage"},{"file":"src\/data\/local_storage.js","line":313,"description":"<p>Removes all items in the web browser's local storage.<\/p>\n<p>Web browsers can save small amounts of data using the built-in\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/localStorage\" target=\"_blank\">localStorage object<\/a>.\nData stored in <code>localStorage<\/code> can be retrieved at any point, even after\nrefreshing a page or restarting the browser. Data are stored as key-value\npairs. Calling <code>clearStorage()<\/code> removes all data from <code>localStorage<\/code>.<\/p>\n<p>Note: Sensitive data such as passwords or personal information shouldn't be\nstored in <code>localStorage<\/code>.<\/p>\n","itemtype":"method","name":"clearStorage","example":["\n<div>\n<code>\n\/\/ Double-click to clear localStorage.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Store the player's name.\n  storeItem('name', 'Feist');\n\n  \/\/ Store the player's score.\n  storeItem('score', 1234);\n\n  describe(\n    'The text \"Feist: 1234\" written in black on a gray background. The text \"null: null\" appears when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Retrieve the name.\n  let name = getItem('name');\n\n  \/\/ Retrieve the score.\n  let score = getItem('score');\n\n  \/\/ Display the score.\n  text(`${name}: ${score}`, 50, 50);\n}\n\n\/\/ Clear localStorage when the user double-clicks.\nfunction doubleClicked() {\n  clearStorage();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"LocalStorage"},{"file":"src\/data\/local_storage.js","line":380,"description":"<p>Removes an item from the web browser's local storage.<\/p>\n<p>Web browsers can save small amounts of data using the built-in\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/localStorage\" target=\"_blank\">localStorage object<\/a>.\nData stored in <code>localStorage<\/code> can be retrieved at any point, even after\nrefreshing a page or restarting the browser. Data are stored as key-value\npairs.<\/p>\n<p><a href=\"#\/p5\/storeItem\">storeItem()<\/a> makes it easy to store values in\n<code>localStorage<\/code> and <code>removeItem()<\/code> makes it easy to delete them.<\/p>\n<p>The parameter, <code>key<\/code>, is the name of the value to remove as a string. For\nexample, calling <code>removeItem('size')<\/code> removes the item with the key <code>size<\/code>.<\/p>\n<p>Note: Sensitive data such as passwords or personal information shouldn't be\nstored in <code>localStorage<\/code>.<\/p>\n","itemtype":"method","name":"removeItem","params":[{"name":"key","description":"<p>name of the value to remove.<\/p>\n","type":"String"}],"example":["\n<div>\n<code>\n\/\/ Double-click to remove an item from localStorage.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Store the player's name.\n  storeItem('name', 'Feist');\n\n  \/\/ Store the player's score.\n  storeItem('score', 1234);\n\n  describe(\n    'The text \"Feist: 1234\" written in black on a gray background. The text \"Feist: null\" appears when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Retrieve the name.\n  let name = getItem('name');\n\n  \/\/ Retrieve the score.\n  let score = getItem('score');\n\n  \/\/ Display the score.\n  text(`${name}: ${score}`, 50, 50);\n}\n\n\/\/ Remove the word from localStorage when the user double-clicks.\nfunction doubleClicked() {\n  removeItem('score');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"LocalStorage"},{"file":"src\/data\/p5.TypedDict.js","line":14,"description":"<p>Creates a new instance of p5.StringDict using the key-value pair\n or the object you provide.<\/p>\n","itemtype":"method","name":"createStringDict","return":{"description":"","type":"p5.StringDict"},"example":["\n <div class=\"norender\">\n <code>\n function setup() {\n   let myDictionary = createStringDict('p5', 'js');\n   print(myDictionary.hasKey('p5')); \/\/ logs true to console\n  let anotherDictionary = createStringDict({ happy: 'coding' });\n   print(anotherDictionary.hasKey('happy')); \/\/ logs true to console\n }\n <\/code><\/div>"],"class":"p5","module":"Data","submodule":"Dictionary","overloads":[{"line":14,"params":[{"name":"key","description":"","type":"String"},{"name":"value","description":"","type":"String"}],"return":{"description":"","type":"p5.StringDict"}},{"line":37,"params":[{"name":"object","description":"<p>object<\/p>\n","type":"Object"}],"return":{"description":"","type":"p5.StringDict"}}]},{"file":"src\/data\/p5.TypedDict.js","line":48,"description":"<p>Creates a new instance of <a href=\"#\/p5.NumberDict\">p5.NumberDict<\/a> using the key-value pair\n or object you provide.<\/p>\n","itemtype":"method","name":"createNumberDict","return":{"description":"","type":"p5.NumberDict"},"example":["\n <div class=\"norender\">\n <code>\n function setup() {\n   let myDictionary = createNumberDict(100, 42);\n   print(myDictionary.hasKey(100)); \/\/ logs true to console\n  let anotherDictionary = createNumberDict({ 200: 84 });\n   print(anotherDictionary.hasKey(200)); \/\/ logs true to console\n }\n <\/code><\/div>"],"class":"p5","module":"Data","submodule":"Dictionary","overloads":[{"line":48,"params":[{"name":"key","description":"","type":"Number"},{"name":"value","description":"","type":"Number"}],"return":{"description":"","type":"p5.NumberDict"}},{"line":71,"params":[{"name":"object","description":"<p>object<\/p>\n","type":"Object"}],"return":{"description":"","type":"p5.NumberDict"}}]},{"file":"src\/data\/p5.TypedDict.js","line":102,"description":"<p>Returns the number of key-value pairs currently stored in the Dictionary.<\/p>\n","itemtype":"method","name":"size","return":{"description":"the number of key-value pairs in the Dictionary","type":"Integer"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict(1, 10);\n  myDictionary.create(2, 20);\n  myDictionary.create(3, 30);\n  print(myDictionary.size()); \/\/ logs 3 to the console\n}\n<\/code><\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":123,"description":"<p>Returns true if the given key exists in the Dictionary,\notherwise returns false.<\/p>\n","itemtype":"method","name":"hasKey","params":[{"name":"key","description":"<p>that you want to look up<\/p>\n","type":"Number|String"}],"return":{"description":"whether that key exists in Dictionary","type":"Boolean"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createStringDict('p5', 'js');\n  print(myDictionary.hasKey('p5')); \/\/ logs true to console\n}\n<\/code><\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":145,"description":"<p>Returns the value stored at the given key.<\/p>\n","itemtype":"method","name":"get","params":[{"name":"the","description":"<p>key you want to access<\/p>\n","type":"Number|String"}],"return":{"description":"the value stored at that key","type":"Number|String"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createStringDict('p5', 'js');\n  let myValue = myDictionary.get('p5');\n  print(myValue === 'js'); \/\/ logs true to console\n}\n<\/code><\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":171,"description":"<p>Updates the value associated with the given key in case it already exists\nin the Dictionary. Otherwise a new key-value pair is added.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"key","description":"","type":"Number|String"},{"name":"value","description":"","type":"Number|String"}],"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createStringDict('p5', 'js');\n  myDictionary.set('p5', 'JS');\n  myDictionary.print(); \/\/ logs \"key: p5 - value: JS\" to console\n}\n<\/code><\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":198,"description":"<p>private helper function to handle the user passing in objects\nduring construction or calls to create()<\/p>\n","class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":209,"description":"<p>Creates a new key-value pair in the Dictionary.<\/p>\n","itemtype":"method","name":"create","example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createStringDict('p5', 'js');\n  myDictionary.create('happy', 'coding');\n  myDictionary.print();\n  \/\/ above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n}\n<\/code><\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary","overloads":[{"line":209,"params":[{"name":"key","description":"","type":"Number|String"},{"name":"value","description":"","type":"Number|String"}]},{"line":227,"params":[{"name":"obj","description":"<p>key\/value pair<\/p>\n","type":"Object"}]}]},{"file":"src\/data\/p5.TypedDict.js","line":245,"description":"<p>Removes all previously stored key-value pairs from the Dictionary.<\/p>\n","itemtype":"method","name":"clear","example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createStringDict('p5', 'js');\n  print(myDictionary.hasKey('p5')); \/\/ prints 'true'\n  myDictionary.clear();\n  print(myDictionary.hasKey('p5')); \/\/ prints 'false'\n}\n<\/code>\n<\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":266,"description":"<p>Removes the key-value pair stored at the given key from the Dictionary.<\/p>\n","itemtype":"method","name":"remove","params":[{"name":"key","description":"<p>for the pair to remove<\/p>\n","type":"Number|String"}],"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createStringDict('p5', 'js');\n  myDictionary.create('happy', 'coding');\n  myDictionary.print();\n  \/\/ above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n  myDictionary.remove('p5');\n  myDictionary.print();\n  \/\/ above logs \"key: happy value: coding\" to console\n}\n<\/code><\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":295,"description":"<p>Logs the set of items currently stored in the Dictionary to the console.<\/p>\n","itemtype":"method","name":"print","example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  let myDictionary = createStringDict('p5', 'js');\n  myDictionary.create('happy', 'coding');\n  myDictionary.print();\n  \/\/ above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n}\n<\/code>\n<\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":319,"description":"<p>Converts the Dictionary into a CSV file for local download.<\/p>\n","itemtype":"method","name":"saveTable","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n  background(200);\n  text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n  if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n    createStringDict({\n      john: 1940,\n      paul: 1942,\n      george: 1943,\n      ringo: 1940\n    }).saveTable('beatles');\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":357,"description":"<p>Converts the Dictionary into a JSON file for local download.<\/p>\n","itemtype":"method","name":"saveJSON","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n  background(200);\n  text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n  if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n    createStringDict({\n      john: 1940,\n      paul: 1942,\n      george: 1943,\n      ringo: 1940\n    }).saveJSON('beatles');\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":388,"description":"<p>private helper function to ensure that the user passed in valid\nvalues for the Dictionary type<\/p>\n","class":"p5.TypedDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":430,"description":"<p>private helper function to ensure that the user passed in valid\nvalues for the Dictionary type<\/p>\n","class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":439,"description":"<p>Add the given number to the value currently stored at the given key.\nThe sum then replaces the value previously stored in the Dictionary.<\/p>\n","itemtype":"method","name":"add","params":[{"name":"Key","description":"<p>for the value you wish to add to<\/p>\n","type":"Number"},{"name":"Number","description":"<p>to add to the value<\/p>\n","type":"Number"}],"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict(2, 5);\n  myDictionary.add(2, 2);\n  print(myDictionary.get(2)); \/\/ logs 7 to console.\n}\n<\/code><\/div>\n"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":466,"description":"<p>Subtract the given number from the value currently stored at the given key.\nThe difference then replaces the value previously stored in the Dictionary.<\/p>\n","itemtype":"method","name":"sub","params":[{"name":"Key","description":"<p>for the value you wish to subtract from<\/p>\n","type":"Number"},{"name":"Number","description":"<p>to subtract from the value<\/p>\n","type":"Number"}],"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict(2, 5);\n  myDictionary.sub(2, 2);\n  print(myDictionary.get(2)); \/\/ logs 3 to console.\n}\n<\/code><\/div>\n"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":489,"description":"<p>Multiply the given number with the value currently stored at the given key.\nThe product then replaces the value previously stored in the Dictionary.<\/p>\n","itemtype":"method","name":"mult","params":[{"name":"Key","description":"<p>for value you wish to multiply<\/p>\n","type":"Number"},{"name":"Amount","description":"<p>to multiply the value by<\/p>\n","type":"Number"}],"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict(2, 4);\n  myDictionary.mult(2, 2);\n  print(myDictionary.get(2)); \/\/ logs 8 to console.\n}\n<\/code><\/div>\n"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":516,"description":"<p>Divide the given number with the value currently stored at the given key.\nThe quotient then replaces the value previously stored in the Dictionary.<\/p>\n","itemtype":"method","name":"div","params":[{"name":"Key","description":"<p>for value you wish to divide<\/p>\n","type":"Number"},{"name":"Amount","description":"<p>to divide the value by<\/p>\n","type":"Number"}],"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict(2, 8);\n  myDictionary.div(2, 2);\n  print(myDictionary.get(2)); \/\/ logs 4 to console.\n}\n<\/code><\/div>\n"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":543,"description":"<p>private helper function for finding lowest or highest value\nthe argument 'flip' is used to flip the comparison arrow\nfrom 'less than' to 'greater than'<\/p>\n","class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":567,"description":"<p>Return the lowest number currently stored in the Dictionary.<\/p>\n","itemtype":"method","name":"minValue","return":{"description":"","type":"Number"},"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });\n  let lowestValue = myDictionary.minValue(); \/\/ value is -10\n  print(lowestValue);\n}\n<\/code><\/div>"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":587,"description":"<p>Return the highest number currently stored in the Dictionary.<\/p>\n","itemtype":"method","name":"maxValue","return":{"description":"","type":"Number"},"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });\n  let highestValue = myDictionary.maxValue(); \/\/ value is 3\n  print(highestValue);\n}\n<\/code><\/div>"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":607,"description":"<p>private helper function for finding lowest or highest key\nthe argument 'flip' is used to flip the comparison arrow\nfrom 'less than' to 'greater than'<\/p>\n","class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":629,"description":"<p>Return the lowest key currently used in the Dictionary.<\/p>\n","itemtype":"method","name":"minKey","return":{"description":"","type":"Number"},"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });\n  let lowestKey = myDictionary.minKey(); \/\/ value is 1.2\n  print(lowestKey);\n}\n<\/code><\/div>"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/data\/p5.TypedDict.js","line":649,"description":"<p>Return the highest key currently used in the Dictionary.<\/p>\n","itemtype":"method","name":"maxKey","return":{"description":"","type":"Number"},"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });\n  let highestKey = myDictionary.maxKey(); \/\/ value is 4\n  print(highestKey);\n}\n<\/code><\/div>"],"class":"p5.NumberDict","module":"Data","submodule":"Dictionary"},{"file":"src\/dom\/dom.js","line":21,"description":"<p>Searches the page for the first element that matches the given\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/Getting_started_with_the_web\/CSS_basics#different_types_of_selectors\" target=\"_blank\">CSS selector string<\/a>.<\/p>\n<p>The selector string can be an ID, class, tag name, or a combination.\n<code>select()<\/code> returns a <a href=\"#\/p5.Element\">p5.Element<\/a> object if it\nfinds a match and <code>null<\/code> if not.<\/p>\n<p>The second parameter, <code>container<\/code>, is optional. It specifies a container to\nsearch within. <code>container<\/code> can be CSS selector string, a\n<a href=\"#\/p5.Element\">p5.Element<\/a> object, or an\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLElement\" target=\"_blank\">HTMLElement<\/a> object.<\/p>\n","itemtype":"method","name":"select","params":[{"name":"selectors","description":"<p>CSS selector string of element to search for.<\/p>\n","type":"String"},{"name":"container","description":"<p>CSS selector string, <a href=\"#\/p5.Element\">p5.Element<\/a>, or\n                                            <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLElement\" target=\"_blank\">HTMLElement<\/a> to search within.<\/p>\n","type":"String|p5.Element|HTMLElement","optional":true}],"return":{"description":"<a href=\"#\/p5.Element\">p5.Element<\/a> containing the element.","type":"p5.Element|null"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n  background(200);\n\n  \/\/ Select the canvas by its tag.\n  let cnv = select('canvas');\n  cnv.style('border', '5px deeppink dashed');\n\n  describe('A gray square with a dashed pink border.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n\n  \/\/ Add a class attribute to the canvas.\n  cnv.class('pinkborder');\n\n  background(200);\n\n  \/\/ Select the canvas by its class.\n  cnv = select('.pinkborder');\n\n  \/\/ Style its border.\n  cnv.style('border', '5px deeppink dashed');\n\n  describe('A gray square with a dashed pink border.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n\n  \/\/ Set the canvas' ID.\n  cnv.id('mycanvas');\n\n  background(200);\n\n  \/\/ Select the canvas by its ID.\n  cnv = select('#mycanvas');\n\n  \/\/ Style its border.\n  cnv.style('border', '5px deeppink dashed');\n\n  describe('A gray square with a dashed pink border.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":109,"description":"<p>Searches the page for all elements that matches the given\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/Getting_started_with_the_web\/CSS_basics#different_types_of_selectors\" target=\"_blank\">CSS selector string<\/a>.<\/p>\n<p>The selector string can be an ID, class, tag name, or a combination.\n<code>selectAll()<\/code> returns an array of <a href=\"#\/p5.Element\">p5.Element<\/a>\nobjects if it finds any matches and an empty array if none are found.<\/p>\n<p>The second parameter, <code>container<\/code>, is optional. It specifies a container to\nsearch within. <code>container<\/code> can be CSS selector string, a\n<a href=\"#\/p5.Element\">p5.Element<\/a> object, or an\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLElement\" target=\"_blank\">HTMLElement<\/a> object.<\/p>\n","itemtype":"method","name":"selectAll","params":[{"name":"selectors","description":"<p>CSS selector string of element to search for.<\/p>\n","type":"String"},{"name":"container","description":"<p>CSS selector string, <a href=\"#\/p5.Element\">p5.Element<\/a>, or\n                                            <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLElement\" target=\"_blank\">HTMLElement<\/a> to search within.<\/p>\n","type":"String|p5.Element|HTMLElement","optional":true}],"return":{"description":"array of <a href=\"#\/p5.Element\">p5.Element<\/a>s containing any elements found.","type":"p5.Element[]"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create three buttons.\n  createButton('1');\n  createButton('2');\n  createButton('3');\n\n  \/\/ Select the buttons by their tag.\n  let buttons = selectAll('button');\n\n  \/\/ Position the buttons.\n  for (let i = 0; i < 3; i += 1) {\n    buttons[i].position(0, i * 30);\n  }\n\n  describe('Three buttons stacked vertically. The buttons are labeled, \"1\", \"2\", and \"3\".');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Create three buttons and position them.\n  let b1 = createButton('1');\n  b1.position(0, 0);\n  let b2 = createButton('2');\n  b2.position(0, 30);\n  let b3 = createButton('3');\n  b3.position(0, 60);\n\n  \/\/ Add a class attribute to each button.\n  b1.class('btn');\n  b2.class('btn btn-pink');\n  b3.class('btn');\n\n  \/\/ Select the buttons by their class.\n  let buttons = selectAll('.btn');\n  let pinkButtons = selectAll('.btn-pink');\n\n  \/\/ Style the selected buttons.\n  buttons.forEach(setFont);\n  pinkButtons.forEach(setColor);\n\n  describe('Three buttons stacked vertically. The buttons are labeled, \"1\", \"2\", and \"3\". Buttons \"1\" and \"3\" are gray. Button \"2\" is pink.');\n}\n\n\/\/ Set a button's font to Comic Sans MS.\nfunction setFont(btn) {\n  btn.style('font-family', 'Comic Sans MS');\n}\n\n\/\/ Set a button's background and font color.\nfunction setColor(btn) {\n  btn.style('background', 'deeppink');\n  btn.style('color', 'white');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":206,"description":"<p>Helper function for select and selectAll<\/p>\n","class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":221,"description":"<p>Helper function for getElement and getElements.<\/p>\n","class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":256,"description":"<p>Removes all elements created by p5.js, including any event handlers.<\/p>\n<p>There are two exceptions:\ncanvas elements created by <a href=\"#\/p5\/createCanvas\">createCanvas()<\/a>\nand <a href=\"#\/p5.Renderer\">p5.Render<\/a> objects created by\n<a href=\"#\/p5\/createGraphics\">createGraphics()<\/a>.<\/p>\n","itemtype":"method","name":"removeElements","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element and place\n  \/\/ it in the middle of the canvas.\n  let p = createP('p5*js');\n  p.position(25, 25);\n\n  describe('A gray square with the text \"p5*js\" written in its center. The text disappears when the mouse is pressed.');\n}\n\n\/\/ Remove all elements when the mouse is pressed.\nfunction mousePressed() {\n  removeElements();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet slider;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a paragraph element and place\n  \/\/ it at the top of the canvas.\n  let p = createP('p5*js');\n  p.position(25, 25);\n\n  \/\/ Create a slider element and place it\n  \/\/ beneath the canvas.\n  slider = createSlider(0, 255, 200);\n  slider.position(0, 100);\n\n  describe('A gray square with the text \"p5*js\" written in its center and a range slider beneath it. The square changes color when the slider is moved. The text and slider disappear when the square is double-clicked.');\n}\n\nfunction draw() {\n  \/\/ Use the slider value to change the background color.\n  let g = slider.value();\n  background(g);\n}\n\n\/\/ Remove all elements when the mouse is double-clicked.\nfunction doubleClicked() {\n  removeElements();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":330,"description":"<p>Calls a function when the element changes.<\/p>\n<p>Calling <code>myElement.changed(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"changed","params":[{"name":"fxn","description":"<p>function to call when the element changes.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nlet dropdown;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a dropdown menu and add a few color options.\n  dropdown = createSelect();\n  dropdown.position(0, 0);\n  dropdown.option('red');\n  dropdown.option('green');\n  dropdown.option('blue');\n\n  \/\/ Call paintBackground() when the color option changes.\n  dropdown.changed(paintBackground);\n\n  describe('A gray square with a dropdown menu at the top. The square changes color when an option is selected.');\n}\n\n\/\/ Paint the background with the selected color.\nfunction paintBackground() {\n  let c = dropdown.value();\n  background(c);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet checkbox;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a checkbox and place it beneath the canvas.\n  checkbox = createCheckbox(' circle');\n  checkbox.position(0, 100);\n\n  \/\/ Call repaint() when the checkbox changes.\n  checkbox.changed(repaint);\n\n  describe('A gray square with a checkbox underneath it that says \"circle\". A white circle appears when the box is checked and disappears otherwise.');\n}\n\n\/\/ Paint the background gray and determine whether to draw a circle.\nfunction repaint() {\n  background(200);\n  if (checkbox.checked() === true) {\n    circle(50, 50, 30);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":405,"description":"<p>Calls a function when the element receives input.<\/p>\n<p><code>myElement.input()<\/code> is often used to with text inputs and sliders. Calling\n<code>myElement.input(false)<\/code> disables the function.<\/p>\n","itemtype":"method","name":"input","params":[{"name":"fxn","description":"<p>function to call when input is detected within\n                               the element.\n                               <code>false<\/code> disables the function.<\/p>\n","type":"Function|Boolean"}],"chainable":1,"example":["\n<div>\n<code>\nlet slider;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a slider and place it beneath the canvas.\n  slider = createSlider(0, 255, 200);\n  slider.position(0, 100);\n\n  \/\/ Call repaint() when the slider changes.\n  slider.input(repaint);\n\n  describe('A gray square with a range slider underneath it. The background changes shades of gray when the slider is moved.');\n}\n\n\/\/ Paint the background using slider's value.\nfunction repaint() {\n  let g = slider.value();\n  background(g);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet input;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an input and place it beneath the canvas.\n  input = createInput('');\n  input.position(0, 100);\n\n  \/\/ Call repaint() when input is detected.\n  input.input(repaint);\n\n  describe('A gray square with a text input bar beneath it. Any text written in the input appears in the middle of the square.');\n}\n\n\/\/ Paint the background gray and display the input's value.\nfunction repaint() {\n  background(200);\n  let msg = input.value();\n  text(msg, 5, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":478,"description":"<p>Helpers for create methods.<\/p>\n","class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":491,"description":"<p>Creates a <code>&lt;div&gt;&lt;\/div&gt;<\/code> element.<\/p>\n<p><code>&lt;div&gt;&lt;\/div&gt;<\/code> elements are commonly used as containers for\nother elements.<\/p>\n<p>The parameter <code>html<\/code> is optional. It accepts a string that sets the\ninner HTML of the new <code>&lt;div&gt;&lt;\/div&gt;<\/code>.<\/p>\n","itemtype":"method","name":"createDiv","params":[{"name":"html","description":"<p>inner HTML for the new <code>&lt;div&gt;&lt;\/div&gt;<\/code> element.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a div element and set its position.\n  let div = createDiv('p5*js');\n  div.position(25, 35);\n\n  describe('A gray square with the text \"p5*js\" written in its center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an h3 element within the div.\n  let div = createDiv('<h3>p5*js<\/h3>');\n  div.position(20, 5);\n\n  describe('A gray square with the text \"p5*js\" written in its center.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":543,"description":"<p>Creates a paragraph element.<\/p>\n<p><code>&lt;p&gt;&lt;\/p&gt;<\/code> elements are commonly used for paragraph-length text.<\/p>\n<p>The parameter <code>html<\/code> is optional. It accepts a string that sets the\ninner HTML of the new <code>&lt;p&gt;&lt;\/p&gt;<\/code>.<\/p>\n","itemtype":"method","name":"createP","params":[{"name":"html","description":"<p>inner HTML for the new <code>&lt;p&gt;&lt;\/p&gt;<\/code> element.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element and set its position.\n  let p = createP('Tell me a story.');\n  p.position(5, 0);\n\n  describe('A gray square displaying the text \"Tell me a story.\" written in black.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":578,"description":"<p>Creates a <code>&lt;span&gt;&lt;\/span&gt;<\/code> element.<\/p>\n<p><code>&lt;span&gt;&lt;\/span&gt;<\/code> elements are commonly used as containers\nfor inline elements. For example, a <code>&lt;span&gt;&lt;\/span&gt;<\/code>\ncan hold part of a sentence that's a\n<span style=\"color: deeppink;\">different<\/span> style.<\/p>\n<p>The parameter <code>html<\/code> is optional. It accepts a string that sets the\ninner HTML of the new <code>&lt;span&gt;&lt;\/span&gt;<\/code>.<\/p>\n","itemtype":"method","name":"createSpan","params":[{"name":"html","description":"<p>inner HTML for the new <code>&lt;span&gt;&lt;\/span&gt;<\/code> element.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a span element and set its position.\n  let span = createSpan('p5*js');\n  span.position(25, 35);\n\n  describe('A gray square with the text \"p5*js\" written in its center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  \/\/ Create a div element as a container.\n  let div = createDiv();\n\n  \/\/ Place the div at the center.\n  div.position(25, 35);\n\n  \/\/ Create a span element.\n  let s1 = createSpan('p5');\n\n  \/\/ Create a second span element.\n  let s2 = createSpan('*');\n\n  \/\/ Set the second span's font color.\n  s2.style('color', 'deeppink');\n\n  \/\/ Create a third span element.\n  let s3 = createSpan('js');\n\n  \/\/ Add all the spans to the container div.\n  s1.parent(div);\n  s2.parent(div);\n  s3.parent(div);\n\n  describe('A gray square with the text \"p5*js\" written in black at its center. The asterisk is pink.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":649,"description":"<p>Creates an <code>&lt;img&gt;<\/code> element that can appear outside of the canvas.<\/p>\n<p>The first parameter, <code>src<\/code>, is a string with the path to the image file.\n<code>src<\/code> should be a relative path, as in <code>'assets\/image.png'<\/code>, or a URL, as\nin <code>'https:\/\/example.com\/image.png'<\/code>.<\/p>\n<p>The second parameter, <code>alt<\/code>, is a string with the\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLImageElement\/alt#usage_notes\" target=\"_blank\">alternate text<\/a>\nfor the image. An empty string <code>''<\/code> can be used for images that aren't displayed.<\/p>\n<p>The third parameter, <code>crossOrigin<\/code>, is optional. It's a string that sets the\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/CORS_settings_attributes\" target=\"_blank\">crossOrigin property<\/a>\nof the image. Use <code>'anonymous'<\/code> or <code>'use-credentials'<\/code> to fetch the image\nwith cross-origin access.<\/p>\n<p>The fourth parameter, <code>callback<\/code>, is also optional. It sets a function to\ncall after the image loads. The new image is passed to the callback\nfunction as a <a href=\"#\/p5.Element\">p5.Element<\/a> object.<\/p>\n","itemtype":"method","name":"createImg","return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  let img = createImg(\n    'https:\/\/p5js.org\/assets\/img\/asterisk-01.png',\n    'The p5.js magenta asterisk.'\n  );\n  img.position(0, -10);\n\n  describe('A gray square with a magenta asterisk in its center.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM","overloads":[{"line":649,"params":[{"name":"src","description":"<p>relative path or URL for the image.<\/p>\n","type":"String"},{"name":"alt","description":"<p>alternate text for the image.<\/p>\n","type":"String"}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"}},{"line":693,"params":[{"name":"src","description":"","type":"String"},{"name":"alt","description":"","type":"String"},{"name":"crossOrigin","description":"<p>crossOrigin property to use when fetching the image.<\/p>\n","type":"String","optional":true},{"name":"successCallback","description":"<p>function to call once the image loads. The new image will be passed\n                                     to the function as a <a href=\"#\/p5.Element\">p5.Element<\/a> object.<\/p>\n","type":"Function","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"}}]},{"file":"src\/dom\/dom.js","line":724,"description":"<p>Creates an <code>&lt;a&gt;&lt;\/a&gt;<\/code> element that links to another web page.<\/p>\n<p>The first parmeter, <code>href<\/code>, is a string that sets the URL of the linked\npage.<\/p>\n<p>The second parameter, <code>html<\/code>, is a string that sets the inner HTML of the\nlink. It's common to use text, images, or buttons as links.<\/p>\n<p>The third parameter, <code>target<\/code>, is optional. It's a string that tells the\nweb browser where to open the link. By default, links open in the current\nbrowser tab. Passing <code>'_blank'<\/code> will cause the link to open in a new\nbrowser tab. MDN describes a few\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/a#target\" target=\"_blank\">other options<\/a>.<\/p>\n","itemtype":"method","name":"createA","params":[{"name":"href","description":"<p>URL of linked page.<\/p>\n","type":"String"},{"name":"html","description":"<p>inner HTML of link element to display.<\/p>\n","type":"String"},{"name":"target","description":"<p>target where the new link should open,\n                            either <code>'_blank'<\/code>, <code>'_self'<\/code>, <code>'_parent'<\/code>, or <code>'_top'<\/code>.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an anchor element that links to p5js.org.\n  let a = createA('https:\/\/p5js.org\/', 'p5*js');\n  a.position(25, 35);\n\n  describe('The text \"p5*js\" written at the center of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background(200);\n\n  \/\/ Create an anchor tag that links to p5js.org.\n  \/\/ Open the link in a new tab.\n  let a = createA('https:\/\/p5js.org\/', 'p5*js', '_blank');\n  a.position(25, 35);\n\n  describe('The text \"p5*js\" written at the center of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":787,"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":789,"description":"<p>Creates a slider <code>&lt;input&gt;&lt;\/input&gt;<\/code> element.<\/p>\n<p>Range sliders are useful for quickly selecting numbers from a given range.<\/p>\n<p>The first two parameters, <code>min<\/code> and <code>max<\/code>, are numbers that set the\nslider's minimum and maximum.<\/p>\n<p>The third parameter, <code>value<\/code>, is optional. It's a number that sets the\nslider's default value.<\/p>\n<p>The fourth parameter, <code>step<\/code>, is also optional. It's a number that sets the\nspacing between each value in the slider's range. Setting <code>step<\/code> to 0\nallows the slider to move smoothly from <code>min<\/code> to <code>max<\/code>.<\/p>\n","itemtype":"method","name":"createSlider","params":[{"name":"min","description":"<p>minimum value of the slider.<\/p>\n","type":"Number"},{"name":"max","description":"<p>maximum value of the slider.<\/p>\n","type":"Number"},{"name":"value","description":"<p>default value of the slider.<\/p>\n","type":"Number","optional":true},{"name":"step","description":"<p>size for each step in the slider's range.<\/p>\n","type":"Number","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nlet slider;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a slider and place it at the top of the canvas.\n  slider = createSlider(0, 255);\n  slider.position(10, 10);\n  slider.size(80);\n\n  describe('A dark gray square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n  \/\/ Use the slider as a grayscale value.\n  let g = slider.value();\n  background(g);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet slider;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a slider and place it at the top of the canvas.\n  \/\/ Set its default value to 0.\n  slider = createSlider(0, 255, 0);\n  slider.position(10, 10);\n  slider.size(80);\n\n  describe('A black square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n  \/\/ Use the slider as a grayscale value.\n  let g = slider.value();\n  background(g);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet slider;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a slider and place it at the top of the canvas.\n  \/\/ Set its default value to 0.\n  \/\/ Set its step size to 50.\n  slider = createSlider(0, 255, 0, 50);\n  slider.position(10, 10);\n  slider.size(80);\n\n  describe('A black square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n  \/\/ Use the slider as a grayscale value.\n  let g = slider.value();\n  background(g);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet slider;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a slider and place it at the top of the canvas.\n  \/\/ Set its default value to 0.\n  \/\/ Set its step size to 0 so that it moves smoothly.\n  slider = createSlider(0, 255, 0, 0);\n  slider.position(10, 10);\n  slider.size(80);\n\n  describe('A black square with a range slider at the top. The square changes color when the slider is moved.');\n}\n\nfunction draw() {\n  \/\/ Use the slider as a grayscale value.\n  let g = slider.value();\n  background(g);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":924,"description":"<p>Creates a <code>&lt;button&gt;&lt;\/button&gt;<\/code> element.<\/p>\n<p>The first parameter, <code>label<\/code>, is a string that sets the label displayed on\nthe button.<\/p>\n<p>The second parameter, <code>value<\/code>, is optional. It's a string that sets the\nbutton's value. See\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/button#value\" target=\"_blank\">MDN<\/a>\nfor more details.<\/p>\n","itemtype":"method","name":"createButton","params":[{"name":"label","description":"<p>label displayed on the button.<\/p>\n","type":"String"},{"name":"value","description":"<p>value of the button.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a button and place it beneath the canvas.\n  let button = createButton('click me');\n  button.position(0, 100);\n\n  \/\/ Call repaint() when the button is pressed.\n  button.mousePressed(repaint);\n\n  describe('A gray square with a button that says \"click me\" beneath it. The square changes color when the button is clicked.');\n}\n\n\/\/ Change the background color.\nfunction repaint() {\n  let g = random(255);\n  background(g);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet button;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a button and set its value to 0.\n  \/\/ Place the button beneath the canvas.\n  button = createButton('click me', 'red');\n  button.position(0, 100);\n\n  \/\/ Call randomColor() when the button is pressed.\n  button.mousePressed(randomColor);\n\n  describe('A red square with a button that says \"click me\" beneath it. The square changes color when the button is clicked.');\n}\n\nfunction draw() {\n  \/\/ Use the button's value to set the background color.\n  let c = button.value();\n  background(c);\n}\n\n\/\/ Set the button's value to a random color.\nfunction randomColor() {\n  let c = random(['red', 'green', 'blue', 'yellow']);\n  button.value(c);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":1008,"description":"<p>Creates a checkbox <code>&lt;input&gt;&lt;\/input&gt;<\/code> element.<\/p>\n<p>Checkboxes extend the <a href=\"#\/p5.Element\">p5.Element<\/a> class with a\n<code>checked()<\/code> method. Calling <code>myBox.checked()<\/code> returns <code>true<\/code> if it the box\nis checked and <code>false<\/code> if not.<\/p>\n<p>The first parameter, <code>label<\/code>, is optional. It's a string that sets the label\nto display next to the checkbox.<\/p>\n<p>The second parameter, <code>value<\/code>, is also optional. It's a boolean that sets the\ncheckbox's value.<\/p>\n","itemtype":"method","name":"createCheckbox","params":[{"name":"label","description":"<p>label displayed after the checkbox.<\/p>\n","type":"String","optional":true},{"name":"value","description":"<p>value of the checkbox. Checked is <code>true<\/code> and unchecked is <code>false<\/code>.<\/p>\n","type":"Boolean","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nlet checkbox;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a checkbox and place it beneath the canvas.\n  checkbox = createCheckbox();\n  checkbox.position(0, 100);\n\n  describe('A black square with a checkbox beneath it. The square turns white when the box is checked.');\n}\n\nfunction draw() {\n  \/\/ Use the checkbox to set the background color.\n  if (checkbox.checked()) {\n    background(255);\n  } else {\n    background(0);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet checkbox;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a checkbox and place it beneath the canvas.\n  \/\/ Label the checkbox \"white\".\n  checkbox = createCheckbox(' white');\n  checkbox.position(0, 100);\n\n  describe('A black square with a checkbox labeled \"white\" beneath it. The square turns white when the box is checked.');\n}\n\nfunction draw() {\n  \/\/ Use the checkbox to set the background color.\n  if (checkbox.checked()) {\n    background(255);\n  } else {\n    background(0);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet checkbox;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a checkbox and place it beneath the canvas.\n  \/\/ Label the checkbox \"white\" and set its value to true.\n  checkbox = createCheckbox(' white', true);\n  checkbox.position(0, 100);\n\n  describe('A white square with a checkbox labeled \"white\" beneath it. The square turns black when the box is unchecked.');\n}\n\nfunction draw() {\n  \/\/ Use the checkbox to set the background color.\n  if (checkbox.checked()) {\n    background(255);\n  } else {\n    background(0);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":1159,"description":"<p>Creates a dropdown menu <code>&lt;select&gt;&lt;\/select&gt;<\/code> element.<\/p>\n<p>The parameter is optional. If <code>true<\/code> is passed, as in\n<code>let mySelect = createSelect(true)<\/code>, then the dropdown will support\nmultiple selections. If an existing <code>&lt;select&gt;&lt;\/select&gt;<\/code> element\nis passed, as in <code>let mySelect = createSelect(otherSelect)<\/code>, the existing\nelement will be wrapped in a new <a href=\"#\/p5.Element\">p5.Element<\/a>\nobject.<\/p>\n<p>Dropdowns extend the <a href=\"#\/p5.Element\">p5.Element<\/a> class with a few\nhelpful methods for managing options:<\/p>\n<ul>\n<li><code>mySelect.option(name, [value])<\/code> adds an option to the menu. The first paremeter, <code>name<\/code>, is a string that sets the option's name and value. The second parameter, <code>value<\/code>, is optional. If provided, it sets the value that corresponds to the key <code>name<\/code>. If an option with <code>name<\/code> already exists, its value is changed to <code>value<\/code>.<\/li>\n<li><code>mySelect.value()<\/code> returns the currently-selected option's value.<\/li>\n<li><code>mySelect.selected()<\/code> returns the currently-selected option.<\/li>\n<li><code>mySelect.selected(option)<\/code> selects the given option by default.<\/li>\n<li><code>mySelect.disable()<\/code> marks the whole dropdown element as disabled.<\/li>\n<li><code>mySelect.disable(option)<\/code> marks a given option as disabled.<\/li>\n<li><code>mySelect.enable()<\/code> marks the whole dropdown element as enabled.<\/li>\n<li><code>mySelect.enable(option)<\/code> marks a given option as enabled.<\/li>\n<\/ul>\n","itemtype":"method","name":"createSelect","return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nlet mySelect;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a dropdown and place it beneath the canvas.\n  mySelect = createSelect();\n  mySelect.position(0, 100);\n\n  \/\/ Add color options.\n  mySelect.option('red');\n  mySelect.option('green');\n  mySelect.option('blue');\n  mySelect.option('yellow');\n\n  \/\/ Set the selected option to \"red\".\n  mySelect.selected('red');\n\n  describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');\n}\n\nfunction draw() {\n  \/\/ Use the selected value to paint the background.\n  let c = mySelect.selected();\n  background(c);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet mySelect;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a dropdown and place it beneath the canvas.\n  mySelect = createSelect();\n  mySelect.position(0, 100);\n\n  \/\/ Add color options.\n  mySelect.option('red');\n  mySelect.option('green');\n  mySelect.option('blue');\n  mySelect.option('yellow');\n\n  \/\/ Set the selected option to \"red\".\n  mySelect.selected('red');\n\n  \/\/ Disable the \"yellow\" option.\n  mySelect.disable('yellow');\n\n  describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');\n}\n\nfunction draw() {\n  \/\/ Use the selected value to paint the background.\n  let c = mySelect.selected();\n  background(c);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet mySelect;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a dropdown and place it beneath the canvas.\n  mySelect = createSelect();\n  mySelect.position(0, 100);\n\n  \/\/ Add color options with names and values.\n  mySelect.option('one', 'red');\n  mySelect.option('two', 'green');\n  mySelect.option('three', 'blue');\n  mySelect.option('four', 'yellow');\n\n  \/\/ Set the selected option to \"one\".\n  mySelect.selected('one');\n\n  describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');\n}\n\nfunction draw() {\n  \/\/ Use the selected value to paint the background.\n  let c = mySelect.selected();\n  background(c);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Hold CTRL to select multiple options on Windows and Linux.\n\/\/ Hold CMD to select multiple options on macOS.\nlet mySelect;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a dropdown and allow multiple selections.\n  \/\/ Place it beneath the canvas.\n  mySelect = createSelect(true);\n  mySelect.position(0, 100);\n\n  \/\/ Add color options.\n  mySelect.option('red');\n  mySelect.option('green');\n  mySelect.option('blue');\n  mySelect.option('yellow');\n\n  describe('A gray square with a dropdown menu beneath it. Colorful circles appear when their color is selected.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Use the selected value(s) to draw circles.\n  let colors = mySelect.selected();\n  for (let i = 0; i < colors.length; i += 1) {\n    \/\/ Calculate the x-coordinate.\n    let x = 10 + i * 20;\n\n    \/\/ Access the color.\n    let c = colors[i];\n\n    \/\/ Draw the circle.\n    fill(c);\n    circle(x, 50, 20);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM","overloads":[{"line":1159,"params":[{"name":"multiple","description":"<p>support multiple selections.<\/p>\n","type":"Boolean","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"}},{"line":1324,"params":[{"name":"existing","description":"<p>select element to wrap, either as a <a href=\"#\/p5.Element\">p5.Element<\/a> or\n                         a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLSelectElement\" target=\"_blank\">HTMLSelectElement<\/a>.<\/p>\n","type":"Object"}],"return":{"description":"","type":"p5.Element"}}]},{"file":"src\/dom\/dom.js","line":1440,"description":"<p>Creates a radio button element.<\/p>\n<p>The parameter is optional. If a string is passed, as in\n<code>let myRadio = createSelect('food')<\/code>, then each radio option will\nhave <code>\"food\"<\/code> as its <code>name<\/code> parameter: <code>&lt;input name=\"food\"&gt;<\/code>.\nIf an existing <code>&lt;div&gt;&lt;\/div&gt;<\/code> or <code>&lt;span&gt;&lt;\/span&gt;<\/code>\nelement is passed, as in <code>let myRadio = createSelect(container)<\/code>, it will\nbecome the radio button's parent element.<\/p>\n<p>Radio buttons extend the <a href=\"#\/p5.Element\">p5.Element<\/a> class with a few\nhelpful methods for managing options:<\/p>\n<ul>\n<li><code>myRadio.option(value, [label])<\/code> adds an option to the menu. The first parameter, <code>value<\/code>, is a string that sets the option's value and label. The second parameter, <code>label<\/code>, is optional. If provided, it sets the label displayed for the <code>value<\/code>. If an option with <code>value<\/code> already exists, its label is changed and its value is returned.<\/li>\n<li><code>myRadio.value()<\/code> returns the currently-selected option's value.<\/li>\n<li><code>myRadio.selected()<\/code> returns the currently-selected option.<\/li>\n<li><code>myRadio.selected(value)<\/code> selects the given option and returns it as an <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLInputElement\" target=\"_blank\"><code>HTMLInputElement<\/code><\/a>.<\/li>\n<li><code>myRadio.disable(shouldDisable)<\/code> Disables the radio button if <code>true<\/code> is passed, and enables it if <code>false<\/code> is passed.<\/li>\n<\/ul>\n","itemtype":"method","name":"createRadio","return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nlet style = document.createElement('style');\nstyle.innerHTML = `\n.p5-radio label {\n   display: flex;\n   align-items: center;\n }\n .p5-radio input {\n   margin-right: 5px;\n }\n `;\ndocument.head.appendChild(style);\n\nlet myRadio;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a radio button element and place it\n  \/\/ in the top-left corner.\n  myRadio = createRadio();\n  myRadio.position(0, 0);\n  myRadio.class('p5-radio');\n  myRadio.size(60);\n\n  \/\/ Add a few color options.\n  myRadio.option('red');\n  myRadio.option('yellow');\n  myRadio.option('blue');\n\n  \/\/ Choose a default option.\n  myRadio.selected('yellow');\n\n  describe('A yellow square with three color options listed, \"red\", \"yellow\", and \"blue\". The square changes color when the user selects a new option.');\n}\n\nfunction draw() {\n  \/\/ Set the background color using the radio button.\n  let g = myRadio.value();\n  background(g);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myRadio;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a radio button element and place it\n  \/\/ in the top-left corner.\n  myRadio = createRadio();\n  myRadio.position(0, 0);\n  myRadio.size(50);\n\n  \/\/ Add a few color options.\n  \/\/ Color values are labeled with\n  \/\/ emotions they evoke.\n  myRadio.option('red', 'love');\n  myRadio.option('yellow', 'joy');\n  myRadio.option('blue', 'trust');\n\n  \/\/ Choose a default option.\n  myRadio.selected('yellow');\n\n  describe('A yellow square with three options listed, \"love\", \"joy\", and \"trust\". The square changes color when the user selects a new option.');\n}\n\nfunction draw() {\n  \/\/ Set the background color using the radio button.\n  let c = myRadio.value();\n  background(c);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myRadio;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a radio button element and place it\n  \/\/ in the top-left corner.\n  myRadio = createRadio();\n  myRadio.position(0, 0);\n  myRadio.class('p5-radio');\n  myRadio.size(50);\n\n  \/\/ Add a few color options.\n  myRadio.option('red');\n  myRadio.option('yellow');\n  myRadio.option('blue');\n\n  \/\/ Choose a default option.\n  myRadio.selected('yellow');\n\n  \/\/ Create a button and place it beneath the canvas.\n  let btn = createButton('disable');\n  btn.position(0, 100);\n\n  \/\/ Call disableRadio() when btn is pressed.\n  btn.mousePressed(disableRadio);\n\n  describe('A yellow square with three options listed, \"red\", \"yellow\", and \"blue\". The square changes color when the user selects a new option. A \"disable\" button beneath the canvas disables the color options when pressed.');\n}\n\nfunction draw() {\n  \/\/ Set the background color using the radio button.\n  let c = myRadio.value();\n  background(c);\n}\n\n\/\/ Disable myRadio.\nfunction disableRadio() {\n  myRadio.disable(true);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM","overloads":[{"line":1440,"params":[{"name":"containerElement","description":"<p>container HTML Element, either a <code>&lt;div&gt;&lt;\/div&gt;<\/code>\nor <code>&lt;span&gt;&lt;\/span&gt;<\/code>.<\/p>\n","type":"Object","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"}},{"line":1588,"params":[{"name":"name","description":"<p>name parameter assigned to each option's <code>&lt;input&gt;&lt;\/input&gt;<\/code> element.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"}},{"line":1593,"params":[],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"}}]},{"file":"src\/dom\/dom.js","line":1759,"description":"<p>Creates a color picker element.<\/p>\n<p>The parameter, <code>value<\/code>, is optional. If a color string or\n<a href=\"#\/p5.Color\">p5.Color<\/a> object is passed, it will set the default\ncolor.<\/p>\n<p>Color pickers extend the <a href=\"#\/p5.Element\">p5.Element<\/a> class with a\ncouple of helpful methods for managing colors:<\/p>\n<ul>\n<li><code>myPicker.value()<\/code> returns the current color as a hex string in the format <code>'#rrggbb'<\/code>.<\/li>\n<li><code>myPicker.color()<\/code> returns the current color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object.<\/li>\n<\/ul>\n","itemtype":"method","name":"createColorPicker","params":[{"name":"value","description":"<p>default color as a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/color\" target=\"_blank\">CSS color string<\/a>.<\/p>\n","type":"String|p5.Color","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nlet myPicker;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a color picker and set its position.\n  myPicker = createColorPicker('deeppink');\n  myPicker.position(0, 100);\n\n  describe('A pink square with a color picker beneath it. The square changes color when the user picks a new color.');\n}\n\nfunction draw() {\n  \/\/ Use the color picker to paint the background.\n  let c = myPicker.color();\n  background(c);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myPicker;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a color picker and set its position.\n  myPicker = createColorPicker('deeppink');\n  myPicker.position(0, 100);\n\n  describe('A number with the format \"#rrggbb\" is displayed on a pink canvas. The background color and number change when the user picks a new color.');\n}\n\nfunction draw() {\n  \/\/ Use the color picker to paint the background.\n  let c = myPicker.value();\n  background(c);\n\n  \/\/ Display the current color as a hex string.\n  text(c, 25, 55);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":1859,"description":"<p>Creates a text <code>&lt;input&gt;&lt;\/input&gt;<\/code> element.<\/p>\n<p>Call <code>myInput.size()<\/code> to set the length of the text box.<\/p>\n<p>The first parameter, <code>value<\/code>, is optional. It's a string that sets the\ninput's default value. The input is blank by default.<\/p>\n<p>The second parameter, <code>type<\/code>, is also optional. It's a string that\nspecifies the type of text being input. See MDN for a full\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/Input\" target=\"_blank\">list of options<\/a>.\nThe default is <code>'text'<\/code>.<\/p>\n","itemtype":"method","name":"createInput","return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nlet myInput;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create an input element and place it\n  \/\/ beneath the canvas.\n  myInput = createInput();\n  myInput.position(0, 100);\n\n  describe('A gray square with a text box beneath it. The text in the square changes when the user types something new in the input bar.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Use the input to display a message.\n  let msg = myInput.value();\n  text(msg, 25, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myInput;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create an input element and place it\n  \/\/ beneath the canvas. Set its default\n  \/\/ text to \"hello!\".\n  myInput = createInput('hello!');\n  myInput.position(0, 100);\n\n  describe('The text \"hello!\" written at the center of a gray square. A text box beneath the square also says \"hello!\". The text in the square changes when the user types something new in the input bar.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Use the input to display a message.\n  let msg = myInput.value();\n  text(msg, 25, 55);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM","overloads":[{"line":1859,"params":[{"name":"value","description":"<p>default value of the input box. Defaults to an empty string <code>''<\/code>.<\/p>\n","type":"String","optional":true},{"name":"type","description":"<p>type of input. Defaults to <code>'text'<\/code>.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"}},{"line":1929,"params":[{"name":"value","description":"","type":"String","optional":true}],"return":{"description":"","type":"p5.Element"}}]},{"file":"src\/dom\/dom.js","line":1942,"description":"<p>Creates an <code>&lt;input&gt;&lt;\/input&gt;<\/code> element of type <code>'file'<\/code>.<\/p>\n<p><code>createFileInput()<\/code> allows users to select local files for use in a sketch.\nIt returns a <a href=\"#\/p5.File\">p5.File<\/a> object.<\/p>\n<p>The first parameter, <code>callback<\/code>, is a function that's called when the file\nloads. The callback function should have one parameter, <code>file<\/code>, that's a\n<a href=\"#\/p5.File\">p5.File<\/a> object.<\/p>\n<p>The second parameter, <code>multiple<\/code>, is optional. It's a boolean value that\nallows loading multiple files if set to <code>true<\/code>. If <code>true<\/code>, <code>callback<\/code>\nwill be called once per file.<\/p>\n","itemtype":"method","name":"createFileInput","params":[{"name":"callback","description":"<p>function to call once the file loads.<\/p>\n","type":"Function"},{"name":"multiple","description":"<p>allow multiple files to be selected.<\/p>\n","type":"Boolean","optional":true}],"return":{"description":"new <a href=\"#\/p5.File\">p5.File<\/a> object.","type":"p5.File"},"example":["\n<div>\n<code>\n\/\/ Use the file input to select an image to\n\/\/ load and display.\nlet input;\nlet img;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a file input and place it beneath\n  \/\/ the canvas.\n  input = createFileInput(handleImage);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the image if loaded.\n  if (img) {\n    image(img, 0, 0, width, height);\n  }\n}\n\n\/\/ Create an image if the file is an image.\nfunction handleImage(file) {\n  if (file.type === 'image') {\n    img = createImg(file.data, '');\n    img.hide();\n  } else {\n    img = null;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Use the file input to select multiple images\n\/\/ to load and display.\nlet input;\nlet images = [];\n\nfunction setup() {\n  \/\/ Create a file input and place it beneath\n  \/\/ the canvas. Allow it to load multiple files.\n  input = createFileInput(handleImage, true);\n  input.position(0, 100);\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the images if loaded. Each image\n  \/\/ is drawn 20 pixels lower than the\n  \/\/ previous image.\n  for (let i = 0; i < images.length; i += 1) {\n    \/\/ Calculate the y-coordinate.\n    let y = i * 20;\n\n    \/\/ Draw the image.\n    image(images[i], 0, y, 100, 100);\n  }\n\n  describe('A gray square with a file input beneath it. If the user selects multiple image files to load, they are displayed on the square.');\n}\n\n\/\/ Create an image if the file is an image,\n\/\/ then add it to the images array.\nfunction handleImage(file) {\n  if (file.type === 'image') {\n    let img = createImg(file.data, '');\n    img.hide();\n    images.push(img);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2068,"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2115,"description":"<p>Creates a <code>&lt;video&gt;<\/code> element for simple audio\/video playback.<\/p>\n<p><code>createVideo()<\/code> returns a new\n<a href=\"#\/p5.MediaElement\">p5.MediaElement<\/a> object. Videos are shown by\ndefault. They can be hidden by calling <code>video.hide()<\/code> and drawn to the\ncanvas using <a href=\"#\/p5\/image\">image()<\/a>.<\/p>\n<p>The first parameter, <code>src<\/code>, is the path the video. If a single string is\npassed, as in <code>'assets\/topsecret.mp4'<\/code>, a single video is loaded. An array\nof strings can be used to load the same video in different formats. For\nexample, <code>['assets\/topsecret.mp4', 'assets\/topsecret.ogv', 'assets\/topsecret.webm']<\/code>.\nThis is useful for ensuring that the video can play across different browsers with\ndifferent capabilities. See\n<a href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Supported_media_formats'>MDN<\/a>\nfor more information about supported formats.<\/p>\n<p>The second parameter, <code>callback<\/code>, is optional. It's a function to call once\nthe video is ready to play.<\/p>\n","itemtype":"method","name":"createVideo","params":[{"name":"src","description":"<p>path to a video file, or an array of paths for\n                              supporting different browsers.<\/p>\n","type":"String|String[]"},{"name":"callback","description":"<p>function to call once the video is ready to play.<\/p>\n","type":"Function","optional":true}],"return":{"description":"new <a href=\"#\/p5.MediaElement\">p5.MediaElement<\/a> object.","type":"p5.MediaElement"},"example":["\n<div class='notest'>\n<code>\nfunction setup() {\n  noCanvas();\n\n  \/\/ Load a video and add it to the page.\n  \/\/ Note: this may not work in some browsers.\n  let video = createVideo('assets\/small.mp4');\n\n  \/\/ Show the default video controls.\n  video.showControls();\n\n  describe('A video of a toy robot with playback controls beneath it.');\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\nfunction setup() {\n  noCanvas();\n\n  \/\/ Load a video and add it to the page.\n  \/\/ Provide an array options for different file formats.\n  let video = createVideo(\n    ['assets\/small.mp4', 'assets\/small.ogv', 'assets\/small.webm']\n  );\n\n  \/\/ Show the default video controls.\n  video.showControls();\n\n  describe('A video of a toy robot with playback controls beneath it.');\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\nlet video;\n\nfunction setup() {\n  noCanvas();\n\n  \/\/ Load a video and add it to the page.\n  \/\/ Provide an array options for different file formats.\n  \/\/ Call mute() once the video loads.\n  video = createVideo(\n    ['assets\/small.mp4', 'assets\/small.ogv', 'assets\/small.webm'],\n    muteVideo\n  );\n\n  \/\/ Show the default video controls.\n  video.showControls();\n\n  describe('A video of a toy robot with playback controls beneath it.');\n}\n\n\/\/ Mute the video once it loads.\nfunction muteVideo() {\n  video.volume(0);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2211,"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2213,"description":"<p>Creates a hidden <code>&lt;audio&gt;<\/code> element for simple audio playback.<\/p>\n<p><code>createAudio()<\/code> returns a new\n<a href=\"#\/p5.MediaElement\">p5.MediaElement<\/a> object.<\/p>\n<p>The first parameter, <code>src<\/code>, is the path the video. If a single string is\npassed, as in <code>'assets\/video.mp4'<\/code>, a single video is loaded. An array\nof strings can be used to load the same video in different formats. For\nexample, <code>['assets\/video.mp4', 'assets\/video.ogv', 'assets\/video.webm']<\/code>.\nThis is useful for ensuring that the video can play across different\nbrowsers with different capabilities. See\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Supported_media_formats\" target=\"_blank\">MDN<\/a>\nfor more information about supported formats.<\/p>\n<p>The second parameter, <code>callback<\/code>, is optional. It's a function to call once\nthe audio is ready to play.<\/p>\n","itemtype":"method","name":"createAudio","params":[{"name":"src","description":"<p>path to an audio file, or an array of paths\n                                for supporting different browsers.<\/p>\n","type":"String|String[]","optional":true},{"name":"callback","description":"<p>function to call once the audio is ready to play.<\/p>\n","type":"Function","optional":true}],"return":{"description":"new <a href=\"#\/p5.MediaElement\">p5.MediaElement<\/a> object.","type":"p5.MediaElement"},"example":["\n<div class='notest'>\n<code>\nfunction setup() {\n  noCanvas();\n\n  \/\/ Load the audio.\n  let beat = createAudio('assets\/beat.mp3');\n\n  \/\/ Show the default audio controls.\n  beat.showControls();\n\n  describe('An audio beat plays when the user double-clicks the square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2259,"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2295,"description":"<p>Creates a <code>&lt;video&gt;<\/code> element that \"captures\" the audio\/video stream from\nthe webcam and microphone.<\/p>\n<p><code>createCapture()<\/code> returns a new\n<a href=\"#\/p5.MediaElement\">p5.MediaElement<\/a> object. Videos are shown by\ndefault. They can be hidden by calling <code>capture.hide()<\/code> and drawn to the\ncanvas using <a href=\"#\/p5\/image\">image()<\/a>.<\/p>\n<p>The first parameter, <code>type<\/code>, is optional. It sets the type of capture to\nuse. By default, <code>createCapture()<\/code> captures both audio and video. If <code>VIDEO<\/code>\nis passed, as in <code>createCapture(VIDEO)<\/code>, only video will be captured.\nIf <code>AUDIO<\/code> is passed, as in <code>createCapture(AUDIO)<\/code>, only audio will be\ncaptured. A constraints object can also be passed to customize the stream.\nSee the <a href=\"http:\/\/w3c.github.io\/mediacapture-main\/getusermedia.html#media-track-constraints\" target=\"_blank\">\nW3C documentation<\/a> for possible properties. Different browsers support different\nproperties.<\/p>\n<p>The 'flipped' property is an optional property which can be set to <code>{flipped:true}<\/code>\nto mirror the video output.If it is true then it means that video will be mirrored\nor flipped and if nothing is mentioned then by default it will be <code>false<\/code>.<\/p>\n<p>The second parameter,<code>callback<\/code>, is optional. It's a function to call once\nthe capture is ready for use. The callback function should have one\nparameter, <code>stream<\/code>, that's a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStream\" target=\"_blank\">MediaStream<\/a> object.<\/p>\n<p>Note: <code>createCapture()<\/code> only works when running a sketch locally or using HTTPS. Learn more\n<a href=\"http:\/\/stackoverflow.com\/questions\/34197653\/getusermedia-in-chrome-47-without-using-https\" target=\"_blank\">here<\/a>\nand <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaDevices\/getUserMedia\" target=\"_blank\">here<\/a>.<\/p>\n","itemtype":"method","name":"createCapture","params":[{"name":"type","description":"<p>type of capture, either AUDIO or VIDEO,\n                                  or a constraints object. Both video and audio\n                                  audio streams are captured by default.<\/p>\n","type":"String|Constant|Object","optional":true},{"name":"flipped","description":"<p>flip the capturing video and mirror the output with <code>{flipped:true}<\/code>. By\n                                  default it is false.<\/p>\n","type":"Object","optional":true},{"name":"callback","description":"<p>function to call once the stream\n                                  has loaded.<\/p>\n","type":"Function","optional":true}],"return":{"description":"new <a href=\"#\/p5.MediaElement\">p5.MediaElement<\/a> object.","type":"p5.MediaElement"},"example":["\n<div class='notest'>\n<code>\nfunction setup() {\n  noCanvas();\n\n  \/\/ Create the video capture.\n  createCapture(VIDEO);\n\n  describe('A video stream from the webcam.');\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\nlet capture;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create the video capture and hide the element.\n  capture = createCapture(VIDEO);\n  capture.hide();\n\n  describe('A video stream from the webcam with inverted colors.');\n}\n\nfunction draw() {\n  \/\/ Draw the video capture within the canvas.\n  image(capture, 0, 0, width, width * capture.height \/ capture.width);\n\n  \/\/ Invert the colors in the stream.\n  filter(INVERT);\n}\n<\/code>\n<\/div>\n<div class='notest'>\n<code>\nlet capture;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create the video capture with mirrored output.\n  capture = createCapture(VIDEO,{ flipped:true });\n  capture.size(100,100);\n\n  describe('A video stream from the webcam with flipped or mirrored output.');\n}\n\n<\/code>\n<\/div>\n\n<div class='notest norender'>\n<code>\nfunction setup() {\n  createCanvas(480, 120);\n\n  \/\/ Create a constraints object.\n  let constraints = {\n    video: {\n      mandatory: {\n        minWidth: 1280,\n        minHeight: 720\n      },\n      optional: [{ maxFrameRate: 10 }]\n    },\n    audio: false\n  };\n\n  \/\/ Create the video capture.\n  createCapture(constraints);\n\n  describe('A video stream from the webcam.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2493,"description":"<p>Creates a new <a href=\"#\/p5.Element\">p5.Element<\/a> object.<\/p>\n<p>The first parameter, <code>tag<\/code>, is a string an HTML tag such as <code>'h5'<\/code>.<\/p>\n<p>The second parameter, <code>content<\/code>, is optional. It's a string that sets the\nHTML content to insert into the new element. New elements have no content\nby default.<\/p>\n","itemtype":"method","name":"createElement","params":[{"name":"tag","description":"<p>tag for the new element.<\/p>\n","type":"String"},{"name":"content","description":"<p>HTML content to insert into the element.<\/p>\n","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Element\">p5.Element<\/a> object.","type":"p5.Element"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an h5 element with nothing in it.\n  createElement('h5');\n\n  describe('A gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an h5 element with the content \"p5*js\".\n  let h5 = createElement('h5', 'p5*js');\n\n  \/\/ Set the element's style and position.\n  h5.style('color', 'deeppink');\n  h5.position(30, 15);\n\n  describe('The text \"p5*js\" written in pink in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2554,"description":"<p>Adds a class to the element.<\/p>\n","itemtype":"method","name":"addClass","params":[{"name":"class","description":"<p>name of class to add.<\/p>\n","type":"String"}],"chainable":1,"example":["\n <div class='norender'>\n <code>\n function setup() {\n   createCanvas(100, 100);\n  background(200);\n  \/\/ Create a div element.\n   let div = createDiv('div');\n  \/\/ Add a class to the div.\n   div.addClass('myClass');\n  describe('A gray square.');\n }\n <\/code>\n <\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2593,"description":"<p>Removes a class from the element.<\/p>\n","itemtype":"method","name":"removeClass","params":[{"name":"class","description":"<p>name of class to remove.<\/p>\n","type":"String"}],"chainable":1,"example":["\n<div class='norender'>\n<code>\n\/\/ In this example, a class is set when the div is created\n\/\/ and removed when mouse is pressed. This could link up\n\/\/ with a CSS style rule to toggle style properties.\n\nlet div;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a div element.\n  div = createDiv('div');\n\n  \/\/ Add a class to the div.\n  div.addClass('myClass');\n\n  describe('A gray square.');\n}\n\n\/\/ Remove 'myClass' from the div when the user presses the mouse.\nfunction mousePressed() {\n  div.removeClass('myClass');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2636,"description":"<p>Checks if a class is already applied to element.<\/p>\n","itemtype":"method","name":"hasClass","return":{"description":"a boolean value if element has specified class.","type":"Boolean"},"params":[{"name":"c","description":"<p>name of class to check.<\/p>\n","type":"String"}],"example":["\n<div class='norender'>\n<code>\nlet div;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a div element.\n  div = createDiv('div');\n\n  \/\/ Add the class 'show' to the div.\n  div.addClass('show');\n\n  describe('A gray square.');\n}\n\n\/\/ Toggle the class 'show' when the mouse is pressed.\nfunction mousePressed() {\n  if (div.hasClass('show')) {\n    div.addClass('show');\n  } else {\n    div.removeClass('show');\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2677,"description":"<p>Toggles whether a class is applied to the element.<\/p>\n","itemtype":"method","name":"toggleClass","params":[{"name":"c","description":"<p>class name to toggle.<\/p>\n","type":"String"}],"chainable":1,"example":["\n<div class='norender'>\n<code>\nlet div;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a div element.\n  div = createDiv('div');\n\n  \/\/ Add the 'show' class to the div.\n  div.addClass('show');\n\n  describe('A gray square.');\n}\n\n\/\/ Toggle the 'show' class when the mouse is pressed.\nfunction mousePressed() {\n  div.toggleClass('show');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2722,"description":"<p>Attaches the element as a child of another element.<\/p>\n<p><code>myElement.child()<\/code> accepts either a string ID, DOM node, or\n<a href=\"#\/p5.Element\">p5.Element<\/a>. For example,\n<code>myElement.child(otherElement)<\/code>. If no argument is provided, an array of\nchildren DOM nodes is returned.<\/p>\n","itemtype":"method","name":"child","return":{"description":"an array of child nodes.","type":"Node[]"},"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create the div elements.\n  let div0 = createDiv('Parent');\n  let div1 = createDiv('Child');\n\n  \/\/ Make div1 the child of div0\n  \/\/ using the p5.Element.\n  div0.child(div1);\n\n  describe('A gray square with the words \"Parent\" and \"Child\" written beneath it.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create the div elements.\n  let div0 = createDiv('Parent');\n  let div1 = createDiv('Child');\n\n  \/\/ Give div1 an ID.\n  div1.id('apples');\n\n  \/\/ Make div1 the child of div0\n  \/\/ using its ID.\n  div0.child('apples');\n\n  describe('A gray square with the words \"Parent\" and \"Child\" written beneath it.');\n}\n<\/code>\n<\/div>\n\n<div class='norender notest'>\n<code>\n\/\/ This example assumes there is a div already on the page\n\/\/ with id \"myChildDiv\".\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create the div elements.\n  let div0 = createDiv('Parent');\n\n  \/\/ Select the child element by its ID.\n  let elt = document.getElementById('myChildDiv');\n\n  \/\/ Make div1 the child of div0\n  \/\/ using its HTMLElement object.\n  div0.child(elt);\n\n  describe('A gray square with the words \"Parent\" and \"Child\" written beneath it.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":2722,"params":[],"return":{"description":"an array of child nodes.","type":"Node[]"}},{"line":2802,"params":[{"name":"child","description":"<p>the ID, DOM node, or <a href=\"#\/p5.Element\">p5.Element<\/a>\n                        to add to the current element<\/p>\n","type":"String|p5.Element","optional":true}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":2827,"description":"<p>Centers the element either vertically, horizontally, or both.<\/p>\n<p><code>center()<\/code> will center the element relative to its parent or according to\nthe page's body if the element has no parent.<\/p>\n<p>If no argument is passed, as in <code>myElement.center()<\/code> the element is aligned\nboth vertically and horizontally.<\/p>\n","itemtype":"method","name":"center","params":[{"name":"align","description":"<p>passing 'vertical', 'horizontal' aligns element accordingly<\/p>\n","type":"String","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create the div element and style it.\n  let div = createDiv('');\n  div.size(10, 10);\n  div.style('background-color', 'orange');\n\n  \/\/ Center the div relative to the page's body.\n  div.center();\n\n  describe('A gray square and an orange rectangle. The rectangle is at the center of the page.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":2893,"description":"<p>Sets the inner HTML of the element, replacing any existing HTML.<\/p>\n<p>The second parameter, <code>append<\/code>, is optional. If <code>true<\/code> is passed, as in\n<code>myElement.html('hi', true)<\/code>, the HTML is appended instead of replacing\nexisting HTML.<\/p>\n<p>If no arguments are passed, as in <code>myElement.html()<\/code>, the element's inner\nHTML is returned.<\/p>\n","itemtype":"method","name":"html","return":{"description":"the inner HTML of the element","type":"String"},"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create the div element and set its size.\n  let div = createDiv('');\n  div.size(100, 100);\n\n  \/\/ Set the inner HTML to \"hi\".\n  div.html('hi');\n\n  describe('A gray square with the word \"hi\" written beneath it.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create the div element and set its size.\n  let div = createDiv('Hello ');\n  div.size(100, 100);\n\n  \/\/ Append \"World\" to the div's HTML.\n  div.html('World', true);\n\n  describe('A gray square with the text \"Hello World\" written beneath it.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create the div element.\n  let div = createDiv('Hello');\n\n  \/\/ Prints \"Hello\" to the console.\n  print(div.html());\n\n  describe('A gray square with the word \"Hello!\" written beneath it.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":2893,"params":[],"return":{"description":"the inner HTML of the element","type":"String"}},{"line":2962,"params":[{"name":"html","description":"<p>the HTML to be placed inside the element<\/p>\n","type":"String","optional":true},{"name":"append","description":"<p>whether to append HTML to existing<\/p>\n","type":"Boolean","optional":true}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":2980,"description":"<p>Sets the element's position.<\/p>\n<p>The first two parameters, <code>x<\/code> and <code>y<\/code>, set the element's position relative\nto the top-left corner of the web page.<\/p>\n<p>The third parameter, <code>positionType<\/code>, is optional. It sets the element's\n<a target=\"_blank\"\nhref=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/position\">positioning scheme<\/a>.\n<code>positionType<\/code> is a string that can be either <code>'static'<\/code>, <code>'fixed'<\/code>,\n<code>'relative'<\/code>, <code>'sticky'<\/code>, <code>'initial'<\/code>, or <code>'inherit'<\/code>.<\/p>\n<p>If no arguments passed, as in <code>myElement.position()<\/code>, the method returns\nthe element's position in an object, as in <code>{ x: 0, y: 0 }<\/code>.<\/p>\n","itemtype":"method","name":"position","return":{"description":"object of form `{ x: 0, y: 0 }` containing the element's position.","type":"Object"},"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Positions the canvas 50px to the right and 100px\n  \/\/ below the top-left corner of the window.\n  cnv.position(50, 100);\n\n  describe('A gray square that is 50 pixels to the right and 100 pixels down from the top-left corner of the web page.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Positions the canvas at the top-left corner\n  \/\/ of the window with a 'fixed' position type.\n  cnv.position(0, 0, 'fixed');\n\n  describe('A gray square in the top-left corner of the web page.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":2980,"params":[],"return":{"description":"object of form `{ x: 0, y: 0 }` containing the element's position.","type":"Object"}},{"line":3031,"params":[{"name":"x","description":"<p>x-position relative to top-left of window (optional)<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y-position relative to top-left of window (optional)<\/p>\n","type":"Number","optional":true},{"name":"positionType","description":"<p>it can be static, fixed, relative, sticky, initial or inherit (optional)<\/p>\n","type":"String","optional":true}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":3118,"description":"<p>Applies a style to the element by adding a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/Syntax\" target=\"_blank\">CSS declaration<\/a>.<\/p>\n<p>The first parameter, <code>property<\/code>, is a string. If the name of a style\nproperty is passed, as in <code>myElement.style('color')<\/code>, the method returns\nthe current value as a string or <code>null<\/code> if it hasn't been set. If a\n<code>property:style<\/code> string is passed, as in\n<code>myElement.style('color:deeppink')<\/code>, the method sets the style <code>property<\/code>\nto <code>value<\/code>.<\/p>\n<p>The second parameter, <code>value<\/code>, is optional. It sets the property's value.\n<code>value<\/code> can be a string, as in\n<code>myElement.style('color', 'deeppink')<\/code>, or a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, as in\n<code>myElement.style('color', myColor)<\/code>.<\/p>\n","itemtype":"method","name":"style","return":{"description":"value of the property.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element and set its font color to \"deeppink\".\n  let p = createP('p5*js');\n  p.position(25, 20);\n  p.style('color', 'deeppink');\n\n  describe('The text p5*js written in pink on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let c = color('deeppink');\n\n  \/\/ Create a paragraph element and set its font color using a p5.Color object.\n  let p = createP('p5*js');\n  p.position(25, 20);\n  p.style('color', c);\n\n  describe('The text p5*js written in pink on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element and set its font color to \"deeppink\"\n  \/\/ using property:value syntax.\n  let p = createP('p5*js');\n  p.position(25, 20);\n  p.style('color:deeppink');\n\n  describe('The text p5*js written in pink on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an empty paragraph element and set its font color to \"deeppink\".\n  let p = createP();\n  p.position(5, 5);\n  p.style('color', 'deeppink');\n\n  \/\/ Get the element's color as an  RGB color string.\n  let c = p.style('color');\n\n  \/\/ Set the element's inner HTML using the RGB color string.\n  p.html(c);\n\n  describe('The text \"rgb(255, 20, 147)\" written in pink on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":3118,"params":[{"name":"property","description":"<p>style property to set.<\/p>\n","type":"String"}],"return":{"description":"value of the property.","type":"String"}},{"line":3218,"params":[{"name":"property","description":"","type":"String"},{"name":"value","description":"<p>value to assign to the property.<\/p>\n","type":"String|p5.Color"}],"chainable":1,"return":{"description":"value of the property.","type":"String"}}]},{"file":"src\/dom\/dom.js","line":3275,"description":"<p>Adds an\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/HTML\/Introduction_to_HTML\/Getting_started#attributes\" target=\"_blank\">attribute<\/a>\nto the element.<\/p>\n<p>This method is useful for advanced tasks. Most commonly-used attributes,\nsuch as <code>id<\/code>, can be set with their dedicated methods. For example,\n<code>nextButton.id('next')<\/code> sets an element's <code>id<\/code> attribute. Calling\n<code>nextButton.attribute('id', 'next')<\/code> has the same effect.<\/p>\n<p>The first parameter, <code>attr<\/code>, is the attribute's name as a string. Calling\n<code>myElement.attribute('align')<\/code> returns the attribute's current value as a\nstring or <code>null<\/code> if it hasn't been set.<\/p>\n<p>The second parameter, <code>value<\/code>, is optional. It's a string used to set the\nattribute's value. For example, calling\n<code>myElement.attribute('align', 'center')<\/code> sets the element's horizontal\nalignment to <code>center<\/code>.<\/p>\n","itemtype":"method","name":"attribute","return":{"description":"value of the attribute.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a container div element and place it at the top-left corner.\n  let container = createDiv();\n  container.position(0, 0);\n\n  \/\/ Create a paragraph element and place it within the container.\n  \/\/ Set its horizontal alignment to \"left\".\n  let p1 = createP('hi');\n  p1.parent(container);\n  p1.attribute('align', 'left');\n\n  \/\/ Create a paragraph element and place it within the container.\n  \/\/ Set its horizontal alignment to \"center\".\n  let p2 = createP('hi');\n  p2.parent(container);\n  p2.attribute('align', 'center');\n\n  \/\/ Create a paragraph element and place it within the container.\n  \/\/ Set its horizontal alignment to \"right\".\n  let p3 = createP('hi');\n  p3.parent(container);\n  p3.attribute('align', 'right');\n\n  describe('A gray square with the text \"hi\" written on three separate lines, each placed further to the right.');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":3275,"params":[],"return":{"description":"value of the attribute.","type":"String"}},{"line":3330,"params":[{"name":"attr","description":"<p>attribute to set.<\/p>\n","type":"String"},{"name":"value","description":"<p>value to assign to the attribute.<\/p>\n","type":"String"}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":3359,"description":"<p>Removes an attribute from the element.<\/p>\n<p>The parameter <code>attr<\/code> is the attribute's name as a string. For example,\ncalling <code>myElement.removeAttribute('align')<\/code> removes its <code>align<\/code>\nattribute if it's been set.<\/p>\n","itemtype":"method","name":"removeAttribute","params":[{"name":"attr","description":"<p>attribute to remove.<\/p>\n","type":"String"}],"chainable":1,"example":["\n<div>\n<code>\nlet p;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element and place it in the center of the canvas.\n  \/\/ Set its \"align\" attribute to \"center\".\n  p = createP('hi');\n  p.position(0, 20);\n  p.attribute('align', 'center');\n\n  describe('The text \"hi\" written in black at the center of a gray square. The text moves to the left edge when double-clicked.');\n}\n\n\/\/ Remove the 'align' attribute when the user double-clicks the paragraph.\nfunction doubleClicked() {\n  p.removeAttribute('align');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":3410,"description":"<p>Returns or sets the element's value.<\/p>\n<p>Calling <code>myElement.value()<\/code> returns the element's current value.<\/p>\n<p>The parameter, <code>value<\/code>, is an optional number or string. If provided,\nas in <code>myElement.value(123)<\/code>, it's used to set the element's value.<\/p>\n","itemtype":"method","name":"value","return":{"description":"value of the element.","type":"String|Number"},"example":["\n<div>\n<code>\nlet input;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a text input and place it beneath the canvas.\n  \/\/ Set its default value to \"hello\".\n  input = createInput('hello');\n  input.position(0, 100);\n\n  describe('The text from an input box is displayed on a gray square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Use the input's value to display a message.\n  let msg = input.value();\n  text(msg, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet input;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a text input and place it beneath the canvas.\n  \/\/ Set its default value to \"hello\".\n  input = createInput('hello');\n  input.position(0, 100);\n\n  describe('The text from an input box is displayed on a gray square. The text resets to \"hello\" when the user double-clicks the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Use the input's value to display a message.\n  let msg = input.value();\n  text(msg, 0, 55);\n}\n\n\/\/ Reset the input's value.\nfunction doubleClicked() {\n  input.value('hello');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":3410,"params":[],"return":{"description":"value of the element.","type":"String|Number"}},{"line":3477,"params":[{"name":"value","description":"","type":"String|Number"}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":3493,"description":"<p>Shows the current element.<\/p>\n","itemtype":"method","name":"show","chainable":1,"example":["\n<div>\n<code>\nlet p;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element and hide it.\n  p = createP('p5*js');\n  p.position(10, 10);\n  p.hide();\n\n  describe('A gray square. The text \"p5*js\" appears when the user double-clicks the square.');\n}\n\n\/\/ Show the paragraph when the user double-clicks.\nfunction doubleClicked() {\n  p.show();\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":3529,"description":"<p>Hides the current element.<\/p>\n","itemtype":"method","name":"hide","chainable":1,"example":["\nlet p;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element.\n  p = createP('p5*js');\n  p.position(10, 10);\n\n  describe('The text \"p5*js\" at the center of a gray square. The text disappears when the user double-clicks the square.');\n}\n\n\/\/ Hide the paragraph when the user double-clicks.\nfunction doubleClicked() {\n  p.hide();\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":3562,"description":"<p>Sets the element's width and height.<\/p>\n<p>Calling <code>myElement.size()<\/code> without an argument returns the element's size\nas an object with the properties <code>width<\/code> and <code>height<\/code>. For example,\n <code>{ width: 20, height: 10 }<\/code>.<\/p>\n<p>The first parameter, <code>width<\/code>, is optional. It's a number used to set the\nelement's width. Calling <code>myElement.size(10)<\/code><\/p>\n<p>The second parameter, 'height<code>, is also optional. It's a number used to set the element's height. For example, calling <\/code>myElement.size(20, 10)` sets the element's width to 20 pixels and height\nto 10 pixels.<\/p>\n<p>The constant <code>AUTO<\/code> can be used to adjust one dimension at a time while\nmaintaining the aspect ratio, which is <code>width \/ height<\/code>. For example,\nconsider an element that's 200 pixels wide and 100 pixels tall. Calling\n<code>myElement.size(20, AUTO)<\/code> sets the width to 20 pixels and height to 10\npixels.<\/p>\n<p>Note: In the case of elements that need to load data, such as images, wait\nto call <code>myElement.size()<\/code> until after the data loads.<\/p>\n","itemtype":"method","name":"size","return":{"description":"width and height of the element in an object.","type":"Object"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a pink div element and place it at the top-left corner.\n  let div = createDiv();\n  div.position(10, 10);\n  div.style('background-color', 'deeppink');\n\n  \/\/ Set the div's width to 80 pixels and height to 20 pixels.\n  div.size(80, 20);\n\n  describe('A gray square with a pink rectangle near its top.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a pink div element and place it at the top-left corner.\n  let div = createDiv();\n  div.position(10, 10);\n  div.style('background-color', 'deeppink');\n\n  \/\/ Set the div's width to 80 pixels and height to 40 pixels.\n  div.size(80, 40);\n\n  \/\/ Get the div's size as an object.\n  let s = div.size();\n\n  \/\/ Display the div's dimensions.\n  div.html(`${s.width} x ${s.height}`);\n\n  describe('A gray square with a pink rectangle near its top. The text \"80 x 40\" is written within the rectangle.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img1;\nlet img2;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Load an image of an astronaut on the moon\n  \/\/ and place it at the top-left of the canvas.\n  img1 = createImg(\n    'assets\/moonwalk.jpg',\n    'An astronaut walking on the moon',\n    ''\n  );\n  img1.position(0, 0);\n\n  \/\/ Load an image of an astronaut on the moon\n  \/\/ and place it at the top-left of the canvas.\n  \/\/ Resize the image once it's loaded.\n  img2 = createImg(\n    'assets\/moonwalk.jpg',\n    'An astronaut walking on the moon',\n    '',\n    resizeImage\n  );\n  img2.position(0, 0);\n\n  describe('A gray square two copies of a space image at the top-left. The copy in front is smaller.');\n}\n\n\/\/ Resize img2 and keep its aspect ratio.\nfunction resizeImage() {\n  img2.size(50, AUTO);\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM","overloads":[{"line":3562,"params":[],"return":{"description":"width and height of the element in an object.","type":"Object"}},{"line":3676,"params":[{"name":"w","description":"<p>width of the element, either AUTO, or a number.<\/p>\n","type":"Number|Constant","optional":true},{"name":"h","description":"<p>height of the element, either AUTO, or a number.<\/p>\n","type":"Number|Constant","optional":true}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":3731,"description":"<p>Removes the element, stops all audio\/video streams, and removes all\ncallback functions.<\/p>\n","itemtype":"method","name":"remove","example":["\n<div>\n<code>\nlet p;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a paragraph element.\n  p = createP('p5*js');\n  p.position(10, 10);\n\n  describe('The text \"p5*js\" written at the center of a gray square. ');\n}\n\n\/\/ Remove the paragraph when the user double-clicks.\nfunction doubleClicked() {\n  p.remove();\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":3790,"description":"<p>Calls a function when the user drops a file on the element.<\/p>\n<p>The first parameter, <code>callback<\/code>, is a function to call once the file loads.\nThe callback function should have one parameter, <code>file<\/code>, that's a\n<a href=\"#\/p5.File\">p5.File<\/a> object. If the user drops multiple files on\nthe element, <code>callback<\/code>, is called once for each file.<\/p>\n<p>The second parameter, <code>fxn<\/code>, is a function to call when the browser detects\none or more dropped files. The callback function should have one\nparameter, <code>event<\/code>, that's a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/DragEvent\">DragEvent<\/a>.<\/p>\n","itemtype":"method","name":"drop","params":[{"name":"callback","description":"<p>called when a file loads. Called once for each file dropped.<\/p>\n","type":"Function"},{"name":"fxn","description":"<p>called once when any files are dropped.<\/p>\n","type":"Function","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Drop an image on the canvas to view\n\/\/ this example.\nlet img;\n\nfunction setup() {\n  let c = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call handleFile() when a file that's dropped on the canvas has loaded.\n  c.drop(handleFile);\n\n  describe('A gray square. When the user drops an image on the square, it is displayed.');\n}\n\n\/\/ Remove the existing image and display the new one.\nfunction handleFile(file) {\n  \/\/ Remove the current image, if any.\n  if (img) {\n    img.remove();\n  }\n\n  \/\/ Create an <img> element with the\n  \/\/ dropped file.\n  img = createImg(file.data, '');\n  img.hide();\n\n  \/\/ Draw the image.\n  image(img, 0, 0, width, height);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Drop an image on the canvas to view\n\/\/ this example.\nlet img;\nlet msg;\n\nfunction setup() {\n  let c = createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Call functions when the user drops a file on the canvas\n  \/\/ and when the file loads.\n  c.drop(handleFile, handleDrop);\n\n  describe('A gray square. When the user drops an image on the square, it is displayed. The id attribute of canvas element is also displayed.');\n}\n\n\/\/ Display the image when it loads.\nfunction handleFile(file) {\n  \/\/ Remove the current image, if any.\n  if (img) {\n    img.remove();\n  }\n\n  \/\/ Create an img element with the dropped file.\n  img = createImg(file.data, '');\n  img.hide();\n\n  \/\/ Draw the image.\n  image(img, 0, 0, width, height);\n}\n\n\/\/ Display the file's name when it loads.\nfunction handleDrop(event) {\n  \/\/ Remove current paragraph, if any.\n  if (msg) {\n    msg.remove();\n  }\n\n  \/\/ Use event to get the drop target's id.\n  let id = event.target.id;\n\n  \/\/ Write the canvas' id beneath it.\n  msg = createP(id);\n  msg.position(0, 100);\n\n  \/\/ Set the font color randomly for each drop.\n  let c = random(['red', 'green', 'blue']);\n  msg.style('color', c);\n  msg.style('font-size', '12px');\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":3945,"description":"<p>Makes the element draggable.<\/p>\n<p>The parameter, <code>elmnt<\/code>, is optional. If another\n<a href=\"#\/p5.Element\">p5.Element<\/a> object is passed, as in\n<code>myElement.draggable(otherElement)<\/code>, the other element will become draggable.<\/p>\n","itemtype":"method","name":"draggable","params":[{"name":"elmnt","description":"<p>another <a href=\"#\/p5.Element\">p5.Element<\/a>.<\/p>\n","type":"p5.Element","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nlet stickyNote;\nlet textInput;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a div element and style it.\n  stickyNote = createDiv('Note');\n  stickyNote.position(5, 5);\n  stickyNote.size(80, 20);\n  stickyNote.style('font-size', '16px');\n  stickyNote.style('font-family', 'Comic Sans MS');\n  stickyNote.style('background', 'orchid');\n  stickyNote.style('padding', '5px');\n\n  \/\/ Make the note draggable.\n  stickyNote.draggable();\n\n  \/\/ Create a panel div and style it.\n  let panel = createDiv('');\n  panel.position(5, 40);\n  panel.size(80, 50);\n  panel.style('background', 'orchid');\n  panel.style('font-size', '16px');\n  panel.style('padding', '5px');\n  panel.style('text-align', 'center');\n\n  \/\/ Make the panel draggable.\n  panel.draggable();\n\n  \/\/ Create a text input and style it.\n  textInput = createInput('Note');\n  textInput.size(70);\n\n  \/\/ Add the input to the panel.\n  textInput.parent(panel);\n\n  \/\/ Call handleInput() when text is input.\n  textInput.input(handleInput);\n\n  describe(\n    'A gray square with two purple rectangles that move when dragged. The top rectangle displays the text that is typed into the bottom rectangle.'\n  );\n}\n\n\/\/ Update stickyNote's HTML when text is input.\nfunction handleInput() {\n  stickyNote.html(textInput.value());\n}\n<\/code>\n<\/div>"],"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4081,"class":"p5.Element","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4158,"description":"<p>Path to the media element's source as a string.<\/p>\n","itemtype":"property","name":"src","return":{"description":"src","type":"String"},"example":["\n<div>\n<code>\nlet beat;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  beat = createAudio('assets\/beat.mp3');\n\n  describe('The text \"https:\/\/p5js.org\/reference\/assets\/beat.mp3\" written in black on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  textWrap(CHAR);\n  text(beat.src, 10, 10, 80, 80);\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4215,"description":"<p>Plays audio or video from a media element.<\/p>\n","itemtype":"method","name":"play","chainable":1,"example":["\n<div>\n<code>\nlet beat;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display a message.\n  text('Click to play', 50, 50);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  beat = createAudio('assets\/beat.mp3');\n\n  describe('The text \"Click to play\" written in black on a gray background. A beat plays when the user clicks the square.');\n}\n\n\/\/ Play the beat when the user presses the mouse.\nfunction mousePressed() {\n  beat.play();\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4281,"description":"<p>Stops a media element and sets its current time to 0.<\/p>\n<p>Calling <code>media.play()<\/code> will restart playing audio\/video from the beginning.<\/p>\n","itemtype":"method","name":"stop","chainable":1,"example":["\n<div>\n<code>\nlet beat;\nlet isStopped = true;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  beat = createAudio('assets\/beat.mp3');\n\n  describe('The text \"Click to start\" written in black on a gray background. The beat starts or stops when the user presses the mouse.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display different instructions based on playback.\n  if (isStopped === true) {\n    text('Click to start', 50, 50);\n  } else {\n    text('Click to stop', 50, 50);\n  }\n}\n\n\/\/ Adjust playback when the user presses the mouse.\nfunction mousePressed() {\n  if (isStopped === true) {\n    \/\/ If the beat is stopped, play it.\n    beat.play();\n    isStopped = false;\n  } else {\n    \/\/ If the beat is playing, stop it.\n    beat.stop();\n    isStopped = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4340,"description":"<p>Pauses a media element.<\/p>\n<p>Calling <code>media.play()<\/code> will resume playing audio\/video from the moment it paused.<\/p>\n","itemtype":"method","name":"pause","chainable":1,"example":["\n<div>\n<code>\nlet beat;\nlet isPaused = true;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  beat = createAudio('assets\/beat.mp3');\n\n  describe('The text \"Click to play\" written in black on a gray background. The beat plays or pauses when the user clicks the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display different instructions based on playback.\n  if (isPaused === true) {\n    text('Click to play', 50, 50);\n  } else {\n    text('Click to pause', 50, 50);\n  }\n}\n\n\/\/ Adjust playback when the user presses the mouse.\nfunction mousePressed() {\n  if (isPaused === true) {\n    \/\/ If the beat is paused,\n    \/\/ play it.\n    beat.play();\n    isPaused = false;\n  } else {\n    \/\/ If the beat is playing,\n    \/\/ pause it.\n    beat.pause();\n    isPaused = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4400,"description":"<p>Plays the audio\/video repeatedly in a loop.<\/p>\n","itemtype":"method","name":"loop","chainable":1,"example":["\n<div>\n<code>\nlet beat;\nlet isLooping = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  beat = createAudio('assets\/beat.mp3');\n\n  describe('The text \"Click to loop\" written in black on a gray background. A beat plays repeatedly in a loop when the user clicks. The beat stops when the user clicks again.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display different instructions based on playback.\n  if (isLooping === true) {\n    text('Click to stop', 50, 50);\n  } else {\n    text('Click to loop', 50, 50);\n  }\n}\n\n\/\/ Adjust playback when the user presses the mouse.\nfunction mousePressed() {\n  if (isLooping === true) {\n    \/\/ If the beat is looping, stop it.\n    beat.stop();\n    isLooping = false;\n  } else {\n    \/\/ If the beat is stopped, loop it.\n    beat.loop();\n    isLooping = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4458,"description":"<p>Stops the audio\/video from playing in a loop.<\/p>\n<p>The media will stop when it finishes playing.<\/p>\n","itemtype":"method","name":"noLoop","chainable":1,"example":["\n<div>\n<code>\nlet beat;\nlet isPlaying = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  beat = createAudio('assets\/beat.mp3');\n\n  describe('The text \"Click to play\" written in black on a gray background. A beat plays when the user clicks. The beat stops when the user clicks again.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display different instructions based on playback.\n  if (isPlaying === true) {\n    text('Click to stop', 50, 50);\n  } else {\n    text('Click to play', 50, 50);\n  }\n}\n\n\/\/ Adjust playback when the user presses the mouse.\nfunction mousePressed() {\n  if (isPlaying === true) {\n    \/\/ If the beat is playing, stop it.\n    beat.stop();\n    isPlaying = false;\n  } else {\n    \/\/ If the beat is stopped, play it.\n    beat.play();\n    isPlaying = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4538,"description":"<p>Sets the audio\/video to play once it's loaded.<\/p>\n<p>The parameter, <code>shouldAutoplay<\/code>, is optional. Calling\n<code>media.autoplay()<\/code> without an argument causes the media to play\nautomatically. If <code>true<\/code> is passed, as in <code>media.autoplay(true)<\/code>, the\nmedia will automatically play. If <code>false<\/code> is passed, as in\n<code>media.autoPlay(false)<\/code>, it won't play automatically.<\/p>\n","itemtype":"method","name":"autoplay","params":[{"name":"shouldAutoplay","description":"<p>whether the element should autoplay.<\/p>\n","type":"Boolean","optional":true}],"chainable":1,"example":["\n<div class='notest'>\n<code>\nlet video;\n\nfunction setup() {\n  noCanvas();\n\n  \/\/ Call handleVideo() once the video loads.\n  video = createVideo('assets\/fingers.mov', handleVideo);\n\n  describe('A video of fingers walking on a treadmill.');\n}\n\n\/\/ Set the video's size and play it.\nfunction handleVideo() {\n  video.size(100, 100);\n  video.autoplay();\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\nfunction setup() {\n  noCanvas();\n\n  \/\/ Load a video, but don't play it automatically.\n  let video = createVideo('assets\/fingers.mov', handleVideo);\n\n  \/\/ Play the video when the user clicks on it.\n  video.mousePressed(handlePress);\n\n  describe('An image of fingers on a treadmill. They start walking when the user double-clicks on them.');\n}\n<\/code>\n<\/div>\n\n\/\/ Set the video's size and playback mode.\nfunction handleVideo() {\n  video.size(100, 100);\n  video.autoplay(false);\n}\n\n\/\/ Play the video.\nfunction handleClick() {\n  video.play();\n}"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":4623,"description":"<p>Sets the audio\/video volume.<\/p>\n<p>Calling <code>media.volume()<\/code> without an argument returns the current volume\nas a number in the range 0 (off) to 1 (maximum).<\/p>\n<p>The parameter, <code>val<\/code>, is optional. It's a number that sets the volume\nfrom 0 (off) to 1 (maximum). For example, calling <code>media.volume(0.5)<\/code>\nsets the volume to half of its maximum.<\/p>\n","itemtype":"method","name":"volume","return":{"description":"current volume.","type":"Number"},"example":["\n<div>\n<code>\nlet dragon;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  dragon = createAudio('assets\/lucky_dragons.mp3');\n\n  \/\/ Show the default media controls.\n  dragon.showControls();\n\n  describe('The text \"Volume: V\" on a gray square with media controls beneath it. The number \"V\" oscillates between 0 and 1 as the music plays.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Produce a number between 0 and 1.\n  let n = 0.5 * sin(frameCount * 0.01) + 0.5;\n\n  \/\/ Use n to set the volume.\n  dragon.volume(n);\n\n  \/\/ Get the current volume and display it.\n  let v = dragon.volume();\n\n  \/\/ Round v to 1 decimal place for display.\n  v = round(v, 1);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the volume.\n  text(`Volume: ${v}`, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM","overloads":[{"line":4623,"params":[],"return":{"description":"current volume.","type":"Number"}},{"line":4678,"params":[{"name":"val","description":"<p>volume between 0.0 and 1.0.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":4691,"description":"<p>Sets the audio\/video playback speed.<\/p>\n<p>The parameter, <code>val<\/code>, is optional. It's a number that sets the playback\nspeed. 1 plays the media at normal speed, 0.5 plays it at half speed, 2\nplays it at double speed, and so on. -1 plays the media at normal speed\nin reverse.<\/p>\n<p>Calling <code>media.speed()<\/code> returns the current speed as a number.<\/p>\n<p>Note: Not all browsers support backward playback. Even if they do,\nplayback might not be smooth.<\/p>\n","itemtype":"method","name":"speed","return":{"description":"current playback speed.","type":"Number"},"example":["\n<div>\n<code>\nlet dragon;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  dragon = createAudio('assets\/lucky_dragons.mp3');\n\n  \/\/ Show the default media controls.\n  dragon.showControls();\n\n  describe('The text \"Speed: S\" on a gray square with media controls beneath it. The number \"S\" oscillates between 0 and 1 as the music plays.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Produce a number between 0 and 2.\n  let n = sin(frameCount * 0.01) + 1;\n\n  \/\/ Use n to set the playback speed.\n  dragon.speed(n);\n\n  \/\/ Get the current speed and display it.\n  let s = dragon.speed();\n\n  \/\/ Round s to 1 decimal place for display.\n  s = round(s, 1);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the speed.\n  text(`Speed: ${s}`, 50, 50);\n}\n<\/code>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM","overloads":[{"line":4691,"params":[],"return":{"description":"current playback speed.","type":"Number"}},{"line":4749,"params":[{"name":"speed","description":"<p>speed multiplier for playback.<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":4766,"description":"<p>Sets the media element's playback time.<\/p>\n<p>The parameter, <code>time<\/code>, is optional. It's a number that specifies the\ntime, in seconds, to jump to when playback begins.<\/p>\n<p>Calling <code>media.time()<\/code> without an argument returns the number of seconds\nthe audio\/video has played.<\/p>\n<p>Note: Time resets to 0 when looping media restarts.<\/p>\n","itemtype":"method","name":"time","return":{"description":"current time (in seconds).","type":"Number"},"example":["\n<div>\n<code>\nlet dragon;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  dragon = createAudio('assets\/lucky_dragons.mp3');\n\n  \/\/ Show the default media controls.\n  dragon.showControls();\n\n  describe('The text \"S seconds\" on a gray square with media controls beneath it. The number \"S\" increases as the song plays.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Get the current playback time.\n  let s = dragon.time();\n\n  \/\/ Round s to 1 decimal place for display.\n  s = round(s, 1);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the playback time.\n  text(`${s} seconds`, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet dragon;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  dragon = createAudio('assets\/lucky_dragons.mp3');\n\n  \/\/ Show the default media controls.\n  dragon.showControls();\n\n  \/\/ Jump to 2 seconds to start.\n  dragon.time(2);\n\n  describe('The text \"S seconds\" on a gray square with media controls beneath it. The number \"S\" increases as the song plays.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Get the current playback time.\n  let s = dragon.time();\n\n  \/\/ Round s to 1 decimal place for display.\n  s = round(s, 1);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the playback time.\n  text(`${s} seconds`, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM","overloads":[{"line":4766,"params":[],"return":{"description":"current time (in seconds).","type":"Number"}},{"line":4854,"params":[{"name":"time","description":"<p>time to jump to (in seconds).<\/p>\n","type":"Number"}],"chainable":1}]},{"file":"src\/dom\/dom.js","line":4868,"description":"<p>Returns the audio\/video's duration in seconds.<\/p>\n","itemtype":"method","name":"duration","return":{"description":"duration (in seconds).","type":"Number"},"example":["\n<div>\n<code>\nlet dragon;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  dragon = createAudio('assets\/lucky_dragons.mp3');\n\n  \/\/ Show the default media controls.\n  dragon.showControls();\n\n  describe('The text \"S seconds left\" on a gray square with media controls beneath it. The number \"S\" decreases as the song plays.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the time remaining.\n  let s = dragon.duration() - dragon.time();\n\n  \/\/ Round s to 1 decimal place for display.\n  s = round(s, 1);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the time remaining.\n  text(`${s} seconds left`, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5024,"description":"<p>Calls a function when the audio\/video reaches the end of its playback.<\/p>\n<p>The element is passed as an argument to the callback function.<\/p>\n<p>Note: The function won't be called if the media is looping.<\/p>\n","itemtype":"method","name":"onended","params":[{"name":"callback","description":"<p>function to call when playback ends.\n                            The <code>p5.MediaElement<\/code> is passed as\n                            the argument.<\/p>\n","type":"Function"}],"chainable":1,"example":["\n<div>\n<code>\nlet beat;\nlet isPlaying = false;\nlet isDone = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  beat = createAudio('assets\/beat.mp3');\n\n  \/\/ Call handleEnd() when the beat finishes.\n  beat.onended(handleEnd);\n\n  describe('The text \"Click to play\" written in black on a gray square. A beat plays when the user clicks. The text \"Done!\" appears when the beat finishes playing.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display different messages based on playback.\n  if (isDone === true) {\n    text('Done!', 50, 50);\n  } else if (isPlaying === false) {\n    text('Click to play', 50, 50);\n  } else {\n    text('Playing...', 50, 50);\n  }\n}\n\n\/\/ Play the beat when the user presses the mouse.\nfunction mousePressed() {\n  if (isPlaying === false) {\n    isPlaying = true;\n    beat.play();\n  }\n}\n\n\/\/ Set isDone when playback ends.\nfunction handleEnd() {\n  isDone = false;\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5093,"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5095,"description":"<p>Sends the element's audio to an output.<\/p>\n<p>The parameter, <code>audioNode<\/code>, can be an <code>AudioNode<\/code> or an object from the\n<code>p5.sound<\/code> library.<\/p>\n<p>If no element is provided, as in <code>myElement.connect()<\/code>, the element\nconnects to the main output. All connections are removed by the\n<code>.disconnect()<\/code> method.<\/p>\n<p>Note: This method is meant to be used with the p5.sound.js addon library.<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"audioNode","description":"<p>AudioNode from the Web Audio API,\nor an object from the p5.sound library<\/p>\n","type":"AudioNode|Object"}],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5148,"description":"<p>Disconnect all Web Audio routing, including to the main output.<\/p>\n<p>This is useful if you want to re-route the output through audio effects,\nfor example.<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5164,"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5166,"description":"<p>Show the default\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLMediaElement\" target=\"_blank\">HTMLMediaElement<\/a>\ncontrols.<\/p>\n<p>Note: The controls vary between web browsers.<\/p>\n","itemtype":"method","name":"showControls","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background('cornflowerblue');\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(50);\n\n  \/\/ Display a dragon.\n  text('\ud83d\udc09', 50, 50);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  let dragon = createAudio('assets\/lucky_dragons.mp3');\n\n  \/\/ Show the default media controls.\n  dragon.showControls();\n\n  describe('A dragon emoji, \ud83d\udc09, drawn in the center of a blue square. A song plays in the background. Audio controls are displayed beneath the canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5207,"description":"<p>Hide the default\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLMediaElement\" target=\"_blank\">HTMLMediaElement<\/a>\ncontrols.<\/p>\n","itemtype":"method","name":"hideControls","example":["\n<div>\n<code>\nlet dragon;\nlet isHidden = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  dragon = createAudio('assets\/lucky_dragons.mp3');\n\n  \/\/ Show the default media controls.\n  dragon.showControls();\n\n  describe('The text \"Double-click to hide controls\" written in the middle of a gray square. A song plays in the background. Audio controls are displayed beneath the canvas. The controls appear\/disappear when the user double-clicks the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n\n  \/\/ Display a different message when controls are hidden or shown.\n  if (isHidden === true) {\n    text('Double-click to show controls', 10, 20, 80, 80);\n  } else {\n    text('Double-click to hide controls', 10, 20, 80, 80);\n  }\n}\n\n\/\/ Show\/hide controls based on a double-click.\nfunction doubleClicked() {\n  if (isHidden === true) {\n    dragon.showControls();\n    isHidden = false;\n  } else {\n    dragon.hideControls();\n    isHidden = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5263,"description":"<p>Schedules a function to call when the audio\/video reaches a specific time\nduring its playback.<\/p>\n<p>The first parameter, <code>time<\/code>, is the time, in seconds, when the function\nshould run. This value is passed to <code>callback<\/code> as its first argument.<\/p>\n<p>The second parameter, <code>callback<\/code>, is the function to call at the specified\ncue time.<\/p>\n<p>The third parameter, <code>value<\/code>, is optional and can be any type of value.\n<code>value<\/code> is passed to <code>callback<\/code>.<\/p>\n<p>Calling <code>media.addCue()<\/code> returns an ID as a string. This is useful for\nremoving the cue later.<\/p>\n","itemtype":"method","name":"addCue","params":[{"name":"time","description":"<p>cue time to run the callback function.<\/p>\n","type":"Number"},{"name":"callback","description":"<p>function to call at the cue time.<\/p>\n","type":"Function"},{"name":"value","description":"<p>object to pass as the argument to\n                           <code>callback<\/code>.<\/p>\n","type":"Object","optional":true}],"return":{"description":"id ID of this cue,\n                    useful for `media.removeCue(id)`.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  let beat = createAudio('assets\/beat.mp3');\n\n  \/\/ Play the beat in a loop.\n  beat.loop();\n\n  \/\/ Schedule a few events.\n  beat.addCue(0, changeBackground, 'red');\n  beat.addCue(2, changeBackground, 'deeppink');\n  beat.addCue(4, changeBackground, 'orchid');\n  beat.addCue(6, changeBackground, 'lavender');\n\n  describe('A red square with a beat playing in the background. Its color changes every 2 seconds while the audio plays.');\n}\n\n\/\/ Change the background color.\nfunction changeBackground(c) {\n  background(c);\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5328,"description":"<p>Removes a callback based on its ID.<\/p>\n","itemtype":"method","name":"removeCue","params":[{"name":"id","description":"<p>ID of the cue, created by <code>media.addCue()<\/code>.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet lavenderID;\nlet isRemoved = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  let beat = createAudio('assets\/beat.mp3');\n\n  \/\/ Play the beat in a loop.\n  beat.loop();\n\n  \/\/ Schedule a few events.\n  beat.addCue(0, changeBackground, 'red');\n  beat.addCue(2, changeBackground, 'deeppink');\n  beat.addCue(4, changeBackground, 'orchid');\n\n  \/\/ Record the ID of the \"lavender\" callback.\n  lavenderID = beat.addCue(6, changeBackground, 'lavender');\n\n  describe('The text \"Double-click to remove lavender.\" written on a red square. The color changes every 2 seconds while the audio plays. The lavender option is removed when the user double-clicks the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Display different instructions based on the available callbacks.\n  if (isRemoved === false) {\n    text('Double-click to remove lavender.', 10, 10, 80, 80);\n  } else {\n    text('No more lavender.', 10, 10, 80, 80);\n  }\n}\n\n\/\/ Change the background color.\nfunction changeBackground(c) {\n  background(c);\n}\n\n\/\/ Remove the lavender color-change cue when the user double-clicks.\nfunction doubleClicked() {\n  if (isRemoved === false) {\n    beat.removeCue(lavenderID);\n    isRemoved = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5399,"description":"<p>Removes all functions scheduled with <code>media.addCue()<\/code>.<\/p>\n","itemtype":"method","name":"clearCues","example":["\n<div>\n<code>\nlet isChanging = true;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.MediaElement using createAudio().\n  let beat = createAudio('assets\/beat.mp3');\n\n  \/\/ Play the beat in a loop.\n  beat.loop();\n\n  \/\/ Schedule a few events.\n  beat.addCue(0, changeBackground, 'red');\n  beat.addCue(2, changeBackground, 'deeppink');\n  beat.addCue(4, changeBackground, 'orchid');\n  beat.addCue(6, changeBackground, 'lavender');\n\n  describe('The text \"Double-click to stop changing.\" written on a square. The color changes every 2 seconds while the audio plays. The color stops changing when the user double-clicks the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Display different instructions based on the available callbacks.\n  if (isChanging === true) {\n    text('Double-click to stop changing.', 10, 10, 80, 80);\n  } else {\n    text('No more changes.', 10, 10, 80, 80);\n  }\n}\n\n\/\/ Change the background color.\nfunction changeBackground(c) {\n  background(c);\n}\n\n\/\/ Remove cued functions and stop changing colors when the user\n\/\/ double-clicks.\nfunction doubleClicked() {\n  if (isChanging === true) {\n    beat.clearCues();\n    isChanging = false;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.MediaElement","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5573,"description":"<p>Underlying\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/File\" target=\"_blank\">File<\/a>\nobject. All <code>File<\/code> properties and methods are accessible.<\/p>\n","itemtype":"property","name":"file","example":["\n<div>\n<code>\n\/\/ Use the file input to load a\n\/\/ file and display its info.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call displayInfo() when the file loads.\n  let input = createFileInput(displayInfo);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.');\n}\n\n\/\/ Use the p5.File once it loads.\nfunction displayInfo(file) {\n  background(200);\n\n  \/\/ Display the p5.File's name.\n  text(file.name, 10, 10, 80, 40);\n\n  \/\/ Display the p5.File's type and subtype.\n  text(`${file.type}\/${file.subtype}`, 10, 70);\n\n  \/\/ Display the p5.File's size in bytes.\n  text(file.size, 10, 90);\n}\n<\/code>\n<\/div>"],"class":"p5.File","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5622,"description":"<p>The file\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types\" target=\"_blank\">MIME type<\/a>\nas a string.<\/p>\n<p>For example, <code>'image'<\/code> and <code>'text'<\/code> are both MIME types.<\/p>\n","itemtype":"property","name":"type","example":["\n<div>\n<code>\n\/\/ Use the file input to load a file and display its info.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call displayType() when the file loads.\n  let input = createFileInput(displayType);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user loads a file, its type is written in black.');\n}\n\n\/\/ Display the p5.File's type once it loads.\nfunction displayType(file) {\n  background(200);\n\n  \/\/ Display the p5.File's type.\n  text(`This is file's type is: ${file.type}`, 10, 10, 80, 80);\n}\n<\/code>\n<\/div>"],"class":"p5.File","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5660,"description":"<p>The file subtype as a string.<\/p>\n<p>For example, a file with an <code>'image'<\/code>\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types\" target=\"_blank\">MIME type<\/a>\nmay have a subtype such as <code>png<\/code> or <code>jpeg<\/code>.<\/p>\n","itemtype":"property","name":"subtype","example":["\n<div>\n<code>\n\/\/ Use the file input to load a\n\/\/ file and display its info.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call displaySubtype() when the file loads.\n  let input = createFileInput(displaySubtype);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user loads a file, its subtype is written in black.');\n}\n\n\/\/ Display the p5.File's type once it loads.\nfunction displaySubtype(file) {\n  background(200);\n\n  \/\/ Display the p5.File's subtype.\n  text(`This is file's subtype is: ${file.subtype}`, 10, 10, 80, 80);\n}\n<\/code>\n<\/div>"],"class":"p5.File","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5699,"description":"<p>The file name as a string.<\/p>\n","itemtype":"property","name":"name","example":["\n<div>\n<code>\n\/\/ Use the file input to load a\n\/\/ file and display its info.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call displayName() when the file loads.\n  let input = createFileInput(displayName);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user loads a file, its name is written in black.');\n}\n\n\/\/ Display the p5.File's name once it loads.\nfunction displayName(file) {\n  background(200);\n\n  \/\/ Display the p5.File's name.\n  text(`This is file's name is: ${file.name}`, 10, 10, 80, 80);\n}\n<\/code>\n<\/div>"],"class":"p5.File","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5734,"description":"<p>The number of bytes in the file.<\/p>\n","itemtype":"property","name":"size","example":["\n<div>\n<code>\n\/\/ Use the file input to load a file and display its info.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call displaySize() when the file loads.\n  let input = createFileInput(displaySize);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user loads a file, its size in bytes is written in black.');\n}\n\n\/\/ Display the p5.File's size in bytes once it loads.\nfunction displaySize(file) {\n  background(200);\n\n  \/\/ Display the p5.File's size.\n  text(`This is file has ${file.size} bytes.`, 10, 10, 80, 80);\n}\n<\/code>\n<\/div>"],"class":"p5.File","module":"DOM","submodule":"DOM"},{"file":"src\/dom\/dom.js","line":5769,"description":"<p>A string containing the file's data.<\/p>\n<p>Data can be either image data, text contents, or a parsed object in the\ncase of JSON and <a href=\"#\/p5.XML\">p5.XML<\/a> objects.<\/p>\n","itemtype":"property","name":"data","example":["\n<div>\n<code>\n\/\/ Use the file input to load a file and display its info.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a file input and place it beneath the canvas.\n  \/\/ Call displayData() when the file loads.\n  let input = createFileInput(displayData);\n  input.position(0, 100);\n\n  describe('A gray square with a file input beneath it. If the user loads a file, its data is written in black.');\n}\n\n\/\/ Display the p5.File's data once it loads.\nfunction displayData(file) {\n  background(200);\n\n  \/\/ Display the p5.File's data, which looks like a random string of characters.\n  text(file.data, 10, 10, 80, 80);\n}\n<\/code>\n<\/div>"],"class":"p5.File","module":"DOM","submodule":"DOM"},{"file":"src\/events\/acceleration.js","line":11,"description":"<p>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'.\neither LANDSCAPE or PORTRAIT.<\/p>\n","itemtype":"property","name":"deviceOrientation","type":"Constant","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":23,"description":"<p>The system variable accelerationX always contains the acceleration of the\ndevice along the x axis. Value is represented as meters per second squared.<\/p>\n","itemtype":"property","name":"accelerationX","type":"Number","readonly":"","example":["\n<div>\n<code>\n\/\/ Move a touchscreen device to register\n\/\/ acceleration changes.\nfunction draw() {\n  background(220, 50);\n  fill('magenta');\n  ellipse(width \/ 2, height \/ 2, accelerationX);\n  describe('Magnitude of device acceleration is displayed as ellipse size.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":45,"description":"<p>The system variable accelerationY always contains the acceleration of the\ndevice along the y axis. Value is represented as meters per second squared.<\/p>\n","itemtype":"property","name":"accelerationY","type":"Number","readonly":"","example":["\n<div>\n<code>\n\/\/ Move a touchscreen device to register\n\/\/ acceleration changes.\nfunction draw() {\n  background(220, 50);\n  fill('magenta');\n  ellipse(width \/ 2, height \/ 2, accelerationY);\n  describe('Magnitude of device acceleration is displayed as ellipse size');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":67,"description":"<p>The system variable accelerationZ always contains the acceleration of the\ndevice along the z axis. Value is represented as meters per second squared.<\/p>\n","itemtype":"property","name":"accelerationZ","type":"Number","readonly":"","example":["\n<div>\n<code>\n\/\/ Move a touchscreen device to register\n\/\/ acceleration changes.\nfunction draw() {\n  background(220, 50);\n  fill('magenta');\n  ellipse(width \/ 2, height \/ 2, accelerationZ);\n  describe('Magnitude of device acceleration is displayed as ellipse size');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":90,"description":"<p>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.<\/p>\n","itemtype":"property","name":"pAccelerationX","type":"Number","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":100,"description":"<p>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.<\/p>\n","itemtype":"property","name":"pAccelerationY","type":"Number","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":110,"description":"<p>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.<\/p>\n","itemtype":"property","name":"pAccelerationZ","type":"Number","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":131,"description":"<p>The system variable rotationX always contains the rotation of the\ndevice along the x axis. If the sketch <a href=\"#\/p5\/angleMode\">\nangleMode()<\/a> is set to DEGREES, the value will be -180 to 180. If\nit is set to RADIANS, the value will be -PI to PI.<\/p>\n<p>Note: 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.<\/p>\n","itemtype":"property","name":"rotationX","type":"Number","readonly":"","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  describe(`red horizontal line right, green vertical line bottom.\n    black background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":164,"description":"<p>The system variable rotationY always contains the rotation of the\ndevice along the y axis. If the sketch <a href=\"#\/p5\/angleMode\">\nangleMode()<\/a> is set to DEGREES, the value will be -90 to 90. If\nit is set to RADIANS, the value will be -PI\/2 to PI\/2.<\/p>\n<p>Note: 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.<\/p>\n","itemtype":"property","name":"rotationY","type":"Number","readonly":"","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  describe(`red horizontal line right, green vertical line bottom.\n    black background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":197,"description":"<p>The system variable rotationZ always contains the rotation of the\ndevice along the z axis. If the sketch <a href=\"#\/p5\/angleMode\">\nangleMode()<\/a> is set to DEGREES, the value will be 0 to 360. If\nit is set to RADIANS, the value will be 0 to 2*PI.<\/p>\n<p>Unlike rotationX and rotationY, this variable is available for devices\nwith a built-in compass only.<\/p>\n<p>Note: 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.<\/p>\n","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  describe(`red horizontal line right, green vertical line bottom.\n    black background.`);\n}\n<\/code>\n<\/div>"],"itemtype":"property","name":"rotationZ","type":"Number","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":234,"description":"<p>The system variable pRotationX always contains the rotation of the\ndevice along the x axis in the frame previous to the current frame.\nIf the sketch <a href=\"#\/p5\/angleMode\"> angleMode()<\/a> is set to DEGREES,\nthe value will be -180 to 180. If it is set to RADIANS, the value will\nbe -PI to PI.<\/p>\n<p>pRotationX can also be used with rotationX to determine the rotate\ndirection of the device along the X-axis.<\/p>\n","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.\nlet rotateDirection = 'clockwise';\n\n\/\/ Simple range conversion to make things simpler.\n\/\/ This is not absolutely necessary but the logic\n\/\/ will be different in that case.\n\nlet rX = rotationX + 180;\nlet pRX = pRotationX + 180;\n\nif ((rX - pRX > 0 && rX - pRX < 270) || rX - pRX < -270) {\n  rotateDirection = 'clockwise';\n} else if (rX - pRX < 0 || rX - pRX > 270) {\n  rotateDirection = 'counter-clockwise';\n}\n\nprint(rotateDirection);\ndescribe('no image to display.');\n<\/code>\n<\/div>"],"itemtype":"property","name":"pRotationX","type":"Number","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":278,"description":"<p>The system variable pRotationY always contains the rotation of the\ndevice along the y axis in the frame previous to the current frame.\nIf the sketch <a href=\"#\/p5\/angleMode\"> angleMode()<\/a> is set to DEGREES,\nthe value will be -90 to 90. If it is set to RADIANS, the value will\nbe -PI\/2 to PI\/2.<\/p>\n<p>pRotationY can also be used with rotationY to determine the rotate\ndirection of the device along the Y-axis.<\/p>\n","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.\nlet rotateDirection = 'clockwise';\n\n\/\/ Simple range conversion to make things simpler.\n\/\/ This is not absolutely necessary but the logic\n\/\/ will be different in that case.\n\nlet rY = rotationY + 180;\nlet pRY = pRotationY + 180;\n\nif ((rY - pRY > 0 && rY - pRY < 270) || rY - pRY < -270) {\n  rotateDirection = 'clockwise';\n} else if (rY - pRY < 0 || rY - pRY > 270) {\n  rotateDirection = 'counter-clockwise';\n}\nprint(rotateDirection);\ndescribe('no image to display.');\n<\/code>\n<\/div>"],"itemtype":"property","name":"pRotationY","type":"Number","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":321,"description":"<p>The system variable pRotationZ always contains the rotation of the\ndevice along the z axis in the frame previous to the current frame.\nIf the sketch <a href=\"#\/p5\/angleMode\"> angleMode()<\/a> is set to DEGREES,\nthe value will be 0 to 360. If it is set to RADIANS, the value will\nbe 0 to 2*PI.<\/p>\n<p>pRotationZ can also be used with rotationZ to determine the rotate\ndirection of the device along the Z-axis.<\/p>\n","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.\nlet rotateDirection = 'clockwise';\n\nif (\n  (rotationZ - pRotationZ > 0 && rotationZ - pRotationZ < 270) ||\n  rotationZ - pRotationZ < -270\n) {\n  rotateDirection = 'clockwise';\n} else if (rotationZ - pRotationZ < 0 || rotationZ - pRotationZ > 270) {\n  rotateDirection = 'counter-clockwise';\n}\nprint(rotateDirection);\ndescribe('no image to display.');\n<\/code>\n<\/div>"],"itemtype":"property","name":"pRotationZ","type":"Number","readonly":"","class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":378,"description":"<p>When a device is rotated, the axis that triggers the <a href=\"#\/p5\/deviceTurned\">deviceTurned()<\/a>\nmethod is stored in the turnAxis variable. The turnAxis variable is only defined within\nthe scope of deviceTurned().<\/p>\n","itemtype":"property","name":"turnAxis","type":"String","readonly":"","example":["\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\nlet value = 0;\nfunction draw() {\n  fill(value);\n  rect(25, 25, 50, 50);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when device turns`);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when x-axis turns`);\n}\nfunction deviceTurned() {\n  if (turnAxis === 'X') {\n    if (value === 0) {\n      value = 255;\n    } else if (value === 255) {\n      value = 0;\n    }\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":417,"description":"<p>The <a href=\"#\/p5\/setMoveThreshold\">setMoveThreshold()<\/a> function is used to set the movement threshold for\nthe <a href=\"#\/p5\/deviceMoved\">deviceMoved()<\/a> function. The default threshold is set to 0.5.<\/p>\n","itemtype":"method","name":"setMoveThreshold","params":[{"name":"value","description":"<p>The threshold value<\/p>\n","type":"Number"}],"example":["\n<div class=\"norender\">\n<code>\n\/\/ Run this example on a mobile device\n\/\/ You will need to move the device incrementally further\n\/\/ the closer the square's color gets to white in order to change the value.\n\nlet value = 0;\nlet threshold = 0.5;\nfunction setup() {\n  setMoveThreshold(threshold);\n}\nfunction draw() {\n  fill(value);\n  rect(25, 25, 50, 50);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when device moves`);\n}\nfunction deviceMoved() {\n  value = value + 5;\n  threshold = threshold + 0.1;\n  if (value > 255) {\n    value = 0;\n    threshold = 30;\n  }\n  setMoveThreshold(threshold);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":459,"description":"<p>The <a href=\"#\/p5\/setShakeThreshold\">setShakeThreshold()<\/a> function is used to set the movement threshold for\nthe <a href=\"#\/p5\/deviceShaken\">deviceShaken()<\/a> function. The default threshold is set to 30.<\/p>\n","itemtype":"method","name":"setShakeThreshold","params":[{"name":"value","description":"<p>The threshold value<\/p>\n","type":"Number"}],"example":["\n<div class=\"norender\">\n<code>\n\/\/ Run this example on a mobile device\n\/\/ You will need to shake the device more firmly\n\/\/ the closer the box's fill gets to white in order to change the value.\n\nlet value = 0;\nlet threshold = 30;\nfunction setup() {\n  setShakeThreshold(threshold);\n}\nfunction draw() {\n  fill(value);\n  rect(25, 25, 50, 50);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when device is being shaked`);\n}\nfunction deviceMoved() {\n  value = value + 5;\n  threshold = threshold + 5;\n  if (value > 255) {\n    value = 0;\n    threshold = 30;\n  }\n  setShakeThreshold(threshold);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":501,"description":"<p>The <a href=\"#\/p5\/deviceMoved\">deviceMoved()<\/a> 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 0.5.\nThe threshold value can be changed using <a href=\"#\/p5\/setMoveThreshold\">setMoveThreshold()<\/a>.<\/p>\n","itemtype":"method","name":"deviceMoved","example":["\n<div class=\"norender\">\n<code>\n\/\/ Run this example on a mobile device\n\/\/ Move the device around\n\/\/ to change the value.\n\nlet value = 0;\nfunction draw() {\n  fill(value);\n  rect(25, 25, 50, 50);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when device moves`);\n}\nfunction deviceMoved() {\n  value = value + 5;\n  if (value > 255) {\n    value = 0;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":531,"description":"<p>The <a href=\"#\/p5\/deviceTurned\">deviceTurned()<\/a> function is called when the device rotates by\nmore than 90 degrees continuously.<\/p>\n<p>The axis that triggers the <a href=\"#\/p5\/deviceTurned\">deviceTurned()<\/a> method is stored in the turnAxis\nvariable. The <a href=\"#\/p5\/deviceTurned\">deviceTurned()<\/a> method can be locked to trigger on any axis:\nX, Y or Z by comparing the turnAxis variable to 'X', 'Y' or 'Z'.<\/p>\n","itemtype":"method","name":"deviceTurned","example":["\n<div class=\"norender\">\n<code>\n\/\/ Run this example on a mobile device\n\/\/ Rotate the device by 90 degrees\n\/\/ to change the value.\n\nlet value = 0;\nfunction draw() {\n  fill(value);\n  rect(25, 25, 50, 50);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when device turns`);\n}\nfunction deviceTurned() {\n  if (value === 0) {\n    value = 255;\n  } else if (value === 255) {\n    value = 0;\n  }\n}\n<\/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\nlet value = 0;\nfunction draw() {\n  fill(value);\n  rect(25, 25, 50, 50);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when x-axis turns`);\n}\nfunction deviceTurned() {\n  if (turnAxis === 'X') {\n    if (value === 0) {\n      value = 255;\n    } else if (value === 255) {\n      value = 0;\n    }\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/acceleration.js","line":589,"description":"<p>The <a href=\"#\/p5\/deviceShaken\">deviceShaken()<\/a> 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.\nThe threshold value can be changed using <a href=\"#\/p5\/setShakeThreshold\">setShakeThreshold()<\/a>.<\/p>\n","itemtype":"method","name":"deviceShaken","example":["\n<div class=\"norender\">\n<code>\n\/\/ Run this example on a mobile device\n\/\/ Shake the device to change the value.\n\nlet value = 0;\nfunction draw() {\n  fill(value);\n  rect(25, 25, 50, 50);\n  describe(`50-by-50 black rect in center of canvas.\n    turns white on mobile when device shakes`);\n}\nfunction deviceShaken() {\n  value = value + 5;\n  if (value > 255) {\n    value = 0;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Acceleration"},{"file":"src\/events\/keyboard.js","line":10,"description":"<p>A <code>Boolean<\/code> system variable that's <code>true<\/code> if any key is currently pressed\nand <code>false<\/code> if not.<\/p>\n","itemtype":"property","name":"keyIsPressed","type":"Boolean","readonly":"","example":["\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a white square at its center. The white square turns black when the user presses a key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  if (keyIsPressed === true) {\n    fill(0);\n  } else {\n    fill(255);\n  }\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a white square at its center. The white square turns black when the user presses a key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  if (keyIsPressed) {\n    fill(0);\n  } else {\n    fill(255);\n  }\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with the word \"false\" at its center. The word switches to \"true\" when the user presses a key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the value of keyIsPressed.\n  text(keyIsPressed, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/keyboard.js","line":102,"description":"<p>A <code>String<\/code> system variable that contains the value of the last key typed.<\/p>\n<p>The key variable is helpful for checking whether an\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/ASCII#Printable_characters\" target=\"_blank\">ASCII<\/a>\nkey has been typed. For example, the expression <code>key === \"a\"<\/code> evaluates to\n<code>true<\/code> if the <code>a<\/code> key was typed and <code>false<\/code> if not. <code>key<\/code> doesn\u2019t update\nfor special keys such as <code>LEFT_ARROW<\/code> and <code>ENTER<\/code>. Use keyCode instead for\nspecial keys. The <a href=\"#\/p5\/keyIsDown\">keyIsDown()<\/a> function should\nbe used to check for multiple different key presses at the same time.<\/p>\n","itemtype":"property","name":"key","type":"String","readonly":"","example":["\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. The last key pressed is displayed at the center.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the last key pressed.\n  text(key, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe(\n    'A gray square with a black circle at its center. The circle moves when the user presses the keys \"w\", \"a\", \"s\", or \"d\". It leaves a trail as it moves.'\n  );\n}\n\nfunction draw() {\n  \/\/ Update x and y if a key is pressed.\n  if (keyIsPressed === true) {\n    if (key === 'w') {\n      y -= 1;\n    } else if (key === 's') {\n      y += 1;\n    } else if (key === 'a') {\n      x -= 1;\n    } else if (key === 'd') {\n      x += 1;\n    }\n  }\n\n  \/\/ Style the circle.\n  fill(0);\n\n  \/\/ Draw the circle at (x, y).\n  circle(x, y, 5);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/keyboard.js","line":184,"description":"<p>A <code>Number<\/code> system variable that contains the code of the last key typed.<\/p>\n<p>All keys have a <code>keyCode<\/code>. For example, the <code>a<\/code> key has the <code>keyCode<\/code> 65.\nThe <code>keyCode<\/code> variable is helpful for checking whether a special key has\nbeen typed. For example, the following conditional checks whether the enter\nkey has been typed:<\/p>\n<pre><code class=\"language-js\">if (keyCode === 13) {\n  \/\/ Code to run if the enter key was pressed.\n}\n<\/code><\/pre>\n<p>The same code can be written more clearly using the system variable <code>ENTER<\/code>\nwhich has a value of 13:<\/p>\n<pre><code class=\"language-js\">if (keyCode === ENTER) {\n  \/\/ Code to run if the enter key was pressed.\n}\n<\/code><\/pre>\n<p>The system variables <code>BACKSPACE<\/code>, <code>DELETE<\/code>, <code>ENTER<\/code>, <code>RETURN<\/code>, <code>TAB<\/code>,\n<code>ESCAPE<\/code>, <code>SHIFT<\/code>, <code>CONTROL<\/code>, <code>OPTION<\/code>, <code>ALT<\/code>, <code>UP_ARROW<\/code>, <code>DOWN_ARROW<\/code>,\n<code>LEFT_ARROW<\/code>, and <code>RIGHT_ARROW<\/code> are all helpful shorthands the key codes of\nspecial keys. Key codes can be found on websites such as\n<a href=\"http:\/\/keycode.info\/\">keycode.info<\/a>.<\/p>\n","itemtype":"property","name":"keyCode","type":"Integer","readonly":"","example":["\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. The last key pressed and its code are displayed at the center.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the last key pressed and its code.\n  text(`${key} : ${keyCode}`, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe(\n    'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.'\n  );\n}\n\nfunction draw() {\n  \/\/ Update x and y if an arrow key is pressed.\n  if (keyIsPressed === true) {\n    if (keyCode === UP_ARROW) {\n      y -= 1;\n    } else if (keyCode === DOWN_ARROW) {\n      y += 1;\n    } else if (keyCode === LEFT_ARROW) {\n      x -= 1;\n    } else if (keyCode === RIGHT_ARROW) {\n      x += 1;\n    }\n  }\n\n  \/\/ Style the circle.\n  fill(0);\n\n  \/\/ Draw the circle at (x, y).\n  circle(x, y, 5);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/keyboard.js","line":284,"description":"<p>A function that's called once when any key is pressed.<\/p>\n<p>Declaring the function <code>keyPressed()<\/code> sets a code block to run once\nautomatically when the user presses any key:<\/p>\n<pre><code class=\"language-js\">function keyPressed() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The <a href=\"#\/p5\/key\">key<\/a> and <a href=\"#\/p5\/keyCode\">keyCode<\/a>\nvariables will be updated with the most recently typed value when\n<code>keyPressed()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function keyPressed() {\n  if (key === 'c') {\n    \/\/ Code to run.\n  }\n\n  if (keyCode === ENTER) {\n    \/\/ Code to run.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>keyPressed()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/KeyboardEvent\" target=\"_blank\">KeyboardEvent<\/a>\nobject with properties that describe the key press event:<\/p>\n<pre><code class=\"language-js\">function keyPressed(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>Browsers may have default behaviors attached to various key events. For\nexample, some browsers may jump to the bottom of a web page when the\n<code>SPACE<\/code> key is pressed. To prevent any default behavior for this event, add\n<code>return false;<\/code> to the end of the function.<\/p>\n","itemtype":"method","name":"keyPressed","params":[{"name":"event","description":"<p>optional <code>KeyboardEvent<\/code> callback argument.<\/p>\n","type":"KeyboardEvent","optional":true}],"example":["\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square changes color when the user presses a key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle the background color when the user presses a key.\nfunction keyPressed() {\n  if (value === 0) {\n    value = 255;\n  } else {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a white square at its center. The inner square turns black when the user presses the \"b\" key. It turns white when the user presses the \"a\" key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Reassign value when the user presses the 'a' or 'b' key.\nfunction keyPressed() {\n  if (key === 'a') {\n    value = 255;\n  } else if (key === 'b') {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square turns white when the user presses the left arrow key. It turns black when the user presses the right arrow key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle the background color when the user presses an arrow key.\nfunction keyPressed() {\n  if (keyCode === LEFT_ARROW) {\n    value = 255;\n  } else if (keyCode === RIGHT_ARROW) {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/keyboard.js","line":474,"description":"<p>A function that's called once when any key is released.<\/p>\n<p>Declaring the function <code>keyReleased()<\/code> sets a code block to run once\nautomatically when the user releases any key:<\/p>\n<pre><code class=\"language-js\">function keyReleased() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The <a href=\"#\/p5\/key\">key<\/a> and <a href=\"#\/p5\/keyCode\">keyCode<\/a>\nvariables will be updated with the most recently released value when\n<code>keyReleased()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function keyReleased() {\n  if (key === 'c') {\n    \/\/ Code to run.\n  }\n\n  if (keyCode === ENTER) {\n    \/\/ Code to run.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>keyReleased()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/KeyboardEvent\" target=\"_blank\">KeyboardEvent<\/a>\nobject with properties that describe the key press event:<\/p>\n<pre><code class=\"language-js\">function keyReleased(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>Browsers may have default behaviors attached to various key events. To\nprevent any default behavior for this event, add <code>return false;<\/code> to the end\nof the function.<\/p>\n","itemtype":"method","name":"keyReleased","params":[{"name":"event","description":"<p>optional <code>KeyboardEvent<\/code> callback argument.<\/p>\n","type":"KeyboardEvent","optional":true}],"example":["\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square changes color when the user releases a key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle value when the user releases a key.\nfunction keyReleased() {\n  if (value === 0) {\n    value = 255;\n  } else {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square becomes white when the user releases the \"w\" key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Set value to 255 the user releases the 'w' key.\nfunction keyReleased() {\n  if (key === 'w') {\n    value = 255;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square turns white when the user presses and releases the left arrow key. It turns black when the user presses and releases the right arrow key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle the background color when the user releases an arrow key.\nfunction keyReleased() {\n  if (keyCode === LEFT_ARROW) {\n    value = 255;\n  } else if (keyCode === RIGHT_ARROW) {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/keyboard.js","line":655,"description":"<p>A function that's called once when keys with printable characters are pressed.<\/p>\n<p>Declaring the function <code>keyTyped()<\/code> sets a code block to run once\nautomatically when the user presses any key with a printable character such\nas <code>a<\/code> or 1. Modifier keys such as <code>SHIFT<\/code>, <code>CONTROL<\/code>, and the arrow keys\nwill be ignored:<\/p>\n<pre><code class=\"language-js\">function keyTyped() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The <a href=\"#\/p5\/key\">key<\/a> and <a href=\"#\/p5\/keyCode\">keyCode<\/a>\nvariables will be updated with the most recently released value when\n<code>keyTyped()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function keyTyped() {\n  \/\/ Check for the \"c\" character using key.\n  if (key === 'c') {\n    \/\/ Code to run.\n  }\n\n  \/\/ Check for \"c\" using keyCode.\n  if (keyCode === 67) {\n    \/\/ Code to run.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>keyTyped()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/KeyboardEvent\" target=\"_blank\">KeyboardEvent<\/a>\nobject with properties that describe the key press event:<\/p>\n<pre><code class=\"language-js\">function keyReleased(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>Note: Use the <a href=\"#\/p5\/keyPressed\">keyPressed()<\/a> function and\n<a href=\"#\/p5\/keyCode\">keyCode<\/a> system variable to respond to modifier\nkeys such as <code>ALT<\/code>.<\/p>\n<p>Browsers may have default behaviors attached to various key events. To\nprevent any default behavior for this event, add <code>return false;<\/code> to the end\nof the function.<\/p>\n","itemtype":"method","name":"keyTyped","params":[{"name":"event","description":"<p>optional <code>KeyboardEvent<\/code> callback argument.<\/p>\n","type":"KeyboardEvent","optional":true}],"example":["\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\/\/ Note: Pressing special keys such as SPACE have no effect.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a white square at its center. The inner square changes color when the user presses a key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle the square's color when the user types a printable key.\nfunction keyTyped() {\n  if (value === 0) {\n    value = 255;\n  } else {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a white square at its center. The inner square turns black when the user types the \"b\" key. It turns white when the user types the \"a\" key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Reassign value when the user types the 'a' or 'b' key.\nfunction keyTyped() {\n  if (key === 'a') {\n    value = 255;\n  } else if (key === 'b') {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/keyboard.js","line":801,"description":"<p>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.<\/p>\n","class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/keyboard.js","line":811,"description":"<p>Returns <code>true<\/code> if the key it\u2019s checking is pressed and <code>false<\/code> if not.<\/p>\n<p><code>keyIsDown()<\/code> is helpful when checking for multiple different key presses.\nFor example, <code>keyIsDown()<\/code> can be used to check if both <code>LEFT_ARROW<\/code> and\n<code>UP_ARROW<\/code> are pressed:<\/p>\n<pre><code class=\"language-js\">if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {\n  \/\/ Move diagonally.\n}\n<\/code><\/pre>\n<p><code>keyIsDown()<\/code> can check for key presses using\n<a href=\"#\/p5\/keyCode\">keyCode<\/a> values, as in <code>keyIsDown(37)<\/code> or\n<code>keyIsDown(LEFT_ARROW)<\/code>. Key codes can be found on websites such as\n<a href=\"https:\/\/keycode.info\" target=\"_blank\">keycode.info<\/a>.<\/p>\n","itemtype":"method","name":"keyIsDown","params":[{"name":"code","description":"<p>key to check.<\/p>\n","type":"Number"}],"return":{"description":"whether the key is down or not.","type":"Boolean"},"example":["\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe(\n    'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.'\n  );\n}\n\nfunction draw() {\n  \/\/ Update x and y if an arrow key is pressed.\n  if (keyIsDown(LEFT_ARROW) === true) {\n    x -= 1;\n  }\n\n  if (keyIsDown(RIGHT_ARROW) === true) {\n    x += 1;\n  }\n\n  if (keyIsDown(UP_ARROW) === true) {\n    y -= 1;\n  }\n\n  if (keyIsDown(DOWN_ARROW) === true) {\n    y += 1;\n  }\n\n  \/\/ Style the circle.\n  fill(0);\n\n  \/\/ Draw the circle.\n  circle(x, y, 5);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click on the canvas to begin detecting key presses.\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe(\n    'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.'\n  );\n}\n\nfunction draw() {\n  \/\/ Update x and y if an arrow key is pressed.\n  if (keyIsDown(37) === true) {\n    x -= 1;\n  }\n\n  if (keyIsDown(39) === true) {\n    x += 1;\n  }\n\n  if (keyIsDown(38) === true) {\n    y -= 1;\n  }\n\n  if (keyIsDown(40) === true) {\n    y += 1;\n  }\n\n  \/\/ Style the circle.\n  fill(0);\n\n  \/\/ Draw the circle.\n  circle(x, y, 5);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Keyboard"},{"file":"src\/events\/mouse.js","line":12,"description":"<p>A <code>Number<\/code> system variable that tracks the mouse's horizontal movement.<\/p>\n<p><code>movedX<\/code> tracks how many pixels the mouse moves left or right between\nframes. <code>movedX<\/code> will have a negative value if the mouse moves left between\nframes and a positive value if it moves right. <code>movedX<\/code> can be calculated\nas <code>mouseX - pmouseX<\/code>.<\/p>\n<p>Note: <code>movedX<\/code> continues updating even when\n<a href=\"#\/p5\/requestPointerLock\">requestPointerLock()<\/a> is active.\nBut keep in mind that during an active pointer lock, mouseX and pmouseX\nare locked, so <code>movedX<\/code> is based on\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\/movementX\">the MouseEvent's movementX value<\/a>\n(which may behave differently in different browsers when the user\nis zoomed in or out).<\/p>\n","itemtype":"property","name":"movedX","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. The text \">>\" appears when the user moves the mouse to the right. The text \"<<\" appears when the user moves the mouse to the left.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display >> when movedX is positive and\n  \/\/ << when it's negative.\n  if (movedX > 0) {\n    text('>>', 50, 50);\n  } else if (movedX < 0) {\n    text('<<', 50, 50);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":62,"description":"<p>A <code>Number<\/code> system variable that tracks the mouse's vertical movement.<\/p>\n<p><code>movedY<\/code> tracks how many pixels the mouse moves up or down between\nframes. <code>movedY<\/code> will have a negative value if the mouse moves up between\nframes and a positive value if it moves down. <code>movedY<\/code> can be calculated\nas <code>mouseY - pmouseY<\/code>.<\/p>\n<p>Note: <code>movedY<\/code> continues updating even when\n<a href=\"#\/p5\/requestPointerLock\">requestPointerLock()<\/a> is active.\nBut keep in mind that during an active pointer lock, mouseX and pmouseX\nare locked, so <code>movedX<\/code> is based on\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\/movementX\">the MouseEvent's movementX value<\/a>\n(which may behave differently in different browsers when the user\nis zoomed in or out).<\/p>\n","itemtype":"property","name":"movedY","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. The text \"\u25b2\" appears when the user moves the mouse upward. The text \"\u25bc\" appears when the user moves the mouse downward.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display \u25bc when movedY is positive and\n  \/\/ \u25b2 when it's negative.\n  if (movedY > 0) {\n    text('\u25bc', 50, 50);\n  } else if (movedY < 0) {\n    text('\u25b2', 50, 50);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":119,"description":"<p>A <code>Number<\/code> system variable that tracks the mouse's horizontal position.<\/p>\n<p><code>mouseX<\/code> keeps track of the mouse's position relative to the\ntop-left corner of the canvas. For example, if the mouse is 50 pixels from\nthe left edge of the canvas, then <code>mouseX<\/code> will be 50.<\/p>\n<p>If touch is used instead of the mouse, then <code>mouseX<\/code> will hold the\nx-coordinate of the most recent touch point.<\/p>\n","itemtype":"property","name":"mouseX","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A vertical black line moves left and right following the mouse's x-position.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a vertical line that follows the mouse's x-coordinate.\n  line(mouseX, 0, mouseX, 100);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the mouse's coordinates.\n  text(`x: ${mouseX} y: ${mouseY}`, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\"A vertical black line moves left and right following the mouse's x-position.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Adjust coordinates for WebGL mode.\n  \/\/ The origin (0, 0) is at the center of the canvas.\n  let mx = mouseX - 50;\n\n  \/\/ Draw the line.\n  line(mx, -50, mx, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet font;\n\n\/\/ Load a font for WebGL mode.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    \"A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse.\"\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the mouse's coordinates.\n  text(`x: ${mouseX} y: ${mouseY}`, 0, 0);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":226,"description":"<p>A <code>Number<\/code> system variable that tracks the mouse's vertical position.<\/p>\n<p><code>mouseY<\/code> keeps track of the mouse's position relative to the\ntop-left corner of the canvas. For example, if the mouse is 50 pixels from\nthe top edge of the canvas, then <code>mouseY<\/code> will be 50.<\/p>\n<p>If touch is used instead of the mouse, then <code>mouseY<\/code> will hold the\ny-coordinate of the most recent touch point.<\/p>\n","itemtype":"property","name":"mouseY","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A horizontal black line moves up and down following the mouse's y-position.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a horizontal line that follows the mouse's y-coordinate.\n  line(0, mouseY, 100, mouseY);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the mouse's coordinates.\n  text(`x: ${mouseX} y: ${mouseY}`, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\"A horizontal black line moves up and down following the mouse's y-position.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Adjust coordinates for WebGL mode.\n  \/\/ The origin (0, 0) is at the center of the canvas.\n  let my = mouseY - 50;\n\n  \/\/ Draw the line.\n  line(-50, my, 50, my);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet font;\n\n\/\/ Load a font for WebGL mode.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    \"A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse.\"\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the mouse's coordinates.\n  text(`x: ${mouseX} y: ${mouseY}`, 0, 0);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":333,"description":"<p>A <code>Number<\/code> system variable that tracks the mouse's previous horizontal\nposition.<\/p>\n<p><code>pmouseX<\/code> keeps track of the mouse's position relative to the\ntop-left corner of the canvas. Its value is\n<a href=\"#\/p5\/mouseX\">mouseX<\/a> from the previous frame. For example, if\nthe mouse was 50 pixels from the left edge of the canvas during the last\nframe, then <code>pmouseX<\/code> will be 50.<\/p>\n<p>If touch is used instead of the mouse, then <code>pmouseX<\/code> will hold the\nx-coordinate of the last touch point.<\/p>\n<p>Note: <code>pmouseX<\/code> is reset to the current <a href=\"#\/p5\/mouseX\">mouseX<\/a>\nvalue at the start of each touch event.<\/p>\n","itemtype":"property","name":"pmouseX","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(10);\n\n  describe('A line follows the mouse as it moves. The line grows longer with faster movements.');\n}\n\nfunction draw() {\n  background(200);\n\n  line(pmouseX, pmouseY, mouseX, mouseY);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A line follows the mouse as it moves. The line grows longer with faster movements.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Adjust coordinates for WebGL mode.\n  \/\/ The origin (0, 0) is at the center of the canvas.\n  let pmx = pmouseX - 50;\n  let pmy = pmouseY - 50;\n  let mx = mouseX - 50;\n  let my = mouseY - 50;\n\n  \/\/ Draw the line.\n  line(pmx, pmy, mx, my);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":398,"description":"<p>A <code>Number<\/code> system variable that tracks the mouse's previous vertical\nposition.<\/p>\n<p><code>pmouseY<\/code> keeps track of the mouse's position relative to the\ntop-left corner of the canvas. Its value is\n<a href=\"#\/p5\/mouseY\">mouseY<\/a> from the previous frame. For example, if\nthe mouse was 50 pixels from the top edge of the canvas during the last\nframe, then <code>pmouseY<\/code> will be 50.<\/p>\n<p>If touch is used instead of the mouse, then <code>pmouseY<\/code> will hold the\ny-coordinate of the last touch point.<\/p>\n<p>Note: <code>pmouseY<\/code> is reset to the current <a href=\"#\/p5\/mouseY\">mouseY<\/a>\nvalue at the start of each touch event.<\/p>\n","itemtype":"property","name":"pmouseY","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(10);\n\n  describe('A line follows the mouse as it moves. The line grows longer with faster movements.');\n}\n\nfunction draw() {\n  background(200);\n\n  line(pmouseX, pmouseY, mouseX, mouseY);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A line follows the mouse as it moves. The line grows longer with faster movements.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Adjust coordinates for WebGL mode.\n  \/\/ The origin (0, 0) is at the center of the canvas.\n  let pmx = pmouseX - 50;\n  let pmy = pmouseY - 50;\n  let mx = mouseX - 50;\n  let my = mouseY - 50;\n\n  \/\/ Draw the line.\n  line(pmx, pmy, mx, my);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":463,"description":"<p>A <code>Number<\/code> variable that tracks the mouse's horizontal position within the\nbrowser.<\/p>\n<p><code>winMouseX<\/code> keeps track of the mouse's position relative to the top-left\ncorner of the browser window. For example, if the mouse is 50 pixels from\nthe left edge of the browser, then <code>winMouseX<\/code> will be 50.<\/p>\n<p>On a touchscreen device, <code>winMouseX<\/code> will hold the x-coordinate of the most\nrecent touch point.<\/p>\n<p>Note: Use <a href=\"#\/p5\/mouseX\">mouseX<\/a> to track the mouse\u2019s\nx-coordinate within the canvas.<\/p>\n","itemtype":"property","name":"winMouseX","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the mouse's coordinates within the browser window.\n  text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":504,"description":"<p>A <code>Number<\/code> variable that tracks the mouse's vertical position within the\nbrowser.<\/p>\n<p><code>winMouseY<\/code> keeps track of the mouse's position relative to the top-left\ncorner of the browser window. For example, if the mouse is 50 pixels from\nthe top edge of the browser, then <code>winMouseY<\/code> will be 50.<\/p>\n<p>On a touchscreen device, <code>winMouseY<\/code> will hold the y-coordinate of the most\nrecent touch point.<\/p>\n<p>Note: Use <a href=\"#\/p5\/mouseY\">mouseY<\/a> to track the mouse\u2019s\ny-coordinate within the canvas.<\/p>\n","itemtype":"property","name":"winMouseY","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the mouse's coordinates within the browser window.\n  text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":545,"description":"<p>A <code>Number<\/code> variable that tracks the mouse's previous horizontal position\nwithin the browser.<\/p>\n<p><code>pwinMouseX<\/code> keeps track of the mouse's position relative to the top-left\ncorner of the browser window. Its value is\n<a href=\"#\/p5\/winMouseX\">winMouseX<\/a> from the previous frame. For\nexample, if the mouse was 50 pixels from\nthe left edge of the browser during the last frame, then <code>pwinMouseX<\/code> will\nbe 50.<\/p>\n<p>On a touchscreen device, <code>pwinMouseX<\/code> will hold the x-coordinate of the most\nrecent touch point. <code>pwinMouseX<\/code> is reset to the current\n<a href=\"#\/p5\/winMouseX\">winMouseX<\/a> value at the start of each touch\nevent.<\/p>\n<p>Note: Use <a href=\"#\/p5\/pmouseX\">pmouseX<\/a> to track the mouse\u2019s previous\nx-coordinate within the canvas.<\/p>\n","itemtype":"property","name":"pwinMouseX","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(10);\n\n  describe('A gray square. A white circle at its center grows larger when the mouse moves horizontally.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the circle's diameter.\n  let d = winMouseX - pwinMouseX;\n\n  \/\/ Draw the circle.\n  circle(50, 50, d);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Create the canvas and set its position.\n  let cnv = createCanvas(100, 100);\n  cnv.position(20, 20);\n\n  describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display pwinMouseX.\n  text(pwinMouseX, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":616,"description":"<p>A <code>Number<\/code> variable that tracks the mouse's previous vertical position\nwithin the browser.<\/p>\n<p><code>pwinMouseY<\/code> keeps track of the mouse's position relative to the top-left\ncorner of the browser window. Its value is\n<a href=\"#\/p5\/winMouseY\">winMouseY<\/a> from the previous frame. For\nexample, if the mouse was 50 pixels from\nthe top edge of the browser during the last frame, then <code>pwinMouseY<\/code> will\nbe 50.<\/p>\n<p>On a touchscreen device, <code>pwinMouseY<\/code> will hold the y-coordinate of the most\nrecent touch point. <code>pwinMouseY<\/code> is reset to the current\n<a href=\"#\/p5\/winMouseY\">winMouseY<\/a> value at the start of each touch\nevent.<\/p>\n<p>Note: Use <a href=\"#\/p5\/pmouseY\">pmouseY<\/a> to track the mouse\u2019s previous\ny-coordinate within the canvas.<\/p>\n","itemtype":"property","name":"pwinMouseY","type":"Number","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(10);\n\n  describe('A gray square. A white circle at its center grows larger when the mouse moves vertically.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the circle's diameter.\n  let d = winMouseY - pwinMouseY;\n\n  \/\/ Draw the circle.\n  circle(50, 50, d);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Create the canvas and set its position.\n  let cnv = createCanvas(100, 100);\n  cnv.position(20, 20);\n\n  describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display pwinMouseY.\n  text(pwinMouseY, 50, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":687,"description":"<p>A String system variable that contains the value of the last mouse button\npressed.<\/p>\n<p>The <code>mouseButton<\/code> variable is either <code>LEFT<\/code>, <code>RIGHT<\/code>, or <code>CENTER<\/code>,\ndepending on which button was pressed last.<\/p>\n<p>Note: Different browsers may track <code>mouseButton<\/code> differently. See\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\/buttons\" target=\"_blank\">MDN<\/a>\nfor more information.<\/p>\n","itemtype":"property","name":"mouseButton","type":"Constant","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with black text at its center. The text changes from 0 to either \"left\" or \"right\" when the user clicks a mouse button.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the mouse button.\n  text(mouseButton, 50, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    \"A gray square. Different shapes appear at its center depending on the mouse button that's clicked.\"\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (mouseIsPressed === true) {\n    if (mouseButton === LEFT) {\n      circle(50, 50, 50);\n    }\n    if (mouseButton === RIGHT) {\n      square(25, 25, 50);\n    }\n    if (mouseButton === CENTER) {\n      triangle(23, 75, 50, 20, 78, 75);\n    }\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":755,"description":"<p>A <code>Boolean<\/code> system variable that's <code>true<\/code> if the mouse is pressed and\n<code>false<\/code> if not.<\/p>\n","itemtype":"property","name":"mouseIsPressed","type":"Boolean","readonly":"","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with the word \"false\" at its center. The word changes to \"true\" when the user presses a mouse button.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the mouseIsPressed variable.\n  text(mouseIsPressed, 25, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a white square at its center. The inner square turns black when the user presses the mouse.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  if (mouseIsPressed === true) {\n    fill(0);\n  } else {\n    fill(255);\n  }\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":896,"description":"<p>A function that's called when the mouse moves.<\/p>\n<p>Declaring the function <code>mouseMoved()<\/code> sets a code block to run\nautomatically when the user moves the mouse without clicking any mouse\nbuttons:<\/p>\n<pre><code class=\"language-js\">function mouseMoved() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The mouse system variables, such as <a href=\"#\/p5\/mouseX\">mouseX<\/a> and\n<a href=\"#\/p5\/mouseY\">mouseY<\/a>, will be updated with their most recent\nvalue when <code>mouseMoved()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function mouseMoved() {\n  if (mouseX < 50) {\n    \/\/ Code to run if the mouse is on the left.\n  }\n\n  if (mouseY > 50) {\n    \/\/ Code to run if the mouse is near the bottom.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>mouseMoved()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\" target=\"_blank\">MouseEvent<\/a>\nobject with properties that describe the mouse move event:<\/p>\n<pre><code class=\"language-js\">function mouseMoved(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>Browsers may have default behaviors attached to various mouse events. For\nexample, some browsers highlight text when the user moves the mouse while\npressing a mouse button. To prevent any default behavior for this event,\nadd <code>return false;<\/code> to the end of the function.<\/p>\n","itemtype":"method","name":"mouseMoved","params":[{"name":"event","description":"<p>optional <code>MouseEvent<\/code> argument.<\/p>\n","type":"MouseEvent","optional":true}],"example":["\n<div>\n<code>\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square becomes lighter as the mouse moves.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\nfunction mouseMoved() {\n  \/\/ Update the grayscale value.\n  value += 5;\n\n  \/\/ Reset the grayscale value.\n  if (value > 255) {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":982,"description":"<p>A function that's called when the mouse moves while a button is pressed.<\/p>\n<p>Declaring the function <code>mouseDragged()<\/code> sets a code block to run\nautomatically when the user clicks and drags the mouse:<\/p>\n<pre><code class=\"language-js\">function mouseDragged() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The mouse system variables, such as <a href=\"#\/p5\/mouseX\">mouseX<\/a> and\n<a href=\"#\/p5\/mouseY\">mouseY<\/a>, will be updated with their most recent\nvalue when <code>mouseDragged()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function mouseDragged() {\n  if (mouseX < 50) {\n    \/\/ Code to run if the mouse is on the left.\n  }\n\n  if (mouseY > 50) {\n    \/\/ Code to run if the mouse is near the bottom.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>mouseDragged()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\" target=\"_blank\">MouseEvent<\/a>\nobject with properties that describe the mouse drag event:<\/p>\n<pre><code class=\"language-js\">function mouseDragged(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, <code>mouseDragged()<\/code> will run when a user moves a touch\npoint if <a href=\"#\/p5\/touchMoved\">touchMoved()<\/a> isn\u2019t declared. If\n<a href=\"#\/p5\/touchMoved\">touchMoved()<\/a> is declared, then\n<a href=\"#\/p5\/touchMoved\">touchMoved()<\/a> will run when a user moves a\ntouch point and <code>mouseDragged()<\/code> won\u2019t.<\/p>\n<p>Browsers may have default behaviors attached to various mouse events. For\nexample, some browsers highlight text when the user moves the mouse while\npressing a mouse button. To prevent any default behavior for this event,\nadd <code>return false;<\/code> to the end of the function.<\/p>\n","itemtype":"method","name":"mouseDragged","params":[{"name":"event","description":"<p>optional <code>MouseEvent<\/code> argument.<\/p>\n","type":"MouseEvent","optional":true}],"example":["\n<div>\n<code>\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square becomes lighter as the user drags the mouse.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\nfunction mouseDragged() {\n  \/\/ Update the grayscale value.\n  value += 5;\n\n  \/\/ Reset the grayscale value.\n  if (value > 255) {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":1098,"description":"<p>A function that's called once when a mouse button is pressed.<\/p>\n<p>Declaring the function <code>mousePressed()<\/code> sets a code block to run\nautomatically when the user presses a mouse button:<\/p>\n<pre><code class=\"language-js\">function mousePressed() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The mouse system variables, such as <a href=\"#\/p5\/mouseX\">mouseX<\/a> and\n<a href=\"#\/p5\/mouseY\">mouseY<\/a>, will be updated with their most recent\nvalue when <code>mousePressed()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function mousePressed() {\n  if (mouseX < 50) {\n    \/\/ Code to run if the mouse is on the left.\n  }\n\n  if (mouseY > 50) {\n    \/\/ Code to run if the mouse is near the bottom.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>mousePressed()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\" target=\"_blank\">MouseEvent<\/a>\nobject with properties that describe the mouse press event:<\/p>\n<pre><code class=\"language-js\">function mousePressed(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, <code>mousePressed()<\/code> will run when a user\u2019s touch\nbegins if <a href=\"#\/p5\/touchStarted\">touchStarted()<\/a> isn\u2019t declared. If\n<a href=\"#\/p5\/touchStarted\">touchStarted()<\/a> is declared, then\n<a href=\"#\/p5\/touchStarted\">touchStarted()<\/a> will run when a user\u2019s touch\nbegins and <code>mousePressed()<\/code> won\u2019t.<\/p>\n<p>Browsers may have default behaviors attached to various mouse events. For\nexample, some browsers highlight text when the user moves the mouse while\npressing a mouse button. To prevent any default behavior for this event,\nadd <code>return false;<\/code> to the end of the function.<\/p>\n<p>Note: <code>mousePressed()<\/code>, <a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a>,\nand <a href=\"#\/p5\/mouseClicked\">mouseClicked()<\/a> are all related.\n<code>mousePressed()<\/code> runs as soon as the user clicks the mouse.\n<a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a> runs as soon as the user\nreleases the mouse click. <a href=\"#\/p5\/mouseClicked\">mouseClicked()<\/a>\nruns immediately after <a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a>.<\/p>\n","itemtype":"method","name":"mousePressed","params":[{"name":"event","description":"<p>optional <code>MouseEvent<\/code> argument.<\/p>\n","type":"MouseEvent","optional":true}],"example":["\n<div>\n<code>\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square becomes lighter when the user presses a mouse button.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\nfunction mousePressed() {\n  \/\/ Update the grayscale value.\n  value += 5;\n\n  \/\/ Reset the grayscale value.\n  if (value > 255) {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Style the circle.\n  fill('orange');\n  stroke('royalblue');\n  strokeWeight(10);\n\n  describe(\n    'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.'\n  );\n}\n\nfunction draw() {\n  background(220);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 20);\n}\n\n\/\/ Set the stroke color and weight as soon as the user clicks.\nfunction mousePressed() {\n  stroke('deeppink');\n  strokeWeight(3);\n}\n\n\/\/ Set the stroke and fill colors as soon as the user releases\n\/\/ the mouse.\nfunction mouseReleased() {\n  stroke('royalblue');\n\n  \/\/ This is never visible because fill() is called\n  \/\/ in mouseClicked() which runs immediately after\n  \/\/ mouseReleased();\n  fill('limegreen');\n}\n\n\/\/ Set the fill color and stroke weight after\n\/\/ mousePressed() and mouseReleased() are called.\nfunction mouseClicked() {\n  fill('orange');\n  strokeWeight(10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":1270,"description":"<p>A function that's called once when a mouse button is released.<\/p>\n<p>Declaring the function <code>mouseReleased()<\/code> sets a code block to run\nautomatically when the user releases a mouse button after having pressed\nit:<\/p>\n<pre><code class=\"language-js\">function mouseReleased() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The mouse system variables, such as <a href=\"#\/p5\/mouseX\">mouseX<\/a> and\n<a href=\"#\/p5\/mouseY\">mouseY<\/a>, will be updated with their most recent\nvalue when <code>mouseReleased()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function mouseReleased() {\n  if (mouseX < 50) {\n    \/\/ Code to run if the mouse is on the left.\n  }\n\n  if (mouseY > 50) {\n    \/\/ Code to run if the mouse is near the bottom.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>mouseReleased()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\" target=\"_blank\">MouseEvent<\/a>\nobject with properties that describe the mouse release event:<\/p>\n<pre><code class=\"language-js\">function mouseReleased(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, <code>mouseReleased()<\/code> will run when a user\u2019s touch\nends if <a href=\"#\/p5\/touchEnded\">touchEnded()<\/a> isn\u2019t declared. If\n<a href=\"#\/p5\/touchEnded\">touchEnded()<\/a> is declared, then\n<a href=\"#\/p5\/touchEnded\">touchEnded()<\/a> will run when a user\u2019s touch\nends and <code>mouseReleased()<\/code> won\u2019t.<\/p>\n<p>Browsers may have default behaviors attached to various mouse events. For\nexample, some browsers highlight text when the user moves the mouse while\npressing a mouse button. To prevent any default behavior for this event,\nadd <code>return false;<\/code> to the end of the function.<\/p>\n<p>Note: <a href=\"#\/p5\/mousePressed\">mousePressed()<\/a>, <code>mouseReleased()<\/code>,\nand <a href=\"#\/p5\/mouseClicked\">mouseClicked()<\/a> are all related.\n<a href=\"#\/p5\/mousePressed\">mousePressed()<\/a> runs as soon as the user\nclicks the mouse. <code>mouseReleased()<\/code> runs as soon as the user releases the\nmouse click. <a href=\"#\/p5\/mouseClicked\">mouseClicked()<\/a> runs\nimmediately after <code>mouseReleased()<\/code>.<\/p>\n","itemtype":"method","name":"mouseReleased","params":[{"name":"event","description":"<p>optional <code>MouseEvent<\/code> argument.<\/p>\n","type":"MouseEvent","optional":true}],"example":["\n<div>\n<code>\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square becomes lighter when the user presses and releases a mouse button.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\nfunction mouseReleased() {\n  \/\/ Update the grayscale value.\n  value += 5;\n\n  \/\/ Reset the grayscale value.\n  if (value > 255) {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Style the circle.\n  fill('orange');\n  stroke('royalblue');\n  strokeWeight(10);\n\n  describe(\n    'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.'\n  );\n}\n\nfunction draw() {\n  background(220);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 20);\n}\n\n\/\/ Set the stroke color and weight as soon as the user clicks.\nfunction mousePressed() {\n  stroke('deeppink');\n  strokeWeight(3);\n}\n\n\/\/ Set the stroke and fill colors as soon as the user releases\n\/\/ the mouse.\nfunction mouseReleased() {\n  stroke('royalblue');\n\n  \/\/ This is never visible because fill() is called\n  \/\/ in mouseClicked() which runs immediately after\n  \/\/ mouseReleased();\n  fill('limegreen');\n}\n\n\/\/ Set the fill color and stroke weight after\n\/\/ mousePressed() and mouseReleased() are called.\nfunction mouseClicked() {\n  fill('orange');\n  strokeWeight(10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":1443,"description":"<p>A function that's called once after a mouse button is pressed and released.<\/p>\n<p>Declaring the function <code>mouseClicked()<\/code> sets a code block to run\nautomatically when the user releases a mouse button after having pressed\nit:<\/p>\n<pre><code class=\"language-js\">function mouseClicked() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The mouse system variables, such as <a href=\"#\/p5\/mouseX\">mouseX<\/a> and\n<a href=\"#\/p5\/mouseY\">mouseY<\/a>, will be updated with their most recent\nvalue when <code>mouseClicked()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function mouseClicked() {\n  if (mouseX < 50) {\n    \/\/ Code to run if the mouse is on the left.\n  }\n\n  if (mouseY > 50) {\n    \/\/ Code to run if the mouse is near the bottom.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>mouseClicked()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\" target=\"_blank\">MouseEvent<\/a>\nobject with properties that describe the mouse click event:<\/p>\n<pre><code class=\"language-js\">function mouseClicked(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, <code>mouseClicked()<\/code> will run when a user\u2019s touch\nends if <a href=\"#\/p5\/touchEnded\">touchEnded()<\/a> isn\u2019t declared. If\n<a href=\"#\/p5\/touchEnded\">touchEnded()<\/a> is declared, then\n<a href=\"#\/p5\/touchEnded\">touchEnded()<\/a> will run when a user\u2019s touch\nends and <code>mouseClicked()<\/code> won\u2019t.<\/p>\n<p>Browsers may have default behaviors attached to various mouse events. For\nexample, some browsers highlight text when the user moves the mouse while\npressing a mouse button. To prevent any default behavior for this event,\nadd <code>return false;<\/code> to the end of the function.<\/p>\n<p>Note: <a href=\"#\/p5\/mousePressed\">mousePressed()<\/a>,\n<a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a>,\nand <code>mouseClicked()<\/code> are all related.\n<a href=\"#\/p5\/mousePressed\">mousePressed()<\/a> runs as soon as the user\nclicks the mouse. <a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a> runs as\nsoon as the user releases the mouse click. <code>mouseClicked()<\/code> runs\nimmediately after <a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a>.<\/p>\n","itemtype":"method","name":"mouseClicked","params":[{"name":"event","description":"<p>optional <code>MouseEvent<\/code> argument.<\/p>\n","type":"MouseEvent","optional":true}],"example":["\n<div>\n<code>\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square changes color when the user presses and releases a mouse button.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle the square's color when the user clicks.\nfunction mouseClicked() {\n  if (value === 0) {\n    value = 255;\n  } else {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Style the circle.\n  fill('orange');\n  stroke('royalblue');\n  strokeWeight(10);\n\n  describe(\n    'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.'\n  );\n}\n\nfunction draw() {\n  background(220);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 20);\n}\n\n\/\/ Set the stroke color and weight as soon as the user clicks.\nfunction mousePressed() {\n  stroke('deeppink');\n  strokeWeight(3);\n}\n\n\/\/ Set the stroke and fill colors as soon as the user releases\n\/\/ the mouse.\nfunction mouseReleased() {\n  stroke('royalblue');\n\n  \/\/ This is never visible because fill() is called\n  \/\/ in mouseClicked() which runs immediately after\n  \/\/ mouseReleased();\n  fill('limegreen');\n}\n\n\/\/ Set the fill color and stroke weight after\n\/\/ mousePressed() and mouseReleased() are called.\nfunction mouseClicked() {\n  fill('orange');\n  strokeWeight(10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":1599,"description":"<p>A function that's called once when a mouse button is clicked twice quickly.<\/p>\n<p>Declaring the function <code>doubleClicked()<\/code> sets a code block to run\nautomatically when the user presses and releases the mouse button twice\nquickly:<\/p>\n<pre><code class=\"language-js\">function doubleClicked() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The mouse system variables, such as <a href=\"#\/p5\/mouseX\">mouseX<\/a> and\n<a href=\"#\/p5\/mouseY\">mouseY<\/a>, will be updated with their most recent\nvalue when <code>doubleClicked()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function doubleClicked() {\n  if (mouseX < 50) {\n    \/\/ Code to run if the mouse is on the left.\n  }\n\n  if (mouseY > 50) {\n    \/\/ Code to run if the mouse is near the bottom.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>doubleClicked()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\" target=\"_blank\">MouseEvent<\/a>\nobject with properties that describe the double-click event:<\/p>\n<pre><code class=\"language-js\">function doubleClicked(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, code placed in <code>doubleClicked()<\/code> will run after two\ntouches that occur within a short time.<\/p>\n<p>Browsers may have default behaviors attached to various mouse events. For\nexample, some browsers highlight text when the user moves the mouse while\npressing a mouse button. To prevent any default behavior for this event,\nadd <code>return false;<\/code> to the end of the function.<\/p>\n","itemtype":"method","name":"doubleClicked","params":[{"name":"event","description":"<p>optional <code>MouseEvent<\/code> argument.<\/p>\n","type":"MouseEvent","optional":true}],"example":["\n<div>\n<code>\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square changes color when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle the square's color when the user double-clicks.\nfunction doubleClicked() {\n  if (value === 0) {\n    value = 255;\n  } else {\n    value = 0;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black circle at its center. When the user double-clicks on the circle, it changes color to white.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the circle.\n  fill(value);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 80);\n}\n\n\/\/ Reassign value to 255 when the user double-clicks on the circle.\nfunction doubleClicked() {\n  if (dist(50, 50, mouseX, mouseY) < 40) {\n    value = 255;\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":1746,"description":"<p>A function that's called once when the mouse wheel moves.<\/p>\n<p>Declaring the function <code>mouseWheel()<\/code> sets a code block to run\nautomatically when the user scrolls with the mouse wheel:<\/p>\n<pre><code class=\"language-js\">function mouseWheel() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The mouse system variables, such as <a href=\"#\/p5\/mouseX\">mouseX<\/a> and\n<a href=\"#\/p5\/mouseY\">mouseY<\/a>, will be updated with their most recent\nvalue when <code>mouseWheel()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function mouseWheel() {\n  if (mouseX < 50) {\n    \/\/ Code to run if the mouse is on the left.\n  }\n\n  if (mouseY > 50) {\n    \/\/ Code to run if the mouse is near the bottom.\n  }\n}\n<\/code><\/pre>\n<p>The parameter, <code>event<\/code>, is optional. <code>mouseWheel()<\/code> is always passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MouseEvent\" target=\"_blank\">MouseEvent<\/a>\nobject with properties that describe the mouse scroll event:<\/p>\n<pre><code class=\"language-js\">function mouseWheel(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>The <code>event<\/code> object has many properties including <code>delta<\/code>, a <code>Number<\/code>\ncontaining the distance that the user scrolled. For example, <code>event.delta<\/code>\nmight have the value 5 when the user scrolls up. <code>event.delta<\/code> is positive\nif the user scrolls up and negative if they scroll down. The signs are\nopposite on macOS with \"natural\" scrolling enabled.<\/p>\n<p>Browsers may have default behaviors attached to various mouse events. For\nexample, some browsers highlight text when the user moves the mouse while\npressing a mouse button. To prevent any default behavior for this event,\nadd <code>return false;<\/code> to the end of the function.<\/p>\n<p>Note: On Safari, <code>mouseWheel()<\/code> may only work as expected if\n<code>return false;<\/code> is added at the end of the function.<\/p>\n","itemtype":"method","name":"mouseWheel","params":[{"name":"event","description":"<p>optional <code>WheelEvent<\/code> argument.<\/p>\n","type":"WheelEvent","optional":true}],"example":["\n<div>\n<code>\nlet circleSize = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. A white circle at its center grows up when the user scrolls the mouse wheel.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the circle\n  circle(50, 50, circleSize);\n}\n\n\/\/ Increment circleSize when the user scrolls the mouse wheel.\nfunction mouseWheel() {\n  circleSize += 1;\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet direction = '';\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. An arrow at its center points up when the user scrolls up. The arrow points down when the user scrolls down.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Draw an arrow that points where\n  \/\/ the mouse last scrolled.\n  text(direction, 50, 50);\n}\n\n\/\/ Change direction when the user scrolls the mouse wheel.\nfunction mouseWheel(event) {\n  if (event.delta > 0) {\n    direction = '\u25b2';\n  } else {\n    direction = '\u25bc';\n  }\n  \/\/ Uncomment to prevent any default behavior.\n  \/\/ return false;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":1880,"description":"<p>Locks the mouse pointer to its current position and makes it invisible.<\/p>\n<p><code>requestPointerLock()<\/code> allows the mouse to move forever without leaving the\nscreen. Calling <code>requestPointerLock()<\/code> locks the values of\n<a href=\"#\/p5\/mouseX\">mouseX<\/a>, <a href=\"#\/p5\/mouseY\">mouseY<\/a>,\n<a href=\"#\/p5\/pmouseX\">pmouseX<\/a>, and <a href=\"#\/p5\/pmouseY\">pmouseY<\/a>.\n<a href=\"#\/p5\/movedX\">movedX<\/a> and <a href=\"#\/p5\/movedY\">movedY<\/a>\ncontinue updating and can be used to get the distance the mouse moved since\nthe last frame was drawn. Calling\n<a href=\"#\/p5\/exitPointerLock\">exitPointerLock()<\/a> resumes updating the\nmouse system variables.<\/p>\n<p>Note: Most browsers require an input, such as a click, before calling\n<code>requestPointerLock()<\/code>. It\u2019s recommended to call <code>requestPointerLock()<\/code> in\nan event function such as <a href=\"#\/p5\/doubleClicked\">doubleClicked()<\/a>.<\/p>\n","itemtype":"method","name":"requestPointerLock","example":["\n<div>\n<code>\nlet score = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with the text \"Score: X\" at its center. The score increases when the user moves the mouse upward. It decreases when the user moves the mouse downward.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Update the score.\n  score -= movedY;\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the score.\n  text(`Score: ${score}`, 50, 50);\n}\n\n\/\/ Lock the pointer when the user double-clicks.\nfunction doubleClicked() {\n  requestPointerLock();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/mouse.js","line":1946,"description":"<p>Exits a pointer lock started with\n<a href=\"#\/p5\/requestPointerLock\">requestPointerLock<\/a>.<\/p>\n<p>Calling <code>requestPointerLock()<\/code> locks the values of\n<a href=\"#\/p5\/mouseX\">mouseX<\/a>, <a href=\"#\/p5\/mouseY\">mouseY<\/a>,\n<a href=\"#\/p5\/pmouseX\">pmouseX<\/a>, and <a href=\"#\/p5\/pmouseY\">pmouseY<\/a>.\nCalling <code>exitPointerLock()<\/code> resumes updating the mouse system variables.<\/p>\n<p>Note: Most browsers require an input, such as a click, before calling\n<code>requestPointerLock()<\/code>. It\u2019s recommended to call <code>requestPointerLock()<\/code> in\nan event function such as <a href=\"#\/p5\/doubleClicked\">doubleClicked()<\/a>.<\/p>\n","itemtype":"method","name":"exitPointerLock","example":["\n<div>\n<code>\nlet isLocked = false;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a word at its center. The word changes between \"Unlocked\" and \"Locked\" when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Tell the user whether the pointer is locked.\n  if (isLocked === true) {\n    text('Locked', 50, 50);\n  } else {\n    text('Unlocked', 50, 50);\n  }\n}\n\n\/\/ Toggle the pointer lock when the user double-clicks.\nfunction doubleClicked() {\n  if (isLocked === true) {\n    exitPointerLock();\n    isLocked = false;\n  } else {\n    requestPointerLock();\n    isLocked = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Mouse"},{"file":"src\/events\/touch.js","line":10,"description":"<p>An <code>Array<\/code> of all the current touch points on a touchscreen device.<\/p>\n<p>The <code>touches<\/code> array is empty by default. When the user touches their\nscreen, a new touch point is tracked and added to the array. Touch points\nare <code>Objects<\/code> with the following properties:<\/p>\n<pre><code class=\"language-js\">\/\/ Iterate over the touches array.\nfor (let touch of touches) {\n  \/\/ x-coordinate relative to the top-left\n  \/\/ corner of the canvas.\n  console.log(touch.x);\n\n  \/\/ y-coordinate relative to the top-left\n  \/\/ corner of the canvas.\n  console.log(touch.y);\n\n  \/\/ x-coordinate relative to the top-left\n  \/\/ corner of the browser.\n  console.log(touch.winX);\n\n  \/\/ y-coordinate relative to the top-left\n  \/\/ corner of the browser.\n  console.log(touch.winY);\n\n  \/\/ ID number\n  console.log(touch.id);\n}\n<\/code><\/pre>\n","itemtype":"property","name":"touches","type":"Object[]","readonly":"","example":["\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. White circles appear where the user touches the square.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a circle at each touch point.\n  for (let touch of touches) {\n    circle(touch.x, touch.y, 40);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square. Labels appear where the user touches the square, displaying the coordinates.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a label above each touch point.\n  for (let touch of touches) {\n    text(`${touch.x}, ${touch.y}`, touch.x, touch.y - 40);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src\/events\/touch.js","line":125,"description":"<p>A function that's called once each time the user touches the screen.<\/p>\n<p>Declaring a function called <code>touchStarted()<\/code> sets a code block to run\nautomatically each time the user begins touching a touchscreen device:<\/p>\n<pre><code class=\"language-js\">function touchStarted() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The <a href=\"#\/p5\/touches\">touches<\/a> array will be updated with the most\nrecent touch points when <code>touchStarted()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function touchStarted() {\n  \/\/ Paint over the background.\n  background(200);\n\n  \/\/ Mark each touch point once with a circle.\n  for (let touch of touches) {\n    circle(touch.x, touch.y, 40);\n  }\n}\n<\/code><\/pre>\n<p>The parameter, event, is optional. <code>touchStarted()<\/code> will be passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/TouchEvent\" target=\"_blank\">TouchEvent<\/a>\nobject with properties that describe the touch event:<\/p>\n<pre><code class=\"language-js\">function touchStarted(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, <a href=\"#\/p5\/mousePressed\">mousePressed()<\/a> will\nrun when a user\u2019s touch starts if <code>touchStarted()<\/code> isn\u2019t declared. If\n<code>touchStarted()<\/code> is declared, then <code>touchStarted()<\/code> will run when a user\u2019s\ntouch starts and <a href=\"#\/p5\/mousePressed\">mousePressed()<\/a> won\u2019t.<\/p>\n<p>Note: <code>touchStarted()<\/code>, <a href=\"#\/p5\/touchEnded\">touchEnded()<\/a>, and\n<a href=\"#\/p5\/touchMoved\">touchMoved()<\/a> are all related.\n<code>touchStarted()<\/code> runs as soon as the user touches a touchscreen device.\n<a href=\"#\/p5\/touchEnded\">touchEnded()<\/a> runs as soon as the user ends a\ntouch. <a href=\"#\/p5\/touchMoved\">touchMoved()<\/a> runs repeatedly as the\nuser moves any touch points.<\/p>\n","itemtype":"method","name":"touchStarted","params":[{"name":"event","description":"<p>optional <code>TouchEvent<\/code> argument.<\/p>\n","type":"TouchEvent","optional":true}],"example":["\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square switches color between black and white each time the user touches the screen.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle colors with each touch.\nfunction touchStarted() {\n  if (value === 0) {\n    value = 255;\n  } else {\n    value = 0;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nlet bgColor = 50;\nlet fillColor = 255;\nlet borderWidth = 0.5;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.'\n  );\n}\n\nfunction draw() {\n  background(bgColor);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  fill(0);\n  noStroke();\n\n  \/\/ Display the number of touch points.\n  text(touches.length, 50, 20);\n\n  \/\/ Style the touch points.\n  fill(fillColor);\n  stroke(0);\n  strokeWeight(borderWidth);\n\n  \/\/ Display the touch points as circles.\n  for (let touch of touches) {\n    circle(touch.x, touch.y, 40);\n  }\n}\n\n\/\/ Set the background color to a random grayscale value.\nfunction touchStarted() {\n  bgColor = random(80, 255);\n}\n\n\/\/ Set the fill color to a random grayscale value.\nfunction touchEnded() {\n  fillColor = random(0, 255);\n}\n\n\/\/ Set the stroke weight.\nfunction touchMoved() {\n  \/\/ Increment the border width.\n  borderWidth += 0.1;\n\n  \/\/ Reset the border width once it's too thick.\n  if (borderWidth > 20) {\n    borderWidth = 0.5;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src\/events\/touch.js","line":295,"description":"<p>A function that's called when the user touches the screen and moves.<\/p>\n<p>Declaring the function <code>touchMoved()<\/code> sets a code block to run\nautomatically when the user touches a touchscreen device and moves:<\/p>\n<pre><code class=\"language-js\">function touchMoved() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The <a href=\"#\/p5\/touches\">touches<\/a> array will be updated with the most\nrecent touch points when <code>touchMoved()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function touchMoved() {\n  \/\/ Paint over the background.\n  background(200);\n\n  \/\/ Mark each touch point while the user moves.\n  for (let touch of touches) {\n    circle(touch.x, touch.y, 40);\n  }\n}\n<\/code><\/pre>\n<p>The parameter, event, is optional. <code>touchMoved()<\/code> will be passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/TouchEvent\" target=\"_blank\">TouchEvent<\/a>\nobject with properties that describe the touch event:<\/p>\n<pre><code class=\"language-js\">function touchMoved(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, <a href=\"#\/p5\/mouseDragged\">mouseDragged()<\/a> will\nrun when the user\u2019s touch points move if <code>touchMoved()<\/code> isn\u2019t declared. If\n<code>touchMoved()<\/code> is declared, then <code>touchMoved()<\/code> will run when a user\u2019s\ntouch points move and <a href=\"#\/p5\/mouseDragged\">mouseDragged()<\/a> won\u2019t.<\/p>\n<p>Note: <a href=\"#\/p5\/touchStarted\">touchStarted()<\/a>,\n<a href=\"#\/p5\/touchEnded\">touchEnded()<\/a>, and\n<code>touchMoved()<\/code> are all related.\n<a href=\"#\/p5\/touchStarted\">touchStarted()<\/a> runs as soon as the user\ntouches a touchscreen device. <a href=\"#\/p5\/touchEnded\">touchEnded()<\/a>\nruns as soon as the user ends a touch. <code>touchMoved()<\/code> runs repeatedly as\nthe user moves any touch points.<\/p>\n","itemtype":"method","name":"touchMoved","params":[{"name":"event","description":"<p>optional TouchEvent argument.<\/p>\n","type":"TouchEvent","optional":true}],"example":["\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square becomes lighter when the user touches the screen and moves.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\nfunction touchMoved() {\n  \/\/ Update the grayscale value.\n  value += 5;\n\n  \/\/ Reset the grayscale value.\n  if (value > 255) {\n    value = 0;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nlet bgColor = 50;\nlet fillColor = 255;\nlet borderWidth = 0.5;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.'\n  );\n}\n\nfunction draw() {\n  background(bgColor);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  fill(0);\n  noStroke();\n\n  \/\/ Display the number of touch points.\n  text(touches.length, 50, 20);\n\n  \/\/ Style the touch points.\n  fill(fillColor);\n  stroke(0);\n  strokeWeight(borderWidth);\n\n  \/\/ Display the touch points as circles.\n  for (let touch of touches) {\n    circle(touch.x, touch.y, 40);\n  }\n}\n\n\/\/ Set the background color to a random grayscale value.\nfunction touchStarted() {\n  bgColor = random(80, 255);\n}\n\n\/\/ Set the fill color to a random grayscale value.\nfunction touchEnded() {\n  fillColor = random(0, 255);\n}\n\n\/\/ Set the stroke weight.\nfunction touchMoved() {\n  \/\/ Increment the border width.\n  borderWidth += 0.1;\n\n  \/\/ Reset the border width once it's too thick.\n  if (borderWidth > 20) {\n    borderWidth = 0.5;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src\/events\/touch.js","line":468,"description":"<p>A function that's called once each time a screen touch ends.<\/p>\n<p>Declaring the function <code>touchEnded()<\/code> sets a code block to run\nautomatically when the user stops touching a touchscreen device:<\/p>\n<pre><code class=\"language-js\">function touchEnded() {\n  \/\/ Code to run.\n}\n<\/code><\/pre>\n<p>The <a href=\"#\/p5\/touches\">touches<\/a> array will be updated with the most\nrecent touch points when <code>touchEnded()<\/code> is called by p5.js:<\/p>\n<pre><code class=\"language-js\">function touchEnded() {\n  \/\/ Paint over the background.\n  background(200);\n\n  \/\/ Mark each remaining touch point when the user stops\n  \/\/ a touch.\n  for (let touch of touches) {\n    circle(touch.x, touch.y, 40);\n  }\n}\n<\/code><\/pre>\n<p>The parameter, event, is optional. <code>touchEnded()<\/code> will be passed a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/TouchEvent\" target=\"_blank\">TouchEvent<\/a>\nobject with properties that describe the touch event:<\/p>\n<pre><code class=\"language-js\">function touchEnded(event) {\n  \/\/ Code to run that uses the event.\n  console.log(event);\n}\n<\/code><\/pre>\n<p>On touchscreen devices, <a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a> will\nrun when the user\u2019s touch ends if <code>touchEnded()<\/code> isn\u2019t declared. If\n<code>touchEnded()<\/code> is declared, then <code>touchEnded()<\/code> will run when a user\u2019s\ntouch ends and <a href=\"#\/p5\/mouseReleased\">mouseReleased()<\/a> won\u2019t.<\/p>\n<p>Note: <a href=\"#\/p5\/touchStarted\">touchStarted()<\/a>,\n<code>touchEnded()<\/code>, and <a href=\"#\/p5\/touchMoved\">touchMoved()<\/a> are all\nrelated. <a href=\"#\/p5\/touchStarted\">touchStarted()<\/a> runs as soon as the\nuser touches a touchscreen device. <code>touchEnded()<\/code> runs as soon as the user\nends a touch. <a href=\"#\/p5\/touchMoved\">touchMoved()<\/a> runs repeatedly as\nthe user moves any touch points.<\/p>\n","itemtype":"method","name":"touchEnded","params":[{"name":"event","description":"<p>optional <code>TouchEvent<\/code> argument.<\/p>\n","type":"TouchEvent","optional":true}],"example":["\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nlet value = 0;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with a black square at its center. The inner square switches color between black and white each time the user stops touching the screen.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the square.\n  fill(value);\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n}\n\n\/\/ Toggle colors when a touch ends.\nfunction touchEnded() {\n  if (value === 0) {\n    value = 255;\n  } else {\n    value = 0;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ On a touchscreen device, touch the canvas using one or more fingers\n\/\/ at the same time.\n\nlet bgColor = 50;\nlet fillColor = 255;\nlet borderWidth = 0.5;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.'\n  );\n}\n\nfunction draw() {\n  background(bgColor);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  fill(0);\n  noStroke();\n\n  \/\/ Display the number of touch points.\n  text(touches.length, 50, 20);\n\n  \/\/ Style the touch points.\n  fill(fillColor);\n  stroke(0);\n  strokeWeight(borderWidth);\n\n  \/\/ Display the touch points as circles.\n  for (let touch of touches) {\n    circle(touch.x, touch.y, 40);\n  }\n}\n\n\/\/ Set the background color to a random grayscale value.\nfunction touchStarted() {\n  bgColor = random(80, 255);\n}\n\n\/\/ Set the fill color to a random grayscale value.\nfunction touchEnded() {\n  fillColor = random(0, 255);\n}\n\n\/\/ Set the stroke weight.\nfunction touchMoved() {\n  \/\/ Increment the border width.\n  borderWidth += 0.1;\n\n  \/\/ Reset the border width once it's too thick.\n  if (borderWidth > 20) {\n    borderWidth = 0.5;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Events","submodule":"Touch"},{"file":"src\/image\/filters.js","line":1,"description":"<p>This module defines the filters for use with image buffers.<\/p>\n<p>This module is basically a collection of functions stored in an object\nas opposed to modules. The functions are destructive, modifying\nthe passed in canvas rather than creating a copy.<\/p>\n<p>Generally speaking users of this module will use the Filters.apply method\non a canvas to create an effect.<\/p>\n<p>A number of functions are borrowed\/adapted from\n<a href=\"http:\/\/www.html5rocks.com\/en\/tutorials\/canvas\/imagefilters\/\">http:\/\/www.html5rocks.com\/en\/tutorials\/canvas\/imagefilters\/<\/a>\nor the java processing implementation.<\/p>\n","class":"p5","module":"Events"},{"file":"src\/image\/image.js","line":8,"description":"<p>This module defines the p5 methods for the <a href=\"#\/p5.Image\">p5.Image<\/a> class\nfor drawing images to the main display canvas.<\/p>\n","class":"p5","module":"Image","submodule":"Image"},{"file":"src\/image\/image.js","line":15,"description":"<p>Creates a new <a href=\"#\/p5.Image\">p5.Image<\/a> object.<\/p>\n<p><code>createImage()<\/code> uses the <code>width<\/code> and <code>height<\/code> parameters to set the new\n<a href=\"#\/p5.Image\">p5.Image<\/a> object's dimensions in pixels. The new\n<a href=\"#\/p5.Image\">p5.Image<\/a> can be modified by updating its\n<a href=\"#\/p5.Image\/pixels\">pixels<\/a> array or by calling its\n<a href=\"#\/p5.Image\/get\">get()<\/a> and\n<a href=\"#\/p5.Image\/set\">set()<\/a> methods. The\n<a href=\"#\/p5.Image\/loadPixels\">loadPixels()<\/a> method must be called\nbefore reading or modifying pixel values. The\n<a href=\"#\/p5.Image\/updatePixels\">updatePixels()<\/a> method must be called\nfor updates to take effect.<\/p>\n<p>Note: The new <a href=\"#\/p5.Image\">p5.Image<\/a> object is transparent by\ndefault.<\/p>\n","itemtype":"method","name":"createImage","params":[{"name":"width","description":"<p>width in pixels.<\/p>\n","type":"Integer"},{"name":"height","description":"<p>height in pixels.<\/p>\n","type":"Integer"}],"return":{"description":"new <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels into memory.\n  img.loadPixels();\n\n  \/\/ Set all the image's pixels to black.\n  for (let x = 0; x < img.width; x += 1) {\n    for (let y = 0; y < img.height; y += 1) {\n      img.set(x, y, 0);\n    }\n  }\n\n  \/\/ Update the image's pixel values.\n  img.updatePixels();\n\n  \/\/ Draw the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels into memory.\n  img.loadPixels();\n\n  \/\/ Create a color gradient.\n  for (let x = 0; x < img.width; x += 1) {\n    for (let y = 0; y < img.height; y += 1) {\n      \/\/ Calculate the transparency.\n      let a = map(x, 0, img.width, 0, 255);\n\n      \/\/ Create a p5.Color object.\n      let c = color(0, a);\n\n      \/\/ Set the pixel's color.\n      img.set(x, y, c);\n    }\n  }\n\n  \/\/ Update the image's pixels.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A square with a horizontal color gradient that transitions from gray to black.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the pixels into memory.\n  img.loadPixels();\n  \/\/ Get the current pixel density.\n  let d = pixelDensity();\n\n  \/\/ Calculate the pixel that is halfway through the image's pixel array.\n  let halfImage = 4 * (d * img.width) * (d * img.height \/ 2);\n\n  \/\/ Set half of the image's pixels to black.\n  for (let i = 0; i < halfImage; i += 4) {\n    \/\/ Red.\n    img.pixels[i] = 0;\n    \/\/ Green.\n    img.pixels[i + 1] = 0;\n    \/\/ Blue.\n    img.pixels[i + 2] = 0;\n    \/\/ Alpha.\n    img.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the image's pixels.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Image"},{"file":"src\/image\/image.js","line":153,"description":"<p>Saves the current canvas as an image.<\/p>\n<p>By default, <code>saveCanvas()<\/code> saves the canvas as a PNG image called\n<code>untitled.png<\/code>.<\/p>\n<p>The first parameter, <code>filename<\/code>, is optional. It's a string that sets the\nfile's name. If a file extension is included, as in\n<code>saveCanvas('drawing.png')<\/code>, then the image will be saved using that\nformat.<\/p>\n<p>The second parameter, <code>extension<\/code>, is also optional. It sets the files format.\nEither <code>'png'<\/code>, <code>'webp'<\/code>, or <code>'jpg'<\/code> can be used. For example, <code>saveCanvas('drawing', 'jpg')<\/code>\nsaves the canvas to a file called <code>drawing.jpg<\/code>.<\/p>\n<p>Note: The browser will either save the file immediately or prompt the user\nwith a dialogue window.<\/p>\n","itemtype":"method","name":"saveCanvas","example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n  background(255);\n\n  \/\/ Save the canvas to 'untitled.png'.\n  saveCanvas();\n\n  describe('A white square.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(255);\n\n  \/\/ Save the canvas to 'myCanvas.jpg'.\n  saveCanvas('myCanvas.jpg');\n\n  describe('A white square.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(255);\n\n  \/\/ Save the canvas to 'myCanvas.jpg'.\n  saveCanvas('myCanvas', 'jpg');\n\n  describe('A white square.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n\n  background(255);\n\n  \/\/ Save the canvas to 'untitled.png'.\n  saveCanvas(cnv);\n\n  describe('A white square.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n\n  background(255);\n\n  \/\/ Save the canvas to 'myCanvas.jpg'.\n  saveCanvas(cnv, 'myCanvas.jpg');\n\n  describe('A white square.');\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n\n  background(255);\n\n  \/\/ Save the canvas to 'myCanvas.jpg'.\n  saveCanvas(cnv, 'myCanvas', 'jpg');\n\n  describe('A white square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Image","overloads":[{"line":153,"params":[{"name":"selectedCanvas","description":"<p>reference to a\n                                                         specific HTML5 canvas element.<\/p>\n","type":"p5.Framebuffer|p5.Element|HTMLCanvasElement"},{"name":"filename","description":"<p>file name. Defaults to 'untitled'.<\/p>\n","type":"String","optional":true},{"name":"extension","description":"<p>file extension, either 'png', 'webp', or 'jpg'. Defaults to 'png'.<\/p>\n","type":"String","optional":true}]},{"line":267,"params":[{"name":"filename","description":"","type":"String","optional":true},{"name":"extension","description":"","type":"String","optional":true}]}]},{"file":"src\/image\/image.js","line":561,"description":"<p>Captures a sequence of frames from the canvas that can be saved as images.<\/p>\n<p><code>saveFrames()<\/code> creates an array of frame objects. Each frame is stored as\nan object with its file type, file name, and image data as a string. For\nexample, the first saved frame might have the following properties:<\/p>\n<p><code>{ ext: 'png', filename: 'frame0', imageData: 'data:image\/octet-stream;base64, abc123' }<\/code>.<\/p>\n<p>The first parameter, <code>filename<\/code>, sets the prefix for the file names. For\nexample, setting the prefix to <code>'frame'<\/code> would generate the image files\n<code>frame0.png<\/code>, <code>frame1.png<\/code>, and so on.<\/p>\n<p>The second parameter, <code>extension<\/code>, sets the file type to either <code>'png'<\/code> or\n<code>'jpg'<\/code>.<\/p>\n<p>The third parameter, <code>duration<\/code>, sets the duration to record in seconds.\nThe maximum duration is 15 seconds.<\/p>\n<p>The fourth parameter, <code>framerate<\/code>, sets the number of frames to record per\nsecond. The maximum frame rate value is 22. Limits are placed on <code>duration<\/code>\nand <code>framerate<\/code> to avoid using too much memory. Recording large canvases\ncan easily crash sketches or even web browsers.<\/p>\n<p>The fifth parameter, <code>callback<\/code>, is optional. If a function is passed,\nimage files won't be saved by default. The callback function can be used\nto process an array containing the data for each captured frame. The array\nof image data contains a sequence of objects with three properties for each\nframe: <code>imageData<\/code>, <code>filename<\/code>, and <code>extension<\/code>.<\/p>\n<p>Note: Frames are downloaded as individual image files by default.<\/p>\n","itemtype":"method","name":"saveFrames","params":[{"name":"filename","description":"<p>prefix of file name.<\/p>\n","type":"String"},{"name":"extension","description":"<p>file extension, either 'jpg' or 'png'.<\/p>\n","type":"String"},{"name":"duration","description":"<p>duration in seconds to record. This parameter will be constrained to be less or equal to 15.<\/p>\n","type":"Number"},{"name":"framerate","description":"<p>number of frames to save per second. This parameter will be constrained to be less or equal to 22.<\/p>\n","type":"Number"},{"name":"callback","description":"<p>callback function that will be executed\n                                 to handle the image data. This function\n                                 should accept an array as argument. The\n                                 array will contain the specified number of\n                                 frames of objects. Each object has three\n                                 properties: <code>imageData<\/code>, <code>filename<\/code>, and <code>extension<\/code>.<\/p>\n","type":"Function(Array)","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A square repeatedly changes color from blue to pink.');\n}\n\nfunction draw() {\n  let r = frameCount % 255;\n  let g = 50;\n  let b = 100;\n  background(r, g, b);\n}\n\n\/\/ Save the frames when the user presses the 's' key.\nfunction keyPressed() {\n  if (key === 's') {\n    saveFrames('frame', 'png', 1, 5);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A square repeatedly changes color from blue to pink.');\n}\n\nfunction draw() {\n  let r = frameCount % 255;\n  let g = 50;\n  let b = 100;\n  background(r, g, b);\n}\n\n\/\/ Print 5 frames when the user presses the mouse.\nfunction mousePressed() {\n  saveFrames('frame', 'png', 1, 5, printFrames);\n}\n\n\/\/ Prints an array of objects containing raw image data, filenames, and extensions.\nfunction printFrames(frames) {\n  for (let frame of frames) {\n    print(frame);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Image"},{"file":"src\/image\/loading_displaying.js","line":18,"description":"<p>Loads an image to create a <a href=\"#\/p5.Image\">p5.Image<\/a> object.<\/p>\n<p><code>loadImage()<\/code> interprets the first parameter one of three ways. If the path\nto an image file is provided, <code>loadImage()<\/code> will load it. Paths to local\nfiles should be relative, such as <code>'assets\/thundercat.jpg'<\/code>. URLs such as\n<code>'https:\/\/example.com\/thundercat.jpg'<\/code> may be blocked due to browser\nsecurity. Raw image data can also be passed as a base64 encoded image in\nthe form <code>'data:image\/png;base64,arandomsequenceofcharacters'<\/code>.<\/p>\n<p>The second parameter is optional. If a function is passed, it will be\ncalled once the image has loaded. The callback function can optionally use\nthe new <a href=\"#\/p5.Image\">p5.Image<\/a> object.<\/p>\n<p>The third parameter is also optional. If a function is passed, it will be\ncalled if the image fails to load. The callback function can optionally use\nthe event error.<\/p>\n<p>Images can take time to load. Calling <code>loadImage()<\/code> in\n<a href=\"#\/p5\/preload\">preload()<\/a> ensures images load before they're\nused in <a href=\"#\/p5\/setup\">setup()<\/a> or <a href=\"#\/p5\/draw\">draw()<\/a>.<\/p>\n","itemtype":"method","name":"loadImage","params":[{"name":"path","description":"<p>path of the image to be loaded or base64 encoded image.<\/p>\n","type":"String"},{"name":"successCallback","description":"<p>function called with\n                              <a href=\"#\/p5.Image\">p5.Image<\/a> once it\n                              loads.<\/p>\n","type":"function(p5.Image)","optional":true},{"name":"failureCallback","description":"<p>function called with event\n                              error if the image fails to load.<\/p>\n","type":"Function(Event)","optional":true}],"return":{"description":"the <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"},"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Draw the image.\n  image(img, 0, 0);\n\n  describe('Image of the underside of a white umbrella and a gridded ceiling.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Call handleImage() once the image loads.\n  loadImage('assets\/laDefense.jpg', handleImage);\n\n  describe('Image of the underside of a white umbrella and a gridded ceiling.');\n}\n\n\/\/ Display the image.\nfunction handleImage(img) {\n  image(img, 0, 0);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  \/\/ Call handleImage() once the image loads or\n  \/\/ call handleError() if an error occurs.\n  loadImage('assets\/laDefense.jpg', handleImage, handleError);\n}\n\n\/\/ Display the image.\nfunction handleImage(img) {\n  image(img, 0, 0);\n\n  describe('Image of the underside of a white umbrella and a gridded ceiling.');\n}\n\n\/\/ Log the error.\nfunction handleError(event) {\n  console.error('Oops!', event);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src\/image\/loading_displaying.js","line":204,"description":"<p>Generates a gif from a sketch and saves it to a file.<\/p>\n<p><code>saveGif()<\/code> may be called in <a href=\"#\/p5\/setup\">setup()<\/a> or at any\npoint while a sketch is running.<\/p>\n<p>The first parameter, <code>fileName<\/code>, sets the gif's file name.<\/p>\n<p>The second parameter, <code>duration<\/code>, sets the gif's duration in seconds.<\/p>\n<p>The third parameter, <code>options<\/code>, is optional. If an object is passed,\n<code>saveGif()<\/code> will use its properties to customize the gif. <code>saveGif()<\/code>\nrecognizes the properties <code>delay<\/code>, <code>units<\/code>, <code>silent<\/code>,\n<code>notificationDuration<\/code>, and <code>notificationID<\/code>.<\/p>\n","itemtype":"method","name":"saveGif","params":[{"name":"filename","description":"<p>file name of gif.<\/p>\n","type":"String"},{"name":"duration","description":"<p>duration in seconds to capture from the sketch.<\/p>\n","type":"Number"},{"name":"options","description":"<p>an object that can contain five more properties:\n                 <code>delay<\/code>, a Number specifying how much time to wait before recording;\n                 <code>units<\/code>, a String that can be either 'seconds' or 'frames'. By default it's 'seconds\u2019;\n                 <code>silent<\/code>, a Boolean that defines presence of progress notifications. By default it\u2019s <code>false<\/code>;\n                 <code>notificationDuration<\/code>, a Number that defines how long in seconds the final notification\n                 will live. By default it's <code>0<\/code>, meaning the notification will never be removed;\n                 <code>notificationID<\/code>, a String that specifies the id of the notification's DOM element. By default it\u2019s <code>'progressBar\u2019<\/code>.<\/p>\n","type":"Object","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the circle.\n  let c = frameCount % 255;\n  fill(c);\n\n  \/\/ Display the circle.\n  circle(50, 50, 25);\n}\n\n\/\/ Save a 5-second gif when the user presses the 's' key.\nfunction keyPressed() {\n  if (key === 's') {\n    saveGif('mySketch', 5);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the circle.\n  let c = frameCount % 255;\n  fill(c);\n\n  \/\/ Display the circle.\n  circle(50, 50, 25);\n}\n\n\/\/ Save a 5-second gif when the user presses the 's' key.\n\/\/ Wait 1 second after the key press before recording.\nfunction keyPressed() {\n  if (key === 's') {\n    saveGif('mySketch', 5, { delay: 1 });\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src\/image\/loading_displaying.js","line":639,"description":"<p>Helper function for loading GIF-based images<\/p>\n","class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src\/image\/loading_displaying.js","line":888,"description":"<p>Draws an image to the canvas.<\/p>\n<p>The first parameter, <code>img<\/code>, is the source image to be drawn. <code>img<\/code> can be\nany of the following objects:<\/p>\n<ul>\n<li><a href=\"#\/p5.Image\">p5.Image<\/a><\/li>\n<li><a href=\"#\/p5.Element\">p5.Element<\/a><\/li>\n<li><a href=\"#\/p5.Texture\">p5.Texture<\/a><\/li>\n<li><a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a><\/li>\n<li><a href=\"#\/p5.FramebufferTexture\">p5.FramebufferTexture<\/a><\/li>\n<\/ul>\n<p>The second and third parameters, <code>dx<\/code> and <code>dy<\/code>, set the coordinates of the\ndestination image's top left corner. See\n<a href=\"#\/p5\/imageMode\">imageMode()<\/a> for other ways to position images.<\/p>\n<p>Here's a diagram that explains how optional parameters work in <code>image()<\/code>:<\/p>\n<p><img src=\"assets\/drawImage.png\"><\/img><\/p>\n<p>The fourth and fifth parameters, <code>dw<\/code> and <code>dh<\/code>, are optional. They set the\nthe width and height to draw the destination image. By default, <code>image()<\/code>\ndraws the full source image at its original size.<\/p>\n<p>The sixth and seventh parameters, <code>sx<\/code> and <code>sy<\/code>, are also optional.\nThese coordinates define the top left corner of a subsection to draw from\nthe source image.<\/p>\n<p>The eighth and ninth parameters, <code>sw<\/code> and <code>sh<\/code>, are also optional.\nThey define the width and height of a subsection to draw from the source\nimage. By default, <code>image()<\/code> draws the full subsection that begins at\n<code>(sx, sy)<\/code> and extends to the edges of the source image.<\/p>\n<p>The ninth parameter, <code>fit<\/code>, is also optional. It enables a subsection of\nthe source image to be drawn without affecting its aspect ratio. If\n<code>CONTAIN<\/code> is passed, the full subsection will appear within the destination\nrectangle. If <code>COVER<\/code> is passed, the subsection will completely cover the\ndestination rectangle. This may have the effect of zooming into the\nsubsection.<\/p>\n<p>The tenth and eleventh parameters, <code>xAlign<\/code> and <code>yAlign<\/code>, are also\noptional. They determine how to align the fitted subsection. <code>xAlign<\/code> can\nbe set to either <code>LEFT<\/code>, <code>RIGHT<\/code>, or <code>CENTER<\/code>. <code>yAlign<\/code> can be set to\neither <code>TOP<\/code>, <code>BOTTOM<\/code>, or <code>CENTER<\/code>. By default, both <code>xAlign<\/code> and <code>yAlign<\/code>\nare set to <code>CENTER<\/code>.<\/p>\n","itemtype":"method","name":"image","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Draw the image.\n  image(img, 0, 0);\n\n  describe('An image of the underside of a white umbrella with a gridded ceiling above.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Draw the image.\n  image(img, 10, 10);\n\n  describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Draw the image 50x50.\n  image(img, 0, 0, 50, 50);\n\n  describe('An image of the underside of a white umbrella with a gridded ceiling above. The image is drawn in the top left corner of a dark gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Draw the center of the image.\n  image(img, 25, 25, 50, 50, 25, 25, 50, 50);\n\n  describe('An image of a gridded ceiling drawn in the center of a dark gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/moonwalk.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Draw the image and scale it to fit within the canvas.\n  image(img, 0, 0, width, height, 0, 0, img.width, img.height, CONTAIN);\n\n  describe('An image of an astronaut on the moon. The top and bottom borders of the image are dark gray.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  \/\/ Image is 50 x 50 pixels.\n  img = loadImage('assets\/laDefense50.png');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Draw the image and scale it to cover the canvas.\n  image(img, 0, 0, width, height, 0, 0, img.width, img.height, COVER);\n\n  describe('A pixelated image of the underside of a white umbrella with a gridded ceiling above.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Loading & Displaying","overloads":[{"line":888,"params":[{"name":"img","description":"<p>image to display.<\/p>\n","type":"p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture"},{"name":"x","description":"<p>x-coordinate of the top-left corner of the image.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the top-left corner of the image.<\/p>\n","type":"Number"},{"name":"width","description":"<p>width to draw the image.<\/p>\n","type":"Number","optional":true},{"name":"height","description":"<p>height to draw the image.<\/p>\n","type":"Number","optional":true}]},{"line":1074,"params":[{"name":"img","description":"","type":"p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture"},{"name":"dx","description":"<p>the x-coordinate of the destination\n                          rectangle in which to draw the source image<\/p>\n","type":"Number"},{"name":"dy","description":"<p>the y-coordinate of the destination\n                          rectangle in which to draw the source image<\/p>\n","type":"Number"},{"name":"dWidth","description":"<p>the width of the destination rectangle<\/p>\n","type":"Number"},{"name":"dHeight","description":"<p>the height of the destination rectangle<\/p>\n","type":"Number"},{"name":"sx","description":"<p>the x-coordinate of the subsection of the source\nimage to draw into the destination rectangle<\/p>\n","type":"Number"},{"name":"sy","description":"<p>the y-coordinate of the subsection of the source\nimage to draw into the destination rectangle<\/p>\n","type":"Number"},{"name":"sWidth","description":"<p>the width of the subsection of the\n                          source image to draw into the destination\n                          rectangle<\/p>\n","type":"Number","optional":true},{"name":"sHeight","description":"<p>the height of the subsection of the\n                           source image to draw into the destination rectangle<\/p>\n","type":"Number","optional":true},{"name":"fit","description":"<p>either CONTAIN or COVER<\/p>\n","type":"Constant","optional":true},{"name":"xAlign","description":"<p>either LEFT, RIGHT or CENTER default is CENTER<\/p>\n","type":"Constant","optional":true},{"name":"yAlign","description":"<p>either TOP, BOTTOM or CENTER default is CENTER<\/p>\n","type":"Constant","optional":true}]}]},{"file":"src\/image\/loading_displaying.js","line":1192,"description":"<p>Tints images using a color.<\/p>\n<p>The version of <code>tint()<\/code> with one parameter interprets it one of four ways.\nIf the parameter is a number, it's interpreted as a grayscale value. If the\nparameter is a string, it's interpreted as a CSS color string. An array of\n<code>[R, G, B, A]<\/code> values or a <a href=\"#\/p5.Color\">p5.Color<\/a> object can\nalso be used to set the tint color.<\/p>\n<p>The version of <code>tint()<\/code> with two parameters uses the first one as a\ngrayscale value and the second as an alpha value. For example, calling\n<code>tint(255, 128)<\/code> will make an image 50% transparent.<\/p>\n<p>The version of <code>tint()<\/code> with three parameters interprets them as RGB or\nHSB values, depending on the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The optional fourth parameter\nsets the alpha value. For example, <code>tint(255, 0, 0, 100)<\/code> will give images\na red tint and make them transparent.<\/p>\n","itemtype":"method","name":"tint","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Left image.\n  image(img, 0, 0);\n\n  \/\/ Right image.\n  \/\/ Tint with a CSS color string.\n  tint('red');\n  image(img, 50, 0);\n\n  describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Left image.\n  image(img, 0, 0);\n\n  \/\/ Right image.\n  \/\/ Tint with RGB values.\n  tint(255, 0, 0);\n  image(img, 50, 0);\n\n  describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Left.\n  image(img, 0, 0);\n\n  \/\/ Right.\n  \/\/ Tint with RGBA values.\n  tint(255, 0, 0, 100);\n  image(img, 50, 0);\n\n  describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a transparent red tint.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Left.\n  image(img, 0, 0);\n\n  \/\/ Right.\n  \/\/ Tint with grayscale and alpha values.\n  tint(255, 180);\n  image(img, 50, 0);\n\n  describe('Two images of an umbrella and a ceiling side-by-side. The image on the right is transparent.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Loading & Displaying","overloads":[{"line":1192,"params":[{"name":"v1","description":"<p>red or hue value.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue or brightness.<\/p>\n","type":"Number"},{"name":"alpha","description":"","type":"Number","optional":true}]},{"line":1318,"params":[{"name":"value","description":"<p>CSS color string.<\/p>\n","type":"String"}]},{"line":1323,"params":[{"name":"gray","description":"<p>grayscale value.<\/p>\n","type":"Number"},{"name":"alpha","description":"","type":"Number","optional":true}]},{"line":1329,"params":[{"name":"values","description":"<p>array containing the red, green, blue &\n                                alpha components of the color.<\/p>\n","type":"Number[]"}]},{"line":1335,"params":[{"name":"color","description":"<p>the tint color<\/p>\n","type":"p5.Color"}]}]},{"file":"src\/image\/loading_displaying.js","line":1345,"description":"<p>Removes the current tint set by <a href=\"#\/p5\/tint\">tint()<\/a>.<\/p>\n<p><code>noTint()<\/code> restores images to their original colors.<\/p>\n","itemtype":"method","name":"noTint","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Left.\n  \/\/ Tint with a CSS color string.\n  tint('red');\n  image(img, 0, 0);\n\n  \/\/ Right.\n  \/\/ Remove the tint.\n  noTint();\n  image(img, 50, 0);\n\n  describe('Two images of an umbrella and a ceiling side-by-side. The image on the left has a red tint.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src\/image\/loading_displaying.js","line":1395,"description":"<p>Changes the location from which images are drawn when\n<a href=\"#\/p5\/image\">image()<\/a> is called.<\/p>\n<p>By default, the first\ntwo parameters of <a href=\"#\/p5\/image\">image()<\/a> are the x- and\ny-coordinates of the image's upper-left corner. The next parameters are\nits width and height. This is the same as calling <code>imageMode(CORNER)<\/code>.<\/p>\n<p><code>imageMode(CORNERS)<\/code> also uses the first two parameters of\n<a href=\"#\/p5\/image\">image()<\/a> as the x- and y-coordinates of the image's\ntop-left corner. The third and fourth parameters are the coordinates of its\nbottom-right corner.<\/p>\n<p><code>imageMode(CENTER)<\/code> uses the first two parameters of\n<a href=\"#\/p5\/image\">image()<\/a> as the x- and y-coordinates of the image's\ncenter. The next parameters are its width and height.<\/p>\n","itemtype":"method","name":"imageMode","params":[{"name":"mode","description":"<p>either CORNER, CORNERS, or CENTER.<\/p>\n","type":"Constant"}],"example":["\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use CORNER mode.\n  imageMode(CORNER);\n\n  \/\/ Display the image.\n  image(img, 10, 10, 50, 50);\n\n  describe('A square image of a brick wall is drawn at the top left of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use CORNERS mode.\n  imageMode(CORNERS);\n\n  \/\/ Display the image.\n  image(img, 10, 10, 90, 40);\n\n  describe('An image of a brick wall is drawn on a gray square. The image is squeezed into a small rectangular area.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use CENTER mode.\n  imageMode(CENTER);\n\n  \/\/ Display the image.\n  image(img, 50, 50, 80, 80);\n\n  describe('A square image of a brick wall is drawn on a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Loading & Displaying"},{"file":"src\/image\/p5.Image.js","line":9,"description":"<p>This module defines the <a href=\"#\/p5.Image\">p5.Image<\/a> class and P5 methods for\ndrawing images to the main display canvas.<\/p>\n","class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":114,"description":"<p>The image's width in pixels.<\/p>\n","type":"{Number}","itemtype":"property","name":"width","readonly":"","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Calculate the center coordinates.\n  let x = img.width \/ 2;\n  let y = img.height \/ 2;\n\n  \/\/ Draw a circle at the image's center.\n  circle(x, y, 20);\n\n  describe('An image of a mountain landscape with a white circle drawn in the middle.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":151,"description":"<p>The image's height in pixels.<\/p>\n","type":"{Number}","itemtype":"property","name":"height","readonly":"","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Calculate the center coordinates.\n  let x = img.width \/ 2;\n  let y = img.height \/ 2;\n\n  \/\/ Draw a circle at the image's center.\n  circle(x, y, 20);\n\n  describe('An image of a mountain landscape with a white circle drawn in the middle.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":198,"description":"<p>An array containing the color of each pixel in the image.<\/p>\n<p>Colors are stored as numbers representing red, green, blue, and alpha\n(RGBA) values. <code>img.pixels<\/code> is a one-dimensional array for performance\nreasons.<\/p>\n<p>Each pixel occupies four elements in the pixels array, one for each\nRGBA value. For example, the pixel at coordinates (0, 0) stores its\nRGBA values at <code>img.pixels[0]<\/code>, <code>img.pixels[1]<\/code>, <code>img.pixels[2]<\/code>,\nand <code>img.pixels[3]<\/code>, respectively. The next pixel at coordinates (1, 0)\nstores its RGBA values at <code>img.pixels[4]<\/code>, <code>img.pixels[5]<\/code>,\n<code>img.pixels[6]<\/code>, and <code>img.pixels[7]<\/code>. And so on. The <code>img.pixels<\/code> array\nfor a 100\u00d7100 <a href=\"#\/p5.Image\">p5.Image<\/a> object has\n100 \u00d7 100 \u00d7 4 = 40,000 elements.<\/p>\n<p>Accessing the RGBA values for a pixel in the image requires a little\nmath as shown in the examples below. The\n<a href=\"#\/p5.Image\/loadPixels\">img.loadPixels()<\/a>\nmethod must be called before accessing the <code>img.pixels<\/code> array. The\n<a href=\"#\/p5.Image\/updatePixels\">img.updatePixels()<\/a> method must be\ncalled after any changes are made.<\/p>\n","itemtype":"property","name":"pixels","type":"Number[]","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels.\n  img.loadPixels();\n\n  for (let i = 0; i < img.pixels.length; i += 4) {\n    \/\/ Red.\n    img.pixels[i] = 0;\n    \/\/ Green.\n    img.pixels[i + 1] = 0;\n    \/\/ Blue.\n    img.pixels[i + 2] = 0;\n    \/\/ Alpha.\n    img.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels.\n  img.loadPixels();\n\n  \/\/ Set the pixels to red.\n  for (let i = 0; i < img.pixels.length; i += 4) {\n    \/\/ Red.\n    img.pixels[i] = 255;\n    \/\/ Green.\n    img.pixels[i + 1] = 0;\n    \/\/ Blue.\n    img.pixels[i + 2] = 0;\n    \/\/ Alpha.\n    img.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A red square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":299,"description":"<p>Gets or sets the pixel density for high pixel density displays.<\/p>\n<p>By default, the density will be set to 1.<\/p>\n<p>Call this method with no arguments to get the default density, or pass\nin a number to set the density. If a non-positive number is provided,\nit defaults to 1.<\/p>\n","itemtype":"method","name":"pixelDensity","params":[{"name":"density","description":"<p>A scaling factor for the number of pixels per\nside<\/p>\n","type":"Number","optional":true}],"return":{"description":"The current density if called without arguments, or the instance for chaining if setting density.","type":"Number"},"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":342,"description":"<p>Helper function for animating GIF-based images with time<\/p>\n","class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":373,"description":"<p>Helper fxn for sharing pixel methods<\/p>\n","class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":381,"description":"<p>Loads the current value of each pixel in the image into the <code>img.pixels<\/code>\narray.<\/p>\n<p><code>img.loadPixels()<\/code> must be called before reading or modifying pixel\nvalues.<\/p>\n","itemtype":"method","name":"loadPixels","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels.\n  img.loadPixels();\n\n  \/\/ Set the pixels to black.\n  for (let x = 0; x < img.width; x += 1) {\n    for (let y = 0; y < img.height; y += 1) {\n      img.set(x, y, 0);\n    }\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels.\n  img.loadPixels();\n\n  for (let i = 0; i < img.pixels.length; i += 4) {\n    \/\/ Red.\n    img.pixels[i] = 0;\n    \/\/ Green.\n    img.pixels[i + 1] = 0;\n    \/\/ Blue.\n    img.pixels[i + 2] = 0;\n    \/\/ Alpha.\n    img.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":462,"description":"<p>Updates the canvas with the RGBA values in the\n<a href=\"#\/p5.Image\/pixels\">img.pixels<\/a> array.<\/p>\n<p><code>img.updatePixels()<\/code> only needs to be called after changing values in\nthe <a href=\"#\/p5.Image\/pixels\">img.pixels<\/a> array. Such changes can be\nmade directly after calling\n<a href=\"#\/p5.Image\/loadPixels\">img.loadPixels()<\/a> or by calling\n<a href=\"#\/p5.Image\/set\">img.set()<\/a>.<\/p>\n<p>The optional parameters <code>x<\/code>, <code>y<\/code>, <code>width<\/code>, and <code>height<\/code> define a\nsubsection of the image to update. Doing so can improve performance in\nsome cases.<\/p>\n<p>If the image was loaded from a GIF, then calling <code>img.updatePixels()<\/code>\nwill update the pixels in current frame.<\/p>\n","itemtype":"method","name":"updatePixels","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels.\n  img.loadPixels();\n\n  \/\/ Set the pixels to black.\n  for (let x = 0; x < img.width; x += 1) {\n    for (let y = 0; y < img.height; y += 1) {\n      img.set(x, y, 0);\n    }\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Load the image's pixels.\n  img.loadPixels();\n\n  \/\/ Set the pixels to black.\n  for (let i = 0; i < img.pixels.length; i += 4) {\n    \/\/ Red.\n    img.pixels[i] = 0;\n    \/\/ Green.\n    img.pixels[i + 1] = 0;\n    \/\/ Blue.\n    img.pixels[i + 2] = 0;\n    \/\/ Alpha.\n    img.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A black square drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image","overloads":[{"line":462,"params":[{"name":"x","description":"<p>x-coordinate of the upper-left corner\n                   of the subsection to update.<\/p>\n","type":"Integer"},{"name":"y","description":"<p>y-coordinate of the upper-left corner\n                   of the subsection to update.<\/p>\n","type":"Integer"},{"name":"w","description":"<p>width of the subsection to update.<\/p>\n","type":"Integer"},{"name":"h","description":"<p>height of the subsection to update.<\/p>\n","type":"Integer"}]},{"line":555,"params":[]}]},{"file":"src\/image\/p5.Image.js","line":563,"description":"<p>Gets a pixel or a region of pixels from the image.<\/p>\n<p><code>img.get()<\/code> is easy to use but it's not as fast as\n<a href=\"#\/p5.Image\/pixels\">img.pixels<\/a>. Use\n<a href=\"#\/p5.Image\/pixels\">img.pixels<\/a> to read many pixel values.<\/p>\n<p>The version of <code>img.get()<\/code> with no parameters returns the entire image.<\/p>\n<p>The version of <code>img.get()<\/code> with two parameters, as in <code>img.get(10, 20)<\/code>,\ninterprets them as coordinates. It returns an array with the\n<code>[R, G, B, A]<\/code> values of the pixel at the given point.<\/p>\n<p>The version of <code>img.get()<\/code> with four parameters, as in\n<code>img,get(10, 20, 50, 90)<\/code>, interprets them as\ncoordinates and dimensions. The first two parameters are the coordinates\nof the upper-left corner of the subsection. The last two parameters are\nthe width and height of the subsection. It returns a subsection of the\ncanvas in a new <a href=\"#\/p5.Image\">p5.Image<\/a> object.<\/p>\n<p>Use <code>img.get()<\/code> instead of <a href=\"#\/p5\/get\">get()<\/a> to work directly\nwith images.<\/p>\n","itemtype":"method","name":"get","return":{"description":"subsection as a <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"},"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Copy the image.\n  let img2 = get();\n\n  \/\/ Display the copied image on the right.\n  image(img2, 50, 0);\n\n  describe('Two identical mountain landscapes shown side-by-side.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Get a pixel's color.\n  let c = img.get(50, 90);\n\n  \/\/ Style the square using the pixel's color.\n  fill(c);\n  noStroke();\n\n  \/\/ Draw the square.\n  square(25, 25, 50);\n\n  describe('A mountain landscape with an olive green square in its center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Copy half of the image.\n  let img2 = img.get(0, 0, img.width \/ 2, img.height \/ 2);\n\n  \/\/ Display half of the image.\n  image(img2, 50, 50);\n\n  describe('A mountain landscape drawn on top of another mountain landscape.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image","overloads":[{"line":563,"params":[{"name":"x","description":"<p>x-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"w","description":"<p>width of the subsection to be returned.<\/p>\n","type":"Number"},{"name":"h","description":"<p>height of the subsection to be returned.<\/p>\n","type":"Number"}],"return":{"description":"subsection as a <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"}},{"line":678,"params":[],"return":{"description":"whole <a href=\"#\/p5.Image\">p5.Image<\/a>","type":"p5.Image"}},{"line":682,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"}],"return":{"description":"color of the pixel at (x, y) in array format `[R, G, B, A]`.","type":"Number[]"}}]},{"file":"src\/image\/p5.Image.js","line":697,"description":"<p>Sets the color of one or more pixels within an image.<\/p>\n<p><code>img.set()<\/code> is easy to use but it's not as fast as\n<a href=\"#\/p5.Image\/pixels\">img.pixels<\/a>. Use\n<a href=\"#\/p5.Image\/pixels\">img.pixels<\/a> to set many pixel values.<\/p>\n<p><code>img.set()<\/code> interprets the first two parameters as x- and y-coordinates. It\ninterprets the last parameter as a grayscale value, a <code>[R, G, B, A]<\/code> pixel\narray, a <a href=\"#\/p5.Color\">p5.Color<\/a> object, or another\n<a href=\"#\/p5.Image\">p5.Image<\/a> object.<\/p>\n<p><a href=\"#\/p5.Image\/updatePixels\">img.updatePixels()<\/a> must be called\nafter using <code>img.set()<\/code> for changes to appear.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"x","description":"<p>x-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"a","description":"<p>grayscale value | pixel array |\n                                  <a href=\"#\/p5.Color\">p5.Color<\/a> object |\n                                  <a href=\"#\/p5.Image\">p5.Image<\/a> to copy.<\/p>\n","type":"Number|Number[]|Object"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(100, 100);\n\n  \/\/ Set four pixels to black.\n  img.set(30, 20, 0);\n  img.set(85, 20, 0);\n  img.set(85, 75, 0);\n  img.set(30, 75, 0);\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('Four black dots arranged in a square drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(100, 100);\n\n  \/\/ Create a p5.Color object.\n  let black = color(0);\n\n  \/\/ Set four pixels to black.\n  img.set(30, 20, black);\n  img.set(85, 20, black);\n  img.set(85, 75, black);\n  img.set(30, 75, black);\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('Four black dots arranged in a square drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Image object.\n  let img = createImage(66, 66);\n\n  \/\/ Draw a color gradient.\n  for (let x = 0; x < img.width; x += 1) {\n    for (let y = 0; y < img.height; y += 1) {\n      let c = map(x, 0, img.width, 0, 255);\n      img.set(x, y, c);\n    }\n  }\n\n  \/\/ Update the image.\n  img.updatePixels();\n\n  \/\/ Display the image.\n  image(img, 17, 17);\n\n  describe('A square with a horizontal color gradient from black to white drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Image object.\n  let img2 = createImage(100, 100);\n\n  \/\/ Set the blank image's pixels using the landscape.\n  img2.set(0, 0, img);\n\n  \/\/ Display the second image.\n  image(img2, 0, 0);\n\n  describe('An image of a mountain landscape.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":837,"description":"<p>Resizes the image to a given width and height.<\/p>\n<p>The image's original aspect ratio can be kept by passing 0 for either\n<code>width<\/code> or <code>height<\/code>. For example, calling <code>img.resize(50, 0)<\/code> on an image\nthat was 500 \u00d7 300 pixels will resize it to 50 \u00d7 30 pixels.<\/p>\n","itemtype":"method","name":"resize","params":[{"name":"width","description":"<p>resized image width.<\/p>\n","type":"Number"},{"name":"height","description":"<p>resized image height.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Resize the image.\n  img.resize(50, 100);\n\n  \/\/ Display the resized image.\n  image(img, 0, 0);\n\n  describe('Two images of a mountain landscape. One copy of the image is squeezed horizontally.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Resize the image, keeping the aspect ratio.\n  img.resize(0, 30);\n\n  \/\/ Display the resized image.\n  image(img, 0, 0);\n\n  describe('Two images of a mountain landscape. The small copy of the image covers the top-left corner of the larger image.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Resize the image, keeping the aspect ratio.\n  img.resize(60, 0);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('Two images of a mountain landscape. The small copy of the image covers the top-left corner of the larger image.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1006,"description":"<p>Copies pixels from a source image to this image.<\/p>\n<p>The first parameter, <code>srcImage<\/code>, is an optional\n<a href=\"#\/p5.Image\">p5.Image<\/a> object to copy. If a source image isn't\npassed, then <code>img.copy()<\/code> can copy a region of this image to another\nregion.<\/p>\n<p>The next four parameters, <code>sx<\/code>, <code>sy<\/code>, <code>sw<\/code>, and <code>sh<\/code> determine the region\nto copy from the source image. <code>(sx, sy)<\/code> is the top-left corner of the\nregion. <code>sw<\/code> and <code>sh<\/code> are the region's width and height.<\/p>\n<p>The next four parameters, <code>dx<\/code>, <code>dy<\/code>, <code>dw<\/code>, and <code>dh<\/code> determine the region\nof this image to copy into. <code>(dx, dy)<\/code> is the top-left corner of the\nregion. <code>dw<\/code> and <code>dh<\/code> are the region's width and height.<\/p>\n<p>Calling <code>img.copy()<\/code> will scale pixels from the source region if it isn't\nthe same size as the destination region.<\/p>\n","itemtype":"method","name":"copy","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Copy one region of the image to another.\n  img.copy(7, 22, 10, 10, 35, 25, 50, 50);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Outline the copied region.\n  stroke(255);\n  noFill();\n  square(7, 22, 10);\n\n  describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet mountains;\nlet bricks;\n\n\/\/ Load the images.\nfunction preload() {\n  mountains = loadImage('assets\/rockies.jpg');\n  bricks = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Calculate the center of the bricks image.\n  let x = bricks.width \/ 2;\n  let y = bricks.height \/ 2;\n\n  \/\/ Copy the bricks to the mountains image.\n  mountains.copy(bricks, 0, 0, x, y, 0, 0, x, y);\n\n  \/\/ Display the mountains image.\n  image(mountains, 0, 0);\n\n  describe('An image of a brick wall drawn at the top-left of an image of a mountain landscape.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image","overloads":[{"line":1006,"params":[{"name":"srcImage","description":"<p>source image.<\/p>\n","type":"p5.Image|p5.Element"},{"name":"sx","description":"<p>x-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sy","description":"<p>y-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sw","description":"<p>source image width.<\/p>\n","type":"Integer"},{"name":"sh","description":"<p>source image height.<\/p>\n","type":"Integer"},{"name":"dx","description":"<p>x-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dy","description":"<p>y-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dw","description":"<p>destination image width.<\/p>\n","type":"Integer"},{"name":"dh","description":"<p>destination image height.<\/p>\n","type":"Integer"}]},{"line":1094,"params":[{"name":"sx","description":"","type":"Integer"},{"name":"sy","description":"","type":"Integer"},{"name":"sw","description":"","type":"Integer"},{"name":"sh","description":"","type":"Integer"},{"name":"dx","description":"","type":"Integer"},{"name":"dy","description":"","type":"Integer"},{"name":"dw","description":"","type":"Integer"},{"name":"dh","description":"","type":"Integer"}]}]},{"file":"src\/image\/p5.Image.js","line":1109,"description":"<p>Masks part of the image with another.<\/p>\n<p><code>img.mask()<\/code> uses another <a href=\"#\/p5.Image\">p5.Image<\/a> object's\nalpha channel as the alpha channel for this image. Masks are cumulative\nand can't be removed once applied. If the mask has a different\npixel density from this image, the mask will be scaled.<\/p>\n","itemtype":"method","name":"mask","params":[{"name":"srcImage","description":"<p>source image.<\/p>\n","type":"p5.Image"}],"example":["\n<div>\n<code>\nlet photo;\nlet maskImage;\n\n\/\/ Load the images.\nfunction preload() {\n  photo = loadImage('assets\/rockies.jpg');\n  maskImage = loadImage('assets\/mask2.png');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the mask.\n  photo.mask(maskImage);\n\n  \/\/ Display the image.\n  image(photo, 0, 0);\n\n  describe('An image of a mountain landscape. The right side of the image has a faded patch of white.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1199,"description":"<p>Applies an image filter to the image.<\/p>\n<p>The preset options are:<\/p>\n<p><code>INVERT<\/code>\nInverts the colors in the image. No parameter is used.<\/p>\n<p><code>GRAY<\/code>\nConverts the image to grayscale. No parameter is used.<\/p>\n<p><code>THRESHOLD<\/code>\nConverts the image to black and white. Pixels with a grayscale value\nabove a given threshold are converted to white. The rest are converted to\nblack. The threshold must be between 0.0 (black) and 1.0 (white). If no\nvalue is specified, 0.5 is used.<\/p>\n<p><code>OPAQUE<\/code>\nSets the alpha channel to be entirely opaque. No parameter is used.<\/p>\n<p><code>POSTERIZE<\/code>\nLimits the number of colors in the image. Each color channel is limited to\nthe number of colors specified. Values between 2 and 255 are valid, but\nresults are most noticeable with lower values. The default value is 4.<\/p>\n<p><code>BLUR<\/code>\nBlurs the image. The level of blurring is specified by a blur radius. Larger\nvalues increase the blur. The default value is 4. A gaussian blur is used\nin <code>P2D<\/code> mode. A box blur is used in <code>WEBGL<\/code> mode.<\/p>\n<p><code>ERODE<\/code>\nReduces the light areas. No parameter is used.<\/p>\n<p><code>DILATE<\/code>\nIncreases the light areas. No parameter is used.<\/p>\n","itemtype":"method","name":"filter","params":[{"name":"filterType","description":"<p>either THRESHOLD, GRAY, OPAQUE, INVERT,\n                               POSTERIZE, ERODE, DILATE or BLUR.<\/p>\n","type":"Constant"},{"name":"filterParam","description":"<p>parameter unique to each filter.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the INVERT filter.\n  img.filter(INVERT);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A blue brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the GRAY filter.\n  img.filter(GRAY);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A brick wall drawn in grayscale.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the THRESHOLD filter.\n  img.filter(THRESHOLD);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A brick wall drawn in black and white.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the OPAQUE filter.\n  img.filter(OPAQUE);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A red brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the POSTERIZE filter.\n  img.filter(POSTERIZE, 3);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('An image of a red brick wall drawn with a limited color palette.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the BLUR filter.\n  img.filter(BLUR, 3);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A blurry image of a red brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the DILATE filter.\n  img.filter(DILATE);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A red brick wall with bright lines between each brick.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Apply the ERODE filter.\n  img.filter(ERODE);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('A red brick wall with faint lines between each brick.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1430,"description":"<p>Copies a region of pixels from another image into this one.<\/p>\n<p>The first parameter, <code>srcImage<\/code>, is the\n<a href=\"#\/p5.Image\">p5.Image<\/a> object to blend.<\/p>\n<p>The next four parameters, <code>sx<\/code>, <code>sy<\/code>, <code>sw<\/code>, and <code>sh<\/code> determine the region\nto blend from the source image. <code>(sx, sy)<\/code> is the top-left corner of the\nregion. <code>sw<\/code> and <code>sh<\/code> are the regions width and height.<\/p>\n<p>The next four parameters, <code>dx<\/code>, <code>dy<\/code>, <code>dw<\/code>, and <code>dh<\/code> determine the region\nof the canvas to blend into. <code>(dx, dy)<\/code> is the top-left corner of the\nregion. <code>dw<\/code> and <code>dh<\/code> are the regions width and height.<\/p>\n<p>The tenth parameter, <code>blendMode<\/code>, sets the effect used to blend the images'\ncolors. The options are <code>BLEND<\/code>, <code>DARKEST<\/code>, <code>LIGHTEST<\/code>, <code>DIFFERENCE<\/code>,\n<code>MULTIPLY<\/code>, <code>EXCLUSION<\/code>, <code>SCREEN<\/code>, <code>REPLACE<\/code>, <code>OVERLAY<\/code>, <code>HARD_LIGHT<\/code>,\n<code>SOFT_LIGHT<\/code>, <code>DODGE<\/code>, <code>BURN<\/code>, <code>ADD<\/code>, or <code>NORMAL<\/code>.<\/p>\n","itemtype":"method","name":"blend","example":["\n<div>\n<code>\nlet mountains;\nlet bricks;\n\n\/\/ Load the images.\nfunction preload() {\n  mountains = loadImage('assets\/rockies.jpg');\n  bricks = loadImage('assets\/bricks_third.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Blend the bricks image into the mountains.\n  mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, ADD);\n\n  \/\/ Display the mountains image.\n  image(mountains, 0, 0);\n\n  \/\/ Display the bricks image.\n  image(bricks, 0, 0);\n\n  describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet mountains;\nlet bricks;\n\n\/\/ Load the images.\nfunction preload() {\n  mountains = loadImage('assets\/rockies.jpg');\n  bricks = loadImage('assets\/bricks_third.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Blend the bricks image into the mountains.\n  mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST);\n\n  \/\/ Display the mountains image.\n  image(mountains, 0, 0);\n\n  \/\/ Display the bricks image.\n  image(bricks, 0, 0);\n\n  describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet mountains;\nlet bricks;\n\n\/\/ Load the images.\nfunction preload() {\n  mountains = loadImage('assets\/rockies.jpg');\n  bricks = loadImage('assets\/bricks_third.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Blend the bricks image into the mountains.\n  mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST);\n\n  \/\/ Display the mountains image.\n  image(mountains, 0, 0);\n\n  \/\/ Display the bricks image.\n  image(bricks, 0, 0);\n\n  describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.');\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image","overloads":[{"line":1430,"params":[{"name":"srcImage","description":"<p>source image<\/p>\n","type":"p5.Image"},{"name":"sx","description":"<p>x-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sy","description":"<p>y-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sw","description":"<p>source image width.<\/p>\n","type":"Integer"},{"name":"sh","description":"<p>source image height.<\/p>\n","type":"Integer"},{"name":"dx","description":"<p>x-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dy","description":"<p>y-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dw","description":"<p>destination image width.<\/p>\n","type":"Integer"},{"name":"dh","description":"<p>destination image height.<\/p>\n","type":"Integer"},{"name":"blendMode","description":"<p>the blend mode. either\n    BLEND, DARKEST, LIGHTEST, DIFFERENCE,\n    MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n    SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.<\/p>\n<p>Available blend modes are: normal | multiply | screen | overlay |\n           darken | lighten | color-dodge | color-burn | hard-light |\n           soft-light | difference | exclusion | hue | saturation |\n           color | luminosity<\/p>\n<p><a href=\"http:\/\/blogs.adobe.com\/webplatform\/2013\/01\/28\/blending-features-in-canvas\/\">http:\/\/blogs.adobe.com\/webplatform\/2013\/01\/28\/blending-features-in-canvas\/<\/a><\/p>\n","type":"Constant"}]},{"line":1556,"params":[{"name":"sx","description":"","type":"Integer"},{"name":"sy","description":"","type":"Integer"},{"name":"sw","description":"","type":"Integer"},{"name":"sh","description":"","type":"Integer"},{"name":"dx","description":"","type":"Integer"},{"name":"dy","description":"","type":"Integer"},{"name":"dw","description":"","type":"Integer"},{"name":"dh","description":"","type":"Integer"},{"name":"blendMode","description":"","type":"Constant"}]}]},{"file":"src\/image\/p5.Image.js","line":1600,"description":"<p>Saves the image to a file.<\/p>\n<p>By default, <code>img.save()<\/code> saves the image as a PNG image called\n<code>untitled.png<\/code>.<\/p>\n<p>The first parameter, <code>filename<\/code>, is optional. It's a string that sets the\nfile's name. If a file extension is included, as in\n<code>img.save('drawing.png')<\/code>, then the image will be saved using that\nformat.<\/p>\n<p>The second parameter, <code>extension<\/code>, is also optional. It sets the files format.\nEither <code>'png'<\/code> or <code>'jpg'<\/code> can be used. For example, <code>img.save('drawing', 'jpg')<\/code>\nsaves the canvas to a file called <code>drawing.jpg<\/code>.<\/p>\n<p>Note: The browser will either save the file immediately or prompt the user\nwith a dialogue window.<\/p>\n<p>The image will only be downloaded as an animated GIF if it was loaded\nfrom a GIF file. See <a href=\"#\/p5\/saveGif\">saveGif()<\/a> to create new\nGIFs.<\/p>\n","itemtype":"method","name":"save","params":[{"name":"filename","description":"<p>filename. Defaults to 'untitled'.<\/p>\n","type":"String"},{"name":"extension","description":"<p>file extension, either 'png' or 'jpg'.\n                           Defaults to 'png'.<\/p>\n","type":"String","optional":true}],"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  describe('An image of a mountain landscape. The image is downloaded when the user presses the \"s\", \"j\", or \"p\" key.');\n}\n\n\/\/ Save the image with different options when the user presses a key.\nfunction keyPressed() {\n  if (key === 's') {\n    img.save();\n  } else if (key === 'j') {\n    img.save('rockies.jpg');\n  } else if (key === 'p') {\n    img.save('rockies', 'png');\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1668,"description":"<p>Restarts an animated GIF at its first frame.<\/p>\n","itemtype":"method","name":"reset","example":["\n<div>\n<code>\nlet gif;\n\n\/\/ Load the image.\nfunction preload() {\n  gif = loadImage('assets\/arnott-wallace-wink-loop-once.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A cartoon face winks once and then freezes. Clicking resets the face and makes it wink again.');\n}\n\nfunction draw() {\n  background(255);\n\n  \/\/ Display the image.\n  image(gif, 0, 0);\n}\n\n\/\/ Reset the GIF when the user presses the mouse.\nfunction mousePressed() {\n  gif.reset();\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1716,"description":"<p>Gets the index of the current frame in an animated GIF.<\/p>\n","itemtype":"method","name":"getCurrentFrame","return":{"description":"index of the GIF's current frame.","type":"Number"},"example":["\n<div>\n<code>\nlet gif;\n\n\/\/ Load the image.\nfunction preload() {\n  gif = loadImage('assets\/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A cartoon eye repeatedly looks around, then outwards. A number displayed in the bottom-left corner increases from 0 to 124, then repeats.');\n}\n\nfunction draw() {\n  \/\/ Get the index of the current GIF frame.\n  let index = gif.getCurrentFrame();\n\n  \/\/ Display the image.\n  image(gif, 0, 0);\n\n  \/\/ Display the current frame.\n  text(index, 10, 90);\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1758,"description":"<p>Sets the current frame in an animated GIF.<\/p>\n","itemtype":"method","name":"setFrame","params":[{"name":"index","description":"<p>index of the frame to display.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet gif;\nlet frameSlider;\n\n\/\/ Load the image.\nfunction preload() {\n  gif = loadImage('assets\/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Get the index of the last frame.\n  let maxFrame = gif.numFrames() - 1;\n\n  \/\/ Create a slider to control which frame is drawn.\n  frameSlider = createSlider(0, maxFrame);\n  frameSlider.position(10, 80);\n  frameSlider.size(80);\n\n  describe('A cartoon eye looks around when a slider is moved.');\n}\n\nfunction draw() {\n  \/\/ Get the slider's value.\n  let index = frameSlider.value();\n\n  \/\/ Set the GIF's frame.\n  gif.setFrame(index);\n\n  \/\/ Display the image.\n  image(gif, 0, 0);\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1818,"description":"<p>Returns the number of frames in an animated GIF.<\/p>\n","itemtype":"method","name":"numFrames","return":{"description":"number of frames in the GIF.","type":"Number"},"example":["\n<div>\n<code>\nlet gif;\n\n\/\/ Load the image.\nfunction preload() {\n  gif = loadImage('assets\/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A cartoon eye looks around. The text \"n \/ 125\" is shown at the bottom of the canvas.');\n}\n\nfunction draw() {\n  \/\/ Display the image.\n  image(gif, 0, 0);\n\n  \/\/ Display the current state of playback.\n  let total = gif.numFrames();\n  let index = gif.getCurrentFrame();\n  text(`${index} \/ ${total}`, 30, 90);\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1858,"description":"<p>Plays an animated GIF that was paused with\n<a href=\"#\/p5.Image\/pause\">img.pause()<\/a>.<\/p>\n","itemtype":"method","name":"play","example":["\n<div>\n<code>\nlet gif;\n\n\/\/ Load the image.\nfunction preload() {\n  gif = loadImage('assets\/nancy-liang-wind-loop-forever.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A drawing of a child with hair blowing in the wind. The animation freezes when clicked and resumes when released.');\n}\n\nfunction draw() {\n  background(255);\n  image(gif, 0, 0);\n}\n\n\/\/ Pause the GIF when the user presses the mouse.\nfunction mousePressed() {\n  gif.pause();\n}\n\n\/\/ Play the GIF when the user releases the mouse.\nfunction mouseReleased() {\n  gif.play();\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1903,"description":"<p>Pauses an animated GIF.<\/p>\n<p>The GIF can be resumed by calling\n<a href=\"#\/p5.Image\/play\">img.play()<\/a>.<\/p>\n","itemtype":"method","name":"pause","example":["\n<div>\n<code>\nlet gif;\n\n\/\/ Load the image.\nfunction preload() {\n  gif = loadImage('assets\/nancy-liang-wind-loop-forever.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A drawing of a child with hair blowing in the wind. The animation freezes when clicked and resumes when released.');\n}\n\nfunction draw() {\n  background(255);\n\n  \/\/ Display the image.\n  image(gif, 0, 0);\n}\n\n\/\/ Pause the GIF when the user presses the mouse.\nfunction mousePressed() {\n  gif.pause();\n}\n\n\/\/ Play the GIF when the user presses the mouse.\nfunction mouseReleased() {\n  gif.play();\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/p5.Image.js","line":1952,"description":"<p>Changes the delay between frames in an animated GIF.<\/p>\n<p>The first parameter, <code>delay<\/code>, is the length of the delay in milliseconds.<\/p>\n<p>The second parameter, <code>index<\/code>, is optional. If provided, only the frame\nat <code>index<\/code> will have its delay modified. All other frames will keep\ntheir default delay.<\/p>\n","itemtype":"method","name":"delay","params":[{"name":"d","description":"<p>delay in milliseconds between switching frames.<\/p>\n","type":"Number"},{"name":"index","description":"<p>index of the frame that will have its delay modified.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\nlet gifFast;\nlet gifSlow;\n\n\/\/ Load the images.\nfunction preload() {\n  gifFast = loadImage('assets\/arnott-wallace-eye-loop-forever.gif');\n  gifSlow = loadImage('assets\/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Resize the images.\n  gifFast.resize(50, 50);\n  gifSlow.resize(50, 50);\n\n  \/\/ Set the delay lengths.\n  gifFast.delay(10);\n  gifSlow.delay(100);\n\n  describe('Two animated eyes looking around. The eye on the left moves faster than the eye on the right.');\n}\n\nfunction draw() {\n  \/\/ Display the images.\n  image(gifFast, 0, 0);\n  image(gifSlow, 50, 0);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet gif;\n\n\/\/ Load the image.\nfunction preload() {\n  gif = loadImage('assets\/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Set the delay of frame 67.\n  gif.delay(3000, 67);\n\n  describe('An animated eye looking around. It pauses for three seconds while it looks down.');\n}\n\nfunction draw() {\n  \/\/ Display the image.\n  image(gif, 0, 0);\n}\n<\/code>\n<\/div>"],"class":"p5.Image","module":"Image","submodule":"Image"},{"file":"src\/image\/pixels.js","line":12,"description":"<p>An array containing the color of each pixel on the canvas.<\/p>\n<p>Colors are stored as numbers representing red, green, blue, and alpha\n(RGBA) values. <code>pixels<\/code> is a one-dimensional array for performance reasons.<\/p>\n<p>Each pixel occupies four elements in the <code>pixels<\/code> array, one for each RGBA\nvalue. For example, the pixel at coordinates (0, 0) stores its RGBA values\nat <code>pixels[0]<\/code>, <code>pixels[1]<\/code>, <code>pixels[2]<\/code>, and <code>pixels[3]<\/code>, respectively.\nThe next pixel at coordinates (1, 0) stores its RGBA values at <code>pixels[4]<\/code>,\n<code>pixels[5]<\/code>, <code>pixels[6]<\/code>, and <code>pixels[7]<\/code>. And so on. The <code>pixels<\/code> array\nfor a 100\u00d7100 canvas has 100 \u00d7 100 \u00d7 4 = 40,000 elements.<\/p>\n<p>Some displays use several smaller pixels to set the color at a single\npoint. The <a href=\"#\/p5\/pixelDensity\">pixelDensity()<\/a> function returns\nthe pixel density of the canvas. High density displays often have a\n<a href=\"#\/p5\/pixelDensity\">pixelDensity()<\/a> of 2. On such a display, the\n<code>pixels<\/code> array for a 100\u00d7100 canvas has 200 \u00d7 200 \u00d7 4 =\n160,000 elements.<\/p>\n<p>Accessing the RGBA values for a point on the canvas requires a little math\nas shown below. The <a href=\"#\/p5\/loadPixels\">loadPixels()<\/a> function\nmust be called before accessing the <code>pixels<\/code> array. The\n<a href=\"#\/p5\/updatePixels\">updatePixels()<\/a> function must be called\nafter any changes are made.<\/p>\n","itemtype":"property","name":"pixels","type":"Number[]","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Load the pixels array.\n  loadPixels();\n\n  \/\/ Set the dot's coordinates.\n  let x = 50;\n  let y = 50;\n\n  \/\/ Get the pixel density.\n  let d = pixelDensity();\n\n  \/\/ Set the pixel(s) at the center of the canvas black.\n  for (let i = 0; i < d; i += 1) {\n    for (let j = 0; j < d; j += 1) {\n      let index = 4 * ((y * d + j) * width * d + (x * d + i));\n      \/\/ Red.\n      pixels[index] = 0;\n      \/\/ Green.\n      pixels[index + 1] = 0;\n      \/\/ Blue.\n      pixels[index + 2] = 0;\n      \/\/ Alpha.\n      pixels[index + 3] = 255;\n    }\n  }\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('A black dot in the middle of a gray rectangle.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Load the pixels array.\n  loadPixels();\n\n  \/\/ Get the pixel density.\n  let d = pixelDensity();\n\n  \/\/ Calculate the halfway index in the pixels array.\n  let halfImage = 4 * (d * width) * (d * height \/ 2);\n\n  \/\/ Make the top half of the canvas red.\n  for (let i = 0; i < halfImage; i += 4) {\n    \/\/ Red.\n    pixels[i] = 255;\n    \/\/ Green.\n    pixels[i + 1] = 0;\n    \/\/ Blue.\n    pixels[i + 2] = 0;\n    \/\/ Alpha.\n    pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('A red rectangle drawn above a gray rectangle.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create a p5.Color object.\n  let pink = color(255, 102, 204);\n\n  \/\/ Load the pixels array.\n  loadPixels();\n\n  \/\/ Get the pixel density.\n  let d = pixelDensity();\n\n  \/\/ Calculate the halfway index in the pixels array.\n  let halfImage = 4 * (d * width) * (d * height \/ 2);\n\n  \/\/ Make the top half of the canvas red.\n  for (let i = 0; i < halfImage; i += 4) {\n    pixels[i] = red(pink);\n    pixels[i + 1] = green(pink);\n    pixels[i + 2] = blue(pink);\n    pixels[i + 3] = alpha(pink);\n  }\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('A pink rectangle drawn above a gray rectangle.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src\/image\/pixels.js","line":148,"description":"<p>Copies a region of pixels from one image to another.<\/p>\n<p>The first parameter, <code>srcImage<\/code>, is the\n<a href=\"#\/p5.Image\">p5.Image<\/a> object to blend.<\/p>\n<p>The next four parameters, <code>sx<\/code>, <code>sy<\/code>, <code>sw<\/code>, and <code>sh<\/code> determine the region\nto blend from the source image. <code>(sx, sy)<\/code> is the top-left corner of the\nregion. <code>sw<\/code> and <code>sh<\/code> are the regions width and height.<\/p>\n<p>The next four parameters, <code>dx<\/code>, <code>dy<\/code>, <code>dw<\/code>, and <code>dh<\/code> determine the region\nof the canvas to blend into. <code>(dx, dy)<\/code> is the top-left corner of the\nregion. <code>dw<\/code> and <code>dh<\/code> are the regions width and height.<\/p>\n<p>The tenth parameter, <code>blendMode<\/code>, sets the effect used to blend the images'\ncolors. The options are <code>BLEND<\/code>, <code>DARKEST<\/code>, <code>LIGHTEST<\/code>, <code>DIFFERENCE<\/code>,\n<code>MULTIPLY<\/code>, <code>EXCLUSION<\/code>, <code>SCREEN<\/code>, <code>REPLACE<\/code>, <code>OVERLAY<\/code>, <code>HARD_LIGHT<\/code>,\n<code>SOFT_LIGHT<\/code>, <code>DODGE<\/code>, <code>BURN<\/code>, <code>ADD<\/code>, or <code>NORMAL<\/code><\/p>\n","itemtype":"method","name":"blend","example":["\n<div>\n<code>\nlet img0;\nlet img1;\n\n\/\/ Load the images.\nfunction preload() {\n  img0 = loadImage('assets\/rockies.jpg');\n  img1 = loadImage('assets\/bricks_third.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use the mountains as the background.\n  background(img0);\n\n  \/\/ Display the bricks.\n  image(img1, 0, 0);\n\n  \/\/ Display the bricks faded into the landscape.\n  blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST);\n\n  describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img0;\nlet img1;\n\n\/\/ Load the images.\nfunction preload() {\n  img0 = loadImage('assets\/rockies.jpg');\n  img1 = loadImage('assets\/bricks_third.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use the mountains as the background.\n  background(img0);\n\n  \/\/ Display the bricks.\n  image(img1, 0, 0);\n\n  \/\/ Display the bricks partially transparent.\n  blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST);\n\n  describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img0;\nlet img1;\n\n\/\/ Load the images.\nfunction preload() {\n  img0 = loadImage('assets\/rockies.jpg');\n  img1 = loadImage('assets\/bricks_third.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use the mountains as the background.\n  background(img0);\n\n  \/\/ Display the bricks.\n  image(img1, 0, 0);\n\n  \/\/ Display the bricks washed out into the landscape.\n  blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, ADD);\n\n  describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels","overloads":[{"line":148,"params":[{"name":"srcImage","description":"<p>source image.<\/p>\n","type":"p5.Image"},{"name":"sx","description":"<p>x-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sy","description":"<p>y-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sw","description":"<p>source image width.<\/p>\n","type":"Integer"},{"name":"sh","description":"<p>source image height.<\/p>\n","type":"Integer"},{"name":"dx","description":"<p>x-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dy","description":"<p>y-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dw","description":"<p>destination image width.<\/p>\n","type":"Integer"},{"name":"dh","description":"<p>destination image height.<\/p>\n","type":"Integer"},{"name":"blendMode","description":"<p>the blend mode. either\n    BLEND, DARKEST, LIGHTEST, DIFFERENCE,\n    MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n    SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.<\/p>\n","type":"Constant"}]},{"line":267,"params":[{"name":"sx","description":"","type":"Integer"},{"name":"sy","description":"","type":"Integer"},{"name":"sw","description":"","type":"Integer"},{"name":"sh","description":"","type":"Integer"},{"name":"dx","description":"","type":"Integer"},{"name":"dy","description":"","type":"Integer"},{"name":"dw","description":"","type":"Integer"},{"name":"dh","description":"","type":"Integer"},{"name":"blendMode","description":"","type":"Constant"}]}]},{"file":"src\/image\/pixels.js","line":288,"description":"<p>Copies pixels from a source image to a region of the canvas.<\/p>\n<p>The first parameter, <code>srcImage<\/code>, is the\n<a href=\"#\/p5.Image\">p5.Image<\/a> object to blend. The source image can be\nthe canvas itself or a\n<a href=\"#\/p5.Image\">p5.Image<\/a> object. <code>copy()<\/code> will scale pixels from\nthe source region if it isn't the same size as the destination region.<\/p>\n<p>The next four parameters, <code>sx<\/code>, <code>sy<\/code>, <code>sw<\/code>, and <code>sh<\/code> determine the region\nto copy from the source image. <code>(sx, sy)<\/code> is the top-left corner of the\nregion. <code>sw<\/code> and <code>sh<\/code> are the region's width and height.<\/p>\n<p>The next four parameters, <code>dx<\/code>, <code>dy<\/code>, <code>dw<\/code>, and <code>dh<\/code> determine the region\nof the canvas to copy into. <code>(dx, dy)<\/code> is the top-left corner of the\nregion. <code>dw<\/code> and <code>dh<\/code> are the region's width and height.<\/p>\n","itemtype":"method","name":"copy","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use the mountains as the background.\n  background(img);\n\n  \/\/ Copy a region of pixels to another spot.\n  copy(img, 7, 22, 10, 10, 35, 25, 50, 50);\n\n  \/\/ Outline the copied region.\n  stroke(255);\n  noFill();\n  square(7, 22, 10);\n\n  describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels","overloads":[{"line":288,"params":[{"name":"srcImage","description":"<p>source image.<\/p>\n","type":"p5.Image|p5.Element"},{"name":"sx","description":"<p>x-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sy","description":"<p>y-coordinate of the source's upper-left corner.<\/p>\n","type":"Integer"},{"name":"sw","description":"<p>source image width.<\/p>\n","type":"Integer"},{"name":"sh","description":"<p>source image height.<\/p>\n","type":"Integer"},{"name":"dx","description":"<p>x-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dy","description":"<p>y-coordinate of the destination's upper-left corner.<\/p>\n","type":"Integer"},{"name":"dw","description":"<p>destination image width.<\/p>\n","type":"Integer"},{"name":"dh","description":"<p>destination image height.<\/p>\n","type":"Integer"}]},{"line":345,"params":[{"name":"sx","description":"","type":"Integer"},{"name":"sy","description":"","type":"Integer"},{"name":"sw","description":"","type":"Integer"},{"name":"sh","description":"","type":"Integer"},{"name":"dx","description":"","type":"Integer"},{"name":"dy","description":"","type":"Integer"},{"name":"dw","description":"","type":"Integer"},{"name":"dh","description":"","type":"Integer"}]}]},{"file":"src\/image\/pixels.js","line":442,"description":"<p>Applies an image filter to the canvas.<\/p>\n<p>The preset options are:<\/p>\n<p><code>INVERT<\/code>\nInverts the colors in the image. No parameter is used.<\/p>\n<p><code>GRAY<\/code>\nConverts the image to grayscale. No parameter is used.<\/p>\n<p><code>THRESHOLD<\/code>\nConverts the image to black and white. Pixels with a grayscale value\nabove a given threshold are converted to white. The rest are converted to\nblack. The threshold must be between 0.0 (black) and 1.0 (white). If no\nvalue is specified, 0.5 is used.<\/p>\n<p><code>OPAQUE<\/code>\nSets the alpha channel to entirely opaque. No parameter is used.<\/p>\n<p><code>POSTERIZE<\/code>\nLimits the number of colors in the image. Each color channel is limited to\nthe number of colors specified. Values between 2 and 255 are valid, but\nresults are most noticeable with lower values. The default value is 4.<\/p>\n<p><code>BLUR<\/code>\nBlurs the image. The level of blurring is specified by a blur radius. Larger\nvalues increase the blur. The default value is 4. A gaussian blur is used\nin <code>P2D<\/code> mode. A box blur is used in <code>WEBGL<\/code> mode.<\/p>\n<p><code>ERODE<\/code>\nReduces the light areas. No parameter is used.<\/p>\n<p><code>DILATE<\/code>\nIncreases the light areas. No parameter is used.<\/p>\n<p><code>filter()<\/code> uses WebGL in the background by default because it's faster.\nThis can be disabled in <code>P2D<\/code> mode by adding a <code>false<\/code> argument, as in\n<code>filter(BLUR, false)<\/code>. This may be useful to keep computation off the GPU\nor to work around a lack of WebGL support.<\/p>\n<p>In WebgL mode, <code>filter()<\/code> can also use custom shaders. See\n<a href=\"#\/p5\/createFilterShader\">createFilterShader()<\/a> for more\ninformation.<\/p>\n","itemtype":"method","name":"filter","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the INVERT filter.\n  filter(INVERT);\n\n  describe('A blue brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the GRAY filter.\n  filter(GRAY);\n\n  describe('A brick wall drawn in grayscale.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the THRESHOLD filter.\n  filter(THRESHOLD);\n\n  describe('A brick wall drawn in black and white.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the OPAQUE filter.\n  filter(OPAQUE);\n\n  describe('A red brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the POSTERIZE filter.\n  filter(POSTERIZE, 3);\n\n  describe('An image of a red brick wall drawn with limited color palette.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the BLUR filter.\n  filter(BLUR, 3);\n\n  describe('A blurry image of a red brick wall.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the DILATE filter.\n  filter(DILATE);\n\n  describe('A red brick wall with bright lines between each brick.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the ERODE filter.\n  filter(ERODE);\n\n  describe('A red brick wall with faint lines between each brick.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Apply the BLUR filter.\n  \/\/ Don't use WebGL.\n  filter(BLUR, 3, false);\n\n  describe('A blurry image of a red brick wall.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels","overloads":[{"line":442,"params":[{"name":"filterType","description":"<p>either THRESHOLD, GRAY, OPAQUE, INVERT,\n                               POSTERIZE, BLUR, ERODE, DILATE or BLUR.<\/p>\n","type":"Constant"},{"name":"filterParam","description":"<p>parameter unique to each filter.<\/p>\n","type":"Number","optional":true},{"name":"useWebGL","description":"<p>flag to control whether to use fast\n                               WebGL filters (GPU) or original image\n                               filters (CPU); defaults to <code>true<\/code>.<\/p>\n","type":"Boolean","optional":true}]},{"line":715,"params":[{"name":"filterType","description":"","type":"Constant"},{"name":"useWebGL","description":"","type":"Boolean","optional":true}]},{"line":720,"params":[{"name":"shaderFilter","description":"<p>shader that's been loaded, with the\n                                  frag shader using a <code>tex0<\/code> uniform.<\/p>\n","type":"p5.Shader"}]}]},{"file":"src\/image\/pixels.js","line":820,"description":"<p>Gets a pixel or a region of pixels from the canvas.<\/p>\n<p><code>get()<\/code> is easy to use but it's not as fast as\n<a href=\"#\/p5\/pixels\">pixels<\/a>. Use <a href=\"#\/p5\/pixels\">pixels<\/a>\nto read many pixel values.<\/p>\n<p>The version of <code>get()<\/code> with no parameters returns the entire canvas.<\/p>\n<p>The version of <code>get()<\/code> with two parameters interprets them as\ncoordinates. It returns an array with the <code>[R, G, B, A]<\/code> values of the\npixel at the given point.<\/p>\n<p>The version of <code>get()<\/code> with four parameters interprets them as coordinates\nand dimensions. It returns a subsection of the canvas as a\n<a href=\"#\/p5.Image\">p5.Image<\/a> object. The first two parameters are the\ncoordinates for the upper-left corner of the subsection. The last two\nparameters are the width and height of the subsection.<\/p>\n<p>Use <a href=\"#\/p5.Image\/get\">p5.Image.get()<\/a> to work directly with\n<a href=\"#\/p5.Image\">p5.Image<\/a> objects.<\/p>\n","itemtype":"method","name":"get","return":{"description":"subsection as a <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"},"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Get the entire canvas.\n  let c = get();\n\n  \/\/ Display half the canvas.\n  image(c, 50, 0);\n\n  describe('Two identical mountain landscapes shown side-by-side.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Get the color of a pixel.\n  let c = get(50, 90);\n\n  \/\/ Style the square with the pixel's color.\n  fill(c);\n  noStroke();\n\n  \/\/ Display the square.\n  square(25, 25, 50);\n\n  describe('A mountain landscape with an olive green square in its center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0);\n\n  \/\/ Get a region of the image.\n  let c = get(0, 0, 50, 50);\n\n  \/\/ Display the region.\n  image(c, 50, 50);\n\n  describe('A mountain landscape drawn on top of another mountain landscape.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels","overloads":[{"line":820,"params":[{"name":"x","description":"<p>x-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"w","description":"<p>width of the subsection to be returned.<\/p>\n","type":"Number"},{"name":"h","description":"<p>height of the subsection to be returned.<\/p>\n","type":"Number"}],"return":{"description":"subsection as a <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"}},{"line":931,"params":[],"return":{"description":"whole canvas as a <a href=\"#\/p5.Image\">p5.Image<\/a>.","type":"p5.Image"}},{"line":935,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"}],"return":{"description":"color of the pixel at (x, y) in array format `[R, G, B, A]`.","type":"Number[]"}}]},{"file":"src\/image\/pixels.js","line":946,"description":"<p>Loads the current value of each pixel on the canvas into the\n<a href=\"#\/p5\/pixels\">pixels<\/a> array.<\/p>\n<p><code>loadPixels()<\/code> must be called before reading from or writing to\n<a href=\"#\/p5\/pixels\">pixels<\/a>.<\/p>\n","itemtype":"method","name":"loadPixels","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0, 100, 100);\n\n  \/\/ Get the pixel density.\n  let d = pixelDensity();\n\n  \/\/ Calculate the halfway index in the pixels array.\n  let halfImage = 4 * (d * width) * (d * height \/ 2);\n\n  \/\/ Load the pixels array.\n  loadPixels();\n\n  \/\/ Copy the top half of the canvas to the bottom.\n  for (let i = 0; i < halfImage; i += 1) {\n    pixels[i + halfImage] = pixels[i];\n  }\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('Two identical images of mountain landscapes, one on top of the other.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src\/image\/pixels.js","line":997,"description":"<p>Sets the color of a pixel or draws an image to the canvas.<\/p>\n<p><code>set()<\/code> is easy to use but it's not as fast as\n<a href=\"#\/p5\/pixels\">pixels<\/a>. Use <a href=\"#\/p5\/pixels\">pixels<\/a>\nto set many pixel values.<\/p>\n<p><code>set()<\/code> interprets the first two parameters as x- and y-coordinates. It\ninterprets the last parameter as a grayscale value, a <code>[R, G, B, A]<\/code> pixel\narray, a <a href=\"#\/p5.Color\">p5.Color<\/a> object, or a\n<a href=\"#\/p5.Image\">p5.Image<\/a> object. If an image is passed, the first\ntwo parameters set the coordinates for the image's upper-left corner,\nregardless of the current <a href=\"#\/p5\/imageMode\">imageMode()<\/a>.<\/p>\n<p><a href=\"#\/p5\/updatePixels\">updatePixels()<\/a> must be called after using\n<code>set()<\/code> for changes to appear.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"x","description":"<p>x-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the pixel.<\/p>\n","type":"Number"},{"name":"c","description":"<p>grayscale value | pixel array |\n                               <a href=\"#\/p5.Color\">p5.Color<\/a> object | <a href=\"#\/p5.Image\">p5.Image<\/a> to copy.<\/p>\n","type":"Number|Number[]|Object"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set four pixels to black.\n  set(30, 20, 0);\n  set(85, 20, 0);\n  set(85, 75, 0);\n  set(30, 75, 0);\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('Four black dots arranged in a square drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object.\n  let black = color(0);\n\n  \/\/ Set four pixels to black.\n  set(30, 20, black);\n  set(85, 20, black);\n  set(85, 75, black);\n  set(30, 75, black);\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('Four black dots arranged in a square drawn on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(255);\n\n  \/\/ Draw a horizontal color gradient.\n  for (let x = 0; x < 100; x += 1) {\n    for (let y = 0; y < 100; y += 1) {\n      \/\/ Calculate the grayscale value.\n      let c = map(x, 0, 100, 0, 255);\n\n      \/\/ Set the pixel using the grayscale value.\n      set(x, y, c);\n    }\n  }\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('A horizontal color gradient from black to white.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use the image to set all pixels.\n  set(0, 0, img);\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('An image of a mountain landscape.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src\/image\/pixels.js","line":1118,"description":"<p>Updates the canvas with the RGBA values in the\n<a href=\"#\/p5\/pixels\">pixels<\/a> array.<\/p>\n<p><code>updatePixels()<\/code> only needs to be called after changing values in the\n<a href=\"#\/p5\/pixels\">pixels<\/a> array. Such changes can be made directly\nafter calling <a href=\"#\/p5\/loadPixels\">loadPixels()<\/a> or by calling\n<a href=\"#\/p5\/set\">set()<\/a>.<\/p>\n","itemtype":"method","name":"updatePixels","params":[{"name":"x","description":"<p>x-coordinate of the upper-left corner of region\n                        to update.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y-coordinate of the upper-left corner of region\n                        to update.<\/p>\n","type":"Number","optional":true},{"name":"w","description":"<p>width of region to update.<\/p>\n","type":"Number","optional":true},{"name":"h","description":"<p>height of region to update.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image.\nfunction preload() {\n  img = loadImage('assets\/rockies.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Display the image.\n  image(img, 0, 0, 100, 100);\n\n  \/\/ Get the pixel density.\n  let d = pixelDensity();\n\n  \/\/ Calculate the halfway index in the pixels array.\n  let halfImage = 4 * (d * width) * (d * height \/ 2);\n\n  \/\/ Load the pixels array.\n  loadPixels();\n\n  \/\/ Copy the top half of the canvas to the bottom.\n  for (let i = 0; i < halfImage; i += 1) {\n    pixels[i + halfImage] = pixels[i];\n  }\n\n  \/\/ Update the canvas.\n  updatePixels();\n\n  describe('Two identical images of mountain landscapes, one on top of the other.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Image","submodule":"Pixels"},{"file":"src\/io\/files.js","line":17,"description":"<p>Loads a JSON file to create an <code>Object<\/code>.<\/p>\n<p>JavaScript Object Notation\n(<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/JSON\" target=\"_blank\">JSON<\/a>)\nis a standard format for sending data between applications. The format is\nbased on JavaScript objects which have keys and values. JSON files store\ndata in an object with strings as keys. Values can be strings, numbers,\nBooleans, arrays, <code>null<\/code>, or other objects.<\/p>\n<p>The first parameter, <code>path<\/code>, is always a string with the path to the file.\nPaths to local files should be relative, as in\n<code>loadJSON('assets\/data.json')<\/code>. URLs such as\n<code>'https:\/\/example.com\/data.json'<\/code> may be blocked due to browser security.<\/p>\n<p>The second parameter, <code>successCallback<\/code>, is optional. If a function is\npassed, as in <code>loadJSON('assets\/data.json', handleData)<\/code>, then the\n<code>handleData()<\/code> function will be called once the data loads. The object\ncreated from the JSON data will be passed to <code>handleData()<\/code> as its only argument.<\/p>\n<p>The third parameter, <code>failureCallback<\/code>, is also optional. If a function is\npassed, as in <code>loadJSON('assets\/data.json', handleData, handleFailure)<\/code>,\nthen the <code>handleFailure()<\/code> function will be called if an error occurs while\nloading. The <code>Error<\/code> object will be passed to <code>handleFailure()<\/code> as its only\nargument.<\/p>\n<p>Note: Data can take time to load. Calling <code>loadJSON()<\/code> within\n<a href=\"#\/p5\/preload\">preload()<\/a> ensures data loads before it's used in\n<a href=\"#\/p5\/setup\">setup()<\/a> or <a href=\"#\/p5\/draw\">draw()<\/a>.<\/p>\n","itemtype":"method","name":"loadJSON","params":[{"name":"path","description":"<p>path of the JSON file to be loaded.<\/p>\n","type":"String"},{"name":"successCallback","description":"<p>function to call once the data is loaded. Will be passed the object.<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to call if the data fails to load. Will be passed an <code>Error<\/code> event object.<\/p>\n","type":"Function","optional":true}],"return":{"description":"object containing the loaded data.","type":"Object"},"example":["\n\n<div>\n<code>\nlet myData;\n\n\/\/ Load the JSON and create an object.\nfunction preload() {\n  myData = loadJSON('assets\/data.json');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the circle.\n  fill(myData.color);\n  noStroke();\n\n  \/\/ Draw the circle.\n  circle(myData.x, myData.y, myData.d);\n\n  describe('A pink circle on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myData;\n\n\/\/ Load the JSON and create an object.\nfunction preload() {\n  myData = loadJSON('assets\/data.json');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Color object and make it transparent.\n  let c = color(myData.color);\n  c.setAlpha(80);\n\n  \/\/ Style the circles.\n  fill(c);\n  noStroke();\n\n  \/\/ Iterate over the myData.bubbles array.\n  for (let b of myData.bubbles) {\n    \/\/ Draw a circle for each bubble.\n    circle(b.x, b.y, b.d);\n  }\n\n  describe('Several pink bubbles floating in a blue sky.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myData;\n\n\/\/ Load the GeoJSON and create an object.\nfunction preload() {\n  myData = loadJSON('https:\/\/earthquake.usgs.gov\/earthquakes\/feed\/v1.0\/summary\/all_day.geojson');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get data about the most recent earthquake.\n  let quake = myData.features[0].properties;\n\n  \/\/ Draw a circle based on the earthquake's magnitude.\n  circle(50, 50, quake.mag * 10);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(11);\n\n  \/\/ Display the earthquake's location.\n  text(quake.place, 5, 80, 100);\n\n  describe(`A white circle on a gray background. The text \"${quake.place}\" is written beneath the circle.`);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet bigQuake;\n\n\/\/ Load the GeoJSON and preprocess it.\nfunction preload() {\n  loadJSON(\n    'https:\/\/earthquake.usgs.gov\/earthquakes\/feed\/v1.0\/summary\/all_day.geojson',\n    handleData\n  );\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw a circle based on the earthquake's magnitude.\n  circle(50, 50, bigQuake.mag * 10);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(11);\n\n  \/\/ Display the earthquake's location.\n  text(bigQuake.place, 5, 80, 100);\n\n  describe(`A white circle on a gray background. The text \"${bigQuake.place}\" is written beneath the circle.`);\n}\n\n\/\/ Find the biggest recent earthquake.\nfunction handleData(data) {\n  let maxMag = 0;\n  \/\/ Iterate over the earthquakes array.\n  for (let quake of data.features) {\n    \/\/ Reassign bigQuake if a larger\n    \/\/ magnitude quake is found.\n    if (quake.properties.mag > maxMag) {\n      bigQuake = quake.properties;\n    }\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet bigQuake;\n\n\/\/ Load the GeoJSON and preprocess it.\nfunction preload() {\n  loadJSON(\n    'https:\/\/earthquake.usgs.gov\/earthquakes\/feed\/v1.0\/summary\/all_day.geojson',\n    handleData,\n    handleError\n  );\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw a circle based on the earthquake's magnitude.\n  circle(50, 50, bigQuake.mag * 10);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(11);\n\n  \/\/ Display the earthquake's location.\n  text(bigQuake.place, 5, 80, 100);\n\n  describe(`A white circle on a gray background. The text \"${bigQuake.place}\" is written beneath the circle.`);\n}\n\n\/\/ Find the biggest recent earthquake.\nfunction handleData(data) {\n  let maxMag = 0;\n  \/\/ Iterate over the earthquakes array.\n  for (let quake of data.features) {\n    \/\/ Reassign bigQuake if a larger\n    \/\/ magnitude quake is found.\n    if (quake.properties.mag > maxMag) {\n      bigQuake = quake.properties;\n    }\n  }\n}\n\n\/\/ Log any errors to the console.\nfunction handleError(error) {\n  console.log('Oops!', error);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src\/io\/files.js","line":309,"description":"<p>Loads a text file to create an <code>Array<\/code>.<\/p>\n<p>The first parameter, <code>path<\/code>, is always a string with the path to the file.\nPaths to local files should be relative, as in\n<code>loadStrings('assets\/data.txt')<\/code>. URLs such as\n<code>'https:\/\/example.com\/data.txt'<\/code> may be blocked due to browser security.<\/p>\n<p>The second parameter, <code>successCallback<\/code>, is optional. If a function is\npassed, as in <code>loadStrings('assets\/data.txt', handleData)<\/code>, then the\n<code>handleData()<\/code> function will be called once the data loads. The array\ncreated from the text data will be passed to <code>handleData()<\/code> as its only\nargument.<\/p>\n<p>The third parameter, <code>failureCallback<\/code>, is also optional. If a function is\npassed, as in <code>loadStrings('assets\/data.txt', handleData, handleFailure)<\/code>,\nthen the <code>handleFailure()<\/code> function will be called if an error occurs while\nloading. The <code>Error<\/code> object will be passed to <code>handleFailure()<\/code> as its only\nargument.<\/p>\n<p>Note: Data can take time to load. Calling <code>loadStrings()<\/code> within\n<a href=\"#\/p5\/preload\">preload()<\/a> ensures data loads before it's used in\n<a href=\"#\/p5\/setup\">setup()<\/a> or <a href=\"#\/p5\/draw\">draw()<\/a>.<\/p>\n","itemtype":"method","name":"loadStrings","params":[{"name":"path","description":"<p>path of the text file to be loaded.<\/p>\n","type":"String"},{"name":"successCallback","description":"<p>function to call once the data is\n                                     loaded. Will be passed the array.<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to call if the data fails to\n                                   load. Will be passed an <code>Error<\/code> event\n                                   object.<\/p>\n","type":"Function","optional":true}],"return":{"description":"new array containing the loaded text.","type":"String[]"},"example":["\n\n<div>\n<code>\nlet myData;\n\n\/\/ Load the text and create an array.\nfunction preload() {\n  myData = loadStrings('assets\/test.txt');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Select a random line from the text.\n  let phrase = random(myData);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display the text.\n  text(phrase, 10, 50, 90);\n\n  describe(`The text \"${phrase}\" written in black on a gray background.`);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet lastLine;\n\n\/\/ Load the text and preprocess it.\nfunction preload() {\n  loadStrings('assets\/test.txt', handleData);\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display the text.\n  text(lastLine, 10, 50, 90);\n\n  describe('The text \"I talk like an orange\" written in black on a gray background.');\n}\n\n\/\/ Select the last line from the text.\nfunction handleData(data) {\n  lastLine = data[data.length - 1];\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet lastLine;\n\n\/\/ Load the text and preprocess it.\nfunction preload() {\n  loadStrings('assets\/test.txt', handleData, handleError);\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display the text.\n  text(lastLine, 10, 50, 90);\n\n  describe('The text \"I talk like an orange\" written in black on a gray background.');\n}\n\n\/\/ Select the last line from the text.\nfunction handleData(data) {\n  lastLine = data[data.length - 1];\n}\n\n\/\/ Log any errors to the console.\nfunction handleError(error) {\n  console.error('Oops!', error);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src\/io\/files.js","line":505,"description":"<p>Reads the contents of a file or URL and creates a <a href=\"#\/p5.Table\">p5.Table<\/a> 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<p>This method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. Calling <a href=\"#\/p5\/loadTable\">loadTable()<\/a> inside <a href=\"#\/p5\/preload\">preload()<\/a>\nguarantees to complete the operation before <a href=\"#\/p5\/setup\">setup()<\/a> and <a href=\"#\/p5\/draw\">draw()<\/a> are called.\nOutside of <a href=\"#\/p5\/preload\">preload()<\/a>, you may supply a callback function to handle the\nobject:<\/p>\n<p>All files loaded and saved use UTF-8 encoding. This method is suitable for fetching files up to size of 64MB.<\/p>\n","itemtype":"method","name":"loadTable","params":[{"name":"filename","description":"<p>name of the file or URL to load<\/p>\n","type":"String"},{"name":"extension","description":"<p>parse the table by comma-separated values \"csv\", semicolon-separated\n                                     values \"ssv\", or tab-separated values \"tsv\"<\/p>\n","type":"String","optional":true},{"name":"header","description":"<p>\"header\" to indicate table has header row<\/p>\n","type":"String","optional":true},{"name":"callback","description":"<p>function to be executed after\n                                     <a href=\"#\/p5\/loadTable\">loadTable()<\/a> completes. On success, the\n                                     <a href=\"#\/p5.Table\">Table<\/a> object is passed in as the\n                                     first argument.<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to be executed if\n                                     there is an error, response is passed\n                                     in as first argument<\/p>\n","type":"Function","optional":true}],"return":{"description":"<a href=\"#\/p5.Table\">Table<\/a> 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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n  \/\/the file can be remote\n  \/\/table = loadTable(\"https:\/\/p5js.org\/reference\/assets\/mammals.csv\",\n  \/\/                  \"csv\", \"header\");\n}\n\nfunction setup() {\n  \/\/count the columns\n  print(table.getRowCount() + ' total rows in table');\n  print(table.getColumnCount() + ' total columns in table');\n\n  print(table.getColumn('name'));\n  \/\/[\"Goat\", \"Leopard\", \"Zebra\"]\n\n  \/\/cycle through the table\n  for (let r = 0; r < table.getRowCount(); r++)\n    for (let c = 0; c < table.getColumnCount(); c++) {\n      print(table.getString(r, c));\n    }\n  describe(`randomly generated text from a file,\n    for example \"i smell like butter\"`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src\/io\/files.js","line":780,"description":"<p>Loads an XML file to create a <a href=\"#\/p5.XML\">p5.XML<\/a> object.<\/p>\n<p>Extensible Markup Language\n(<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/XML\/XML_introduction\" target=\"_blank\">XML<\/a>)\nis a standard format for sending data between applications. Like HTML, the\nXML format is based on tags and attributes, as in\n<code>&lt;time units=\"s\"&gt;1234&lt;\/time&gt;<\/code>.<\/p>\n<p>The first parameter, <code>path<\/code>, is always a string with the path to the file.\nPaths to local files should be relative, as in\n<code>loadXML('assets\/data.xml')<\/code>. URLs such as <code>'https:\/\/example.com\/data.xml'<\/code>\nmay be blocked due to browser security.<\/p>\n<p>The second parameter, <code>successCallback<\/code>, is optional. If a function is\npassed, as in <code>loadXML('assets\/data.xml', handleData)<\/code>, then the\n<code>handleData()<\/code> function will be called once the data loads. The\n<a href=\"#\/p5.XML\">p5.XML<\/a> object created from the data will be passed\nto <code>handleData()<\/code> as its only argument.<\/p>\n<p>The third parameter, <code>failureCallback<\/code>, is also optional. If a function is\npassed, as in <code>loadXML('assets\/data.xml', handleData, handleFailure)<\/code>, then\nthe <code>handleFailure()<\/code> function will be called if an error occurs while\nloading. The <code>Error<\/code> object will be passed to <code>handleFailure()<\/code> as its only\nargument.<\/p>\n<p>Note: Data can take time to load. Calling <code>loadXML()<\/code> within\n<a href=\"#\/p5\/preload\">preload()<\/a> ensures data loads before it's used in\n<a href=\"#\/p5\/setup\">setup()<\/a> or <a href=\"#\/p5\/draw\">draw()<\/a>.<\/p>\n","itemtype":"method","name":"loadXML","params":[{"name":"path","description":"<p>path of the XML file to be loaded.<\/p>\n","type":"String"},{"name":"successCallback","description":"<p>function to call once the data is\n                                     loaded. Will be passed the\n                                     <a href=\"#\/p5.XML\">p5.XML<\/a> object.<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to call if the data fails to\n                                   load. Will be passed an <code>Error<\/code> event\n                                   object.<\/p>\n","type":"Function","optional":true}],"return":{"description":"XML data loaded into a <a href=\"#\/p5.XML\">p5.XML<\/a>\n                 object.","type":"p5.XML"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get an array with all mammal tags.\n  let mammals = myXML.getChildren('mammal');\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Iterate over the mammals array.\n  for (let i = 0; i < mammals.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Get the mammal's common name.\n    let name = mammals[i].getContent();\n\n    \/\/ Display the mammal's name.\n    text(name, 20, y);\n  }\n\n  describe(\n    'The words \"Goat\", \"Leopard\", and \"Zebra\" written on three separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet lastMammal;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  loadXML('assets\/animals.xml', handleData);\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(16);\n\n  \/\/ Display the content of the last mammal element.\n  text(lastMammal, 50, 50);\n\n  describe('The word \"Zebra\" written in black on a gray background.');\n}\n\n\/\/ Get the content of the last mammal element.\nfunction handleData(data) {\n  \/\/ Get an array with all mammal elements.\n  let mammals = data.getChildren('mammal');\n\n  \/\/ Get the content of the last mammal.\n  lastMammal = mammals[mammals.length - 1].getContent();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet lastMammal;\n\n\/\/ Load the XML and preprocess it.\nfunction preload() {\n  loadXML('assets\/animals.xml', handleData, handleError);\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(16);\n\n  \/\/ Display the content of the last mammal element.\n  text(lastMammal, 50, 50);\n\n  describe('The word \"Zebra\" written in black on a gray background.');\n}\n\n\/\/ Get the content of the last mammal element.\nfunction handleData(data) {\n  \/\/ Get an array with all mammal elements.\n  let mammals = data.getChildren('mammal');\n\n  \/\/ Get the content of the last mammal.\n  lastMammal = mammals[mammals.length - 1].getContent();\n}\n\n\/\/ Log any errors to the console.\nfunction handleError(error) {\n  console.error('Oops!', error);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src\/io\/files.js","line":986,"description":"<p>This method is suitable for fetching files up to size of 64MB.<\/p>\n","itemtype":"method","name":"loadBytes","params":[{"name":"file","description":"<p>name of the file or URL to load<\/p>\n","type":"String"},{"name":"callback","description":"<p>function to be executed after <a href=\"#\/p5\/loadBytes\">loadBytes()<\/a>\n                                   completes<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to be executed if there\n                                   is an error<\/p>\n","type":"Function","optional":true}],"return":{"description":"an object whose 'bytes' property will be the loaded buffer","type":"Object"},"example":["\n<div class='norender'><code>\nlet data;\n\nfunction preload() {\n  data = loadBytes('assets\/mammals.xml');\n}\n\nfunction setup() {\n  for (let i = 0; i < 5; i++) {\n    console.log(data.bytes[i].toString(16));\n  }\n  describe('no image displayed');\n}\n<\/code><\/div>"],"class":"p5","module":"IO","submodule":"Input"},{"file":"src\/io\/files.js","line":1043,"description":"<p>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. This is equivalent to\ncalling <code>httpDo(path, 'GET')<\/code>. The 'binary' datatype will return\na Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer\nwhich can be used to initialize typed arrays (such as Uint8Array).<\/p>\n","itemtype":"method","name":"httpGet","return":{"description":"A promise that resolves with the data when the operation\n                  completes successfully or rejects with the error after\n                  one occurs.","type":"Promise"},"example":["\n<div class='norender'><code>\n\/\/ Examples use USGS Earthquake API:\n\/\/   https:\/\/earthquake.usgs.gov\/fdsnws\/event\/1\/#methods\nlet earthquakes;\nfunction preload() {\n  \/\/ Get the most recent earthquake in the database\n  let url =\n   'https:\/\/earthquake.usgs.gov\/fdsnws\/event\/1\/query?' +\n    'format=geojson&limit=1&orderby=time';\n  httpGet(url, 'jsonp', false, function(response) {\n    \/\/ when the HTTP request completes, populate the variable that holds the\n    \/\/ earthquake data used in the visualization.\n    earthquakes = response;\n  });\n}\n\nfunction draw() {\n  if (!earthquakes) {\n    \/\/ Wait until the earthquake data has loaded before drawing.\n    return;\n  }\n  background(200);\n  \/\/ Get the magnitude and name of the earthquake out of the loaded JSON\n  let earthquakeMag = earthquakes.features[0].properties.mag;\n  let earthquakeName = earthquakes.features[0].properties.place;\n  ellipse(width \/ 2, height \/ 2, earthquakeMag * 10, earthquakeMag * 10);\n  textAlign(CENTER);\n  text(earthquakeName, 0, height - 30, width, 30);\n  noLoop();\n}\n<\/code><\/div>"],"class":"p5","module":"IO","submodule":"Input","overloads":[{"line":1043,"params":[{"name":"path","description":"<p>name of the file or url to load<\/p>\n","type":"String"},{"name":"datatype","description":"<p>\"json\", \"jsonp\", \"binary\", \"arrayBuffer\",\n                                   \"xml\", or \"text\"<\/p>\n","type":"String","optional":true},{"name":"data","description":"<p>param data passed sent with request<\/p>\n","type":"Object|Boolean","optional":true},{"name":"callback","description":"<p>function to be executed after\n                                   <a href=\"#\/p5\/httpGet\">httpGet()<\/a> completes, data is passed in\n                                   as first argument<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to be executed if\n                                   there is an error, response is passed\n                                   in as first argument<\/p>\n","type":"Function","optional":true}],"return":{"description":"A promise that resolves with the data when the operation\n                  completes successfully or rejects with the error after\n                  one occurs.","type":"Promise"}},{"line":1097,"params":[{"name":"path","description":"","type":"String"},{"name":"data","description":"","type":"Object|Boolean"},{"name":"callback","description":"","type":"Function","optional":true},{"name":"errorCallback","description":"","type":"Function","optional":true}],"return":{"description":"","type":"Promise"}},{"line":1105,"params":[{"name":"path","description":"","type":"String"},{"name":"callback","description":"","type":"Function"},{"name":"errorCallback","description":"","type":"Function","optional":true}],"return":{"description":"","type":"Promise"}}]},{"file":"src\/io\/files.js","line":1119,"description":"<p>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. This is equivalent to\ncalling <code>httpDo(path, 'POST')<\/code>.<\/p>\n","itemtype":"method","name":"httpPost","return":{"description":"A promise that resolves with the data when the operation\n                  completes successfully or rejects with the error after\n                  one occurs.","type":"Promise"},"example":["\n<div>\n<code>\n\/\/ Examples use jsonplaceholder.typicode.com for a Mock Data API\n\nlet url = 'https:\/\/jsonplaceholder.typicode.com\/posts';\nlet postData = { userId: 1, title: 'p5 Clicked!', body: 'p5.js is very cool.' };\n\nfunction setup() {\n  createCanvas(100, 100);\n  background(200);\n}\n\nfunction mousePressed() {\n  httpPost(url, 'json', postData, function(result) {\n    strokeWeight(2);\n    text(result.body, mouseX, mouseY);\n  });\n}\n<\/code>\n<\/div>\n\n<div><code>\nlet url = 'ttps:\/\/invalidURL'; \/\/ A bad URL that will cause errors\nlet postData = { title: 'p5 Clicked!', body: 'p5.js is very cool.' };\n\nfunction setup() {\n  createCanvas(100, 100);\n  background(200);\n}\n\nfunction mousePressed() {\n  httpPost(\n    url,\n    'json',\n    postData,\n    function(result) {\n      \/\/ ... won't be called\n    },\n    function(error) {\n      strokeWeight(2);\n      text(error.toString(), mouseX, mouseY);\n    }\n  );\n}\n<\/code><\/div>"],"class":"p5","module":"IO","submodule":"Input","overloads":[{"line":1119,"params":[{"name":"path","description":"<p>name of the file or url to load<\/p>\n","type":"String"},{"name":"datatype","description":"<p>\"json\", \"jsonp\", \"xml\", or \"text\".\n                                   If omitted, <a href=\"#\/p5\/httpPost\">httpPost()<\/a> will guess.<\/p>\n","type":"String","optional":true},{"name":"data","description":"<p>param data passed sent with request<\/p>\n","type":"Object|Boolean","optional":true},{"name":"callback","description":"<p>function to be executed after\n                                   <a href=\"#\/p5\/httpPost\">httpPost()<\/a> completes, data is passed in\n                                   as first argument<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to be executed if\n                                   there is an error, response is passed\n                                   in as first argument<\/p>\n","type":"Function","optional":true}],"return":{"description":"A promise that resolves with the data when the operation\n                  completes successfully or rejects with the error after\n                  one occurs.","type":"Promise"}},{"line":1186,"params":[{"name":"path","description":"","type":"String"},{"name":"data","description":"","type":"Object|Boolean"},{"name":"callback","description":"","type":"Function","optional":true},{"name":"errorCallback","description":"","type":"Function","optional":true}],"return":{"description":"","type":"Promise"}},{"line":1194,"params":[{"name":"path","description":"","type":"String"},{"name":"callback","description":"","type":"Function"},{"name":"errorCallback","description":"","type":"Function","optional":true}],"return":{"description":"","type":"Promise"}}]},{"file":"src\/io\/files.js","line":1208,"description":"<p>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>\nFor more advanced use, you may also pass in the path as the first argument\nand a object as the second argument, the signature follows the one specified\nin the Fetch API specification.\nThis method is suitable for fetching files up to size of 64MB when \"GET\" is used.<\/p>\n","itemtype":"method","name":"httpDo","return":{"description":"A promise that resolves with the data when the operation\n                  completes successfully or rejects with the error after\n                  one occurs.","type":"Promise"},"example":["\n<div>\n<code>\n\/\/ Examples use USGS Earthquake API:\n\/\/ https:\/\/earthquake.usgs.gov\/fdsnws\/event\/1\/#methods\n\n\/\/ displays an animation of all USGS earthquakes\nlet earthquakes;\nlet eqFeatureIndex = 0;\n\nfunction preload() {\n  let url = 'https:\/\/earthquake.usgs.gov\/fdsnws\/event\/1\/query?format=geojson';\n  httpDo(\n    url,\n    {\n      method: 'GET',\n      \/\/ Other Request options, like special headers for apis\n      headers: { authorization: 'Bearer secretKey' }\n    },\n    function(res) {\n      earthquakes = res;\n    }\n  );\n}\n\nfunction draw() {\n  \/\/ wait until the data is loaded\n  if (!earthquakes || !earthquakes.features[eqFeatureIndex]) {\n    return;\n  }\n  clear();\n\n  let feature = earthquakes.features[eqFeatureIndex];\n  let mag = feature.properties.mag;\n  let rad = mag \/ 11 * ((width + height) \/ 2);\n  fill(255, 0, 0, 100);\n  ellipse(width \/ 2 + random(-2, 2), height \/ 2 + random(-2, 2), rad, rad);\n\n  if (eqFeatureIndex >= earthquakes.features.length) {\n    eqFeatureIndex = 0;\n  } else {\n    eqFeatureIndex += 1;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Input","overloads":[{"line":1208,"params":[{"name":"path","description":"<p>name of the file or url to load<\/p>\n","type":"String"},{"name":"method","description":"<p>either \"GET\", \"POST\", or \"PUT\",\n                                   defaults to \"GET\"<\/p>\n","type":"String","optional":true},{"name":"datatype","description":"<p>\"json\", \"jsonp\", \"xml\", or \"text\"<\/p>\n","type":"String","optional":true},{"name":"data","description":"<p>param data passed sent with request<\/p>\n","type":"Object","optional":true},{"name":"callback","description":"<p>function to be executed after\n                                   <a href=\"#\/p5\/httpGet\">httpGet()<\/a> completes, data is passed in\n                                   as first argument<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to be executed if\n                                   there is an error, response is passed\n                                   in as first argument<\/p>\n","type":"Function","optional":true}],"return":{"description":"A promise that resolves with the data when the operation\n                  completes successfully or rejects with the error after\n                  one occurs.","type":"Promise"}},{"line":1279,"params":[{"name":"path","description":"","type":"String"},{"name":"options","description":"<p>Request object options as documented in the\n                                   \"fetch\" API\n<a href=\"https:\/\/developer.mozilla.org\/en\/docs\/Web\/API\/Fetch_API\">reference<\/a><\/p>\n","type":"Object"},{"name":"callback","description":"","type":"Function","optional":true},{"name":"errorCallback","description":"","type":"Function","optional":true}],"return":{"description":"","type":"Promise"}}]},{"file":"src\/io\/files.js","line":1444,"description":"<p>Creates a new <a href=\"#\/p5.PrintWriter\">p5.PrintWriter<\/a> object.<\/p>\n<p><a href=\"#\/p5.PrintWriter\">p5.PrintWriter<\/a> objects provide a way to\nsave a sequence of text data, called the <em>print stream<\/em>, to the user's\ncomputer. They're low-level objects that enable precise control of text\noutput. Functions such as\n<a href=\"#\/p5\/saveStrings\">saveStrings()<\/a> and\n<a href=\"#\/p5\/saveJSON\">saveJSON()<\/a> are easier to use for simple file\nsaving.<\/p>\n<p>The first parameter, <code>filename<\/code>, is the name of the file to be written. If\na string is passed, as in <code>createWriter('words.txt')<\/code>, a new\n<a href=\"#\/p5.PrintWriter\">p5.PrintWriter<\/a> object will be created that\nwrites to a file named <code>words.txt<\/code>.<\/p>\n<p>The second parameter, <code>extension<\/code>, is optional. If a string is passed, as\nin <code>createWriter('words', 'csv')<\/code>, the first parameter will be interpreted\nas the file name and the second parameter as the extension.<\/p>\n","itemtype":"method","name":"createWriter","params":[{"name":"name","description":"<p>name of the file to create.<\/p>\n","type":"String"},{"name":"extension","description":"<p>format to use for the file.<\/p>\n","type":"String","optional":true}],"return":{"description":"stream for writing data.","type":"p5.PrintWriter"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create a p5.PrintWriter object.\n    let myWriter = createWriter('xo.txt');\n\n    \/\/ Add some lines to the print stream.\n    myWriter.print('XOO');\n    myWriter.print('OXO');\n    myWriter.print('OOX');\n\n    \/\/ Save the file and close the print stream.\n    myWriter.close();\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create a p5.PrintWriter object.\n    \/\/ Use the file format .csv.\n    let myWriter = createWriter('mauna_loa_co2', 'csv');\n\n    \/\/ Add some lines to the print stream.\n    myWriter.print('date,ppm_co2');\n    myWriter.print('1960-01-01,316.43');\n    myWriter.print('1970-01-01,325.06');\n    myWriter.print('1980-01-01,337.9');\n    myWriter.print('1990-01-01,353.86');\n    myWriter.print('2000-01-01,369.45');\n    myWriter.print('2020-01-01,413.61');\n\n    \/\/ Save the file and close the print stream.\n    myWriter.close();\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":1622,"description":"<p>Writes data to the print stream without adding new lines.<\/p>\n<p>The parameter, <code>data<\/code>, is the data to write. <code>data<\/code> can be a number or\nstring, as in <code>myWriter.write('hi')<\/code>, or an array of numbers and strings,\nas in <code>myWriter.write([1, 2, 3])<\/code>. A comma will be inserted between array\narray elements when they're added to the print stream.<\/p>\n","itemtype":"method","name":"write","params":[{"name":"data","description":"<p>data to be written as a string, number,\n                                  or array of strings and numbers.<\/p>\n","type":"String|Number|Array"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Create a p5.PrintWriter object.\n  let myWriter = createWriter('numbers.txt');\n\n  \/\/ Add some data to the print stream.\n  myWriter.write('1,2,3,');\n  myWriter.write(['4', '5', '6']);\n\n  \/\/ Save the file and close the print stream.\n  myWriter.close();\n}\n<\/code>\n<\/div>"],"class":"p5.PrintWriter","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":1672,"description":"<p>Writes data to the print stream with new lines added.<\/p>\n<p>The parameter, <code>data<\/code>, is the data to write. <code>data<\/code> can be a number or\nstring, as in <code>myWriter.print('hi')<\/code>, or an array of numbers and strings,\nas in <code>myWriter.print([1, 2, 3])<\/code>. A comma will be inserted between array\narray elements when they're added to the print stream.<\/p>\n","itemtype":"method","name":"print","params":[{"name":"data","description":"<p>data to be written as a string, number,\n                                  or array of strings and numbers.<\/p>\n","type":"String|Number|Array"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Create a p5.PrintWriter object.\n  let myWriter = createWriter('numbers.txt');\n\n  \/\/ Add some data to the print stream.\n  myWriter.print('1,2,3,');\n  myWriter.print(['4', '5', '6']);\n\n  \/\/ Save the file and close the print stream.\n  myWriter.close();\n}\n<\/code>\n<\/div>"],"class":"p5.PrintWriter","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":1722,"description":"<p>Clears all data from the print stream.<\/p>\n","itemtype":"method","name":"clear","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Create a p5.PrintWriter object.\n  let myWriter = createWriter('numbers.txt');\n\n  \/\/ Add some data to the print stream.\n  myWriter.print('Hello p5*js!');\n\n  \/\/ Clear the print stream.\n  myWriter.clear();\n\n  \/\/ Save the file and close the print stream.\n  myWriter.close();\n}\n<\/code>\n<\/div>"],"class":"p5.PrintWriter","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":1767,"description":"<p>Saves the file and closes the print stream.<\/p>\n","itemtype":"method","name":"close","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Create a p5.PrintWriter object.\n  let myWriter = createWriter('cat.txt');\n\n  \/\/ Add some data to the print stream.\n  \/\/ ASCII art courtesy Wikipedia:\n  \/\/ https:\/\/en.wikipedia.org\/wiki\/ASCII_art\n  myWriter.print(' (\\\\_\/) ');\n  myWriter.print(\"(='.'=)\");\n  myWriter.print('(\")_(\")');\n\n  \/\/ Save the file and close the print stream.\n  myWriter.close();\n}\n<\/code>\n<\/div>"],"class":"p5.PrintWriter","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":1835,"description":"<p>Saves a given element(image, text, json, csv, wav, or html) to the client's\ncomputer. The first parameter can be a pointer to element we want to save.\nThe element can be one of <a href=\"#\/p5.Element\">p5.Element<\/a>,an Array of\nStrings, an Array of JSON, a JSON object, a <a href=\"#\/p5.Table\">p5.Table\n<\/a>, a <a href=\"#\/p5.Image\">p5.Image<\/a>, or a p5.SoundFile (requires\np5.sound). The second parameter is a filename (including extension).The\nthird parameter is for options specific to this type of object. This method\nwill save a file that fits the given parameters.\nIf it is called without specifying an element, by default it will save the\nwhole canvas as an image file. You can optionally specify a filename as\nthe first parameter in such a case.\n<strong>Note that it is not recommended to\ncall this method within draw, as it will open a new save dialog on every\nrender.<\/strong><\/p>\n","itemtype":"method","name":"save","params":[{"name":"objectOrFilename","description":"<p>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).<\/p>\n","type":"Object|String","optional":true},{"name":"filename","description":"<p>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).<\/p>\n","type":"String","optional":true},{"name":"options","description":"<p>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.<\/p>\n","type":"Boolean|String","optional":true}],"example":["\n <div class=\"norender\"><code>\n \/\/ Saves the canvas as an image\n cnv = createCanvas(300, 300);\n save(cnv, 'myCanvas.jpg');\n\n \/\/ Saves the canvas as an image by default\n save('myCanvas.jpg');\n describe('An example for saving a canvas as an image.');\n <\/code><\/div>\n\n <div class=\"norender\"><code>\n \/\/ Saves p5.Image as an image\n img = createImage(10, 10);\n save(img, 'myImage.png');\n describe('An example for saving a p5.Image element as an image.');\n <\/code><\/div>\n\n <div class=\"norender\"><code>\n \/\/ Saves p5.Renderer object as an image\n obj = createGraphics(100, 100);\n save(obj, 'myObject.png');\n describe('An example for saving a p5.Renderer element.');\n <\/code><\/div>\n\n <div class=\"norender\"><code>\n let myTable = new p5.Table();\n \/\/ Saves table as html file\n save(myTable, 'myTable.html');\n\n \/\/ Comma Separated Values\n save(myTable, 'myTable.csv');\n\n \/\/ Tab Separated Values\n save(myTable, 'myTable.tsv');\n\n describe(`An example showing how to save a table in formats of\n HTML, CSV and TSV.`);\n <\/code><\/div>\n\n <div class=\"norender\"><code>\n let myJSON = { a: 1, b: true };\n\n \/\/ Saves pretty JSON\n save(myJSON, 'my.json');\n\n \/\/ Optimizes JSON filesize\n save(myJSON, 'my.json', true);\n\n describe('An example for saving JSON to a txt file with some extra arguments.');\n <\/code><\/div>\n\n <div class=\"norender\"><code>\n \/\/ Saves array of strings to text file with line breaks after each item\n let arrayOfStrings = ['a', 'b'];\n save(arrayOfStrings, 'my.txt');\n describe(`An example for saving an array of strings to text file\n with line breaks.`);\n <\/code><\/div>"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":1979,"description":"<p>Saves an <code>Object<\/code> or <code>Array<\/code> to a JSON file.<\/p>\n<p>JavaScript Object Notation\n(<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/JSON\" target=\"_blank\">JSON<\/a>)\nis a standard format for sending data between applications. The format is\nbased on JavaScript objects which have keys and values. JSON files store\ndata in an object with strings as keys. Values can be strings, numbers,\nBooleans, arrays, <code>null<\/code>, or other objects.<\/p>\n<p>The first parameter, <code>json<\/code>, is the data to save. The data can be an array,\nas in <code>[1, 2, 3]<\/code>, or an object, as in\n<code>{ x: 50, y: 50, color: 'deeppink' }<\/code>.<\/p>\n<p>The second parameter, <code>filename<\/code>, is a string that sets the file's name.\nFor example, calling <code>saveJSON([1, 2, 3], 'data.json')<\/code> saves the array\n<code>[1, 2, 3]<\/code> to a file called <code>data.json<\/code> on the user's computer.<\/p>\n<p>The third parameter, <code>optimize<\/code>, is optional. If <code>true<\/code> is passed, as in\n<code>saveJSON([1, 2, 3], 'data.json', true)<\/code>, then all unneeded whitespace will\nbe removed to reduce the file size.<\/p>\n<p>Note: The browser will either save the file immediately or prompt the user\nwith a dialogue window.<\/p>\n","itemtype":"method","name":"saveJSON","params":[{"name":"json","description":"<p>data to save.<\/p>\n","type":"Array|Object"},{"name":"filename","description":"<p>name of the file to be saved.<\/p>\n","type":"String"},{"name":"optimize","description":"<p>whether to trim unneeded whitespace. Defaults\n                             to <code>true<\/code>.<\/p>\n","type":"Boolean","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create an array.\n    let data = [1, 2, 3];\n\n    \/\/ Save the JSON file.\n    saveJSON(data, 'numbers.json');\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create an object.\n    let data = { x: mouseX, y: mouseY };\n\n    \/\/ Save the JSON file.\n    saveJSON(data, 'state.json');\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create an object.\n    let data = { x: mouseX, y: mouseY };\n\n    \/\/ Save the JSON file and reduce its size.\n    saveJSON(data, 'state.json', true);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":2118,"description":"<p>Saves an <code>Array<\/code> of <code>String<\/code>s to a file, one per line.<\/p>\n<p>The first parameter, <code>list<\/code>, is an array with the strings to save.<\/p>\n<p>The second parameter, <code>filename<\/code>, is a string that sets the file's name.\nFor example, calling <code>saveStrings(['0', '01', '011'], 'data.txt')<\/code> saves\nthe array <code>['0', '01', '011']<\/code> to a file called <code>data.txt<\/code> on the user's\ncomputer.<\/p>\n<p>The third parameter, <code>extension<\/code>, is optional. If a string is passed, as in\n<code>saveStrings(['0', '01', '0<\/code>1'], 'data', 'txt')`, the second parameter will\nbe interpreted as the file name and the third parameter as the extension.<\/p>\n<p>The fourth parameter, <code>isCRLF<\/code>, is also optional, If <code>true<\/code> is passed, as\nin <code>saveStrings(['0', '01', '011'], 'data', 'txt', true)<\/code>, then two\ncharacters, <code>\\r\\n<\/code> , will be added to the end of each string to create new\nlines in the saved file. <code>\\r<\/code> is a carriage return (CR) and <code>\\n<\/code> is a line\nfeed (LF). By default, only <code>\\n<\/code> (line feed) is added to each string in\norder to create new lines.<\/p>\n<p>Note: The browser will either save the file immediately or prompt the user\nwith a dialogue window.<\/p>\n","itemtype":"method","name":"saveStrings","params":[{"name":"list","description":"<p>data to save.<\/p>\n","type":"String[]"},{"name":"filename","description":"<p>name of file to be saved.<\/p>\n","type":"String"},{"name":"extension","description":"<p>format to use for the file.<\/p>\n","type":"String","optional":true},{"name":"isCRLF","description":"<p>whether to add <code>\\r\\n<\/code> to the end of each\n                            string. Defaults to <code>false<\/code>.<\/p>\n","type":"Boolean","optional":true}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create an array.\n    let data = ['0', '01', '011'];\n\n    \/\/ Save the text file.\n    saveStrings(data, 'data.txt');\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create an array.\n    \/\/ ASCII art courtesy Wikipedia:\n    \/\/ https:\/\/en.wikipedia.org\/wiki\/ASCII_art\n    let data = [' (\\\\_\/) ', \"(='.'=)\", '(\")_(\")'];\n\n    \/\/ Save the text file.\n    saveStrings(data, 'cat', 'txt');\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n    \/\/ Create an array.\n    \/\/   +--+\n    \/\/  \/  \/|\n    \/\/ +--+ +\n    \/\/ |  |\/\n    \/\/ +--+\n    let data = ['  +--+', ' \/  \/|', '+--+ +', '|  |\/', '+--+'];\n\n    \/\/ Save the text file.\n    \/\/ Use CRLF for line endings.\n    saveStrings(data, 'box', 'txt', true);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src\/io\/files.js","line":2275,"description":"<p>Writes the contents of a <a href=\"#\/p5.Table\">Table<\/a> 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.<\/p>\n","itemtype":"method","name":"saveTable","params":[{"name":"Table","description":"<p>the <a href=\"#\/p5.Table\">Table<\/a> object to save to a file<\/p>\n","type":"p5.Table"},{"name":"filename","description":"<p>the filename to which the Table should be saved<\/p>\n","type":"String"},{"name":"options","description":"<p>can be one of \"tsv\", \"csv\", or \"html\"<\/p>\n","type":"String","optional":true}],"example":["\n<div><code>\n let table;\n\n function setup() {\n table = new p5.Table();\n\n table.addColumn('id');\n table.addColumn('species');\n table.addColumn('name');\n\n let newRow = table.addRow();\n newRow.setNum('id', table.getRowCount() - 1);\n newRow.setString('species', 'Panthera leo');\n newRow.setString('name', 'Lion');\n\n \/\/ To save, un-comment next line then click 'run'\n \/\/ saveTable(table, 'new.csv');\n\n describe('no image displayed');\n }\n\n \/\/ Saves the following to a file called 'new.csv':\n \/\/ id,species,name\n \/\/ 0,Panthera leo,Lion\n <\/code><\/div>"],"class":"p5","module":"IO","submodule":"Output"},{"file":"src\/io\/p5.Table.js","line":9,"description":"<p>Table Options\nGeneric class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.\nCSV 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.\nFile names should end with .csv if they're comma separated.\nA rough \"spec\" for CSV can be found\n<a href=\"http:\/\/tools.ietf.org\/html\/rfc4180\">here<\/a>.\nTo load files, use the <a href=\"#\/p5\/loadTable\">loadTable<\/a> method.\nTo save tables to your computer, use the <a href=\"#\/p5\/save\">save<\/a> method\n or the <a href=\"#\/p5\/saveTable\">saveTable<\/a> method.<\/p>\n<p>Possible options include:<\/p>\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":43,"description":"<p>An array containing the names of the columns in the table, if the \"header\" the table is\nloaded with the \"header\" parameter.<\/p>\n","type":"{String[]}","itemtype":"property","name":"columns","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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  \/\/print the column names\n  for (let c = 0; c < table.getColumnCount(); c++) {\n    print('column ' + c + ' is named ' + table.columns[c]);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":80,"description":"<p>An array containing the <a href=\"#\/p5.Table\">p5.TableRow<\/a> objects that make up the\nrows of the table. The same result as calling <a href=\"#\/p5\/getRows\">getRows()<\/a><\/p>\n","type":"{p5.TableRow[]}","itemtype":"property","name":"rows","class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":90,"description":"<p>Use <a href=\"#\/p5\/addRow\">addRow()<\/a> to add a new row of data to a <a href=\"#\/p5.Table\">p5.Table<\/a> 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 <a href=\"#\/p5\/set\">set()<\/a>.<\/p>\n<p>If a <a href=\"#\/p5.TableRow\">p5.TableRow<\/a> object is included as a parameter, then that row is\nduplicated and added to the table.<\/p>\n","itemtype":"method","name":"addRow","params":[{"name":"row","description":"<p>row to be added to the table<\/p>\n","type":"p5.TableRow","optional":true}],"return":{"description":"the row that was added","type":"p5.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 let 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 let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n \/\/print the results\n for (let r = 0; r < table.getRowCount(); r++)\n   for (let c = 0; c < table.getColumnCount(); c++)\n     print(table.getString(r, c));\n\n describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":152,"description":"<p>Removes a row from the table object.<\/p>\n","itemtype":"method","name":"removeRow","params":[{"name":"id","description":"<p>ID number of the row to remove<\/p>\n","type":"Integer"}],"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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  \/\/remove the first row\n  table.removeRow(0);\n\n  \/\/print the results\n  for (let r = 0; r < table.getRowCount(); r++)\n    for (let c = 0; c < table.getColumnCount(); c++)\n      print(table.getString(r, c));\n\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":198,"description":"<p>Returns a reference to the specified <a href=\"#\/p5.TableRow\">p5.TableRow<\/a>. The reference\ncan then be used to get and set values of the selected row.<\/p>\n","itemtype":"method","name":"getRow","params":[{"name":"rowID","description":"<p>ID number of the row to get<\/p>\n","type":"Integer"}],"return":{"description":"<a href=\"#\/p5.TableRow\">p5.TableRow<\/a> object","type":"p5.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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  let row = table.getRow(1);\n  \/\/print it column by column\n  \/\/note: a row is an object, not an array\n  for (let c = 0; c < table.getColumnCount(); c++) {\n    print(row.getString(c));\n  }\n\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":242,"description":"<p>Gets all rows from the table. Returns an array of <a href=\"#\/p5.TableRow\">p5.TableRow<\/a>s.<\/p>\n","itemtype":"method","name":"getRows","return":{"description":"Array of <a href=\"#\/p5.TableRow\">p5.TableRow<\/a>s","type":"p5.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 let 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 let rows = table.getRows();\n\n \/\/warning: rows is an array of objects\n for (let r = 0; r < rows.length; r++) {\n   rows[r].set('name', 'Unicorn');\n }\n\n \/\/print the results\n for (let r = 0; r < table.getRowCount(); r++)\n   for (let c = 0; c < table.getColumnCount(); c++)\n     print(table.getString(r, c));\n\n describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":289,"description":"<p>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.<\/p>\n","itemtype":"method","name":"findRow","params":[{"name":"value","description":"<p>The value to match<\/p>\n","type":"String"},{"name":"column","description":"<p>ID number or title of the\n                               column to search<\/p>\n","type":"Integer|String"}],"return":{"description":"","type":"p5.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 let 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 let row = table.findRow('Zebra', 'name');\n \/\/find the corresponding species\n print(row.getString('species'));\n describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":351,"description":"<p>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.<\/p>\n","itemtype":"method","name":"findRows","params":[{"name":"value","description":"<p>The value to match<\/p>\n","type":"String"},{"name":"column","description":"<p>ID number or title of the\n                               column to search<\/p>\n","type":"Integer|String"}],"return":{"description":"An Array of TableRow objects","type":"p5.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 let 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 let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Scape Goat');\n newRow.setString('name', 'Goat');\n\n \/\/find the rows containing animals named Goat\n let rows = table.findRows('Goat', 'name');\n print(rows.length + ' Goats found');\n describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":417,"description":"<p>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.<\/p>\n","itemtype":"method","name":"matchRow","params":[{"name":"regexp","description":"<p>The regular expression to match<\/p>\n","type":"String|RegExp"},{"name":"column","description":"<p>The column ID (number) or\n                                 title (string)<\/p>\n","type":"String|Integer"}],"return":{"description":"TableRow object","type":"p5.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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  \/\/Search using specified regex on a given column, return TableRow object\n  let mammal = table.matchRow(new RegExp('ant'), 1);\n  print(mammal.getString(1));\n  \/\/Output \"Panthera pardus\"\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":475,"description":"<p>Finds the rows in the Table that match the regular expression provided,\nand returns references to those rows. Returns an array, so for must be\nused to iterate through all the rows, as shown in the example. The\ncolumn to search may be specified by either its ID or title.<\/p>\n","itemtype":"method","name":"matchRows","params":[{"name":"regexp","description":"<p>The regular expression to match<\/p>\n","type":"String"},{"name":"column","description":"<p>The column ID (number) or\n                                 title (string)<\/p>\n","type":"String|Integer","optional":true}],"return":{"description":"An Array of TableRow objects","type":"p5.TableRow[]"},"example":["\n<div class=\"norender\">\n<code>\nlet table;\n\nfunction setup() {\n  table = new p5.Table();\n\n  table.addColumn('name');\n  table.addColumn('type');\n\n  let newRow = table.addRow();\n  newRow.setString('name', 'Lion');\n  newRow.setString('type', 'Mammal');\n\n  newRow = table.addRow();\n  newRow.setString('name', 'Snake');\n  newRow.setString('type', 'Reptile');\n\n  newRow = table.addRow();\n  newRow.setString('name', 'Mosquito');\n  newRow.setString('type', 'Insect');\n\n  newRow = table.addRow();\n  newRow.setString('name', 'Lizard');\n  newRow.setString('type', 'Reptile');\n\n  let rows = table.matchRows('R.*', 'type');\n  for (let i = 0; i < rows.length; i++) {\n    print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n  }\n}\n\/\/ Sketch prints:\n\/\/ Snake: Reptile\n\/\/ Lizard: Reptile\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":542,"description":"<p>Retrieves all values in the specified column, and returns them\nas an array. The column may be specified by either its ID or title.<\/p>\n","itemtype":"method","name":"getColumn","params":[{"name":"column","description":"<p>String or Number of the column to return<\/p>\n","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 let 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 describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":592,"description":"<p>Removes all rows from a Table. While all rows are removed,\ncolumns and column titles are maintained.<\/p>\n","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 let 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 describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":631,"description":"<p>Use <a href=\"#\/p5\/addColumn\">addColumn()<\/a> to add a new column to a <a href=\"#\/p5.Table\">Table<\/a> 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.)<\/p>\n","itemtype":"method","name":"addColumn","params":[{"name":"title","description":"<p>title of the given column<\/p>\n","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 let 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 (let r = 0; r < table.getRowCount(); r++)\n   for (let c = 0; c < table.getColumnCount(); c++)\n     print(table.getString(r, c));\n\n describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":680,"description":"<p>Returns the total number of columns in a Table.<\/p>\n","itemtype":"method","name":"getColumnCount","return":{"description":"Number of columns in this table","type":"Integer"},"example":["\n <div>\n <code>\n \/\/ given the cvs file \"blobs.csv\" in \/assets directory\n \/\/ ID, Name, Flavor, Shape, Color\n \/\/ Blob1, Blobby, Sweet, Blob, Pink\n \/\/ Blob2, Saddy, Savory, Blob, Blue\n\n let table;\n\n function preload() {\n table = loadTable('assets\/blobs.csv');\n }\n\n function setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n }\n\n function draw() {\n let numOfColumn = table.getColumnCount();\n text('There are ' + numOfColumn + ' columns in the table.', 100, 50);\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":716,"description":"<p>Returns the total number of rows in a Table.<\/p>\n","itemtype":"method","name":"getRowCount","return":{"description":"Number of rows in this table","type":"Integer"},"example":["\n <div>\n <code>\n \/\/ given the cvs file \"blobs.csv\" in \/assets directory\n \/\/\n \/\/ ID, Name, Flavor, Shape, Color\n \/\/ Blob1, Blobby, Sweet, Blob, Pink\n \/\/ Blob2, Saddy, Savory, Blob, Blue\n\n let table;\n\n function preload() {\n table = loadTable('assets\/blobs.csv');\n }\n\n function setup() {\n createCanvas(200, 100);\n textAlign(CENTER);\n background(255);\n }\n\n function draw() {\n text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":752,"description":"<p>Removes any of the specified characters (or \"tokens\").<\/p>\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>\n","itemtype":"method","name":"removeTokens","params":[{"name":"chars","description":"<p>String listing characters to be removed<\/p>\n","type":"String"},{"name":"column","description":"<p>Column ID (number)\n                                 or name (string)<\/p>\n","type":"String|Integer","optional":true}],"example":["\n <div class=\"norender\"><code>\n function setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', '   $Lion  ,');\n newRow.setString('type', ',,,Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', '$Snake  ');\n newRow.setString('type', ',,,Reptile');\n\n table.removeTokens(',$ ');\n print(table.getArray());\n }\n\n \/\/ prints:\n \/\/  0  \"Lion\"   \"Mamal\"\n \/\/  1  \"Snake\"  \"Reptile\"\n <\/code><\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":824,"description":"<p>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.<\/p>\n","itemtype":"method","name":"trim","params":[{"name":"column","description":"<p>Column ID (number)\n                                 or name (string)<\/p>\n","type":"String|Integer","optional":true}],"example":["\n <div class=\"norender\"><code>\n function setup() {\n let table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', '   Lion  ,');\n newRow.setString('type', ' Mammal  ');\n\n newRow = table.addRow();\n newRow.setString('name', '  Snake  ');\n newRow.setString('type', '  Reptile  ');\n\n table.trim();\n print(table.getArray());\n }\n\n \/\/ prints:\n \/\/  0  \"Lion\"   \"Mamal\"\n \/\/  1  \"Snake\"  \"Reptile\"\n <\/code><\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":888,"description":"<p>Use <a href=\"#\/p5\/removeColumn\">removeColumn()<\/a> 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.<\/p>\n","itemtype":"method","name":"removeColumn","params":[{"name":"column","description":"<p>columnName (string) or ID (number)<\/p>\n","type":"String|Integer"}],"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 let 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 describe('no image displayed');\n }\n <\/code>\n <\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":950,"description":"<p>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.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"row","description":"<p>row ID<\/p>\n","type":"Integer"},{"name":"column","description":"<p>column ID (Number)\n                              or title (String)<\/p>\n","type":"String|Integer"},{"name":"value","description":"<p>value to assign<\/p>\n","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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  table.set(0, 'species', 'Canis Lupus');\n  table.set(0, 'name', 'Wolf');\n\n  \/\/print the results\n  for (let r = 0; r < table.getRowCount(); r++)\n    for (let c = 0; c < table.getColumnCount(); c++)\n      print(table.getString(r, c));\n\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":998,"description":"<p>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.<\/p>\n","itemtype":"method","name":"setNum","params":[{"name":"row","description":"<p>row ID<\/p>\n","type":"Integer"},{"name":"column","description":"<p>column ID (Number)\n                              or title (String)<\/p>\n","type":"String|Integer"},{"name":"value","description":"<p>value to assign<\/p>\n","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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  table.setNum(1, 'id', 1);\n\n  print(table.getColumn(0));\n  \/\/[\"0\", 1, \"2\"]\n\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":1043,"description":"<p>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.<\/p>\n","itemtype":"method","name":"setString","params":[{"name":"row","description":"<p>row ID<\/p>\n","type":"Integer"},{"name":"column","description":"<p>column ID (Number)\n                              or title (String)<\/p>\n","type":"String|Integer"},{"name":"value","description":"<p>value to assign<\/p>\n","type":"String"}],"example":["\n<div class=\"norender\"><code>\n\/\/ Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n\/\/\n\/\/ id,species,name\n\/\/ 0,Capra hircus,Goat\n\/\/ 1,Panthera pardus,Leopard\n\/\/ 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  \/\/add a row\n  let newRow = table.addRow();\n  newRow.setString('id', table.getRowCount() - 1);\n  newRow.setString('species', 'Canis Lupus');\n  newRow.setString('name', 'Wolf');\n\n  print(table.getArray());\n\n  describe('no image displayed');\n}\n<\/code><\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":1087,"description":"<p>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.<\/p>\n","itemtype":"method","name":"get","params":[{"name":"row","description":"<p>row ID<\/p>\n","type":"Integer"},{"name":"column","description":"<p>columnName (string) or\n                                  ID (number)<\/p>\n","type":"String|Integer"}],"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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  print(table.get(0, 1));\n  \/\/Capra hircus\n  print(table.get(0, 'species'));\n  \/\/Capra hircus\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":1131,"description":"<p>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.<\/p>\n","itemtype":"method","name":"getNum","params":[{"name":"row","description":"<p>row ID<\/p>\n","type":"Integer"},{"name":"column","description":"<p>columnName (string) or\n                                  ID (number)<\/p>\n","type":"String|Integer"}],"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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  print(table.getNum(1, 0) + 100);\n  \/\/id 1 + 100 = 101\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":1173,"description":"<p>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.<\/p>\n","itemtype":"method","name":"getString","params":[{"name":"row","description":"<p>row ID<\/p>\n","type":"Integer"},{"name":"column","description":"<p>columnName (string) or\n                                  ID (number)<\/p>\n","type":"String|Integer"}],"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\nlet table;\n\nfunction preload() {\n  \/\/ table is comma separated value \"CSV\"\n  \/\/ and has specifying header for column labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  print(table.getString(0, 0)); \/\/ 0\n  print(table.getString(0, 1)); \/\/ Capra hircus\n  print(table.getString(0, 2)); \/\/ Goat\n  print(table.getString(1, 0)); \/\/ 1\n  print(table.getString(1, 1)); \/\/ Panthera pardus\n  print(table.getString(1, 2)); \/\/ Leopard\n  print(table.getString(2, 0)); \/\/ 2\n  print(table.getString(2, 1)); \/\/ Equus zebra\n  print(table.getString(2, 2)); \/\/ Zebra\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":1223,"description":"<p>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.<\/p>\n","itemtype":"method","name":"getObject","params":[{"name":"headerColumn","description":"<p>Name of the column which should be used to\n                             title each row object (optional)<\/p>\n","type":"String","optional":true}],"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\nlet table;\n\nfunction preload() {\n  \/\/my table is comma separated value \"csv\"\n  \/\/and has a header specifying the columns labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  let tableObject = table.getObject();\n\n  print(tableObject);\n  \/\/outputs an object\n\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.Table.js","line":1285,"description":"<p>Retrieves all table data and returns it as a multidimensional array.<\/p>\n","itemtype":"method","name":"getArray","return":{"description":"","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,Leoperd\n\/\/ 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n  \/\/ table is comma separated value \"CSV\"\n  \/\/ and has specifying header for column labels\n  table = loadTable('assets\/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n  let tableArray = table.getArray();\n  for (let i = 0; i < tableArray.length; i++) {\n    print(tableArray[i]);\n  }\n  describe('no image displayed');\n}\n<\/code>\n<\/div>"],"class":"p5.Table","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.TableRow.js","line":36,"description":"<p>Stores a value in the TableRow's specified column.\nThe column may be specified by either its ID or title.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"column","description":"<p>Column ID (Number)\n                              or Title (String)<\/p>\n","type":"String|Integer"},{"name":"value","description":"<p>The value to be stored<\/p>\n","type":"String|Number"}],"example":["\n <div class=\"norender\"><code>\n \/\/ Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n \/\/\n \/\/ id,species,name\n \/\/ 0,Capra hircus,Goat\n \/\/ 1,Panthera pardus,Leopard\n \/\/ 2,Equus zebra,Zebra\n\n let 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 let rows = table.getRows();\n for (let r = 0; r < rows.length; r++) {\n   rows[r].set('name', 'Unicorn');\n }\n\n \/\/print the results\n print(table.getArray());\n\n describe('no image displayed');\n }\n <\/code><\/div>"],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.TableRow.js","line":97,"description":"<p>Stores a Float value in the TableRow's specified column.\nThe column may be specified by either its ID or title.<\/p>\n","itemtype":"method","name":"setNum","params":[{"name":"column","description":"<p>Column ID (Number)\n                              or Title (String)<\/p>\n","type":"String|Integer"},{"name":"value","description":"<p>The value to be stored\n                              as a Float<\/p>\n","type":"Number|String"}],"example":["\n <div class=\"norender\"><code>\n \/\/ Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n \/\/\n \/\/ id,species,name\n \/\/ 0,Capra hircus,Goat\n \/\/ 1,Panthera pardus,Leopard\n \/\/ 2,Equus zebra,Zebra\n\n let 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 let rows = table.getRows();\n for (let r = 0; r < rows.length; r++) {\n   rows[r].setNum('id', r + 10);\n }\n\n print(table.getArray());\n\n describe('no image displayed');\n }\n <\/code><\/div>"],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.TableRow.js","line":140,"description":"<p>Stores a String value in the TableRow's specified column.\nThe column may be specified by either its ID or title.<\/p>\n","itemtype":"method","name":"setString","params":[{"name":"column","description":"<p>Column ID (Number)\n                              or Title (String)<\/p>\n","type":"String|Integer"},{"name":"value","description":"<p>The value to be stored\n                              as a String<\/p>\n","type":"String|Number|Boolean|Object"}],"example":["\n <div class=\"norender\"><code>\n \/\/ Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n \/\/\n \/\/ id,species,name\n \/\/ 0,Capra hircus,Goat\n \/\/ 1,Panthera pardus,Leopard\n \/\/ 2,Equus zebra,Zebra\n\n let 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 let rows = table.getRows();\n for (let r = 0; r < rows.length; r++) {\n   let name = rows[r].getString('name');\n   rows[r].setString('name', 'A ' + name + ' named George');\n }\n\n print(table.getArray());\n\n describe('no image displayed');\n }\n <\/code><\/div>"],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.TableRow.js","line":184,"description":"<p>Retrieves a value from the TableRow's specified column.\nThe column may be specified by either its ID or title.<\/p>\n","itemtype":"method","name":"get","params":[{"name":"column","description":"<p>columnName (string) or\n                                 ID (number)<\/p>\n","type":"String|Integer"}],"return":{"description":"","type":"String|Number"},"example":["\n <div class=\"norender\"><code>\n \/\/ Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n \/\/\n \/\/ id,species,name\n \/\/ 0,Capra hircus,Goat\n \/\/ 1,Panthera pardus,Leopard\n \/\/ 2,Equus zebra,Zebra\n\n let 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 let names = [];\n let rows = table.getRows();\n for (let r = 0; r < rows.length; r++) {\n   names.push(rows[r].get('name'));\n }\n\n print(names);\n\n describe('no image displayed');\n }\n <\/code><\/div>"],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.TableRow.js","line":231,"description":"<p>Retrieves a Float value from the TableRow's specified\ncolumn. The column may be specified by either its ID or\ntitle.<\/p>\n","itemtype":"method","name":"getNum","params":[{"name":"column","description":"<p>columnName (string) or\n                                 ID (number)<\/p>\n","type":"String|Integer"}],"return":{"description":"Float Floating point number","type":"Number"},"example":["\n <div class=\"norender\"><code>\n \/\/ Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n \/\/\n \/\/ id,species,name\n \/\/ 0,Capra hircus,Goat\n \/\/ 1,Panthera pardus,Leopard\n \/\/ 2,Equus zebra,Zebra\n\n let 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 let rows = table.getRows();\n let minId = Infinity;\n let maxId = -Infinity;\n for (let r = 0; r < rows.length; r++) {\n   let id = rows[r].getNum('id');\n   minId = min(minId, id);\n   maxId = min(maxId, id);\n }\n print('minimum id = ' + minId + ', maximum id = ' + maxId);\n describe('no image displayed');\n }\n <\/code><\/div>"],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.TableRow.js","line":285,"description":"<p>Retrieves an String value from the TableRow's specified\ncolumn. The column may be specified by either its ID or\ntitle.<\/p>\n","itemtype":"method","name":"getString","params":[{"name":"column","description":"<p>columnName (string) or\n                                 ID (number)<\/p>\n","type":"String|Integer"}],"return":{"description":"String","type":"String"},"example":["\n <div class=\"norender\"><code>\n \/\/ Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n \/\/\n \/\/ id,species,name\n \/\/ 0,Capra hircus,Goat\n \/\/ 1,Panthera pardus,Leopard\n \/\/ 2,Equus zebra,Zebra\n\n let 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 let rows = table.getRows();\n let longest = '';\n for (let r = 0; r < rows.length; r++) {\n   let species = rows[r].getString('species');\n   if (longest.length < species.length) {\n     longest = species;\n   }\n }\n\n print('longest: ' + longest);\n\n describe('no image displayed');\n }\n <\/code><\/div>"],"class":"p5.TableRow","module":"IO","submodule":"Table"},{"file":"src\/io\/p5.XML.js","line":77,"description":"<p>Returns the element's parent element as a new <a href=\"#\/p5.XML\">p5.XML<\/a>\nobject.<\/p>\n","itemtype":"method","name":"getParent","return":{"description":"parent element.","type":"p5.XML"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get an array with all mammal elements.\n  let mammals = myXML.getChildren('mammal');\n\n  \/\/ Get the first mammal element.\n  let firstMammal = mammals[0];\n\n  \/\/ Get the parent element.\n  let parent = firstMammal.getParent();\n\n  \/\/ Get the parent element's name.\n  let name = parent.getName();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the parent element's name.\n  text(name, 50, 50);\n\n  describe('The word \"animals\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":128,"description":"<p>Returns the element's name as a <code>String<\/code>.<\/p>\n<p>An XML element's name is given by its tag. For example, the element\n<code>&lt;language&gt;JavaScript&lt;\/language&gt;<\/code> has the name <code>language<\/code>.<\/p>\n","itemtype":"method","name":"getName","return":{"description":"name of the element.","type":"String"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get an array with all mammal elements.\n  let mammals = myXML.getChildren('mammal');\n\n  \/\/ Get the first mammal element.\n  let firstMammal = mammals[0];\n\n  \/\/ Get the mammal element's name.\n  let name = firstMammal.getName();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the element's name.\n  text(name, 50, 50);\n\n  describe('The word \"mammal\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":178,"description":"<p>Sets the element's tag name.<\/p>\n<p>An XML element's name is given by its tag. For example, the element\n<code>&lt;language&gt;JavaScript&lt;\/language&gt;<\/code> has the name <code>language<\/code>.<\/p>\n<p>The parameter, <code>name<\/code>, is the element's new name as a string. For example,\ncalling <code>myXML.setName('planet')<\/code> will make the element's new tag name\n<code>&lt;planet&gt;&lt;\/planet&gt;<\/code>.<\/p>\n","itemtype":"method","name":"setName","params":[{"name":"name","description":"<p>new tag name of the element.<\/p>\n","type":"String"}],"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the element's original name.\n  let oldName = myXML.getName();\n\n  \/\/ Set the element's name.\n  myXML.setName('monsters');\n\n  \/\/ Get the element's new name.\n  let newName = myXML.getName();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the element's names.\n  text(oldName, 50, 33);\n  text(newName, 50, 67);\n\n  describe(\n    'The words \"animals\" and \"monsters\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code><\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":242,"description":"<p>Returns <code>true<\/code> if the element has child elements and <code>false<\/code> if not.<\/p>\n","itemtype":"method","name":"hasChildren","return":{"description":"whether the element has children.","type":"Boolean"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Check whether the element has child elements.\n  let isParent = myXML.hasChildren();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Style the text.\n  if (isParent === true) {\n    text('Parent', 50, 50);\n  } else {\n    text('Not Parent', 50, 50);\n  }\n\n  describe('The word \"Parent\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":287,"description":"<p>Returns an array with the names of the element's child elements as\n<code>String<\/code>s.<\/p>\n","itemtype":"method","name":"listChildren","return":{"description":"names of the child elements.","type":"String[]"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the names of the element's children as an array.\n  let children = myXML.listChildren();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Iterate over the array.\n  for (let i = 0; i < children.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Display the child element's name.\n    text(children[i], 10, y);\n  }\n\n  describe(\n    'The words \"mammal\", \"mammal\", \"mammal\", and \"reptile\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":342,"description":"<p>Returns an array with the element's child elements as new\n<a href=\"#\/p5.XML\">p5.XML<\/a> objects.<\/p>\n<p>The parameter, <code>name<\/code>, is optional. If a string is passed, as in\n<code>myXML.getChildren('cat')<\/code>, then the method will only return child elements\nwith the tag <code>&lt;cat&gt;<\/code>.<\/p>\n","itemtype":"method","name":"getChildren","params":[{"name":"name","description":"<p>name of the elements to return.<\/p>\n","type":"String","optional":true}],"return":{"description":"child elements.","type":"p5.XML[]"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get an array of the child elements.\n  let children = myXML.getChildren();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Iterate over the array.\n  for (let i = 0; i < children.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 20;\n\n    \/\/ Get the child element's content.\n    let content = children[i].getContent();\n\n    \/\/ Display the child element's content.\n    text(content, 10, y);\n  }\n\n  describe(\n    'The words \"Goat\", \"Leopard\", \"Zebra\", and \"Turtle\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get an array of the child elements\n  \/\/ that are mammals.\n  let children = myXML.getChildren('mammal');\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Iterate over the array.\n  for (let i = 0; i < children.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 20;\n\n    \/\/ Get the child element's content.\n    let content = children[i].getContent();\n\n    \/\/ Display the child element's content.\n    text(content, 10, y);\n  }\n\n  describe(\n    'The words \"Goat\", \"Leopard\", and \"Zebra\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":448,"description":"<p>Returns the first matching child element as a new\n<a href=\"#\/p5.XML\">p5.XML<\/a> object.<\/p>\n<p>The parameter, <code>name<\/code>, is optional. If a string is passed, as in\n<code>myXML.getChild('cat')<\/code>, then the first child element with the tag\n<code>&lt;cat&gt;<\/code> will be returned. If a number is passed, as in\n<code>myXML.getChild(1)<\/code>, then the child element at that index will be returned.<\/p>\n","itemtype":"method","name":"getChild","params":[{"name":"name","description":"<p>element name or index.<\/p>\n","type":"String|Integer"}],"return":{"description":"child element.","type":"p5.XML"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first child element that is a mammal.\n  let goat = myXML.getChild('mammal');\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Get the child element's content.\n  let content = goat.getContent();\n\n  \/\/ Display the child element's content.\n  text(content, 50, 50);\n\n  describe('The word \"Goat\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the child element at index 1.\n  let leopard = myXML.getChild(1);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Get the child element's content.\n  let content = leopard.getContent();\n\n  \/\/ Display the child element's content.\n  text(content, 50, 50);\n\n  describe('The word \"Leopard\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":538,"description":"<p>Adds a new child element and returns a reference to it.<\/p>\n<p>The parameter, <code>child<\/code>, is the <a href=\"#\/p5.XML\">p5.XML<\/a> object to add\nas a child element. For example, calling <code>myXML.addChild(otherXML)<\/code> inserts\n<code>otherXML<\/code> as a child element of <code>myXML<\/code>.<\/p>\n","itemtype":"method","name":"addChild","params":[{"name":"child","description":"<p>child element to add.<\/p>\n","type":"p5.XML"}],"return":{"description":"added child element.","type":"p5.XML"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a new p5.XML object.\n  let newAnimal = new p5.XML();\n\n  \/\/ Set its properties.\n  newAnimal.setName('hydrozoa');\n  newAnimal.setAttribute('id', 4);\n  newAnimal.setAttribute('species', 'Physalia physalis');\n  newAnimal.setContent('Bluebottle');\n\n  \/\/ Add the child element.\n  myXML.addChild(newAnimal);\n\n  \/\/ Get the first child element that is a hydrozoa.\n  let blueBottle = myXML.getChild('hydrozoa');\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Get the child element's content.\n  let content = blueBottle.getContent();\n\n  \/\/ Display the child element's content.\n  text(content, 50, 50);\n\n  describe('The word \"Bluebottle\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":603,"description":"<p>Removes the first matching child element.<\/p>\n<p>The parameter, <code>name<\/code>, is the child element to remove. If a string is\npassed, as in <code>myXML.removeChild('cat')<\/code>, then the first child element\nwith the tag <code>&lt;cat&gt;<\/code> will be removed. If a number is passed, as in\n<code>myXML.removeChild(1)<\/code>, then the child element at that index will be\nremoved.<\/p>\n","itemtype":"method","name":"removeChild","params":[{"name":"name","description":"<p>name or index of the child element to remove.<\/p>\n","type":"String|Integer"}],"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Remove the first mammal element.\n  myXML.removeChild('mammal');\n\n  \/\/ Get an array of child elements.\n  let children = myXML.getChildren();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Iterate over the array.\n  for (let i = 0; i < children.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Get the child element's content.\n    let content = children[i].getContent();\n\n    \/\/ Display the child element's content.\n    text(content, 10, y);\n  }\n\n  describe(\n    'The words \"Leopard\", \"Zebra\", and \"Turtle\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Remove the element at index 2.\n  myXML.removeChild(2);\n\n  \/\/ Get an array of child elements.\n  let children = myXML.getChildren();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Iterate over the array.\n  for (let i = 0; i < children.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Get the child element's content.\n    let content = children[i].getContent();\n\n    \/\/ Display the child element's content.\n    text(content, 10, y);\n  }\n\n  describe(\n    'The words \"Goat\", \"Leopard\", and \"Turtle\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":723,"description":"<p>Returns the number of attributes the element has.<\/p>\n","itemtype":"method","name":"getAttributeCount","return":{"description":"number of attributes.","type":"Integer"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first child element.\n  let first = myXML.getChild(0);\n\n  \/\/ Get the number of attributes.\n  let numAttributes = first.getAttributeCount();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the number of attributes.\n  text(numAttributes, 50, 50);\n\n  describe('The number \"2\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":767,"description":"<p>Returns an <code>Array<\/code> with the names of the element's attributes.<\/p>\n<p>Note: Use\n<a href=\"#\/p5.XML\/getString\">myXML.getString()<\/a> or\n<a href=\"#\/p5.XML\/getNum\">myXML.getNum()<\/a> to return an attribute's value.<\/p>\n","itemtype":"method","name":"listAttributes","return":{"description":"attribute names.","type":"String[]"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first child element.\n  let first = myXML.getChild(0);\n\n  \/\/ Get the number of attributes.\n  let attributes = first.listAttributes();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the element's attributes.\n  text(attributes, 50, 50);\n\n  describe('The text \"id,species\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":821,"description":"<p>Returns <code>true<\/code> if the element has a given attribute and <code>false<\/code> if not.<\/p>\n<p>The parameter, <code>name<\/code>, is a string with the name of the attribute being\nchecked.<\/p>\n<p>Note: Use\n<a href=\"#\/p5.XML\/getString\">myXML.getString()<\/a> or\n<a href=\"#\/p5.XML\/getNum\">myXML.getNum()<\/a> to return an attribute's value.<\/p>\n","itemtype":"method","name":"hasAttribute","params":[{"name":"name","description":"<p>name of the attribute to be checked.<\/p>\n","type":"String"}],"return":{"description":"whether the element has the attribute.","type":"Boolean"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first mammal child element.\n  let mammal = myXML.getChild('mammal');\n\n  \/\/ Check whether the element has an\n  \/\/ species attribute.\n  let hasSpecies = mammal.hasAttribute('species');\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display whether the element has a species attribute.\n  if (hasSpecies === true) {\n    text('Species', 50, 50);\n  } else {\n    text('No species', 50, 50);\n  }\n\n  describe('The text \"Species\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":884,"description":"<p>Return an attribute's value as a <code>Number<\/code>.<\/p>\n<p>The first parameter, <code>name<\/code>, is a string with the name of the attribute\nbeing checked. For example, calling <code>myXML.getNum('id')<\/code> returns the\nelement's <code>id<\/code> attribute as a number.<\/p>\n<p>The second parameter, <code>defaultValue<\/code>, is optional. If a number is passed,\nas in <code>myXML.getNum('id', -1)<\/code>, it will be returned if the attribute\ndoesn't exist or can't be converted to a number.<\/p>\n<p>Note: Use\n<a href=\"#\/p5.XML\/getString\">myXML.getString()<\/a> or\n<a href=\"#\/p5.XML\/getNum\">myXML.getNum()<\/a> to return an attribute's value.<\/p>\n","itemtype":"method","name":"getNum","params":[{"name":"name","description":"<p>name of the attribute to be checked.<\/p>\n","type":"String"},{"name":"defaultValue","description":"<p>value to return if the attribute doesn't exist.<\/p>\n","type":"Number","optional":true}],"return":{"description":"attribute value as a number.","type":"Number"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first reptile child element.\n  let reptile = myXML.getChild('reptile');\n\n  \/\/ Get the reptile's content.\n  let content = reptile.getContent();\n\n  \/\/ Get the reptile's ID.\n  let id = reptile.getNum('id');\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the ID attribute.\n  text(`${content} is ${id + 1}th`, 5, 50, 90);\n\n  describe(`The text \"${content} is ${id + 1}th\" written in black on a gray background.`);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first reptile child element.\n  let reptile = myXML.getChild('reptile');\n\n  \/\/ Get the reptile's content.\n  let content = reptile.getContent();\n\n  \/\/ Get the reptile's size.\n  let weight = reptile.getNum('weight', 135);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the ID attribute.\n  text(`${content} is ${weight}kg`, 5, 50, 90);\n\n  describe(\n    `The text \"${content} is ${weight}kg\" written in black on a gray background.`\n  );\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":989,"description":"<p>Return an attribute's value as a string.<\/p>\n<p>The first parameter, <code>name<\/code>, is a string with the name of the attribute\nbeing checked. For example, calling <code>myXML.getString('color')<\/code> returns the\nelement's <code>id<\/code> attribute as a string.<\/p>\n<p>The second parameter, <code>defaultValue<\/code>, is optional. If a string is passed,\nas in <code>myXML.getString('color', 'deeppink')<\/code>, it will be returned if the\nattribute doesn't exist.<\/p>\n<p>Note: Use\n<a href=\"#\/p5.XML\/getString\">myXML.getString()<\/a> or\n<a href=\"#\/p5.XML\/getNum\">myXML.getNum()<\/a> to return an attribute's value.<\/p>\n","itemtype":"method","name":"getString","params":[{"name":"name","description":"<p>name of the attribute to be checked.<\/p>\n","type":"String"},{"name":"defaultValue","description":"<p>value to return if the attribute doesn't exist.<\/p>\n","type":"Number","optional":true}],"return":{"description":"attribute value as a string.","type":"String"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first reptile child element.\n  let reptile = myXML.getChild('reptile');\n\n  \/\/ Get the reptile's content.\n  let content = reptile.getContent();\n\n  \/\/ Get the reptile's species.\n  let species = reptile.getString('species');\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the species attribute.\n  text(`${content}: ${species}`, 5, 50, 90);\n\n  describe(`The text \"${content}: ${species}\" written in black on a gray background.`);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first reptile child element.\n  let reptile = myXML.getChild('reptile');\n\n  \/\/ Get the reptile's content.\n  let content = reptile.getContent();\n\n  \/\/ Get the reptile's color.\n  let attribute = reptile.getString('color', 'green');\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n  fill(attribute);\n\n  \/\/ Display the element's content.\n  text(content, 50, 50);\n\n  describe(`The text \"${content}\" written in green on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":1093,"description":"<p>Sets an attribute to a given value.<\/p>\n<p>The first parameter, <code>name<\/code>, is a string with the name of the attribute\nbeing set.<\/p>\n<p>The second parameter, <code>value<\/code>, is the attribute's new value. For example,\ncalling <code>myXML.setAttribute('id', 123)<\/code> sets the <code>id<\/code> attribute to the\nvalue 123.<\/p>\n","itemtype":"method","name":"setAttribute","params":[{"name":"name","description":"<p>name of the attribute to be set.<\/p>\n","type":"String"},{"name":"value","description":"<p>attribute's new value.<\/p>\n","type":"Number|String|Boolean"}],"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first reptile child element.\n  let reptile = myXML.getChild('reptile');\n\n  \/\/ Set the reptile's color.\n  reptile.setAttribute('color', 'green');\n\n  \/\/ Get the reptile's content.\n  let content = reptile.getContent();\n\n  \/\/ Get the reptile's color.\n  let attribute = reptile.getString('color');\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the element's content.\n  text(`${content} is ${attribute}`, 5, 50, 90);\n\n  describe(\n    `The text \"${content} is ${attribute}\" written in green on a gray background.`\n  );\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":1153,"description":"<p>Returns the element's content as a <code>String<\/code>.<\/p>\n<p>The parameter, <code>defaultValue<\/code>, is optional. If a string is passed, as in\n<code>myXML.getContent('???')<\/code>, it will be returned if the element has no\ncontent.<\/p>\n","itemtype":"method","name":"getContent","params":[{"name":"defaultValue","description":"<p>value to return if the element has no\n                               content.<\/p>\n","type":"String","optional":true}],"return":{"description":"element's content as a string.","type":"String"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first reptile child element.\n  let reptile = myXML.getChild('reptile');\n\n  \/\/ Get the reptile's content.\n  let content = reptile.getContent();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the element's content.\n  text(content, 5, 50, 90);\n\n  describe(`The text \"${content}\" written in green on a gray background.`);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.XML object.\n  let blankSpace = new p5.XML();\n\n  \/\/ Get the element's content and use a default value.\n  let content = blankSpace.getContent('Your name');\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the element's content.\n  text(content, 5, 50, 90);\n\n  describe(`The text \"${content}\" written in green on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":1232,"description":"<p>Sets the element's content.<\/p>\n<p>An element's content is the text between its tags. For example, the element\n<code>&lt;language&gt;JavaScript&lt;\/language&gt;<\/code> has the content <code>JavaScript<\/code>.<\/p>\n<p>The parameter, <code>content<\/code>, is a string with the element's new content.<\/p>\n","itemtype":"method","name":"setContent","params":[{"name":"content","description":"<p>new content for the element.<\/p>\n","type":"String"}],"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the first reptile child element.\n  let reptile = myXML.getChild('reptile');\n\n  \/\/ Get the reptile's original content.\n  let oldContent = reptile.getContent();\n\n  \/\/ Set the reptile's content.\n  reptile.setContent('Loggerhead');\n\n  \/\/ Get the reptile's new content.\n  let newContent = reptile.getContent();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(14);\n\n  \/\/ Display the element's old and new content.\n  text(`${oldContent}: ${newContent}`, 5, 50, 90);\n\n  describe(\n    `The text \"${oldContent}: ${newContent}\" written in green on a gray background.`\n  );\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/io\/p5.XML.js","line":1291,"description":"<p>Returns the element as a <code>String<\/code>.<\/p>\n<p><code>myXML.serialize()<\/code> is useful for sending the element over the network or\nsaving it to a file.<\/p>\n","itemtype":"method","name":"serialize","return":{"description":"element as a string.","type":"String"},"example":["\n<div>\n<code>\nlet myXML;\n\n\/\/ Load the XML and create a p5.XML object.\nfunction preload() {\n  myXML = loadXML('assets\/animals.xml');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Display instructions.\n  text('Double-click to save', 5, 50, 90);\n\n  describe('The text \"Double-click to save\" written in black on a gray background.');\n}\n\n\/\/ Save the file when the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Create a p5.PrintWriter object.\n  \/\/ Use the file format .xml.\n  let myWriter = createWriter('animals', 'xml');\n\n  \/\/ Serialize the XML data to a string.\n  let data = myXML.serialize();\n\n  \/\/ Write the data to the print stream.\n  myWriter.write(data);\n\n  \/\/ Save the file and close the print stream.\n  myWriter.close();\n}\n<\/code>\n<\/div>"],"class":"p5.XML","module":"IO","submodule":"Input"},{"file":"src\/math\/calculation.js","line":10,"description":"<p>Calculates the absolute value of a number.<\/p>\n<p>A number's absolute value is its distance from zero on the number line.\n-5 and 5 are both five units away from zero, so calling <code>abs(-5)<\/code> and\n<code>abs(5)<\/code> both return 5. The absolute value of a number is always positive.<\/p>\n","itemtype":"method","name":"abs","params":[{"name":"n","description":"<p>number to compute.<\/p>\n","type":"Number"}],"return":{"description":"absolute value of given number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A gray square with a vertical black line that divides it in half. A white rectangle gets taller when the user moves the mouse away from the line.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Divide the canvas.\n  line(50, 0, 50, 100);\n\n  \/\/ Calculate the mouse's distance from the middle.\n  let h = abs(mouseX - 50);\n\n  \/\/ Draw a rectangle based on the mouse's distance\n  \/\/ from the middle.\n  rect(0, 100 - h, 100, h);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":48,"description":"<p>Calculates the closest integer value that is greater than or equal to a\nnumber.<\/p>\n<p>For example, calling <code>ceil(9.03)<\/code> and <code>ceil(9.97)<\/code> both return the value\n10.<\/p>\n","itemtype":"method","name":"ceil","params":[{"name":"n","description":"<p>number to round up.<\/p>\n","type":"Number"}],"return":{"description":"rounded up number.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use RGB color with values from 0 to 1.\n  colorMode(RGB, 1);\n\n  noStroke();\n\n  \/\/ Draw the left rectangle.\n  let r = 0.3;\n  fill(r, 0, 0);\n  rect(0, 0, 50, 100);\n\n  \/\/ Round r up to 1.\n  r = ceil(r);\n\n  \/\/ Draw the right rectangle.\n  fill(r, 0, 0);\n  rect(50, 0, 50, 100);\n\n  describe('Two rectangles. The one on the left is dark red and the one on the right is bright red.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":91,"description":"<p>Constrains a number between a minimum and maximum value.<\/p>\n","itemtype":"method","name":"constrain","params":[{"name":"n","description":"<p>number to constrain.<\/p>\n","type":"Number"},{"name":"low","description":"<p>minimum limit.<\/p>\n","type":"Number"},{"name":"high","description":"<p>maximum limit.<\/p>\n","type":"Number"}],"return":{"description":"constrained number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black dot drawn on a gray square follows the mouse from left to right. Its movement is constrained to the middle third of the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  let x = constrain(mouseX, 33, 67);\n  let y = 50;\n\n  strokeWeight(5);\n  point(x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Two vertical lines. Two circles move horizontally with the mouse. One circle stops at the vertical lines.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set boundaries and draw them.\n  let leftWall = 25;\n  let rightWall = 75;\n  line(leftWall, 0, leftWall, 100);\n  line(rightWall, 0, rightWall, 100);\n\n  \/\/ Draw a circle that follows the mouse freely.\n  fill(255);\n  circle(mouseX, 33, 9);\n\n  \/\/ Draw a circle that's constrained.\n  let xc = constrain(mouseX, leftWall, rightWall);\n  fill(0);\n  circle(xc, 67, 9);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":155,"description":"<p>Calculates the distance between two points.<\/p>\n<p>The version of <code>dist()<\/code> with four parameters calculates distance in two\ndimensions.<\/p>\n<p>The version of <code>dist()<\/code> with six parameters calculates distance in three\ndimensions.<\/p>\n<p>Use <a href=\"#\/p5.Vector\/dist\">p5.Vector.dist()<\/a> to calculate the\ndistance between two <a href=\"#\/p5.Vector\">p5.Vector<\/a> objects.<\/p>\n","itemtype":"method","name":"dist","return":{"description":"distance between the two points.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the coordinates.\n  let x1 = 10;\n  let y1 = 50;\n  let x2 = 90;\n  let y2 = 50;\n\n  \/\/ Draw the points and a line connecting them.\n  line(x1, y1, x2, y2);\n  strokeWeight(5);\n  point(x1, y1);\n  point(x2, y2);\n\n  \/\/ Calculate the distance.\n  let d = dist(x1, y1, x2, y2);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the distance.\n  text(d, 43, 40);\n\n  describe('Two dots connected by a horizontal line. The number 80 is written above the center of the line.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation","overloads":[{"line":155,"params":[{"name":"x1","description":"<p>x-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"y1","description":"<p>y-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"x2","description":"<p>x-coordinate of the second point.<\/p>\n","type":"Number"},{"name":"y2","description":"<p>y-coordinate of the second point.<\/p>\n","type":"Number"}],"return":{"description":"distance between the two points.","type":"Number"}},{"line":209,"params":[{"name":"x1","description":"","type":"Number"},{"name":"y1","description":"","type":"Number"},{"name":"z1","description":"<p>z-coordinate of the first point.<\/p>\n","type":"Number"},{"name":"x2","description":"","type":"Number"},{"name":"y2","description":"","type":"Number"},{"name":"z2","description":"<p>z-coordinate of the second point.<\/p>\n","type":"Number"}],"return":{"description":"distance between the two points.","type":"Number"}}]},{"file":"src\/math\/calculation.js","line":230,"description":"<p>Calculates the value of Euler's number e (2.71828...) raised to the power\nof a number.<\/p>\n","itemtype":"method","name":"exp","params":[{"name":"n","description":"<p>exponent to raise.<\/p>\n","type":"Number"}],"return":{"description":"e^n","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top-left.\n  let d = exp(1);\n  circle(10, 10, d);\n\n  \/\/ Left-center.\n  d = exp(2);\n  circle(20, 20, d);\n\n  \/\/ Right-center.\n  d = exp(3);\n  circle(40, 40, d);\n\n  \/\/ Bottom-right.\n  d = exp(4);\n  circle(80, 80, d);\n\n  describe('A series of circles that grow exponentially from top left to bottom right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots that grow exponentially from left to right.');\n}\n\nfunction draw() {\n  \/\/ Invert the y-axis.\n  scale(1, -1);\n  translate(0, -100);\n\n  \/\/ Calculate the coordinates.\n  let x = frameCount;\n  let y = 0.005 * exp(x * 0.1);\n\n  \/\/ Draw a point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":294,"description":"<p>Calculates the closest integer value that is less than or equal to the\nvalue of a number.<\/p>\n","itemtype":"method","name":"floor","params":[{"name":"n","description":"<p>number to round down.<\/p>\n","type":"Number"}],"return":{"description":"rounded down number.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use RGB color with values from 0 to 1.\n  colorMode(RGB, 1);\n\n  noStroke();\n\n  \/\/ Draw the left rectangle.\n  let r = 0.8;\n  fill(r, 0, 0);\n  rect(0, 0, 50, 100);\n\n  \/\/ Round r down to 0.\n  r = floor(r);\n\n  \/\/ Draw the right rectangle.\n  fill(r, 0, 0);\n  rect(50, 0, 50, 100);\n\n  describe('Two rectangles. The one on the left is bright red and the one on the right is black.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":332,"description":"<p>Calculates a number between two numbers at a specific increment.<\/p>\n<p>The <code>amt<\/code> parameter is the amount to interpolate between the two numbers.\n0.0 is equal to the first number, 0.1 is very near the first number, 0.5 is\nhalf-way in between, and 1.0 is equal to the second number. The <code>lerp()<\/code>\nfunction is convenient for creating motion along a straight path and for\ndrawing dotted lines.<\/p>\n<p>If the value of <code>amt<\/code> is less than 0 or more than 1, <code>lerp()<\/code> will return a\nnumber outside of the original interval. For example, calling\n<code>lerp(0, 10, 1.5)<\/code> will return 15.<\/p>\n","itemtype":"method","name":"lerp","params":[{"name":"start","description":"<p>first value.<\/p>\n","type":"Number"},{"name":"stop","description":"<p>second value.<\/p>\n","type":"Number"},{"name":"amt","description":"<p>number.<\/p>\n","type":"Number"}],"return":{"description":"lerped value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Declare variables for coordinates.\n  let a = 20;\n  let b = 80;\n  let c = lerp(a, b, 0.2);\n  let d = lerp(a, b, 0.5);\n  let e = lerp(a, b, 0.8);\n\n  strokeWeight(5);\n\n  \/\/ Draw the original points in black.\n  stroke(0);\n  point(a, 50);\n  point(b, 50);\n\n  \/\/ Draw the lerped points in gray.\n  stroke(100);\n  point(c, 50);\n  point(d, 50);\n  point(e, 50);\n\n  describe('Five points in a horizontal line. The outer points are black and the inner points are gray.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet x = 50;\nlet y = 50;\nlet targetX = 50;\nlet targetY = 50;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A white circle at the center of a gray canvas. The circle moves to where the user clicks, then moves smoothly back to the center.');\n}\n\nfunction draw() {\n  background(220);\n\n  \/\/ Move x and y toward the target.\n  x = lerp(x, targetX, 0.05);\n  y = lerp(y, targetY, 0.05);\n\n  \/\/ Draw the circle.\n  circle(x, y, 20);\n}\n\n\/\/ Set x and y when the user clicks the mouse.\nfunction mouseClicked() {\n  x = mouseX;\n  y = mouseY;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":423,"description":"<p>Calculates the natural logarithm (the base-e logarithm) of a number.<\/p>\n<p><code>log()<\/code> expects the <code>n<\/code> parameter to be a value greater than 0 because\nthe natural logarithm is defined that way.<\/p>\n","itemtype":"method","name":"log","params":[{"name":"n","description":"<p>number greater than 0.<\/p>\n","type":"Number"}],"return":{"description":"natural logarithm of n.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top-left.\n  let d = log(50);\n  circle(33, 33, d);\n\n  \/\/ Bottom-right.\n  d = log(500000000);\n  circle(67, 67, d);\n\n  describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is about five times larger.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots that get higher slowly from left to right.');\n}\n\nfunction draw() {\n  \/\/ Invert the y-axis.\n  scale(1, -1);\n  translate(0, -100);\n\n  \/\/ Calculate coordinates.\n  let x = frameCount;\n  let y = 15 * log(x);\n\n  \/\/ Draw a point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":481,"description":"<p>Calculates the magnitude, or length, of a vector.<\/p>\n<p>A vector can be thought of in different ways. In one view, a vector is a\npoint in space. The vector's components, <code>x<\/code> and <code>y<\/code>, are the point's\ncoordinates <code>(x, y)<\/code>. A vector's magnitude is the distance from the origin\n<code>(0, 0)<\/code> to <code>(x, y)<\/code>. <code>mag(x, y)<\/code> is a shortcut for calling\n<code>dist(0, 0, x, y)<\/code>.<\/p>\n<p>A vector can also be thought of as an arrow pointing in space. This view is\nhelpful for programming motion. See <a href=\"#\/p5.Vector\">p5.Vector<\/a> for\nmore details.<\/p>\n<p>Use <a href=\"#\/p5.Vector\/mag\">p5.Vector.mag()<\/a> to calculate the\nmagnitude of a <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","itemtype":"method","name":"mag","params":[{"name":"x","description":"<p>first component.<\/p>\n","type":"Number"},{"name":"y","description":"<p>second component.<\/p>\n","type":"Number"}],"return":{"description":"magnitude of vector.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the vector's components.\n  let x = 30;\n  let y = 40;\n\n  \/\/ Calculate the magnitude.\n  let m = mag(x, y);\n\n  \/\/ Style the text.\n  textSize(16);\n\n  \/\/ Display the vector and its magnitude.\n  line(0, 0, x, y);\n  text(m, x, y);\n\n  describe('A diagonal line is drawn from the top left of the canvas. The number 50 is written at the end of the line.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":534,"description":"<p>Re-maps a number from one range to another.<\/p>\n<p>For example, calling <code>map(2, 0, 10, 0, 100)<\/code> returns 20. The first three\narguments set the original value to 2 and the original range from 0 to 10.\nThe last two arguments set the target range from 0 to 100. 20's position\nin the target range [0, 100] is proportional to 2's position in the\noriginal range [0, 10].<\/p>\n<p>The sixth parameter, <code>withinBounds<\/code>, is optional. By default, <code>map()<\/code> can\nreturn values outside of the target range. For example,\n<code>map(11, 0, 10, 0, 100)<\/code> returns 110. Passing <code>true<\/code> as the sixth parameter\nconstrains the remapped value to the target range. For example,\n<code>map(11, 0, 10, 0, 100, true)<\/code> returns 100.<\/p>\n","itemtype":"method","name":"map","params":[{"name":"value","description":"<p>the value to be remapped.<\/p>\n","type":"Number"},{"name":"start1","description":"<p>lower bound of the value's current range.<\/p>\n","type":"Number"},{"name":"stop1","description":"<p>upper bound of the value's current range.<\/p>\n","type":"Number"},{"name":"start2","description":"<p>lower bound of the value's target range.<\/p>\n","type":"Number"},{"name":"stop2","description":"<p>upper bound of the value's target range.<\/p>\n","type":"Number"},{"name":"withinBounds","description":"<p>constrain the value to the newly mapped range.<\/p>\n","type":"Boolean","optional":true}],"return":{"description":"remapped number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Two horizontal lines. The top line grows horizontally as the mouse moves to the right. The bottom line also grows horizontally but is scaled to stay on the left half of the canvas.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the top line.\n  line(0, 25, mouseX, 25);\n\n  \/\/ Remap mouseX from [0, 100] to [0, 50].\n  let x = map(mouseX, 0, 100, 0, 50);\n\n  \/\/ Draw the bottom line.\n  line(0, 75, x, 75);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A circle changes color from black to white as the mouse moves from left to right.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Remap mouseX from [0, 100] to [0, 255]\n  let c = map(mouseX, 0, 100, 0, 255);\n\n  \/\/ Style the circle.\n  fill(c);\n\n  \/\/ Draw the circle.\n  circle(50, 50, 20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":618,"description":"<p>Returns the largest value in a sequence of numbers.<\/p>\n<p>The version of <code>max()<\/code> with one parameter interprets it as an array of\nnumbers and returns the largest number.<\/p>\n<p>The version of <code>max()<\/code> with two or more parameters interprets them as\nindividual numbers and returns the largest number.<\/p>\n","itemtype":"method","name":"max","return":{"description":"maximum number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate the maximum of 10, 5, and 20.\n  let m = max(10, 5, 20);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the max.\n  text(m, 50, 50);\n\n  describe('The number 20 written in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of numbers.\n  let numbers = [10, 5, 20];\n\n  \/\/ Calculate the maximum of the array.\n  let m = max(numbers);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the max.\n  text(m, 50, 50);\n\n  describe('The number 20 written in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation","overloads":[{"line":618,"params":[{"name":"n0","description":"<p>first number to compare.<\/p>\n","type":"Number"},{"name":"n1","description":"<p>second number to compare.<\/p>\n","type":"Number"}],"return":{"description":"maximum number.","type":"Number"}},{"line":680,"params":[{"name":"nums","description":"<p>numbers to compare.<\/p>\n","type":"Number[]"}],"return":{"description":"","type":"Number"}}]},{"file":"src\/math\/calculation.js","line":695,"description":"<p>Returns the smallest value in a sequence of numbers.<\/p>\n<p>The version of <code>min()<\/code> with one parameter interprets it as an array of\nnumbers and returns the smallest number.<\/p>\n<p>The version of <code>min()<\/code> with two or more parameters interprets them as\nindividual numbers and returns the smallest number.<\/p>\n","itemtype":"method","name":"min","return":{"description":"minimum number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate the minimum of 10, 5, and 20.\n  let m = min(10, 5, 20);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the min.\n  text(m, 50, 50);\n\n  describe('The number 5 written in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of numbers.\n  let numbers = [10, 5, 20];\n\n  \/\/ Calculate the minimum of the array.\n  let m = min(numbers);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the min.\n  text(m, 50, 50);\n\n  describe('The number 5 written in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation","overloads":[{"line":695,"params":[{"name":"n0","description":"<p>first number to compare.<\/p>\n","type":"Number"},{"name":"n1","description":"<p>second number to compare.<\/p>\n","type":"Number"}],"return":{"description":"minimum number.","type":"Number"}},{"line":757,"params":[{"name":"nums","description":"<p>numbers to compare.<\/p>\n","type":"Number[]"}],"return":{"description":"","type":"Number"}}]},{"file":"src\/math\/calculation.js","line":772,"description":"<p>Maps a number from one range to a value between 0 and 1.<\/p>\n<p>For example, <code>norm(2, 0, 10)<\/code> returns 0.2. 2's position in the original\nrange [0, 10] is proportional to 0.2's position in the range [0, 1]. This\nis the same as calling <code>map(2, 0, 10, 0, 1)<\/code>.<\/p>\n<p>Numbers outside of the original range are not constrained between 0 and 1.\nOut-of-range values are often intentional and useful.<\/p>\n","itemtype":"method","name":"norm","params":[{"name":"value","description":"<p>incoming value to be normalized.<\/p>\n","type":"Number"},{"name":"start","description":"<p>lower bound of the value's current range.<\/p>\n","type":"Number"},{"name":"stop","description":"<p>upper bound of the value's current range.<\/p>\n","type":"Number"}],"return":{"description":"normalized number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use RGB color with values from 0 to 1.\n  colorMode(RGB, 1);\n\n  describe('A square changes color from black to red as the mouse moves from left to right.');\n}\n\nfunction draw() {\n  \/\/ Calculate the redValue.\n  let redValue = norm(mouseX, 0, 100);\n\n  \/\/ Paint the background.\n  background(redValue, 0, 0);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":815,"description":"<p>Calculates exponential expressions such as <var>2<sup>3<\/sup><\/var>.<\/p>\n<p>For example, <code>pow(2, 3)<\/code> evaluates the expression\n2 \u00d7 2 \u00d7 2. <code>pow(2, -3)<\/code> evaluates 1 \u00f7\n(2 \u00d7 2 \u00d7 2).<\/p>\n","itemtype":"method","name":"pow","params":[{"name":"n","description":"<p>base of the exponential expression.<\/p>\n","type":"Number"},{"name":"e","description":"<p>power by which to raise the base.<\/p>\n","type":"Number"}],"return":{"description":"n^e.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the base of the exponent.\n  let base = 3;\n\n  \/\/ Top-left.\n  let d = pow(base, 1);\n  circle(10, 10, d);\n\n  \/\/ Left-center.\n  d = pow(base, 2);\n  circle(20, 20, d);\n\n  \/\/ Right-center.\n  d = pow(base, 3);\n  circle(40, 40, d);\n\n  \/\/ Bottom-right.\n  d = pow(base, 4);\n  circle(80, 80, d);\n\n  describe('A series of circles that grow exponentially from top left to bottom right.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":861,"description":"<p>Calculates the integer closest to a number.<\/p>\n<p>For example, <code>round(133.8)<\/code> returns the value 134.<\/p>\n<p>The second parameter, <code>decimals<\/code>, is optional. It sets the number of\ndecimal places to use when rounding. For example, <code>round(12.34, 1)<\/code> returns\n12.3. <code>decimals<\/code> is 0 by default.<\/p>\n","itemtype":"method","name":"round","params":[{"name":"n","description":"<p>number to round.<\/p>\n","type":"Number"},{"name":"decimals","description":"<p>number of decimal places to round to, default is 0.<\/p>\n","type":"Number","optional":true}],"return":{"description":"rounded number.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Round a number.\n  let x = round(4.2);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the rounded number.\n  text(x, 50, 50);\n\n  describe('The number 4 written in middle of the canvas.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Round a number to 2 decimal places.\n  let x = round(12.782383, 2);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the rounded number.\n  text(x, 50, 50);\n\n  describe('The number 12.78 written in middle of canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":928,"description":"<p>Calculates the square of a number.<\/p>\n<p>Squaring a number means multiplying the number by itself. For example,\n<code>sq(3)<\/code> evaluates 3 \u00d7 3 which is 9. <code>sq(-3)<\/code> evaluates -3 \u00d7 -3\nwhich is also 9. Multiplying two negative numbers produces a positive\nnumber. The value returned by <code>sq()<\/code> is always positive.<\/p>\n","itemtype":"method","name":"sq","params":[{"name":"n","description":"<p>number to square.<\/p>\n","type":"Number"}],"return":{"description":"squared number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top-left.\n  let d = sq(3);\n  circle(33, 33, d);\n\n  \/\/ Bottom-right.\n  d = sq(6);\n  circle(67, 67, d);\n\n  describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is four times larger.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots that get higher quickly from left to right.');\n}\n\nfunction draw() {\n  \/\/ Invert the y-axis.\n  scale(1, -1);\n  translate(0, -100);\n\n  \/\/ Calculate the coordinates.\n  let x = frameCount;\n  let y = 0.01 * sq(x);\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":988,"description":"<p>Calculates the square root of a number.<\/p>\n<p>A number's square root can be multiplied by itself to produce the original\nnumber. For example, <code>sqrt(9)<\/code> returns 3 because 3 \u00d7 3 = 9. <code>sqrt()<\/code>\nalways returns a positive value. <code>sqrt()<\/code> doesn't work with negative arguments\nsuch as <code>sqrt(-9)<\/code>.<\/p>\n","itemtype":"method","name":"sqrt","params":[{"name":"n","description":"<p>non-negative number to square root.<\/p>\n","type":"Number"}],"return":{"description":"square root of number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top-left.\n  let d = sqrt(16);\n  circle(33, 33, d);\n\n  \/\/ Bottom-right.\n  d = sqrt(1600);\n  circle(67, 67, d);\n\n  describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is ten times larger.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots that get higher slowly from left to right.');\n}\n\nfunction draw() {\n  \/\/ Invert the y-axis.\n  scale(1, -1);\n  translate(0, -100);\n\n  \/\/ Calculate the coordinates.\n  let x = frameCount;\n  let y = 5 * sqrt(x);\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/calculation.js","line":1048,"description":"<p>Calculates the fractional part of a number.<\/p>\n<p>A number's fractional part includes its decimal values. For example,\n<code>fract(12.34)<\/code> returns 0.34.<\/p>\n","itemtype":"method","name":"fract","params":[{"name":"n","description":"<p>number whose fractional part will be found.<\/p>\n","type":"Number"}],"return":{"description":"fractional part of n.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Original number.\n  let n = 56.78;\n  text(n, 50, 33);\n\n  \/\/ Fractional part.\n  let f = fract(n);\n  text(f, 50, 67);\n\n  describe('The number 56.78 written above the number 0.78.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Calculation"},{"file":"src\/math\/math.js","line":10,"description":"<p>Creates a new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n<p>A vector can be thought of in different ways. In one view, a vector is like\nan arrow pointing in space. Vectors have both magnitude (length) and\ndirection. This view is helpful for programming motion.<\/p>\n<p>A vector's components determine its magnitude and direction. For example,\ncalling <code>createVector(3, 4)<\/code> creates a new\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object with an x-component of 3 and a\ny-component of 4. From the origin, this vector's tip is 3 units to the\nright and 4 units down.<\/p>\n<p><a href=\"#\/p5.Vector\">p5.Vector<\/a> objects are often used to program\nmotion because they simplify the math. For example, a moving ball has a\nposition and a velocity. Position describes where the ball is in space. The\nball's position vector extends from the origin to the ball's center.\nVelocity describes the ball's speed and the direction it's moving. If the\nball is moving straight up, its velocity vector points straight up. Adding\nthe ball's velocity vector to its position vector moves it, as in\n<code>pos.add(vel)<\/code>. Vector math relies on methods inside the\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> class.<\/p>\n","itemtype":"method","name":"createVector","params":[{"name":"x","description":"<p>x component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z component of the vector.<\/p>\n","type":"Number","optional":true}],"return":{"description":"new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.","type":"p5.Vector"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let p1 = createVector(25, 25);\n  let p2 = createVector(50, 50);\n  let p3 = createVector(75, 75);\n\n  \/\/ Draw the dots.\n  strokeWeight(5);\n  point(p1);\n  point(p2);\n  point(p3);\n\n  describe('Three black dots form a diagonal line from top left to bottom right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet pos;\nlet vel;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create p5.Vector objects.\n  pos = createVector(50, 100);\n  vel = createVector(0, -1);\n\n  describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Add velocity to position.\n  pos.add(vel);\n\n  \/\/ If the dot reaches the top of the canvas,\n  \/\/ restart from the bottom.\n  if (pos.y < 0) {\n    pos.y = 100;\n  }\n\n  \/\/ Draw the dot.\n  strokeWeight(5);\n  point(pos);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Vector"},{"file":"src\/math\/noise.js","line":36,"description":"<p>Returns random numbers that can be tuned to feel organic.<\/p>\n<p>Values returned by <a href=\"#\/p5\/random\">random()<\/a> and\n<a href=\"#\/p5\/randomGaussian\">randomGaussian()<\/a> can change by large\namounts between function calls. By contrast, values returned by <code>noise()<\/code>\ncan be made \"smooth\". Calls to <code>noise()<\/code> with similar inputs will produce\nsimilar outputs. <code>noise()<\/code> is used to create textures, motion, shapes,\nterrains, and so on. Ken Perlin invented <code>noise()<\/code> while animating the\noriginal <em>Tron<\/em> film in the 1980s.<\/p>\n<p><code>noise()<\/code> always returns values between 0 and 1. It returns the same value\nfor a given input while a sketch is running. <code>noise()<\/code> produces different\nresults each time a sketch runs. The\n<a href=\"#\/p5\/noiseSeed\">noiseSeed()<\/a> function can be used to generate\nthe same sequence of Perlin noise values each time a sketch runs.<\/p>\n<p>The character of the noise can be adjusted in two ways. The first way is to\nscale the inputs. <code>noise()<\/code> interprets inputs as coordinates. The sequence\nof noise values will be smoother when the input coordinates are closer. The\nsecond way is to use the <a href=\"#\/p5\/noiseDetail\">noiseDetail()<\/a>\nfunction.<\/p>\n<p>The version of <code>noise()<\/code> with one parameter computes noise values in one\ndimension. This dimension can be thought of as space, as in <code>noise(x)<\/code>, or\ntime, as in <code>noise(t)<\/code>.<\/p>\n<p>The version of <code>noise()<\/code> with two parameters computes noise values in two\ndimensions. These dimensions can be thought of as space, as in\n<code>noise(x, y)<\/code>, or space and time, as in <code>noise(x, t)<\/code>.<\/p>\n<p>The version of <code>noise()<\/code> with three parameters computes noise values in\nthree dimensions. These dimensions can be thought of as space, as in\n<code>noise(x, y, z)<\/code>, or space and time, as in <code>noise(x, y, t)<\/code>.<\/p>\n","itemtype":"method","name":"noise","params":[{"name":"x","description":"<p>x-coordinate in noise space.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate in noise space.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z-coordinate in noise space.<\/p>\n","type":"Number","optional":true}],"return":{"description":"Perlin noise value at specified coordinates.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black dot moves randomly on a gray square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the coordinates.\n  let x = 100 * noise(0.005 * frameCount);\n  let y = 100 * noise(0.005 * frameCount + 10000);\n\n  \/\/ Draw the point.\n  strokeWeight(5);\n  point(x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black dot moves randomly on a gray square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the noise level and scale.\n  let noiseLevel = 100;\n  let noiseScale = 0.005;\n\n  \/\/ Scale the input coordinate.\n  let nt = noiseScale * frameCount;\n\n  \/\/ Compute the noise values.\n  let x = noiseLevel * noise(nt);\n  let y = noiseLevel * noise(nt + 10000);\n\n  \/\/ Draw the point.\n  strokeWeight(5);\n  point(x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A hilly terrain drawn in gray against a black sky.');\n}\n\nfunction draw() {\n  \/\/ Set the noise level and scale.\n  let noiseLevel = 100;\n  let noiseScale = 0.02;\n\n  \/\/ Scale the input coordinate.\n  let x = frameCount;\n  let nx = noiseScale * x;\n\n  \/\/ Compute the noise value.\n  let y = noiseLevel * noise(nx);\n\n  \/\/ Draw the line.\n  line(x, 0, x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A calm sea drawn in gray against a black sky.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Set the noise level and scale.\n  let noiseLevel = 100;\n  let noiseScale = 0.002;\n\n  \/\/ Iterate from left to right.\n  for (let x = 0; x < width; x += 1) {\n    \/\/ Scale the input coordinates.\n    let nx = noiseScale * x;\n    let nt = noiseScale * frameCount;\n\n    \/\/ Compute the noise value.\n    let y = noiseLevel * noise(nx, nt);\n\n    \/\/ Draw the line.\n    line(x, 0, x, y);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the noise level and scale.\n  let noiseLevel = 255;\n  let noiseScale = 0.01;\n\n  \/\/ Iterate from top to bottom.\n  for (let y = 0; y < height; y += 1) {\n    \/\/ Iterate from left to right.\n    for (let x = 0; x < width; x += 1) {\n      \/\/ Scale the input coordinates.\n      let nx = noiseScale * x;\n      let ny = noiseScale * y;\n\n      \/\/ Compute the noise value.\n      let c = noiseLevel * noise(nx, ny);\n\n      \/\/ Draw the point.\n      stroke(c);\n      point(x, y);\n    }\n  }\n\n  describe('A gray cloudy pattern.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A gray cloudy pattern that changes.');\n}\n\nfunction draw() {\n  \/\/ Set the noise level and scale.\n  let noiseLevel = 255;\n  let noiseScale = 0.009;\n\n  \/\/ Iterate from top to bottom.\n  for (let y = 0; y < height; y += 1) {\n    \/\/ Iterate from left to right.\n    for (let x = 0; x < width; x += 1) {\n      \/\/ Scale the input coordinates.\n      let nx = noiseScale * x;\n      let ny = noiseScale * y;\n      let nt = noiseScale * frameCount;\n\n      \/\/ Compute the noise value.\n      let c = noiseLevel * noise(nx, ny, nt);\n\n      \/\/ Draw the point.\n      stroke(c);\n      point(x, y);\n    }\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Noise"},{"file":"src\/math\/noise.js","line":331,"description":"<p>Adjusts the character of the noise produced by the\n<a href=\"#\/p5\/noise\">noise()<\/a> function.<\/p>\n<p>Perlin noise values are created by adding layers of noise together. The\nnoise layers, called octaves, are similar to harmonics in music. Lower\noctaves contribute more to the output signal. They define the overall\nintensity of the noise. Higher octaves create finer-grained details.<\/p>\n<p>By default, noise values are created by combining four octaves. Each higher\noctave contributes half as much (50% less) compared to its predecessor.\n<code>noiseDetail()<\/code> changes the number of octaves and the falloff amount. For\nexample, calling <code>noiseDetail(6, 0.25)<\/code> ensures that\n<a href=\"#\/p5\/noise\">noise()<\/a> will use six octaves. Each higher octave\nwill contribute 25% as much (75% less) compared to its predecessor. Falloff\nvalues between 0 and 1 are valid. However, falloff values greater than 0.5\nmight result in noise values greater than 1.<\/p>\n","itemtype":"method","name":"noiseDetail","params":[{"name":"lod","description":"<p>number of octaves to be used by the noise.<\/p>\n","type":"Number"},{"name":"falloff","description":"<p>falloff factor for each octave.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Set the noise level and scale.\n  let noiseLevel = 255;\n  let noiseScale = 0.02;\n\n  \/\/ Iterate from top to bottom.\n  for (let y = 0; y < height; y += 1) {\n    \/\/ Iterate from left to right.\n    for (let x = 0; x < width \/ 2; x += 1) {\n      \/\/ Scale the input coordinates.\n      let nx = noiseScale * x;\n      let ny = noiseScale * y;\n\n      \/\/ Compute the noise value with six octaves\n      \/\/ and a low falloff factor.\n      noiseDetail(6, 0.25);\n      let c = noiseLevel * noise(nx, ny);\n\n      \/\/ Draw the left side.\n      stroke(c);\n      point(x, y);\n\n      \/\/ Compute the noise value with four octaves\n      \/\/ and a high falloff factor.\n      noiseDetail(4, 0.5);\n      c = noiseLevel * noise(nx, ny);\n\n      \/\/ Draw the right side.\n      stroke(c);\n      point(x + 50, y);\n    }\n  }\n\n  describe('Two gray cloudy patterns. The pattern on the right is cloudier than the pattern on the left.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Noise"},{"file":"src\/math\/noise.js","line":405,"description":"<p>Sets the seed value for the <a href=\"#\/p5\/noise\">noise()<\/a> function.<\/p>\n<p>By default, <a href=\"#\/p5\/noise\">noise()<\/a> produces different results\neach time a sketch is run. Calling <code>noiseSeed()<\/code> with a constant argument,\nsuch as <code>noiseSeed(99)<\/code>, makes <a href=\"#\/p5\/noise\">noise()<\/a> produce the\nsame results each time a sketch is run.<\/p>\n","itemtype":"method","name":"noiseSeed","params":[{"name":"seed","description":"<p>seed value.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Set the noise seed for consistent results.\n  noiseSeed(99);\n\n  describe('A black rectangle that grows randomly, first to the right and then to the left.');\n}\n\nfunction draw() {\n  \/\/ Set the noise level and scale.\n  let noiseLevel = 100;\n  let noiseScale = 0.005;\n\n  \/\/ Scale the input coordinate.\n  let nt = noiseScale * frameCount;\n\n  \/\/ Compute the noise value.\n  let x = noiseLevel * noise(nt);\n\n  \/\/ Draw the line.\n  line(x, 0, x, height);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Noise"},{"file":"src\/math\/p5.Vector.js","line":113,"description":"<p>The x component of the vector<\/p>\n","type":"{Number}","itemtype":"property","name":"x","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":120,"description":"<p>The y component of the vector<\/p>\n","type":"{Number}","itemtype":"property","name":"y","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":127,"description":"<p>The z component of the vector<\/p>\n","type":"{Number}","itemtype":"property","name":"z","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":136,"description":"<p>Returns a string representation of a vector.<\/p>\n<p>Calling <code>toString()<\/code> is useful for printing vectors to the console while\ndebugging.<\/p>\n","itemtype":"method","name":"toString","return":{"description":"string representation of the vector.","type":"String"},"example":["\n<div class = \"norender\">\n<code>\nfunction setup() {\n  let v = createVector(20, 30);\n\n  \/\/ Prints 'p5.Vector Object : [20, 30, 0]'.\n  print(v.toString());\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":161,"description":"<p>Sets the vector's <code>x<\/code>, <code>y<\/code>, and <code>z<\/code> components.<\/p>\n<p><code>set()<\/code> can use separate numbers, as in <code>v.set(1, 2, 3)<\/code>, a\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object, as in <code>v.set(v2)<\/code>, or an\narray of numbers, as in <code>v.set([1, 2, 3])<\/code>.<\/p>\n<p>If a value isn't provided for a component, it will be set to 0. For\nexample, <code>v.set(4, 5)<\/code> sets <code>v.x<\/code> to 4, <code>v.y<\/code> to 5, and <code>v.z<\/code> to 0.\nCalling <code>set()<\/code> with no arguments, as in <code>v.set()<\/code>, sets all the vector's\ncomponents to 0.<\/p>\n","itemtype":"method","name":"set","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Top left.\n  let pos = createVector(25, 25);\n  point(pos);\n\n  \/\/ Top right.\n  \/\/ set() with numbers.\n  pos.set(75, 25);\n  point(pos);\n\n  \/\/ Bottom right.\n  \/\/ set() with a p5.Vector.\n  let p2 = createVector(75, 75);\n  pos.set(p2);\n  point(pos);\n\n  \/\/ Bottom left.\n  \/\/ set() with an array.\n  let arr = [25, 75];\n  pos.set(arr);\n  point(pos);\n\n  describe('Four black dots arranged in a square on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":161,"params":[{"name":"x","description":"<p>x component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z component of the vector.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":215,"params":[{"name":"value","description":"<p>vector to set.<\/p>\n","type":"p5.Vector|Number[]"}],"chainable":1}]},{"file":"src\/math\/p5.Vector.js","line":239,"description":"<p>Returns a copy of the <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","itemtype":"method","name":"copy","return":{"description":"copy of the <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.","type":"p5.Vector"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100 ,100);\n\n  background(200);\n\n  \/\/ Create a p5.Vector object.\n  let pos = createVector(50, 50);\n\n  \/\/ Make a copy.\n  let pc = pos.copy();\n\n  \/\/ Draw the point.\n  strokeWeight(5);\n  point(pc);\n\n  describe('A black point drawn in the middle of a gray square.');\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":239,"params":[],"return":{"description":"copy of the <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.","type":"p5.Vector"}},{"line":3341,"params":[{"name":"v","description":"<p>the <a href=\"#\/p5.Vector\">p5.Vector<\/a> to create a copy of<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"the copy of the <a href=\"#\/p5.Vector\">p5.Vector<\/a> object","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":282,"description":"<p>Adds to a vector's <code>x<\/code>, <code>y<\/code>, and <code>z<\/code> components.<\/p>\n<p><code>add()<\/code> can use separate numbers, as in <code>v.add(1, 2, 3)<\/code>,\nanother <a href=\"#\/p5.Vector\">p5.Vector<\/a> object, as in <code>v.add(v2)<\/code>, or\nan array of numbers, as in <code>v.add([1, 2, 3])<\/code>.<\/p>\n<p>If a value isn't provided for a component, it won't change. For\nexample, <code>v.add(4, 5)<\/code> adds 4 to <code>v.x<\/code>, 5 to <code>v.y<\/code>, and 0 to <code>v.z<\/code>.\nCalling <code>add()<\/code> with no arguments, as in <code>v.add()<\/code>, has no effect.<\/p>\n<p>The static version of <code>add()<\/code>, as in <code>p5.Vector.add(v2, v1)<\/code>, returns a new\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change the\noriginals.<\/p>\n","itemtype":"method","name":"add","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Top left.\n  let pos = createVector(25, 25);\n  point(pos);\n\n  \/\/ Top right.\n  \/\/ Add numbers.\n  pos.add(50, 0);\n  point(pos);\n\n  \/\/ Bottom right.\n  \/\/ Add a p5.Vector.\n  let p2 = createVector(0, 50);\n  pos.add(p2);\n  point(pos);\n\n  \/\/ Bottom left.\n  \/\/ Add an array.\n  let arr = [-50, 0];\n  pos.add(arr);\n  point(pos);\n\n  describe('Four black dots arranged in a square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top left.\n  let p1 = createVector(25, 25);\n\n  \/\/ Center.\n  let p2 = createVector(50, 50);\n\n  \/\/ Bottom right.\n  \/\/ Add p1 and p2.\n  let p3 = p5.Vector.add(p1, p2);\n\n  \/\/ Draw the points.\n  strokeWeight(5);\n  point(p1);\n  point(p2);\n  point(p3);\n\n  describe('Three black dots in a diagonal line from top left to bottom right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Three arrows drawn on a gray square. A red arrow extends from the top left corner to the center. A blue arrow extends from the tip of the red arrow. A purple arrow extends from the origin to the tip of the blue arrow.');\n}\n\nfunction draw() {\n  background(200);\n\n  let origin = createVector(0, 0);\n\n  \/\/ Draw the red arrow.\n  let v1 = createVector(50, 50);\n  drawArrow(origin, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  let v2 = createVector(-30, 20);\n  drawArrow(v1, v2, 'blue');\n\n  \/\/ Purple arrow.\n  let v3 = p5.Vector.add(v1, v2);\n  drawArrow(origin, v3, 'purple');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":282,"params":[{"name":"x","description":"<p>x component of the vector to be added.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y component of the vector to be added.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z component of the vector to be added.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":411,"params":[{"name":"value","description":"<p>The vector to add<\/p>\n","type":"p5.Vector|Number[]"}],"chainable":1},{"line":3353,"params":[{"name":"v1","description":"<p>A <a href=\"#\/p5.Vector\">p5.Vector<\/a> to add<\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>A <a href=\"#\/p5.Vector\">p5.Vector<\/a> to add<\/p>\n","type":"p5.Vector"},{"name":"target","description":"<p>vector to receive the result.<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"resulting <a href=\"#\/p5.Vector\">p5.Vector<\/a>.","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":466,"description":"<p>Performs modulo (remainder) division with a vector's <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>\ncomponents.<\/p>\n<p><code>rem()<\/code> can use separate numbers, as in <code>v.rem(1, 2, 3)<\/code>,\nanother <a href=\"#\/p5.Vector\">p5.Vector<\/a> object, as in <code>v.rem(v2)<\/code>, or\nan array of numbers, as in <code>v.rem([1, 2, 3])<\/code>.<\/p>\n<p>If only one value is provided, as in <code>v.rem(2)<\/code>, then all the components\nwill be set to their values modulo 2. If two values are provided, as in\n<code>v.rem(2, 3)<\/code>, then <code>v.z<\/code> won't change. Calling <code>rem()<\/code> with no\narguments, as in <code>v.rem()<\/code>, has no effect.<\/p>\n<p>The static version of <code>rem()<\/code>, as in <code>p5.Vector.rem(v2, v1)<\/code>, returns a\nnew <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change the\noriginals.<\/p>\n","itemtype":"method","name":"rem","chainable":1,"example":["\n<div class='norender'>\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(3, 4, 5);\n\n  \/\/ Divide numbers.\n  v.rem(2);\n\n  \/\/ Prints 'p5.Vector Object : [1, 0, 1]'.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(3, 4, 5);\n\n  \/\/ Divide numbers.\n  v.rem(2, 3);\n\n  \/\/ Prints 'p5.Vector Object : [1, 1, 5]'.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(3, 4, 5);\n\n  \/\/ Divide numbers.\n  v.rem(2, 3, 4);\n\n  \/\/ Prints 'p5.Vector Object : [1, 1, 1]'.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(3, 4, 5);\n  let v2 = createVector(2, 3, 4);\n\n  \/\/ Divide a p5.Vector.\n  v1.rem(v2);\n\n  \/\/ Prints 'p5.Vector Object : [1, 1, 1]'.\n  print(v1.toString());\n}\n<\/code>\n<\/div>\n\n<div class='norender'>\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(3, 4, 5);\n\n  \/\/ Divide an array.\n  let arr = [2, 3, 4];\n  v.rem(arr);\n\n  \/\/ Prints 'p5.Vector Object : [1, 1, 1]'.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(3, 4, 5);\n  let v2 = createVector(2, 3, 4);\n\n  \/\/ Divide without modifying the original vectors.\n  let v3 = p5.Vector.rem(v1, v2);\n\n  \/\/ Prints 'p5.Vector Object : [1, 1, 1]'.\n  print(v3.toString());\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":466,"params":[{"name":"x","description":"<p>x component of divisor vector.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y component of divisor vector.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z component of divisor vector.<\/p>\n","type":"Number"}],"chainable":1},{"line":583,"params":[{"name":"value","description":"<p>divisor vector.<\/p>\n","type":"p5.Vector | Number[]"}],"chainable":1},{"line":3380,"params":[{"name":"v1","description":"<p>The dividend <a href=\"#\/p5.Vector\">p5.Vector<\/a><\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>The divisor <a href=\"#\/p5.Vector\">p5.Vector<\/a><\/p>\n","type":"p5.Vector"}],"static":1},{"line":3386,"params":[{"name":"v1","description":"","type":"p5.Vector"},{"name":"v2","description":"","type":"p5.Vector"}],"static":1,"return":{"description":"The resulting <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":635,"description":"<p>Subtracts from a vector's <code>x<\/code>, <code>y<\/code>, and <code>z<\/code> components.<\/p>\n<p><code>sub()<\/code> can use separate numbers, as in <code>v.sub(1, 2, 3)<\/code>, another\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object, as in <code>v.sub(v2)<\/code>, or an array\nof numbers, as in <code>v.sub([1, 2, 3])<\/code>.<\/p>\n<p>If a value isn't provided for a component, it won't change. For\nexample, <code>v.sub(4, 5)<\/code> subtracts 4 from <code>v.x<\/code>, 5 from <code>v.y<\/code>, and 0 from <code>v.z<\/code>.\nCalling <code>sub()<\/code> with no arguments, as in <code>v.sub()<\/code>, has no effect.<\/p>\n<p>The static version of <code>sub()<\/code>, as in <code>p5.Vector.sub(v2, v1)<\/code>, returns a new\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change the\noriginals.<\/p>\n","itemtype":"method","name":"sub","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Bottom right.\n  let pos = createVector(75, 75);\n  point(pos);\n\n  \/\/ Top right.\n  \/\/ Subtract numbers.\n  pos.sub(0, 50);\n  point(pos);\n\n  \/\/ Top left.\n  \/\/ Subtract a p5.Vector.\n  let p2 = createVector(50, 0);\n  pos.sub(p2);\n  point(pos);\n\n  \/\/ Bottom left.\n  \/\/ Subtract an array.\n  let arr = [0, -50];\n  pos.sub(arr);\n  point(pos);\n\n  describe('Four black dots arranged in a square on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let p1 = createVector(75, 75);\n  let p2 = createVector(50, 50);\n\n  \/\/ Subtract without modifying the original vectors.\n  let p3 = p5.Vector.sub(p1, p2);\n\n  \/\/ Draw the points.\n  strokeWeight(5);\n  point(p1);\n  point(p2);\n  point(p3);\n\n  describe('Three black dots in a diagonal line from top left to bottom right.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Three arrows drawn on a gray square. A red and a blue arrow extend from the top left. A purple arrow extends from the tip of the red arrow to the tip of the blue arrow.');\n}\n\nfunction draw() {\n  background(200);\n\n  let origin = createVector(0, 0);\n\n  \/\/ Draw the red arrow.\n  let v1 = createVector(50, 50);\n  drawArrow(origin, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  let v2 = createVector(20, 70);\n  drawArrow(origin, v2, 'blue');\n\n  \/\/ Purple arrow.\n  let v3 = p5.Vector.sub(v2, v1);\n  drawArrow(v1, v3, 'purple');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":635,"params":[{"name":"x","description":"<p>x component of the vector to subtract.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y component of the vector to subtract.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z component of the vector to subtract.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":761,"params":[{"name":"value","description":"<p>the vector to subtract<\/p>\n","type":"p5.Vector|Number[]"}],"chainable":1},{"line":3405,"params":[{"name":"v1","description":"<p>A <a href=\"#\/p5.Vector\">p5.Vector<\/a> to subtract from<\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>A <a href=\"#\/p5.Vector\">p5.Vector<\/a> to subtract<\/p>\n","type":"p5.Vector"},{"name":"target","description":"<p>vector to receive the result.<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":785,"description":"<p>Multiplies a vector's <code>x<\/code>, <code>y<\/code>, and <code>z<\/code> components.<\/p>\n<p><code>mult()<\/code> can use separate numbers, as in <code>v.mult(1, 2, 3)<\/code>, another\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object, as in <code>v.mult(v2)<\/code>, or an array\nof numbers, as in <code>v.mult([1, 2, 3])<\/code>.<\/p>\n<p>If only one value is provided, as in <code>v.mult(2)<\/code>, then all the components\nwill be multiplied by 2. If a value isn't provided for a component, it\nwon't change. For example, <code>v.mult(4, 5)<\/code> multiplies <code>v.x<\/code> by 4, <code>v.y<\/code> by 5,\nand <code>v.z<\/code> by 1. Calling <code>mult()<\/code> with no arguments, as in <code>v.mult()<\/code>, has\nno effect.<\/p>\n<p>The static version of <code>mult()<\/code>, as in <code>p5.Vector.mult(v, 2)<\/code>, returns a new\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change the\noriginals.<\/p>\n","itemtype":"method","name":"mult","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Top-left.\n  let p = createVector(25, 25);\n  point(p);\n\n  \/\/ Center.\n  \/\/ Multiply all components by 2.\n  p.mult(2);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  strokeWeight(5);\n\n  \/\/ Top-left.\n  let p = createVector(25, 25);\n  point(p);\n\n  \/\/ Bottom-right.\n  \/\/ Multiply p.x * 2 and p.y * 3\n  p.mult(2, 3);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Top-left.\n  let p = createVector(25, 25);\n  point(p);\n\n  \/\/ Bottom-right.\n  \/\/ Multiply p.x * 2 and p.y * 3\n  let arr = [2, 3];\n  p.mult(arr);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Top-left.\n  let p = createVector(25, 25);\n  point(p);\n\n  \/\/ Bottom-right.\n  \/\/ Multiply p.x * p2.x and p.y * p2.y\n  let p2 = createVector(2, 3);\n  p.mult(p2);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Top-left.\n  let p = createVector(25, 25);\n  point(p);\n\n  \/\/ Bottom-right.\n  \/\/ Create a new p5.Vector with\n  \/\/ p3.x = p.x * p2.x\n  \/\/ p3.y = p.y * p2.y\n  let p2 = createVector(2, 3);\n  let p3 = p5.Vector.mult(p, p2);\n  point(p3);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Two arrows extending from the top left corner. The blue arrow is twice the length of the red arrow.');\n}\nfunction draw() {\n  background(200);\n\n  let origin = createVector(0, 0);\n\n  \/\/ Draw the red arrow.\n  let v1 = createVector(25, 25);\n  drawArrow(origin, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  let v2 = p5.Vector.mult(v1, 2);\n  drawArrow(origin, v2, 'blue');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":785,"params":[{"name":"n","description":"<p>The number to multiply with the vector<\/p>\n","type":"Number"}],"chainable":1},{"line":965,"params":[{"name":"x","description":"<p>number to multiply with the x component of the vector.<\/p>\n","type":"Number"},{"name":"y","description":"<p>number to multiply with the y component of the vector.<\/p>\n","type":"Number"},{"name":"z","description":"<p>number to multiply with the z component of the vector.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":973,"params":[{"name":"arr","description":"<p>array to multiply with the components of the vector.<\/p>\n","type":"Number[]"}],"chainable":1},{"line":979,"params":[{"name":"v","description":"<p>vector to multiply with the components of the original vector.<\/p>\n","type":"p5.Vector"}],"chainable":1},{"line":3435,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number","optional":true}],"static":1,"return":{"description":"resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>.","type":"p5.Vector"}},{"line":3444,"params":[{"name":"v","description":"","type":"p5.Vector"},{"name":"n","description":"","type":"Number"},{"name":"target","description":"<p>vector to receive the result.<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}},{"line":3453,"params":[{"name":"v0","description":"","type":"p5.Vector"},{"name":"v1","description":"","type":"p5.Vector"},{"name":"target","description":"","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}},{"line":3462,"params":[{"name":"v0","description":"","type":"p5.Vector"},{"name":"arr","description":"","type":"Number[]"},{"name":"target","description":"","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":1065,"description":"<p>Divides a vector's <code>x<\/code>, <code>y<\/code>, and <code>z<\/code> components.<\/p>\n<p><code>div()<\/code> can use separate numbers, as in <code>v.div(1, 2, 3)<\/code>, another\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object, as in <code>v.div(v2)<\/code>, or an array\nof numbers, as in <code>v.div([1, 2, 3])<\/code>.<\/p>\n<p>If only one value is provided, as in <code>v.div(2)<\/code>, then all the components\nwill be divided by 2. If a value isn't provided for a component, it\nwon't change. For example, <code>v.div(4, 5)<\/code> divides <code>v.x<\/code> by, <code>v.y<\/code> by 5,\nand <code>v.z<\/code> by 1. Calling <code>div()<\/code> with no arguments, as in <code>v.div()<\/code>, has\nno effect.<\/p>\n<p>The static version of <code>div()<\/code>, as in <code>p5.Vector.div(v, 2)<\/code>, returns a new\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change the\noriginals.<\/p>\n","itemtype":"method","name":"div","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Center.\n  let p = createVector(50, 50);\n  point(p);\n\n  \/\/ Top-left.\n  \/\/ Divide p.x \/ 2 and p.y \/ 2\n  p.div(2);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Bottom-right.\n  let p = createVector(50, 75);\n  point(p);\n\n  \/\/ Top-left.\n  \/\/ Divide p.x \/ 2 and p.y \/ 3\n  p.div(2, 3);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Bottom-right.\n  let p = createVector(50, 75);\n  point(p);\n\n  \/\/ Top-left.\n  \/\/ Divide p.x \/ 2 and p.y \/ 3\n  let arr = [2, 3];\n  p.div(arr);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Bottom-right.\n  let p = createVector(50, 75);\n  point(p);\n\n  \/\/ Top-left.\n  \/\/ Divide p.x \/ 2 and p.y \/ 3\n  let p2 = createVector(2, 3);\n  p.div(p2);\n  point(p);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the points.\n  strokeWeight(5);\n\n  \/\/ Bottom-right.\n  let p = createVector(50, 75);\n  point(p);\n\n  \/\/ Top-left.\n  \/\/ Create a new p5.Vector with\n  \/\/ p3.x = p.x \/ p2.x\n  \/\/ p3.y = p.y \/ p2.y\n  let p2 = createVector(2, 3);\n  let p3 = p5.Vector.div(p, p2);\n  point(p3);\n\n  describe('Two black dots drawn on a gray square. One dot is in the top left corner and the other is in the bottom center.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction draw() {\n  background(200);\n\n  let origin = createVector(0, 0);\n\n  \/\/ Draw the red arrow.\n  let v1 = createVector(50, 50);\n  drawArrow(origin, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  let v2 = p5.Vector.div(v1, 2);\n  drawArrow(origin, v2, 'blue');\n\n  describe('Two arrows extending from the top left corner. The blue arrow is half the length of the red arrow.');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1065,"params":[{"name":"n","description":"<p>The number to divide the vector by<\/p>\n","type":"Number"}],"chainable":1},{"line":1247,"params":[{"name":"x","description":"<p>number to divide with the x component of the vector.<\/p>\n","type":"Number"},{"name":"y","description":"<p>number to divide with the y component of the vector.<\/p>\n","type":"Number"},{"name":"z","description":"<p>number to divide with the z component of the vector.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1255,"params":[{"name":"arr","description":"<p>array to divide the components of the vector by.<\/p>\n","type":"Number[]"}],"chainable":1},{"line":1261,"params":[{"name":"v","description":"<p>vector to divide the components of the original vector by.<\/p>\n","type":"p5.Vector"}],"chainable":1},{"line":3520,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}},{"line":3529,"params":[{"name":"v","description":"","type":"p5.Vector"},{"name":"n","description":"","type":"Number"},{"name":"target","description":"<p>The vector to receive the result<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}},{"line":3538,"params":[{"name":"v0","description":"","type":"p5.Vector"},{"name":"v1","description":"","type":"p5.Vector"},{"name":"target","description":"","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}},{"line":3547,"params":[{"name":"v0","description":"","type":"p5.Vector"},{"name":"arr","description":"","type":"Number[]"},{"name":"target","description":"","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":1362,"description":"<p>Calculates the magnitude (length) of the vector.<\/p>\n<p>Use <a href=\"#\/p5\/mag\">mag()<\/a> to calculate the magnitude of a 2D vector\nusing components as in <code>mag(x, y)<\/code>.<\/p>\n","itemtype":"method","name":"mag","return":{"description":"magnitude of the vector.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Vector object.\n  let p = createVector(30, 40);\n\n  \/\/ Draw a line from the origin.\n  line(0, 0, p.x, p.y);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the vector's magnitude.\n  let m = p.mag();\n  text(m, p.x, p.y);\n\n  describe('A diagonal black line extends from the top left corner of a gray square. The number 50 is written at the end of the line.');\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1362,"params":[],"return":{"description":"magnitude of the vector.","type":"Number"}},{"line":3682,"params":[{"name":"vecT","description":"<p>The vector to return the magnitude of<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"The magnitude of vecT","type":"Number"}}]},{"file":"src\/math\/p5.Vector.js","line":1402,"description":"<p>Calculates the magnitude (length) of the vector squared.<\/p>\n","itemtype":"method","name":"magSq","return":{"description":"squared magnitude of the vector.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Vector object.\n  let p = createVector(30, 40);\n\n  \/\/ Draw a line from the origin.\n  line(0, 0, p.x, p.y);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n\n  \/\/ Display the vector's magnitude squared.\n  let m = p.magSq();\n  text(m, p.x, p.y);\n\n  describe('A diagonal black line extends from the top left corner of a gray square. The number 2500 is written at the end of the line.');\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1402,"params":[],"return":{"description":"squared magnitude of the vector.","type":"Number"}},{"line":3698,"params":[{"name":"vecT","description":"<p>the vector to return the squared magnitude of<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"the squared magnitude of vecT","type":"Number"}}]},{"file":"src\/math\/p5.Vector.js","line":1441,"description":"<p>Calculates the dot product of two vectors.<\/p>\n<p>The dot product is a number that describes the overlap between two vectors.\nVisually, the dot product can be thought of as the \"shadow\" one vector\ncasts on another. The dot product's magnitude is largest when two vectors\npoint in the same or opposite directions. Its magnitude is 0 when two\nvectors form a right angle.<\/p>\n<p>The version of <code>dot()<\/code> with one parameter interprets it as another\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n<p>The version of <code>dot()<\/code> with multiple parameters interprets them as the\n<code>x<\/code>, <code>y<\/code>, and <code>z<\/code> components of another vector.<\/p>\n<p>The static version of <code>dot()<\/code>, as in <code>p5.Vector.dot(v1, v2)<\/code>, is the same\nas calling <code>v1.dot(v2)<\/code>.<\/p>\n","itemtype":"method","name":"dot","return":{"description":"dot product.","type":"Number"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(3, 4);\n  let v2 = createVector(3, 0);\n\n  \/\/ Calculate the dot product.\n  let dp = v1.dot(v2);\n\n  \/\/ Prints \"9\" to the console.\n  print(dp);\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(1, 0);\n  let v2 = createVector(0, 1);\n\n  \/\/ Calculate the dot product.\n  let dp = p5.Vector.dot(v1, v2);\n\n  \/\/ Prints \"0\" to the console.\n  print(dp);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Two arrows drawn on a gray square. A black arrow points to the right and a red arrow follows the mouse. The text \"v1 \u2022 v2 = something\" changes as the mouse moves.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Center.\n  let v0 = createVector(50, 50);\n\n  \/\/ Draw the black arrow.\n  let v1 = createVector(30, 0);\n  drawArrow(v0, v1, 'black');\n\n  \/\/ Draw the red arrow.\n  let v2 = createVector(mouseX - 50, mouseY - 50);\n  drawArrow(v0, v2, 'red');\n\n  \/\/ Display the dot product.\n  let dp = v2.dot(v1);\n  text(`v2 \u2022 v1 = ${dp}`, 10, 20);\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1441,"params":[{"name":"x","description":"<p>x component of the vector.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z component of the vector.<\/p>\n","type":"Number","optional":true}],"return":{"description":"dot product.","type":"Number"}},{"line":1542,"params":[{"name":"v","description":"<p><a href=\"#\/p5.Vector\">p5.Vector<\/a> to be dotted.<\/p>\n","type":"p5.Vector"}],"return":{"description":"","type":"Number"}},{"line":3576,"params":[{"name":"v1","description":"<p>first <a href=\"#\/p5.Vector\">p5.Vector<\/a>.<\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>second <a href=\"#\/p5.Vector\">p5.Vector<\/a>.<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"dot product.","type":"Number"}}]},{"file":"src\/math\/p5.Vector.js","line":1554,"description":"<p>Calculates the cross product of two vectors.<\/p>\n<p>The cross product is a vector that points straight out of the plane created\nby two vectors. The cross product's magnitude is the area of the parallelogram\nformed by the original two vectors.<\/p>\n<p>The static version of <code>cross()<\/code>, as in <code>p5.Vector.cross(v1, v2)<\/code>, is the same\nas calling <code>v1.cross(v2)<\/code>.<\/p>\n","itemtype":"method","name":"cross","return":{"description":"cross product as a <a href=\"#\/p5.Vector\">p5.Vector<\/a>.","type":"p5.Vector"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(1, 0);\n  let v2 = createVector(3, 4);\n\n  \/\/ Calculate the cross product.\n  let cp = v1.cross(v2);\n\n  \/\/ Prints \"p5.Vector Object : [0, 0, 4]\" to the console.\n  print(cp.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(1, 0);\n  let v2 = createVector(3, 4);\n\n  \/\/ Calculate the cross product.\n  let cp = p5.Vector.cross(v1, v2);\n\n  \/\/ Prints \"p5.Vector Object : [0, 0, 4]\" to the console.\n  print(cp.toString());\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1554,"params":[{"name":"v","description":"<p><a href=\"#\/p5.Vector\">p5.Vector<\/a> to be crossed.<\/p>\n","type":"p5.Vector"}],"return":{"description":"cross product as a <a href=\"#\/p5.Vector\">p5.Vector<\/a>.","type":"p5.Vector"}},{"line":3590,"params":[{"name":"v1","description":"<p>first <a href=\"#\/p5.Vector\">p5.Vector<\/a>.<\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>second <a href=\"#\/p5.Vector\">p5.Vector<\/a>.<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"cross product.","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":1612,"description":"<p>Calculates the distance between two points represented by vectors.<\/p>\n<p>A point's coordinates can be represented by the components of a vector\nthat extends from the origin to the point.<\/p>\n<p>The static version of <code>dist()<\/code>, as in <code>p5.Vector.dist(v1, v2)<\/code>, is the same\nas calling <code>v1.dist(v2)<\/code>.<\/p>\n<p>Use <a href=\"#\/p5\/dist\">dist()<\/a> to calculate the distance between points\nusing coordinates as in <code>dist(x1, y1, x2, y2)<\/code>.<\/p>\n","itemtype":"method","name":"dist","return":{"description":"distance.","type":"Number"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(1, 0);\n  let v2 = createVector(0, 1);\n\n  \/\/ Calculate the distance between them.\n  let d = v1.dist(v2);\n\n  \/\/ Prints \"1.414...\" to the console.\n  print(d);\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let v1 = createVector(1, 0);\n  let v2 = createVector(0, 1);\n\n  \/\/ Calculate the distance between them.\n  let d = p5.Vector.dist(v1, v2);\n\n  \/\/ Prints \"1.414...\" to the console.\n  print(d);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Three arrows drawn on a gray square. A red and a blue arrow extend from the top left. A purple arrow extends from the tip of the red arrow to the tip of the blue arrow. The number 36 is written in black near the purple arrow.');\n}\n\nfunction draw() {\n  background(200);\n\n  let origin = createVector(0, 0);\n\n  \/\/ Draw the red arrow.\n  let v1 = createVector(50, 50);\n  drawArrow(origin, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  let v2 = createVector(20, 70);\n  drawArrow(origin, v2, 'blue');\n\n  \/\/ Purple arrow.\n  let v3 = p5.Vector.sub(v2, v1);\n  drawArrow(v1, v3, 'purple');\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n\n  \/\/ Display the magnitude. The same as floor(v3.mag());\n  let m = floor(p5.Vector.dist(v1, v2));\n  text(m, 50, 75);\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1612,"params":[{"name":"v","description":"<p>x, y, and z coordinates of a <a href=\"#\/p5.Vector\">p5.Vector<\/a>.<\/p>\n","type":"p5.Vector"}],"return":{"description":"distance.","type":"Number"}},{"line":3605,"params":[{"name":"v1","description":"<p>The first <a href=\"#\/p5.Vector\">p5.Vector<\/a><\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>The second <a href=\"#\/p5.Vector\">p5.Vector<\/a><\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"The distance","type":"Number"}}]},{"file":"src\/math\/p5.Vector.js","line":1726,"description":"<p>Scales the components of a <a href=\"#\/p5.Vector\">p5.Vector<\/a> object so\nthat its magnitude is 1.<\/p>\n<p>The static version of <code>normalize()<\/code>,  as in <code>p5.Vector.normalize(v)<\/code>,\nreturns a new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change\nthe original.<\/p>\n","itemtype":"method","name":"normalize","return":{"description":"normalized <a href=\"#\/p5.Vector\">p5.Vector<\/a>.","type":"p5.Vector"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Vector.\n  let v = createVector(10, 20, 2);\n\n  \/\/ Normalize.\n  v.normalize();\n\n  \/\/ Prints \"p5.Vector Object : [0.445..., 0.890..., 0.089...]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a p5.Vector.\n  let v0 = createVector(10, 20, 2);\n\n  \/\/ Create a normalized copy.\n  let v1 = p5.Vector.normalize(v0);\n\n  \/\/ Prints \"p5.Vector Object : [10, 20, 2]\" to the console.\n  print(v0.toString());\n  \/\/ Prints \"p5.Vector Object : [0.445..., 0.890..., 0.089...]\" to the console.\n  print(v1.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A red and blue arrow extend from the center of a circle. Both arrows follow the mouse, but the blue arrow's length is fixed to the circle's radius.\");\n}\n\nfunction draw() {\n  background(240);\n\n  \/\/ Vector to the center.\n  let v0 = createVector(50, 50);\n\n  \/\/ Vector from the center to the mouse.\n  let v1 = createVector(mouseX - 50, mouseY - 50);\n\n  \/\/ Circle's radius.\n  let r = 25;\n\n  \/\/ Draw the red arrow.\n  drawArrow(v0, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  v1.normalize();\n  drawArrow(v0, v1.mult(r), 'blue');\n\n  \/\/ Draw the circle.\n  noFill();\n  circle(50, 50, r * 2);\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1726,"params":[],"return":{"description":"normalized <a href=\"#\/p5.Vector\">p5.Vector<\/a>.","type":"p5.Vector"}},{"line":3711,"params":[{"name":"v","description":"<p>The vector to normalize<\/p>\n","type":"p5.Vector"},{"name":"target","description":"<p>The vector to receive the result<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The vector v, normalized to a length of 1","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":1835,"description":"<p>Limits a vector's magnitude to a maximum value.<\/p>\n<p>The static version of <code>limit()<\/code>, as in <code>p5.Vector.limit(v, 5)<\/code>, returns a\nnew <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change the\noriginal.<\/p>\n","itemtype":"method","name":"limit","chainable":1,"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(10, 20, 2);\n\n  \/\/ Limit its magnitude.\n  v.limit(5);\n\n  \/\/ Prints \"p5.Vector Object : [2.227..., 4.454..., 0.445...]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v0 = createVector(10, 20, 2);\n\n  \/\/ Create a copy an limit its magintude.\n  let v1 = p5.Vector.limit(v0, 5);\n\n  \/\/ Prints \"p5.Vector Object : [2.227..., 4.454..., 0.445...]\" to the console.\n  print(v1.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\"A red and blue arrow extend from the center of a circle. Both arrows follow the mouse, but the blue arrow never crosses the circle's edge.\");\n}\nfunction draw() {\n  background(240);\n\n  \/\/ Vector to the center.\n  let v0 = createVector(50, 50);\n\n  \/\/ Vector from the center to the mouse.\n  let v1 = createVector(mouseX - 50, mouseY - 50);\n\n  \/\/ Circle's radius.\n  let r = 25;\n\n  \/\/ Draw the red arrow.\n  drawArrow(v0, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  drawArrow(v0, v1.limit(r), 'blue');\n\n  \/\/ Draw the circle.\n  noFill();\n  circle(50, 50, r * 2);\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1835,"params":[{"name":"max","description":"<p>maximum magnitude for the vector.<\/p>\n","type":"Number"}],"chainable":1},{"line":3738,"params":[{"name":"v","description":"<p>the vector to limit<\/p>\n","type":"p5.Vector"},{"name":"max","description":"","type":"Number"},{"name":"target","description":"<p>the vector to receive the result (Optional)<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"v with a magnitude limited to max","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":1933,"description":"<p>Sets a vector's magnitude to a given value.<\/p>\n<p>The static version of <code>setMag()<\/code>, as in <code>p5.Vector.setMag(v, 10)<\/code>, returns\na new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change the\noriginal.<\/p>\n","itemtype":"method","name":"setMag","chainable":1,"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(3, 4, 0);\n\n  \/\/ Prints \"5\" to the console.\n  print(v.mag());\n\n  \/\/ Set its magnitude to 10.\n  v.setMag(10);\n\n  \/\/ Prints \"p5.Vector Object : [6, 8, 0]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v0 = createVector(3, 4, 0);\n\n  \/\/ Create a copy with a magnitude of 10.\n  let v1 = p5.Vector.setMag(v0, 10);\n\n  \/\/ Prints \"5\" to the console.\n  print(v0.mag());\n\n  \/\/ Prints \"p5.Vector Object : [6, 8, 0]\" to the console.\n  print(v1.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Two arrows extend from the top left corner of a square toward its center. The red arrow reaches the center and the blue arrow only extends part of the way.');\n}\n\nfunction draw() {\n  background(240);\n\n  let origin = createVector(0, 0);\n  let v = createVector(50, 50);\n\n  \/\/ Draw the red arrow.\n  drawArrow(origin, v, 'red');\n\n  \/\/ Set v's magnitude to 30.\n  v.setMag(30);\n\n  \/\/ Draw the blue arrow.\n  drawArrow(origin, v, 'blue');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":1933,"params":[{"name":"len","description":"<p>new length for this vector.<\/p>\n","type":"Number"}],"chainable":1},{"line":3766,"params":[{"name":"v","description":"<p>the vector to set the magnitude of<\/p>\n","type":"p5.Vector"},{"name":"len","description":"","type":"Number"},{"name":"target","description":"<p>the vector to receive the result (Optional)<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"v with a magnitude set to len","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":2026,"description":"<p>Calculates the angle a 2D vector makes with the positive x-axis.<\/p>\n<p>By convention, the positive x-axis has an angle of 0. Angles increase in\nthe clockwise direction.<\/p>\n<p>If the vector was created with\n<a href=\"#\/p5\/createVector\">createVector()<\/a>, <code>heading()<\/code> returns angles\nin the units of the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>The static version of <code>heading()<\/code>, as in <code>p5.Vector.heading(v)<\/code>, works the\nsame way.<\/p>\n","itemtype":"method","name":"heading","return":{"description":"angle of rotation.","type":"Number"},"example":["\n<div class = \"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(1, 1);\n\n  \/\/ Prints \"0.785...\" to the console.\n  print(v.heading());\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Prints \"45\" to the console.\n  print(v.heading());\n}\n<\/code>\n<\/div>\n\n<div class = \"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(1, 1);\n\n  \/\/ Prints \"0.785...\" to the console.\n  print(p5.Vector.heading(v));\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Prints \"45\" to the console.\n  print(p5.Vector.heading(v));\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black arrow extends from the top left of a square to its center. The text \"Radians: 0.79\" and \"Degrees: 45\" is written near the tip of the arrow.');\n}\n\nfunction draw() {\n  background(200);\n\n  let origin = createVector(0, 0);\n  let v = createVector(50, 50);\n\n  \/\/ Draw the black arrow.\n  drawArrow(origin, v, 'black');\n\n  \/\/ Use radians.\n  angleMode(RADIANS);\n\n  \/\/ Display the heading in radians.\n  let h = round(v.heading(), 2);\n  text(`Radians: ${h}`, 20, 70);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Display the heading in degrees.\n  h = v.heading();\n  text(`Degrees: ${h}`, 20, 85);\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":2026,"params":[],"return":{"description":"angle of rotation.","type":"Number"}},{"line":3796,"params":[{"name":"v","description":"<p>the vector to find the angle of<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"the angle of rotation","type":"Number"}}]},{"file":"src\/math\/p5.Vector.js","line":2134,"description":"<p>Rotates a 2D vector to a specific angle without changing its magnitude.<\/p>\n<p>By convention, the positive x-axis has an angle of 0. Angles increase in\nthe clockwise direction.<\/p>\n<p>If the vector was created with\n<a href=\"#\/p5\/createVector\">createVector()<\/a>, <code>setHeading()<\/code> uses\nthe units of the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","itemtype":"method","name":"setHeading","params":[{"name":"angle","description":"<p>angle of rotation.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(0, 1);\n\n  \/\/ Prints \"1.570...\" to the console.\n  print(v.heading());\n\n  \/\/ Point to the left.\n  v.setHeading(PI);\n\n  \/\/ Prints \"3.141...\" to the console.\n  print(v.heading());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Create a p5.Vector object.\n  let v = createVector(0, 1);\n\n  \/\/ Prints \"90\" to the console.\n  print(v.heading());\n\n  \/\/ Point to the left.\n  v.setHeading(180);\n\n  \/\/ Prints \"180\" to the console.\n  print(v.heading());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Two arrows extend from the center of a gray square. The red arrow points to the right and the blue arrow points down.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(50, 50);\n  let v1 = createVector(30, 0);\n\n  \/\/ Draw the red arrow.\n  drawArrow(v0, v1, 'red');\n\n  \/\/ Point down.\n  v1.setHeading(HALF_PI);\n\n  \/\/ Draw the blue arrow.\n  drawArrow(v0, v1, 'blue');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":2238,"description":"<p>Rotates a 2D vector by an angle without changing its magnitude.<\/p>\n<p>By convention, the positive x-axis has an angle of 0. Angles increase in\nthe clockwise direction.<\/p>\n<p>If the vector was created with\n<a href=\"#\/p5\/createVector\">createVector()<\/a>, <code>rotate()<\/code> uses\nthe units of the current <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n<p>The static version of <code>rotate()<\/code>, as in <code>p5.Vector.rotate(v, PI)<\/code>,\nreturns a new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change\nthe original.<\/p>\n","itemtype":"method","name":"rotate","chainable":1,"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(1, 0);\n\n  \/\/ Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\n  print(v.toString());\n\n  \/\/ Rotate a quarter turn.\n  v.rotate(HALF_PI);\n\n  \/\/ Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Create a p5.Vector object.\n  let v = createVector(1, 0);\n\n  \/\/ Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\n  print(v.toString());\n\n  \/\/ Rotate a quarter turn.\n  v.rotate(90);\n\n  \/\/ Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v0 = createVector(1, 0);\n\n  \/\/ Create a rotated copy.\n  let v1 = p5.Vector.rotate(v0, HALF_PI);\n\n  \/\/ Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\n  print(v0.toString());\n  \/\/ Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\n  print(v1.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Create a p5.Vector object.\n  let v0 = createVector(1, 0);\n\n  \/\/ Create a rotated copy.\n  let v1 = p5.Vector.rotate(v0, 90);\n\n  \/\/ Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\n  print(v0.toString());\n\n  \/\/ Prints \"p5.Vector Object : [0, 1, 0]\" to the console.\n  print(v1.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet v0;\nlet v1;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Create p5.Vector objects.\n  v0 = createVector(50, 50);\n  v1 = createVector(30, 0);\n\n  describe('A black arrow extends from the center of a gray square. The arrow rotates clockwise.');\n}\n\nfunction draw() {\n  background(240);\n\n  \/\/ Rotate v1.\n  v1.rotate(0.01);\n\n  \/\/ Draw the black arrow.\n  drawArrow(v0, v1, 'black');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":2238,"params":[{"name":"angle","description":"<p>angle of rotation.<\/p>\n","type":"Number"}],"chainable":1},{"line":3491,"params":[{"name":"v","description":"","type":"p5.Vector"},{"name":"angle","description":"","type":"Number"},{"name":"target","description":"<p>The vector to receive the result<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The resulting new <a href=\"#\/p5.Vector\">p5.Vector<\/a>","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":2384,"description":"<p>Calculates the angle between two vectors.<\/p>\n<p>The angles returned are signed, which means that\n<code>v1.angleBetween(v2) === -v2.angleBetween(v1)<\/code>.<\/p>\n<p>If the vector was created with\n<a href=\"#\/p5\/createVector\">createVector()<\/a>, <code>angleBetween()<\/code> returns\nangles in the units of the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","itemtype":"method","name":"angleBetween","return":{"description":"angle between the vectors.","type":"Number"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(1, 0);\n  let v1 = createVector(0, 1);\n\n  \/\/ Prints \"1.570...\" to the console.\n  print(v0.angleBetween(v1));\n\n  \/\/ Prints \"-1.570...\" to the console.\n  print(v1.angleBetween(v0));\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(1, 0);\n  let v1 = createVector(0, 1);\n\n  \/\/ Prints \"90\" to the console.\n  print(v0.angleBetween(v1));\n\n  \/\/ Prints \"-90\" to the console.\n  print(v1.angleBetween(v0));\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(1, 0);\n  let v1 = createVector(0, 1);\n\n  \/\/ Prints \"1.570...\" to the console.\n  print(p5.Vector.angleBetween(v0, v1));\n\n  \/\/ Prints \"-1.570...\" to the console.\n  print(p5.Vector.angleBetween(v1, v0));\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(1, 0);\n  let v1 = createVector(0, 1);\n\n  \/\/ Prints \"90\" to the console.\n  print(p5.Vector.angleBetween(v0, v1));\n\n  \/\/ Prints \"-90\" to the console.\n  print(p5.Vector.angleBetween(v1, v0));\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Two arrows extend from the center of a gray square. A red arrow points to the right and a blue arrow points down. The text \"Radians: 1.57\" and \"Degrees: 90\" is written above the arrows.');\n}\nfunction draw() {\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(50, 50);\n  let v1 = createVector(30, 0);\n  let v2 = createVector(0, 30);\n\n  \/\/ Draw the red arrow.\n  drawArrow(v0, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  drawArrow(v0, v2, 'blue');\n\n  \/\/ Use radians.\n  angleMode(RADIANS);\n\n  \/\/ Display the angle in radians.\n  let angle = round(v1.angleBetween(v2), 2);\n  text(`Radians: ${angle}`, 20, 20);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Display the angle in degrees.\n  angle = round(v1.angleBetween(v2), 2);\n  text(`Degrees: ${angle}`, 20, 35);\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":2384,"params":[{"name":"value","description":"<p>x, y, and z components of a <a href=\"#\/p5.Vector\">p5.Vector<\/a>.<\/p>\n","type":"p5.Vector"}],"return":{"description":"angle between the vectors.","type":"Number"}},{"line":3811,"params":[{"name":"v1","description":"<p>the first vector.<\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>the second vector.<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"angle between the two vectors.","type":"Number"}}]},{"file":"src\/math\/p5.Vector.js","line":2538,"description":"<p>Calculates new <code>x<\/code>, <code>y<\/code>, and <code>z<\/code> components that are proportionally the\nsame distance between two vectors.<\/p>\n<p>The <code>amt<\/code> parameter is the amount to interpolate between the old vector and\nthe new vector. 0.0 keeps all components equal to the old vector's, 0.5 is\nhalfway between, and 1.0 sets all components equal to the new vector's.<\/p>\n<p>The static version of <code>lerp()<\/code>, as in <code>p5.Vector.lerp(v0, v1, 0.5)<\/code>,\nreturns a new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change\nthe original.<\/p>\n","itemtype":"method","name":"lerp","chainable":1,"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v0 = createVector(1, 1, 1);\n  let v1 = createVector(3, 3, 3);\n\n  \/\/ Interpolate.\n  v0.lerp(v1, 0.5);\n\n  \/\/ Prints \"p5.Vector Object : [2, 2, 2]\" to the console.\n  print(v0.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(1, 1, 1);\n\n  \/\/ Interpolate.\n  v.lerp(3, 3, 3, 0.5);\n\n  \/\/ Prints \"p5.Vector Object : [2, 2, 2]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(1, 1, 1);\n  let v1 = createVector(3, 3, 3);\n\n  \/\/ Interpolate.\n  let v2 = p5.Vector.lerp(v0, v1, 0.5);\n\n  \/\/ Prints \"p5.Vector Object : [2, 2, 2]\" to the console.\n  print(v2.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Three arrows extend from the center of a gray square. A red arrow points to the right, a blue arrow points down, and a purple arrow points to the bottom right.');\n}\nfunction draw() {\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(50, 50);\n  let v1 = createVector(30, 0);\n  let v2 = createVector(0, 30);\n\n  \/\/ Interpolate.\n  let v3 = p5.Vector.lerp(v1, v2, 0.5);\n\n  \/\/ Draw the red arrow.\n  drawArrow(v0, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  drawArrow(v0, v2, 'blue');\n\n  \/\/ Draw the purple arrow.\n  drawArrow(v0, v3, 'purple');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":2538,"params":[{"name":"x","description":"<p>x component.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y component.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z component.<\/p>\n","type":"Number"},{"name":"amt","description":"<p>amount of interpolation between 0.0 (old vector)\n                        and 1.0 (new vector). 0.5 is halfway between.<\/p>\n","type":"Number"}],"chainable":1},{"line":2651,"params":[{"name":"v","description":"<p><a href=\"#\/p5.Vector\">p5.Vector<\/a> to lerp toward.<\/p>\n","type":"p5.Vector"},{"name":"amt","description":"","type":"Number"}],"chainable":1},{"line":3620,"params":[{"name":"v1","description":"","type":"p5.Vector"},{"name":"v2","description":"","type":"p5.Vector"},{"name":"amt","description":"","type":"Number"},{"name":"target","description":"<p>The vector to receive the result<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"The lerped value","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":2667,"description":"<p>Calculates a new heading and magnitude that are between two vectors.<\/p>\n<p>The <code>amt<\/code> parameter is the amount to interpolate between the old vector and\nthe new vector. 0.0 keeps the heading and magnitude equal to the old\nvector's, 0.5 sets them halfway between, and 1.0 sets the heading and\nmagnitude equal to the new vector's.<\/p>\n<p><code>slerp()<\/code> differs from <a href=\"#\/p5.Vector\/lerp\">lerp()<\/a> because\nit interpolates magnitude. Calling <code>v0.slerp(v1, 0.5)<\/code> sets <code>v0<\/code>'s\nmagnitude to a value halfway between its original magnitude and <code>v1<\/code>'s.\nCalling <code>v0.lerp(v1, 0.5)<\/code> makes no such guarantee.<\/p>\n<p>The static version of <code>slerp()<\/code>, as in <code>p5.Vector.slerp(v0, v1, 0.5)<\/code>,\nreturns a new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change\nthe original.<\/p>\n","itemtype":"method","name":"slerp","return":{"description":"","type":"p5.Vector"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v0 = createVector(3, 0);\n\n  \/\/ Prints \"3\" to the console.\n  print(v0.mag());\n\n  \/\/ Prints \"0\" to the console.\n  print(v0.heading());\n\n  \/\/ Create a p5.Vector object.\n  let v1 = createVector(0, 1);\n\n  \/\/ Prints \"1\" to the console.\n  print(v1.mag());\n\n  \/\/ Prints \"1.570...\" to the console.\n  print(v1.heading());\n\n  \/\/ Interpolate halfway between v0 and v1.\n  v0.slerp(v1, 0.5);\n\n  \/\/ Prints \"2\" to the console.\n  print(v0.mag());\n\n  \/\/ Prints \"0.785...\" to the console.\n  print(v0.heading());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v0 = createVector(3, 0);\n\n  \/\/ Prints \"3\" to the console.\n  print(v0.mag());\n\n  \/\/ Prints \"0\" to the console.\n  print(v0.heading());\n\n  \/\/ Create a p5.Vector object.\n  let v1 = createVector(0, 1);\n\n  \/\/ Prints \"1\" to the console.\n  print(v1.mag());\n\n  \/\/ Prints \"1.570...\" to the console.\n  print(v1.heading());\n\n  \/\/ Create a p5.Vector that's halfway between v0 and v1.\n  let v3 = p5.Vector.slerp(v0, v1, 0.5);\n\n  \/\/ Prints \"2\" to the console.\n  print(v3.mag());\n\n  \/\/ Prints \"0.785...\" to the console.\n  print(v3.heading());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Three arrows extend from the center of a gray square. A red arrow points to the right, a blue arrow points to the left, and a purple arrow points down.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(50, 50);\n  let v1 = createVector(20, 0);\n  let v2 = createVector(-40, 0);\n\n  \/\/ Create a p5.Vector that's halfway between v1 and v2.\n  let v3 = p5.Vector.slerp(v1, v2, 0.5);\n\n  \/\/ Draw the red arrow.\n  drawArrow(v0, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  drawArrow(v0, v2, 'blue');\n\n  \/\/ Draw the purple arrow.\n  drawArrow(v0, v3, 'purple');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":2667,"params":[{"name":"v","description":"<p><a href=\"#\/p5.Vector\">p5.Vector<\/a> to slerp toward.<\/p>\n","type":"p5.Vector"},{"name":"amt","description":"<p>amount of interpolation between 0.0 (old vector)\n                     and 1.0 (new vector). 0.5 is halfway between.<\/p>\n","type":"Number"}],"return":{"description":"","type":"p5.Vector"}},{"line":3652,"params":[{"name":"v1","description":"<p>old vector.<\/p>\n","type":"p5.Vector"},{"name":"v2","description":"<p>new vector.<\/p>\n","type":"p5.Vector"},{"name":"amt","description":"","type":"Number"},{"name":"target","description":"<p>vector to receive the result.<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"slerped vector between v1 and v2","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":2869,"description":"<p>Reflects a vector about a line in 2D or a plane in 3D.<\/p>\n<p>The orientation of the line or plane is described by a normal vector that\npoints away from the shape.<\/p>\n<p>The static version of <code>reflect()<\/code>, as in <code>p5.Vector.reflect(v, n)<\/code>,\nreturns a new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object and doesn't change\nthe original.<\/p>\n","itemtype":"method","name":"reflect","chainable":1,"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a normal vector.\n  let n = createVector(0, 1);\n  \/\/ Create a vector to reflect.\n  let v = createVector(4, 6);\n\n  \/\/ Reflect v about n.\n  v.reflect(n);\n\n  \/\/ Prints \"p5.Vector Object : [4, -6, 0]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a normal vector.\n  let n = createVector(0, 1);\n\n  \/\/ Create a vector to reflect.\n  let v0 = createVector(4, 6);\n\n  \/\/ Create a reflected vector.\n  let v1 = p5.Vector.reflect(v0, n);\n\n  \/\/ Prints \"p5.Vector Object : [4, -6, 0]\" to the console.\n  print(v1.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('Three arrows extend from the center of a gray square with a vertical line down its middle. A black arrow points to the right, a blue arrow points to the bottom left, and a red arrow points to the bottom right.');\n}\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a vertical line.\n  line(50, 0, 50, 100);\n\n  \/\/ Create a normal vector.\n  let n = createVector(1, 0);\n\n  \/\/ Center.\n  let v0 = createVector(50, 50);\n\n  \/\/ Create a vector to reflect.\n  let v1 = createVector(30, 40);\n\n  \/\/ Create a reflected vector.\n  let v2 = p5.Vector.reflect(v1, n);\n\n  \/\/ Scale the normal vector for drawing.\n  n.setMag(30);\n\n  \/\/ Draw the black arrow.\n  drawArrow(v0, n, 'black');\n\n  \/\/ Draw the red arrow.\n  drawArrow(v0, v1, 'red');\n\n  \/\/ Draw the blue arrow.\n  drawArrow(v0, v2, 'blue');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":2869,"params":[{"name":"surfaceNormal","description":"<p><a href=\"#\/p5.Vector\">p5.Vector<\/a>\n                                   to reflect about.<\/p>\n","type":"p5.Vector"}],"chainable":1},{"line":3826,"params":[{"name":"incidentVector","description":"<p>vector to be reflected.<\/p>\n","type":"p5.Vector"},{"name":"surfaceNormal","description":"","type":"p5.Vector"},{"name":"target","description":"<p>vector to receive the result.<\/p>\n","type":"p5.Vector","optional":true}],"static":1,"return":{"description":"the reflected vector","type":"p5.Vector"}}]},{"file":"src\/math\/p5.Vector.js","line":2979,"description":"<p>Returns the vector's components as an array of numbers.<\/p>\n","itemtype":"method","name":"array","return":{"description":"array with the vector's components.","type":"Number[]"},"example":["\n<div class = \"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = createVector(20, 30);\n\n  \/\/ Prints \"[20, 30, 0]\" to the console.\n  print(v.array());\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":2979,"params":[],"return":{"description":"array with the vector's components.","type":"Number[]"}},{"line":3856,"params":[{"name":"v","description":"<p>the vector to convert to an array<\/p>\n","type":"p5.Vector"}],"static":1,"return":{"description":"an Array with the 3 values","type":"Number[]"}}]},{"file":"src\/math\/p5.Vector.js","line":3001,"description":"<p>Checks whether all the vector's components are equal to another vector's.<\/p>\n<p><code>equals()<\/code> returns <code>true<\/code> if the vector's components are all the same as another\nvector's and <code>false<\/code> if not.<\/p>\n<p>The version of <code>equals()<\/code> with one parameter interprets it as another\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n<p>The version of <code>equals()<\/code> with multiple parameters interprets them as the\ncomponents of another vector. Any missing parameters are assigned the value\n0.<\/p>\n<p>The static version of <code>equals()<\/code>, as in <code>p5.Vector.equals(v0, v1)<\/code>,\ninterprets both parameters as <a href=\"#\/p5.Vector\">p5.Vector<\/a> objects.<\/p>\n","itemtype":"method","name":"equals","return":{"description":"whether the vectors are equal.","type":"Boolean"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(10, 20, 30);\n  let v1 = createVector(10, 20, 30);\n  let v2 = createVector(0, 0, 0);\n\n  \/\/ Prints \"true\" to the console.\n  print(v0.equals(v1));\n\n  \/\/ Prints \"false\" to the console.\n  print(v0.equals(v2));\n}\n<\/code>\n<\/div>\n\n<div class = \"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(5, 10, 20);\n  let v1 = createVector(5, 10, 20);\n  let v2 = createVector(13, 10, 19);\n\n  \/\/ Prints \"true\" to the console.\n  print(v0.equals(v1.x, v1.y, v1.z));\n\n  \/\/ Prints \"false\" to the console.\n  print(v0.equals(v2.x, v2.y, v2.z));\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create p5.Vector objects.\n  let v0 = createVector(10, 20, 30);\n  let v1 = createVector(10, 20, 30);\n  let v2 = createVector(0, 0, 0);\n\n  \/\/ Prints \"true\" to the console.\n  print(p5.Vector.equals(v0, v1));\n\n  \/\/ Prints \"false\" to the console.\n  print(p5.Vector.equals(v0, v2));\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector","overloads":[{"line":3001,"params":[{"name":"x","description":"<p>x component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y component of the vector.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z component of the vector.<\/p>\n","type":"Number","optional":true}],"return":{"description":"whether the vectors are equal.","type":"Boolean"}},{"line":3074,"params":[{"name":"value","description":"<p>vector to compare.<\/p>\n","type":"p5.Vector|Array"}],"return":{"description":"","type":"Boolean"}},{"line":3869,"params":[{"name":"v1","description":"<p>the first vector to compare<\/p>\n","type":"p5.Vector|Array"},{"name":"v2","description":"<p>the second vector to compare<\/p>\n","type":"p5.Vector|Array"}],"static":1,"return":{"description":"","type":"Boolean"}}]},{"file":"src\/math\/p5.Vector.js","line":3099,"description":"<p>Creates a new 2D vector from an angle.<\/p>\n","itemtype":"method","name":"fromAngle","static":1,"params":[{"name":"angle","description":"<p>desired angle, in radians. Unaffected by <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"},{"name":"length","description":"<p>length of the new vector (defaults to 1).<\/p>\n","type":"Number","optional":true}],"return":{"description":"new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.","type":"p5.Vector"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = p5.Vector.fromAngle(0);\n\n  \/\/ Prints \"p5.Vector Object : [1, 0, 0]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = p5.Vector.fromAngle(0, 30);\n\n  \/\/ Prints \"p5.Vector Object : [30, 0, 0]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A black arrow extends from the center of a gray square. It points to the right.');\n}\nfunction draw() {\n  background(200);\n\n  \/\/ Create a p5.Vector to the center.\n  let v0 = createVector(50, 50);\n\n  \/\/ Create a p5.Vector with an angle 0 and magnitude 30.\n  let v1 = p5.Vector.fromAngle(0, 30);\n\n  \/\/ Draw the black arrow.\n  drawArrow(v0, v1, 'black');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3174,"description":"<p>Creates a new 3D vector from a pair of ISO spherical angles.<\/p>\n","itemtype":"method","name":"fromAngles","static":1,"params":[{"name":"theta","description":"<p>polar angle in radians (zero is up).<\/p>\n","type":"Number"},{"name":"phi","description":"<p>azimuthal angle in radians\n                              (zero is out of the screen).<\/p>\n","type":"Number"},{"name":"length","description":"<p>length of the new vector (defaults to 1).<\/p>\n","type":"Number","optional":true}],"return":{"description":"new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.","type":"p5.Vector"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = p5.Vector.fromAngles(0, 0);\n\n  \/\/ Prints \"p5.Vector Object : [0, -1, 0]\" to the console.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A light shines on a pink sphere as it orbits.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Calculate the ISO angles.\n  let theta = frameCount *  0.05;\n  let phi = 0;\n\n  \/\/ Create a p5.Vector object.\n  let v = p5.Vector.fromAngles(theta, phi, 100);\n\n  \/\/ Create a point light using the p5.Vector.\n  let c = color('deeppink');\n  pointLight(c, v);\n\n  \/\/ Style the sphere.\n  fill(255);\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(35);\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3243,"description":"<p>Creates a new 2D unit vector with a random heading.<\/p>\n","itemtype":"method","name":"random2D","static":1,"return":{"description":"new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.","type":"p5.Vector"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = p5.Vector.random2D();\n\n  \/\/ Prints \"p5.Vector Object : [x, y, 0]\" to the console\n  \/\/ where x and y are small random numbers.\n  print(v.toString());\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(1);\n\n  describe('A black arrow in extends from the center of a gray square. It changes direction once per second.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create a p5.Vector to the center.\n  let v0 = createVector(50, 50);\n\n  \/\/ Create a random p5.Vector.\n  let v1 = p5.Vector.random2D();\n\n  \/\/ Scale v1 for drawing.\n  v1.mult(30);\n\n  \/\/ Draw the black arrow.\n  drawArrow(v0, v1, 'black');\n}\n\n\/\/ Draws an arrow between two vectors.\nfunction drawArrow(base, vec, myColor) {\n  push();\n  stroke(myColor);\n  strokeWeight(3);\n  fill(myColor);\n  translate(base.x, base.y);\n  line(0, 0, vec.x, vec.y);\n  rotate(vec.heading());\n  let arrowSize = 7;\n  translate(vec.mag() - arrowSize, 0);\n  triangle(0, arrowSize \/ 2, 0, -arrowSize \/ 2, arrowSize, 0);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3311,"description":"<p>Creates a new 3D unit vector with a random heading.<\/p>\n","itemtype":"method","name":"random3D","static":1,"return":{"description":"new <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.","type":"p5.Vector"},"example":["\n<div class=\"norender\">\n<code>\nfunction setup() {\n  \/\/ Create a p5.Vector object.\n  let v = p5.Vector.random3D();\n\n  \/\/ Prints \"p5.Vector Object : [x, y, z]\" to the console\n  \/\/ where x, y, and z are small random numbers.\n  print(v.toString());\n}\n<\/code>\n<\/div>"],"class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3431,"description":"<p>Multiplies a vector by a scalar and returns a new vector.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3487,"description":"<p>Rotates the vector (only 2D vectors) by the given angle; magnitude remains the same. Returns a new vector.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3516,"description":"<p>Divides a vector by a scalar and returns a new vector.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3573,"description":"<p>Calculates the dot product of two vectors.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3587,"description":"<p>Calculates the cross product of two vectors.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3601,"description":"<p>Calculates the Euclidean distance between two points (considering a\npoint as a vector object).<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3616,"description":"<p>Linear interpolate a vector to another vector and return the result as a\nnew vector.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3646,"description":"<p>Performs spherical linear interpolation with the other vector\nand returns the resulting vector.\nThis works in both 3D and 2D. As for 2D, the result of slerping\nbetween 2D vectors is always a 2D vector.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3678,"description":"<p>Calculates the magnitude (length) of the vector and returns the result as\na float (this is simply the equation <code>sqrt(x*x + y*y + z*z)<\/code>.)<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3692,"description":"<p>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.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3708,"description":"<p>Normalize the vector to length 1 (make it a unit vector).<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3734,"description":"<p>Limit the magnitude of the vector to the value used for the <b>max<\/b>\nparameter.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3762,"description":"<p>Set the magnitude of the vector to the value used for the <b>len<\/b>\nparameter.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3790,"description":"<p>Calculate the angle of rotation for this vector (only 2D vectors).\np5.Vectors created using <a href=\"#\/p5\/createVector\">createVector()<\/a>\nwill take the current <a href=\"#\/p5\/angleMode\">angleMode<\/a> into\nconsideration, and give the angle in radians or degrees accordingly.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3806,"description":"<p>Calculates and returns the angle between two vectors. This function will take\nthe <a href=\"#\/p5\/angleMode\">angleMode<\/a> on v1 into consideration, and\ngive the angle in radians or degrees accordingly.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3822,"description":"<p>Reflect a vector about a normal to a line in 2D, or about a normal to a\nplane in 3D.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3850,"description":"<p>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.<a href=\"#\/p5.Vector\/copy\">copy()<\/a><\/b>\nmethod to copy into your own vector.<\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3866,"description":"<p>Equality check against a <a href=\"#\/p5.Vector\">p5.Vector<\/a><\/p>\n","class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/p5.Vector.js","line":3892,"description":"<p>Replaces the components of a <a href=\"#\/p5.Vector\">p5.Vector<\/a> that are very close to zero with zero.<\/p>\n<p>In computers, handling numbers with decimals can give slightly imprecise answers due to the way those numbers are represented.\nThis can make it hard to check if a number is zero, as it may be close but not exactly zero.\nThis method rounds very close numbers to zero to make those checks easier<\/p>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Number\/EPSILON\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Number\/EPSILON<\/a><\/p>\n","itemtype":"method","name":"clampToZero","return":{"description":"with components very close to zero replaced with zero.","type":"p5.Vector"},"chainable":1,"class":"p5.Vector","module":"Math","submodule":"Vector"},{"file":"src\/math\/random.js","line":37,"description":"<p>Sets the seed value for the <a href=\"#\/p5\/random\">random()<\/a> and\n<a href=\"#\/p5\/randomGaussian\">randomGaussian()<\/a> functions.<\/p>\n<p>By default, <a href=\"#\/p5\/random\">random()<\/a> and\n<a href=\"#\/p5\/randomGaussian\">randomGaussian()<\/a> produce different\nresults each time a sketch is run. Calling <code>randomSeed()<\/code> with a constant\nargument, such as <code>randomSeed(99)<\/code>, makes these functions produce the same\nresults each time a sketch is run.<\/p>\n","itemtype":"method","name":"randomSeed","params":[{"name":"seed","description":"<p>seed value.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get random coordinates.\n  let x = random(0, 100);\n  let y = random(0, 100);\n\n  \/\/ Draw the white circle.\n  circle(x, y, 10);\n\n  \/\/ Set a random seed for consistency.\n  randomSeed(99);\n\n  \/\/ Get random coordinates.\n  x = random(0, 100);\n  y = random(0, 100);\n\n  \/\/ Draw the black circle.\n  fill(0);\n  circle(x, y, 10);\n\n  describe('A white circle appears at a random position. A black circle appears at (27.4, 25.8).');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Random"},{"file":"src\/math\/random.js","line":86,"description":"<p>Returns a random number or a random element from an array.<\/p>\n<p><code>random()<\/code> follows uniform distribution, which means that all outcomes are\nequally likely. When <code>random()<\/code> is used to generate numbers, all\nnumbers in the output range are equally likely to be returned. When\n<code>random()<\/code> is used to select elements from an array, all elements are\nequally likely to be chosen.<\/p>\n<p>By default, <code>random()<\/code> produces different results each time a sketch runs.\nThe <a href=\"#\/p5\/randomSeed\">randomSeed()<\/a> function can be used to\ngenerate the same sequence of numbers or choices each time a sketch runs.<\/p>\n<p>The version of <code>random()<\/code> with no parameters returns a random number from 0\nup to but not including 1.<\/p>\n<p>The version of <code>random()<\/code> with one parameter works one of two ways. If the\nargument passed is a number, <code>random()<\/code> returns a random number from 0 up\nto but not including the number. For example, calling <code>random(5)<\/code> returns\nvalues between 0 and 5. If the argument passed is an array, <code>random()<\/code>\nreturns a random element from that array. For example, calling\n<code>random(['\ud83e\udd81', '\ud83d\udc2f', '\ud83d\udc3b'])<\/code> returns either a lion, tiger, or bear emoji.<\/p>\n<p>The version of <code>random()<\/code> with two parameters returns a random number from\na given range. The arguments passed set the range's lower and upper bounds.\nFor example, calling <code>random(-5, 10.2)<\/code> returns values from -5 up to but\nnot including 10.2.<\/p>\n","itemtype":"method","name":"random","return":{"description":"random number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get random coordinates between 0 and 100.\n  let x = random(0, 100);\n  let y = random(0, 100);\n\n  \/\/ Draw a point.\n  strokeWeight(5);\n  point(x, y);\n\n  describe('A black dot appears in a random position on a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get random coordinates between 0 and 100.\n  let x = random(100);\n  let y = random(100);\n\n  \/\/ Draw the point.\n  strokeWeight(5);\n  point(x, y);\n\n  describe('A black dot appears in a random position on a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of emoji strings.\n  let animals = ['\ud83e\udd81', '\ud83d\udc2f', '\ud83d\udc3b'];\n\n  \/\/ Choose a random element from the array.\n  let choice = random(animals);\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(20);\n\n  \/\/ Display the emoji.\n  text(choice, 50, 50);\n\n  describe('An animal face is displayed at random. Either a lion, tiger, or bear.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(5);\n\n  describe('A black dot moves around randomly on a gray square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Get random coordinates between 0 and 100.\n  let x = random(100);\n  let y = random(100);\n\n  \/\/ Draw the point.\n  strokeWeight(5);\n  point(x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Slow the frame rate.\n  frameRate(5);\n\n  describe('A black dot moves around randomly in the middle of a gray square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Get random coordinates between 45 and 55.\n  let x = random(45, 55);\n  let y = random(45, 55);\n\n  \/\/ Draw the point.\n  strokeWeight(5);\n  point(x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A black dot moves around randomly leaving a trail.');\n}\n\nfunction draw() {\n  \/\/ Update x and y randomly.\n  x += random(-1, 1);\n  y += random(-1, 1);\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Random","overloads":[{"line":86,"params":[{"name":"min","description":"<p>lower bound (inclusive).<\/p>\n","type":"Number","optional":true},{"name":"max","description":"<p>upper bound (exclusive).<\/p>\n","type":"Number","optional":true}],"return":{"description":"random number.","type":"Number"}},{"line":259,"params":[{"name":"choices","description":"<p>array to choose from.<\/p>\n","type":"Array"}],"return":{"description":"random element from the array.","type":"*"}}]},{"file":"src\/math\/random.js","line":292,"description":"<p>Returns a random number fitting a Gaussian, or normal, distribution.<\/p>\n<p>Normal distributions look like bell curves when plotted. Values from a\nnormal distribution cluster around a central value called the mean. The\ncluster's standard deviation describes its spread.<\/p>\n<p>By default, <code>randomGaussian()<\/code> produces different results each time a\nsketch runs. The <a href=\"#\/p5\/randomSeed\">randomSeed()<\/a> function can be\nused to generate the same sequence of numbers each time a sketch runs.<\/p>\n<p>There's no minimum or maximum value that <code>randomGaussian()<\/code> might return.\nValues far from the mean are very unlikely and values near the mean are\nvery likely.<\/p>\n<p>The version of <code>randomGaussian()<\/code> with no parameters returns values with a\nmean of 0 and standard deviation of 1.<\/p>\n<p>The version of <code>randomGaussian()<\/code> with one parameter interprets the\nargument passed as the mean. The standard deviation is 1.<\/p>\n<p>The version of <code>randomGaussian()<\/code> with two parameters interprets the first\nargument passed as the mean and the second as the standard deviation.<\/p>\n","itemtype":"method","name":"randomGaussian","params":[{"name":"mean","description":"<p>mean.<\/p>\n","type":"Number","optional":true},{"name":"sd","description":"<p>standard deviation.<\/p>\n","type":"Number","optional":true}],"return":{"description":"random number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('Three horizontal black lines are filled in randomly. The top line spans entire canvas. The middle line is very short. The bottom line spans two-thirds of the canvas.');\n}\n\nfunction draw() {\n  \/\/ Style the circles.\n  noStroke();\n  fill(0, 10);\n\n  \/\/ Uniform distribution between 0 and 100.\n  let x = random(100);\n  let y = 25;\n  circle(x, y, 5);\n\n  \/\/ Gaussian distribution with a mean of 50 and sd of 1.\n  x = randomGaussian(50);\n  y = 50;\n  circle(x, y, 5);\n\n  \/\/ Gaussian distribution with a mean of 50 and sd of 10.\n  x = randomGaussian(50, 10);\n  y = 75;\n  circle(x, y, 5);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Random"},{"file":"src\/math\/trigonometry.js","line":18,"description":"<p>Calculates the arc cosine of a number.<\/p>\n<p><code>acos()<\/code> is the inverse of <a href=\"#\/p5\/cos\">cos()<\/a>. It expects\narguments in the range -1 to 1. By default, <code>acos()<\/code> returns values in the\nrange 0 to \u03c0 (about 3.14). If the\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a> is <code>DEGREES<\/code>, then values are\nreturned in the range 0 to 180.<\/p>\n","itemtype":"method","name":"acos","params":[{"name":"value","description":"<p>value whose arc cosine is to be returned.<\/p>\n","type":"Number"}],"return":{"description":"arc cosine of the given value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate cos() and acos() values.\n  let a = PI;\n  let c = cos(a);\n  let ac = acos(c);\n\n  \/\/ Display the values.\n  text(`${round(a, 3)}`, 35, 25);\n  text(`${round(c, 3)}`, 35, 50);\n  text(`${round(ac, 3)}`, 35, 75);\n\n  describe('The numbers 3.142, -1, and 3.142 written on separate rows.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate cos() and acos() values.\n  let a = PI + QUARTER_PI;\n  let c = cos(a);\n  let ac = acos(c);\n\n  \/\/ Display the values.\n  text(`${round(a, 3)}`, 35, 25);\n  text(`${round(c, 3)}`, 35, 50);\n  text(`${round(ac, 3)}`, 35, 75);\n\n  describe('The numbers 3.927, -0.707, and 2.356 written on separate rows.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":80,"description":"<p>Calculates the arc sine of a number.<\/p>\n<p><code>asin()<\/code> is the inverse of <a href=\"#\/p5\/sin\">sin()<\/a>. It expects input\nvalues in the range of -1 to 1. By default, <code>asin()<\/code> returns values in the\nrange -\u03c0 \u00f7 2 (about -1.57) to \u03c0 \u00f7 2 (about 1.57). If\nthe <a href=\"#\/p5\/angleMode\">angleMode()<\/a> is <code>DEGREES<\/code> then values are\nreturned in the range -90 to 90.<\/p>\n","itemtype":"method","name":"asin","params":[{"name":"value","description":"<p>value whose arc sine is to be returned.<\/p>\n","type":"Number"}],"return":{"description":"arc sine of the given value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate sin() and asin() values.\n  let a = PI \/ 3;\n  let s = sin(a);\n  let as = asin(s);\n\n  \/\/ Display the values.\n  text(`${round(a, 3)}`, 35, 25);\n  text(`${round(s, 3)}`, 35, 50);\n  text(`${round(as, 3)}`, 35, 75);\n\n  describe('The numbers 1.047, 0.866, and 1.047 written on separate rows.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate sin() and asin() values.\n  let a = PI + PI \/ 3;\n  let s = sin(a);\n  let as = asin(s);\n\n  \/\/ Display the values.\n  text(`${round(a, 3)}`, 35, 25);\n  text(`${round(s, 3)}`, 35, 50);\n  text(`${round(as, 3)}`, 35, 75);\n\n  describe('The numbers 4.189, -0.866, and -1.047 written on separate rows.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":142,"description":"<p>Calculates the arc tangent of a number.<\/p>\n<p><code>atan()<\/code> is the inverse of <a href=\"#\/p5\/tan\">tan()<\/a>. It expects input\nvalues in the range of -Infinity to Infinity. By default, <code>atan()<\/code> returns\nvalues in the range -\u03c0 \u00f7 2 (about -1.57) to \u03c0 \u00f7 2\n(about 1.57). If the <a href=\"#\/p5\/angleMode\">angleMode()<\/a> is <code>DEGREES<\/code>\nthen values are returned in the range -90 to 90.<\/p>\n","itemtype":"method","name":"atan","params":[{"name":"value","description":"<p>value whose arc tangent is to be returned.<\/p>\n","type":"Number"}],"return":{"description":"arc tangent of the given value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate tan() and atan() values.\n  let a = PI \/ 3;\n  let t = tan(a);\n  let at = atan(t);\n\n  \/\/ Display the values.\n  text(`${round(a, 3)}`, 35, 25);\n  text(`${round(t, 3)}`, 35, 50);\n  text(`${round(at, 3)}`, 35, 75);\n\n  describe('The numbers 1.047, 1.732, and 1.047 written on separate rows.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate tan() and atan() values.\n  let a = PI + PI \/ 3;\n  let t = tan(a);\n  let at = atan(t);\n\n  \/\/ Display the values.\n  text(`${round(a, 3)}`, 35, 25);\n  text(`${round(t, 3)}`, 35, 50);\n  text(`${round(at, 3)}`, 35, 75);\n\n  describe('The numbers 4.189, 1.732, and 1.047 written on separate rows.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":204,"description":"<p>Calculates the angle formed by a point, the origin, and the positive\nx-axis.<\/p>\n<p><code>atan2()<\/code> is most often used for orienting geometry to the mouse's\nposition, as in <code>atan2(mouseY, mouseX)<\/code>. The first parameter is the point's\ny-coordinate and the second parameter is its x-coordinate.<\/p>\n<p>By default, <code>atan2()<\/code> returns values in the range\n-\u03c0 (about -3.14) to \u03c0 (3.14). If the\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a> is <code>DEGREES<\/code>, then values are\nreturned in the range -180 to 180.<\/p>\n","itemtype":"method","name":"atan2","params":[{"name":"y","description":"<p>y-coordinate of the point.<\/p>\n","type":"Number"},{"name":"x","description":"<p>x-coordinate of the point.<\/p>\n","type":"Number"}],"return":{"description":"arc tangent of the given point.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A rectangle at the top-left of the canvas rotates with mouse movements.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the angle between the mouse\n  \/\/ and the origin.\n  let a = atan2(mouseY, mouseX);\n\n  \/\/ Rotate.\n  rotate(a);\n\n  \/\/ Draw the shape.\n  rect(0, 0, 60, 10);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A rectangle at the center of the canvas rotates with mouse movements.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin to the center.\n  translate(50, 50);\n\n  \/\/ Get the mouse's coordinates relative to the origin.\n  let x = mouseX - 50;\n  let y = mouseY - 50;\n\n  \/\/ Calculate the angle between the mouse and the origin.\n  let a = atan2(y, x);\n\n  \/\/ Rotate.\n  rotate(a);\n\n  \/\/ Draw the shape.\n  rect(-30, -5, 60, 10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":281,"description":"<p>Calculates the cosine of an angle.<\/p>\n<p><code>cos()<\/code> is useful for many geometric tasks in creative coding. The values\nreturned oscillate between -1 and 1 as the input angle increases. <code>cos()<\/code>\ncalculates the cosine of an angle, using radians by default, or according to\nif <a href=\"#\/p5\/angleMode\">angleMode()<\/a> setting (RADIANS or DEGREES).<\/p>\n","itemtype":"method","name":"cos","params":[{"name":"angle","description":"<p>the angle, in radians by default, or according to\nif <a href=\"\/reference\/p5\/angleMode\/\">angleMode()<\/a> setting (RADIANS or DEGREES).<\/p>\n","type":"Number"}],"return":{"description":"cosine of the angle.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white ball on a string oscillates left and right.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the coordinates.\n  let x = 30 * cos(frameCount * 0.05) + 50;\n  let y = 50;\n\n  \/\/ Draw the oscillator.\n  line(50, y, x, y);\n  circle(x, y, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots form a wave pattern.');\n}\n\nfunction draw() {\n  \/\/ Calculate the coordinates.\n  let x = frameCount;\n  let y = 30 * cos(x * 0.1) + 50;\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots form an infinity symbol.');\n}\n\nfunction draw() {\n  \/\/ Calculate the coordinates.\n  let x = 30 * cos(frameCount * 0.1) + 50;\n  let y = 10 * sin(frameCount * 0.2) + 50;\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":363,"description":"<p>Calculates the sine of an angle.<\/p>\n<p><code>sin()<\/code> is useful for many geometric tasks in creative coding. The values\nreturned oscillate between -1 and 1 as the input angle increases. <code>sin()<\/code>\ncalculates the sine of an angle, using radians by default, or according to\nif <a href=\"#\/p5\/angleMode\">angleMode()<\/a> setting (RADIANS or DEGREES).<\/p>\n","itemtype":"method","name":"sin","params":[{"name":"angle","description":"<p>the angle, in radians by default, or according to\nif <a href=\"\/reference\/p5\/angleMode\/\">angleMode()<\/a> setting (RADIANS or DEGREES).<\/p>\n","type":"Number"}],"return":{"description":"sine of the angle.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white ball on a string oscillates up and down.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the coordinates.\n  let x = 50;\n  let y = 30 * sin(frameCount * 0.05) + 50;\n\n  \/\/ Draw the oscillator.\n  line(50, y, x, y);\n  circle(x, y, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots form a wave pattern.');\n}\n\nfunction draw() {\n  \/\/ Calculate the coordinates.\n  let x = frameCount;\n  let y = 30 * sin(x * 0.1) + 50;\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of black dots form an infinity symbol.');\n}\n\nfunction draw() {\n  \/\/ Calculate the coordinates.\n  let x = 30 * cos(frameCount * 0.1) + 50;\n  let y = 10 * sin(frameCount * 0.2) + 50;\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":445,"description":"<p>Calculates the tangent of an angle.<\/p>\n<p><code>tan()<\/code> is useful for many geometric tasks in creative coding. The values\nreturned range from -Infinity to Infinity and repeat periodically as the\ninput angle increases. <code>tan()<\/code> calculates the tan of an angle, using radians\nby default, or according to\nif <a href=\"#\/p5\/angleMode\">angleMode()<\/a> setting (RADIANS or DEGREES).<\/p>\n","itemtype":"method","name":"tan","params":[{"name":"angle","description":"<p>the angle, in radians by default, or according to\nif <a href=\"\/reference\/p5\/angleMode\/\">angleMode()<\/a> setting (RADIANS or DEGREES).<\/p>\n","type":"Number"}],"return":{"description":"tangent of the angle.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  describe('A series of identical curves drawn with black dots. Each curve starts from the top of the canvas, continues down at a slight angle, flattens out at the middle of the canvas, then continues to the bottom.');\n}\n\nfunction draw() {\n  \/\/ Calculate the coordinates.\n  let x = frameCount;\n  let y = 5 * tan(x * 0.1) + 50;\n\n  \/\/ Draw the point.\n  point(x, y);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":485,"description":"<p>Converts an angle measured in radians to its value in degrees.<\/p>\n<p>Degrees and radians are both units for measuring angles. There are 360\u02da in\none full rotation. A full rotation is 2 \u00d7 \u03c0 (about 6.28) radians.<\/p>\n<p>The same angle can be expressed in with either unit. For example, 90\u00b0 is a\nquarter of a full rotation. The same angle is 2 \u00d7 \u03c0 \u00f7 4\n(about 1.57) radians.<\/p>\n","itemtype":"method","name":"degrees","params":[{"name":"radians","description":"<p>radians value to convert to degrees.<\/p>\n","type":"Number"}],"return":{"description":"converted angle.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate the angle conversion.\n  let rad = QUARTER_PI;\n  let deg = degrees(rad);\n\n  \/\/ Display the conversion.\n  text(`${round(rad, 2)} rad = ${deg}\u02da`, 10, 50);\n\n  describe('The text \"0.79 rad = 45\u02da\".');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":521,"description":"<p>Converts an angle measured in degrees to its value in radians.<\/p>\n<p>Degrees and radians are both units for measuring angles. There are 360\u02da in\none full rotation. A full rotation is 2 \u00d7 \u03c0 (about 6.28) radians.<\/p>\n<p>The same angle can be expressed in with either unit. For example, 90\u00b0 is a\nquarter of a full rotation. The same angle is 2 \u00d7 \u03c0 \u00f7 4\n(about 1.57) radians.<\/p>\n","itemtype":"method","name":"radians","params":[{"name":"degrees","description":"<p>degree value to convert to radians.<\/p>\n","type":"Number"}],"return":{"description":"converted angle.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Calculate the angle conversion.\n  let deg = 45;\n  let rad = radians(deg);\n\n  \/\/ Display the angle conversion.\n  text(`${deg}\u02da = ${round(rad, 3)} rad`, 10, 50);\n\n  describe('The text \"45\u02da = 0.785 rad\".');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry"},{"file":"src\/math\/trigonometry.js","line":557,"description":"<p>Changes the unit system used to measure angles.<\/p>\n<p>Degrees and radians are both units for measuring angles. There are 360\u02da in\none full rotation. A full rotation is 2 \u00d7 \u03c0 (about 6.28) radians.<\/p>\n<p>Functions such as <a href=\"#\/p5\/rotate\">rotate()<\/a> and\n<a href=\"#\/p5\/sin\">sin()<\/a> expect angles measured radians by default.\nCalling <code>angleMode(DEGREES)<\/code> switches to degrees. Calling\n<code>angleMode(RADIANS)<\/code> switches back to radians.<\/p>\n<p>Calling <code>angleMode()<\/code> with no arguments returns current angle mode, which\nis either <code>RADIANS<\/code> or <code>DEGREES<\/code>.<\/p>\n","itemtype":"method","name":"angleMode","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Rotate 1\/8 turn.\n  rotate(QUARTER_PI);\n\n  \/\/ Draw a line.\n  line(0, 0, 80, 0);\n\n  describe('A diagonal line radiating from the top-left corner of a square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Rotate 1\/8 turn.\n  rotate(45);\n\n  \/\/ Draw a line.\n  line(0, 0, 80, 0);\n\n  describe('A diagonal line radiating from the top-left corner of a square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Calculate the angle to rotate.\n  let angle = TWO_PI \/ 7;\n\n  \/\/ Move the origin to the center.\n  translate(50, 50);\n\n  \/\/ Style the flower.\n  noStroke();\n  fill(255, 50);\n\n  \/\/ Draw the flower.\n  for (let i = 0; i < 7; i += 1) {\n    ellipse(0, 0, 80, 20);\n    rotate(angle);\n  }\n\n  describe('A translucent white flower on a dark background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(50);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Calculate the angle to rotate.\n  let angle = 360 \/ 7;\n\n  \/\/ Move the origin to the center.\n  translate(50, 50);\n\n  \/\/ Style the flower.\n  noStroke();\n  fill(255, 50);\n\n  \/\/ Draw the flower.\n  for (let i = 0; i < 7; i += 1) {\n    ellipse(0, 0, 80, 20);\n    rotate(angle);\n  }\n\n  describe('A translucent white flower on a dark background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white ball on a string oscillates left and right.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the coordinates.\n  let x = 30 * cos(frameCount * 0.05) + 50;\n  let y = 50;\n\n  \/\/ Draw the oscillator.\n  line(50, y, x, y);\n  circle(x, y, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  describe('A white ball on a string oscillates left and right.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the coordinates.\n  let x = 30 * cos(frameCount * 2.86) + 50;\n  let y = 50;\n\n  \/\/ Draw the oscillator.\n  line(50, y, x, y);\n  circle(x, y, 20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw the upper line.\n  rotate(PI \/ 6);\n  line(0, 0, 80, 0);\n\n  \/\/ Use degrees.\n  angleMode(DEGREES);\n\n  \/\/ Draw the lower line.\n  rotate(30);\n  line(0, 0, 80, 0);\n\n  describe('Two diagonal lines radiating from the top-left corner of a square. The lines are oriented 30 degrees from the edges of the square and 30 degrees apart from each other.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Math","submodule":"Trigonometry","overloads":[{"line":557,"params":[{"name":"mode","description":"<p>either RADIANS or DEGREES.<\/p>\n","type":"Constant"}]},{"line":743,"params":[],"return":{"description":"mode either RADIANS or DEGREES","type":"Constant"}}]},{"file":"src\/typography\/attributes.js","line":11,"description":"<p>Sets the way text is aligned when <a href=\"#\/p5\/text\">text()<\/a> is called.<\/p>\n<p>By default, calling <code>text('hi', 10, 20)<\/code> places the bottom-left corner of\nthe text's bounding box at (10, 20).<\/p>\n<p>The first parameter, <code>horizAlign<\/code>, changes the way\n<a href=\"#\/p5\/text\">text()<\/a> interprets x-coordinates. By default, the\nx-coordinate sets the left edge of the bounding box. <code>textAlign()<\/code> accepts\nthe following values for <code>horizAlign<\/code>: <code>LEFT<\/code>, <code>CENTER<\/code>, or <code>RIGHT<\/code>.<\/p>\n<p>The second parameter, <code>vertAlign<\/code>, is optional. It changes the way\n<a href=\"#\/p5\/text\">text()<\/a> interprets y-coordinates. By default, the\ny-coordinate sets the bottom edge of the bounding box. <code>textAlign()<\/code>\naccepts the following values for <code>vertAlign<\/code>: <code>TOP<\/code>, <code>BOTTOM<\/code>, <code>CENTER<\/code>,\nor <code>BASELINE<\/code>.<\/p>\n","itemtype":"method","name":"textAlign","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Draw a vertical line.\n  strokeWeight(0.5);\n  line(50, 0, 50, 100);\n\n  \/\/ Top line.\n  textSize(16);\n  textAlign(RIGHT);\n  text('ABCD', 50, 30);\n\n  \/\/ Middle line.\n  textAlign(CENTER);\n  text('EFGH', 50, 50);\n\n  \/\/ Bottom line.\n  textAlign(LEFT);\n  text('IJKL', 50, 70);\n\n  describe('The letters ABCD displayed at top-left, EFGH at center, and IJKL at bottom-right. A vertical line divides the canvas in half.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  strokeWeight(0.5);\n\n  \/\/ First line.\n  line(0, 12, width, 12);\n  textAlign(CENTER, TOP);\n  text('TOP', 50, 12);\n\n  \/\/ Second line.\n  line(0, 37, width, 37);\n  textAlign(CENTER, CENTER);\n  text('CENTER', 50, 37);\n\n  \/\/ Third line.\n  line(0, 62, width, 62);\n  textAlign(CENTER, BASELINE);\n  text('BASELINE', 50, 62);\n\n  \/\/ Fourth line.\n  line(0, 97, width, 97);\n  textAlign(CENTER, BOTTOM);\n  text('BOTTOM', 50, 97);\n\n  describe('The words \"TOP\", \"CENTER\", \"BASELINE\", and \"BOTTOM\" each drawn relative to a horizontal line. Their positions demonstrate different vertical alignments.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes","overloads":[{"line":11,"params":[{"name":"horizAlign","description":"<p>horizontal alignment, either LEFT,\n                           CENTER, or RIGHT.<\/p>\n","type":"Constant"},{"name":"vertAlign","description":"<p>vertical alignment, either TOP,\n                           BOTTOM, CENTER, or BASELINE.<\/p>\n","type":"Constant","optional":true}],"chainable":1},{"line":98,"params":[],"return":{"description":"","type":"Object"}}]},{"file":"src\/typography\/attributes.js","line":107,"description":"<p>Sets the spacing between lines of text when\n<a href=\"#\/p5\/text\">text()<\/a> is called.<\/p>\n<p>Note: Spacing is measured in pixels.<\/p>\n<p>Calling <code>textLeading()<\/code> without an argument returns the current spacing.<\/p>\n","itemtype":"method","name":"textLeading","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ \"\\n\" starts a new line of text.\n  let lines = 'one\\ntwo';\n\n  \/\/ Left.\n  text(lines, 10, 25);\n\n  \/\/ Right.\n  textLeading(30);\n  text(lines, 70, 25);\n\n  describe('The words \"one\" and \"two\" written on separate lines twice. The words on the left have less vertical spacing than the words on the right.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes","overloads":[{"line":107,"params":[{"name":"leading","description":"<p>spacing between lines of text in units of pixels.<\/p>\n","type":"Number"}],"chainable":1},{"line":142,"params":[],"return":{"description":"","type":"Number"}}]},{"file":"src\/typography\/attributes.js","line":151,"description":"<p>Sets the font size when\n<a href=\"#\/p5\/text\">text()<\/a> is called.<\/p>\n<p>Note: Font size is measured in pixels.<\/p>\n<p>Calling <code>textSize()<\/code> without an argument returns the current size.<\/p>\n","itemtype":"method","name":"textSize","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Top.\n  textSize(12);\n  text('Font Size 12', 10, 30);\n\n  \/\/ Middle.\n  textSize(14);\n  text('Font Size 14', 10, 60);\n\n  \/\/ Bottom.\n  textSize(16);\n  text('Font Size 16', 10, 90);\n\n  describe('The text \"Font Size 12\" drawn small, \"Font Size 14\" drawn medium, and \"Font Size 16\" drawn large.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes","overloads":[{"line":151,"params":[{"name":"size","description":"<p>size of the letters in units of pixels.<\/p>\n","type":"Number"}],"chainable":1},{"line":188,"params":[],"return":{"description":"","type":"Number"}}]},{"file":"src\/typography\/attributes.js","line":197,"description":"<p>Sets the style for system fonts when\n<a href=\"#\/p5\/text\">text()<\/a> is called.<\/p>\n<p>The parameter, <code>style<\/code>, can be either <code>NORMAL<\/code>, <code>ITALIC<\/code>, <code>BOLD<\/code>, or\n<code>BOLDITALIC<\/code>.<\/p>\n<p><code>textStyle()<\/code> may be overridden by CSS styling. This function doesn't\naffect fonts loaded with <a href=\"#\/p5\/loadFont\">loadFont()<\/a>.<\/p>\n","itemtype":"method","name":"textStyle","chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textSize(12);\n  textAlign(CENTER);\n\n  \/\/ First row.\n  textStyle(NORMAL);\n  text('Normal', 50, 15);\n\n  \/\/ Second row.\n  textStyle(ITALIC);\n  text('Italic', 50, 40);\n\n  \/\/ Third row.\n  textStyle(BOLD);\n  text('Bold', 50, 65);\n\n  \/\/ Fourth row.\n  textStyle(BOLDITALIC);\n  text('Bold Italic', 50, 90);\n\n  describe('The words \"Normal\" displayed normally, \"Italic\" in italic, \"Bold\" in bold, and \"Bold Italic\" in bold italics.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes","overloads":[{"line":197,"params":[{"name":"style","description":"<p>styling for text, either NORMAL,\n                           ITALIC, BOLD or BOLDITALIC.<\/p>\n","type":"Constant"}],"chainable":1},{"line":244,"params":[],"return":{"description":"","type":"String"}}]},{"file":"src\/typography\/attributes.js","line":253,"description":"<p>Calculates the maximum width of a string of text drawn when\n<a href=\"#\/p5\/text\">text()<\/a> is called.<\/p>\n","itemtype":"method","name":"textWidth","params":[{"name":"str","description":"<p>string of text to measure.<\/p>\n","type":"String"}],"return":{"description":"width measured in units of pixels.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textSize(28);\n  strokeWeight(0.5);\n\n  \/\/ Calculate the text width.\n  let s = 'yoyo';\n  let w = textWidth(s);\n\n  \/\/ Display the text.\n  text(s, 22, 55);\n\n  \/\/ Underline the text.\n  line(22, 55, 22 + w, 55);\n\n  describe('The word \"yoyo\" underlined.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textSize(28);\n  strokeWeight(0.5);\n\n  \/\/ Calculate the text width.\n  \/\/ \"\\n\" starts a new line.\n  let s = 'yo\\nyo';\n  let w = textWidth(s);\n\n  \/\/ Display the text.\n  text(s, 22, 55);\n\n  \/\/ Underline the text.\n  line(22, 55, 22 + w, 55);\n\n  describe('The word \"yo\" written twice, one copy beneath the other. The words are divided by a horizontal line.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src\/typography\/attributes.js","line":337,"description":"<p>Calculates the ascent of the current font at its current size.<\/p>\n<p>The ascent represents the distance, in pixels, of the tallest character\nabove the baseline.<\/p>\n","itemtype":"method","name":"textAscent","return":{"description":"ascent measured in units of pixels.","type":"Number"},"example":["\n<div>\n<code>\nlet font;\n\nfunction preload()  {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup()  {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textFont(font);\n\n  \/\/ Different for each font.\n  let fontScale = 0.8;\n\n  let baseY = 75;\n  strokeWeight(0.5);\n\n  \/\/ Draw small text.\n  textSize(24);\n  text('dp', 0, baseY);\n\n  \/\/ Draw baseline and ascent.\n  let a = textAscent() * fontScale;\n  line(0, baseY, 23, baseY);\n  line(23, baseY - a, 23, baseY);\n\n  \/\/ Draw large text.\n  textSize(48);\n  text('dp', 45, baseY);\n\n  \/\/ Draw baseline and ascent.\n  a = textAscent() * fontScale;\n  line(45, baseY, 91, baseY);\n  line(91, baseY - a, 91, baseY);\n\n  describe('The letters \"dp\" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends upward from each baseline to the top of the \"d\".');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src\/typography\/attributes.js","line":396,"description":"<p>Calculates the descent of the current font at its current size.<\/p>\n<p>The descent represents the distance, in pixels, of the character with the\nlongest descender below the baseline.<\/p>\n","itemtype":"method","name":"textDescent","return":{"description":"descent measured in units of pixels.","type":"Number"},"example":["\n<div>\n<code>\nlet font;\n\nfunction preload()  {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup()  {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the font.\n  textFont(font);\n\n  \/\/ Different for each font.\n  let fontScale = 0.9;\n\n  let baseY = 75;\n  strokeWeight(0.5);\n\n  \/\/ Draw small text.\n  textSize(24);\n  text('dp', 0, baseY);\n\n  \/\/ Draw baseline and descent.\n  let d = textDescent() * fontScale;\n  line(0, baseY, 23, baseY);\n  line(23, baseY, 23, baseY + d);\n\n  \/\/ Draw large text.\n  textSize(48);\n  text('dp', 45, baseY);\n\n  \/\/ Draw baseline and descent.\n  d = textDescent() * fontScale;\n  line(45, baseY, 91, baseY);\n  line(91, baseY, 91, baseY + d);\n\n  describe('The letters \"dp\" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends downward from each baseline to the bottom of the \"p\".');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src\/typography\/attributes.js","line":455,"description":"<p>Helper function to measure ascent and descent.<\/p>\n","class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src\/typography\/attributes.js","line":462,"description":"<p>Sets the style for wrapping text when\n<a href=\"#\/p5\/text\">text()<\/a> is called.<\/p>\n<p>The parameter, <code>style<\/code>, can be one of the following values:<\/p>\n<p><code>WORD<\/code> starts new lines of text at spaces. If a string of text doesn't\nhave spaces, it may overflow the text box and the canvas. This is the\ndefault style.<\/p>\n<p><code>CHAR<\/code> starts new lines as needed to stay within the text box.<\/p>\n<p><code>textWrap()<\/code> only works when the maximum width is set for a text box. For\nexample, calling <code>text('Have a wonderful day', 0, 10, 100)<\/code> sets the\nmaximum width to 100 pixels.<\/p>\n<p>Calling <code>textWrap()<\/code> without an argument returns the current style.<\/p>\n","itemtype":"method","name":"textWrap","params":[{"name":"style","description":"<p>text wrapping style, either WORD or CHAR.<\/p>\n","type":"Constant"}],"return":{"description":"style","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textSize(20);\n  textWrap(WORD);\n\n  \/\/ Display the text.\n  text('Have a wonderful day', 0, 10, 100);\n\n  describe('The text \"Have a wonderful day\" written across three lines.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textSize(20);\n  textWrap(CHAR);\n\n  \/\/ Display the text.\n  text('Have a wonderful day', 0, 10, 100);\n\n  describe('The text \"Have a wonderful day\" written across two lines.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textSize(20);\n  textWrap(CHAR);\n\n  \/\/ Display the text.\n  text('\u795d\u4f60\u6709\u7f8e\u597d\u7684\u4e00\u5929', 0, 10, 100);\n\n  describe('The text \"\u795d\u4f60\u6709\u7f8e\u597d\u7684\u4e00\u5929\" written across two lines.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Attributes"},{"file":"src\/typography\/loading_displaying.js","line":16,"description":"<p>Loads a font and creates a <a href=\"#\/p5.Font\">p5.Font<\/a> object.\n<code>loadFont()<\/code> can load fonts in either .otf or .ttf format. Loaded fonts can\nbe used to style text on the canvas and in HTML elements.<\/p>\n<p>The first parameter, <code>path<\/code>, is the path to a font file.\nPaths to local files should be relative. For example,\n<code>'assets\/inconsolata.otf'<\/code>. The Inconsolata font used in the following\nexamples can be downloaded for free\n<a href=\"https:\/\/www.fontsquirrel.com\/fonts\/inconsolata\" target=\"_blank\">here<\/a>.\nPaths to remote files should be URLs. For example,\n<code>'https:\/\/example.com\/inconsolata.otf'<\/code>. URLs may be blocked due to browser\nsecurity.<\/p>\n<p>The second parameter, <code>successCallback<\/code>, is optional. If a function is\npassed, it will be called once the font has loaded. The callback function\nmay use the new <a href=\"#\/p5.Font\">p5.Font<\/a> object if needed.<\/p>\n<p>The third parameter, <code>failureCallback<\/code>, is also optional. If a function is\npassed, it will be called if the font fails to load. The callback function\nmay use the error\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Event\" target=\"_blank\">Event<\/a>\nobject if needed.<\/p>\n<p>Fonts can take time to load. Calling <code>loadFont()<\/code> in\n<a href=\"#\/p5\/preload\">preload()<\/a> ensures fonts load before they're\nused in <a href=\"#\/p5\/setup\">setup()<\/a> or\n<a href=\"#\/p5\/draw\">draw()<\/a>.<\/p>\n","itemtype":"method","name":"loadFont","params":[{"name":"path","description":"<p>path of the font to be loaded.<\/p>\n","type":"String"},{"name":"successCallback","description":"<p>function called with the\n                                          <a href=\"#\/p5.Font\">p5.Font<\/a> object after it\n                                          loads.<\/p>\n","type":"Function","optional":true},{"name":"failureCallback","description":"<p>function called with the error\n                                          <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Event\" target=\"_blank\">Event<\/a>\n                                          object if the font fails to load.<\/p>\n","type":"Function","optional":true}],"return":{"description":"<a href=\"#\/p5.Font\">p5.Font<\/a> object.","type":"p5.Font"},"example":["\n\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  fill('deeppink');\n  textFont(font);\n  textSize(36);\n  text('p5*js', 10, 50);\n\n  describe('The text \"p5*js\" written in pink on a white background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  loadFont('assets\/inconsolata.otf', font => {\n    fill('deeppink');\n    textFont(font);\n    textSize(36);\n    text('p5*js', 10, 50);\n\n    describe('The text \"p5*js\" written in pink on a white background.');\n  });\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  loadFont('assets\/inconsolata.otf', success, failure);\n}\n\nfunction success(font) {\n  fill('deeppink');\n  textFont(font);\n  textSize(36);\n  text('p5*js', 10, 50);\n\n  describe('The text \"p5*js\" written in pink on a white background.');\n}\n\nfunction failure(event) {\n  console.error('Oops!', event);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction preload() {\n  loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  let p = createP('p5*js');\n  p.style('color', 'deeppink');\n  p.style('font-family', 'Inconsolata');\n  p.style('font-size', '36px');\n  p.position(10, 50);\n\n  describe('The text \"p5*js\" written in pink on a white background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Loading & Displaying"},{"file":"src\/typography\/loading_displaying.js","line":182,"description":"<p>Draws text to the canvas.<\/p>\n<p>The first parameter, <code>str<\/code>, is the text to be drawn. The second and third\nparameters, <code>x<\/code> and <code>y<\/code>, set the coordinates of the text's bottom-left\ncorner. See <a href=\"#\/p5\/textAlign\">textAlign()<\/a> for other ways to\nalign text.<\/p>\n<p>The fourth and fifth parameters, <code>maxWidth<\/code> and <code>maxHeight<\/code>, are optional.\nThey set the dimensions of the invisible rectangle containing the text. By\ndefault, they set its  maximum width and height. See\n<a href=\"#\/p5\/rectMode\">rectMode()<\/a> for other ways to define the\nrectangular text box. Text will wrap to fit within the text box. Text\noutside of the box won't be drawn.<\/p>\n<p>Text can be styled a few ways. Call the <a href=\"#\/p5\/fill\">fill()<\/a>\nfunction to set the text's fill color. Call\n<a href=\"#\/p5\/stroke\">stroke()<\/a> and\n<a href=\"#\/p5\/strokeWeight\">strokeWeight()<\/a> to set the text's outline.\nCall <a href=\"#\/p5\/textSize\">textSize()<\/a> and\n<a href=\"#\/p5\/textFont\">textFont()<\/a> to set the text's size and font,\nrespectively.<\/p>\n<p>Note: <code>WEBGL<\/code> mode only supports fonts loaded with\n<a href=\"#\/p5\/loadFont\">loadFont()<\/a>. Calling\n<a href=\"#\/p5\/stroke\">stroke()<\/a> has no effect in <code>WEBGL<\/code> mode.<\/p>\n","itemtype":"method","name":"text","params":[{"name":"str","description":"<p>text to be displayed.<\/p>\n","type":"String|Object|Array|Number|Boolean"},{"name":"x","description":"<p>x-coordinate of the text box.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the text box.<\/p>\n","type":"Number"},{"name":"maxWidth","description":"<p>maximum width of the text box. See\n                           <a href=\"#\/p5\/rectMode\">rectMode()<\/a> for\n                           other options.<\/p>\n","type":"Number","optional":true},{"name":"maxHeight","description":"<p>maximum height of the text box. See\n                           <a href=\"#\/p5\/rectMode\">rectMode()<\/a> for\n                           other options.<\/p>\n","type":"Number","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n  text('hi', 50, 50);\n\n  describe('The text \"hi\" written in black in the middle of a gray square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background('skyblue');\n  textSize(100);\n  text('\ud83c\udf08', 0, 100);\n\n  describe('A rainbow in a blue sky.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  textSize(32);\n  fill(255);\n  stroke(0);\n  strokeWeight(4);\n  text('hi', 50, 50);\n\n  describe('The text \"hi\" written in white with a black outline.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background('black');\n  textSize(22);\n  fill('yellow');\n  text('rainbows', 6, 20);\n  fill('cornflowerblue');\n  text('rainbows', 6, 45);\n  fill('tomato');\n  text('rainbows', 6, 70);\n  fill('limegreen');\n  text('rainbows', 6, 95);\n\n  describe('The text \"rainbows\" written on several lines, each in a different color.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background(200);\n  let s = 'The quick brown fox jumps over the lazy dog.';\n  text(s, 10, 10, 70, 80);\n\n  describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background(200);\n  rectMode(CENTER);\n  let s = 'The quick brown fox jumps over the lazy dog.';\n  text(s, 50, 50, 70, 80);\n\n  describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n<\/code>\n<\/div>\n\n<div modernizr='webgl'>\n<code>\nlet font;\n\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n  textFont(font);\n  textSize(32);\n  textAlign(CENTER, CENTER);\n}\n\nfunction draw() {\n  background(0);\n  rotateY(frameCount \/ 30);\n  text('p5*js', 0, 0);\n\n  describe('The text \"p5*js\" written in white and spinning in 3D.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Loading & Displaying"},{"file":"src\/typography\/loading_displaying.js","line":335,"description":"<p>Sets the font used by the <a href=\"#\/p5\/text\">text()<\/a> function.<\/p>\n<p>The first parameter, <code>font<\/code>, sets the font. <code>textFont()<\/code> recognizes either\na <a href=\"#\/p5.Font\">p5.Font<\/a> object or a string with the name of a\nsystem font. For example, <code>'Courier New'<\/code>.<\/p>\n<p>The second parameter, <code>size<\/code>, is optional. It sets the font size in pixels.\nThis has the same effect as calling <a href=\"#\/p5\/textSize\">textSize()<\/a>.<\/p>\n<p>Note: <code>WEBGL<\/code> mode only supports fonts loaded with\n<a href=\"#\/p5\/loadFont\">loadFont()<\/a>.<\/p>\n","itemtype":"method","name":"textFont","return":{"description":"current font or p5 Object.","type":"Object"},"example":["\n<div>\n<code>\nfunction setup() {\n  background(200);\n  textFont('Courier New');\n  textSize(24);\n  text('hi', 35, 55);\n\n  describe('The text \"hi\" written in a black, monospace font on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background('black');\n  fill('palegreen');\n  textFont('Courier New', 10);\n  text('You turn to the left and see a door. Do you enter?', 5, 5, 90, 90);\n  text('>', 5, 70);\n\n  describe('A text prompt from a game is written in a green, monospace font on a black background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  background(200);\n  textFont('Verdana');\n  let currentFont = textFont();\n  text(currentFont, 25, 50);\n\n  describe('The text \"Verdana\" written in a black, sans-serif font on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet fontRegular;\nlet fontItalic;\nlet fontBold;\n\nfunction preload() {\n  fontRegular = loadFont('assets\/Regular.otf');\n  fontItalic = loadFont('assets\/Italic.ttf');\n  fontBold = loadFont('assets\/Bold.ttf');\n}\n\nfunction setup() {\n  background(200);\n  textFont(fontRegular);\n  text('I am Normal', 10, 30);\n  textFont(fontItalic);\n  text('I am Italic', 10, 50);\n  textFont(fontBold);\n  text('I am Bold', 10, 70);\n\n  describe('The statements \"I am Normal\", \"I am Italic\", and \"I am Bold\" written in black on separate lines. The statements have normal, italic, and bold fonts, respectively.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Typography","submodule":"Loading & Displaying","overloads":[{"line":335,"params":[],"return":{"description":"current font or p5 Object.","type":"Object"}},{"line":418,"params":[{"name":"font","description":"<p>font as a <a href=\"#\/p5.Font\">p5.Font<\/a> object or a string.<\/p>\n","type":"Object|String"},{"name":"size","description":"<p>font size in pixels.<\/p>\n","type":"Number","optional":true}],"chainable":1}]},{"file":"src\/typography\/p5.Font.js","line":51,"description":"<p>The font's underlying\n<a href=\"https:\/\/opentype.js.org\/\" target=\"_blank\">opentype.js<\/a>\nfont object.<\/p>\n","itemtype":"property","name":"font","class":"p5.Font","module":"Typography","submodule":"Loading & Displaying"},{"file":"src\/typography\/p5.Font.js","line":62,"description":"<p>Returns the bounding box for a string of text written using the font.<\/p>\n<p>The bounding box is the smallest rectangle that can contain a string of\ntext. <code>font.textBounds()<\/code> returns an object with the bounding box's\nlocation and size. For example, calling <code>font.textBounds('p5*js', 5, 20)<\/code>\nreturns an object in the format\n<code>{ x: 5.7, y: 12.1 , w: 9.9, h: 28.6 }<\/code>. The <code>x<\/code> and <code>y<\/code> properties are\nalways the coordinates of the bounding box's top-left corner.<\/p>\n<p>The first parameter, <code>str<\/code>, is a string of text. The second and third\nparameters, <code>x<\/code> and <code>y<\/code>, are the text's position. By default, they set the\ncoordinates of the bounding box's bottom-left corner. See\n<a href=\"#\/p5\/textAlign\">textAlign()<\/a> for more ways to align text.<\/p>\n<p>The fourth parameter, <code>fontSize<\/code>, is optional. It sets the font size used to\ndetermine the bounding box. By default, <code>font.textBounds()<\/code> will use the\ncurrent <a href=\"#\/p5\/textSize\">textSize()<\/a>.<\/p>\n","itemtype":"method","name":"textBounds","params":[{"name":"str","description":"<p>string of text.<\/p>\n","type":"String"},{"name":"x","description":"<p>x-coordinate of the text.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the text.<\/p>\n","type":"Number"},{"name":"fontSize","description":"<p>font size. Defaults to the current\n                            <a href=\"#\/p5\/textSize\">textSize()<\/a>.<\/p>\n","type":"Number","optional":true}],"return":{"description":"object describing the bounding box with\n                            properties x, y, w, and h.","type":"Object"},"example":["\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Display the bounding box.\n  let bbox = font.textBounds('p5*js', 35, 53);\n  rect(bbox.x, bbox.y, bbox.w, bbox.h);\n\n  \/\/ Style the text.\n  textFont(font);\n\n  \/\/ Display the text.\n  text('p5*js', 35, 53);\n\n  describe('The text \"p5*js\" written in black inside a white rectangle.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textFont(font);\n  textSize(15);\n  textAlign(CENTER, CENTER);\n\n  \/\/ Display the bounding box.\n  let bbox = font.textBounds('p5*js', 50, 50);\n  rect(bbox.x, bbox.y, bbox.w, bbox.h);\n\n  \/\/ Display the text.\n  text('p5*js', 50, 50);\n\n  describe('The text \"p5*js\" written in black inside a white rectangle.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Display the bounding box.\n  let bbox = font.textBounds('p5*js', 31, 53, 15);\n  rect(bbox.x, bbox.y, bbox.w, bbox.h);\n\n  \/\/ Style the text.\n  textFont(font);\n  textSize(15);\n\n  \/\/ Display the text.\n  text('p5*js', 31, 53);\n\n  describe('The text \"p5*js\" written in black inside a white rectangle.');\n}\n<\/code>\n<\/div>"],"class":"p5.Font","module":"Typography","submodule":"Loading & Displaying"},{"file":"src\/typography\/p5.Font.js","line":279,"description":"<p>Returns an array of points outlining a string of text written using the\nfont.<\/p>\n<p>Each point object in the array has three properties that describe the\npoint's location and orientation, called its path angle. For example,\n<code>{ x: 10, y: 20, alpha: 450 }<\/code>.<\/p>\n<p>The first parameter, <code>str<\/code>, is a string of text. The second and third\nparameters, <code>x<\/code> and <code>y<\/code>, are the text's position. By default, they set the\ncoordinates of the bounding box's bottom-left corner. See\n<a href=\"#\/p5\/textAlign\">textAlign()<\/a> for more ways to align text.<\/p>\n<p>The fourth parameter, <code>fontSize<\/code>, is optional. It sets the text's font\nsize. By default, <code>font.textToPoints()<\/code> will use the current\n<a href=\"#\/p5\/textSize\">textSize()<\/a>.<\/p>\n<p>The fifth parameter, <code>options<\/code>, is also optional. <code>font.textToPoints()<\/code>\nexpects an object with the following properties:<\/p>\n<p><code>sampleFactor<\/code> is the ratio of the text's path length to the number of\nsamples. It defaults to 0.1. Higher values produce more points along the\npath and are more precise.<\/p>\n<p><code>simplifyThreshold<\/code> removes collinear points if it's set to a number other\nthan 0. The value represents the threshold angle to use when determining\nwhether two edges are collinear.<\/p>\n","itemtype":"method","name":"textToPoints","params":[{"name":"str","description":"<p>string of text.<\/p>\n","type":"String"},{"name":"x","description":"<p>x-coordinate of the text.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the text.<\/p>\n","type":"Number"},{"name":"fontSize","description":"<p>font size. Defaults to the current\n                            <a href=\"#\/p5\/textSize\">textSize()<\/a>.<\/p>\n","type":"Number","optional":true},{"name":"options","description":"<p>object with sampleFactor and simplifyThreshold\n                            properties.<\/p>\n","type":"Object","optional":true}],"return":{"description":"array of point objects, each with x, y, and alpha (path angle) properties.","type":"Array"},"example":["\n<div>\n<code>\nlet font;\n\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the point array.\n  let points = font.textToPoints('p5*js', 6, 60, 35, { sampleFactor:  0.5 });\n\n  \/\/ Draw a dot at each point.\n  for (let p of points) {\n    point(p.x, p.y);\n  }\n\n  describe('A set of black dots outlining the text \"p5*js\" on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.Font","module":"Typography","submodule":"Loading & Displaying"},{"file":"src\/utilities\/array_functions.js","line":10,"description":"<p>Adds a value to the end of an array. Extends the length of\nthe array by one. Maps to Array.push().<\/p>\n","itemtype":"method","name":"append","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/push\">array.push(value)<\/a> instead.","params":[{"name":"array","description":"<p>Array to append<\/p>\n","type":"Array"},{"name":"value","description":"<p>to be added to the Array<\/p>\n","type":"Any"}],"return":{"description":"the array that was appended to","type":"Array"},"example":["\n<div class='norender'><code>\nfunction setup() {\n  let myArray = ['Mango', 'Apple', 'Papaya'];\n  print(myArray); \/\/ ['Mango', 'Apple', 'Papaya']\n\n  append(myArray, 'Peach');\n  print(myArray); \/\/ ['Mango', 'Apple', 'Papaya', 'Peach']\n}\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/array_functions.js","line":35,"description":"<p>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 <a href=\"#\/p5\/concat\">concat()<\/a>.<\/p>\n<p>The 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).<\/p>\n<p>Using this function is far more efficient for copying array data than\niterating through a for() loop and copying each element individually.<\/p>\n","itemtype":"method","name":"arrayCopy","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/copyWithin\">arr1.copyWithin(arr2)<\/a> instead.","example":["\n<div class='norender'><code>\nlet src = ['A', 'B', 'C'];\nlet dst = [1, 2, 3];\nlet srcPosition = 1;\nlet dstPosition = 0;\nlet length = 2;\n\nprint(src); \/\/ ['A', 'B', 'C']\nprint(dst); \/\/ [ 1 ,  2 ,  3 ]\n\narrayCopy(src, srcPosition, dst, dstPosition, length);\nprint(dst); \/\/ ['B', 'C', 3]\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions","overloads":[{"line":35,"params":[{"name":"src","description":"<p>the source Array<\/p>\n","type":"Array"},{"name":"srcPosition","description":"<p>starting position in the source Array<\/p>\n","type":"Integer"},{"name":"dst","description":"<p>the destination Array<\/p>\n","type":"Array"},{"name":"dstPosition","description":"<p>starting position in the destination Array<\/p>\n","type":"Integer"},{"name":"length","description":"<p>number of Array elements to be copied<\/p>\n","type":"Integer"}]},{"line":73,"params":[{"name":"src","description":"","type":"Array"},{"name":"dst","description":"","type":"Array"},{"name":"length","description":"","type":"Integer","optional":true}]}]},{"file":"src\/utilities\/array_functions.js","line":112,"description":"<p>Concatenates two arrays, maps to Array.concat(). Does not modify the\ninput arrays.<\/p>\n","itemtype":"method","name":"concat","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/concat\">arr1.concat(arr2)<\/a> instead.","params":[{"name":"a","description":"<p>first Array to concatenate<\/p>\n","type":"Array"},{"name":"b","description":"<p>second Array to concatenate<\/p>\n","type":"Array"}],"return":{"description":"concatenated array","type":"Array"},"example":["\n<div class = 'norender'><code>\nfunction setup() {\n  let arr1 = ['A', 'B', 'C'];\n  let arr2 = [1, 2, 3];\n\n  print(arr1); \/\/ ['A','B','C']\n  print(arr2); \/\/ [1,2,3]\n\n  let arr3 = concat(arr1, arr2);\n\n  print(arr1); \/\/ ['A','B','C']\n  print(arr2); \/\/ [1, 2, 3]\n  print(arr3); \/\/ ['A','B','C', 1, 2, 3]\n}\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/array_functions.js","line":141,"description":"<p>Reverses the order of an array, maps to Array.reverse()<\/p>\n","itemtype":"method","name":"reverse","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/reverse\">array.reverse()<\/a> instead.","params":[{"name":"list","description":"<p>Array to reverse<\/p>\n","type":"Array"}],"return":{"description":"the reversed list","type":"Array"},"example":["\n<div class='norender'><code>\nfunction setup() {\n  let myArray = ['A', 'B', 'C'];\n  print(myArray); \/\/ ['A','B','C']\n\n  reverse(myArray);\n  print(myArray); \/\/ ['C','B','A']\n}\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/array_functions.js","line":161,"description":"<p>Decreases an array by one element and returns the shortened array,\nmaps to Array.pop().<\/p>\n","itemtype":"method","name":"shorten","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/pop\">array.pop()<\/a> instead.","params":[{"name":"list","description":"<p>Array to shorten<\/p>\n","type":"Array"}],"return":{"description":"shortened Array","type":"Array"},"example":["\n<div class = 'norender'><code>\nfunction setup() {\n  let myArray = ['A', 'B', 'C'];\n  print(myArray); \/\/ ['A', 'B', 'C']\n  let newArray = shorten(myArray);\n  print(myArray); \/\/ ['A','B','C']\n  print(newArray); \/\/ ['A','B']\n}\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/array_functions.js","line":185,"description":"<p>Shuffles the elements of an array.<\/p>\n<p>The first parameter, <code>array<\/code>, is the array to be shuffled. For example,\ncalling <code>shuffle(myArray)<\/code> will shuffle the elements of <code>myArray<\/code>. By\ndefault, the original array won\u2019t be modified. Instead, a copy will be\ncreated, shuffled, and returned.<\/p>\n<p>The second parameter, <code>modify<\/code>, is optional. If <code>true<\/code> is passed, as in\n<code>shuffle(myArray, true)<\/code>, then the array will be shuffled in place without\nmaking a copy.<\/p>\n","itemtype":"method","name":"shuffle","params":[{"name":"array","description":"<p>array to shuffle.<\/p>\n","type":"Array"},{"name":"bool","description":"<p>if <code>true<\/code>, shuffle the original array in place. Defaults to <code>false<\/code>.<\/p>\n","type":"Boolean","optional":true}],"return":{"description":"shuffled array.","type":"Array"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of colors.\n  let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];\n\n  \/\/ Create a shuffled copy of the array.\n  let shuffledColors = shuffle(colors);\n\n  \/\/ Draw  a row of circles using the original array.\n  for (let i = 0; i < colors.length; i += 1) {\n    \/\/ Calculate the x-coordinate.\n    let x = (i + 1) * 12.5;\n\n    \/\/ Style the circle.\n    let c = colors[i];\n    fill(c);\n\n    \/\/ Draw the circle.\n    circle(x, 33, 10);\n  }\n\n  \/\/ Draw  a row of circles using the original array.\n  for (let i = 0; i < shuffledColors.length; i += 1) {\n    \/\/ Calculate the x-coordinate.\n    let x = (i + 1) * 12.5;\n\n    \/\/ Style the circle.\n    let c = shuffledColors[i];\n    fill(c);\n\n    \/\/ Draw the circle.\n    circle(x, 67, 10);\n  }\n\n  describe(\n    'Two rows of circles on a gray background. The top row follows the color sequence ROYGBIV. The bottom row has all the same colors but they are shuffled.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of colors.\n  let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];\n\n  \/\/ Shuffle the array.\n  shuffle(colors, true);\n\n  \/\/ Draw  a row of circles using the original array.\n  for (let i = 0; i < colors.length; i += 1) {\n    \/\/ Calculate the x-coordinate.\n    let x = (i + 1) * 12.5;\n\n    \/\/ Style the circle.\n    let c = colors[i];\n    fill(c);\n\n    \/\/ Draw the circle.\n    circle(x, 50, 10);\n  }\n\n  describe(\n    'A row of colorful circles on a gray background. Their sequence changes each time the sketch runs.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/array_functions.js","line":300,"description":"<p>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.<\/p>\n","itemtype":"method","name":"sort","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/sort\">array.sort()<\/a> instead.","params":[{"name":"list","description":"<p>Array to sort<\/p>\n","type":"Array"},{"name":"count","description":"<p>number of elements to sort, starting from 0<\/p>\n","type":"Integer","optional":true}],"return":{"description":"the sorted list","type":"Array"},"example":["\n<div class = 'norender'><code>\nfunction setup() {\n  let words = ['banana', 'apple', 'pear', 'lime'];\n  print(words); \/\/ ['banana', 'apple', 'pear', 'lime']\n  let count = 4; \/\/ length of array\n\n  words = sort(words, count);\n  print(words); \/\/ ['apple', 'banana', 'lime', 'pear']\n}\n<\/code><\/div>\n<div class = 'norender'><code>\nfunction setup() {\n  let numbers = [2, 6, 1, 5, 14, 9, 8, 12];\n  print(numbers); \/\/ [2, 6, 1, 5, 14, 9, 8, 12]\n  let count = 5; \/\/ Less than the length of the array\n\n  numbers = sort(numbers, count);\n  print(numbers); \/\/ [1,2,5,6,14,9,8,12]\n}\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/array_functions.js","line":346,"description":"<p>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.)<\/p>\n","itemtype":"method","name":"splice","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/splice\">array.splice()<\/a> instead.","params":[{"name":"list","description":"<p>Array to splice into<\/p>\n","type":"Array"},{"name":"value","description":"<p>value to be spliced in<\/p>\n","type":"Any"},{"name":"position","description":"<p>in the array from which to insert data<\/p>\n","type":"Integer"}],"return":{"description":"the list","type":"Array"},"example":["\n<div class = 'norender'><code>\nfunction setup() {\n  let myArray = [0, 1, 2, 3, 4];\n  let insArray = ['A', 'B', 'C'];\n  print(myArray); \/\/ [0, 1, 2, 3, 4]\n  print(insArray); \/\/ ['A','B','C']\n\n  splice(myArray, insArray, 3);\n  print(myArray); \/\/ [0,1,2,'A','B','C',3,4]\n}\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/array_functions.js","line":381,"description":"<p>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.<\/p>\n","itemtype":"method","name":"subset","deprecated":true,"deprecationMessage":"Use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/slice\">array.slice()<\/a> instead.","params":[{"name":"list","description":"<p>Array to extract from<\/p>\n","type":"Array"},{"name":"start","description":"<p>position to begin<\/p>\n","type":"Integer"},{"name":"count","description":"<p>number of values to extract<\/p>\n","type":"Integer","optional":true}],"return":{"description":"Array of extracted elements","type":"Array"},"example":["\n<div class = 'norender'><code>\nfunction setup() {\n  let myArray = [1, 2, 3, 4, 5];\n  print(myArray); \/\/ [1, 2, 3, 4, 5]\n\n  let sub1 = subset(myArray, 0, 3);\n  let sub2 = subset(myArray, 2, 2);\n  print(sub1); \/\/ [1,2,3]\n  print(sub2); \/\/ [3,4]\n}\n<\/code><\/div>"],"class":"p5","module":"Data","submodule":"Array Functions"},{"file":"src\/utilities\/conversion.js","line":10,"description":"<p>Converts a <code>String<\/code> to a floating point (decimal) <code>Number<\/code>.<\/p>\n<p><code>float()<\/code> converts strings that resemble numbers, such as <code>'12.34'<\/code>, into\nnumbers.<\/p>\n<p>The parameter, <code>str<\/code>, is the string value to convert. For example, calling\n<code>float('12.34')<\/code> returns the number <code>12.34<\/code>.  If an array of strings is\npassed, as in <code>float(['12.34', '56.78'])<\/code>, then an array of numbers will be\nreturned.<\/p>\n<p>Note: If a string can't be converted to a number, as in <code>float('giraffe')<\/code>,\nthen the value <code>NaN<\/code> (not a number) will be returned.<\/p>\n","itemtype":"method","name":"float","return":{"description":"converted number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let original = '12.3';\n\n  \/\/ Convert the string to a number.\n  let converted = float(original);\n\n  \/\/ Double the converted value.\n  let twice = converted * 2;\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(12);\n\n  \/\/ Display the original and converted values.\n  text(`${original} \u00d7 2 = ${twice}`, 50, 50);\n\n  describe('The text \"12.3 \u00d7 2 = 24.6\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of strings.\n  let original = ['60', '30', '15'];\n\n  \/\/ Convert the strings to numbers.\n  let diameters = float(original);\n\n  for (let d of diameters) {\n    \/\/ Draw a circle.\n    circle(50, 50, d);\n  }\n\n  describe('Three white, concentric circles on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":10,"params":[{"name":"str","description":"<p>string to convert.<\/p>\n","type":"String"}],"return":{"description":"converted number.","type":"Number"}},{"line":80,"params":[{"name":"ns","description":"<p>array of strings to convert.<\/p>\n","type":"String[]"}],"return":{"description":"converted numbers.","type":"Number[]"}}]},{"file":"src\/utilities\/conversion.js","line":92,"description":"<p>Converts a <code>Boolean<\/code>, <code>String<\/code>, or decimal <code>Number<\/code> to an integer.<\/p>\n<p><code>int()<\/code> converts values to integers. Integers are positive or negative\nnumbers without decimals. If the original value has decimals, as in -34.56,\nthey're removed to produce an integer such as -34.<\/p>\n<p>The parameter, <code>n<\/code>, is the value to convert. If <code>n<\/code> is a Boolean, as in\n<code>int(false)<\/code> or <code>int(true)<\/code>, then the number 0 (<code>false<\/code>) or 1 (<code>true<\/code>) will\nbe returned. If <code>n<\/code> is a string or number, as in <code>int('45')<\/code> or\n<code>int(67.89)<\/code>, then an integer will be returned. If an array is passed, as\nin <code>int([12.34, 56.78])<\/code>, then an array of integers will be returned.<\/p>\n<p>Note: If a value can't be converted to a number, as in <code>int('giraffe')<\/code>,\nthen the value <code>NaN<\/code> (not a number) will be returned.<\/p>\n","itemtype":"method","name":"int","return":{"description":"converted number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a Boolean variable.\n  let original = false;\n\n  \/\/ Convert the Boolean to an integer.\n  let converted = int(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"false : 0\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let original = '12.34';\n\n  \/\/ Convert the string to an integer.\n  let converted = int(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Display the original and converted values.\n  text(`${original} \u2248 ${converted}`, 50, 50);\n\n  describe('The text \"12.34 \u2248 12\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a decimal number variable.\n  let original = 12.34;\n\n  \/\/ Convert the decimal number to an integer.\n  let converted = int(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Display the original and converted values.\n  text(`${original} \u2248 ${converted}`, 50, 50);\n\n  describe('The text \"12.34 \u2248 12\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of strings.\n  let original = ['60', '30', '15'];\n\n  \/\/ Convert the strings to integers.\n  let diameters = int(original);\n\n  for (let d of diameters) {\n    \/\/ Draw a circle.\n    circle(50, 50, d);\n  }\n\n  describe('Three white, concentric circles on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":92,"params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"String|Boolean|Number"}],"return":{"description":"converted number.","type":"Number"}},{"line":211,"params":[{"name":"ns","description":"<p>values to convert.<\/p>\n","type":"Array"}],"return":{"description":"converted numbers.","type":"Number[]"}}]},{"file":"src\/utilities\/conversion.js","line":232,"description":"<p>Converts a <code>Boolean<\/code> or <code>Number<\/code> to <code>String<\/code>.<\/p>\n<p><code>str()<\/code> converts values to strings. See the\n<a href=\"#\/p5\/String\">String<\/a> reference page for guidance on using\ntemplate literals instead.<\/p>\n<p>The parameter, <code>n<\/code>, is the value to convert. If <code>n<\/code> is a Boolean, as in\n<code>str(false)<\/code> or <code>str(true)<\/code>, then the value will be returned as a string,\nas in <code>'false'<\/code> or <code>'true'<\/code>. If <code>n<\/code> is a number, as in <code>str(123)<\/code>, then its\nvalue will be returned as a string, as in <code>'123'<\/code>. If an array is passed,\nas in <code>str([12.34, 56.78])<\/code>, then an array of strings will be returned.<\/p>\n","itemtype":"method","name":"str","params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"String|Boolean|Number"}],"return":{"description":"converted string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a Boolean variable.\n  let original = false;\n\n  \/\/ Convert the Boolean to a string.\n  let converted = str(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"false : false\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a number variable.\n  let original = 123;\n\n  \/\/ Convert the number to a string.\n  let converted = str(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} = ${converted}`, 50, 50);\n\n  describe('The text \"123 = 123\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of numbers.\n  let original = [12, 34, 56];\n\n  \/\/ Convert the numbers to strings.\n  let strings = str(original);\n\n  \/\/ Create an empty string variable.\n  let final = '';\n\n  \/\/ Concatenate all the strings.\n  for (let s of strings) {\n    final += s;\n  }\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the concatenated string.\n  text(final, 50, 50);\n\n  describe('The text \"123456\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion"},{"file":"src\/utilities\/conversion.js","line":341,"description":"<p>Converts a <code>String<\/code> or <code>Number<\/code> to a <code>Boolean<\/code>.<\/p>\n<p><code>boolean()<\/code> converts values to <code>true<\/code> or <code>false<\/code>.<\/p>\n<p>The parameter, <code>n<\/code>, is the value to convert. If <code>n<\/code> is a string, then\n<code>boolean('true')<\/code> will return <code>true<\/code> and every other string value will\nreturn <code>false<\/code>. If <code>n<\/code> is a number, then <code>boolean(0)<\/code> will return <code>false<\/code>\nand every other numeric value will return <code>true<\/code>. If an array is passed, as\n<code>in boolean([0, 1, 'true', 'blue'])<\/code>, then an array of Boolean values will\nbe returned.<\/p>\n","itemtype":"method","name":"boolean","return":{"description":"converted Boolean value.","type":"Boolean"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a number variable.\n  let original = 0;\n\n  \/\/ Convert the number to a Boolean value.\n  let converted = boolean(original);\n\n  \/\/ Style the circle based on the converted value.\n  if (converted === true) {\n    fill('blue');\n  } else {\n    fill('red');\n  }\n\n  \/\/ Draw the circle.\n  circle(50, 50, 40);\n\n  describe('A red circle on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let original = 'true';\n\n  \/\/ Convert the string to a Boolean value.\n  let converted = boolean(original);\n\n  \/\/ Style the circle based on the converted value.\n  if (converted === true) {\n    fill('blue');\n  } else {\n    fill('red');\n  }\n\n  \/\/ Draw the circle.\n  circle(50, 50, 40);\n\n  describe('A blue circle on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of values.\n  let original = [0, 'hi', 123, 'true'];\n\n  \/\/ Convert the array to a Boolean values.\n  let converted = boolean(original);\n\n  \/\/ Iterate over the array of converted Boolean values.\n  for (let i = 0; i < converted.length; i += 1) {\n\n    \/\/ Style the circle based on the converted value.\n    if (converted[i] === true) {\n      fill('blue');\n    } else {\n      fill('red');\n    }\n\n    \/\/ Calculate the x-coordinate.\n    let x = (i + 1) * 20;\n\n    \/\/ Draw the circle.\n    circle(x, 50, 15);\n  }\n\n  describe(\n    'A row of circles on a gray background. The two circles on the left are red and the two on the right are blue.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":341,"params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"String|Boolean|Number"}],"return":{"description":"converted Boolean value.","type":"Boolean"}},{"line":451,"params":[{"name":"ns","description":"<p>values to convert.<\/p>\n","type":"Array"}],"return":{"description":"converted Boolean values.","type":"Boolean[]"}}]},{"file":"src\/utilities\/conversion.js","line":468,"description":"<p>Converts a <code>Boolean<\/code>, <code>String<\/code>, or <code>Number<\/code> to its byte value.<\/p>\n<p><code>byte()<\/code> converts a value to an integer (whole number) between -128 and\n127. Values greater than 127 wrap around while negative values are\nunchanged. For example, 128 becomes -128 and -129 remains the same.<\/p>\n<p>The parameter, <code>n<\/code>, is the value to convert. If <code>n<\/code> is a Boolean, as in\n<code>byte(false)<\/code> or <code>byte(true)<\/code>, the number 0 (<code>false<\/code>) or 1 (<code>true<\/code>) will be\nreturned. If <code>n<\/code> is a string or number, as in <code>byte('256')<\/code> or <code>byte(256)<\/code>,\nthen the byte value will be returned. Decimal values are ignored. If an\narray is passed, as in <code>byte([true, 123, '456'])<\/code>, then an array of byte\nvalues will be returned.<\/p>\n<p>Note: If a value can't be converted to a number, as in <code>byte('giraffe')<\/code>,\nthen the value <code>NaN<\/code> (not a number) will be returned.<\/p>\n","itemtype":"method","name":"byte","return":{"description":"converted byte value.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a Boolean variable.\n  let original = true;\n\n  \/\/ Convert the Boolean to its byte value.\n  let converted = byte(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"true : 1\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let original = '256';\n\n  \/\/ Convert the string to its byte value.\n  let converted = byte(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"256 : 0\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a number variable.\n  let original = 256;\n\n  \/\/ Convert the number to its byte value.\n  let converted = byte(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"256 : 0\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of values.\n  let original = [false, '64', 383];\n\n  \/\/ Convert the array elements to their byte values.\n  let converted = byte(original);\n\n  \/\/ Iterate over the converted array elements.\n  for (let i = 0; i < converted.length; i += 1) {\n\n    \/\/ Style the circle.\n    fill(converted[i]);\n\n    \/\/ Calculate the x-coordinate.\n    let x = (i + 1) * 25;\n\n    \/\/ Draw the circle.\n    circle(x, 50, 20);\n  }\n\n  describe(\n    'Three gray circles on a gray background. The circles get lighter from left to right.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":468,"params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"String|Boolean|Number"}],"return":{"description":"converted byte value.","type":"Number"}},{"line":598,"params":[{"name":"ns","description":"<p>values to convert.<\/p>\n","type":"Array"}],"return":{"description":"converted byte values.","type":"Number[]"}}]},{"file":"src\/utilities\/conversion.js","line":612,"description":"<p>Converts a <code>Number<\/code> or <code>String<\/code> to a single-character <code>String<\/code>.<\/p>\n<p><code>char()<\/code> converts numbers to their single-character string representations.<\/p>\n<p>The parameter, <code>n<\/code>, is the value to convert. If a number is passed, as in\n<code>char(65)<\/code>, the corresponding single-character string is returned. If a\nstring is passed, as in <code>char('65')<\/code>, the string is converted to an integer\n(whole number) and the corresponding single-character string is returned.\nIf an array is passed, as in <code>char([65, 66, 67])<\/code>, an array of\nsingle-character strings is returned.<\/p>\n<p>See <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/String\/fromCharCode\" target=\"_blank\">MDN<\/a>\nfor more information about conversions.<\/p>\n","itemtype":"method","name":"char","return":{"description":"converted single-character string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a number variable.\n  let original = 65;\n\n  \/\/ Convert the number to a char.\n  let converted = char(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"65 : A\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let original = '65';\n\n  \/\/ Convert the string to a char.\n  let converted = char(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"65 : A\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of numbers.\n  let original = ['65', 66, '67'];\n\n  \/\/ Convert the string to a char.\n  let converted = char(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Iterate over elements of the converted array.\n  for (let i = 0; i < converted.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Display the original and converted values.\n    text(`${original[i]} : ${converted[i]}`, 50, y);\n  }\n\n  describe(\n    'The text \"65 : A\", \"66 : B\", and \"67 : C\" written on three separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":612,"params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"String|Number"}],"return":{"description":"converted single-character string.","type":"String"}},{"line":716,"params":[{"name":"ns","description":"<p>values to convert.<\/p>\n","type":"Array"}],"return":{"description":"converted single-character strings.","type":"String[]"}}]},{"file":"src\/utilities\/conversion.js","line":731,"description":"<p>Converts a single-character <code>String<\/code> to a <code>Number<\/code>.<\/p>\n<p><code>unchar()<\/code> converts single-character strings to their corresponding\ninteger (whole number).<\/p>\n<p>The parameter, <code>n<\/code>, is the character to convert. For example,\n<code>unchar('A')<\/code>, returns the number 65. If an array is passed, as in\n<code>unchar(['A', 'B', 'C'])<\/code>, an array of integers is returned.<\/p>\n","itemtype":"method","name":"unchar","return":{"description":"converted number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let original = 'A';\n\n  \/\/ Convert the string to a number.\n  let converted = unchar(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} : ${converted}`, 50, 50);\n\n  describe('The text \"A : 65\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of characters.\n  let original = ['A', 'B', 'C'];\n\n  \/\/ Convert the string to a number.\n  let converted = unchar(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Iterate over elements of the converted array.\n  for (let i = 0; i < converted.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Display the original and converted values.\n    text(`${original[i]} : ${converted[i]}`, 50, y);\n  }\n\n  describe(\n    'The text \"A : 65\", \"B : 66\", and \"C :67\" written on three separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":731,"params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"String"}],"return":{"description":"converted number.","type":"Number"}},{"line":805,"params":[{"name":"ns","description":"<p>values to convert.<\/p>\n","type":"String[]"}],"return":{"description":"converted numbers.","type":"Number[]"}}]},{"file":"src\/utilities\/conversion.js","line":818,"description":"<p>Converts a <code>Number<\/code> to a <code>String<\/code> with its hexadecimal value.<\/p>\n<p><code>hex()<\/code> converts a number to a string with its hexadecimal number value.\nHexadecimal (hex) numbers are base-16, which means there are 16 unique\ndigits. Hex extends the numbers 0\u20139 with the letters A\u2013F. For example, the\nnumber <code>11<\/code> (eleven) in base-10 is written as the letter <code>B<\/code> in hex.<\/p>\n<p>The first parameter, <code>n<\/code>, is the number to convert. For example, <code>hex(20)<\/code>,\nreturns the string <code>'00000014'<\/code>. If an array is passed, as in\n<code>hex([1, 10, 100])<\/code>, an array of hexadecimal strings is returned.<\/p>\n<p>The second parameter, <code>digits<\/code>, is optional. If a number is passed, as in\n<code>hex(20, 2)<\/code>, it sets the number of hexadecimal digits to display. For\nexample, calling <code>hex(20, 2)<\/code> returns the string <code>'14'<\/code>.<\/p>\n","itemtype":"method","name":"hex","return":{"description":"converted hexadecimal value.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a number variable.\n  let original = 20;\n\n  \/\/ Convert the number to a hex string.\n  let converted = hex(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Display the original and converted values.\n  text(`${original} = ${converted}`, 50, 50);\n\n  describe('The text \"20 = 00000014\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a number variable.\n  let original = 20;\n\n  \/\/ Convert the number to a hex string.\n  \/\/ Only display two hex digits.\n  let converted = hex(original, 2);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} = ${converted}`, 50, 50);\n\n  describe('The text \"20 = 14\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of numbers.\n  let original = [1, 10, 100];\n\n  \/\/ Convert the numbers to hex strings.\n  \/\/ Only use two hex digits.\n  let converted = hex(original, 2);\n\n  \/\/ Style the text.\n  textAlign(RIGHT, CENTER);\n  textSize(16);\n\n  \/\/ Iterate over the converted values.\n  for (let i = 0; i < converted.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Display the original and converted values.\n    text(`${ original[i]} = ${converted[i]}`, 75, y);\n  }\n\n  describe(\n    'The text \"1 = 01\", \"10 = 0A\", and \"100 = 64\" written on three separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":818,"params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"Number"},{"name":"digits","description":"<p>number of digits to include.<\/p>\n","type":"Number","optional":true}],"return":{"description":"converted hexadecimal value.","type":"String"}},{"line":926,"params":[{"name":"ns","description":"<p>values to convert.<\/p>\n","type":"Number[]"},{"name":"digits","description":"","type":"Number","optional":true}],"return":{"description":"converted hexadecimal values.","type":"String[]"}}]},{"file":"src\/utilities\/conversion.js","line":956,"description":"<p>Converts a <code>String<\/code> with a hexadecimal value to a  <code>Number<\/code>.<\/p>\n<p><code>unhex()<\/code> converts a string with its hexadecimal number value to a number.\nHexadecimal (hex) numbers are base-16, which means there are 16 unique\ndigits. Hex extends the numbers 0\u20139 with the letters A\u2013F. For example, the\nnumber <code>11<\/code> (eleven) in base-10 is written as the letter <code>B<\/code> in hex.<\/p>\n<p>The first parameter, <code>n<\/code>, is the hex string to convert. For example,\n<code>unhex('FF')<\/code>, returns the number 255. If an array is passed, as in\n<code>unhex(['00', '80', 'FF'])<\/code>, an array of numbers is returned.<\/p>\n","itemtype":"method","name":"unhex","return":{"description":"converted number.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a a hex string variable\n  let original = 'FF';\n\n  \/\/ Convert the hex string to a number.\n  let converted = unhex(original);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the original and converted values.\n  text(`${original} = ${converted}`, 50, 50);\n\n  describe('The text \"FF = 255\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of numbers.\n  let original = ['00', '80', 'FF'];\n\n  \/\/ Convert the numbers to hex strings.\n  \/\/ Only use two hex digits.\n  let converted = unhex(original, 2);\n\n  \/\/ Style the text.\n  textAlign(RIGHT, CENTER);\n  textSize(16);\n\n  \/\/ Iterate over the converted values.\n  for (let i = 0; i < converted.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Display the original and converted values.\n    text(`${ original[i]} = ${converted[i]}`, 80, y);\n  }\n\n  describe(\n    'The text \"00 = 0\", \"80 = 128\", and \"FF = 255\" written on three separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"Conversion","overloads":[{"line":956,"params":[{"name":"n","description":"<p>value to convert.<\/p>\n","type":"String"}],"return":{"description":"converted number.","type":"Number"}},{"line":1033,"params":[{"name":"ns","description":"<p>values to convert.<\/p>\n","type":"String[]"}],"return":{"description":"converted numbers.","type":"Number[]"}}]},{"file":"src\/utilities\/string_functions.js","line":15,"description":"<p>Combines an array of strings into one string.<\/p>\n<p>The first parameter, <code>list<\/code>, is the array of strings to join.<\/p>\n<p>The second parameter, <code>separator<\/code>, is the character(s) that should be used\nto separate the combined strings. For example, calling\n<code>join(myWords, ' : ')<\/code> would return a string of words each separated by a\ncolon and spaces.<\/p>\n","itemtype":"method","name":"join","params":[{"name":"list","description":"<p>array of strings to combine.<\/p>\n","type":"Array"},{"name":"separator","description":"<p>character(s) to place between strings when they're combined.<\/p>\n","type":"String"}],"return":{"description":"combined string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of strings.\n  let myWords = ['one', 'two', 'three'];\n\n  \/\/ Create a combined string\n  let combined = join(myWords, ' : ');\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n\n  \/\/ Display the combined string.\n  text(combined, 50, 50);\n\n  describe('The text \"one : two : three\" written in black on a gray canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src\/utilities\/string_functions.js","line":60,"description":"<p>Applies a regular expression to a string and returns an array with the\nfirst match.<\/p>\n<p><code>match()<\/code> uses regular expressions (regex) to match patterns in text. For\nexample, the regex <code>abc<\/code> can be used to search a string for the exact\nsequence of characters <code>abc<\/code>. See\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Regular_Expressions#tools\" target=\"_blank\">MDN<\/a>.\nfor more information about regexes.<\/p>\n<p>The first parameter, <code>str<\/code>, is the string to search.<\/p>\n<p>The second parameter, <code>regex<\/code>, is a string with the regular expression to\napply. For example, calling <code>match('Hello, p5*js!', '[a-z][0-9]')<\/code> would\nreturn the array <code>['p5']<\/code>.<\/p>\n<p>Note: If no matches are found, <code>null<\/code> is returned.<\/p>\n","itemtype":"method","name":"match","params":[{"name":"str","description":"<p>string to search.<\/p>\n","type":"String"},{"name":"regexp","description":"<p>regular expression to match.<\/p>\n","type":"String"}],"return":{"description":"match if found.","type":"String[]"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let string = 'Hello, p5*js!';\n\n  \/\/ Match the characters that are lowercase\n  \/\/ letters followed by digits.\n  let matches = match(string, '[a-z][0-9]');\n\n  \/\/ Print the matches array to the console:\n  \/\/ ['p5']\n  print(matches);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the matches.\n  text(matches, 50, 50);\n\n  describe('The text \"p5\" written in black on a gray canvas.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src\/utilities\/string_functions.js","line":119,"description":"<p>Applies a regular expression to a string and returns an array of matches.<\/p>\n<p><code>match()<\/code> uses regular expressions (regex) to match patterns in text. For\nexample, the regex <code>abc<\/code> can be used to search a string for the exact\nsequence of characters <code>abc<\/code>. See\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Regular_Expressions#tools\" target=\"_blank\">MDN<\/a>.\nfor more information about regexes. <code>matchAll()<\/code> is different from\n<a href=\"#\/p5\/match\">match()<\/a> because it returns every match, not just\nthe first.<\/p>\n<p>The first parameter, <code>str<\/code>, is the string to search.<\/p>\n<p>The second parameter, <code>regex<\/code>, is a string with the regular expression to\napply. For example, calling\n<code>matchAll('p5*js is easier than abc123', '[a-z][0-9]')<\/code> would return the\n2D array <code>[['p5'], ['c1']]<\/code>.<\/p>\n<p>Note: If no matches are found, an empty array <code>[]<\/code> is returned.<\/p>\n","itemtype":"method","name":"matchAll","params":[{"name":"str","description":"<p>string to search.<\/p>\n","type":"String"},{"name":"regexp","description":"<p>regular expression to match.<\/p>\n","type":"String"}],"return":{"description":"matches found.","type":"String[]"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let string = 'p5*js is easier than abc123';\n\n  \/\/ Match the character sequences that are\n  \/\/ lowercase letters followed by digits.\n  let matches = matchAll(string, '[a-z][0-9]');\n\n  \/\/ Print the matches array to the console:\n  \/\/ [['p5'], ['c1']]\n  print(matches);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Iterate over the matches array.\n  for (let i = 0; i < matches.length; i += 1) {\n\n    \/\/ Calculate the y-coordainate.\n    let y = (i + 1) * 33;\n\n    \/\/ Display the match.\n    text(matches[i], 50, y);\n  }\n\n  describe(\n    'The text \"p5\" and \"c1\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src\/utilities\/string_functions.js","line":199,"description":"<p>Converts a <code>Number<\/code> into a <code>String<\/code> with a given number of digits.<\/p>\n<p><code>nf()<\/code> converts numbers such as <code>123.45<\/code> into strings formatted with a set\nnumber of digits, as in <code>'123.4500'<\/code>.<\/p>\n<p>The first parameter, <code>num<\/code>, is the number to convert to a string. For\nexample, calling <code>nf(123.45)<\/code> returns the string <code>'123.45'<\/code>. If an array of\nnumbers is passed, as in <code>nf([123.45, 67.89])<\/code>, an array of formatted\nstrings will be returned.<\/p>\n<p>The second parameter, <code>left<\/code>, is optional. If a number is passed, as in\n<code>nf(123.45, 4)<\/code>, it sets the minimum number of digits to include to the\nleft of the decimal place. If <code>left<\/code> is larger than the number of digits in\n<code>num<\/code>, then unused digits will be set to 0. For example, calling\n<code>nf(123.45, 4)<\/code> returns the string <code>'0123.45'<\/code>.<\/p>\n<p>The third parameter, <code>right<\/code>, is also optional. If a number is passed, as\nin <code>nf(123.45, 4, 1)<\/code>, it sets the minimum number of digits to include to\nthe right of the decimal place. If <code>right<\/code> is smaller than the number of\ndecimal places in <code>num<\/code>, then <code>num<\/code> will be rounded to the given number of\ndecimal places. For example, calling <code>nf(123.45, 4, 1)<\/code> returns the string\n<code>'0123.5'<\/code>. If right is larger than the number of decimal places in <code>num<\/code>,\nthen unused decimal places will be set to 0. For example, calling\n<code>nf(123.45, 4, 3)<\/code> returns the string <code>'0123.450'<\/code>.<\/p>\n<p>When the number is negative, for example, calling <code>nf(-123.45, 5, 2)<\/code>\nreturns the string <code>'-00123.45'<\/code>.<\/p>\n","itemtype":"method","name":"nf","return":{"description":"formatted string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(16);\n\n  \/\/ Create a number variable.\n  let number = 123.45;\n\n  \/\/ Display the number as a string.\n  let formatted = nf(number);\n  text(formatted, 20, 20);\n\n  let negative = nf(-number, 4, 2);\n  text(negative, 20, 40);\n\n  \/\/ Display the number with four digits\n  \/\/ to the left of the decimal.\n  let left = nf(number, 4);\n  text(left, 20, 60);\n\n  \/\/ Display the number with four digits\n  \/\/ to the left of the decimal and one\n  \/\/ to the right.\n  let right = nf(number, 4, 1);\n  text(right, 20, 80);\n\n  describe(\n    'The numbers \"123.45\", \"-0123.45\", \"0123.45\", and \"0123.5\" written on four separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions","overloads":[{"line":199,"params":[{"name":"num","description":"<p>number to format.<\/p>\n","type":"Number|String"},{"name":"left","description":"<p>number of digits to include to the left of\n                               the decimal point.<\/p>\n","type":"Integer|String","optional":true},{"name":"right","description":"<p>number of digits to include to the right\n                                of the decimal point.<\/p>\n","type":"Integer|String","optional":true}],"return":{"description":"formatted string.","type":"String"}},{"line":276,"params":[{"name":"nums","description":"<p>numbers to format.<\/p>\n","type":"Number[]"},{"name":"left","description":"","type":"Integer|String","optional":true},{"name":"right","description":"","type":"Integer|String","optional":true}],"return":{"description":"formatted strings.","type":"String[]"}}]},{"file":"src\/utilities\/string_functions.js","line":322,"description":"<p>Converts a <code>Number<\/code> into a <code>String<\/code> with commas to mark units of 1,000.<\/p>\n<p><code>nfc()<\/code> converts numbers such as 12345 into strings formatted with commas\nto mark the thousands place, as in <code>'12,345'<\/code>.<\/p>\n<p>The first parameter, <code>num<\/code>, is the number to convert to a string. For\nexample, calling <code>nfc(12345)<\/code> returns the string <code>'12,345'<\/code>.<\/p>\n<p>The second parameter, <code>right<\/code>, is optional. If a number is passed, as in\n<code>nfc(12345, 1)<\/code>, it sets the minimum number of digits to include to the\nright of the decimal place. If <code>right<\/code> is smaller than the number of\ndecimal places in <code>num<\/code>, then <code>num<\/code> will be rounded to the given number of\ndecimal places. For example, calling <code>nfc(12345.67, 1)<\/code> returns the string\n<code>'12,345.7'<\/code>. If <code>right<\/code> is larger than the number of decimal places in\n<code>num<\/code>, then unused decimal places will be set to 0. For example, calling\n<code>nfc(12345.67, 3)<\/code> returns the string <code>'12,345.670'<\/code>.<\/p>\n","itemtype":"method","name":"nfc","return":{"description":"formatted string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(16);\n\n  \/\/ Create a number variable.\n  let number = 12345;\n\n  \/\/ Display the number as a string.\n  let commas = nfc(number);\n  text(commas, 15, 33);\n\n  \/\/ Display the number with four digits\n  \/\/ to the left of the decimal.\n  let decimals = nfc(number, 2);\n  text(decimals, 15, 67);\n\n  describe(\n    'The numbers \"12,345\" and \"12,345.00\" written on separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of numbers.\n  let numbers = [12345, 6789];\n\n  \/\/ Convert the numbers to formatted strings.\n  let formatted = nfc(numbers);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Iterate over the array.\n  for (let i = 0; i < formatted.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 33;\n\n    \/\/ Display the original and formatted numbers.\n    text(`${numbers[i]} : ${formatted[i]}`, 50, y);\n  }\n\n  describe(\n    'The text \"12345 : 12,345\" and \"6789 : 6,789\" written on two separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions","overloads":[{"line":322,"params":[{"name":"num","description":"<p>number to format.<\/p>\n","type":"Number|String"},{"name":"right","description":"<p>number of digits to include to the right\n                                 of the decimal point.<\/p>\n","type":"Integer|String","optional":true}],"return":{"description":"formatted string.","type":"String"}},{"line":411,"params":[{"name":"nums","description":"<p>numbers to format.<\/p>\n","type":"Number[]"},{"name":"right","description":"","type":"Integer|String","optional":true}],"return":{"description":"formatted strings.","type":"String[]"}}]},{"file":"src\/utilities\/string_functions.js","line":447,"description":"<p>Converts a <code>Number<\/code> into a <code>String<\/code> with a plus or minus sign.<\/p>\n<p><code>nfp()<\/code> converts numbers such as 123 into strings formatted with a <code>+<\/code> or\n<code>-<\/code> symbol to mark whether they're positive or negative, as in <code>'+123'<\/code>.<\/p>\n<p>The first parameter, <code>num<\/code>, is the number to convert to a string. For\nexample, calling <code>nfp(123.45)<\/code> returns the string <code>'+123.45'<\/code>. If an array\nof numbers is passed, as in <code>nfp([123.45, -6.78])<\/code>, an array of formatted\nstrings will be returned.<\/p>\n<p>The second parameter, <code>left<\/code>, is optional. If a number is passed, as in\n<code>nfp(123.45, 4)<\/code>, it sets the minimum number of digits to include to the\nleft of the decimal place. If <code>left<\/code> is larger than the number of digits in\n<code>num<\/code>, then unused digits will be set to 0. For example, calling\n<code>nfp(123.45, 4)<\/code> returns the string <code>'+0123.45'<\/code>.<\/p>\n<p>The third parameter, <code>right<\/code>, is also optional. If a number is passed, as\nin <code>nfp(123.45, 4, 1)<\/code>, it sets the minimum number of digits to include to\nthe right of the decimal place. If <code>right<\/code> is smaller than the number of\ndecimal places in <code>num<\/code>, then <code>num<\/code> will be rounded to the given number of\ndecimal places.  For example, calling <code>nfp(123.45, 4, 1)<\/code> returns the\nstring <code>'+0123.5'<\/code>. If <code>right<\/code> is larger than the number of decimal places\nin <code>num<\/code>, then unused decimal places will be set to 0.  For example,\ncalling <code>nfp(123.45, 4, 3)<\/code> returns the string <code>'+0123.450'<\/code>.<\/p>\n","itemtype":"method","name":"nfp","return":{"description":"formatted string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create number variables.\n  let positive = 123;\n  let negative = -123;\n\n  \/\/ Convert the positive number to a formatted string.\n  let p = nfp(positive);\n\n  \/\/ Convert the negative number to a formatted string\n  \/\/ with four digits to the left of the decimal\n  \/\/ and two digits to the right of the decimal.\n  let n = nfp(negative, 4, 2);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Display the original and formatted numbers.\n  text(`${positive} : ${p}`, 50, 33);\n  text(`${negative} : ${n}`, 50, 67);\n\n  describe(\n    'The text \"123 : +123\" and \"-123 : -123.00\" written on separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create number variables.\n  let numbers = [123, -4.56];\n\n  \/\/ Convert the numbers to formatted strings\n  \/\/ with four digits to the left of the decimal\n  \/\/ and one digit to the right of the decimal.\n  let formatted = nfp(numbers, 4, 1);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(14);\n\n  \/\/ Iterate over the array.\n  for (let i = 0; i < formatted.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 33;\n\n    \/\/ Display the original and formatted numbers.\n    text(`${numbers[i]} : ${formatted[i]}`, 50, y);\n  }\n\n  describe(\n    'The text \"123 : +0123.0\" and \"-4.56 : 00-4.6\" written on separate lines. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions","overloads":[{"line":447,"params":[{"name":"num","description":"<p>number to format.<\/p>\n","type":"Number"},{"name":"left","description":"<p>number of digits to include to the left of the\n                        decimal point.<\/p>\n","type":"Integer","optional":true},{"name":"right","description":"<p>number of digits to include to the right of the\n                         decimal point.<\/p>\n","type":"Integer","optional":true}],"return":{"description":"formatted string.","type":"String"}},{"line":552,"params":[{"name":"nums","description":"<p>numbers to format.<\/p>\n","type":"Number[]"},{"name":"left","description":"","type":"Integer","optional":true},{"name":"right","description":"","type":"Integer","optional":true}],"return":{"description":"formatted strings.","type":"String[]"}}]},{"file":"src\/utilities\/string_functions.js","line":573,"description":"<p>Converts a positive <code>Number<\/code> into a <code>String<\/code> with an extra space in front.<\/p>\n<p><code>nfs()<\/code> converts positive numbers such as 123.45 into strings formatted\nwith an extra space in front, as in ' 123.45'. Doing so can be helpful for\naligning positive and negative numbers.<\/p>\n<p>The first parameter, <code>num<\/code>, is the number to convert to a string. For\nexample, calling <code>nfs(123.45)<\/code> returns the string <code>' 123.45'<\/code>.<\/p>\n<p>The second parameter, <code>left<\/code>, is optional. If a number is passed, as in\n<code>nfs(123.45, 4)<\/code>, it sets the minimum number of digits to include to the\nleft of the decimal place. If <code>left<\/code> is larger than the number of digits in\n<code>num<\/code>, then unused digits will be set to 0. For example, calling\n<code>nfs(123.45, 4)<\/code> returns the string <code>' 0123.45'<\/code>.<\/p>\n<p>The third parameter, <code>right<\/code>, is also optional. If a number is passed, as\nin <code>nfs(123.45, 4, 1)<\/code>, it sets the minimum number of digits to include to\nthe right of the decimal place. If <code>right<\/code> is smaller than the number of\ndecimal places in <code>num<\/code>, then <code>num<\/code> will be rounded to the given number of\ndecimal places.  For example, calling <code>nfs(123.45, 4, 1)<\/code> returns the\nstring <code>' 0123.5'<\/code>. If <code>right<\/code> is larger than the number of decimal places\nin <code>num<\/code>, then unused decimal places will be set to 0.  For example,\ncalling <code>nfs(123.45, 4, 3)<\/code> returns the string <code>' 0123.450'<\/code>.<\/p>\n","itemtype":"method","name":"nfs","return":{"description":"formatted string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create number variables.\n  let positive = 123;\n  let negative = -123;\n\n  \/\/ Convert the positive number to a formatted string.\n  let formatted = nfs(positive);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(16);\n\n  \/\/ Display the negative number and the formatted positive number.\n  text(negative, 50, 33);\n  text(formatted, 50, 67);\n\n  describe(\n    'The numbers -123 and 123 written on separate lines. The numbers align vertically. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a number variable.\n  let number = 123.45;\n\n  \/\/ Convert the positive number to a formatted string.\n  \/\/ Use four digits to the left of the decimal and\n  \/\/ one digit to the right.\n  let formatted = nfs(number, 4, 1);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(16);\n\n  \/\/ Display a negative version of the number and\n  \/\/ the formatted positive version.\n  text('-0123.5', 50, 33);\n  text(formatted, 50, 67);\n\n  describe(\n    'The numbers \"-0123.5\" and \"0123.5\" written on separate lines. The numbers align vertically. The text is in black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions","overloads":[{"line":573,"params":[{"name":"num","description":"<p>number to format.<\/p>\n","type":"Number"},{"name":"left","description":"<p>number of digits to include to the left of the\n                        decimal point.<\/p>\n","type":"Integer","optional":true},{"name":"right","description":"<p>number of digits to include to the right of the\n                         decimal point.<\/p>\n","type":"Integer","optional":true}],"return":{"description":"formatted string.","type":"String"}},{"line":669,"params":[{"name":"nums","description":"<p>numbers to format.<\/p>\n","type":"Array"},{"name":"left","description":"","type":"Integer","optional":true},{"name":"right","description":"","type":"Integer","optional":true}],"return":{"description":"formatted strings.","type":"String[]"}}]},{"file":"src\/utilities\/string_functions.js","line":690,"description":"<p>Splits a <code>String<\/code> into pieces and returns an array containing the pieces.<\/p>\n<p>The first parameter, <code>value<\/code>, is the string to split.<\/p>\n<p>The second parameter, <code>delim<\/code>, is the character(s) that should be used to\nsplit the string. For example, calling\n<code>split('rock...paper...scissors', '...')<\/code> would return the array\n<code>['rock', 'paper', 'scissors']<\/code> because there are three periods <code>...<\/code>\nbetween each word.<\/p>\n","itemtype":"method","name":"split","params":[{"name":"value","description":"<p>the String to be split<\/p>\n","type":"String"},{"name":"delim","description":"<p>the String used to separate the data<\/p>\n","type":"String"}],"return":{"description":"Array of Strings","type":"String[]"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let string = 'rock...paper...scissors';\n\n  \/\/ Split the string at each ...\n  let words = split(string, '...');\n\n  \/\/ Print the array to the console:\n  \/\/ [\"rock\", \"paper\", \"scissors\"]\n  print(words);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(16);\n\n  \/\/ Iterate over the words array.\n  for (let i = 0; i < words.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 25;\n\n    \/\/ Display the word.\n    text(words[i], 50, y);\n  }\n\n  describe(\n    'The words \"rock\", \"paper\", and \"scissors\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src\/utilities\/string_functions.js","line":751,"description":"<p>Splits a <code>String<\/code> into pieces and returns an array containing the pieces.<\/p>\n<p><code>splitTokens()<\/code> is an enhanced version of\n<a href=\"#\/p5\/split\">split()<\/a>. It can split a string when any characters\nfrom a list are detected.<\/p>\n<p>The first parameter, <code>value<\/code>, is the string to split.<\/p>\n<p>The second parameter, <code>delim<\/code>, is optional. It sets the character(s) that\nshould be used to split the string. <code>delim<\/code> can be a single string, as in\n<code>splitTokens('rock...paper...scissors...shoot', '...')<\/code>, or an array of\nstrings, as in\n<code>splitTokens('rock;paper,scissors...shoot, [';', ',', '...'])<\/code>. By default,\nif no <code>delim<\/code> characters are specified, then any whitespace character is\nused to split. Whitespace characters include tab (<code>\\t<\/code>), line feed (<code>\\n<\/code>),\ncarriage return (<code>\\r<\/code>), form feed (<code>\\f<\/code>), and space.<\/p>\n","itemtype":"method","name":"splitTokens","params":[{"name":"value","description":"<p>string to split.<\/p>\n","type":"String"},{"name":"delim","description":"<p>character(s) to use for splitting the string.<\/p>\n","type":"String","optional":true}],"return":{"description":"separated strings.","type":"String[]"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let string = 'rock paper scissors shoot';\n\n  \/\/ Split the string at each space.\n  let words = splitTokens(string);\n\n  \/\/ Print the array to the console.\n  print(words);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Iterate over the words array.\n  for (let i = 0; i < words.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 20;\n\n    \/\/ Display the word.\n    text(words[i], 50, y);\n  }\n\n  describe(\n    'The words \"rock\", \"paper\", \"scissors\", and \"shoot\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let string = 'rock...paper...scissors...shoot';\n\n  \/\/ Split the string at each ...\n  let words = splitTokens(string, '...');\n\n  \/\/ Print the array to the console.\n  print(words);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Iterate over the words array.\n  for (let i = 0; i < words.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 20;\n\n    \/\/ Display the word.\n    text(words[i], 50, y);\n  }\n\n  describe(\n    'The words \"rock\", \"paper\", \"scissors\", and \"shoot\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let string = 'rock;paper,scissors...shoot';\n\n  \/\/ Split the string at each semicolon, comma, or ...\n  let words = splitTokens(string, [';', ',', '...']);\n\n  \/\/ Print the array to the console.\n  print(words);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(12);\n\n  \/\/ Iterate over the words array.\n  for (let i = 0; i < words.length; i += 1) {\n\n    \/\/ Calculate the y-coordinate.\n    let y = (i + 1) * 20;\n\n    \/\/ Display the word.\n    text(words[i], 50, y);\n  }\n\n  describe(\n    'The words \"rock\", \"paper\", \"scissors\", and \"shoot\" written on separate lines. The text is black on a gray background.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions"},{"file":"src\/utilities\/string_functions.js","line":916,"description":"<p>Removes whitespace from the start and end of a <code>String<\/code> without changing the middle.<\/p>\n<p><code>trim()<\/code> trims\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/whitespace\" target=\"_blank\">whitespace characters<\/a>\nsuch as spaces, carriage returns, tabs, Unicode \"nbsp\" character.<\/p>\n<p>The parameter, <code>str<\/code>, is the string to trim. If a single string is passed,\nas in <code>trim('   pad   ')<\/code>, a single string is returned. If an array of\nstrings is passed, as in <code>trim(['    pad   ', '\\n space \\n'])<\/code>, an array of\nstrings is returned.<\/p>\n","itemtype":"method","name":"trim","return":{"description":"trimmed string.","type":"String"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create a string variable.\n  let string = '   p5*js   ';\n\n  \/\/ Trim the whitespace.\n  let trimmed = trim(string);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(16);\n\n  \/\/ Display the text.\n  text(`Hello, ${trimmed}!`, 50, 50);\n\n  describe('The text \"Hello, p5*js!\" written in black on a gray background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Create an array of strings.\n  let strings = ['   wide  ', '\\n  open  ', '\\n spaces  '];\n\n  \/\/ Trim the whitespace.\n  let trimmed = trim(strings);\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont('Courier New');\n  textSize(10);\n\n  \/\/ Display the text.\n  text(`${trimmed[0]} ${trimmed[1]} ${trimmed[2]}`, 50, 50);\n\n  describe('The text \"wide open spaces\" written in black on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Data","submodule":"String Functions","overloads":[{"line":916,"params":[{"name":"str","description":"<p>string to trim.<\/p>\n","type":"String"}],"return":{"description":"trimmed string.","type":"String"}},{"line":984,"params":[{"name":"strs","description":"<p>strings to trim.<\/p>\n","type":"String[]"}],"return":{"description":"trimmed strings.","type":"String[]"}}]},{"file":"src\/utilities\/time_date.js","line":10,"description":"<p>Returns the current day as a number from 1\u201331.<\/p>\n","itemtype":"method","name":"day","return":{"description":"current day between 1 and 31.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the current day.\n  let d = day();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(12);\n  textFont('Courier New');\n\n  \/\/ Display the day.\n  text(`Current day: ${d}`, 20, 50, 60);\n\n  describe(`The text 'Current day: ${d}' written in black on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src\/utilities\/time_date.js","line":44,"description":"<p>Returns the current hour as a number from 0\u201323.<\/p>\n","itemtype":"method","name":"hour","return":{"description":"current hour between 0 and 23.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the current hour.\n  let h = hour();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(12);\n  textFont('Courier New');\n\n  \/\/ Display the hour.\n  text(`Current hour: ${h}`, 20, 50, 60);\n\n  describe(`The text 'Current hour: ${h}' written in black on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src\/utilities\/time_date.js","line":78,"description":"<p>Returns the current minute as a number from 0\u201359.<\/p>\n","itemtype":"method","name":"minute","return":{"description":"current minute between 0 and 59.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the current minute.\n  let m = minute();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(12);\n  textFont('Courier New');\n\n  \/\/ Display the minute.\n  text(`Current minute: ${m}`, 10, 50, 80);\n\n  describe(`The text 'Current minute: ${m}' written in black on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src\/utilities\/time_date.js","line":112,"description":"<p>Returns the number of milliseconds since a sketch started running.<\/p>\n<p><code>millis()<\/code> keeps track of how long a sketch has been running in\nmilliseconds (thousandths of a second). This information is often\nhelpful for timing events and animations.<\/p>\n<p>If a sketch has a\n<a href=\"#\/p5\/setup\">setup()<\/a> function, then <code>millis()<\/code> begins tracking\ntime before the code in <a href=\"#\/p5\/setup\">setup()<\/a> runs. If a\nsketch includes a <a href=\"#\/p5\/preload\">preload()<\/a> function, then\n<code>millis()<\/code> begins tracking time as soon as the code in\n<a href=\"#\/p5\/preload\">preload()<\/a> starts running.<\/p>\n","itemtype":"method","name":"millis","return":{"description":"number of milliseconds since starting the sketch.","type":"Number"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the number of milliseconds the sketch has run.\n  let ms = millis();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(10);\n  textFont('Courier New');\n\n  \/\/ Display how long it took setup() to be called.\n  text(`Startup time: ${round(ms, 2)} ms`, 5, 50, 90);\n\n  describe(\n    `The text 'Startup time: ${round(ms, 2)} ms' written in black on a gray background.`\n  );\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('The text \"Running time: S sec\" written in black on a gray background. The number S increases as the sketch runs.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Get the number of seconds the sketch has run.\n  let s = millis() \/ 1000;\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(10);\n  textFont('Courier New');\n\n  \/\/ Display how long the sketch has run.\n  text(`Running time: ${nf(s, 1, 1)} sec`, 5, 50, 90);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe('A white circle oscillates left and right on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Get the number of seconds the sketch has run.\n  let s = millis() \/ 1000;\n\n  \/\/ Calculate an x-coordinate.\n  let x = 30 * sin(s) + 50;\n\n  \/\/ Draw the circle.\n  circle(x, 50, 30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Load the GeoJSON.\nfunction preload() {\n  loadJSON('https:\/\/earthquake.usgs.gov\/earthquakes\/feed\/v1.0\/summary\/all_day.geojson');\n}\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the number of milliseconds the sketch has run.\n  let ms = millis();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textFont('Courier New');\n  textSize(11);\n\n  \/\/ Display how long it took to load the data.\n  text(`It took ${round(ms, 2)} ms to load the data`, 5, 50, 100);\n\n  describe(\n    `The text \"It took ${round(ms, 2)} ms to load the data\" written in black on a gray background.`\n  );\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src\/utilities\/time_date.js","line":242,"description":"<p>Returns the current month as a number from 1\u201312.<\/p>\n","itemtype":"method","name":"month","return":{"description":"current month between 1 and 12.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the current month.\n  let m = month();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(12);\n  textFont('Courier New');\n\n  \/\/ Display the month.\n  text(`Current month: ${m}`, 10, 50, 80);\n\n  describe(`The text 'Current month: ${m}' written in black on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src\/utilities\/time_date.js","line":277,"description":"<p>Returns the current second as a number from 0\u201359.<\/p>\n","itemtype":"method","name":"second","return":{"description":"current second between 0 and 59.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the current second.\n  let s = second();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(12);\n  textFont('Courier New');\n\n  \/\/ Display the second.\n  text(`Current second: ${s}`, 10, 50, 80);\n\n  describe(`The text 'Current second: ${s}' written in black on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src\/utilities\/time_date.js","line":311,"description":"<p>Returns the current year as a number such as 1999.<\/p>\n","itemtype":"method","name":"year","return":{"description":"current year.","type":"Integer"},"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100);\n\n  background(200);\n\n  \/\/ Get the current year.\n  let y = year();\n\n  \/\/ Style the text.\n  textAlign(LEFT, CENTER);\n  textSize(12);\n  textFont('Courier New');\n\n  \/\/ Display the year.\n  text(`Current year: ${y}`, 10, 50, 80);\n\n  describe(`The text 'Current year: ${y}' written in black on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"IO","submodule":"Time & Date"},{"file":"src\/webgl\/3d_primitives.js","line":13,"description":"<p>Begins adding shapes to a new\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object.<\/p>\n<p>The <code>beginGeometry()<\/code> and <a href=\"#\/p5\/endGeometry\">endGeometry()<\/a>\nfunctions help with creating complex 3D shapes from simpler ones such as\n<a href=\"#\/p5\/sphere\">sphere()<\/a>. <code>beginGeometry()<\/code> begins adding shapes\nto a custom <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object and\n<a href=\"#\/p5\/endGeometry\">endGeometry()<\/a> stops adding them.<\/p>\n<p><code>beginGeometry()<\/code> and <a href=\"#\/p5\/endGeometry\">endGeometry()<\/a> can help\nto make sketches more performant. For example, if a complex 3D shape\ndoesn\u2019t change while a sketch runs, then it can be created with\n<code>beginGeometry()<\/code> and <a href=\"#\/p5\/endGeometry\">endGeometry()<\/a>.\nCreating a <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object once and then\ndrawing it will run faster than repeatedly drawing the individual pieces.<\/p>\n<p>See <a href=\"#\/p5\/buildGeometry\">buildGeometry()<\/a> for another way to\nbuild 3D shapes.<\/p>\n<p>Note: <code>beginGeometry()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"beginGeometry","example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  \/\/ Add a cone.\n  cone();\n\n  \/\/ Stop building the p5.Geometry object.\n  shape = endGeometry();\n\n  describe('A white cone drawn on a gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Geometry object.\n  createArrow();\n\n  describe('A white arrow drawn on a gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n}\n\nfunction createArrow() {\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  \/\/ Add shapes.\n  push();\n  rotateX(PI);\n  cone(10);\n  translate(0, -10, 0);\n  cylinder(3, 20);\n  pop();\n\n  \/\/ Stop building the p5.Geometry object.\n  shape = endGeometry();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet blueArrow;\nlet redArrow;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the arrows.\n  redArrow = createArrow('red');\n  blueArrow = createArrow('blue');\n\n  describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the arrows.\n  noStroke();\n\n  \/\/ Draw the red arrow.\n  model(redArrow);\n\n  \/\/ Translate and rotate the coordinate system.\n  translate(30, 0, 0);\n  rotateZ(frameCount * 0.01);\n\n  \/\/ Draw the blue arrow.\n  model(blueArrow);\n}\n\nfunction createArrow(fillColor) {\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  fill(fillColor);\n\n  \/\/ Add shapes to the p5.Geometry object.\n  push();\n  rotateX(PI);\n  cone(10);\n  translate(0, -10, 0);\n  cylinder(3, 20);\n  pop();\n\n  \/\/ Stop building the p5.Geometry object.\n  let shape = endGeometry();\n\n  return shape;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet button;\nlet particles;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a button to reset the particle system.\n  button = createButton('Reset');\n\n  \/\/ Call resetModel() when the user presses the button.\n  button.mousePressed(resetModel);\n\n  \/\/ Add the original set of particles.\n  resetModel();\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the particles.\n  noStroke();\n\n  \/\/ Draw the particles.\n  model(particles);\n}\n\nfunction resetModel() {\n  \/\/ If the p5.Geometry object has already been created,\n  \/\/ free those resources.\n  if (particles) {\n    freeGeometry(particles);\n  }\n\n  \/\/ Create a new p5.Geometry object with random spheres.\n  particles = createParticles();\n}\n\nfunction createParticles() {\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  \/\/ Add shapes.\n  for (let i = 0; i < 60; i += 1) {\n    \/\/ Calculate random coordinates.\n    let x = randomGaussian(0, 20);\n    let y = randomGaussian(0, 20);\n    let z = randomGaussian(0, 20);\n\n    push();\n    \/\/ Translate to the particle's coordinates.\n    translate(x, y, z);\n    \/\/ Draw the particle.\n    sphere(5);\n    pop();\n  }\n\n  \/\/ Stop building the p5.Geometry object.\n  let shape = endGeometry();\n\n  return shape;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":266,"description":"<p>Stops adding shapes to a new\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object and returns the object.<\/p>\n<p>The <code>beginGeometry()<\/code> and <a href=\"#\/p5\/endGeometry\">endGeometry()<\/a>\nfunctions help with creating complex 3D shapes from simpler ones such as\n<a href=\"#\/p5\/sphere\">sphere()<\/a>. <code>beginGeometry()<\/code> begins adding shapes\nto a custom <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object and\n<a href=\"#\/p5\/endGeometry\">endGeometry()<\/a> stops adding them.<\/p>\n<p><code>beginGeometry()<\/code> and <a href=\"#\/p5\/endGeometry\">endGeometry()<\/a> can help\nto make sketches more performant. For example, if a complex 3D shape\ndoesn\u2019t change while a sketch runs, then it can be created with\n<code>beginGeometry()<\/code> and <a href=\"#\/p5\/endGeometry\">endGeometry()<\/a>.\nCreating a <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object once and then\ndrawing it will run faster than repeatedly drawing the individual pieces.<\/p>\n<p>See <a href=\"#\/p5\/buildGeometry\">buildGeometry()<\/a> for another way to\nbuild 3D shapes.<\/p>\n<p>Note: <code>endGeometry()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"endGeometry","return":{"description":"new 3D shape.","type":"p5.Geometry"},"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  \/\/ Add a cone.\n  cone();\n\n  \/\/ Stop building the p5.Geometry object.\n  shape = endGeometry();\n\n  describe('A white cone drawn on a gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Geometry object.\n  createArrow();\n\n  describe('A white arrow drawn on a gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n}\n\nfunction createArrow() {\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  \/\/ Add shapes.\n  push();\n  rotateX(PI);\n  cone(10);\n  translate(0, -10, 0);\n  cylinder(3, 20);\n  pop();\n\n  \/\/ Stop building the p5.Geometry object.\n  shape = endGeometry();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet blueArrow;\nlet redArrow;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the arrows.\n  redArrow = createArrow('red');\n  blueArrow = createArrow('blue');\n\n  describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the arrows.\n  noStroke();\n\n  \/\/ Draw the red arrow.\n  model(redArrow);\n\n  \/\/ Translate and rotate the coordinate system.\n  translate(30, 0, 0);\n  rotateZ(frameCount * 0.01);\n\n  \/\/ Draw the blue arrow.\n  model(blueArrow);\n}\n\nfunction createArrow(fillColor) {\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  fill(fillColor);\n\n  \/\/ Add shapes to the p5.Geometry object.\n  push();\n  rotateX(PI);\n  cone(10);\n  translate(0, -10, 0);\n  cylinder(3, 20);\n  pop();\n\n  \/\/ Stop building the p5.Geometry object.\n  let shape = endGeometry();\n\n  return shape;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet button;\nlet particles;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a button to reset the particle system.\n  button = createButton('Reset');\n\n  \/\/ Call resetModel() when the user presses the button.\n  button.mousePressed(resetModel);\n\n  \/\/ Add the original set of particles.\n  resetModel();\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the particles.\n  noStroke();\n\n  \/\/ Draw the particles.\n  model(particles);\n}\n\nfunction resetModel() {\n  \/\/ If the p5.Geometry object has already been created,\n  \/\/ free those resources.\n  if (particles) {\n    freeGeometry(particles);\n  }\n\n  \/\/ Create a new p5.Geometry object with random spheres.\n  particles = createParticles();\n}\n\nfunction createParticles() {\n  \/\/ Start building the p5.Geometry object.\n  beginGeometry();\n\n  \/\/ Add shapes.\n  for (let i = 0; i < 60; i += 1) {\n    \/\/ Calculate random coordinates.\n    let x = randomGaussian(0, 20);\n    let y = randomGaussian(0, 20);\n    let z = randomGaussian(0, 20);\n\n    push();\n    \/\/ Translate to the particle's coordinates.\n    translate(x, y, z);\n    \/\/ Draw the particle.\n    sphere(5);\n    pop();\n  }\n\n  \/\/ Stop building the p5.Geometry object.\n  let shape = endGeometry();\n\n  return shape;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":520,"description":"<p>Creates a custom <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object from\nsimpler 3D shapes.<\/p>\n<p><code>buildGeometry()<\/code> helps with creating complex 3D shapes from simpler ones\nsuch as <a href=\"#\/p5\/sphere\">sphere()<\/a>. It can help to make sketches\nmore performant. For example, if a complex 3D shape doesn\u2019t change while a\nsketch runs, then it can be created with <code>buildGeometry()<\/code>. Creating a\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object once and then drawing it\nwill run faster than repeatedly drawing the individual pieces.<\/p>\n<p>The parameter, <code>callback<\/code>, is a function with the drawing instructions for\nthe new <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object. It will be called\nonce to create the new 3D shape.<\/p>\n<p>See <a href=\"#\/p5\/beginGeometry\">beginGeometry()<\/a> and\n<a href=\"#\/p5\/endGeometry\">endGeometry()<\/a> for another way to build 3D\nshapes.<\/p>\n<p>Note: <code>buildGeometry()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"buildGeometry","params":[{"name":"callback","description":"<p>function that draws the shape.<\/p>\n","type":"Function"}],"return":{"description":"new 3D shape.","type":"p5.Geometry"},"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Geometry object.\n  shape = buildGeometry(createShape);\n\n  describe('A white cone drawn on a gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n}\n\n\/\/ Create p5.Geometry object from a single cone.\nfunction createShape() {\n  cone();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the arrow.\n  shape = buildGeometry(createArrow);\n\n  describe('A white arrow drawn on a gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the arrow.\n  noStroke();\n\n  \/\/ Draw the arrow.\n  model(shape);\n}\n\nfunction createArrow() {\n  \/\/ Add shapes to the p5.Geometry object.\n  push();\n  rotateX(PI);\n  cone(10);\n  translate(0, -10, 0);\n  cylinder(3, 20);\n  pop();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Geometry object.\n  shape = buildGeometry(createArrow);\n\n  describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the arrows.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n\n  \/\/ Translate and rotate the coordinate system.\n  translate(30, 0, 0);\n  rotateZ(frameCount * 0.01);\n\n  \/\/ Draw the p5.Geometry object again.\n  model(shape);\n}\n\nfunction createArrow() {\n  \/\/ Add shapes to the p5.Geometry object.\n  push();\n  rotateX(PI);\n  cone(10);\n  translate(0, -10, 0);\n  cylinder(3, 20);\n  pop();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet button;\nlet particles;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a button to reset the particle system.\n  button = createButton('Reset');\n\n  \/\/ Call resetModel() when the user presses the button.\n  button.mousePressed(resetModel);\n\n  \/\/ Add the original set of particles.\n  resetModel();\n\n  describe('A set of white spheres on a gray background. The spheres are positioned randomly. Their positions reset when the user presses the Reset button.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the particles.\n  noStroke();\n\n  \/\/ Draw the particles.\n  model(particles);\n}\n\nfunction resetModel() {\n  \/\/ If the p5.Geometry object has already been created,\n  \/\/ free those resources.\n  if (particles) {\n    freeGeometry(particles);\n  }\n\n  \/\/ Create a new p5.Geometry object with random spheres.\n  particles = buildGeometry(createParticles);\n}\n\nfunction createParticles() {\n  for (let i = 0; i < 60; i += 1) {\n    \/\/ Calculate random coordinates.\n    let x = randomGaussian(0, 20);\n    let y = randomGaussian(0, 20);\n    let z = randomGaussian(0, 20);\n\n    push();\n    \/\/ Translate to the particle's coordinates.\n    translate(x, y, z);\n    \/\/ Draw the particle.\n    sphere(5);\n    pop();\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":748,"description":"<p>Clears a <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object from the graphics\nprocessing unit (GPU) memory.<\/p>\n<p><a href=\"#\/p5.Geometry\">p5.Geometry<\/a> objects can contain lots of data\nabout their vertices, surface normals, colors, and so on. Complex 3D shapes\ncan use lots of memory which is a limited resource in many GPUs. Calling\n<code>freeGeometry()<\/code> can improve performance by freeing a\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object\u2019s resources from GPU memory.\n<code>freeGeometry()<\/code> works with <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> objects\ncreated with <a href=\"#\/p5\/beginGeometry\">beginGeometry()<\/a> and\n<a href=\"#\/p5\/endGeometry\">endGeometry()<\/a>,\n<a href=\"#\/p5\/buildGeometry\">buildGeometry()<\/a>, and\n<a href=\"#\/p5\/loadModel\">loadModel()<\/a>.<\/p>\n<p>The parameter, <code>geometry<\/code>, is the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a>\nobject to be freed.<\/p>\n<p>Note: A <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object can still be drawn\nafter its resources are cleared from GPU memory. It may take longer to draw\nthe first time it\u2019s redrawn.<\/p>\n<p>Note: <code>freeGeometry()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"freeGeometry","params":[{"name":"geometry","description":"<p>3D shape whose resources should be freed.<\/p>\n","type":"p5.Geometry"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Geometry object.\n  beginGeometry();\n  cone();\n  let shape = endGeometry();\n\n  \/\/ Draw the shape.\n  model(shape);\n\n  \/\/ Free the shape's resources.\n  freeGeometry(shape);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet button;\nlet particles;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a button to reset the particle system.\n  button = createButton('Reset');\n\n  \/\/ Call resetModel() when the user presses the button.\n  button.mousePressed(resetModel);\n\n  \/\/ Add the original set of particles.\n  resetModel();\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the particles.\n  noStroke();\n\n  \/\/ Draw the particles.\n  model(particles);\n}\n\nfunction resetModel() {\n  \/\/ If the p5.Geometry object has already been created,\n  \/\/ free those resources.\n  if (particles) {\n    freeGeometry(particles);\n  }\n\n  \/\/ Create a new p5.Geometry object with random spheres.\n  particles = buildGeometry(createParticles);\n}\n\nfunction createParticles() {\n  for (let i = 0; i < 60; i += 1) {\n    \/\/ Calculate random coordinates.\n    let x = randomGaussian(0, 20);\n    let y = randomGaussian(0, 20);\n    let z = randomGaussian(0, 20);\n\n    push();\n    \/\/ Translate to the particle's coordinates.\n    translate(x, y, z);\n    \/\/ Draw the particle.\n    sphere(5);\n    pop();\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":866,"description":"<p>Draws a plane.<\/p>\n<p>A plane is a four-sided, flat shape with every angle measuring 90\u02da. It\u2019s\nsimilar to a rectangle and offers advanced drawing features in WebGL mode.<\/p>\n<p>The first parameter, <code>width<\/code>, is optional. If a <code>Number<\/code> is passed, as in\n<code>plane(20)<\/code>, it sets the plane\u2019s width and height. By default, <code>width<\/code> is\n50.<\/p>\n<p>The second parameter, <code>height<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>plane(20, 30)<\/code>, it sets the plane\u2019s height. By default, <code>height<\/code> is\nset to the plane\u2019s <code>width<\/code>.<\/p>\n<p>The third parameter, <code>detailX<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>plane(20, 30, 5)<\/code> it sets the number of triangle subdivisions to use\nalong the x-axis. All 3D shapes are made by connecting triangles to form\ntheir surfaces. By default, <code>detailX<\/code> is 1.<\/p>\n<p>The fourth parameter, <code>detailY<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>plane(20, 30, 5, 7)<\/code> it sets the number of triangle subdivisions to\nuse along the y-axis. All 3D shapes are made by connecting triangles to\nform their surfaces. By default, <code>detailY<\/code> is 1.<\/p>\n<p>Note: <code>plane()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"plane","params":[{"name":"width","description":"<p>width of the plane.<\/p>\n","type":"Number","optional":true},{"name":"height","description":"<p>height of the plane.<\/p>\n","type":"Number","optional":true},{"name":"detailX","description":"<p>number of triangle subdivisions along the x-axis.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of triangle subdivisions along the y-axis.<\/p>\n","type":"Integer","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white plane on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the plane.\n  plane();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white plane on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the plane.\n  \/\/ Set its width and height to 30.\n  plane(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white plane on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the plane.\n  \/\/ Set its width to 30 and height to 50.\n  plane(30, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":1009,"description":"<p>Draws a box (rectangular prism).<\/p>\n<p>A box is a 3D shape with six faces. Each face makes a 90\u02da with four\nneighboring faces.<\/p>\n<p>The first parameter, <code>width<\/code>, is optional. If a <code>Number<\/code> is passed, as in\n<code>box(20)<\/code>, it sets the box\u2019s width and height. By default, <code>width<\/code> is 50.<\/p>\n<p>The second parameter, <code>height<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>box(20, 30)<\/code>, it sets the box\u2019s height. By default, <code>height<\/code> is set\nto the box\u2019s <code>width<\/code>.<\/p>\n<p>The third parameter, <code>depth<\/code>, is also optional. If a <code>Number<\/code> is passed, as\nin <code>box(20, 30, 40)<\/code>, it sets the box\u2019s depth. By default, <code>depth<\/code> is set\nto the box\u2019s <code>height<\/code>.<\/p>\n<p>The fourth parameter, <code>detailX<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>box(20, 30, 40, 5)<\/code>, it sets the number of triangle subdivisions to\nuse along the x-axis. All 3D shapes are made by connecting triangles to\nform their surfaces. By default, <code>detailX<\/code> is 1.<\/p>\n<p>The fifth parameter, <code>detailY<\/code>, is also optional. If a number is passed, as\nin <code>box(20, 30, 40, 5, 7)<\/code>, it sets the number of triangle subdivisions to\nuse along the y-axis. All 3D shapes are made by connecting triangles to\nform their surfaces. By default, <code>detailY<\/code> is 1.<\/p>\n<p>Note: <code>box()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"box","params":[{"name":"width","description":"<p>width of the box.<\/p>\n","type":"Number","optional":true},{"name":"height","description":"<p>height of the box.<\/p>\n","type":"Number","optional":true},{"name":"depth","description":"<p>depth of the box.<\/p>\n","type":"Number","optional":true},{"name":"detailX","description":"<p>number of triangle subdivisions along the x-axis.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of triangle subdivisions along the y-axis.<\/p>\n","type":"Integer","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white box on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white box on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the box.\n  \/\/ Set its width and height to 30.\n  box(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white box on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the box.\n  \/\/ Set its width to 30 and height to 50.\n  box(30, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white box on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the box.\n  \/\/ Set its width to 30, height to 50, and depth to 10.\n  box(30, 50, 10);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":1227,"description":"<p>Draws a sphere.<\/p>\n<p>A sphere is a 3D shape with triangular faces that connect to form a round\nsurface. Spheres with few faces look like crystals. Spheres with many faces\nhave smooth surfaces and look like balls.<\/p>\n<p>The first parameter, <code>radius<\/code>, is optional. If a <code>Number<\/code> is passed, as in\n<code>sphere(20)<\/code>, it sets the radius of the sphere. By default, <code>radius<\/code> is 50.<\/p>\n<p>The second parameter, <code>detailX<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>sphere(20, 5)<\/code>, it sets the number of triangle subdivisions to use\nalong the x-axis. All 3D shapes are made by connecting triangles to form\ntheir surfaces. By default, <code>detailX<\/code> is 24.<\/p>\n<p>The third parameter, <code>detailY<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>sphere(20, 5, 2)<\/code>, it sets the number of triangle subdivisions to\nuse along the y-axis. All 3D shapes are made by connecting triangles to\nform their surfaces. By default, <code>detailY<\/code> is 16.<\/p>\n<p>Note: <code>sphere()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"sphere","params":[{"name":"radius","description":"<p>radius of the sphere. Defaults to 50.<\/p>\n","type":"Number","optional":true},{"name":"detailX","description":"<p>number of triangle subdivisions along the x-axis. Defaults to 24.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of triangle subdivisions along the y-axis. Defaults to 16.<\/p>\n","type":"Integer","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the sphere.\n  sphere();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the sphere.\n  \/\/ Set its radius to 30.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the sphere.\n  \/\/ Set its radius to 30.\n  \/\/ Set its detailX to 6.\n  sphere(30, 6);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the sphere.\n  \/\/ Set its radius to 30.\n  \/\/ Set its detailX to 24.\n  \/\/ Set its detailY to 4.\n  sphere(30, 24, 4);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":1477,"description":"<p>Draws a cylinder.<\/p>\n<p>A cylinder is a 3D shape with triangular faces that connect a flat bottom\nto a flat top. Cylinders with few faces look like boxes. Cylinders with\nmany faces have smooth surfaces.<\/p>\n<p>The first parameter, <code>radius<\/code>, is optional. If a <code>Number<\/code> is passed, as in\n<code>cylinder(20)<\/code>, it sets the radius of the cylinder\u2019s base. By default,\n<code>radius<\/code> is 50.<\/p>\n<p>The second parameter, <code>height<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>cylinder(20, 30)<\/code>, it sets the cylinder\u2019s height. By default,\n<code>height<\/code> is set to the cylinder\u2019s <code>radius<\/code>.<\/p>\n<p>The third parameter, <code>detailX<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>cylinder(20, 30, 5)<\/code>, it sets the number of edges used to form the\ncylinder's top and bottom. Using more edges makes the top and bottom look\nmore like circles. By default, <code>detailX<\/code> is 24.<\/p>\n<p>The fourth parameter, <code>detailY<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>cylinder(20, 30, 5, 2)<\/code>, it sets the number of triangle subdivisions\nto use along the y-axis, between cylinder's the top and bottom. All 3D\nshapes are made by connecting triangles to form their surfaces. By default,\n<code>detailY<\/code> is 1.<\/p>\n<p>The fifth parameter, <code>bottomCap<\/code>, is also optional. If a <code>false<\/code> is passed,\nas in <code>cylinder(20, 30, 5, 2, false)<\/code> the cylinder\u2019s bottom won\u2019t be drawn.\nBy default, <code>bottomCap<\/code> is <code>true<\/code>.<\/p>\n<p>The sixth parameter, <code>topCap<\/code>, is also optional. If a <code>false<\/code> is passed, as\nin <code>cylinder(20, 30, 5, 2, false, false)<\/code> the cylinder\u2019s top won\u2019t be\ndrawn. By default, <code>topCap<\/code> is <code>true<\/code>.<\/p>\n<p>Note: <code>cylinder()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"cylinder","params":[{"name":"radius","description":"<p>radius of the cylinder. Defaults to 50.<\/p>\n","type":"Number","optional":true},{"name":"height","description":"<p>height of the cylinder. Defaults to the value of <code>radius<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"detailX","description":"<p>number of edges along the top and bottom. Defaults to 24.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of triangle subdivisions along the y-axis. Defaults to 1.<\/p>\n","type":"Integer","optional":true},{"name":"bottomCap","description":"<p>whether to draw the cylinder's bottom. Defaults to <code>true<\/code>.<\/p>\n","type":"Boolean","optional":true},{"name":"topCap","description":"<p>whether to draw the cylinder's top. Defaults to <code>true<\/code>.<\/p>\n","type":"Boolean","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cylinder on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cylinder.\n  cylinder();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cylinder on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cylinder.\n  \/\/ Set its radius and height to 30.\n  cylinder(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cylinder on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cylinder.\n  \/\/ Set its radius to 30 and height to 50.\n  cylinder(30, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white box on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cylinder.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 5.\n  cylinder(30, 50, 5);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cylinder on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cylinder.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 24 and detailY to 2.\n  cylinder(30, 50, 24, 2);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cylinder on a gray background. Its top is missing.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cylinder.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 24 and detailY to 1.\n  \/\/ Don't draw its bottom.\n  cylinder(30, 50, 24, 1, false);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cylinder on a gray background. Its top and bottom are missing.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cylinder.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 24 and detailY to 1.\n  \/\/ Don't draw its bottom or top.\n  cylinder(30, 50, 24, 1, false, false);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":1730,"description":"<p>Draws a cone.<\/p>\n<p>A cone is a 3D shape with triangular faces that connect a flat bottom to a\nsingle point. Cones with few faces look like pyramids. Cones with many\nfaces have smooth surfaces.<\/p>\n<p>The first parameter, <code>radius<\/code>, is optional. If a <code>Number<\/code> is passed, as in\n<code>cone(20)<\/code>, it sets the radius of the cone\u2019s base. By default, <code>radius<\/code> is\n50.<\/p>\n<p>The second parameter, <code>height<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>cone(20, 30)<\/code>, it sets the cone\u2019s height. By default, <code>height<\/code> is\nset to the cone\u2019s <code>radius<\/code>.<\/p>\n<p>The third parameter, <code>detailX<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>cone(20, 30, 5)<\/code>, it sets the number of edges used to form the\ncone's base. Using more edges makes the base look more like a circle. By\ndefault, <code>detailX<\/code> is 24.<\/p>\n<p>The fourth parameter, <code>detailY<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>cone(20, 30, 5, 7)<\/code>, it sets the number of triangle subdivisions to\nuse along the y-axis connecting the base to the tip. All 3D shapes are made\nby connecting triangles to form their surfaces. By default, <code>detailY<\/code> is 1.<\/p>\n<p>The fifth parameter, <code>cap<\/code>, is also optional. If a <code>false<\/code> is passed, as\nin <code>cone(20, 30, 5, 7, false)<\/code> the cone\u2019s base won\u2019t be drawn. By default,\n<code>cap<\/code> is <code>true<\/code>.<\/p>\n<p>Note: <code>cone()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"cone","params":[{"name":"radius","description":"<p>radius of the cone's base. Defaults to 50.<\/p>\n","type":"Number","optional":true},{"name":"height","description":"<p>height of the cone. Defaults to the value of <code>radius<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"detailX","description":"<p>number of edges used to draw the base. Defaults to 24.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of triangle subdivisions along the y-axis. Defaults to 1.<\/p>\n","type":"Integer","optional":true},{"name":"cap","description":"<p>whether to draw the cone's base.  Defaults to <code>true<\/code>.<\/p>\n","type":"Boolean","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cone on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cone.\n  cone();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cone on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cone.\n  \/\/ Set its radius and height to 30.\n  cone(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cone on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cone.\n  \/\/ Set its radius to 30 and height to 50.\n  cone(30, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cone on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cone.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 5.\n  cone(30, 50, 5);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white pyramid on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cone.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 5.\n  cone(30, 50, 5);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cone on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cone.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 24 and detailY to 2.\n  cone(30, 50, 24, 2);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cone on a gray background. Its base is missing.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the cone.\n  \/\/ Set its radius to 30 and height to 50.\n  \/\/ Set its detailX to 24 and detailY to 1.\n  \/\/ Don't draw its base.\n  cone(30, 50, 24, 1, false);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":1965,"description":"<p>Draws an ellipsoid.<\/p>\n<p>An ellipsoid is a 3D shape with triangular faces that connect to form a\nround surface. Ellipsoids with few faces look like crystals. Ellipsoids\nwith many faces have smooth surfaces and look like eggs. <code>ellipsoid()<\/code>\ndefines a shape by its radii. This is different from\n<a href=\"#\/p5\/ellipse\">ellipse()<\/a> which uses diameters\n(width and height).<\/p>\n<p>The first parameter, <code>radiusX<\/code>, is optional. If a <code>Number<\/code> is passed, as in\n<code>ellipsoid(20)<\/code>, it sets the radius of the ellipsoid along the x-axis. By\ndefault, <code>radiusX<\/code> is 50.<\/p>\n<p>The second parameter, <code>radiusY<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>ellipsoid(20, 30)<\/code>, it sets the ellipsoid\u2019s radius along the y-axis.\nBy default, <code>radiusY<\/code> is set to the ellipsoid\u2019s <code>radiusX<\/code>.<\/p>\n<p>The third parameter, <code>radiusZ<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>ellipsoid(20, 30, 40)<\/code>, it sets the ellipsoid\u2019s radius along the\nz-axis. By default, <code>radiusZ<\/code> is set to the ellipsoid\u2019s <code>radiusY<\/code>.<\/p>\n<p>The fourth parameter, <code>detailX<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>ellipsoid(20, 30, 40, 5)<\/code>, it sets the number of triangle\nsubdivisions to use along the x-axis. All 3D shapes are made by connecting\ntriangles to form their surfaces. By default, <code>detailX<\/code> is 24.<\/p>\n<p>The fifth parameter, <code>detailY<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>ellipsoid(20, 30, 40, 5, 7)<\/code>, it sets the number of triangle\nsubdivisions to use along the y-axis. All 3D shapes are made by connecting\ntriangles to form their surfaces. By default, <code>detailY<\/code> is 16.<\/p>\n<p>Note: <code>ellipsoid()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"ellipsoid","params":[{"name":"radiusX","description":"<p>radius of the ellipsoid along the x-axis. Defaults to 50.<\/p>\n","type":"Number","optional":true},{"name":"radiusY","description":"<p>radius of the ellipsoid along the y-axis. Defaults to <code>radiusX<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"radiusZ","description":"<p>radius of the ellipsoid along the z-axis. Defaults to <code>radiusY<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"detailX","description":"<p>number of triangle subdivisions along the x-axis. Defaults to 24.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of triangle subdivisions along the y-axis. Defaults to 16.<\/p>\n","type":"Integer","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the ellipsoid.\n  \/\/ Set its radiusX to 30.\n  ellipsoid(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white ellipsoid on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the ellipsoid.\n  \/\/ Set its radiusX to 30.\n  \/\/ Set its radiusY to 40.\n  ellipsoid(30, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white ellipsoid on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the ellipsoid.\n  \/\/ Set its radiusX to 30.\n  \/\/ Set its radiusY to 40.\n  \/\/ Set its radiusZ to 50.\n  ellipsoid(30, 40, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white ellipsoid on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the ellipsoid.\n  \/\/ Set its radiusX to 30.\n  \/\/ Set its radiusY to 40.\n  \/\/ Set its radiusZ to 50.\n  \/\/ Set its detailX to 4.\n  ellipsoid(30, 40, 50, 4);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white ellipsoid on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the ellipsoid.\n  \/\/ Set its radiusX to 30.\n  \/\/ Set its radiusY to 40.\n  \/\/ Set its radiusZ to 50.\n  \/\/ Set its detailX to 4.\n  \/\/ Set its detailY to 3.\n  ellipsoid(30, 40, 50, 4, 3);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/3d_primitives.js","line":2183,"description":"<p>Draws a torus.<\/p>\n<p>A torus is a 3D shape with triangular faces that connect to form a ring.\nToruses with few faces look flattened. Toruses with many faces have smooth\nsurfaces.<\/p>\n<p>The first parameter, <code>radius<\/code>, is optional. If a <code>Number<\/code> is passed, as in\n<code>torus(30)<\/code>, it sets the radius of the ring. By default, <code>radius<\/code> is 50.<\/p>\n<p>The second parameter, <code>tubeRadius<\/code>, is also optional. If a <code>Number<\/code> is\npassed, as in <code>torus(30, 15)<\/code>, it sets the radius of the tube. By default,\n<code>tubeRadius<\/code> is 10.<\/p>\n<p>The third parameter, <code>detailX<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>torus(30, 15, 5)<\/code>, it sets the number of edges used to draw the hole\nof the torus. Using more edges makes the hole look more like a circle. By\ndefault, <code>detailX<\/code> is 24.<\/p>\n<p>The fourth parameter, <code>detailY<\/code>, is also optional. If a <code>Number<\/code> is passed,\nas in <code>torus(30, 15, 5, 7)<\/code>, it sets the number of triangle subdivisions to\nuse while filling in the torus\u2019 height. By default, <code>detailY<\/code> is 16.<\/p>\n<p>Note: <code>torus()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"torus","params":[{"name":"radius","description":"<p>radius of the torus. Defaults to 50.<\/p>\n","type":"Number","optional":true},{"name":"tubeRadius","description":"<p>radius of the tube. Defaults to 10.<\/p>\n","type":"Number","optional":true},{"name":"detailX","description":"<p>number of edges that form the hole. Defaults to 24.<\/p>\n","type":"Integer","optional":true},{"name":"detailY","description":"<p>number of triangle subdivisions along the y-axis. Defaults to 16.<\/p>\n","type":"Integer","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white torus on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the torus.\n  torus();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white torus on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the torus.\n  \/\/ Set its radius to 30.\n  torus(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white torus on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the torus.\n  \/\/ Set its radius to 30 and tubeRadius to 15.\n  torus(30, 15);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white torus on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the torus.\n  \/\/ Set its radius to 30 and tubeRadius to 15.\n  \/\/ Set its detailX to 5.\n  torus(30, 15, 5);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white torus on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the torus.\n  \/\/ Set its radius to 30 and tubeRadius to 15.\n  \/\/ Set its detailX to 5.\n  \/\/ Set its detailY to 3.\n  torus(30, 15, 5, 3);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/GeometryBuilder.js","line":80,"description":"<p>Adds geometry from the renderer's immediate mode into the builder's\ncombined geometry.<\/p>\n","class":"p5","module":"Shape"},{"file":"src\/webgl\/GeometryBuilder.js","line":114,"description":"<p>Adds geometry from the renderer's retained mode into the builder's\ncombined geometry.<\/p>\n","class":"p5","module":"Shape"},{"file":"src\/webgl\/GeometryBuilder.js","line":122,"description":"<p>Cleans up the state of the renderer and returns the combined geometry that\nwas built.<\/p>\n","return":{"description":"p5.Geometry The flattened, combined geometry"},"class":"p5","module":"Shape"},{"file":"src\/webgl\/GeometryBuilder.js","line":133,"description":"<p>Keeps track of how many custom geometry objects have been made so that each\ncan be assigned a unique ID.<\/p>\n","class":"p5","module":"Shape"},{"file":"src\/webgl\/interaction.js","line":11,"description":"<p>Allows the user to orbit around a 3D sketch using a mouse, trackpad, or\ntouchscreen.<\/p>\n<p>3D sketches are viewed through an imaginary camera. Calling\n<code>orbitControl()<\/code> within the <a href=\"#\/p5\/draw\">draw()<\/a> function allows\nthe user to change the camera\u2019s position:<\/p>\n<pre><code class=\"language-js\">function draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Rest of sketch.\n}\n<\/code><\/pre>\n<p>Left-clicking and dragging or swipe motion will rotate the camera position\nabout the center of the sketch. Right-clicking and dragging or multi-swipe\nwill pan the camera position without rotation. Using the mouse wheel\n(scrolling) or pinch in\/out will move the camera further or closer from the\ncenter of the sketch.<\/p>\n<p>The first three parameters, <code>sensitivityX<\/code>, <code>sensitivityY<\/code>, and\n<code>sensitivityZ<\/code>, are optional. They\u2019re numbers that set the sketch\u2019s\nsensitivity to movement along each axis. For example, calling\n<code>orbitControl(1, 2, -1)<\/code> keeps movement along the x-axis at its default\nvalue, makes the sketch twice as sensitive to movement along the y-axis,\nand reverses motion along the z-axis. By default, all sensitivity values\nare 1.<\/p>\n<p>The fourth parameter, <code>options<\/code>, is also optional. It\u2019s an object that\nchanges the behavior of orbiting. For example, calling\n<code>orbitControl(1, 1, 1, options)<\/code> keeps the default sensitivity values while\nchanging the behaviors set with <code>options<\/code>. The object can have the\nfollowing properties:<\/p>\n<pre><code class=\"language-js\">let options = {\n  \/\/ Setting this to false makes mobile interactions smoother by\n  \/\/ preventing accidental interactions with the page while orbiting.\n  \/\/ By default, it's true.\n  disableTouchActions: true,\n\n  \/\/ Setting this to true makes the camera always rotate in the\n  \/\/ direction the mouse\/touch is moving.\n  \/\/ By default, it's false.\n  freeRotation: false\n};\n\norbitControl(1, 1, 1, options);\n<\/code><\/pre>\n","itemtype":"method","name":"orbitControl","params":[{"name":"sensitivityX","description":"<p>sensitivity to movement along the x-axis. Defaults to 1.<\/p>\n","type":"Number","optional":true},{"name":"sensitivityY","description":"<p>sensitivity to movement along the y-axis. Defaults to 1.<\/p>\n","type":"Number","optional":true},{"name":"sensitivityZ","description":"<p>sensitivity to movement along the z-axis. Defaults to 1.<\/p>\n","type":"Number","optional":true},{"name":"options","description":"<p>object with two optional properties, <code>disableTouchActions<\/code>\n                           and <code>freeRotation<\/code>. Both are <code>Boolean<\/code>s. <code>disableTouchActions<\/code>\n                           defaults to <code>true<\/code> and <code>freeRotation<\/code> defaults to <code>false<\/code>.<\/p>\n","type":"Object","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.\n  box(30, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  \/\/ Make the interactions 3X sensitive.\n  orbitControl(3, 3, 3);\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.\n  box(30, 50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Create an options object.\n  let options = {\n    disableTouchActions: false,\n    freeRotation: true\n  };\n\n  \/\/ Enable orbiting with the mouse.\n  \/\/ Prevent accidental touch actions on touchscreen devices\n  \/\/ and enable free rotation.\n  orbitControl(1, 1, 1, options);\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.\n  box(30, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Interaction"},{"file":"src\/webgl\/interaction.js","line":471,"description":"<p>Adds a grid and an axes icon to clarify orientation in 3D sketches.<\/p>\n<p><code>debugMode()<\/code> adds a grid that shows where the \u201cground\u201d is in a sketch. By\ndefault, the grid will run through the origin <code>(0, 0, 0)<\/code> of the sketch\nalong the XZ plane. <code>debugMode()<\/code> also adds an axes icon that points along\nthe positive x-, y-, and z-axes. Calling <code>debugMode()<\/code> displays the grid\nand axes icon with their default size and position.<\/p>\n<p>There are four ways to call <code>debugMode()<\/code> with optional parameters to\ncustomize the debugging environment.<\/p>\n<p>The first way to call <code>debugMode()<\/code> has one parameter, <code>mode<\/code>. If the\nsystem constant <code>GRID<\/code> is passed, as in <code>debugMode(GRID)<\/code>, then the grid\nwill be displayed and the axes icon will be hidden. If the constant <code>AXES<\/code>\nis passed, as in <code>debugMode(AXES)<\/code>, then the axes icon will be displayed\nand the grid will be hidden.<\/p>\n<p>The second way to call <code>debugMode()<\/code> has six parameters. The first\nparameter, <code>mode<\/code>, selects either <code>GRID<\/code> or <code>AXES<\/code> to be displayed. The\nnext five parameters, <code>gridSize<\/code>, <code>gridDivisions<\/code>, <code>xOff<\/code>, <code>yOff<\/code>, and\n<code>zOff<\/code> are optional. They\u2019re numbers that set the appearance of the grid\n(<code>gridSize<\/code> and <code>gridDivisions<\/code>) and the placement of the axes icon\n(<code>xOff<\/code>, <code>yOff<\/code>, and <code>zOff<\/code>). For example, calling\n<code>debugMode(20, 5, 10, 10, 10)<\/code> sets the <code>gridSize<\/code> to 20 pixels, the number\nof <code>gridDivisions<\/code> to 5, and offsets the axes icon by 10 pixels along the\nx-, y-, and z-axes.<\/p>\n<p>The third way to call <code>debugMode()<\/code> has five parameters. The first\nparameter, <code>mode<\/code>, selects either <code>GRID<\/code> or <code>AXES<\/code> to be displayed. The\nnext four parameters, <code>axesSize<\/code>, <code>xOff<\/code>, <code>yOff<\/code>, and <code>zOff<\/code> are optional.\nThey\u2019re numbers that set the appearance of the size of the axes icon\n(<code>axesSize<\/code>) and its placement (<code>xOff<\/code>, <code>yOff<\/code>, and <code>zOff<\/code>).<\/p>\n<p>The fourth way to call <code>debugMode()<\/code> has nine optional parameters. The\nfirst five parameters, <code>gridSize<\/code>, <code>gridDivisions<\/code>, <code>gridXOff<\/code>, <code>gridYOff<\/code>,\nand <code>gridZOff<\/code> are numbers that set the appearance of the grid. For\nexample, calling <code>debugMode(100, 5, 0, 0, 0)<\/code> sets the <code>gridSize<\/code> to 100,\nthe number of <code>gridDivisions<\/code> to 5, and sets all the offsets to 0 so that\nthe grid is centered at the origin. The next four parameters, <code>axesSize<\/code>,\n<code>xOff<\/code>, <code>yOff<\/code>, and <code>zOff<\/code> are numbers that set the appearance of the size\nof the axes icon (<code>axesSize<\/code>) and its placement (<code>axesXOff<\/code>, <code>axesYOff<\/code>,\nand <code>axesZOff<\/code>). For example, calling\n<code>debugMode(100, 5, 0, 0, 0, 50, 10, 10, 10)<\/code> sets the <code>gridSize<\/code> to 100,\nthe number of <code>gridDivisions<\/code> to 5, and sets all the offsets to 0 so that\nthe grid is centered at the origin. It then sets the <code>axesSize<\/code> to 50 and\noffsets the icon 10 pixels along each axis.<\/p>\n","itemtype":"method","name":"debugMode","example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Enable debug mode.\n  debugMode();\n\n  describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.\n  box(20, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Enable debug mode.\n  \/\/ Only display the axes icon.\n  debugMode(AXES);\n\n  describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.\n  box(20, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Enable debug mode.\n  \/\/ Only display the grid and customize it:\n  \/\/ - size: 50\n  \/\/ - divisions: 10\n  \/\/ - offsets: 0, 20, 0\n  debugMode(GRID, 50, 10, 0, 20, 0);\n\n  describe('A multicolor box on a gray background. A grid is displayed below the box.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.\n  box(20, 40);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Enable debug mode.\n  \/\/ Display the grid and axes icon and customize them:\n  \/\/ Grid\n  \/\/ ----\n  \/\/ - size: 50\n  \/\/ - divisions: 10\n  \/\/ - offsets: 0, 20, 0\n  \/\/ Axes\n  \/\/ ----\n  \/\/ - size: 50\n  \/\/ - offsets: 0, 0, 0\n  debugMode(50, 10, 0, 20, 0, 50, 0, 0, 0);\n\n  describe('A multicolor box on a gray background. A grid is displayed below the box. An axes icon is displayed at the center of the box.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.\n  box(20, 40);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Interaction","overloads":[{"line":471,"params":[]},{"line":650,"params":[{"name":"mode","description":"<p>either GRID or AXES<\/p>\n","type":"Constant"}]},{"line":655,"params":[{"name":"mode","description":"","type":"Constant"},{"name":"gridSize","description":"<p>side length of the grid.<\/p>\n","type":"Number","optional":true},{"name":"gridDivisions","description":"<p>number of divisions in the grid.<\/p>\n","type":"Number","optional":true},{"name":"xOff","description":"<p>offset from origin along the x-axis.<\/p>\n","type":"Number","optional":true},{"name":"yOff","description":"<p>offset from origin along the y-axis.<\/p>\n","type":"Number","optional":true},{"name":"zOff","description":"<p>offset from origin along the z-axis.<\/p>\n","type":"Number","optional":true}]},{"line":665,"params":[{"name":"mode","description":"","type":"Constant"},{"name":"axesSize","description":"<p>length of axes icon markers.<\/p>\n","type":"Number","optional":true},{"name":"xOff","description":"","type":"Number","optional":true},{"name":"yOff","description":"","type":"Number","optional":true},{"name":"zOff","description":"","type":"Number","optional":true}]},{"line":674,"params":[{"name":"gridSize","description":"","type":"Number","optional":true},{"name":"gridDivisions","description":"","type":"Number","optional":true},{"name":"gridXOff","description":"<p>grid offset from the origin along the x-axis.<\/p>\n","type":"Number","optional":true},{"name":"gridYOff","description":"<p>grid offset from the origin along the y-axis.<\/p>\n","type":"Number","optional":true},{"name":"gridZOff","description":"<p>grid offset from the origin along the z-axis.<\/p>\n","type":"Number","optional":true},{"name":"axesSize","description":"","type":"Number","optional":true},{"name":"axesXOff","description":"<p>axes icon offset from the origin along the x-axis.<\/p>\n","type":"Number","optional":true},{"name":"axesYOff","description":"<p>axes icon offset from the origin along the y-axis.<\/p>\n","type":"Number","optional":true},{"name":"axesZOff","description":"<p>axes icon offset from the origin along the z-axis.<\/p>\n","type":"Number","optional":true}]}]},{"file":"src\/webgl\/interaction.js","line":725,"description":"<p>Turns off <a href=\"#\/p5\/debugMode\">debugMode()<\/a> in a 3D sketch.<\/p>\n","itemtype":"method","name":"noDebugMode","example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Enable debug mode.\n  debugMode();\n\n  describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box. They disappear when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the box.\n  normalMaterial();\n\n  \/\/ Draw the box.  box(20, 40);\n}\n\n\/\/ Disable debug mode when the user double-clicks.\nfunction doubleClicked() {\n  noDebugMode();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Interaction"},{"file":"src\/webgl\/light.js","line":10,"description":"<p>Creates a light that shines from all directions.<\/p>\n<p>Ambient light does not come from one direction. Instead, 3D shapes are\nlit evenly from all sides. Ambient lights are almost always used in\ncombination with other types of lights.<\/p>\n<p>There are three ways to call <code>ambientLight()<\/code> with optional parameters to\nset the light\u2019s color.<\/p>\n<p>The first way to call <code>ambientLight()<\/code> has two parameters, <code>gray<\/code> and\n<code>alpha<\/code>. <code>alpha<\/code> is optional. Grayscale and alpha values between 0 and 255\ncan be passed to set the ambient light\u2019s color, as in <code>ambientLight(50)<\/code> or\n<code>ambientLight(50, 30)<\/code>.<\/p>\n<p>The second way to call <code>ambientLight()<\/code> has one parameter, color. A\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color values, or a\nCSS color string, as in <code>ambientLight('magenta')<\/code>, can be passed to set the\nambient light\u2019s color.<\/p>\n<p>The third way to call <code>ambientLight()<\/code> has four parameters, <code>v1<\/code>, <code>v2<\/code>,\n<code>v3<\/code>, and <code>alpha<\/code>. <code>alpha<\/code> is optional. RGBA, HSBA, or HSLA values can be\npassed to set the ambient light\u2019s colors, as in <code>ambientLight(255, 0, 0)<\/code>\nor <code>ambientLight(255, 0, 0, 30)<\/code>. Color values will be interpreted using\nthe current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","itemtype":"method","name":"ambientLight","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click the canvas to turn on the light.\n\nlet isLit = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn against a gray background. The sphere appears to change color when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Control the light.\n  if (isLit === true) {\n    \/\/ Use a grayscale value of 80.\n    ambientLight(80);\n  }\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n\n\/\/ Turn on the ambient light when the user double-clicks.\nfunction doubleClicked() {\n  isLit = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A faded magenta sphere drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  \/\/ Use a p5.Color object.\n  let c = color('orchid');\n  ambientLight(c);\n\n  \/\/ Draw the sphere.\n  sphere();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A faded magenta sphere drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  \/\/ Use a CSS color string.\n  ambientLight('#DA70D6');\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A faded magenta sphere drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  \/\/ Use RGB values\n  ambientLight(218, 112, 214);\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights","overloads":[{"line":10,"params":[{"name":"v1","description":"<p>red or hue value in the current\n                           <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value in the current\n                           <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value in the current\n                           <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"alpha","description":"<p>alpha (transparency) value in the current\n                                <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":164,"params":[{"name":"gray","description":"<p>grayscale value between 0 and 255.<\/p>\n","type":"Number"},{"name":"alpha","description":"","type":"Number","optional":true}],"chainable":1},{"line":171,"params":[{"name":"value","description":"<p>color as a CSS string.<\/p>\n","type":"String"}],"chainable":1},{"line":177,"params":[{"name":"values","description":"<p>color as an array of RGBA, HSBA, or HSLA\n                                values.<\/p>\n","type":"Number[]"}],"chainable":1},{"line":184,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object.<\/p>\n","type":"p5.Color"}],"chainable":1}]},{"file":"src\/webgl\/light.js","line":205,"description":"<p>Sets the specular color for lights.<\/p>\n<p><code>specularColor()<\/code> affects lights that bounce off a surface in a preferred\ndirection. These lights include\n<a href=\"#\/p5\/directionalLight\">directionalLight()<\/a>,\n<a href=\"#\/p5\/pointLight\">pointLight()<\/a>, and\n<a href=\"#\/p5\/spotLight\">spotLight()<\/a>. The function helps to create\nhighlights on <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> objects that are\nstyled with <a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a>. If a\ngeometry does not use\n<a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a>, then\n<code>specularColor()<\/code> will have no effect.<\/p>\n<p>Note: <code>specularColor()<\/code> doesn\u2019t affect lights that bounce in all\ndirections, including <a href=\"#\/p5\/ambientLight\">ambientLight()<\/a> and\n<a href=\"#\/p5\/imageLight\">imageLight()<\/a>.<\/p>\n<p>There are three ways to call <code>specularColor()<\/code> with optional parameters to\nset the specular highlight color.<\/p>\n<p>The first way to call <code>specularColor()<\/code> has two optional parameters, <code>gray<\/code>\nand <code>alpha<\/code>. Grayscale and alpha values between 0 and 255, as in\n<code>specularColor(50)<\/code> or <code>specularColor(50, 80)<\/code>, can be passed to set the\nspecular highlight color.<\/p>\n<p>The second way to call <code>specularColor()<\/code> has one optional parameter,\n<code>color<\/code>. A <a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color\nvalues, or a CSS color string can be passed to set the specular highlight\ncolor.<\/p>\n<p>The third way to call <code>specularColor()<\/code> has four optional parameters, <code>v1<\/code>,\n<code>v2<\/code>, <code>v3<\/code>, and <code>alpha<\/code>. RGBA, HSBA, or HSLA values, as in\n<code>specularColor(255, 0, 0, 80)<\/code>, can be passed to set the specular highlight\ncolor. Color values will be interpreted using the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","itemtype":"method","name":"specularColor","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ No specular color.\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click the canvas to add a point light.\n\nlet isLit = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn on a gray background. A spotlight starts shining when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the sphere.\n  noStroke();\n  specularColor(100);\n  specularMaterial(255, 255, 255);\n\n  \/\/ Control the light.\n  if (isLit === true) {\n    \/\/ Add a white point light from the top-right.\n    pointLight(255, 255, 255, 30, -20, 40);\n  }\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n\n\/\/ Turn on the point light when the user double-clicks.\nfunction doubleClicked() {\n  isLit = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a specular highlight.\n  \/\/ Use a p5.Color object.\n  let c = color('dodgerblue');\n  specularColor(c);\n\n  \/\/ Add a white point light from the top-right.\n  pointLight(255, 255, 255, 30, -20, 40);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Add a white specular material.\n  specularMaterial(255, 255, 255);\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a specular highlight.\n  \/\/ Use a CSS color string.\n  specularColor('#1E90FF');\n\n  \/\/ Add a white point light from the top-right.\n  pointLight(255, 255, 255, 30, -20, 40);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Add a white specular material.\n  specularMaterial(255, 255, 255);\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a specular highlight.\n  \/\/ Use RGB values.\n  specularColor(30, 144, 255);\n\n  \/\/ Add a white point light from the top-right.\n  pointLight(255, 255, 255, 30, -20, 40);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Add a white specular material.\n  specularMaterial(255, 255, 255);\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights","overloads":[{"line":205,"params":[{"name":"v1","description":"<p>red or hue value in the current\n                           <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value in the current\n                           <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value in the current\n                           <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"}],"chainable":1},{"line":423,"params":[{"name":"gray","description":"<p>grayscale value between 0 and 255.<\/p>\n","type":"Number"}],"chainable":1},{"line":429,"params":[{"name":"value","description":"<p>color as a CSS string.<\/p>\n","type":"String"}],"chainable":1},{"line":435,"params":[{"name":"values","description":"<p>color as an array of RGBA, HSBA, or HSLA\n                                values.<\/p>\n","type":"Number[]"}],"chainable":1},{"line":442,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object.<\/p>\n","type":"p5.Color"}],"chainable":1}]},{"file":"src\/webgl\/light.js","line":461,"description":"<p>Creates a light that shines in one direction.<\/p>\n<p>Directional lights don\u2019t shine from a specific point. They\u2019re like a sun\nthat shines from somewhere offscreen. The light\u2019s direction is set using\nthree <code>(x, y, z)<\/code> values between -1 and 1. For example, setting a light\u2019s\ndirection as <code>(1, 0, 0)<\/code> will light <a href=\"#\/p5.Geometry\">p5.Geometry<\/a>\nobjects from the left since the light faces directly to the right. A\nmaximum of 5 directional lights can be active at once.<\/p>\n<p>There are four ways to call <code>directionalLight()<\/code> with parameters to set the\nlight\u2019s color and direction.<\/p>\n<p>The first way to call <code>directionalLight()<\/code> has six parameters. The first\nthree parameters, <code>v1<\/code>, <code>v2<\/code>, and <code>v3<\/code>, set the light\u2019s color using the\ncurrent <a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The last three\nparameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, set the light\u2019s direction. For example,\n<code>directionalLight(255, 0, 0, 1, 0, 0)<\/code> creates a red <code>(255, 0, 0)<\/code> light\nthat shines to the right <code>(1, 0, 0)<\/code>.<\/p>\n<p>The second way to call <code>directionalLight()<\/code> has four parameters. The first\nthree parameters, <code>v1<\/code>, <code>v2<\/code>, and <code>v3<\/code>, set the light\u2019s color using the\ncurrent <a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The last parameter,\n<code>direction<\/code> sets the light\u2019s direction using a\n <a href=\"#\/p5.Vector\">p5.Vector<\/a> object. For example,\n<code>directionalLight(255, 0, 0, lightDir)<\/code> creates a red <code>(255, 0, 0)<\/code> light\nthat shines in the direction the <code>lightDir<\/code> vector points.<\/p>\n<p>The third way to call <code>directionalLight()<\/code> has four parameters. The first\nparameter, <code>color<\/code>, sets the light\u2019s color using a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object or an array of color values. The\nlast three parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, set the light\u2019s direction. For\nexample, <code>directionalLight(myColor, 1, 0, 0)<\/code> creates a light that shines\nto the right <code>(1, 0, 0)<\/code> with the color value of <code>myColor<\/code>.<\/p>\n<p>The fourth way to call <code>directionalLight()<\/code> has two parameters. The first\nparameter, <code>color<\/code>, sets the light\u2019s color using a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object or an array of color values. The\nsecond parameter, <code>direction<\/code>, sets the light\u2019s direction using a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object. For example,\n<code>directionalLight(myColor, lightDir)<\/code> creates a light that shines in the\ndirection the <code>lightDir<\/code> vector points with the color value of <code>myColor<\/code>.<\/p>\n","itemtype":"method","name":"directionalLight","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click to turn on the directional light.\n\nlet isLit = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Control the light.\n  if (isLit === true) {\n    \/\/ Add a red directional light from above.\n    \/\/ Use RGB values and XYZ directions.\n    directionalLight(255, 0, 0, 0, 1, 0);\n  }\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a red directional light from above.\n  \/\/ Use a p5.Color object and XYZ directions.\n  let c = color(255, 0, 0);\n  directionalLight(c, 0, 1, 0);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a red directional light from above.\n  \/\/ Use a p5.Color object and a p5.Vector object.\n  let c = color(255, 0, 0);\n  let lightDir = createVector(0, 1, 0);\n  directionalLight(c, lightDir);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights","overloads":[{"line":461,"params":[{"name":"v1","description":"<p>red or hue value in the current\n                       <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value in the current\n                       <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value in the current\n                       <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"x","description":"<p>x-component of the light's direction between -1 and 1.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-component of the light's direction between -1 and 1.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z-component of the light's direction between -1 and 1.<\/p>\n","type":"Number"}],"chainable":1},{"line":614,"params":[{"name":"v1","description":"","type":"Number"},{"name":"v2","description":"","type":"Number"},{"name":"v3","description":"","type":"Number"},{"name":"direction","description":"<p>direction of the light as a\n                              <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","type":"p5.Vector"}],"chainable":1},{"line":624,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object,\n                                          an array of color values, or as a CSS string.<\/p>\n","type":"p5.Color|Number[]|String"},{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number"}],"chainable":1},{"line":634,"params":[{"name":"color","description":"","type":"p5.Color|Number[]|String"},{"name":"direction","description":"","type":"p5.Vector"}],"chainable":1}]},{"file":"src\/webgl\/light.js","line":683,"description":"<p>Creates a light that shines from a point in all directions.<\/p>\n<p>Point lights are like light bulbs that shine in all directions. They can be\nplaced at different positions to achieve different lighting effects. A\nmaximum of 5 point lights can be active at once.<\/p>\n<p>There are four ways to call <code>pointLight()<\/code> with parameters to set the\nlight\u2019s color and position.<\/p>\n<p>The first way to call <code>pointLight()<\/code> has six parameters. The first three\nparameters, <code>v1<\/code>, <code>v2<\/code>, and <code>v3<\/code>, set the light\u2019s color using the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The last three parameters, <code>x<\/code>,\n<code>y<\/code>, and <code>z<\/code>, set the light\u2019s position. For example,\n<code>pointLight(255, 0, 0, 50, 0, 0)<\/code> creates a red <code>(255, 0, 0)<\/code> light that\nshines from the coordinates <code>(50, 0, 0)<\/code>.<\/p>\n<p>The second way to call <code>pointLight()<\/code> has four parameters. The first three\nparameters, <code>v1<\/code>, <code>v2<\/code>, and <code>v3<\/code>, set the light\u2019s color using the current\n<a href=\"#\/p5\/colorMode\">colorMode()<\/a>. The last parameter, position sets\nthe light\u2019s position using a <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.\nFor example, <code>pointLight(255, 0, 0, lightPos)<\/code> creates a red <code>(255, 0, 0)<\/code>\nlight that shines from the position set by the <code>lightPos<\/code> vector.<\/p>\n<p>The third way to call <code>pointLight()<\/code> has four parameters. The first\nparameter, <code>color<\/code>, sets the light\u2019s color using a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object or an array of color values. The\nlast three parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, set the light\u2019s position. For\nexample, <code>directionalLight(myColor, 50, 0, 0)<\/code> creates a light that shines\nfrom the coordinates <code>(50, 0, 0)<\/code> with the color value of <code>myColor<\/code>.<\/p>\n<p>The fourth way to call <code>pointLight()<\/code> has two parameters. The first\nparameter, <code>color<\/code>, sets the light\u2019s color using a\n<a href=\"#\/p5.Color\">p5.Color<\/a> object or an array of color values. The\nsecond parameter, <code>position<\/code>, sets the light\u2019s position using a\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object. For example,\n<code>directionalLight(myColor, lightPos)<\/code> creates a light that shines from the\nposition set by the <code>lightPos<\/code> vector with the color value of <code>myColor<\/code>.<\/p>\n","itemtype":"method","name":"pointLight","chainable":1,"example":["\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click to turn on the point light.\n\nlet isLit = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Control the light.\n  if (isLit === true) {\n    \/\/ Add a red point light from above.\n    \/\/ Use RGB values and XYZ coordinates.\n    pointLight(255, 0, 0, 0, -150, 0);\n  }\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n\n\/\/ Turn on the point light when the user double-clicks.\nfunction doubleClicked() {\n  isLit = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a red point light from above.\n  \/\/ Use a p5.Color object and XYZ directions.\n  let c = color(255, 0, 0);\n  pointLight(c, 0, -150, 0);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a red point light from above.\n  \/\/ Use a p5.Color object and a p5.Vector object.\n  let c = color(255, 0, 0);\n  let lightPos = createVector(0, -150, 0);\n  pointLight(c, lightPos);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('Four spheres arranged in a square and drawn on a gray background. The spheres appear bright red toward the center of the square. The color gets darker toward the corners of the square.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a red point light that points to the center of the scene.\n  \/\/ Use a p5.Color object and a p5.Vector object.\n  let c = color(255, 0, 0);\n  let lightPos = createVector(0, 0, 65);\n  pointLight(c, lightPos);\n\n  \/\/ Style the spheres.\n  noStroke();\n\n  \/\/ Draw a sphere up and to the left.\n  push();\n  translate(-25, -25, 25);\n  sphere(10);\n  pop();\n\n  \/\/ Draw a box up and to the right.\n  push();\n  translate(25, -25, 25);\n  sphere(10);\n  pop();\n\n  \/\/ Draw a sphere down and to the left.\n  push();\n  translate(-25, 25, 25);\n  sphere(10);\n  pop();\n\n  \/\/ Draw a box down and to the right.\n  push();\n  translate(25, 25, 25);\n  sphere(10);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights","overloads":[{"line":683,"params":[{"name":"v1","description":"<p>red or hue value in the current\n                       <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value in the current\n                       <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value in the current\n                       <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"x","description":"<p>x-coordinate of the light.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the light.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z-coordinate of the light.<\/p>\n","type":"Number"}],"chainable":1},{"line":890,"params":[{"name":"v1","description":"","type":"Number"},{"name":"v2","description":"","type":"Number"},{"name":"v3","description":"","type":"Number"},{"name":"position","description":"<p>position of the light as a\n                              <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","type":"p5.Vector"}],"chainable":1},{"line":900,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object,\n                                         an array of color values, or a CSS string.<\/p>\n","type":"p5.Color|Number[]|String"},{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number"}],"chainable":1},{"line":910,"params":[{"name":"color","description":"","type":"p5.Color|Number[]|String"},{"name":"position","description":"","type":"p5.Vector"}],"chainable":1}]},{"file":"src\/webgl\/light.js","line":956,"description":"<p>Creates an ambient light from an image.<\/p>\n<p><code>imageLight()<\/code> simulates a light shining from all directions. The effect is\nlike placing the sketch at the center of a giant sphere that uses the image\nas its texture. The image's diffuse light will be affected by\n<a href=\"#\/p5\/fill\">fill()<\/a> and the specular reflections will be\naffected by <a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a> and\n<a href=\"#\/p5\/shininess\">shininess()<\/a>.<\/p>\n<p>The parameter, <code>img<\/code>, is the <a href=\"#\/p5.Image\">p5.Image<\/a> object to\nuse as the light source.<\/p>\n","itemtype":"method","name":"imageLight","params":[{"name":"img","description":"<p>image to use as the light source.<\/p>\n","type":"p5.image"}],"example":["\n<div class=\"notest\">\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet img;\n\n\/\/ Load an image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/outdoor_spheremap.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape.');\n}\n\nfunction draw() {\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the image as a panorama (360\u02da background).\n  panorama(img);\n\n  \/\/ Add a soft ambient light.\n  ambientLight(50);\n\n  \/\/ Add light from the image.\n  imageLight(img);\n\n  \/\/ Style the sphere.\n  specularMaterial(20);\n  shininess(100);\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights"},{"file":"src\/webgl\/light.js","line":1021,"description":"<p>Creates an immersive 3D background.<\/p>\n<p><code>panorama()<\/code> transforms images containing 360\u02da content, such as maps or\nHDRIs, into immersive 3D backgrounds that surround a sketch. Exploring the\nspace requires changing the camera's perspective with functions such as\n<a href=\"#\/p5\/orbitControl\">orbitControl()<\/a> or\n<a href=\"#\/p5\/camera\">camera()<\/a>.<\/p>\n","itemtype":"method","name":"panorama","params":[{"name":"img","description":"<p>360\u02da image to use as the background.<\/p>\n","type":"p5.Image"}],"example":["\n<div class=\"notest\">\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet img;\n\n\/\/ Load an image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/outdoor_spheremap.jpg');\n}\n\nfunction setup() {\n  createCanvas(100 ,100 ,WEBGL);\n\n  describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape. The full landscape is viewable in 3D as the user drags the mouse.');\n}\n\nfunction draw() {\n  \/\/ Add the panorama.\n  panorama(img);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Use the image as a light source.\n  imageLight(img);\n\n  \/\/ Style the sphere.\n  noStroke();\n  specularMaterial(50);\n  shininess(200);\n  metalness(100);\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights"},{"file":"src\/webgl\/light.js","line":1077,"description":"<p>Places an ambient and directional light in the scene.\nThe lights are set to ambientLight(128, 128, 128) and\ndirectionalLight(128, 128, 128, 0, 0, -1).<\/p>\n<p>Note: lights need to be called (whether directly or indirectly)\nwithin draw() to remain persistent in a looping program.\nPlacing them in setup() will cause them to only have an effect\nthe first time through the loop.<\/p>\n","itemtype":"method","name":"lights","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click to turn on the lights.\n\nlet isLit = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white box drawn against a gray background. The quality of the light changes when the user double-clicks.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Control the lights.\n  if (isLit === true) {\n    lights();\n  }\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ Turn on the lights when the user double-clicks.\nfunction doubleClicked() {\n  isLit = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white box drawn against a gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  ambientLight(128, 128, 128);\n  directionalLight(128, 128, 128, 0, 0, -1);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights"},{"file":"src\/webgl\/light.js","line":1161,"description":"<p>Sets the falloff rate for <a href=\"#\/p5\/pointLight\">pointLight()<\/a>\nand <a href=\"#\/p5\/spotLight\">spotLight()<\/a>.<\/p>\n<p>A light\u2019s falloff describes the intensity of its beam at a distance. For\nexample, a lantern has a slow falloff, a flashlight has a medium falloff,\nand a laser pointer has a sharp falloff.<\/p>\n<p><code>lightFalloff()<\/code> has three parameters, <code>constant<\/code>, <code>linear<\/code>, and\n<code>quadratic<\/code>. They\u2019re numbers used to calculate falloff at a distance, <code>d<\/code>,\nas follows:<\/p>\n<p><code>falloff = 1 \/ (constant + d * linear + (d * d) * quadratic)<\/code><\/p>\n<p>Note: <code>constant<\/code>, <code>linear<\/code>, and <code>quadratic<\/code> should always be set to values\ngreater than 0.<\/p>\n","itemtype":"method","name":"lightFalloff","params":[{"name":"constant","description":"<p>constant value for calculating falloff.<\/p>\n","type":"Number"},{"name":"linear","description":"<p>linear value for calculating falloff.<\/p>\n","type":"Number"},{"name":"quadratic","description":"<p>quadratic value for calculating falloff.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click to change the falloff rate.\n\nlet useFalloff = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A sphere drawn against a gray background. The intensity of the light changes when the user double-clicks.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Set the light falloff.\n  if (useFalloff === true) {\n    lightFalloff(2, 0, 0);\n  }\n\n  \/\/ Add a white point light from the front.\n  pointLight(255, 255, 255, 0, 0, 100);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n\n\/\/ Change the falloff value when the user double-clicks.\nfunction doubleClicked() {\n  useFalloff = true;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights"},{"file":"src\/webgl\/light.js","line":1272,"description":"<p>Creates a light that shines from a point in one direction.<\/p>\n<p>Spot lights are like flashlights that shine in one direction creating a\ncone of light. The shape of the cone can be controlled using the angle and\nconcentration parameters. A maximum of 5 spot lights can be active at once.<\/p>\n<p>There are eight ways to call <code>spotLight()<\/code> with parameters to set the\nlight\u2019s color, position, direction. For example,\n<code>spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0)<\/code> creates a red <code>(255, 0, 0)<\/code> light\nat the origin <code>(0, 0, 0)<\/code> that points to the right <code>(1, 0, 0)<\/code>.<\/p>\n<p>The <code>angle<\/code> parameter is optional. It sets the radius of the light cone.\nFor example, <code>spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI \/ 16)<\/code> creates a\nred <code>(255, 0, 0)<\/code> light at the origin <code>(0, 0, 0)<\/code> that points to the right\n<code>(1, 0, 0)<\/code> with an angle of <code>PI \/ 16<\/code> radians. By default, <code>angle<\/code> is\n<code>PI \/ 3<\/code> radians.<\/p>\n<p>The <code>concentration<\/code> parameter is also optional. It focuses the light\ntowards the center of the light cone. For example,\n<code>spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI \/ 16, 50)<\/code> creates a red\n<code>(255, 0, 0)<\/code> light at the origin <code>(0, 0, 0)<\/code> that points to the right\n<code>(1, 0, 0)<\/code> with an angle of <code>PI \/ 16<\/code> radians at concentration of 50. By\ndefault, <code>concentration<\/code> is 100.<\/p>\n","itemtype":"method","name":"spotLight","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click to adjust the spotlight.\n\nlet isLit = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Control the spotlight.\n  if (isLit === true) {\n    \/\/ Add a red spot light that shines into the screen.\n    \/\/ Set its angle to PI \/ 32 radians.\n    spotLight(255, 0, 0, 0, 0, 100, 0, 0, -1, PI \/ 32);\n  }\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n\n\/\/ Turn on the spotlight when the user double-clicks.\nfunction doubleClicked() {\n  isLit = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click to adjust the spotlight.\n\nlet isLit = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Control the spotlight.\n  if (isLit === true) {\n    \/\/ Add a red spot light that shines into the screen.\n    \/\/ Set its angle to PI \/ 3 radians (default).\n    \/\/ Set its concentration to 1000.\n    let c = color(255, 0, 0);\n    let position = createVector(0, 0, 100);\n    let direction = createVector(0, 0, -1);\n    spotLight(c, position, direction, PI \/ 3, 1000);\n  }\n\n  \/\/ Draw the sphere.\n  sphere(30);\n}\n\n\/\/ Turn on the spotlight when the user double-clicks.\nfunction doubleClicked() {\n  isLit = true;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights","overloads":[{"line":1272,"params":[{"name":"v1","description":"<p>red or hue value in the current\n                                     <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value in the current\n                                     <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value in the current\n                                     <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"x","description":"<p>x-coordinate of the light.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the light.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z-coordinate of the light.<\/p>\n","type":"Number"},{"name":"rx","description":"<p>x-component of light direction between -1 and 1.<\/p>\n","type":"Number"},{"name":"ry","description":"<p>y-component of light direction between -1 and 1.<\/p>\n","type":"Number"},{"name":"rz","description":"<p>z-component of light direction between -1 and 1.<\/p>\n","type":"Number"},{"name":"angle","description":"<p>angle of the light cone. Defaults to <code>PI \/ 3<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"concentration","description":"<p>concentration of the light. Defaults to 100.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":1399,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object,\n                                             an array of color values, or a CSS string.<\/p>\n","type":"p5.Color|Number[]|String"},{"name":"position","description":"<p>position of the light as a <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","type":"p5.Vector"},{"name":"direction","description":"<p>direction of light as a <a href=\"#\/p5.Vector\">p5.Vector<\/a> object.<\/p>\n","type":"p5.Vector"},{"name":"angle","description":"","type":"Number","optional":true},{"name":"concentration","description":"","type":"Number","optional":true}]},{"line":1408,"params":[{"name":"v1","description":"","type":"Number"},{"name":"v2","description":"","type":"Number"},{"name":"v3","description":"","type":"Number"},{"name":"position","description":"","type":"p5.Vector"},{"name":"direction","description":"","type":"p5.Vector"},{"name":"angle","description":"","type":"Number","optional":true},{"name":"concentration","description":"","type":"Number","optional":true}]},{"line":1418,"params":[{"name":"color","description":"","type":"p5.Color|Number[]|String"},{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number"},{"name":"direction","description":"","type":"p5.Vector"},{"name":"angle","description":"","type":"Number","optional":true},{"name":"concentration","description":"","type":"Number","optional":true}]},{"line":1428,"params":[{"name":"color","description":"","type":"p5.Color|Number[]|String"},{"name":"position","description":"","type":"p5.Vector"},{"name":"rx","description":"","type":"Number"},{"name":"ry","description":"","type":"Number"},{"name":"rz","description":"","type":"Number"},{"name":"angle","description":"","type":"Number","optional":true},{"name":"concentration","description":"","type":"Number","optional":true}]},{"line":1438,"params":[{"name":"v1","description":"","type":"Number"},{"name":"v2","description":"","type":"Number"},{"name":"v3","description":"","type":"Number"},{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number"},{"name":"direction","description":"","type":"p5.Vector"},{"name":"angle","description":"","type":"Number","optional":true},{"name":"concentration","description":"","type":"Number","optional":true}]},{"line":1450,"params":[{"name":"v1","description":"","type":"Number"},{"name":"v2","description":"","type":"Number"},{"name":"v3","description":"","type":"Number"},{"name":"position","description":"","type":"p5.Vector"},{"name":"rx","description":"","type":"Number"},{"name":"ry","description":"","type":"Number"},{"name":"rz","description":"","type":"Number"},{"name":"angle","description":"","type":"Number","optional":true},{"name":"concentration","description":"","type":"Number","optional":true}]},{"line":1462,"params":[{"name":"color","description":"","type":"p5.Color|Number[]|String"},{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"},{"name":"z","description":"","type":"Number"},{"name":"rx","description":"","type":"Number"},{"name":"ry","description":"","type":"Number"},{"name":"rz","description":"","type":"Number"},{"name":"angle","description":"","type":"Number","optional":true},{"name":"concentration","description":"","type":"Number","optional":true}]}]},{"file":"src\/webgl\/light.js","line":1687,"description":"<p>Removes all lights from the sketch.<\/p>\n<p>Calling <code>noLights()<\/code> removes any lights created with\n<a href=\"#\/p5\/lights\">lights()<\/a>,\n<a href=\"#\/p5\/ambientLight\">ambientLight()<\/a>,\n<a href=\"#\/p5\/directionalLight\">directionalLight()<\/a>,\n<a href=\"#\/p5\/pointLight\">pointLight()<\/a>, or\n<a href=\"#\/p5\/spotLight\">spotLight()<\/a>. These functions may be called\nafter <code>noLights()<\/code> to create a new lighting scheme.<\/p>\n","itemtype":"method","name":"noLights","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('Two spheres drawn against a gray background. The top sphere is white and the bottom sphere is red.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the spheres.\n  noStroke();\n\n  \/\/ Draw the top sphere.\n  push();\n  translate(0, -25, 0);\n  sphere(20);\n  pop();\n\n  \/\/ Turn off the lights.\n  noLights();\n\n  \/\/ Add a red directional light that points into the screen.\n  directionalLight(255, 0, 0, 0, 0, -1);\n\n  \/\/ Draw the bottom sphere.\n  push();\n  translate(0, 25, 0);\n  sphere(20);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Lights"},{"file":"src\/webgl\/loading.js","line":13,"description":"<p>Loads a 3D model to create a\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object.<\/p>\n<p><code>loadModel()<\/code> can load 3D models from OBJ and STL files. Once the model is\nloaded, it can be displayed with the\n<a href=\"#\/p5\/model\">model()<\/a> function, as in <code>model(shape)<\/code>.<\/p>\n<p>There are three ways to call <code>loadModel()<\/code> with optional parameters to help\nprocess the model.<\/p>\n<p>The first parameter, <code>path<\/code>, is always a <code>String<\/code> with the path to the\nfile. Paths to local files should be relative, as in\n<code>loadModel('assets\/model.obj')<\/code>. URLs such as\n<code>'https:\/\/example.com\/model.obj'<\/code> may be blocked due to browser security.<\/p>\n<p>Note: When loading a <code>.obj<\/code> file that references materials stored in\n<code>.mtl<\/code> files, p5.js will attempt to load and apply those materials.\nTo ensure that the <code>.obj<\/code> file reads the <code>.mtl<\/code> file correctly include the\n<code>.mtl<\/code> file alongside it.<\/p>\n<p>The first way to call <code>loadModel()<\/code> has three optional parameters after the\nfile path. The first optional parameter, <code>successCallback<\/code>, is a function\nto call once the model loads. For example,\n<code>loadModel('assets\/model.obj', handleModel)<\/code> will call the <code>handleModel()<\/code>\nfunction once the model loads. The second optional parameter,\n<code>failureCallback<\/code>, is a function to call if the model fails to load. For\nexample, <code>loadModel('assets\/model.obj', handleModel, handleFailure)<\/code> will\ncall the <code>handleFailure()<\/code> function if an error occurs while loading. The\nthird optional parameter, <code>fileType<\/code>, is the model\u2019s file extension as a\nstring. For example,\n<code>loadModel('assets\/model', handleModel, handleFailure, '.obj')<\/code> will try to\nload the file model as a <code>.obj<\/code> file.<\/p>\n<p>The second way to call <code>loadModel()<\/code> has four optional parameters after the\nfile path. The first optional parameter is a <code>Boolean<\/code> value. If <code>true<\/code> is\npassed, as in <code>loadModel('assets\/model.obj', true)<\/code>, then the model will be\nresized to ensure it fits the canvas. The next three parameters are\n<code>successCallback<\/code>, <code>failureCallback<\/code>, and <code>fileType<\/code> as described above.<\/p>\n<p>The third way to call <code>loadModel()<\/code> has one optional parameter after the\nfile path. The optional parameter, <code>options<\/code>, is an <code>Object<\/code> with options,\nas in <code>loadModel('assets\/model.obj', options)<\/code>. The <code>options<\/code> object can\nhave the following properties:<\/p>\n<pre><code class=\"language-js\">let options = {\n  \/\/ Enables standardized size scaling during loading if set to true.\n  normalize: true,\n\n  \/\/ Function to call once the model loads.\n  successCallback: handleModel,\n\n  \/\/ Function to call if an error occurs while loading.\n  failureCallback: handleError,\n\n  \/\/ Model's file extension.\n  fileType: '.stl',\n\n  \/\/ Flips the U texture coordinates of the model.\n  flipU: false,\n\n  \/\/ Flips the V texture coordinates of the model.\n  flipV: false\n};\n\n\/\/ Pass the options object to loadModel().\nloadModel('assets\/model.obj', options);\n<\/code><\/pre>\n<p>Models can take time to load. Calling <code>loadModel()<\/code> in\n<a href=\"#\/p5\/preload\">preload()<\/a> ensures models load before they're\nused in <a href=\"#\/p5\/setup\">setup()<\/a> or <a href=\"#\/p5\/draw\">draw()<\/a>.<\/p>\n<p>Note: There\u2019s no support for colored STL files. STL files with color will\nbe rendered without color.<\/p>\n","itemtype":"method","name":"loadModel","return":{"description":"the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object","type":"p5.Geometry"},"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\n\/\/ Load the file and create a p5.Geometry object.\nfunction preload() {\n  shape = loadModel('assets\/teapot.obj');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white teapot drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the shape.\n  model(shape);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\n\/\/ Load the file and create a p5.Geometry object.\n\/\/ Normalize the geometry's size to fit the canvas.\nfunction preload() {\n  shape = loadModel('assets\/teapot.obj', true);\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white teapot drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the shape.\n  model(shape);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\n\/\/ Load the file and create a p5.Geometry object.\nfunction preload() {\n  loadModel('assets\/teapot.obj', true, handleModel);\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white teapot drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the shape.\n  model(shape);\n}\n\n\/\/ Set the shape variable and log the geometry's\n\/\/ ID to the console.\nfunction handleModel(data) {\n  shape = data;\n  console.log(shape.gid);\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\n\/\/ Load the file and create a p5.Geometry object.\nfunction preload() {\n  loadModel('assets\/wrong.obj', true, handleModel, handleError);\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white teapot drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the shape.\n  model(shape);\n}\n\n\/\/ Set the shape variable and print the geometry's\n\/\/ ID to the console.\nfunction handleModel(data) {\n  shape = data;\n  console.log(shape.gid);\n}\n\n\/\/ Print an error message if the file doesn't load.\nfunction handleError(error) {\n  console.error('Oops!', error);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\n\/\/ Load the file and create a p5.Geometry object.\nfunction preload() {\n  loadModel('assets\/teapot.obj', true, handleModel, handleError, '.obj');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white teapot drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the shape.\n  model(shape);\n}\n\n\/\/ Set the shape variable and print the geometry's\n\/\/ ID to the console.\nfunction handleModel(data) {\n  shape = data;\n  console.log(shape.gid);\n}\n\n\/\/ Print an error message if the file doesn't load.\nfunction handleError(error) {\n  console.error('Oops!', error);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\nlet options = {\n  normalize: true,\n  successCallback: handleModel,\n  failureCallback: handleError,\n  fileType: '.obj'\n};\n\n\/\/ Load the file and create a p5.Geometry object.\nfunction preload() {\n  loadModel('assets\/teapot.obj', options);\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white teapot drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the shape.\n  model(shape);\n}\n\n\/\/ Set the shape variable and print the geometry's\n\/\/ ID to the console.\nfunction handleModel(data) {\n  shape = data;\n  console.log(shape.gid);\n}\n\n\/\/ Print an error message if the file doesn't load.\nfunction handleError(error) {\n  console.error('Oops!', error);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Models","overloads":[{"line":13,"params":[{"name":"path","description":"<p>path of the model to be loaded.<\/p>\n","type":"String"},{"name":"normalize","description":"<p>if <code>true<\/code>, scale the model to fit the canvas.<\/p>\n","type":"Boolean"},{"name":"successCallback","description":"<p>function to call once the model is loaded. Will be passed\n                                                  the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object.<\/p>\n","type":"function(p5.Geometry)","optional":true},{"name":"failureCallback","description":"<p>function to call if the model fails to load. Will be passed an <code>Error<\/code> event object.<\/p>\n","type":"Function(Event)","optional":true},{"name":"fileType","description":"<p>model\u2019s file extension. Either <code>'.obj'<\/code> or <code>'.stl'<\/code>.<\/p>\n","type":"String","optional":true}],"return":{"description":"the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object","type":"p5.Geometry"}},{"line":324,"params":[{"name":"path","description":"","type":"String"},{"name":"successCallback","description":"","type":"function(p5.Geometry)","optional":true},{"name":"failureCallback","description":"","type":"Function(Event)","optional":true},{"name":"fileType","description":"","type":"String","optional":true}],"return":{"description":"new <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object.","type":"p5.Geometry"}},{"line":332,"params":[{"name":"path","description":"","type":"String"},{"name":"options","description":"<p>loading options.<\/p>\n","type":"Object","optional":true,"props":[{"name":"successCallback","description":"","type":"function(p5.Geometry)","optional":true},{"name":"failureCallback","description":"","type":"Function(Event)","optional":true},{"name":"fileType","description":"","type":"String","optional":true},{"name":"normalize","description":"","type":"Boolean","optional":true},{"name":"flipU","description":"","type":"Boolean","optional":true},{"name":"flipV","description":"","type":"Boolean","optional":true}]}],"return":{"description":"new <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object.","type":"p5.Geometry"}}]},{"file":"src\/webgl\/loading.js","line":551,"description":"<p>Parse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:<\/p>\n<p>v -0.5 -0.5 0.5\nv -0.5 -0.5 -0.5\nv -0.5 0.5 -0.5\nv -0.5 0.5 0.5<\/p>\n<p>f 4 3 2 1<\/p>\n","class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src\/webgl\/loading.js","line":693,"description":"<p>STL files can be of two types, ASCII and Binary,<\/p>\n<p>We need to convert the arrayBuffer to an array of strings,\nto parse it as an ASCII file.<\/p>\n","class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src\/webgl\/loading.js","line":720,"description":"<p>This function checks if the file is in ASCII format or in Binary format<\/p>\n<p>It is done by searching keyword <code>solid<\/code> at the start of the file.<\/p>\n<p>An ASCII STL data must begin with <code>solid<\/code> as the first six bytes.\nHowever, ASCII STLs lacking the SPACE after the <code>d<\/code> are known to be\nplentiful. So, check the first 5 bytes for <code>solid<\/code>.<\/p>\n<p>Several encodings, such as UTF-8, precede the text with up to 5 bytes:\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Byte_order_mark#Byte_order_marks_by_encoding\">https:\/\/en.wikipedia.org\/wiki\/Byte_order_mark#Byte_order_marks_by_encoding<\/a>\nSearch for <code>solid<\/code> to start anywhere after those prefixes.<\/p>\n","class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src\/webgl\/loading.js","line":747,"description":"<p>This function matches the <code>query<\/code> at the provided <code>offset<\/code><\/p>\n","class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src\/webgl\/loading.js","line":759,"description":"<p>This function parses the Binary STL files.\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/STL_%28file_format%29#Binary_STL\">https:\/\/en.wikipedia.org\/wiki\/STL_%28file_format%29#Binary_STL<\/a><\/p>\n<p>Currently there is no support for the colors provided in STL files.<\/p>\n","class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src\/webgl\/loading.js","line":847,"description":"<p>ASCII STL file starts with <code>solid 'nameOfFile'<\/code>\nThen contain the normal of the face, starting with <code>facet normal<\/code>\nNext contain a keyword indicating the start of face vertex, <code>outer loop<\/code>\nNext comes the three vertex, starting with <code>vertex x y z<\/code>\nVertices ends with <code>endloop<\/code>\nFace ends with <code>endfacet<\/code>\nNext face starts with <code>facet normal<\/code>\nThe end of the file is indicated by <code>endsolid<\/code><\/p>\n","class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src\/webgl\/loading.js","line":991,"description":"<p>Draws a <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object to the canvas.<\/p>\n<p>The parameter, <code>model<\/code>, is the\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object to draw.\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> objects can be built with\n<a href=\"#\/p5\/buildGeometry\">buildGeometry()<\/a>, or\n<a href=\"#\/p5\/beginGeometry\">beginGeometry()<\/a> and\n<a href=\"#\/p5\/endGeometry\">endGeometry()<\/a>. They can also be loaded from\na file with <a href=\"#\/p5\/loadGeometry\">loadGeometry()<\/a>.<\/p>\n<p>Note: <code>model()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"model","params":[{"name":"model","description":"<p>3D shape to be drawn.<\/p>\n","type":"p5.Geometry"}],"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Geometry object.\n  shape = buildGeometry(createShape);\n\n  describe('A white cone drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n}\n\n\/\/ Create p5.Geometry object from a single cone.\nfunction createShape() {\n  cone();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the p5.Geometry object.\n  shape = buildGeometry(createArrow);\n\n  describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the arrows.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object.\n  model(shape);\n\n  \/\/ Translate and rotate the coordinate system.\n  translate(30, 0, 0);\n  rotateZ(frameCount * 0.01);\n\n  \/\/ Draw the p5.Geometry object again.\n  model(shape);\n}\n\nfunction createArrow() {\n  \/\/ Add shapes to the p5.Geometry object.\n  push();\n  rotateX(PI);\n  cone(10);\n  translate(0, -10, 0);\n  cylinder(3, 20);\n  pop();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet shape;\n\n\/\/ Load the file and create a p5.Geometry object.\nfunction preload() {\n  shape = loadModel('assets\/octahedron.obj');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white octahedron drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the shape.\n  model(shape);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Models"},{"file":"src\/webgl\/loading.js","line":1132,"description":"<p>Load a 3d model from an OBJ or STL string.<\/p>\n<p>OBJ and STL files lack a built-in sense of scale, causing models exported from different programs to vary in size.\nIf your model doesn't display correctly, consider using <code>loadModel()<\/code> with <code>normalize<\/code> set to <code>true<\/code> to standardize its size.\nFurther adjustments can be made using the <code>scale()<\/code> function.<\/p>\n<p>Also, the support for colored STL files is not present. STL files with color will be\nrendered without color properties.<\/p>\n<ul>\n<li>Options can include:<\/li>\n<\/ul>\n<ul>\n<li><code>modelString<\/code>: Specifies the plain text string of either an stl or obj file to be loaded.<\/li>\n<li><code>fileType<\/code>: Defines the file extension of the model.<\/li>\n<li><code>normalize<\/code>: Enables standardized size scaling during loading if set to true.<\/li>\n<li><code>successCallback<\/code>: Callback for post-loading actions with the 3D model object.<\/li>\n<li><code>failureCallback<\/code>: Handles errors if model loading fails, receiving an event error.<\/li>\n<li><code>flipU<\/code>: Flips the U texture coordinates of the model.<\/li>\n<li><code>flipV<\/code>: Flips the V texture coordinates of the model.<\/li>\n<\/ul>\n","itemtype":"method","name":"createModel","return":{"description":"the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object","type":"p5.Geometry"},"example":["\n<div>\n<code>\nconst octahedron_model = `\nv 0.000000E+00 0.000000E+00 40.0000\nv 22.5000 22.5000 0.000000E+00\nv 22.5000 -22.5000 0.000000E+00\nv -22.5000 -22.5000 0.000000E+00\nv -22.5000 22.5000 0.000000E+00\nv 0.000000E+00 0.000000E+00 -40.0000\nf     1 2 3\nf     1 3 4\nf     1 4 5\nf     1 5 2\nf     6 5 4\nf     6 4 3\nf     6 3 2\nf     6 2 5\n`;\n\/\/draw a spinning octahedron\nlet octahedron;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n  octahedron = createModel(octahedron_model, '.obj');\n  describe('Vertically rotating 3D octahedron.');\n}\n\nfunction draw() {\n  background(200);\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  model(octahedron);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"Shape","submodule":"3D Models","overloads":[{"line":1132,"params":[{"name":"modelString","description":"<p>String of the object to be loaded<\/p>\n","type":"String"},{"name":"fileType","description":"<p>The file extension of the model\n                                     (<code>.stl<\/code>, <code>.obj<\/code>).<\/p>\n","type":"String","optional":true},{"name":"normalize","description":"<p>If true, scale the model to a\n                                     standardized size when loading<\/p>\n","type":"Boolean"},{"name":"successCallback","description":"<p>Function to be called\n                                    once the model is loaded. Will be passed\n                                    the 3D model object.<\/p>\n","type":"function(p5.Geometry)","optional":true},{"name":"failureCallback","description":"<p>called with event error if\n                                        the model fails to load.<\/p>\n","type":"Function(Event)","optional":true}],"return":{"description":"the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object","type":"p5.Geometry"}},{"line":1202,"params":[{"name":"modelString","description":"","type":"String"},{"name":"fileType","description":"","type":"String","optional":true},{"name":"successCallback","description":"","type":"function(p5.Geometry)","optional":true},{"name":"failureCallback","description":"","type":"Function(Event)","optional":true}],"return":{"description":"the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object","type":"p5.Geometry"}},{"line":1210,"params":[{"name":"modelString","description":"","type":"String"},{"name":"fileType","description":"","type":"String","optional":true},{"name":"options","description":"","type":"Object","optional":true,"props":[{"name":"successCallback","description":"","type":"function(p5.Geometry)","optional":true},{"name":"failureCallback","description":"","type":"Function(Event)","optional":true},{"name":"normalize","description":"","type":"Boolean","optional":true},{"name":"flipU","description":"","type":"Boolean","optional":true},{"name":"flipV","description":"","type":"Boolean","optional":true}]}],"return":{"description":"the <a href=\"#\/p5.Geometry\">p5.Geometry<\/a> object","type":"p5.Geometry"}}]},{"file":"src\/webgl\/material.js","line":12,"description":"<p>Loads vertex and fragment shaders to create a\n<a href=\"#\/p5.Shader\">p5.Shader<\/a> object.<\/p>\n<p>Shaders are programs that run on the graphics processing unit (GPU). They\ncan process many pixels at the same time, making them fast for many\ngraphics tasks. They\u2019re written in a language called\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Games\/Techniques\/3D_on_the_web\/GLSL_Shaders\" target=\"_blank\">GLSL<\/a>\nand run along with the rest of the code in a sketch.<\/p>\n<p>Once the <a href=\"#\/p5.Shader\">p5.Shader<\/a> object is created, it can be\nused with the <a href=\"#\/p5\/shader\">shader()<\/a> function, as in\n<code>shader(myShader)<\/code>. A shader program consists of two files, a vertex shader\nand a fragment shader. The vertex shader affects where 3D geometry is drawn\non the screen and the fragment shader affects color.<\/p>\n<p><code>loadShader()<\/code> loads the vertex and fragment shaders from their <code>.vert<\/code> and\n<code>.frag<\/code> files. For example, calling\n<code>loadShader('assets\/shader.vert', 'assets\/shader.frag')<\/code> loads both\nrequired shaders and returns a <a href=\"#\/p5.Shader\">p5.Shader<\/a> object.<\/p>\n<p>The third parameter, <code>successCallback<\/code>, is optional. If a function is\npassed, it will be called once the shader has loaded. The callback function\ncan use the new <a href=\"#\/p5.Shader\">p5.Shader<\/a> object as its\nparameter.<\/p>\n<p>The fourth parameter, <code>failureCallback<\/code>, is also optional. If a function is\npassed, it will be called if the shader fails to load. The callback\nfunction can use the event error as its parameter.<\/p>\n<p>Shaders can take time to load. Calling <code>loadShader()<\/code> in\n<a href=\"#\/p5\/preload\">preload()<\/a> ensures shaders load before they're\nused in <a href=\"#\/p5\/setup\">setup()<\/a> or <a href=\"#\/p5\/draw\">draw()<\/a>.<\/p>\n<p>Note: Shaders can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"loadShader","params":[{"name":"vertFilename","description":"<p>path of the vertex shader to be loaded.<\/p>\n","type":"String"},{"name":"fragFilename","description":"<p>path of the fragment shader to be loaded.<\/p>\n","type":"String"},{"name":"successCallback","description":"<p>function to call once the shader is loaded. Can be passed the\n                                    <a href=\"#\/p5.Shader\">p5.Shader<\/a> object.<\/p>\n","type":"Function","optional":true},{"name":"failureCallback","description":"<p>function to call if the shader fails to load. Can be passed an\n                                    <code>Error<\/code> event object.<\/p>\n","type":"Function","optional":true}],"return":{"description":"new shader created from the vertex and fragment shader files.","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\nlet mandelbrot;\n\n\/\/ Load the shader and create a p5.Shader object.\nfunction preload() {\n  mandelbrot = loadShader('assets\/shader.vert', 'assets\/shader.frag');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Compile and apply the p5.Shader object.\n  shader(mandelbrot);\n\n  \/\/ Set the shader uniform p to an array.\n  mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]);\n\n  \/\/ Set the shader uniform r to the value 1.5.\n  mandelbrot.setUniform('r', 1.5);\n\n  \/\/ Add a quad as a display surface for the shader.\n  quad(-1, -1, 1, -1, 1, 1, -1, 1);\n\n  describe('A black fractal image on a magenta background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\nlet mandelbrot;\n\n\/\/ Load the shader and create a p5.Shader object.\nfunction preload() {\n  mandelbrot = loadShader('assets\/shader.vert', 'assets\/shader.frag');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Use the p5.Shader object.\n  shader(mandelbrot);\n\n  \/\/ Set the shader uniform p to an array.\n  mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]);\n\n  describe('A fractal image zooms in and out of focus.');\n}\n\nfunction draw() {\n  \/\/ Set the shader uniform r to a value that oscillates between 0 and 2.\n  mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1);\n\n  \/\/ Add a quad as a display surface for the shader.\n  quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":173,"description":"<p>Creates a new <a href=\"#\/p5.Shader\">p5.Shader<\/a> object.<\/p>\n<p>Shaders are programs that run on the graphics processing unit (GPU). They\ncan process many pixels at the same time, making them fast for many\ngraphics tasks. They\u2019re written in a language called\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Games\/Techniques\/3D_on_the_web\/GLSL_Shaders\" target=\"_blank\">GLSL<\/a>\nand run along with the rest of the code in a sketch.<\/p>\n<p>Once the <a href=\"#\/p5.Shader\">p5.Shader<\/a> object is created, it can be\nused with the <a href=\"#\/p5\/shader\">shader()<\/a> function, as in\n<code>shader(myShader)<\/code>. A shader program consists of two parts, a vertex shader\nand a fragment shader. The vertex shader affects where 3D geometry is drawn\non the screen and the fragment shader affects color.<\/p>\n<p>The first parameter, <code>vertSrc<\/code>, sets the vertex shader. It\u2019s a string that\ncontains the vertex shader program written in GLSL.<\/p>\n<p>The second parameter, <code>fragSrc<\/code>, sets the fragment shader. It\u2019s a string\nthat contains the fragment shader program written in GLSL.<\/p>\n<p>A shader can optionally describe <em>hooks,<\/em> which are functions in GLSL that\nusers may choose to provide to customize the behavior of the shader using the\n<a href=\"#\/p5.Shader\/modify\"><code>modify()<\/code><\/a> method of <code>p5.Shader<\/code>. These are added by\ndescribing the hooks in a third parameter, <code>options<\/code>, and referencing the hooks in\nyour <code>vertSrc<\/code> or <code>fragSrc<\/code>. Hooks for the vertex or fragment shader are described under\nthe <code>vertex<\/code> and <code>fragment<\/code> keys of <code>options<\/code>. Each one is an object. where each key is\nthe type and name of a hook function, and each value is a string with the\nparameter list and default implementation of the hook. For example, to let users\noptionally run code at the start of the vertex shader, the options object could\ninclude:<\/p>\n<pre><code class=\"language-js\">{\n  vertex: {\n    'void beforeVertex': '() {}'\n  }\n}\n<\/code><\/pre>\n<p>Then, in your vertex shader source, you can run a hook by calling a function\nwith the same name prefixed by <code>HOOK_<\/code>. If you want to check if the default\nhook has been replaced, maybe to avoid extra overhead, you can check if the\nsame name prefixed by <code>AUGMENTED_HOOK_<\/code> has been defined:<\/p>\n<pre><code class=\"language-glsl\">void main() {\n  \/\/ In most cases, just calling the hook is fine:\n  HOOK_beforeVertex();\n\n  \/\/ Alternatively, for more efficiency:\n  #ifdef AUGMENTED_HOOK_beforeVertex\n  HOOK_beforeVertex();\n  #endif\n\n  \/\/ Add the rest of your shader code here!\n}\n<\/code><\/pre>\n<p>Note: Only filter shaders can be used in 2D mode. All shaders can be used\nin WebGL mode.<\/p>\n","itemtype":"method","name":"createShader","params":[{"name":"vertSrc","description":"<p>source code for the vertex shader.<\/p>\n","type":"String"},{"name":"fragSrc","description":"<p>source code for the fragment shader.<\/p>\n","type":"String"},{"name":"options","description":"<p>An optional object describing how this shader can\nbe augmented with hooks. It can include:<\/p>\n<ul>\n<li><code>vertex<\/code>: An object describing the available vertex shader hooks.<\/li>\n<li><code>fragment<\/code>: An object describing the available frament shader hooks.<\/li>\n<\/ul>\n","type":"Object","optional":true}],"return":{"description":"new shader object created from the\nvertex and fragment shaders.","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision highp float;\n\nvoid main() {\n  \/\/ Set each pixel's RGBA value to yellow.\n  gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);\n}\n`;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  let shaderProgram = createShader(vertSrc, fragSrc);\n\n  \/\/ Compile and apply the p5.Shader object.\n  shader(shaderProgram);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a plane as a drawing surface.\n  plane(100, 100);\n\n  describe('A yellow square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision highp float;\nuniform vec2 p;\nuniform float r;\nconst int numIterations = 500;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vec2 c = p + gl_FragCoord.xy * r;\n  vec2 z = c;\n  float n = 0.0;\n\n  for (int i = numIterations; i > 0; i--) {\n    if (z.x * z.x + z.y * z.y > 4.0) {\n      n = float(i) \/ float(numIterations);\n      break;\n    }\n    z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;\n  }\n\n  gl_FragColor = vec4(\n    0.5 - cos(n * 17.0) \/ 2.0,\n    0.5 - cos(n * 13.0) \/ 2.0,\n    0.5 - cos(n * 23.0) \/ 2.0,\n    1.0\n  );\n}\n`;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  let mandelbrot = createShader(vertSrc, fragSrc);\n\n  \/\/ Compile and apply the p5.Shader object.\n  shader(mandelbrot);\n\n  \/\/ Set the shader uniform p to an array.\n  \/\/ p is the center point of the Mandelbrot image.\n  mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]);\n\n  \/\/ Set the shader uniform r to 0.005.\n  \/\/ r is the size of the image in Mandelbrot-space.\n  mandelbrot.setUniform('r', 0.005);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a plane as a drawing surface.\n  plane(100, 100);\n\n  describe('A black fractal image on a magenta background.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision highp float;\nuniform vec2 p;\nuniform float r;\nconst int numIterations = 500;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vec2 c = p + gl_FragCoord.xy * r;\n  vec2 z = c;\n  float n = 0.0;\n\n  for (int i = numIterations; i > 0; i--) {\n    if (z.x * z.x + z.y * z.y > 4.0) {\n      n = float(i) \/ float(numIterations);\n      break;\n    }\n\n    z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;\n  }\n\n  gl_FragColor = vec4(\n    0.5 - cos(n * 17.0) \/ 2.0,\n    0.5 - cos(n * 13.0) \/ 2.0,\n    0.5 - cos(n * 23.0) \/ 2.0,\n    1.0\n  );\n}\n`;\n\nlet mandelbrot;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  mandelbrot = createShader(vertSrc, fragSrc);\n\n  \/\/ Apply the p5.Shader object.\n  shader(mandelbrot);\n\n  \/\/ Set the shader uniform p to an array.\n  \/\/ p is the center point of the Mandelbrot image.\n  mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]);\n\n  describe('A fractal image zooms in and out of focus.');\n}\n\nfunction draw() {\n  \/\/ Set the shader uniform r to a value that oscillates\n  \/\/ between 0 and 0.005.\n  \/\/ r is the size of the image in Mandelbrot-space.\n  let radius = 0.005 * (sin(frameCount * 0.01) + 1);\n  mandelbrot.setUniform('r', radius);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a plane as a drawing surface.\n  plane(100, 100);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ A shader with hooks.\nlet myShader;\n\n\/\/ A shader with modified hooks.\nlet modifiedShader;\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\n\nvoid main() {\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a fragment shader that uses a hook.\nlet fragSrc = `\nprecision highp float;\nvoid main() {\n  \/\/ Let users override the color\n  gl_FragColor = HOOK_getColor(vec4(1., 0., 0., 1.));\n}\n`;\n\nfunction setup() {\n  createCanvas(50, 50, WEBGL);\n\n  \/\/ Create a shader with hooks\n  myShader = createShader(vertSrc, fragSrc, {\n    fragment: {\n      'vec4 getColor': '(vec4 color) { return color; }'\n    }\n  });\n\n  \/\/ Make a version of the shader with a hook overridden\n  modifiedShader = myShader.modify({\n    'vec4 getColor': `(vec4 color) {\n      return vec4(0., 0., 1., 1.);\n    }`\n  });\n}\n\nfunction draw() {\n  noStroke();\n\n  push();\n  shader(myShader);\n  translate(-width\/3, 0);\n  sphere(10);\n  pop();\n\n  push();\n  shader(modifiedShader);\n  translate(width\/3, 0);\n  sphere(10);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":540,"description":"<p>Creates a <a href=\"#\/p5.Shader\">p5.Shader<\/a> object to be used with the\n<a href=\"#\/p5\/filter\">filter()<\/a> function.<\/p>\n<p><code>createFilterShader()<\/code> works like\n<a href=\"#\/p5\/createShader\">createShader()<\/a> but has a default vertex\nshader included. <code>createFilterShader()<\/code> is intended to be used along with\n<a href=\"#\/p5\/filter\">filter()<\/a> for filtering the contents of a canvas.\nA filter shader will be applied to the whole canvas instead of just\n<a href=\"#\/p5.Geometry\">p5.Geometry<\/a> objects.<\/p>\n<p>The parameter, <code>fragSrc<\/code>, sets the fragment shader. It\u2019s a string that\ncontains the fragment shader program written in\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Games\/Techniques\/3D_on_the_web\/GLSL_Shaders\" target=\"_blank\">GLSL<\/a>.<\/p>\n<p>The <a href=\"#\/p5.Shader\">p5.Shader<\/a> object that's created has some\nuniforms that can be set:<\/p>\n<ul>\n<li><code>sampler2D tex0<\/code>, which contains the canvas contents as a texture.<\/li>\n<li><code>vec2 canvasSize<\/code>, which is the width and height of the canvas, not including pixel density.<\/li>\n<li><code>vec2 texelSize<\/code>, which is the size of a physical pixel including pixel density. This is calculated as <code>1.0 \/ (width * density)<\/code> for the pixel width and <code>1.0 \/ (height * density)<\/code> for the pixel height.<\/li>\n<\/ul>\n<p>The <a href=\"#\/p5.Shader\">p5.Shader<\/a> that's created also provides\n<code>varying vec2 vTexCoord<\/code>, a coordinate with values between 0 and 1.\n<code>vTexCoord<\/code> describes where on the canvas the pixel will be drawn.<\/p>\n<p>For more info about filters and shaders, see Adam Ferriss' <a href=\"https:\/\/github.com\/aferriss\/p5jsShaderExamples\">repo of shader examples<\/a>\nor the <a href=\"https:\/\/p5js.org\/tutorials\/intro-to-shaders\/\">Introduction to Shaders<\/a> tutorial.<\/p>\n","itemtype":"method","name":"createFilterShader","params":[{"name":"fragSrc","description":"<p>source code for the fragment shader.<\/p>\n","type":"String"}],"return":{"description":"new shader object created from the fragment shader.","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\nfunction setup() {\n  let fragSrc = `precision highp float;\n  void main() {\n    gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);\n  }`;\n\n  createCanvas(100, 100, WEBGL);\n  let s = createFilterShader(fragSrc);\n  filter(s);\n  describe('a yellow canvas');\n}\n<\/code>\n<\/div>\n\n<div modernizr='webgl'>\n<code>\nlet img, s;\nfunction preload() {\n  img = loadImage('assets\/bricks.jpg');\n}\nfunction setup() {\n  let fragSrc = `precision highp float;\n\n  \/\/ x,y coordinates, given from the vertex shader\n  varying vec2 vTexCoord;\n\n  \/\/ the canvas contents, given from filter()\n  uniform sampler2D tex0;\n  \/\/ other useful information from the canvas\n  uniform vec2 texelSize;\n  uniform vec2 canvasSize;\n  \/\/ a custom variable from this sketch\n  uniform float darkness;\n\n  void main() {\n    \/\/ get the color at current pixel\n    vec4 color = texture2D(tex0, vTexCoord);\n    \/\/ set the output color\n    color.b = 1.0;\n    color *= darkness;\n    gl_FragColor = vec4(color.rgb, 1.0);\n  }`;\n\n  createCanvas(100, 100, WEBGL);\n  s = createFilterShader(fragSrc);\n}\nfunction draw() {\n  image(img, -50, -50);\n  s.setUniform('darkness', 0.5);\n  filter(s);\n  describe('a image of bricks tinted dark blue');\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":682,"description":"<p>Sets the <a href=\"#\/p5.Shader\">p5.Shader<\/a> object to apply while drawing.<\/p>\n<p>Shaders are programs that run on the graphics processing unit (GPU). They\ncan process many pixels or vertices at the same time, making them fast for\nmany graphics tasks. They\u2019re written in a language called\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Games\/Techniques\/3D_on_the_web\/GLSL_Shaders\" target=\"_blank\">GLSL<\/a>\nand run along with the rest of the code in a sketch.\n<a href=\"#\/p5.Shader\">p5.Shader<\/a> objects can be created using the\n<a href=\"#\/p5\/createShader\">createShader()<\/a> and\n<a href=\"#\/p5\/loadShader\">loadShader()<\/a> functions.<\/p>\n<p>The parameter, <code>s<\/code>, is the <a href=\"#\/p5.Shader\">p5.Shader<\/a> object to\napply. For example, calling <code>shader(myShader)<\/code> applies <code>myShader<\/code> to\nprocess each pixel on the canvas. The shader will be used for:<\/p>\n<ul>\n<li>Fills when a texture is enabled if it includes a uniform <code>sampler2D<\/code>.<\/li>\n<li>Fills when lights are enabled if it includes the attribute <code>aNormal<\/code>, or if it has any of the following uniforms: <code>uUseLighting<\/code>, <code>uAmbientLightCount<\/code>, <code>uDirectionalLightCount<\/code>, <code>uPointLightCount<\/code>, <code>uAmbientColor<\/code>, <code>uDirectionalDiffuseColors<\/code>, <code>uDirectionalSpecularColors<\/code>, <code>uPointLightLocation<\/code>, <code>uPointLightDiffuseColors<\/code>, <code>uPointLightSpecularColors<\/code>, <code>uLightingDirection<\/code>, or <code>uSpecular<\/code>.<\/li>\n<li>Fills whenever there are no lights or textures.<\/li>\n<li>Strokes if it includes the uniform <code>uStrokeWeight<\/code>.<\/li>\n<\/ul>\n<p>The source code from a <a href=\"#\/p5.Shader\">p5.Shader<\/a> object's\nfragment and vertex shaders will be compiled the first time it's passed to\n<code>shader()<\/code>. See\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/WebGLRenderingContext\/compileShader\" target=\"_blank\">MDN<\/a>\nfor more information about compiling shaders.<\/p>\n<p>Calling <a href=\"#\/p5\/resetShader\">resetShader()<\/a> restores a sketch\u2019s\ndefault shaders.<\/p>\n<p>Note: Shaders can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"shader","chainable":1,"params":[{"name":"s","description":"<p><a href=\"#\/p5.Shader\">p5.Shader<\/a> object\n                     to apply.<\/p>\n","type":"p5.Shader"}],"example":["\n<div modernizr='webgl'>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision highp float;\n\nvoid main() {\n  \/\/ Set each pixel's RGBA value to yellow.\n  gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);\n}\n`;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  let shaderProgram = createShader(vertSrc, fragSrc);\n\n  \/\/ Apply the p5.Shader object.\n  shader(shaderProgram);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a plane as a drawing surface.\n  plane(100, 100);\n\n  describe('A yellow square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\nlet mandelbrot;\n\n\/\/ Load the shader and create a p5.Shader object.\nfunction preload() {\n  mandelbrot = loadShader('assets\/shader.vert', 'assets\/shader.frag');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Use the p5.Shader object.\n  shader(mandelbrot);\n\n  \/\/ Set the shader uniform p to an array.\n  mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]);\n\n  describe('A fractal image zooms in and out of focus.');\n}\n\nfunction draw() {\n  \/\/ Set the shader uniform r to a value that oscillates between 0 and 2.\n  mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1);\n\n  \/\/ Add a quad as a display surface for the shader.\n  quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\nlet redGreen;\nlet orangeBlue;\nlet showRedGreen = false;\n\n\/\/ Load the shader and create two separate p5.Shader objects.\nfunction preload() {\n  redGreen = loadShader('assets\/shader.vert', 'assets\/shader-gradient.frag');\n  orangeBlue = loadShader('assets\/shader.vert', 'assets\/shader-gradient.frag');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Initialize the redGreen shader.\n  shader(redGreen);\n\n  \/\/ Set the redGreen shader's center and background color.\n  redGreen.setUniform('colorCenter', [1.0, 0.0, 0.0]);\n  redGreen.setUniform('colorBackground', [0.0, 1.0, 0.0]);\n\n  \/\/ Initialize the orangeBlue shader.\n  shader(orangeBlue);\n\n  \/\/ Set the orangeBlue shader's center and background color.\n  orangeBlue.setUniform('colorCenter', [1.0, 0.5, 0.0]);\n  orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]);\n\n  describe(\n    'The scene toggles between two circular gradients when the user double-clicks. An orange and blue gradient vertically, and red and green gradient moves horizontally.'\n  );\n}\n\nfunction draw() {\n  \/\/ Update the offset values for each shader.\n  \/\/ Move orangeBlue vertically.\n  \/\/ Move redGreen horizontally.\n  orangeBlue.setUniform('offset', [0, sin(frameCount * 0.01) + 1]);\n  redGreen.setUniform('offset', [sin(frameCount * 0.01), 1]);\n\n  if (showRedGreen === true) {\n    shader(redGreen);\n  } else {\n    shader(orangeBlue);\n  }\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a quad as a drawing surface.\n  quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n\n\/\/ Toggle between shaders when the user double-clicks.\nfunction doubleClicked() {\n  showRedGreen = !showRedGreen;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":886,"description":"<p>Get the default shader used with lights, materials,\nand textures.<\/p>\n<p>You can call <a href=\"#\/p5.Shader\/modify\"><code>baseMaterialShader().modify()<\/code><\/a>\nand change any of the following hooks:<\/p>\n<table>\n<tr><th>Hook<\/th><th>Description<\/th><\/tr>\n<tr><td>\n\n<p><code>void beforeVertex<\/code><\/p>\n<\/td><td>\n\n<p>Called at the start of the vertex shader.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec3 getLocalPosition<\/code><\/p>\n<\/td><td>\n\n<p>Update the position of vertices before transforms are applied. It takes in <code>vec3 position<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec3 getWorldPosition<\/code><\/p>\n<\/td><td>\n\n<p>Update the position of vertices after transforms are applied. It takes in <code>vec3 position<\/code> and pust return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec3 getLocalNormal<\/code><\/p>\n<\/td><td>\n\n<p>Update the normal before transforms are applied. It takes in <code>vec3 normal<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec3 getWorldNormal<\/code><\/p>\n<\/td><td>\n\n<p>Update the normal after transforms are applied. It takes in <code>vec3 normal<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec2 getUV<\/code><\/p>\n<\/td><td>\n\n<p>Update the texture coordinates. It takes in <code>vec2 uv<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec4 getVertexColor<\/code><\/p>\n<\/td><td>\n\n<p>Update the color of each vertex. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>void afterVertex<\/code><\/p>\n<\/td><td>\n\n<p>Called at the end of the vertex shader.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>void beforeFragment<\/code><\/p>\n<\/td><td>\n\n<p>Called at the start of the fragment shader.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>Inputs getPixelInputs<\/code><\/p>\n<\/td><td>\n\n<p>Update the per-pixel inputs of the material. It takes in an <code>Inputs<\/code> struct, which includes:<\/p>\n<ul>\n<li><code>vec3 normal<\/code>, the direction pointing out of the surface<\/li>\n<li><code>vec2 texCoord<\/code>, a vector where <code>x<\/code> and <code>y<\/code> are between 0 and 1 describing the spot on a texture the pixel is mapped to, as a fraction of the texture size<\/li>\n<li><code>vec3 ambientLight<\/code>, the ambient light color on the vertex<\/li>\n<li><code>vec4 color<\/code>, the base material color of the pixel<\/li>\n<li><code>vec3 ambientMaterial<\/code>, the color of the pixel when affected by ambient light<\/li>\n<li><code>vec3 specularMaterial<\/code>, the color of the pixel when reflecting specular highlights<\/li>\n<li><code>vec3 emissiveMaterial<\/code>, the light color emitted by the pixel<\/li>\n<li><code>float shininess<\/code>, a number representing how sharp specular reflections should be, from 1 to infinity<\/li>\n<li><code>float metalness<\/code>, a number representing how mirrorlike the material should be, between 0 and 1\nThe struct can be modified and returned.<\/td><\/tr>\n<tr><td><\/li>\n<\/ul>\n<p><code>vec4 combineColors<\/code><\/p>\n<\/td><td>\n\n<p>Take in a <code>ColorComponents<\/code> struct containing all the different components of light, and combining them into\na single final color. The struct contains:<\/p>\n<ul>\n<li><code>vec3 baseColor<\/code>, the base color of the pixel<\/li>\n<li><code>float opacity<\/code>, the opacity between 0 and 1 that it should be drawn at<\/li>\n<li><code>vec3 ambientColor<\/code>, the color of the pixel when affected by ambient light<\/li>\n<li><code>vec3 specularColor<\/code>, the color of the pixel when affected by specular reflections<\/li>\n<li><code>vec3 diffuse<\/code>, the amount of diffused light hitting the pixel<\/li>\n<li><code>vec3 ambient<\/code>, the amount of ambient light hitting the pixel<\/li>\n<li><code>vec3 specular<\/code>, the amount of specular reflection hitting the pixel<\/li>\n<li><code>vec3 emissive<\/code>, the amount of light emitted by the pixel<\/li>\n<\/ul>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec4 getFinalColor<\/code><\/p>\n<\/td><td>\n\n<p>Update the final color after mixing. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>void afterFragment<\/code><\/p>\n<\/td><td>\n\n<p>Called at the end of the fragment shader.<\/p>\n<\/td><\/tr>\n<\/table>\n\n<p>Most of the time, you will need to write your hooks in GLSL ES version 300. If you\nare using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.<\/p>\n<p>Call <code>baseMaterialShader().inspectHooks()<\/code> to see all the possible hooks and\ntheir default implementations.<\/p>\n","itemtype":"method","name":"baseMaterialShader","beta":1,"return":{"description":"The material shader","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseMaterialShader().modify({\n    uniforms: {\n      'float time': () => millis()\n    },\n    'vec3 getWorldPosition': `(vec3 pos) {\n      pos.y += 20.0 * sin(time * 0.001 + pos.x * 0.05);\n      return pos;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  lights();\n  noStroke();\n  fill('red');\n  sphere(50);\n}\n<\/code>\n<\/div>","\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseMaterialShader().modify({\n    declarations: 'vec3 myNormal;',\n    'Inputs getPixelInputs': `(Inputs inputs) {\n      myNormal = inputs.normal;\n      return inputs;\n    }`,\n    'vec4 getFinalColor': `(vec4 color) {\n      return mix(\n        vec4(1.0, 1.0, 1.0, 1.0),\n        color,\n        abs(dot(myNormal, vec3(0.0, 0.0, 1.0)))\n      );\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  rotateY(millis() * 0.001);\n  shader(myShader);\n  lights();\n  noStroke();\n  fill('red');\n  torus(30);\n}\n<\/code>\n<\/div>","\n<div modernizr='webgl'>\n<code>\nlet myShader;\nlet environment;\n\nfunction preload() {\n  environment = loadImage('assets\/outdoor_spheremap.jpg');\n}\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseMaterialShader().modify({\n    'Inputs getPixelInputs': `(Inputs inputs) {\n      float factor =\n        sin(\n          inputs.texCoord.x * ${TWO_PI} +\n          inputs.texCoord.y * ${TWO_PI}\n        ) * 0.4 + 0.5;\n      inputs.shininess = mix(1., 100., factor);\n      inputs.metalness = factor;\n      return inputs;\n    }`\n  });\n}\n\nfunction draw() {\n  panorama(environment);\n  ambientLight(100);\n  imageLight(environment);\n  rotateY(millis() * 0.001);\n  shader(myShader);\n  noStroke();\n  fill(255);\n  specularMaterial(150);\n  sphere(50);\n}\n<\/code>\n<\/div>","\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseMaterialShader().modify({\n    'Inputs getPixelInputs': `(Inputs inputs) {\n      vec3 newNormal = inputs.normal;\n      \/\/ Simple bump mapping: adjust the normal based on position\n      newNormal.x += 0.2 * sin(\n          sin(\n            inputs.texCoord.y * ${TWO_PI} * 10.0 +\n            inputs.texCoord.x * ${TWO_PI} * 25.0\n          )\n        );\n      newNormal.y += 0.2 * sin(\n        sin(\n            inputs.texCoord.x * ${TWO_PI} * 10.0 +\n            inputs.texCoord.y * ${TWO_PI} * 25.0\n          )\n      );\n      inputs.normal = normalize(newNormal);\n      return inputs;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  ambientLight(150);\n  pointLight(\n    255, 255, 255,\n    100*cos(frameCount*0.04), -50, 100*sin(frameCount*0.04)\n  );\n  noStroke();\n  fill('red');\n  shininess(200);\n  specularMaterial(255);\n  sphere(50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":1197,"description":"<p>Get the shader used by <a href=\"#\/p5\/normalMaterial\"><code>normalMaterial()<\/code><\/a>.<\/p>\n<p>You can call <a href=\"#\/p5.Shader\/modify\"><code>baseNormalShader().modify()<\/code><\/a>\nand change any of the following hooks:<\/p>\n<table>\n<thead>\n<tr>\n<th>Hook<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody><tr>\n<td><code>void beforeVertex<\/code><\/td>\n<td>Called at the start of the vertex shader.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getLocalPosition<\/code><\/td>\n<td>Update the position of vertices before transforms are applied. It takes in <code>vec3 position<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getWorldPosition<\/code><\/td>\n<td>Update the position of vertices after transforms are applied. It takes in <code>vec3 position<\/code> and pust return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getLocalNormal<\/code><\/td>\n<td>Update the normal before transforms are applied. It takes in <code>vec3 normal<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getWorldNormal<\/code><\/td>\n<td>Update the normal after transforms are applied. It takes in <code>vec3 normal<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec2 getUV<\/code><\/td>\n<td>Update the texture coordinates. It takes in <code>vec2 uv<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec4 getVertexColor<\/code><\/td>\n<td>Update the color of each vertex. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>void afterVertex<\/code><\/td>\n<td>Called at the end of the vertex shader.<\/td>\n<\/tr>\n<tr>\n<td><code>void beforeFragment<\/code><\/td>\n<td>Called at the start of the fragment shader.<\/td>\n<\/tr>\n<tr>\n<td><code>vec4 getFinalColor<\/code><\/td>\n<td>Update the final color after mixing. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>void afterFragment<\/code><\/td>\n<td>Called at the end of the fragment shader.<\/td>\n<\/tr>\n<\/tbody><\/table>\n<p>Most of the time, you will need to write your hooks in GLSL ES version 300. If you\nare using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.<\/p>\n<p>Call <code>baseNormalShader().inspectHooks()<\/code> to see all the possible hooks and\ntheir default implementations.<\/p>\n","itemtype":"method","name":"baseNormalShader","beta":1,"return":{"description":"The `normalMaterial` shader","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseNormalShader().modify({\n    uniforms: {\n      'float time': () => millis()\n    },\n    'vec3 getWorldPosition': `(vec3 pos) {\n      pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);\n      return pos;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  noStroke();\n  sphere(50);\n}\n<\/code>\n<\/div>","\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseNormalShader().modify({\n    'vec3 getWorldNormal': '(vec3 normal) { return abs(normal); }',\n    'vec4 getFinalColor': `(vec4 color) {\n      \/\/ Map the r, g, and b values of the old normal to new colors\n      \/\/ instead of just red, green, and blue:\n      vec3 newColor =\n        color.r * vec3(89.0, 240.0, 232.0) \/ 255.0 +\n        color.g * vec3(240.0, 237.0, 89.0) \/ 255.0 +\n        color.b * vec3(205.0, 55.0, 222.0) \/ 255.0;\n      newColor = newColor \/ (color.r + color.g + color.b);\n      return vec4(newColor, 1.0) * color.a;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  noStroke();\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.015);\n  box(100);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":1292,"description":"<p>Get the shader used when no lights or materials are applied.<\/p>\n<p>You can call <a href=\"#\/p5.Shader\/modify\"><code>baseColorShader().modify()<\/code><\/a>\nand change any of the following hooks:<\/p>\n<table>\n<thead>\n<tr>\n<th>Hook<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody><tr>\n<td><code>void beforeVertex<\/code><\/td>\n<td>Called at the start of the vertex shader.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getLocalPosition<\/code><\/td>\n<td>Update the position of vertices before transforms are applied. It takes in <code>vec3 position<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getWorldPosition<\/code><\/td>\n<td>Update the position of vertices after transforms are applied. It takes in <code>vec3 position<\/code> and pust return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getLocalNormal<\/code><\/td>\n<td>Update the normal before transforms are applied. It takes in <code>vec3 normal<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec3 getWorldNormal<\/code><\/td>\n<td>Update the normal after transforms are applied. It takes in <code>vec3 normal<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec2 getUV<\/code><\/td>\n<td>Update the texture coordinates. It takes in <code>vec2 uv<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>vec4 getVertexColor<\/code><\/td>\n<td>Update the color of each vertex. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>void afterVertex<\/code><\/td>\n<td>Called at the end of the vertex shader.<\/td>\n<\/tr>\n<tr>\n<td><code>void beforeFragment<\/code><\/td>\n<td>Called at the start of the fragment shader.<\/td>\n<\/tr>\n<tr>\n<td><code>vec4 getFinalColor<\/code><\/td>\n<td>Update the final color after mixing. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/td>\n<\/tr>\n<tr>\n<td><code>void afterFragment<\/code><\/td>\n<td>Called at the end of the fragment shader.<\/td>\n<\/tr>\n<\/tbody><\/table>\n<p>Most of the time, you will need to write your hooks in GLSL ES version 300. If you\nare using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.<\/p>\n<p>Call <code>baseColorShader().inspectHooks()<\/code> to see all the possible hooks and\ntheir default implementations.<\/p>\n","itemtype":"method","name":"baseColorShader","beta":1,"return":{"description":"The color shader","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseColorShader().modify({\n    uniforms: {\n      'float time': () => millis()\n    },\n    'vec3 getWorldPosition': `(vec3 pos) {\n      pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);\n      return pos;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  noStroke();\n  fill('red');\n  circle(0, 0, 50);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":1355,"description":"<p>Get the shader used when drawing the strokes of shapes.<\/p>\n<p>You can call <a href=\"#\/p5.Shader\/modify\"><code>baseStrokeShader().modify()<\/code><\/a>\nand change any of the following hooks:<\/p>\n<table>\n<tr><th>Hook<\/th><th>Description<\/th><\/tr>\n<tr><td>\n\n<p><code>void beforeVertex<\/code><\/p>\n<\/td><td>\n\n<p>Called at the start of the vertex shader.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec3 getLocalPosition<\/code><\/p>\n<\/td><td>\n\n<p>Update the position of vertices before transforms are applied. It takes in <code>vec3 position<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec3 getWorldPosition<\/code><\/p>\n<\/td><td>\n\n<p>Update the position of vertices after transforms are applied. It takes in <code>vec3 position<\/code> and pust return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>float getStrokeWeight<\/code><\/p>\n<\/td><td>\n\n<p>Update the stroke weight. It takes in <code>float weight<\/code> and pust return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec2 getLineCenter<\/code><\/p>\n<\/td><td>\n\n<p>Update the center of the line. It takes in <code>vec2 center<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec2 getLinePosition<\/code><\/p>\n<\/td><td>\n\n<p>Update the position of each vertex on the edge of the line. It takes in <code>vec2 position<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec4 getVertexColor<\/code><\/p>\n<\/td><td>\n\n<p>Update the color of each vertex. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>void afterVertex<\/code><\/p>\n<\/td><td>\n\n<p>Called at the end of the vertex shader.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>void beforeFragment<\/code><\/p>\n<\/td><td>\n\n<p>Called at the start of the fragment shader.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>Inputs getPixelInputs<\/code><\/p>\n<\/td><td>\n\n<p>Update the inputs to the shader. It takes in a struct <code>Inputs inputs<\/code>, which includes:<\/p>\n<ul>\n<li><code>vec4 color<\/code>, the color of the stroke<\/li>\n<li><code>vec2 tangent<\/code>, the direction of the stroke in screen space<\/li>\n<li><code>vec2 center<\/code>, the coordinate of the center of the stroke in screen space p5.js pixels<\/li>\n<li><code>vec2 position<\/code>, the coordinate of the current pixel in screen space p5.js pixels<\/li>\n<li><code>float strokeWeight<\/code>, the thickness of the stroke in p5.js pixels<\/li>\n<\/ul>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>bool shouldDiscard<\/code><\/p>\n<\/td><td>\n\n<p>Caps and joins are made by discarded pixels in the fragment shader to carve away unwanted areas. Use this to change this logic. It takes in a <code>bool willDiscard<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>vec4 getFinalColor<\/code><\/p>\n<\/td><td>\n\n<p>Update the final color after mixing. It takes in a <code>vec4 color<\/code> and must return a modified version.<\/p>\n<\/td><\/tr>\n<tr><td>\n\n<p><code>void afterFragment<\/code><\/p>\n<\/td><td>\n\n<p>Called at the end of the fragment shader.<\/p>\n<\/td><\/tr>\n<\/table>\n\n<p>Most of the time, you will need to write your hooks in GLSL ES version 300. If you\nare using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.<\/p>\n<p>Call <code>baseStrokeShader().inspectHooks()<\/code> to see all the possible hooks and\ntheir default implementations.<\/p>\n","itemtype":"method","name":"baseStrokeShader","beta":1,"return":{"description":"The stroke shader","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseStrokeShader().modify({\n    'Inputs getPixelInputs': `(Inputs inputs) {\n      float opacity = 1.0 - smoothstep(\n        0.0,\n        15.0,\n        length(inputs.position - inputs.center)\n      );\n      inputs.color *= opacity;\n      return inputs;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  strokeWeight(30);\n  line(\n    -width\/3,\n    sin(millis()*0.001) * height\/4,\n    width\/3,\n    sin(millis()*0.001 + 1) * height\/4\n  );\n}\n<\/code>\n<\/div>","\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseStrokeShader().modify({\n    uniforms: {\n      'float time': () => millis()\n    },\n    declarations: 'vec3 myPosition;',\n    'vec3 getWorldPosition': `(vec3 pos) {\n      myPosition = pos;\n      return pos;\n    }`,\n    'float getStrokeWeight': `(float w) {\n      \/\/ Add a somewhat random offset to the weight\n      \/\/ that varies based on position and time\n      float scale = 0.8 + 0.2*sin(10.0 * sin(\n        floor(time\/250.) +\n        myPosition.x*0.01 +\n        myPosition.y*0.01\n      ));\n      return w * scale;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  myShader.setUniform('time', millis());\n  strokeWeight(10);\n  beginShape();\n  for (let i = 0; i <= 50; i++) {\n    let r = map(i, 0, 50, 0, width\/3);\n    let x = r*cos(i*0.2);\n    let y = r*sin(i*0.2);\n    vertex(x, y);\n  }\n  endShape();\n}\n<\/code>\n<\/div>","\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseStrokeShader().modify({\n    'float random': `(vec2 p) {\n      vec3 p3  = fract(vec3(p.xyx) * .1031);\n      p3 += dot(p3, p3.yzx + 33.33);\n      return fract((p3.x + p3.y) * p3.z);\n    }`,\n    'Inputs getPixelInputs': `(Inputs inputs) {\n      \/\/ Replace alpha in the color with dithering by\n      \/\/ randomly setting pixel colors to 0 based on opacity\n      float a = inputs.color.a;\n      inputs.color.a = 1.0;\n      inputs.color *= random(inputs.position.xy) > a ? 0.0 : 1.0;\n      return inputs;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  strokeWeight(10);\n  beginShape();\n  for (let i = 0; i <= 50; i++) {\n    stroke(\n      0,\n      255\n        * map(i, 0, 20, 0, 1, true)\n        * map(i, 30, 50, 1, 0, true)\n    );\n    vertex(\n      map(i, 0, 50, -1, 1) * width\/3,\n      50 * sin(i\/10 + frameCount\/100)\n    );\n  }\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":1628,"description":"<p>Restores the default shaders.<\/p>\n<p><code>resetShader()<\/code> deactivates any shaders previously applied by\n<a href=\"#\/p5\/shader\">shader()<\/a>.<\/p>\n<p>Note: Shaders can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"resetShader","chainable":1,"example":["\n<div>\n<code>\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nuniform mat4 uProjectionMatrix;\nuniform mat4 uModelViewMatrix;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 position = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * position;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision mediump float;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vec2 uv = vTexCoord;\n  vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0));\n  gl_FragColor = vec4(color, 1.0);\n}\n`;\n\nlet myShader;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  myShader = createShader(vertSrc, fragSrc);\n\n  describe(\n    'Two rotating cubes on a gray background. The left one has a blue-purple gradient on each face. The right one is red.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw a box using the p5.Shader.\n  \/\/ shader() sets the active shader to myShader.\n  shader(myShader);\n  push();\n  translate(-25, 0, 0);\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  box(width \/ 4);\n  pop();\n\n  \/\/ Draw a box using the default fill shader.\n  \/\/ resetShader() restores the default fill shader.\n  resetShader();\n  fill(255, 0, 0);\n  push();\n  translate(25, 0, 0);\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  box(width \/ 4);\n  pop();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":1716,"description":"<p>Sets the texture that will be used on shapes.<\/p>\n<p>A texture is like a skin that wraps around a shape. <code>texture()<\/code> works with\nbuilt-in shapes, such as <a href=\"#\/p5\/square\">square()<\/a> and\n<a href=\"#\/p5\/sphere\">sphere()<\/a>, and custom shapes created with\nfunctions such as <a href=\"#\/p5\/buildGeometry\">buildGeometry()<\/a>. To\ntexture a geometry created with <a href=\"#\/p5\/beginShape\">beginShape()<\/a>,\nuv coordinates must be passed to each\n<a href=\"#\/p5\/vertex\">vertex()<\/a> call.<\/p>\n<p>The parameter, <code>tex<\/code>, is the texture to apply. <code>texture()<\/code> can use a range\nof sources including images, videos, and offscreen renderers such as\n<a href=\"#\/p5.Graphics\">p5.Graphics<\/a> and\n<a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a> objects.<\/p>\n<p>To texture a geometry created with <a href=\"#\/p5\/beginShape\">beginShape()<\/a>,\nyou will need to specify uv coordinates in <a href=\"#\/p5\/vertex\">vertex()<\/a>.<\/p>\n<p>Note: <code>texture()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"texture","params":[{"name":"tex","description":"<p>media to use as the texture.<\/p>\n","type":"p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture"}],"chainable":1,"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load an image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A spinning cube with an image of a ceiling on each face.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Rotate around the x-, y-, and z-axes.\n  rotateZ(frameCount * 0.01);\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n\n  \/\/ Apply the image as a texture.\n  texture(img);\n\n  \/\/ Draw the box.\n  box(50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Graphics object.\n  pg = createGraphics(100, 100);\n\n  \/\/ Draw a circle to the p5.Graphics object.\n  pg.background(200);\n  pg.circle(50, 50, 30);\n\n  describe('A spinning cube with circle at the center of each face.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Rotate around the x-, y-, and z-axes.\n  rotateZ(frameCount * 0.01);\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n\n  \/\/ Apply the p5.Graphics object as a texture.\n  texture(pg);\n\n  \/\/ Draw the box.\n  box(50);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet vid;\n\n\/\/ Load a video and create a p5.MediaElement object.\nfunction preload() {\n  vid = createVideo('assets\/fingers.mov');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Hide the video.\n  vid.hide();\n\n  \/\/ Set the video to loop.\n  vid.loop();\n\n  describe('A rectangle with video as texture');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Apply the video as a texture.\n  texture(vid);\n\n  \/\/ Draw the rectangle.\n  rect(-40, -40, 80, 80);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet vid;\n\n\/\/ Load a video and create a p5.MediaElement object.\nfunction preload() {\n  vid = createVideo('assets\/fingers.mov');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Hide the video.\n  vid.hide();\n\n  \/\/ Set the video to loop.\n  vid.loop();\n\n  describe('A rectangle with video as texture');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Set the texture mode.\n  textureMode(NORMAL);\n\n  \/\/ Apply the video as a texture.\n  texture(vid);\n\n  \/\/ Draw a custom shape using uv coordinates.\n  beginShape();\n  vertex(-40, -40, 0, 0);\n  vertex(40, -40, 1, 0);\n  vertex(40, 40, 1, 1);\n  vertex(-40, 40, 0, 1);\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":1903,"description":"<p>Changes the coordinate system used for textures when they\u2019re applied to\ncustom shapes.<\/p>\n<p>In order for <a href=\"#\/p5\/texture\">texture()<\/a> to work, a shape needs a\nway to map the points on its surface to the pixels in an image. Built-in\nshapes such as <a href=\"#\/p5\/rect\">rect()<\/a> and\n<a href=\"#\/p5\/box\">box()<\/a> already have these texture mappings based on\ntheir vertices. Custom shapes created with\n<a href=\"#\/p5\/vertex\">vertex()<\/a> require texture mappings to be passed as\nuv coordinates.<\/p>\n<p>Each call to <a href=\"#\/p5\/vertex\">vertex()<\/a> must include 5 arguments,\nas in <code>vertex(x, y, z, u, v)<\/code>, to map the vertex at coordinates <code>(x, y, z)<\/code>\nto the pixel at coordinates <code>(u, v)<\/code> within an image. For example, the\ncorners of a rectangular image are mapped to the corners of a rectangle by default:<\/p>\n<pre><code class=\"language-js\">\/\/ Apply the image as a texture.\ntexture(img);\n\n\/\/ Draw the rectangle.\nrect(0, 0, 30, 50);\n<\/code><\/pre>\n<p>If the image in the code snippet above has dimensions of 300 x 500 pixels,\nthe same result could be achieved as follows:<\/p>\n<pre><code class=\"language-js\">\/\/ Apply the image as a texture.\ntexture(img);\n\n\/\/ Draw the rectangle.\nbeginShape();\n\n\/\/ Top-left.\n\/\/ u: 0, v: 0\nvertex(0, 0, 0, 0, 0);\n\n\/\/ Top-right.\n\/\/ u: 300, v: 0\nvertex(30, 0, 0, 300, 0);\n\n\/\/ Bottom-right.\n\/\/ u: 300, v: 500\nvertex(30, 50, 0, 300, 500);\n\n\/\/ Bottom-left.\n\/\/ u: 0, v: 500\nvertex(0, 50, 0, 0, 500);\n\nendShape();\n<\/code><\/pre>\n<p><code>textureMode()<\/code> changes the coordinate system for uv coordinates.<\/p>\n<p>The parameter, <code>mode<\/code>, accepts two possible constants. If <code>NORMAL<\/code> is\npassed, as in <code>textureMode(NORMAL)<\/code>, then the texture\u2019s uv coordinates can\nbe provided in the range 0 to 1 instead of the image\u2019s dimensions. This can\nbe helpful for using the same code for multiple images of different sizes.\nFor example, the code snippet above could be rewritten as follows:<\/p>\n<pre><code class=\"language-js\">\/\/ Set the texture mode to use normalized coordinates.\ntextureMode(NORMAL);\n\n\/\/ Apply the image as a texture.\ntexture(img);\n\n\/\/ Draw the rectangle.\nbeginShape();\n\n\/\/ Top-left.\n\/\/ u: 0, v: 0\nvertex(0, 0, 0, 0, 0);\n\n\/\/ Top-right.\n\/\/ u: 1, v: 0\nvertex(30, 0, 0, 1, 0);\n\n\/\/ Bottom-right.\n\/\/ u: 1, v: 1\nvertex(30, 50, 0, 1, 1);\n\n\/\/ Bottom-left.\n\/\/ u: 0, v: 1\nvertex(0, 50, 0, 0, 1);\n\nendShape();\n<\/code><\/pre>\n<p>By default, <code>mode<\/code> is <code>IMAGE<\/code>, which scales uv coordinates to the\ndimensions of the image. Calling <code>textureMode(IMAGE)<\/code> applies the default.<\/p>\n<p>Note: <code>textureMode()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"textureMode","params":[{"name":"mode","description":"<p>either IMAGE or NORMAL.<\/p>\n","type":"Constant"}],"example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load an image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('An image of a ceiling against a black background.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Apply the image as a texture.\n  texture(img);\n\n  \/\/ Draw the custom shape.\n  \/\/ Use the image's width and height as uv coordinates.\n  beginShape();\n  vertex(-30, -30, 0, 0);\n  vertex(30, -30, img.width, 0);\n  vertex(30, 30, img.width, img.height);\n  vertex(-30, 30, 0, img.height);\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\n\/\/ Load an image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('An image of a ceiling against a black background.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Set the texture mode.\n  textureMode(NORMAL);\n\n  \/\/ Apply the image as a texture.\n  texture(img);\n\n  \/\/ Draw the custom shape.\n  \/\/ Use normalized uv coordinates.\n  beginShape();\n  vertex(-30, -30, 0, 0);\n  vertex(30, -30, 1, 0);\n  vertex(30, 30, 1, 1);\n  vertex(-30, 30, 0, 1);\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":2082,"description":"<p>Changes the way textures behave when a shape\u2019s uv coordinates go beyond the\ntexture.<\/p>\n<p>In order for <a href=\"#\/p5\/texture\">texture()<\/a> to work, a shape needs a\nway to map the points on its surface to the pixels in an image. Built-in\nshapes such as <a href=\"#\/p5\/rect\">rect()<\/a> and\n<a href=\"#\/p5\/box\">box()<\/a> already have these texture mappings based on\ntheir vertices. Custom shapes created with\n<a href=\"#\/p5\/vertex\">vertex()<\/a> require texture mappings to be passed as\nuv coordinates.<\/p>\n<p>Each call to <a href=\"#\/p5\/vertex\">vertex()<\/a> must include 5 arguments,\nas in <code>vertex(x, y, z, u, v)<\/code>, to map the vertex at coordinates <code>(x, y, z)<\/code>\nto the pixel at coordinates <code>(u, v)<\/code> within an image. For example, the\ncorners of a rectangular image are mapped to the corners of a rectangle by default:<\/p>\n<pre><code class=\"language-js\">\/\/ Apply the image as a texture.\ntexture(img);\n\n\/\/ Draw the rectangle.\nrect(0, 0, 30, 50);\n<\/code><\/pre>\n<p>If the image in the code snippet above has dimensions of 300 x 500 pixels,\nthe same result could be achieved as follows:<\/p>\n<pre><code class=\"language-js\">\/\/ Apply the image as a texture.\ntexture(img);\n\n\/\/ Draw the rectangle.\nbeginShape();\n\n\/\/ Top-left.\n\/\/ u: 0, v: 0\nvertex(0, 0, 0, 0, 0);\n\n\/\/ Top-right.\n\/\/ u: 300, v: 0\nvertex(30, 0, 0, 300, 0);\n\n\/\/ Bottom-right.\n\/\/ u: 300, v: 500\nvertex(30, 50, 0, 300, 500);\n\n\/\/ Bottom-left.\n\/\/ u: 0, v: 500\nvertex(0, 50, 0, 0, 500);\n\nendShape();\n<\/code><\/pre>\n<p><code>textureWrap()<\/code> controls how textures behave when their uv's go beyond the\ntexture. Doing so can produce interesting visual effects such as tiling.\nFor example, the custom shape above could have u-coordinates are greater\nthan the image\u2019s width:<\/p>\n<pre><code class=\"language-js\">\/\/ Apply the image as a texture.\ntexture(img);\n\n\/\/ Draw the rectangle.\nbeginShape();\nvertex(0, 0, 0, 0, 0);\n\n\/\/ Top-right.\n\/\/ u: 600\nvertex(30, 0, 0, 600, 0);\n\n\/\/ Bottom-right.\n\/\/ u: 600\nvertex(30, 50, 0, 600, 500);\n\nvertex(0, 50, 0, 0, 500);\nendShape();\n<\/code><\/pre>\n<p>The u-coordinates of 600 are greater than the texture image\u2019s width of 300.\nThis creates interesting possibilities.<\/p>\n<p>The first parameter, <code>wrapX<\/code>, accepts three possible constants. If <code>CLAMP<\/code>\nis passed, as in <code>textureWrap(CLAMP)<\/code>, the pixels at the edge of the\ntexture will extend to the shape\u2019s edges. If <code>REPEAT<\/code> is passed, as in\n<code>textureWrap(REPEAT)<\/code>, the texture will tile repeatedly until reaching the\nshape\u2019s edges. If <code>MIRROR<\/code> is passed, as in <code>textureWrap(MIRROR)<\/code>, the\ntexture will tile repeatedly until reaching the shape\u2019s edges, flipping\nits orientation between tiles. By default, textures <code>CLAMP<\/code>.<\/p>\n<p>The second parameter, <code>wrapY<\/code>, is optional. It accepts the same three\nconstants, <code>CLAMP<\/code>, <code>REPEAT<\/code>, and <code>MIRROR<\/code>. If one of these constants is\npassed, as in <code>textureWRAP(MIRROR, REPEAT)<\/code>, then the texture will <code>MIRROR<\/code>\nhorizontally and <code>REPEAT<\/code> vertically. By default, <code>wrapY<\/code> will be set to\nthe same value as <code>wrapX<\/code>.<\/p>\n<p>Note: <code>textureWrap()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"textureWrap","params":[{"name":"wrapX","description":"<p>either CLAMP, REPEAT, or MIRROR<\/p>\n","type":"Constant"},{"name":"wrapY","description":"<p>either CLAMP, REPEAT, or MIRROR<\/p>\n","type":"Constant","optional":true}],"example":["\n<div>\n<code>\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/rockies128.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'An image of a landscape occupies the top-left corner of a square. Its edge colors smear to cover the other thre quarters of the square.'\n  );\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Set the texture mode.\n  textureMode(NORMAL);\n\n  \/\/ Set the texture wrapping.\n  \/\/ Note: CLAMP is the default mode.\n  textureWrap(CLAMP);\n\n  \/\/ Apply the image as a texture.\n  texture(img);\n\n  \/\/ Style the shape.\n  noStroke();\n\n  \/\/ Draw the shape.\n  \/\/ Use uv coordinates > 1.\n  beginShape();\n  vertex(-30, -30, 0, 0, 0);\n  vertex(30, -30, 0, 2, 0);\n  vertex(30, 30, 0, 2, 2);\n  vertex(-30, 30, 0, 0, 2);\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/rockies128.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('Four identical images of a landscape arranged in a grid.');\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Set the texture mode.\n  textureMode(NORMAL);\n\n  \/\/ Set the texture wrapping.\n  textureWrap(REPEAT);\n\n  \/\/ Apply the image as a texture.\n  texture(img);\n\n  \/\/ Style the shape.\n  noStroke();\n\n  \/\/ Draw the shape.\n  \/\/ Use uv coordinates > 1.\n  beginShape();\n  vertex(-30, -30, 0, 0, 0);\n  vertex(30, -30, 0, 2, 0);\n  vertex(30, 30, 0, 2, 2);\n  vertex(-30, 30, 0, 0, 2);\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/rockies128.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'Four identical images of a landscape arranged in a grid. The images are reflected horizontally and vertically, creating a kaleidoscope effect.'\n  );\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Set the texture mode.\n  textureMode(NORMAL);\n\n  \/\/ Set the texture wrapping.\n  textureWrap(MIRROR);\n\n  \/\/ Apply the image as a texture.\n  texture(img);\n\n  \/\/ Style the shape.\n  noStroke();\n\n  \/\/ Draw the shape.\n  \/\/ Use uv coordinates > 1.\n  beginShape();\n  vertex(-30, -30, 0, 0, 0);\n  vertex(30, -30, 0, 2, 0);\n  vertex(30, 30, 0, 2, 2);\n  vertex(-30, 30, 0, 0, 2);\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/rockies128.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'Four identical images of a landscape arranged in a grid. The top row and bottom row are reflections of each other.'\n  );\n}\n\nfunction draw() {\n  background(0);\n\n  \/\/ Set the texture mode.\n  textureMode(NORMAL);\n\n  \/\/ Set the texture wrapping.\n  textureWrap(REPEAT, MIRROR);\n\n  \/\/ Apply the image as a texture.\n  texture(img);\n\n  \/\/ Style the shape.\n  noStroke();\n\n  \/\/ Draw the shape.\n  \/\/ Use uv coordinates > 1.\n  beginShape();\n  vertex(-30, -30, 0, 0, 0);\n  vertex(30, -30, 0, 2, 0);\n  vertex(30, 30, 0, 2, 2);\n  vertex(-30, 30, 0, 0, 2);\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":2365,"description":"<p>Sets the current material as a normal material.<\/p>\n<p>A normal material sets surfaces facing the x-axis to red, those facing the\ny-axis to green, and those facing the z-axis to blue. Normal material isn't\naffected by light. It\u2019s often used as a placeholder material when debugging.<\/p>\n<p>Note: <code>normalMaterial()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"normalMaterial","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A multicolor torus drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Style the torus.\n  normalMaterial();\n\n  \/\/ Draw the torus.\n  torus(30);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":2416,"description":"<p>Sets the ambient color of shapes\u2019 surface material.<\/p>\n<p>The <code>ambientMaterial()<\/code> color sets the components of the\n<a href=\"#\/p5\/ambientLight\">ambientLight()<\/a> color that shapes will\nreflect. For example, calling <code>ambientMaterial(255, 255, 0)<\/code> would cause a\nshape to reflect red and green light, but not blue light.<\/p>\n<p><code>ambientMaterial()<\/code> can be called three ways with different parameters to\nset the material\u2019s color.<\/p>\n<p>The first way to call <code>ambientMaterial()<\/code> has one parameter, <code>gray<\/code>.\nGrayscale values between 0 and 255, as in <code>ambientMaterial(50)<\/code>, can be\npassed to set the material\u2019s color. Higher grayscale values make shapes\nappear brighter.<\/p>\n<p>The second way to call <code>ambientMaterial()<\/code> has one parameter, <code>color<\/code>. A\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color values, or a\nCSS color string, as in <code>ambientMaterial('magenta')<\/code>, can be passed to set\nthe material\u2019s color.<\/p>\n<p>The third way to call <code>ambientMaterial()<\/code> has three parameters, <code>v1<\/code>, <code>v2<\/code>,\nand <code>v3<\/code>. RGB, HSB, or HSL values, as in <code>ambientMaterial(255, 0, 0)<\/code>, can\nbe passed to set the material\u2019s colors. Color values will be interpreted\nusing the current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n<p>Note: <code>ambientMaterial()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"ambientMaterial","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A magenta cube drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a magenta ambient light.\n  ambientLight(255, 0, 255);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A purple cube drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a magenta ambient light.\n  ambientLight(255, 0, 255);\n\n  \/\/ Add a dark gray ambient material.\n  ambientMaterial(150);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A red cube drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a magenta ambient light.\n  ambientLight(255, 0, 255);\n\n  \/\/ Add a yellow ambient material using RGB values.\n  ambientMaterial(255, 255, 0);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A red cube drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a magenta ambient light.\n  ambientLight(255, 0, 255);\n\n  \/\/ Add a yellow ambient material using a p5.Color object.\n  let c = color(255, 255, 0);\n  ambientMaterial(c);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A red cube drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a magenta ambient light.\n  ambientLight(255, 0, 255);\n\n  \/\/ Add a yellow ambient material using a color string.\n  ambientMaterial('yellow');\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A yellow cube drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a white ambient light.\n  ambientLight(255, 255, 255);\n\n  \/\/ Add a yellow ambient material using a color string.\n  ambientMaterial('yellow');\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material","overloads":[{"line":2416,"params":[{"name":"v1","description":"<p>red or hue value in the current\n                      <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value in the\n                     current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value in the\n                     current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"}],"chainable":1},{"line":2621,"params":[{"name":"gray","description":"<p>grayscale value between 0 (black) and 255 (white).<\/p>\n","type":"Number"}],"chainable":1},{"line":2627,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object,\n           an array of color values, or a CSS string.<\/p>\n","type":"p5.Color|Number[]|String"}],"chainable":1}]},{"file":"src\/webgl\/material.js","line":2647,"description":"<p>Sets the emissive color of shapes\u2019 surface material.<\/p>\n<p>The <code>emissiveMaterial()<\/code> color sets a color shapes display at full\nstrength, regardless of lighting. This can give the appearance that a shape\nis glowing. However, emissive materials don\u2019t actually emit light that\ncan affect surrounding objects.<\/p>\n<p><code>emissiveMaterial()<\/code> can be called three ways with different parameters to\nset the material\u2019s color.<\/p>\n<p>The first way to call <code>emissiveMaterial()<\/code> has one parameter, <code>gray<\/code>.\nGrayscale values between 0 and 255, as in <code>emissiveMaterial(50)<\/code>, can be\npassed to set the material\u2019s color. Higher grayscale values make shapes\nappear brighter.<\/p>\n<p>The second way to call <code>emissiveMaterial()<\/code> has one parameter, <code>color<\/code>. A\n<a href=\"#\/p5.Color\">p5.Color<\/a> object, an array of color values, or a\nCSS color string, as in <code>emissiveMaterial('magenta')<\/code>, can be passed to set\nthe material\u2019s color.<\/p>\n<p>The third way to call <code>emissiveMaterial()<\/code> has four parameters, <code>v1<\/code>, <code>v2<\/code>,\n<code>v3<\/code>, and <code>alpha<\/code>. <code>alpha<\/code> is optional. RGBA, HSBA, or HSLA values can be\npassed to set the material\u2019s colors, as in <code>emissiveMaterial(255, 0, 0)<\/code> or\n<code>emissiveMaterial(255, 0, 0, 30)<\/code>. Color values will be interpreted using\nthe current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n<p>Note: <code>emissiveMaterial()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"emissiveMaterial","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A red cube drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a white ambient light.\n  ambientLight(255, 255, 255);\n\n  \/\/ Add a red emissive material using RGB values.\n  emissiveMaterial(255, 0, 0);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material","overloads":[{"line":2647,"params":[{"name":"v1","description":"<p>red or hue value in the current\n                          <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value in the\n                          current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value in the\n                          current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"alpha","description":"<p>alpha value in the current\n                          <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":2717,"params":[{"name":"gray","description":"<p>grayscale value between 0 (black) and 255 (white).<\/p>\n","type":"Number"}],"chainable":1},{"line":2723,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object,\n           an array of color values, or a CSS string.<\/p>\n","type":"p5.Color|Number[]|String"}],"chainable":1}]},{"file":"src\/webgl\/material.js","line":2743,"description":"<p>Sets the specular color of shapes\u2019 surface material.<\/p>\n<p>The <code>specularMaterial()<\/code> color sets the components of light color that\nglossy coats on shapes will reflect. For example, calling\n<code>specularMaterial(255, 255, 0)<\/code> would cause a shape to reflect red and\ngreen light, but not blue light.<\/p>\n<p>Unlike <a href=\"#\/p5\/ambientMaterial\">ambientMaterial()<\/a>,\n<code>specularMaterial()<\/code> will reflect the full color of light sources including\n<a href=\"#\/p5\/directionalLight\">directionalLight()<\/a>,\n<a href=\"#\/p5\/pointLight\">pointLight()<\/a>,\nand <a href=\"#\/p5\/spotLight\">spotLight()<\/a>. This is what gives it shapes\ntheir \"shiny\" appearance. The material\u2019s shininess can be controlled by the\n<a href=\"#\/p5\/shininess\">shininess()<\/a> function.<\/p>\n<p><code>specularMaterial()<\/code> can be called three ways with different parameters to\nset the material\u2019s color.<\/p>\n<p>The first way to call <code>specularMaterial()<\/code> has one parameter, <code>gray<\/code>.\nGrayscale values between 0 and 255, as in <code>specularMaterial(50)<\/code>, can be\npassed to set the material\u2019s color. Higher grayscale values make shapes\nappear brighter.<\/p>\n<p>The second way to call <code>specularMaterial()<\/code> has one parameter, <code>color<\/code>. A\n<a href=\"#\/p5.Color\">p5.Color> object, an array of color values, or a CSS\ncolor string, as in <code>specularMaterial('magenta')<\/code>, can be passed to set the\nmaterial\u2019s color.<\/p>\n<p>The third way to call <code>specularMaterial()<\/code> has four parameters, <code>v1<\/code>, <code>v2<\/code>,\n<code>v3<\/code>, and <code>alpha<\/code>. <code>alpha<\/code> is optional. RGBA, HSBA, or HSLA values can be\npassed to set the material\u2019s colors, as in <code>specularMaterial(255, 0, 0)<\/code> or\n<code>specularMaterial(255, 0, 0, 30)<\/code>. Color values will be interpreted using\nthe current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","itemtype":"method","name":"specularMaterial","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click the canvas to apply a specular material.\n\nlet isGlossy = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A red torus drawn on a gray background. It becomes glossy when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a white point light at the top-right.\n  pointLight(255, 255, 255, 30, -40, 30);\n\n  \/\/ Add a glossy coat if the user has double-clicked.\n  if (isGlossy === true) {\n    specularMaterial(255);\n    shininess(50);\n  }\n\n  \/\/ Style the torus.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Draw the torus.\n  torus(30);\n}\n\n\/\/ Make the torus glossy when the user double-clicks.\nfunction doubleClicked() {\n  isGlossy = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click the canvas to apply a specular material.\n\nlet isGlossy = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a white point light at the top-right.\n  pointLight(255, 255, 255, 30, -40, 30);\n\n  \/\/ Add a glossy green coat if the user has double-clicked.\n  if (isGlossy === true) {\n    specularMaterial(0, 255, 0);\n    shininess(50);\n  }\n\n  \/\/ Style the torus.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Draw the torus.\n  torus(30);\n}\n\n\/\/ Make the torus glossy when the user double-clicks.\nfunction doubleClicked() {\n  isGlossy = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click the canvas to apply a specular material.\n\nlet isGlossy = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a white point light at the top-right.\n  pointLight(255, 255, 255, 30, -40, 30);\n\n  \/\/ Add a glossy green coat if the user has double-clicked.\n  if (isGlossy === true) {\n    \/\/ Create a p5.Color object.\n    let c = color('green');\n    specularMaterial(c);\n    shininess(50);\n  }\n\n  \/\/ Style the torus.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Draw the torus.\n  torus(30);\n}\n\n\/\/ Make the torus glossy when the user double-clicks.\nfunction doubleClicked() {\n  isGlossy = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\/\/ Double-click the canvas to apply a specular material.\n\nlet isGlossy = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on a white point light at the top-right.\n  pointLight(255, 255, 255, 30, -40, 30);\n\n  \/\/ Add a glossy green coat if the user has double-clicked.\n  if (isGlossy === true) {\n    specularMaterial('#00FF00');\n    shininess(50);\n  }\n\n  \/\/ Style the torus.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Draw the torus.\n  torus(30);\n}\n\n\/\/ Make the torus glossy when the user double-clicks.\nfunction doubleClicked() {\n  isGlossy = true;\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material","overloads":[{"line":2743,"params":[{"name":"gray","description":"<p>grayscale value between 0 (black) and 255 (white).<\/p>\n","type":"Number"},{"name":"alpha","description":"<p>alpha value in the current current\n                         <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number","optional":true}],"chainable":1},{"line":2966,"params":[{"name":"v1","description":"<p>red or hue value in\n                                the current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v2","description":"<p>green or saturation value\n                                in the current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"v3","description":"<p>blue, brightness, or lightness value\n                                in the current <a href=\"#\/p5\/colorMode\">colorMode()<\/a>.<\/p>\n","type":"Number"},{"name":"alpha","description":"","type":"Number","optional":true}],"chainable":1},{"line":2978,"params":[{"name":"color","description":"<p>color as a <a href=\"#\/p5.Color\">p5.Color<\/a> object,\n           an array of color values, or a CSS string.<\/p>\n","type":"p5.Color|Number[]|String"}],"chainable":1}]},{"file":"src\/webgl\/material.js","line":2998,"description":"<p>Sets the amount of gloss (\"shininess\") of a\n<a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a>.<\/p>\n<p>Shiny materials focus reflected light more than dull materials.\n<code>shininess()<\/code> affects the way materials reflect light sources including\n<a href=\"#\/p5\/directionalLight\">directionalLight()<\/a>,\n<a href=\"#\/p5\/pointLight\">pointLight()<\/a>,\nand <a href=\"#\/p5\/spotLight\">spotLight()<\/a>.<\/p>\n<p>The parameter, <code>shine<\/code>, is a number that sets the amount of shininess.\n<code>shine<\/code> must be greater than 1, which is its default value.<\/p>\n","itemtype":"method","name":"shininess","params":[{"name":"shine","description":"<p>amount of shine.<\/p>\n","type":"Number"}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'Two red spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is shinier than the left sphere.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Turn on a red ambient light.\n  ambientLight(255, 0, 0);\n\n  \/\/ Get the mouse's coordinates.\n  let mx = mouseX - 50;\n  let my = mouseY - 50;\n\n  \/\/ Turn on a white point light that follows the mouse.\n  pointLight(255, 255, 255, mx, my, 50);\n\n  \/\/ Style the sphere.\n  noStroke();\n\n  \/\/ Add a specular material with a grayscale value.\n  specularMaterial(255);\n\n  \/\/ Draw the left sphere with low shininess.\n  translate(-25, 0, 0);\n  shininess(10);\n  sphere(20);\n\n  \/\/ Draw the right sphere with high shininess.\n  translate(50, 0, 0);\n  shininess(100);\n  sphere(20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/material.js","line":3069,"description":"<p>Sets the amount of \"metalness\" of a\n<a href=\"#\/p5\/specularMaterial\">specularMaterial()<\/a>.<\/p>\n<p><code>metalness()<\/code> can make materials appear more metallic. It affects the way\nmaterials reflect light sources including\naffects the way materials reflect light sources including\n<a href=\"#\/p5\/directionalLight\">directionalLight()<\/a>,\n<a href=\"#\/p5\/pointLight\">pointLight()<\/a>,\n<a href=\"#\/p5\/spotLight\">spotLight()<\/a>, and\n<a href=\"#\/p5\/imageLight\">imageLight()<\/a>.<\/p>\n<p>The parameter, <code>metallic<\/code>, is a number that sets the amount of metalness.\n<code>metallic<\/code> must be greater than 1, which is its default value. Higher\nvalues, such as <code>metalness(100)<\/code>, make specular materials appear more\nmetallic.<\/p>\n","itemtype":"method","name":"metalness","params":[{"name":"metallic","description":"<p>amount of metalness.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'Two blue spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is more metallic than the left sphere.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Turn on an ambient light.\n  ambientLight(200);\n\n  \/\/ Get the mouse's coordinates.\n  let mx = mouseX - 50;\n  let my = mouseY - 50;\n\n  \/\/ Turn on a white point light that follows the mouse.\n  pointLight(255, 255, 255, mx, my, 50);\n\n  \/\/ Style the spheres.\n  noStroke();\n  fill(30, 30, 255);\n  specularMaterial(255);\n  shininess(20);\n\n  \/\/ Draw the left sphere with low metalness.\n  translate(-25, 0, 0);\n  metalness(1);\n  sphere(20);\n\n  \/\/ Draw the right sphere with high metalness.\n  translate(50, 0, 0);\n  metalness(50);\n  sphere(20);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/outdoor_spheremap.jpg');\n}\n\nfunction setup() {\n  createCanvas(100 ,100 ,WEBGL);\n\n  describe(\n    'Two spheres floating above a landscape. The surface of the spheres reflect the landscape. The right sphere is more reflective than the left sphere.'\n  );\n}\n\nfunction draw() {\n  \/\/ Add the panorama.\n  panorama(img);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Use the image as a light source.\n  imageLight(img);\n\n  \/\/ Style the spheres.\n  noStroke();\n  specularMaterial(50);\n  shininess(200);\n\n  \/\/ Draw the left sphere with low metalness.\n  translate(-25, 0, 0);\n  metalness(1);\n  sphere(20);\n\n  \/\/ Draw the right sphere with high metalness.\n  translate(50, 0, 0);\n  metalness(50);\n  sphere(20);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Material"},{"file":"src\/webgl\/p5.Camera.js","line":13,"description":"<p>Sets the position and orientation of the current camera in a 3D sketch.<\/p>\n<p><code>camera()<\/code> allows objects to be viewed from different angles. It has nine\nparameters that are all optional.<\/p>\n<p>The first three parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, are the coordinates of the\ncamera\u2019s position. For example, calling <code>camera(0, 0, 0)<\/code> places the camera\nat the origin <code>(0, 0, 0)<\/code>. By default, the camera is placed at\n<code>(0, 0, 800)<\/code>.<\/p>\n<p>The next three parameters, <code>centerX<\/code>, <code>centerY<\/code>, and <code>centerZ<\/code> are the\ncoordinates of the point where the camera faces. For example, calling\n<code>camera(0, 0, 0, 10, 20, 30)<\/code> places the camera at the origin <code>(0, 0, 0)<\/code>\nand points it at <code>(10, 20, 30)<\/code>. By default, the camera points at the\norigin <code>(0, 0, 0)<\/code>.<\/p>\n<p>The last three parameters, <code>upX<\/code>, <code>upY<\/code>, and <code>upZ<\/code> are the components of\nthe \"up\" vector. The \"up\" vector orients the camera\u2019s y-axis. For example,\ncalling <code>camera(0, 0, 0, 10, 20, 30, 0, -1, 0)<\/code> places the camera at the\norigin <code>(0, 0, 0)<\/code>, points it at <code>(10, 20, 30)<\/code>, and sets the \"up\" vector\nto <code>(0, -1, 0)<\/code> which is like holding it upside-down. By default, the \"up\"\nvector is <code>(0, 1, 0)<\/code>.<\/p>\n<p>Note: <code>camera()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"camera","is_constructor":1,"params":[{"name":"x","description":"<p>x-coordinate of the camera. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y-coordinate of the camera. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z-coordinate of the camera. Defaults to 800.<\/p>\n","type":"Number","optional":true},{"name":"centerX","description":"<p>x-coordinate of the point the camera faces. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"centerY","description":"<p>y-coordinate of the point the camera faces. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"centerZ","description":"<p>z-coordinate of the point the camera faces. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"upX","description":"<p>x-component of the camera\u2019s \"up\" vector. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"upY","description":"<p>y-component of the camera\u2019s \"up\" vector. Defaults to 1.<\/p>\n","type":"Number","optional":true},{"name":"upZ","description":"<p>z-component of the camera\u2019s \"up\" vector. Defaults to 0.<\/p>\n","type":"Number","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Move the camera to the top-right.\n  camera(200, -400, 800);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube apperas to sway left and right on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the camera's x-coordinate.\n  let x = 400 * cos(frameCount * 0.01);\n\n  \/\/ Orbit the camera around the box.\n  camera(x, -400, 800);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Adjust the range sliders to change the camera's position.\n\nlet xSlider;\nlet ySlider;\nlet zSlider;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create slider objects to set the camera's coordinates.\n  xSlider = createSlider(-400, 400, 400);\n  xSlider.position(0, 100);\n  xSlider.size(100);\n  ySlider = createSlider(-400, 400, -200);\n  ySlider.position(0, 120);\n  ySlider.size(100);\n  zSlider = createSlider(0, 1600, 800);\n  zSlider.position(0, 140);\n  zSlider.size(100);\n\n  describe(\n    'A white cube drawn against a gray background. Three range sliders appear beneath the image. The camera position changes when the user moves the sliders.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Get the camera's coordinates from the sliders.\n  let x = xSlider.value();\n  let y = ySlider.value();\n  let z = zSlider.value();\n\n  \/\/ Move the camera.\n  camera(x, y, z);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":148,"description":"<p>Sets a perspective projection for the current camera in a 3D sketch.<\/p>\n<p>In a perspective projection, shapes that are further from the camera appear\nsmaller than shapes that are near the camera. This technique, called\nforeshortening, creates realistic 3D scenes. It\u2019s applied by default in\nWebGL mode.<\/p>\n<p><code>perspective()<\/code> changes the camera\u2019s perspective by changing its viewing\nfrustum. The frustum is the volume of space that\u2019s visible to the camera.\nIts shape is a pyramid with its top cut off. The camera is placed where\nthe top of the pyramid should be and views everything between the frustum\u2019s\ntop (near) plane and its bottom (far) plane.<\/p>\n<p>The first parameter, <code>fovy<\/code>, is the camera\u2019s vertical field of view. It\u2019s\nan angle that describes how tall or narrow a view the camera has. For\nexample, calling <code>perspective(0.5)<\/code> sets the camera\u2019s vertical field of\nview to 0.5 radians. By default, <code>fovy<\/code> is calculated based on the sketch\u2019s\nheight and the camera\u2019s default z-coordinate, which is 800. The formula for\nthe default <code>fovy<\/code> is <code>2 * atan(height \/ 2 \/ 800)<\/code>.<\/p>\n<p>The second parameter, <code>aspect<\/code>, is the camera\u2019s aspect ratio. It\u2019s a number\nthat describes the ratio of the top plane\u2019s width to its height. For\nexample, calling <code>perspective(0.5, 1.5)<\/code> sets the camera\u2019s field of view to\n0.5 radians and aspect ratio to 1.5, which would make shapes appear thinner\non a square canvas. By default, aspect is set to <code>width \/ height<\/code>.<\/p>\n<p>The third parameter, <code>near<\/code>, is the distance from the camera to the near\nplane. For example, calling <code>perspective(0.5, 1.5, 100)<\/code> sets the camera\u2019s\nfield of view to 0.5 radians, its aspect ratio to 1.5, and places the near\nplane 100 pixels from the camera. Any shapes drawn less than 100 pixels\nfrom the camera won\u2019t be visible. By default, near is set to <code>0.1 * 800<\/code>,\nwhich is 1\/10th the default distance between the camera and the origin.<\/p>\n<p>The fourth parameter, <code>far<\/code>, is the distance from the camera to the far\nplane. For example, calling <code>perspective(0.5, 1.5, 100, 10000)<\/code> sets the\ncamera\u2019s field of view to 0.5 radians, its aspect ratio to 1.5, places the\nnear plane 100 pixels from the camera, and places the far plane 10,000\npixels from the camera. Any shapes drawn more than 10,000 pixels from the\ncamera won\u2019t be visible. By default, far is set to <code>10 * 800<\/code>, which is 10\ntimes the default distance between the camera and the origin.<\/p>\n<p>Note: <code>perspective()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"perspective","params":[{"name":"fovy","description":"<p>camera frustum vertical field of view. Defaults to\n                          <code>2 * atan(height \/ 2 \/ 800)<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"aspect","description":"<p>camera frustum aspect ratio. Defaults to\n                          <code>width \/ height<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"near","description":"<p>distance from the camera to the near clipping plane.\n                          Defaults to <code>0.1 * 800<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"far","description":"<p>distance from the camera to the far clipping plane.\n                          Defaults to <code>10 * 800<\/code>.<\/p>\n","type":"Number","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Double-click to squeeze the box.\n\nlet isSqueezed = false;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white rectangular prism on a gray background. The box appears to become thinner when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Place the camera at the top-right.\n  camera(400, -400, 800);\n\n  if (isSqueezed === true) {\n    \/\/ Set fovy to 0.2.\n    \/\/ Set aspect to 1.5.\n    perspective(0.2, 1.5);\n  }\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ Change the camera's perspective when the user double-clicks.\nfunction doubleClicked() {\n  isSqueezed = true;\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white rectangular prism on a gray background. The prism moves away from the camera until it disappears.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Place the camera at the top-right.\n  camera(400, -400, 800);\n\n  \/\/ Set fovy to 0.2.\n  \/\/ Set aspect to 1.5.\n  \/\/ Set near to 600.\n  \/\/ Set far to 1200.\n  perspective(0.2, 1.5, 600, 1200);\n\n  \/\/ Move the origin away from the camera.\n  let x = -frameCount;\n  let y = frameCount;\n  let z = -2 * frameCount;\n  translate(x, y, z);\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":280,"description":"<p>Enables or disables perspective for lines in 3D sketches.<\/p>\n<p>In WebGL mode, lines can be drawn with a thinner stroke when they\u2019re\nfurther from the camera. Doing so gives them a more realistic appearance.<\/p>\n<p>By default, lines are drawn differently based on the type of perspective\nbeing used:<\/p>\n<ul>\n<li><code>perspective()<\/code> and <code>frustum()<\/code> simulate a realistic perspective. In\nthese modes, stroke weight is affected by the line\u2019s distance from the\ncamera. Doing so results in a more natural appearance. <code>perspective()<\/code> is\nthe default mode for 3D sketches.<\/li>\n<li><code>ortho()<\/code> doesn\u2019t simulate a realistic perspective. In this mode, stroke\nweights are consistent regardless of the line\u2019s distance from the camera.\nDoing so results in a more predictable and consistent appearance.<\/li>\n<\/ul>\n<p><code>linePerspective()<\/code> can override the default line drawing mode.<\/p>\n<p>The parameter, <code>enable<\/code>, is optional. It\u2019s a <code>Boolean<\/code> value that sets the\nway lines are drawn. If <code>true<\/code> is passed, as in <code>linePerspective(true)<\/code>,\nthen lines will appear thinner when they are further from the camera. If\n<code>false<\/code> is passed, as in <code>linePerspective(false)<\/code>, then lines will have\nconsistent stroke weights regardless of their distance from the camera. By\ndefault, <code>linePerspective()<\/code> is enabled.<\/p>\n<p>Calling <code>linePerspective()<\/code> without passing an argument returns <code>true<\/code> if\nit's enabled and <code>false<\/code> if not.<\/p>\n<p>Note: <code>linePerspective()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"linePerspective","example":["\n<div>\n<code>\n\/\/ Double-click the canvas to toggle the line perspective.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A white cube with black edges on a gray background. Its edges toggle between thick and thin when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 600);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n\n\/\/ Toggle the line perspective when the user double-clicks.\nfunction doubleClicked() {\n  let isEnabled = linePerspective();\n  linePerspective(!isEnabled);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click the canvas to toggle the line perspective.\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe(\n    'A row of cubes with black edges on a gray background. Their edges toggle between thick and thin when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Use an orthographic projection.\n  ortho();\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 600);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n\n\/\/ Toggle the line perspective when the user double-clicks.\nfunction doubleClicked() {\n  let isEnabled = linePerspective();\n  linePerspective(!isEnabled);\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Camera","overloads":[{"line":280,"params":[{"name":"enable","description":"<p>whether to enable line perspective.<\/p>\n","type":"Boolean"}]},{"line":392,"params":[],"return":{"description":"whether line perspective is enabled.","type":"Boolean"}}]},{"file":"src\/webgl\/p5.Camera.js","line":412,"description":"<p>Sets an orthographic projection for the current camera in a 3D sketch.<\/p>\n<p>In an orthographic projection, shapes with the same size always appear the\nsame size, regardless of whether they are near or far from the camera.<\/p>\n<p><code>ortho()<\/code> changes the camera\u2019s perspective by changing its viewing frustum\nfrom a truncated pyramid to a rectangular prism. The camera is placed in\nfront of the frustum and views everything between the frustum\u2019s near plane\nand its far plane. <code>ortho()<\/code> has six optional parameters to define the\nfrustum.<\/p>\n<p>The first four parameters, <code>left<\/code>, <code>right<\/code>, <code>bottom<\/code>, and <code>top<\/code>, set the\ncoordinates of the frustum\u2019s sides, bottom, and top. For example, calling\n<code>ortho(-100, 100, 200, -200)<\/code> creates a frustum that\u2019s 200 pixels wide and\n400 pixels tall. By default, these coordinates are set based on the\nsketch\u2019s width and height, as in\n<code>ortho(-width \/ 2, width \/ 2, -height \/ 2, height \/ 2)<\/code>.<\/p>\n<p>The last two parameters, <code>near<\/code> and <code>far<\/code>, set the distance of the\nfrustum\u2019s near and far plane from the camera. For example, calling\n<code>ortho(-100, 100, 200, 200, 50, 1000)<\/code> creates a frustum that\u2019s 200 pixels\nwide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000\npixels from the camera. By default, <code>near<\/code> and <code>far<\/code> are set to 0 and\n<code>max(width, height) + 800<\/code>, respectively.<\/p>\n<p>Note: <code>ortho()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"ortho","params":[{"name":"left","description":"<p>x-coordinate of the frustum\u2019s left plane. Defaults to <code>-width \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"right","description":"<p>x-coordinate of the frustum\u2019s right plane. Defaults to <code>width \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"bottom","description":"<p>y-coordinate of the frustum\u2019s bottom plane. Defaults to <code>height \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"top","description":"<p>y-coordinate of the frustum\u2019s top plane. Defaults to <code>-height \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"near","description":"<p>z-coordinate of the frustum\u2019s near plane. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"far","description":"<p>z-coordinate of the frustum\u2019s far plane. Defaults to <code>max(width, height) + 800<\/code>.<\/p>\n","type":"Number","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A row of tiny, white cubes on a gray background. All the cubes appear the same size.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Apply an orthographic projection.\n  ortho();\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 600);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Apply an orthographic projection.\n  \/\/ Center the frustum.\n  \/\/ Set its width and height to 20.\n  \/\/ Place its near plane 300 pixels from the camera.\n  \/\/ Place its far plane 350 pixels from the camera.\n  ortho(-10, 10, -10, 10, 300, 350);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 600);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":522,"description":"<p>Sets the frustum of the current camera in a 3D sketch.<\/p>\n<p>In a frustum projection, shapes that are further from the camera appear\nsmaller than shapes that are near the camera. This technique, called\nforeshortening, creates realistic 3D scenes.<\/p>\n<p><code>frustum()<\/code> changes the default camera\u2019s perspective by changing its\nviewing frustum. The frustum is the volume of space that\u2019s visible to the\ncamera. The frustum\u2019s shape is a pyramid with its top cut off. The camera\nis placed where the top of the pyramid should be and points towards the\nbase of the pyramid. It views everything within the frustum.<\/p>\n<p>The first four parameters, <code>left<\/code>, <code>right<\/code>, <code>bottom<\/code>, and <code>top<\/code>, set the\ncoordinates of the frustum\u2019s sides, bottom, and top. For example, calling\n<code>frustum(-100, 100, 200, -200)<\/code> creates a frustum that\u2019s 200 pixels wide\nand 400 pixels tall. By default, these coordinates are set based on the\nsketch\u2019s width and height, as in\n<code>ortho(-width \/ 20, width \/ 20, height \/ 20, -height \/ 20)<\/code>.<\/p>\n<p>The last two parameters, <code>near<\/code> and <code>far<\/code>, set the distance of the\nfrustum\u2019s near and far plane from the camera. For example, calling\n<code>ortho(-100, 100, 200, -200, 50, 1000)<\/code> creates a frustum that\u2019s 200 pixels\nwide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000\npixels from the camera. By default, near is set to <code>0.1 * 800<\/code>, which is\n1\/10th the default distance between the camera and the origin. <code>far<\/code> is set\nto <code>10 * 800<\/code>, which is 10 times the default distance between the camera\nand the origin.<\/p>\n<p>Note: <code>frustum()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"frustum","params":[{"name":"left","description":"<p>x-coordinate of the frustum\u2019s left plane. Defaults to <code>-width \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"right","description":"<p>x-coordinate of the frustum\u2019s right plane. Defaults to <code>width \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"bottom","description":"<p>y-coordinate of the frustum\u2019s bottom plane. Defaults to <code>height \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"top","description":"<p>y-coordinate of the frustum\u2019s top plane. Defaults to <code>-height \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"near","description":"<p>z-coordinate of the frustum\u2019s near plane. Defaults to <code>0.1 * 800<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"far","description":"<p>z-coordinate of the frustum\u2019s far plane. Defaults to <code>10 * 800<\/code>.<\/p>\n","type":"Number","optional":true}],"chainable":1,"example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  describe('A row of white cubes on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Apply the default frustum projection.\n  frustum();\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 600);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n  describe('A white cube on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Adjust the frustum.\n  \/\/ Center it.\n  \/\/ Set its width and height to 20 pixels.\n  \/\/ Place its near plane 300 pixels from the camera.\n  \/\/ Place its far plane 350 pixels from the camera.\n  frustum(-10, 10, -10, 10, 300, 350);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 600);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":638,"description":"<p>Creates a new <a href=\"#\/p5.Camera\">p5.Camera<\/a> object and sets it\nas the current (active) camera.<\/p>\n<p>The new camera is initialized with a default position <code>(0, 0, 800)<\/code> and a\ndefault perspective projection. Its properties can be controlled with\n<a href=\"#\/p5.Camera\">p5.Camera<\/a> methods such as\n<code>myCamera.lookAt(0, 0, 0)<\/code>.<\/p>\n<p>Note: Every 3D sketch starts with a default camera initialized.\nThis camera can be controlled with the functions\n<a href=\"#\/p5\/camera\">camera()<\/a>,\n<a href=\"#\/p5\/perspective\">perspective()<\/a>,\n<a href=\"#\/p5\/ortho\">ortho()<\/a>, and\n<a href=\"#\/p5\/frustum\">frustum()<\/a> if it's the only camera in the scene.<\/p>\n<p>Note: <code>createCamera()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"createCamera","return":{"description":"the new camera.","type":"p5.Camera"},"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet usingCam1 = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  \/\/ Place it at the top-left.\n  \/\/ Point it at the origin.\n  cam2 = createCamera();\n  cam2.setPosition(400, -400, 800);\n  cam2.lookAt(0, 0, 0);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (usingCam1 === true) {\n    setCamera(cam2);\n    usingCam1 = false;\n  } else {\n    setCamera(cam1);\n    usingCam1 = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":851,"description":"<p>The camera\u2019s x-coordinate.<\/p>\n<p>By default, the camera\u2019s x-coordinate is set to 0 in \"world\" space.<\/p>\n","itemtype":"property","name":"eyeX","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The text \"eyeX: 0\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of eyeX, rounded to the nearest integer.\n  text(`eyeX: ${round(cam.eyeX)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The cube appears to move left and right as the camera moves. The text \"eyeX: X\" is written in black beneath the cube. X oscillates between -25 and 25.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the new x-coordinate.\n  let x = 25 * sin(frameCount * 0.01);\n\n  \/\/ Set the camera's position.\n  cam.setPosition(x, -400, 800);\n\n  \/\/ Display the value of eyeX, rounded to the nearest integer.\n  text(`eyeX: ${round(cam.eyeX)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":963,"description":"<p>The camera\u2019s y-coordinate.<\/p>\n<p>By default, the camera\u2019s y-coordinate is set to 0 in \"world\" space.<\/p>\n","itemtype":"property","name":"eyeY","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The text \"eyeY: -400\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of eyeY, rounded to the nearest integer.\n  text(`eyeX: ${round(cam.eyeY)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The cube appears to move up and down as the camera moves. The text \"eyeY: Y\" is written in black beneath the cube. Y oscillates between -374 and -425.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the new y-coordinate.\n  let y = 25 * sin(frameCount * 0.01) - 400;\n\n  \/\/ Set the camera's position.\n  cam.setPosition(0, y, 800);\n\n  \/\/ Display the value of eyeY, rounded to the nearest integer.\n  text(`eyeY: ${round(cam.eyeY)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1075,"description":"<p>The camera\u2019s z-coordinate.<\/p>\n<p>By default, the camera\u2019s z-coordinate is set to 800 in \"world\" space.<\/p>\n","itemtype":"property","name":"eyeZ","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The text \"eyeZ: 800\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of eyeZ, rounded to the nearest integer.\n  text(`eyeZ: ${round(cam.eyeZ)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The cube appears to move forward and back as the camera moves. The text \"eyeZ: Z\" is written in black beneath the cube. Z oscillates between 700 and 900.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the new z-coordinate.\n  let z = 100 * sin(frameCount * 0.01) + 800;\n\n  \/\/ Set the camera's position.\n  cam.setPosition(0, -400, z);\n\n  \/\/ Display the value of eyeZ, rounded to the nearest integer.\n  text(`eyeZ: ${round(cam.eyeZ)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1187,"description":"<p>The x-coordinate of the place where the camera looks.<\/p>\n<p>By default, the camera looks at the origin <code>(0, 0, 0)<\/code> in \"world\" space, so\n<code>myCamera.centerX<\/code> is 0.<\/p>\n","itemtype":"property","name":"centerX","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at (10, 20, -30).\n  cam.lookAt(10, 20, -30);\n\n  describe(\n    'A white cube on a gray background. The text \"centerX: 10\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of centerX, rounded to the nearest integer.\n  text(`centerX: ${round(cam.centerX)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right.\n  cam.setPosition(100, -400, 800);\n\n  \/\/ Point the camera at (10, 20, -30).\n  cam.lookAt(10, 20, -30);\n\n  describe(\n    'A white cube on a gray background. The cube appears to move left and right as the camera shifts its focus. The text \"centerX: X\" is written in black beneath the cube. X oscillates between -15 and 35.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the new x-coordinate.\n  let x = 25 * sin(frameCount * 0.01) + 10;\n\n  \/\/ Point the camera.\n  cam.lookAt(x, 20, -30);\n\n  \/\/ Display the value of centerX, rounded to the nearest integer.\n  text(`centerX: ${round(cam.centerX)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1300,"description":"<p>The y-coordinate of the place where the camera looks.<\/p>\n<p>By default, the camera looks at the origin <code>(0, 0, 0)<\/code> in \"world\" space, so\n<code>myCamera.centerY<\/code> is 0.<\/p>\n","itemtype":"property","name":"centerY","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at (10, 20, -30).\n  cam.lookAt(10, 20, -30);\n\n  describe(\n    'A white cube on a gray background. The text \"centerY: 20\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of centerY, rounded to the nearest integer.\n  text(`centerY: ${round(cam.centerY)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right.\n  cam.setPosition(100, -400, 800);\n\n  \/\/ Point the camera at (10, 20, -30).\n  cam.lookAt(10, 20, -30);\n\n  describe(\n    'A white cube on a gray background. The cube appears to move up and down as the camera shifts its focus. The text \"centerY: Y\" is written in black beneath the cube. Y oscillates between -5 and 45.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the new y-coordinate.\n  let y = 25 * sin(frameCount * 0.01) + 20;\n\n  \/\/ Point the camera.\n  cam.lookAt(10, y, -30);\n\n  \/\/ Display the value of centerY, rounded to the nearest integer.\n  text(`centerY: ${round(cam.centerY)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1413,"description":"<p>The y-coordinate of the place where the camera looks.<\/p>\n<p>By default, the camera looks at the origin <code>(0, 0, 0)<\/code> in \"world\" space, so\n<code>myCamera.centerZ<\/code> is 0.<\/p>\n","itemtype":"property","name":"centerZ","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at (10, 20, -30).\n  cam.lookAt(10, 20, -30);\n\n  describe(\n    'A white cube on a gray background. The text \"centerZ: -30\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of centerZ, rounded to the nearest integer.\n  text(`centerZ: ${round(cam.centerZ)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right.\n  cam.setPosition(100, -400, 800);\n\n  \/\/ Point the camera at (10, 20, -30).\n  cam.lookAt(10, 20, -30);\n\n  describe(\n    'A white cube on a gray background. The cube appears to move forward and back as the camera shifts its focus. The text \"centerZ: Z\" is written in black beneath the cube. Z oscillates between -55 and -25.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the new z-coordinate.\n  let z = 25 * sin(frameCount * 0.01) - 30;\n\n  \/\/ Point the camera.\n  cam.lookAt(10, 20, z);\n\n  \/\/ Display the value of centerZ, rounded to the nearest integer.\n  text(`centerZ: ${round(cam.centerZ)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1526,"description":"<p>The x-component of the camera's \"up\" vector.<\/p>\n<p>The camera's \"up\" vector orients its y-axis. By default, the \"up\" vector is\n<code>(0, 1, 0)<\/code>, so its x-component is 0 in \"local\" space.<\/p>\n","itemtype":"property","name":"upX","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right: (100, -400, 800)\n  \/\/ Point it at the origin: (0, 0, 0)\n  \/\/ Set its \"up\" vector: (0, 1, 0).\n  cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);\n\n  describe(\n    'A white cube on a gray background. The text \"upX: 0\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of upX, rounded to the nearest tenth.\n  text(`upX: ${round(cam.upX, 1)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right: (100, -400, 800)\n  \/\/ Point it at the origin: (0, 0, 0)\n  \/\/ Set its \"up\" vector: (0, 1, 0).\n  cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);\n\n  describe(\n    'A white cube on a gray background. The cube appears to rock back and forth. The text \"upX: X\" is written in black beneath it. X oscillates between -1 and 1.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the x-component.\n  let x = sin(frameCount * 0.01);\n\n  \/\/ Update the camera's \"up\" vector.\n  cam.camera(100, -400, 800, 0, 0, 0, x, 1, 0);\n\n  \/\/ Display the value of upX, rounded to the nearest tenth.\n  text(`upX: ${round(cam.upX, 1)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1637,"description":"<p>The y-component of the camera's \"up\" vector.<\/p>\n<p>The camera's \"up\" vector orients its y-axis. By default, the \"up\" vector is\n<code>(0, 1, 0)<\/code>, so its y-component is 1 in \"local\" space.<\/p>\n","itemtype":"property","name":"upY","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right: (100, -400, 800)\n  \/\/ Point it at the origin: (0, 0, 0)\n  \/\/ Set its \"up\" vector: (0, 1, 0).\n  cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);\n\n  describe(\n    'A white cube on a gray background. The text \"upY: 1\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of upY, rounded to the nearest tenth.\n  text(`upY: ${round(cam.upY, 1)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right: (100, -400, 800)\n  \/\/ Point it at the origin: (0, 0, 0)\n  \/\/ Set its \"up\" vector: (0, 1, 0).\n  cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);\n\n  describe(\n    'A white cube on a gray background. The cube flips upside-down periodically. The text \"upY: Y\" is written in black beneath it. Y oscillates between -1 and 1.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the y-component.\n  let y = sin(frameCount * 0.01);\n\n  \/\/ Update the camera's \"up\" vector.\n  cam.camera(100, -400, 800, 0, 0, 0, 0, y, 0);\n\n  \/\/ Display the value of upY, rounded to the nearest tenth.\n  text(`upY: ${round(cam.upY, 1)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1748,"description":"<p>The z-component of the camera's \"up\" vector.<\/p>\n<p>The camera's \"up\" vector orients its y-axis. By default, the \"up\" vector is\n<code>(0, 1, 0)<\/code>, so its z-component is 0 in \"local\" space.<\/p>\n","itemtype":"property","name":"upZ","type":"Number","readonly":"","example":["\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right: (100, -400, 800)\n  \/\/ Point it at the origin: (0, 0, 0)\n  \/\/ Set its \"up\" vector: (0, 1, 0).\n  cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);\n\n  describe(\n    'A white cube on a gray background. The text \"upZ: 0\" is written in black beneath it.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Display the value of upZ, rounded to the nearest tenth.\n  text(`upZ: ${round(cam.upZ, 1)}`, 0, 55);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet cam;\nlet font;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  font = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right: (100, -400, 800)\n  \/\/ Point it at the origin: (0, 0, 0)\n  \/\/ Set its \"up\" vector: (0, 1, 0).\n  cam.camera(100, -400, 800, 0, 0, 0, 0, 1, 0);\n\n  describe(\n    'A white cube on a gray background. The cube appears to rock back and forth. The text \"upZ: Z\" is written in black beneath it. Z oscillates between -1 and 1.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the box.\n  fill(255);\n\n  \/\/ Draw the box.\n  box();\n\n  \/\/ Style the text.\n  textAlign(CENTER);\n  textSize(16);\n  textFont(font);\n  fill(0);\n\n  \/\/ Calculate the z-component.\n  let z = sin(frameCount * 0.01);\n\n  \/\/ Update the camera's \"up\" vector.\n  cam.camera(100, -400, 800, 0, 0, 0, 0, 1, z);\n\n  \/\/ Display the value of upZ, rounded to the nearest tenth.\n  text(`upZ: ${round(cam.upZ, 1)}`, 0, 55);\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":1863,"description":"<p>Sets a perspective projection for the camera.<\/p>\n<p>In a perspective projection, shapes that are further from the camera appear\nsmaller than shapes that are near the camera. This technique, called\nforeshortening, creates realistic 3D scenes. It\u2019s applied by default in new\n<code>p5.Camera<\/code> objects.<\/p>\n<p><code>myCamera.perspective()<\/code> changes the camera\u2019s perspective by changing its\nviewing frustum. The frustum is the volume of space that\u2019s visible to the\ncamera. The frustum\u2019s shape is a pyramid with its top cut off. The camera\nis placed where the top of the pyramid should be and points towards the\nbase of the pyramid. It views everything within the frustum.<\/p>\n<p>The first parameter, <code>fovy<\/code>, is the camera\u2019s vertical field of view. It\u2019s\nan angle that describes how tall or narrow a view the camera has. For\nexample, calling <code>myCamera.perspective(0.5)<\/code> sets the camera\u2019s vertical\nfield of view to 0.5 radians. By default, <code>fovy<\/code> is calculated based on the\nsketch\u2019s height and the camera\u2019s default z-coordinate, which is 800. The\nformula for the default <code>fovy<\/code> is <code>2 * atan(height \/ 2 \/ 800)<\/code>.<\/p>\n<p>The second parameter, <code>aspect<\/code>, is the camera\u2019s aspect ratio. It\u2019s a number\nthat describes the ratio of the top plane\u2019s width to its height. For\nexample, calling <code>myCamera.perspective(0.5, 1.5)<\/code> sets the camera\u2019s field\nof view to 0.5 radians and aspect ratio to 1.5, which would make shapes\nappear thinner on a square canvas. By default, <code>aspect<\/code> is set to\n<code>width \/ height<\/code>.<\/p>\n<p>The third parameter, <code>near<\/code>, is the distance from the camera to the near\nplane. For example, calling <code>myCamera.perspective(0.5, 1.5, 100)<\/code> sets the\ncamera\u2019s field of view to 0.5 radians, its aspect ratio to 1.5, and places\nthe near plane 100 pixels from the camera. Any shapes drawn less than 100\npixels from the camera won\u2019t be visible. By default, <code>near<\/code> is set to\n<code>0.1 * 800<\/code>, which is 1\/10th the default distance between the camera and\nthe origin.<\/p>\n<p>The fourth parameter, <code>far<\/code>, is the distance from the camera to the far\nplane. For example, calling <code>myCamera.perspective(0.5, 1.5, 100, 10000)<\/code>\nsets the camera\u2019s field of view to 0.5 radians, its aspect ratio to 1.5,\nplaces the near plane 100 pixels from the camera, and places the far plane\n10,000 pixels from the camera. Any shapes drawn more than 10,000 pixels\nfrom the camera won\u2019t be visible. By default, <code>far<\/code> is set to <code>10 * 800<\/code>,\nwhich is 10 times the default distance between the camera and the origin.<\/p>\n","itemtype":"method","name":"perspective","params":[{"name":"fovy","description":"<p>camera frustum vertical field of view. Defaults to\n                          <code>2 * atan(height \/ 2 \/ 800)<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"aspect","description":"<p>camera frustum aspect ratio. Defaults to\n                          <code>width \/ height<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"near","description":"<p>distance from the camera to the near clipping plane.\n                          Defaults to <code>0.1 * 800<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"far","description":"<p>distance from the camera to the far clipping plane.\n                          Defaults to <code>10 * 800<\/code>.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Place it at the top-right.\n  cam2.camera(400, -400, 800);\n\n  \/\/ Set its fovy to 0.2.\n  \/\/ Set its aspect to 1.5.\n  \/\/ Set its near to 600.\n  \/\/ Set its far to 1200.\n  cam2.perspective(0.2, 1.5, 600, 1200);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe('A white cube on a gray background. The camera toggles between a frontal view and a skewed aerial view when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Place it at the top-right.\n  cam2.camera(400, -400, 800);\n\n  \/\/ Set its fovy to 0.2.\n  \/\/ Set its aspect to 1.5.\n  \/\/ Set its near to 600.\n  \/\/ Set its far to 1200.\n  cam2.perspective(0.2, 1.5, 600, 1200);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe('A white cube moves left and right on a gray background. The camera toggles between a frontal and a skewed aerial view when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin left and right.\n  let x = 100 * sin(frameCount * 0.01);\n  translate(x, 0, 0);\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":2086,"description":"<p>Sets an orthographic projection for the camera.<\/p>\n<p>In an orthographic projection, shapes with the same size always appear the\nsame size, regardless of whether they are near or far from the camera.<\/p>\n<p><code>myCamera.ortho()<\/code> changes the camera\u2019s perspective by changing its viewing\nfrustum from a truncated pyramid to a rectangular prism. The frustum is the\nvolume of space that\u2019s visible to the camera. The camera is placed in front\nof the frustum and views everything within the frustum. <code>myCamera.ortho()<\/code>\nhas six optional parameters to define the viewing frustum.<\/p>\n<p>The first four parameters, <code>left<\/code>, <code>right<\/code>, <code>bottom<\/code>, and <code>top<\/code>, set the\ncoordinates of the frustum\u2019s sides, bottom, and top. For example, calling\n<code>myCamera.ortho(-100, 100, 200, -200)<\/code> creates a frustum that\u2019s 200 pixels\nwide and 400 pixels tall. By default, these dimensions are set based on\nthe sketch\u2019s width and height, as in\n<code>myCamera.ortho(-width \/ 2, width \/ 2, -height \/ 2, height \/ 2)<\/code>.<\/p>\n<p>The last two parameters, <code>near<\/code> and <code>far<\/code>, set the distance of the\nfrustum\u2019s near and far plane from the camera. For example, calling\n<code>myCamera.ortho(-100, 100, 200, -200, 50, 1000)<\/code> creates a frustum that\u2019s\n200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and\nends 1,000 pixels from the camera. By default, <code>near<\/code> and <code>far<\/code> are set to\n0 and <code>max(width, height) + 800<\/code>, respectively.<\/p>\n","itemtype":"method","name":"ortho","params":[{"name":"left","description":"<p>x-coordinate of the frustum\u2019s left plane. Defaults to <code>-width \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"right","description":"<p>x-coordinate of the frustum\u2019s right plane. Defaults to <code>width \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"bottom","description":"<p>y-coordinate of the frustum\u2019s bottom plane. Defaults to <code>height \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"top","description":"<p>y-coordinate of the frustum\u2019s top plane. Defaults to <code>-height \/ 2<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"near","description":"<p>z-coordinate of the frustum\u2019s near plane. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"far","description":"<p>z-coordinate of the frustum\u2019s far plane. Defaults to <code>max(width, height) + 800<\/code>.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Apply an orthographic projection.\n  cam2.ortho();\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe('A row of white cubes against a gray background. The camera toggles between a perspective and an orthographic projection when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 500);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Apply an orthographic projection.\n  cam2.ortho();\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe('A row of white cubes slither like a snake against a gray background. The camera toggles between a perspective and an orthographic projection when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 500);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    push();\n    \/\/ Calculate the box's coordinates.\n    let x = 10 * sin(frameCount * 0.02 + i * 0.6);\n    let z = -40 * i;\n    \/\/ Translate the origin.\n    translate(x, 0, z);\n    \/\/ Draw the box.\n    box(10);\n    pop();\n  }\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":2274,"description":"<p>Sets the camera's frustum.<\/p>\n<p>In a frustum projection, shapes that are further from the camera appear\nsmaller than shapes that are near the camera. This technique, called\nforeshortening, creates realistic 3D scenes.<\/p>\n<p><code>myCamera.frustum()<\/code> changes the camera\u2019s perspective by changing its\nviewing frustum. The frustum is the volume of space that\u2019s visible to the\ncamera. The frustum\u2019s shape is a pyramid with its top cut off. The camera\nis placed where the top of the pyramid should be and points towards the\nbase of the pyramid. It views everything within the frustum.<\/p>\n<p>The first four parameters, <code>left<\/code>, <code>right<\/code>, <code>bottom<\/code>, and <code>top<\/code>, set the\ncoordinates of the frustum\u2019s sides, bottom, and top. For example, calling\n<code>myCamera.frustum(-100, 100, 200, -200)<\/code> creates a frustum that\u2019s 200\npixels wide and 400 pixels tall. By default, these coordinates are set\nbased on the sketch\u2019s width and height, as in\n<code>myCamera.frustum(-width \/ 20, width \/ 20, height \/ 20, -height \/ 20)<\/code>.<\/p>\n<p>The last two parameters, <code>near<\/code> and <code>far<\/code>, set the distance of the\nfrustum\u2019s near and far plane from the camera. For example, calling\n<code>myCamera.frustum(-100, 100, 200, -200, 50, 1000)<\/code> creates a frustum that\u2019s\n200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and ends\n1,000 pixels from the camera. By default, near is set to <code>0.1 * 800<\/code>, which\nis 1\/10th the default distance between the camera and the origin. <code>far<\/code> is\nset to <code>10 * 800<\/code>, which is 10 times the default distance between the\ncamera and the origin.<\/p>\n","itemtype":"method","name":"frustum","params":[{"name":"left","description":"<p>x-coordinate of the frustum\u2019s left plane. Defaults to <code>-width \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"right","description":"<p>x-coordinate of the frustum\u2019s right plane. Defaults to <code>width \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"bottom","description":"<p>y-coordinate of the frustum\u2019s bottom plane. Defaults to <code>height \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"top","description":"<p>y-coordinate of the frustum\u2019s top plane. Defaults to <code>-height \/ 20<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"near","description":"<p>z-coordinate of the frustum\u2019s near plane. Defaults to <code>0.1 * 800<\/code>.<\/p>\n","type":"Number","optional":true},{"name":"far","description":"<p>z-coordinate of the frustum\u2019s far plane. Defaults to <code>10 * 800<\/code>.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Adjust the frustum.\n  \/\/ Center it.\n  \/\/ Set its width and height to 20 pixels.\n  \/\/ Place its near plane 300 pixels from the camera.\n  \/\/ Place its far plane 350 pixels from the camera.\n  cam2.frustum(-10, 10, -10, 10, 300, 350);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe(\n    'A row of white cubes against a gray background. The camera zooms in on one cube when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 600);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -40);\n    box(10);\n  }\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":2472,"description":"<p>Rotates the camera in a clockwise\/counter-clockwise direction.<\/p>\n<p>Rolling rotates the camera without changing its orientation. The rotation\nhappens in the camera\u2019s \"local\" space.<\/p>\n<p>The parameter, <code>angle<\/code>, is the angle the camera should rotate. Passing a\npositive angle, as in <code>myCamera.roll(0.001)<\/code>, rotates the camera in counter-clockwise direction.\nPassing a negative angle, as in <code>myCamera.roll(-0.001)<\/code>, rotates the\ncamera in clockwise direction.<\/p>\n<p>Note: Angles are interpreted based on the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","itemtype":"method","name":"roll","params":[{"name":"angle","description":"<p>amount to rotate camera in current\n<a href=\"#\/p5\/angleMode\">angleMode<\/a> units.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet cam;\nlet delta = 0.01;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n  normalMaterial();\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Roll camera according to angle 'delta'\n  cam.roll(delta);\n\n  translate(0, 0, 0);\n  box(20);\n  translate(0, 25, 0);\n  box(20);\n  translate(0, 26, 0);\n  box(20);\n  translate(0, 27, 0);\n  box(20);\n  translate(0, 28, 0);\n  box(20);\n  translate(0,29, 0);\n  box(20);\n  translate(0, 30, 0);\n  box(20);\n}\n<\/code>\n<\/div>"],"alt":"camera view rotates in counter clockwise direction with vertically stacked boxes in front of it.","class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":2550,"description":"<p>Rotates the camera left and right.<\/p>\n<p>Panning rotates the camera without changing its position. The rotation\nhappens in the camera\u2019s \"local\" space.<\/p>\n<p>The parameter, <code>angle<\/code>, is the angle the camera should rotate. Passing a\npositive angle, as in <code>myCamera.pan(0.001)<\/code>, rotates the camera to the\nright. Passing a negative angle, as in <code>myCamera.pan(-0.001)<\/code>, rotates the\ncamera to the left.<\/p>\n<p>Note: Angles are interpreted based on the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","itemtype":"method","name":"pan","params":[{"name":"angle","description":"<p>amount to rotate in the current\n                      <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet cam;\nlet delta = 0.001;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The cube goes in and out of view as the camera pans left and right.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Pan with the camera.\n  cam.pan(delta);\n\n  \/\/ Switch directions every 120 frames.\n  if (frameCount % 120 === 0) {\n    delta *= -1;\n  }\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":2613,"description":"<p>Rotates the camera up and down.<\/p>\n<p>Tilting rotates the camera without changing its position. The rotation\nhappens in the camera\u2019s \"local\" space.<\/p>\n<p>The parameter, <code>angle<\/code>, is the angle the camera should rotate. Passing a\npositive angle, as in <code>myCamera.tilt(0.001)<\/code>, rotates the camera down.\nPassing a negative angle, as in <code>myCamera.tilt(-0.001)<\/code>, rotates the camera\nup.<\/p>\n<p>Note: Angles are interpreted based on the current\n<a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","itemtype":"method","name":"tilt","params":[{"name":"angle","description":"<p>amount to rotate in the current\n                      <a href=\"#\/p5\/angleMode\">angleMode()<\/a>.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet cam;\nlet delta = 0.001;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube on a gray background. The cube goes in and out of view as the camera tilts up and down.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Pan with the camera.\n  cam.tilt(delta);\n\n  \/\/ Switch directions every 120 frames.\n  if (frameCount % 120 === 0) {\n    delta *= -1;\n  }\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":2676,"description":"<p>Points the camera at a location.<\/p>\n<p><code>myCamera.lookAt()<\/code> changes the camera\u2019s orientation without changing its\nposition.<\/p>\n<p>The parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, are the coordinates in \"world\" space\nwhere the camera should point. For example, calling\n<code>myCamera.lookAt(10, 20, 30)<\/code> points the camera at the coordinates\n<code>(10, 20, 30)<\/code>.<\/p>\n","itemtype":"method","name":"lookAt","params":[{"name":"x","description":"<p>x-coordinate of the position where the camera should look in \"world\" space.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the position where the camera should look in \"world\" space.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z-coordinate of the position where the camera should look in \"world\" space.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\n\/\/ Double-click to look at a different cube.\n\nlet cam;\nlet isLookingLeft = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Camera object.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-center.\n  cam.setPosition(0, -400, 800);\n\n  \/\/ Point the camera at the origin.\n  cam.lookAt(-30, 0, 0);\n\n  describe(\n    'A red cube and a blue cube on a gray background. The camera switches focus between the cubes when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the box on the left.\n  push();\n  \/\/ Translate the origin to the left.\n  translate(-30, 0, 0);\n  \/\/ Style the box.\n  fill(255, 0, 0);\n  \/\/ Draw the box.\n  box(20);\n  pop();\n\n  \/\/ Draw the box on the right.\n  push();\n  \/\/ Translate the origin to the right.\n  translate(30, 0, 0);\n  \/\/ Style the box.\n  fill(0, 0, 255);\n  \/\/ Draw the box.\n  box(20);\n  pop();\n}\n\n\/\/ Change the camera's focus when the user double-clicks.\nfunction doubleClicked() {\n  if (isLookingLeft === true) {\n    cam.lookAt(30, 0, 0);\n    isLookingLeft = false;\n  } else {\n    cam.lookAt(-30, 0, 0);\n    isLookingLeft = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":2773,"description":"<p>Sets the position and orientation of the camera.<\/p>\n<p><code>myCamera.camera()<\/code> allows objects to be viewed from different angles. It\nhas nine parameters that are all optional.<\/p>\n<p>The first three parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, are the coordinates of the\ncamera\u2019s position in \"world\" space. For example, calling\n<code>myCamera.camera(0, 0, 0)<\/code> places the camera at the origin <code>(0, 0, 0)<\/code>. By\ndefault, the camera is placed at <code>(0, 0, 800)<\/code>.<\/p>\n<p>The next three parameters, <code>centerX<\/code>, <code>centerY<\/code>, and <code>centerZ<\/code> are the\ncoordinates of the point where the camera faces in \"world\" space. For\nexample, calling <code>myCamera.camera(0, 0, 0, 10, 20, 30)<\/code> places the camera\nat the origin <code>(0, 0, 0)<\/code> and points it at <code>(10, 20, 30)<\/code>. By default, the\ncamera points at the origin <code>(0, 0, 0)<\/code>.<\/p>\n<p>The last three parameters, <code>upX<\/code>, <code>upY<\/code>, and <code>upZ<\/code> are the components of\nthe \"up\" vector in \"local\" space. The \"up\" vector orients the camera\u2019s\ny-axis. For example, calling\n<code>myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0)<\/code> places the camera at the\norigin <code>(0, 0, 0)<\/code>, points it at <code>(10, 20, 30)<\/code>, and sets the \"up\" vector\nto <code>(0, -1, 0)<\/code> which is like holding it upside-down. By default, the \"up\"\nvector is <code>(0, 1, 0)<\/code>.<\/p>\n","itemtype":"method","name":"camera","params":[{"name":"x","description":"<p>x-coordinate of the camera. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"y","description":"<p>y-coordinate of the camera. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"z","description":"<p>z-coordinate of the camera. Defaults to 800.<\/p>\n","type":"Number","optional":true},{"name":"centerX","description":"<p>x-coordinate of the point the camera faces. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"centerY","description":"<p>y-coordinate of the point the camera faces. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"centerZ","description":"<p>z-coordinate of the point the camera faces. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"upX","description":"<p>x-component of the camera\u2019s \"up\" vector. Defaults to 0.<\/p>\n","type":"Number","optional":true},{"name":"upY","description":"<p>x-component of the camera\u2019s \"up\" vector. Defaults to 1.<\/p>\n","type":"Number","optional":true},{"name":"upZ","description":"<p>z-component of the camera\u2019s \"up\" vector. Defaults to 0.<\/p>\n","type":"Number","optional":true}],"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Place it at the top-right: (1200, -600, 100)\n  \/\/ Point it at the row of boxes: (-10, -10, 400)\n  \/\/ Set its \"up\" vector to the default: (0, 1, 0)\n  cam2.camera(1200, -600, 100, -10, -10, 400, 0, 1, 0);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe(\n    'A row of white cubes against a gray background. The camera toggles between a frontal and an aerial view when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 500);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -30);\n    box(10);\n  }\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Place it at the right: (1200, 0, 100)\n  \/\/ Point it at the row of boxes: (-10, -10, 400)\n  \/\/ Set its \"up\" vector to the default: (0, 1, 0)\n  cam2.camera(1200, 0, 100, -10, -10, 400, 0, 1, 0);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe(\n    'A row of white cubes against a gray background. The camera toggles between a static frontal view and an orbiting view when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Update cam2's position.\n  let x = 1200 * cos(frameCount * 0.01);\n  let y = -600 * sin(frameCount * 0.01);\n  cam2.camera(x, y, 100, -10, -10, 400, 0, 1, 0);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 500);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -30);\n    box(10);\n  }\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":3001,"description":"<p>Moves the camera along its \"local\" axes without changing its orientation.<\/p>\n<p>The parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, are the distances the camera should\nmove. For example, calling <code>myCamera.move(10, 20, 30)<\/code> moves the camera 10\npixels to the right, 20 pixels down, and 30 pixels backward in its \"local\"\nspace.<\/p>\n","itemtype":"method","name":"move","params":[{"name":"x","description":"<p>distance to move along the camera\u2019s \"local\" x-axis.<\/p>\n","type":"Number"},{"name":"y","description":"<p>distance to move along the camera\u2019s \"local\" y-axis.<\/p>\n","type":"Number"},{"name":"z","description":"<p>distance to move along the camera\u2019s \"local\" z-axis.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\n\/\/ Click the canvas to begin detecting key presses.\n\nlet cam;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam = createCamera();\n\n  \/\/ Place the camera at the top-right.\n  cam.setPosition(400, -400, 800);\n\n  \/\/ Point it at the origin.\n  cam.lookAt(0, 0, 0);\n\n  describe(\n    'A white cube drawn against a gray background. The cube appears to move when the user presses certain keys.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Move the camera along its \"local\" axes\n  \/\/ when the user presses certain keys.\n  if (keyIsPressed === true) {\n\n    \/\/ Move horizontally.\n    if (keyCode === LEFT_ARROW) {\n      cam.move(-1, 0, 0);\n    }\n    if (keyCode === RIGHT_ARROW) {\n      cam.move(1, 0, 0);\n    }\n\n    \/\/ Move vertically.\n    if (keyCode === UP_ARROW) {\n      cam.move(0, -1, 0);\n    }\n    if (keyCode === DOWN_ARROW) {\n      cam.move(0, 1, 0);\n    }\n\n    \/\/ Move in\/out of the screen.\n    if (key === 'i') {\n      cam.move(0, 0, -1);\n    }\n    if (key === 'o') {\n      cam.move(0, 0, 1);\n    }\n  }\n\n  \/\/ Draw the box.\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":3098,"description":"<p>Sets the camera\u2019s position in \"world\" space without changing its\norientation.<\/p>\n<p>The parameters, <code>x<\/code>, <code>y<\/code>, and <code>z<\/code>, are the coordinates where the camera\nshould be placed. For example, calling <code>myCamera.setPosition(10, 20, 30)<\/code>\nplaces the camera at coordinates <code>(10, 20, 30)<\/code> in \"world\" space.<\/p>\n","itemtype":"method","name":"setPosition","params":[{"name":"x","description":"<p>x-coordinate in \"world\" space.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate in \"world\" space.<\/p>\n","type":"Number"},{"name":"z","description":"<p>z-coordinate in \"world\" space.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Place it closer to the origin.\n  cam2.setPosition(0, 0, 600);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe(\n    'A row of white cubes against a gray background. The camera toggles the amount of zoom when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 500);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -30);\n    box(10);\n  }\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet isDefaultCamera = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Place it closer to the origin.\n  cam2.setPosition(0, 0, 600);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe(\n    'A row of white cubes against a gray background. The camera toggles between a static view and a view that zooms in and out when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Update cam2's z-coordinate.\n  let z = 100 * sin(frameCount * 0.01) + 700;\n  cam2.setPosition(0, 0, z);\n\n  \/\/ Translate the origin toward the camera.\n  translate(-10, 10, 500);\n\n  \/\/ Rotate the coordinate system.\n  rotateY(-0.1);\n  rotateX(-0.1);\n\n  \/\/ Draw the row of boxes.\n  for (let i = 0; i < 6; i += 1) {\n    translate(0, 0, -30);\n    box(10);\n  }\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (isDefaultCamera === true) {\n    setCamera(cam2);\n    isDefaultCamera = false;\n  } else {\n    setCamera(cam1);\n    isDefaultCamera = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":3252,"description":"<p>Sets the camera\u2019s position, orientation, and projection by copying another\ncamera.<\/p>\n<p>The parameter, <code>cam<\/code>, is the <code>p5.Camera<\/code> object to copy. For example, calling\n<code>cam2.set(cam1)<\/code> will set <code>cam2<\/code> using <code>cam1<\/code>\u2019s configuration.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"cam","description":"<p>camera to copy.<\/p>\n","type":"p5.Camera"}],"example":["\n<div>\n<code>\n\/\/ Double-click to \"reset\" the camera zoom.\n\nlet cam1;\nlet cam2;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  cam1 = createCamera();\n\n  \/\/ Place the camera at the top-right.\n  cam1.setPosition(400, -400, 800);\n\n  \/\/ Point it at the origin.\n  cam1.lookAt(0, 0, 0);\n\n  \/\/ Create the second camera.\n  cam2 = createCamera();\n\n  \/\/ Copy cam1's configuration.\n  cam2.set(cam1);\n\n  describe(\n    'A white cube drawn against a gray background. The camera slowly moves forward. The camera resets when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Update cam2's position.\n  cam2.move(0, 0, -1);\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ \"Reset\" the camera when the user double-clicks.\nfunction doubleClicked() {\n  cam2.set(cam1);\n}"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":3329,"description":"<p>Sets the camera\u2019s position and orientation to values that are in-between\nthose of two other cameras.<\/p>\n<p><code>myCamera.slerp()<\/code> uses spherical linear interpolation to calculate a\nposition and orientation that\u2019s in-between two other cameras. Doing so is\nhelpful for transitioning smoothly between two perspectives.<\/p>\n<p>The first two parameters, <code>cam0<\/code> and <code>cam1<\/code>, are the <code>p5.Camera<\/code> objects\nthat should be used to set the current camera.<\/p>\n<p>The third parameter, <code>amt<\/code>, is the amount to interpolate between <code>cam0<\/code> and\n<code>cam1<\/code>. 0.0 keeps the camera\u2019s position and orientation equal to <code>cam0<\/code>\u2019s,\n0.5 sets them halfway between <code>cam0<\/code>\u2019s and <code>cam1<\/code>\u2019s , and 1.0 sets the\nposition and orientation equal to <code>cam1<\/code>\u2019s.<\/p>\n<p>For example, calling <code>myCamera.slerp(cam0, cam1, 0.1)<\/code> sets cam\u2019s position\nand orientation very close to <code>cam0<\/code>\u2019s. Calling\n<code>myCamera.slerp(cam0, cam1, 0.9)<\/code> sets cam\u2019s position and orientation very\nclose to <code>cam1<\/code>\u2019s.<\/p>\n<p>Note: All of the cameras must use the same projection.<\/p>\n","itemtype":"method","name":"slerp","params":[{"name":"cam0","description":"<p>first camera.<\/p>\n","type":"p5.Camera"},{"name":"cam1","description":"<p>second camera.<\/p>\n","type":"p5.Camera"},{"name":"amt","description":"<p>amount of interpolation between 0.0 (<code>cam0<\/code>) and 1.0 (<code>cam1<\/code>).<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet cam;\nlet cam0;\nlet cam1;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the main camera.\n  \/\/ Keep its default settings.\n  cam = createCamera();\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam0 = createCamera();\n\n  \/\/ Create the second camera.\n  cam1 = createCamera();\n\n  \/\/ Place it at the top-right.\n  cam1.setPosition(400, -400, 800);\n\n  \/\/ Point it at the origin.\n  cam1.lookAt(0, 0, 0);\n\n  \/\/ Set the current camera to cam.\n  setCamera(cam);\n\n  describe('A white cube drawn against a gray background. The camera slowly oscillates between a frontal view and an aerial view.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Calculate the amount to interpolate between cam0 and cam1.\n  let amt = 0.5 * sin(frameCount * 0.01) + 0.5;\n\n  \/\/ Update the main camera's position and orientation.\n  cam.slerp(cam0, cam1, amt);\n\n  box();\n}\n<\/code>\n<\/div>"],"class":"p5.Camera","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Camera.js","line":3897,"description":"<p>Sets the current (active) camera of a 3D sketch.<\/p>\n<p><code>setCamera()<\/code> allows for switching between multiple cameras created with\n<a href=\"#\/p5\/createCamera\">createCamera()<\/a>.<\/p>\n<p>Note: <code>setCamera()<\/code> can only be used in WebGL mode.<\/p>\n","itemtype":"method","name":"setCamera","params":[{"name":"cam","description":"<p>camera that should be made active.<\/p>\n","type":"p5.Camera"}],"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet cam1;\nlet cam2;\nlet usingCam1 = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = createCamera();\n\n  \/\/ Create the second camera.\n  \/\/ Place it at the top-left.\n  \/\/ Point it at the origin.\n  cam2 = createCamera();\n  cam2.setPosition(400, -400, 800);\n  cam2.lookAt(0, 0, 0);\n\n  \/\/ Set the current camera to cam1.\n  setCamera(cam1);\n\n  describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the box.\n  box();\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (usingCam1 === true) {\n    setCamera(cam2);\n    usingCam1 = false;\n  } else {\n    setCamera(cam1);\n    usingCam1 = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5","module":"3D","submodule":"Camera"},{"file":"src\/webgl\/p5.Framebuffer.js","line":111,"description":"<p>An array containing the color of each pixel in the framebuffer.<\/p>\n<p><a href=\"#\/p5.Framebuffer\/loadPixels\">myBuffer.loadPixels()<\/a> must be\ncalled before accessing the <code>myBuffer.pixels<\/code> array.\n<a href=\"#\/p5.Framebuffer\/updatePixels\">myBuffer.updatePixels()<\/a>\nmust be called after any changes are made.<\/p>\n<p>Note: Updating pixels via this property is slower than drawing to the\nframebuffer directly. Consider using a\n<a href=\"#\/p5.Shader\">p5.Shader<\/a> object instead of looping over\n<code>myBuffer.pixels<\/code>.<\/p>\n","itemtype":"property","name":"pixels","type":"Number[]","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Framebuffer object.\n  let myBuffer = createFramebuffer();\n\n  \/\/ Load the pixels array.\n  myBuffer.loadPixels();\n\n  \/\/ Get the number of pixels in the\n  \/\/ top half of the framebuffer.\n  let numPixels = myBuffer.pixels.length \/ 2;\n\n  \/\/ Set the framebuffer's top half to pink.\n  for (let i = 0; i < numPixels; i += 4) {\n    myBuffer.pixels[i] = 255;\n    myBuffer.pixels[i + 1] = 102;\n    myBuffer.pixels[i + 2] = 204;\n    myBuffer.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the pixels array.\n  myBuffer.updatePixels();\n\n  \/\/ Draw the p5.Framebuffer object to the canvas.\n  image(myBuffer, -50, -50);\n\n  describe('A pink rectangle above a gray rectangle.');\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":238,"description":"<p>Resizes the framebuffer to a given width and height.<\/p>\n<p>The parameters, <code>width<\/code> and <code>height<\/code>, set the dimensions of the\nframebuffer. For example, calling <code>myBuffer.resize(300, 500)<\/code> resizes\nthe framebuffer to 300\u00d7500 pixels, then sets <code>myBuffer.width<\/code> to 300\nand <code>myBuffer.height<\/code> 500.<\/p>\n","itemtype":"method","name":"resize","params":[{"name":"width","description":"<p>width of the framebuffer.<\/p>\n","type":"Number"},{"name":"height","description":"<p>height of the framebuffer.<\/p>\n","type":"Number"}],"example":["\n<div>\n<code>\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  describe('A multicolor sphere on a white surface. The image grows larger or smaller when the user moves the mouse, revealing a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw to the p5.Framebuffer object.\n  myBuffer.begin();\n  background(255);\n  normalMaterial();\n  sphere(20);\n  myBuffer.end();\n\n  \/\/ Display the p5.Framebuffer object.\n  image(myBuffer, -50, -50);\n}\n\n\/\/ Resize the p5.Framebuffer object when the\n\/\/ user moves the mouse.\nfunction mouseMoved() {\n  myBuffer.resize(mouseX, mouseY);\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":297,"description":"<p>Sets the framebuffer's pixel density or returns its current density.<\/p>\n<p>Computer displays are grids of little lights called pixels. A display's\npixel density describes how many pixels it packs into an area. Displays\nwith smaller pixels have a higher pixel density and create sharper\nimages.<\/p>\n<p>The parameter, <code>density<\/code>, is optional. If a number is passed, as in\n<code>myBuffer.pixelDensity(1)<\/code>, it sets the framebuffer's pixel density. By\ndefault, the framebuffer's pixel density will match that of the canvas\nwhere it was created. All canvases default to match the display's pixel\ndensity.<\/p>\n<p>Calling <code>myBuffer.pixelDensity()<\/code> without an argument returns its current\npixel density.<\/p>\n","itemtype":"method","name":"pixelDensity","params":[{"name":"density","description":"<p>pixel density to set.<\/p>\n","type":"Number","optional":true}],"return":{"description":"current pixel density.","type":"Number"},"example":["\n<div>\n<code>\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  describe(\"A white circle on a gray canvas. The circle's edge become fuzzy while the user presses and holds the mouse.\");\n}\n\nfunction draw() {\n  \/\/ Draw to the p5.Framebuffer object.\n  myBuffer.begin();\n  background(200);\n  circle(0, 0, 40);\n  myBuffer.end();\n\n  \/\/ Display the p5.Framebuffer object.\n  image(myBuffer, -50, -50);\n}\n\n\/\/ Decrease the pixel density when the user\n\/\/ presses the mouse.\nfunction mousePressed() {\n  myBuffer.pixelDensity(1);\n}\n\n\/\/ Increase the pixel density when the user\n\/\/ releases the mouse.\nfunction mouseReleased() {\n  myBuffer.pixelDensity(2);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\nlet myBuffer;\nlet myFont;\n\n\/\/ Load a font and create a p5.Font object.\nfunction preload() {\n  myFont = loadFont('assets\/inconsolata.otf');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  \/\/ Get the p5.Framebuffer object's pixel density.\n  let d = myBuffer.pixelDensity();\n\n  \/\/ Style the text.\n  textAlign(CENTER, CENTER);\n  textFont(myFont);\n  textSize(16);\n  fill(0);\n\n  \/\/ Display the pixel density.\n  text(`Density: ${d}`, 0, 0);\n\n  describe(`The text \"Density: ${d}\" written in black on a gray background.`);\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":402,"description":"<p>Toggles the framebuffer's autosizing mode or returns the current mode.<\/p>\n<p>By default, the framebuffer automatically resizes to match the canvas\nthat created it. Calling <code>myBuffer.autoSized(false)<\/code> disables this\nbehavior and calling <code>myBuffer.autoSized(true)<\/code> re-enables it.<\/p>\n<p>Calling <code>myBuffer.autoSized()<\/code> without an argument returns <code>true<\/code> if\nthe framebuffer automatically resizes and <code>false<\/code> if not.<\/p>\n","itemtype":"method","name":"autoSized","params":[{"name":"autoSized","description":"<p>whether to automatically resize the framebuffer to match the canvas.<\/p>\n","type":"Boolean","optional":true}],"return":{"description":"current autosize setting.","type":"Boolean"},"example":["\n<div>\n<code>\n\/\/ Double-click to toggle the autosizing mode.\n\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  describe('A multicolor sphere on a gray background. The image resizes when the user moves the mouse.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Draw to the p5.Framebuffer object.\n  myBuffer.begin();\n  background(200);\n  normalMaterial();\n  sphere(width \/ 4);\n  myBuffer.end();\n\n  \/\/ Display the p5.Framebuffer object.\n  image(myBuffer, -width \/ 2, -height \/ 2);\n}\n\n\/\/ Resize the canvas when the user moves the mouse.\nfunction mouseMoved() {\n  let w = constrain(mouseX, 0, 100);\n  let h = constrain(mouseY, 0, 100);\n  resizeCanvas(w, h);\n}\n\n\/\/ Toggle autoSizing when the user double-clicks.\n\/\/ Note: opened an issue to fix(?) this.\nfunction doubleClicked() {\n  let isAuto = myBuffer.autoSized();\n  myBuffer.autoSized(!isAuto);\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":892,"description":"<p>Creates a new\n<a href=\"#\/p5.Camera\">p5.Camera<\/a> object to use with the framebuffer.<\/p>\n<p>The new camera is initialized with a default position <code>(0, 0, 800)<\/code> and a\ndefault perspective projection. Its properties can be controlled with\n<a href=\"#\/p5.Camera\">p5.Camera<\/a> methods such as <code>myCamera.lookAt(0, 0, 0)<\/code>.<\/p>\n<p>Framebuffer cameras should be created between calls to\n<a href=\"#\/p5.Framebuffer\/begin\">myBuffer.begin()<\/a> and\n<a href=\"#\/p5.Framebuffer\/end\">myBuffer.end()<\/a> like so:<\/p>\n<pre><code class=\"language-js\">let myCamera;\n\nmyBuffer.begin();\n\n\/\/ Create the camera for the framebuffer.\nmyCamera = myBuffer.createCamera();\n\nmyBuffer.end();\n<\/code><\/pre>\n<p>Calling <a href=\"#\/p5\/setCamera\">setCamera()<\/a> updates the\nframebuffer's projection using the camera.\n<a href=\"#\/p5\/resetMatrix\">resetMatrix()<\/a> must also be called for the\nview to change properly:<\/p>\n<pre><code class=\"language-js\">myBuffer.begin();\n\n\/\/ Set the camera for the framebuffer.\nsetCamera(myCamera);\n\n\/\/ Reset all transformations.\nresetMatrix();\n\n\/\/ Draw stuff...\n\nmyBuffer.end();\n<\/code><\/pre>\n","itemtype":"method","name":"createCamera","return":{"description":"new camera.","type":"p5.Camera"},"example":["\n<div>\n<code>\n\/\/ Double-click to toggle between cameras.\n\nlet myBuffer;\nlet cam1;\nlet cam2;\nlet usingCam1 = true;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  \/\/ Create the cameras between begin() and end().\n  myBuffer.begin();\n\n  \/\/ Create the first camera.\n  \/\/ Keep its default settings.\n  cam1 = myBuffer.createCamera();\n\n  \/\/ Create the second camera.\n  \/\/ Place it at the top-left.\n  \/\/ Point it at the origin.\n  cam2 = myBuffer.createCamera();\n  cam2.setPosition(400, -400, 800);\n  cam2.lookAt(0, 0, 0);\n\n  myBuffer.end();\n\n  describe(\n    'A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'\n  );\n}\n\nfunction draw() {\n  \/\/ Draw to the p5.Framebuffer object.\n  myBuffer.begin();\n  background(200);\n\n  \/\/ Set the camera.\n  if (usingCam1 === true) {\n    setCamera(cam1);\n  } else {\n    setCamera(cam2);\n  }\n\n  \/\/ Reset all transformations.\n  resetMatrix();\n\n  \/\/ Draw the box.\n  box();\n\n  myBuffer.end();\n\n  \/\/ Display the p5.Framebuffer object.\n  image(myBuffer, -50, -50);\n}\n\n\/\/ Toggle the current camera when the user double-clicks.\nfunction doubleClicked() {\n  if (usingCam1 === true) {\n    usingCam1 = false;\n  } else {\n    usingCam1 = true;\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1031,"description":"<p>Deletes the framebuffer from GPU memory.<\/p>\n<p>Calling <code>myBuffer.remove()<\/code> frees the GPU memory used by the framebuffer.\nThe framebuffer also uses a bit of memory on the CPU which can be freed\nlike so:<\/p>\n<pre><code class=\"language-js\">\/\/ Delete the framebuffer from GPU memory.\nmyBuffer.remove();\n\n\/\/ Delete the framebuffer from CPU memory.\nmyBuffer = undefined;\n<\/code><\/pre>\n<p>Note: All variables that reference the framebuffer must be assigned\nthe value <code>undefined<\/code> to delete the framebuffer from CPU memory. If any\nvariable still refers to the framebuffer, then it won't be garbage\ncollected.<\/p>\n","itemtype":"method","name":"remove","example":["\n<div>\n<code>\n\/\/ Double-click to remove the p5.Framebuffer object.\n\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create an options object.\n  let options = { width: 60, height: 60 };\n\n  \/\/ Create a p5.Framebuffer object and\n  \/\/ configure it using options.\n  myBuffer = createFramebuffer(options);\n\n  describe('A white circle at the center of a dark gray square disappears when the user double-clicks.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Display the p5.Framebuffer object if\n  \/\/ it's available.\n  if (myBuffer) {\n    \/\/ Draw to the p5.Framebuffer object.\n    myBuffer.begin();\n    background(100);\n    circle(0, 0, 20);\n    myBuffer.end();\n\n    image(myBuffer, -30, -30);\n  }\n}\n\n\/\/ Remove the p5.Framebuffer object when the\n\/\/ the user double-clicks.\nfunction doubleClicked() {\n  \/\/ Delete the framebuffer from GPU memory.\n  myBuffer.remove();\n\n  \/\/ Delete the framebuffer from CPU memory.\n  myBuffer = undefined;\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1118,"description":"<p>Begins drawing shapes to the framebuffer.<\/p>\n<p><code>myBuffer.begin()<\/code> and <a href=\"#\/p5.Framebuffer\/end\">myBuffer.end()<\/a>\nallow shapes to be drawn to the framebuffer. <code>myBuffer.begin()<\/code> begins\ndrawing to the framebuffer and\n<a href=\"#\/p5.Framebuffer\/end\">myBuffer.end()<\/a> stops drawing to the\nframebuffer. Changes won't be visible until the framebuffer is displayed\nas an image or texture.<\/p>\n","itemtype":"method","name":"begin","example":["\n<div>\n<code>\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  describe('An empty gray canvas. The canvas gets darker and a rotating, multicolor torus appears while the user presses and holds the mouse.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Start drawing to the p5.Framebuffer object.\n  myBuffer.begin();\n\n  background(50);\n  rotateY(frameCount * 0.01);\n  normalMaterial();\n  torus(30);\n\n  \/\/ Stop drawing to the p5.Framebuffer object.\n  myBuffer.end();\n\n  \/\/ Display the p5.Framebuffer object while\n  \/\/ the user presses the mouse.\n  if (mouseIsPressed === true) {\n    image(myBuffer, -50, -50);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1254,"description":"<p>Stops drawing shapes to the framebuffer.<\/p>\n<p><a href=\"#\/p5.Framebuffer\/begin\">myBuffer.begin()<\/a> and <code>myBuffer.end()<\/code>\nallow shapes to be drawn to the framebuffer.\n<a href=\"#\/p5.Framebuffer\/begin\">myBuffer.begin()<\/a> begins drawing to\nthe framebuffer and <code>myBuffer.end()<\/code> stops drawing to the framebuffer.\nChanges won't be visible until the framebuffer is displayed as an image\nor texture.<\/p>\n","itemtype":"method","name":"end","example":["\n<div>\n<code>\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  describe('An empty gray canvas. The canvas gets darker and a rotating, multicolor torus appears while the user presses and holds the mouse.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Start drawing to the p5.Framebuffer object.\n  myBuffer.begin();\n\n  background(50);\n  rotateY(frameCount * 0.01);\n  normalMaterial();\n  torus(30);\n\n  \/\/ Stop drawing to the p5.Framebuffer object.\n  myBuffer.end();\n\n  \/\/ Display the p5.Framebuffer object while\n  \/\/ the user presses the mouse.\n  if (mouseIsPressed === true) {\n    image(myBuffer, -50, -50);\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1323,"description":"<p>Draws to the framebuffer by calling a function that contains drawing\ninstructions.<\/p>\n<p>The parameter, <code>callback<\/code>, is a function with the drawing instructions\nfor the framebuffer. For example, calling <code>myBuffer.draw(myFunction)<\/code>\nwill call a function named <code>myFunction()<\/code> to draw to the framebuffer.\nDoing so has the same effect as the following:<\/p>\n<pre><code class=\"language-js\">myBuffer.begin();\nmyFunction();\nmyBuffer.end();\n<\/code><\/pre>\n","itemtype":"method","name":"draw","params":[{"name":"callback","description":"<p>function that draws to the framebuffer.<\/p>\n","type":"Function"}],"example":["\n<div>\n<code>\n\/\/ Click the canvas to display the framebuffer.\n\nlet myBuffer;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  describe('An empty gray canvas. The canvas gets darker and a rotating, multicolor torus appears while the user presses and holds the mouse.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw to the p5.Framebuffer object.\n  myBuffer.draw(bagel);\n\n  \/\/ Display the p5.Framebuffer object while\n  \/\/ the user presses the mouse.\n  if (mouseIsPressed === true) {\n    image(myBuffer, -50, -50);\n  }\n}\n\n\/\/ Draw a rotating, multicolor torus.\nfunction bagel() {\n  background(50);\n  rotateY(frameCount * 0.01);\n  normalMaterial();\n  torus(30);\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1386,"description":"<p>Loads the current value of each pixel in the framebuffer into its\n<a href=\"#\/p5.Framebuffer\/pixels\">pixels<\/a> array.<\/p>\n<p><code>myBuffer.loadPixels()<\/code> must be called before reading from or writing to\n<a href=\"#\/p5.Framebuffer\/pixels\">myBuffer.pixels<\/a>.<\/p>\n","itemtype":"method","name":"loadPixels","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Framebuffer object.\n  let myBuffer = createFramebuffer();\n\n  \/\/ Load the pixels array.\n  myBuffer.loadPixels();\n\n  \/\/ Get the number of pixels in the\n  \/\/ top half of the framebuffer.\n  let numPixels = myBuffer.pixels.length \/ 2;\n\n  \/\/ Set the framebuffer's top half to pink.\n  for (let i = 0; i < numPixels; i += 4) {\n    myBuffer.pixels[i] = 255;\n    myBuffer.pixels[i + 1] = 102;\n    myBuffer.pixels[i + 2] = 204;\n    myBuffer.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the pixels array.\n  myBuffer.updatePixels();\n\n  \/\/ Draw the p5.Framebuffer object to the canvas.\n  image(myBuffer, -50, -50);\n\n  describe('A pink rectangle above a gray rectangle.');\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1455,"description":"<p>Gets a pixel or a region of pixels from the framebuffer.<\/p>\n<p><code>myBuffer.get()<\/code> is easy to use but it's not as fast as\n<a href=\"#\/p5.Framebuffer\/pixels\">myBuffer.pixels<\/a>. Use\n<a href=\"#\/p5.Framebuffer\/pixels\">myBuffer.pixels<\/a> to read many pixel\nvalues.<\/p>\n<p>The version of <code>myBuffer.get()<\/code> with no parameters returns the entire\nframebuffer as a a <a href=\"#\/p5.Image\">p5.Image<\/a> object.<\/p>\n<p>The version of <code>myBuffer.get()<\/code> with two parameters interprets them as\ncoordinates. It returns an array with the <code>[R, G, B, A]<\/code> values of the\npixel at the given point.<\/p>\n<p>The version of <code>myBuffer.get()<\/code> with four parameters interprets them as\ncoordinates and dimensions. It returns a subsection of the framebuffer as\na <a href=\"#\/p5.Image\">p5.Image<\/a> object. The first two parameters are\nthe coordinates for the upper-left corner of the subsection. The last two\nparameters are the width and height of the subsection.<\/p>\n","itemtype":"method","name":"get","return":{"description":"subsection as a <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"},"class":"p5.Framebuffer","module":"Rendering","overloads":[{"line":1455,"params":[{"name":"x","description":"<p>x-coordinate of the pixel. Defaults to 0.<\/p>\n","type":"Number"},{"name":"y","description":"<p>y-coordinate of the pixel. Defaults to 0.<\/p>\n","type":"Number"},{"name":"w","description":"<p>width of the subsection to be returned.<\/p>\n","type":"Number"},{"name":"h","description":"<p>height of the subsection to be returned.<\/p>\n","type":"Number"}],"return":{"description":"subsection as a <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"}},{"line":1483,"params":[],"return":{"description":"entire framebuffer as a <a href=\"#\/p5.Image\">p5.Image<\/a> object.","type":"p5.Image"}},{"line":1487,"params":[{"name":"x","description":"","type":"Number"},{"name":"y","description":"","type":"Number"}],"return":{"description":"color of the pixel at `(x, y)` as an array of color values `[R, G, B, A]`.","type":"Number[]"}}]},{"file":"src\/webgl\/p5.Framebuffer.js","line":1581,"description":"<p>Updates the framebuffer with the RGBA values in the\n<a href=\"#\/p5.Framebuffer\/pixels\">pixels<\/a> array.<\/p>\n<p><code>myBuffer.updatePixels()<\/code> only needs to be called after changing values\nin the <a href=\"#\/p5.Framebuffer\/pixels\">myBuffer.pixels<\/a> array. Such\nchanges can be made directly after calling\n<a href=\"#\/p5.Framebuffer\/loadPixels\">myBuffer.loadPixels()<\/a>.<\/p>\n","itemtype":"method","name":"updatePixels","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Framebuffer object.\n  let myBuffer = createFramebuffer();\n\n  \/\/ Load the pixels array.\n  myBuffer.loadPixels();\n\n  \/\/ Get the number of pixels in the\n  \/\/ top half of the framebuffer.\n  let numPixels = myBuffer.pixels.length \/ 2;\n\n  \/\/ Set the framebuffer's top half to pink.\n  for (let i = 0; i < numPixels; i += 4) {\n    myBuffer.pixels[i] = 255;\n    myBuffer.pixels[i + 1] = 102;\n    myBuffer.pixels[i + 2] = 204;\n    myBuffer.pixels[i + 3] = 255;\n  }\n\n  \/\/ Update the pixels array.\n  myBuffer.updatePixels();\n\n  \/\/ Draw the p5.Framebuffer object to the canvas.\n  image(myBuffer, -50, -50);\n\n  describe('A pink rectangle above a gray rectangle.');\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1701,"description":"<p>An object that stores the framebuffer's color data.<\/p>\n<p>Each framebuffer uses a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/WebGLTexture\" target=\"_blank\">WebGLTexture<\/a>\nobject internally to store its color data. The <code>myBuffer.color<\/code> property\nmakes it possible to pass this data directly to other functions. For\nexample, calling <code>texture(myBuffer.color)<\/code> or\n<code>myShader.setUniform('colorTexture', myBuffer.color)<\/code>  may be helpful for\nadvanced use cases.<\/p>\n<p>Note: By default, a framebuffer's y-coordinates are flipped compared to\nimages and videos. It's easy to flip a framebuffer's y-coordinates as\nneeded when applying it as a texture. For example, calling\n<code>plane(myBuffer.width, -myBuffer.height)<\/code> will flip the framebuffer.<\/p>\n","itemtype":"property","name":"color","type":"p5.FramebufferTexture","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Framebuffer object.\n  let myBuffer = createFramebuffer();\n\n  \/\/ Start drawing to the p5.Framebuffer object.\n  myBuffer.begin();\n\n  triangle(-25, 25, 0, -25, 25, 25);\n\n  \/\/ Stop drawing to the p5.Framebuffer object.\n  myBuffer.end();\n\n  \/\/ Use the p5.Framebuffer object's WebGLTexture.\n  texture(myBuffer.color);\n\n  \/\/ Style the plane.\n  noStroke();\n\n  \/\/ Draw the plane.\n  plane(myBuffer.width, myBuffer.height);\n\n  describe('A white triangle on a gray background.');\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Framebuffer.js","line":1754,"description":"<p>An object that stores the framebuffer's depth data.<\/p>\n<p>Each framebuffer uses a\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/WebGLTexture\" target=\"_blank\">WebGLTexture<\/a>\nobject internally to store its depth data. The <code>myBuffer.depth<\/code> property\nmakes it possible to pass this data directly to other functions. For\nexample, calling <code>texture(myBuffer.depth)<\/code> or\n<code>myShader.setUniform('depthTexture', myBuffer.depth)<\/code>  may be helpful for\nadvanced use cases.<\/p>\n<p>Note: By default, a framebuffer's y-coordinates are flipped compared to\nimages and videos. It's easy to flip a framebuffer's y-coordinates as\nneeded when applying it as a texture. For example, calling\n<code>plane(myBuffer.width, -myBuffer.height)<\/code> will flip the framebuffer.<\/p>\n","itemtype":"property","name":"depth","type":"p5.FramebufferTexture","example":["\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * viewModelPosition;\n  vTexCoord = aTexCoord;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D depth;\n\nvoid main() {\n  \/\/ Get the pixel's depth value.\n  float depthVal = texture2D(depth, vTexCoord).r;\n\n  \/\/ Set the pixel's color based on its depth.\n  gl_FragColor = mix(\n    vec4(0., 0., 0., 1.),\n    vec4(1., 0., 1., 1.),\n    depthVal);\n}\n`;\n\nlet myBuffer;\nlet myShader;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Framebuffer object.\n  myBuffer = createFramebuffer();\n\n  \/\/ Create a p5.Shader object.\n  myShader = createShader(vertSrc, fragSrc);\n\n  \/\/ Compile and apply the shader.\n  shader(myShader);\n\n  describe('The shadow of a box rotates slowly against a magenta background.');\n}\n\nfunction draw() {\n  \/\/ Draw to the p5.Framebuffer object.\n  myBuffer.begin();\n  background(255);\n  rotateX(frameCount * 0.01);\n  box(20, 20, 80);\n  myBuffer.end();\n\n  \/\/ Set the shader's depth uniform using\n  \/\/ the framebuffer's depth texture.\n  myShader.setUniform('depth', myBuffer.depth);\n\n  \/\/ Style the plane.\n  noStroke();\n\n  \/\/ Draw the plane.\n  plane(myBuffer.width, myBuffer.height);\n}\n<\/code>\n<\/div>"],"class":"p5.Framebuffer","module":"Rendering"},{"file":"src\/webgl\/p5.Geometry.js","line":252,"description":"<p>An array with the geometry's vertices.<\/p>\n<p>The geometry's vertices are stored as\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> objects in the <code>myGeometry.vertices<\/code>\narray. The geometry's first vertex is the\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object at <code>myGeometry.vertices[0]<\/code>,\nits second vertex is <code>myGeometry.vertices[1]<\/code>, its third vertex is\n<code>myGeometry.vertices[2]<\/code>, and so on.<\/p>\n","itemtype":"property","name":"vertices","example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  myGeometry = new p5.Geometry();\n\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(40, 0, 0);\n\n  \/\/ Add the vertices to the p5.Geometry object's vertices array.\n  myGeometry.vertices.push(v0, v1, v2);\n\n  describe('A white triangle drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  beginGeometry();\n  torus(30, 15, 10, 8);\n  myGeometry = endGeometry();\n\n  describe('A white torus rotates slowly against a dark gray background. Red spheres mark its vertices.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Style the p5.Geometry object.\n  fill(255);\n  stroke(0);\n\n  \/\/ Display the p5.Geometry object.\n  model(myGeometry);\n\n  \/\/ Style the vertices.\n  fill(255, 0, 0);\n  noStroke();\n\n  \/\/ Iterate over the vertices array.\n  for (let v of myGeometry.vertices) {\n    \/\/ Draw a sphere to mark the vertex.\n    push();\n    translate(v);\n    sphere(2.5);\n    pop();\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":375,"description":"<p>An array with the vectors that are normal to the geometry's vertices.<\/p>\n<p>A face's orientation is defined by its <em>normal vector<\/em> which points out\nof the face and is normal (perpendicular) to the surface. Calling\n<code>myGeometry.computeNormals()<\/code> first calculates each face's normal\nvector. Then it calculates the normal vector for each vertex by\naveraging the normal vectors of the faces surrounding the vertex. The\nvertex normals are stored as <a href=\"#\/p5.Vector\">p5.Vector<\/a>\nobjects in the <code>myGeometry.vertexNormals<\/code> array.<\/p>\n","itemtype":"property","name":"vertexNormals","example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  beginGeometry();\n  torus(30, 15, 10, 8);\n  myGeometry = endGeometry();\n\n  \/\/ Compute the vertex normals.\n  myGeometry.computeNormals();\n\n  describe(\n    'A white torus rotates against a dark gray background. Red lines extend outward from its vertices.'\n  );\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Style the p5.Geometry object.\n  stroke(0);\n\n  \/\/ Display the p5.Geometry object.\n  model(myGeometry);\n\n  \/\/ Style the normal vectors.\n  stroke(255, 0, 0);\n\n  \/\/ Iterate over the vertices and vertexNormals arrays.\n  for (let i = 0; i < myGeometry.vertices.length; i += 1) {\n\n    \/\/ Get the vertex p5.Vector object.\n    let v = myGeometry.vertices[i];\n\n    \/\/ Get the vertex normal p5.Vector object.\n    let n = myGeometry.vertexNormals[i];\n\n    \/\/ Calculate a point along the vertex normal.\n    let p = p5.Vector.mult(n, 8);\n\n    \/\/ Draw the vertex normal as a red line.\n    push();\n    translate(v);\n    line(0, 0, 0, p.x, p.y, p.z);\n    pop();\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  myGeometry = new p5.Geometry();\n\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(0, 40, 0);\n  let v3 = createVector(40, 0, 0);\n\n  \/\/ Add the vertices to the p5.Geometry object's vertices array.\n  myGeometry.vertices.push(v0, v1, v2, v3);\n\n  \/\/ Compute the faces array.\n  myGeometry.computeFaces();\n\n  \/\/ Compute the surface normals.\n  myGeometry.computeNormals();\n\n  describe('A red square drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a white point light.\n  pointLight(255, 255, 255, 0, 0, 10);\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Display the p5.Geometry object.\n  model(myGeometry);\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":505,"description":"<p>An array that lists which of the geometry's vertices form each of its\nfaces.<\/p>\n<p>All 3D shapes are made by connecting sets of points called <em>vertices<\/em>. A\ngeometry's surface is formed by connecting vertices to form triangles\nthat are stitched together. Each triangular patch on the geometry's\nsurface is called a <em>face<\/em>.<\/p>\n<p>The geometry's vertices are stored as\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> objects in the\n<a href=\"#\/p5.Geometry\/vertices\">myGeometry.vertices<\/a> array. The\ngeometry's first vertex is the <a href=\"#\/p5.Vector\">p5.Vector<\/a>\nobject at <code>myGeometry.vertices[0]<\/code>, its second vertex is\n<code>myGeometry.vertices[1]<\/code>, its third vertex is <code>myGeometry.vertices[2]<\/code>,\nand so on.<\/p>\n<p>For example, a geometry made from a rectangle has two faces because a\nrectangle is made by joining two triangles. <code>myGeometry.faces<\/code> for a\nrectangle would be the two-dimensional array <code>[[0, 1, 2], [2, 1, 3]]<\/code>.\nThe first face, <code>myGeometry.faces[0]<\/code>, is the array <code>[0, 1, 2]<\/code> because\nit's formed by connecting <code>myGeometry.vertices[0]<\/code>,\n<code>myGeometry.vertices[1]<\/code>,and <code>myGeometry.vertices[2]<\/code>. The second face,\n<code>myGeometry.faces[1]<\/code>, is the array <code>[2, 1, 3]<\/code> because it's formed by\nconnecting <code>myGeometry.vertices[2]<\/code>, <code>myGeometry.vertices[1]<\/code>,and\n<code>myGeometry.vertices[3]<\/code>.<\/p>\n","itemtype":"property","name":"faces","example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  beginGeometry();\n  sphere();\n  myGeometry = endGeometry();\n\n  describe(\"A sphere drawn on a gray background. The sphere's surface is a grayscale patchwork of triangles.\");\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n\n  \/\/ Set a random seed.\n  randomSeed(1234);\n\n  \/\/ Iterate over the faces array.\n  for (let face of myGeometry.faces) {\n\n    \/\/ Style the face.\n    let g = random(0, 255);\n    fill(g);\n\n    \/\/ Draw the face.\n    beginShape();\n    \/\/ Iterate over the vertices that form the face.\n    for (let f of face) {\n      \/\/ Get the vertex's p5.Vector object.\n      let v = myGeometry.vertices[f];\n      vertex(v.x, v.y, v.z);\n    }\n    endShape();\n\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":591,"description":"<p>An array that lists the texture coordinates for each of the geometry's\nvertices.<\/p>\n<p>In order for <a href=\"#\/p5\/texture\">texture()<\/a> to work, the geometry\nneeds a way to map the points on its surface to the pixels in a\nrectangular image that's used as a texture. The geometry's vertex at\ncoordinates <code>(x, y, z)<\/code> maps to the texture image's pixel at coordinates\n<code>(u, v)<\/code>.<\/p>\n<p>The <code>myGeometry.uvs<\/code> array stores the <code>(u, v)<\/code> coordinates for each\nvertex in the order it was added to the geometry. For example, the\nfirst vertex, <code>myGeometry.vertices[0]<\/code>, has its <code>(u, v)<\/code> coordinates\nstored at <code>myGeometry.uvs[0]<\/code> and <code>myGeometry.uvs[1]<\/code>.<\/p>\n","itemtype":"property","name":"uvs","example":["\n<div>\n<code>\nlet img;\n\n\/\/ Load the image and create a p5.Image object.\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create p5.Geometry objects.\n  let geom1 = buildGeometry(createShape);\n  let geom2 = buildGeometry(createShape);\n\n  \/\/ Left (original).\n  push();\n  translate(-25, 0, 0);\n  texture(img);\n  noStroke();\n  model(geom1);\n  pop();\n\n  \/\/ Set geom2's texture coordinates.\n  geom2.uvs = [0.25, 0.25, 0.75, 0.25, 0.25, 0.75, 0.75, 0.75];\n\n  \/\/ Right (zoomed in).\n  push();\n  translate(25, 0, 0);\n  texture(img);\n  noStroke();\n  model(geom2);\n  pop();\n\n  describe(\n    'Two photos of a ceiling on a gray background. The photo on the right zooms in to the center of the photo.'\n  );\n}\n\nfunction createShape() {\n  plane(40);\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":682,"description":"<p>Calculates the position and size of the smallest box that contains the geometry.<\/p>\n<p>A bounding box is the smallest rectangular prism that contains the entire\ngeometry. It's defined by the box's minimum and maximum coordinates along\neach axis, as well as the size (length) and offset (center).<\/p>\n<p>Calling <code>myGeometry.calculateBoundingBox()<\/code> returns an object with four\nproperties that describe the bounding box:<\/p>\n<pre><code class=\"language-js\">\/\/ Get myGeometry's bounding box.\nlet bbox = myGeometry.calculateBoundingBox();\n\n\/\/ Print the bounding box to the console.\nconsole.log(bbox);\n\n\/\/ {\n\/\/  \/\/ The minimum coordinate along each axis.\n\/\/  min: { x: -1, y: -2, z: -3 },\n\/\/\n\/\/  \/\/ The maximum coordinate along each axis.\n\/\/  max: { x: 1, y: 2, z: 3},\n\/\/\n\/\/  \/\/ The size (length) along each axis.\n\/\/  size: { x: 2, y: 4, z: 6},\n\/\/\n\/\/  \/\/ The offset (center) along each axis.\n\/\/  offset: { x: 0, y: 0, z: 0}\n\/\/ }\n<\/code><\/pre>\n","itemtype":"method","name":"calculateBoundingBox","return":{"description":"bounding box of the geometry.","type":"Object"},"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet particles;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a new p5.Geometry object with random spheres.\n  particles = buildGeometry(createParticles);\n\n  describe('Ten white spheres placed randomly against a gray background. A box encloses the spheres.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the particles.\n  noStroke();\n  fill(255);\n\n  \/\/ Draw the particles.\n  model(particles);\n\n  \/\/ Calculate the bounding box.\n  let bbox = particles.calculateBoundingBox();\n\n  \/\/ Translate to the bounding box's center.\n  translate(bbox.offset.x, bbox.offset.y, bbox.offset.z);\n\n  \/\/ Style the bounding box.\n  stroke(255);\n  noFill();\n\n  \/\/ Draw the bounding box.\n  box(bbox.size.x, bbox.size.y, bbox.size.z);\n}\n\nfunction createParticles() {\n  for (let i = 0; i < 10; i += 1) {\n    \/\/ Calculate random coordinates.\n    let x = randomGaussian(0, 15);\n    let y = randomGaussian(0, 15);\n    let z = randomGaussian(0, 15);\n\n    push();\n    \/\/ Translate to the particle's coordinates.\n    translate(x, y, z);\n    \/\/ Draw the particle.\n    sphere(3);\n    pop();\n  }\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":863,"description":"<p>Removes the geometry\u2019s internal colors.<\/p>\n<p><code>p5.Geometry<\/code> objects can be created with \"internal colors\" assigned to\nvertices or the entire shape. When a geometry has internal colors,\n<a href=\"#\/p5\/fill\">fill()<\/a> has no effect. Calling\n<code>myGeometry.clearColors()<\/code> allows the\n<a href=\"#\/p5\/fill\">fill()<\/a> function to apply color to the geometry.<\/p>\n","itemtype":"method","name":"clearColors","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Geometry object.\n  \/\/ Set its internal color to red.\n  beginGeometry();\n  fill(255, 0, 0);\n  plane(20);\n  let myGeometry = endGeometry();\n\n  \/\/ Style the shape.\n  noStroke();\n\n  \/\/ Draw the p5.Geometry object (center).\n  model(myGeometry);\n\n  \/\/ Translate the origin to the bottom-right.\n  translate(25, 25, 0);\n\n  \/\/ Try to fill the geometry with green.\n  fill(0, 255, 0);\n\n  \/\/ Draw the geometry again (bottom-right).\n  model(myGeometry);\n\n  \/\/ Clear the geometry's colors.\n  myGeometry.clearColors();\n\n  \/\/ Fill the geometry with blue.\n  fill(0, 0, 255);\n\n  \/\/ Translate the origin up.\n  translate(0, -50, 0);\n\n  \/\/ Draw the geometry again (top-right).\n  model(myGeometry);\n\n  describe(\n    'Three squares drawn against a gray background. Red squares are at the center and the bottom-right. A blue square is at the top-right.'\n  );\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":928,"description":"<p>The <code>saveObj()<\/code> function exports <code>p5.Geometry<\/code> objects as\n3D models in the Wavefront .obj file format.\nThis way, you can use the 3D shapes you create in p5.js in other software\nfor rendering, animation, 3D printing, or more.<\/p>\n<p>The exported .obj file will include the faces and vertices of the <code>p5.Geometry<\/code>,\nas well as its texture coordinates and normals, if it has them.<\/p>\n","itemtype":"method","name":"saveObj","params":[{"name":"fileName","description":"<p>The name of the file to save the model as.\n                                       If not specified, the default file name will be 'model.obj'.<\/p>\n","type":"String","optional":true,"optdefault":"'model.obj'"}],"example":["\n<div>\n<code>\nlet myModel;\nlet saveBtn;\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myModel = buildGeometry(() => {\n    for (let i = 0; i < 5; i++) {\n      push();\n      translate(\n        random(-75, 75),\n        random(-75, 75),\n        random(-75, 75)\n      );\n      sphere(random(5, 50));\n      pop();\n    }\n  });\n\n  saveBtn = createButton('Save .obj');\n  saveBtn.mousePressed(() => myModel.saveObj());\n\n  describe('A few spheres rotating in space');\n}\n\nfunction draw() {\n  background(0);\n  noStroke();\n  lights();\n  rotateX(millis() * 0.001);\n  rotateY(millis() * 0.002);\n  model(myModel);\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":1028,"description":"<p>The <code>saveStl()<\/code> function exports <code>p5.Geometry<\/code> objects as\n3D models in the STL stereolithography file format.\nThis way, you can use the 3D shapes you create in p5.js in other software\nfor rendering, animation, 3D printing, or more.<\/p>\n<p>The exported .stl file will include the faces, vertices, and normals of the <code>p5.Geometry<\/code>.<\/p>\n<p>By default, this method saves a text-based .stl file. Alternatively, you can save a more compact\nbut less human-readable binary .stl file by passing <code>{ binary: true }<\/code> as a second parameter.<\/p>\n","itemtype":"method","name":"saveStl","params":[{"name":"fileName","description":"<p>The name of the file to save the model as.\n                                       If not specified, the default file name will be 'model.stl'.<\/p>\n","type":"String","optional":true,"optdefault":"'model.stl'"},{"name":"options","description":"<p>Optional settings. Options can include a boolean <code>binary<\/code> property, which\ncontrols whether or not a binary .stl file is saved. It defaults to false.<\/p>\n","type":"Object","optional":true}],"example":["\n<div>\n<code>\nlet myModel;\nlet saveBtn1;\nlet saveBtn2;\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myModel = buildGeometry(() => {\n    for (let i = 0; i < 5; i++) {\n      push();\n      translate(\n        random(-75, 75),\n        random(-75, 75),\n        random(-75, 75)\n      );\n      sphere(random(5, 50));\n      pop();\n    }\n  });\n\n  saveBtn1 = createButton('Save .stl');\n  saveBtn1.mousePressed(function() {\n    myModel.saveStl();\n  });\n  saveBtn2 = createButton('Save binary .stl');\n  saveBtn2.mousePressed(function() {\n    myModel.saveStl('model.stl', { binary: true });\n  });\n\n  describe('A few spheres rotating in space');\n}\n\nfunction draw() {\n  background(0);\n  noStroke();\n  lights();\n  rotateX(millis() * 0.001);\n  rotateY(millis() * 0.002);\n  model(myModel);\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":1150,"description":"<p>Flips the geometry\u2019s texture u-coordinates.<\/p>\n<p>In order for <a href=\"#\/p5\/texture\">texture()<\/a> to work, the geometry\nneeds a way to map the points on its surface to the pixels in a rectangular\nimage that's used as a texture. The geometry's vertex at coordinates\n<code>(x, y, z)<\/code> maps to the texture image's pixel at coordinates <code>(u, v)<\/code>.<\/p>\n<p>The <a href=\"#\/p5.Geometry\/uvs\">myGeometry.uvs<\/a> array stores the\n<code>(u, v)<\/code> coordinates for each vertex in the order it was added to the\ngeometry. Calling <code>myGeometry.flipU()<\/code> flips a geometry's u-coordinates\nso that the texture appears mirrored horizontally.<\/p>\n<p>For example, a plane's four vertices are added clockwise starting from the\ntop-left corner. Here's how calling <code>myGeometry.flipU()<\/code> would change a\nplane's texture coordinates:<\/p>\n<pre><code class=\"language-js\">\/\/ Print the original texture coordinates.\n\/\/ Output: [0, 0, 1, 0, 0, 1, 1, 1]\nconsole.log(myGeometry.uvs);\n\n\/\/ Flip the u-coordinates.\nmyGeometry.flipU();\n\n\/\/ Print the flipped texture coordinates.\n\/\/ Output: [1, 0, 0, 0, 1, 1, 0, 1]\nconsole.log(myGeometry.uvs);\n\n\/\/ Notice the swaps:\n\/\/ Top vertices: [0, 0, 1, 0] --> [1, 0, 0, 0]\n\/\/ Bottom vertices: [0, 1, 1, 1] --> [1, 1, 0, 1]\n<\/code><\/pre>\n","itemtype":"method","name":"flipU","example":["\n<div>\n<code>\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create p5.Geometry objects.\n  let geom1 = buildGeometry(createShape);\n  let geom2 = buildGeometry(createShape);\n\n  \/\/ Flip geom2's U texture coordinates.\n  geom2.flipU();\n\n  \/\/ Left (original).\n  push();\n  translate(-25, 0, 0);\n  texture(img);\n  noStroke();\n  model(geom1);\n  pop();\n\n  \/\/ Right (flipped).\n  push();\n  translate(25, 0, 0);\n  texture(img);\n  noStroke();\n  model(geom2);\n  pop();\n\n  describe(\n    'Two photos of a ceiling on a gray background. The photos are mirror images of each other.'\n  );\n}\n\nfunction createShape() {\n  plane(40);\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":1245,"description":"<p>Flips the geometry\u2019s texture v-coordinates.<\/p>\n<p>In order for <a href=\"#\/p5\/texture\">texture()<\/a> to work, the geometry\nneeds a way to map the points on its surface to the pixels in a rectangular\nimage that's used as a texture. The geometry's vertex at coordinates\n<code>(x, y, z)<\/code> maps to the texture image's pixel at coordinates <code>(u, v)<\/code>.<\/p>\n<p>The <a href=\"#\/p5.Geometry\/uvs\">myGeometry.uvs<\/a> array stores the\n<code>(u, v)<\/code> coordinates for each vertex in the order it was added to the\ngeometry. Calling <code>myGeometry.flipV()<\/code> flips a geometry's v-coordinates\nso that the texture appears mirrored vertically.<\/p>\n<p>For example, a plane's four vertices are added clockwise starting from the\ntop-left corner. Here's how calling <code>myGeometry.flipV()<\/code> would change a\nplane's texture coordinates:<\/p>\n<pre><code class=\"language-js\">\/\/ Print the original texture coordinates.\n\/\/ Output: [0, 0, 1, 0, 0, 1, 1, 1]\nconsole.log(myGeometry.uvs);\n\n\/\/ Flip the v-coordinates.\nmyGeometry.flipV();\n\n\/\/ Print the flipped texture coordinates.\n\/\/ Output: [0, 1, 1, 1, 0, 0, 1, 0]\nconsole.log(myGeometry.uvs);\n\n\/\/ Notice the swaps:\n\/\/ Left vertices: [0, 0] &lt;--&gt; [1, 0]\n\/\/ Right vertices: [1, 0] &lt;--&gt; [1, 1]\n<\/code><\/pre>\n","itemtype":"method","name":"flipV","example":["\n<div>\n<code>\nlet img;\n\nfunction preload() {\n  img = loadImage('assets\/laDefense.jpg');\n}\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create p5.Geometry objects.\n  let geom1 = buildGeometry(createShape);\n  let geom2 = buildGeometry(createShape);\n\n  \/\/ Flip geom2's V texture coordinates.\n  geom2.flipV();\n\n  \/\/ Left (original).\n  push();\n  translate(-25, 0, 0);\n  texture(img);\n  noStroke();\n  model(geom1);\n  pop();\n\n  \/\/ Right (flipped).\n  push();\n  translate(25, 0, 0);\n  texture(img);\n  noStroke();\n  model(geom2);\n  pop();\n\n  describe(\n    'Two photos of a ceiling on a gray background. The photos are mirror images of each other.'\n  );\n}\n\nfunction createShape() {\n  plane(40);\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":1340,"description":"<p>Computes the geometry's faces using its vertices.<\/p>\n<p>All 3D shapes are made by connecting sets of points called <em>vertices<\/em>. A\ngeometry's surface is formed by connecting vertices to form triangles that\nare stitched together. Each triangular patch on the geometry's surface is\ncalled a <em>face<\/em>. <code>myGeometry.computeFaces()<\/code> performs the math needed to\ndefine each face based on the distances between vertices.<\/p>\n<p>The geometry's vertices are stored as <a href=\"#\/p5.Vector\">p5.Vector<\/a>\nobjects in the <a href=\"#\/p5.Geometry\/vertices\">myGeometry.vertices<\/a>\narray. The geometry's first vertex is the\n<a href=\"#\/p5.Vector\">p5.Vector<\/a> object at <code>myGeometry.vertices[0]<\/code>,\nits second vertex is <code>myGeometry.vertices[1]<\/code>, its third vertex is\n<code>myGeometry.vertices[2]<\/code>, and so on.<\/p>\n<p>Calling <code>myGeometry.computeFaces()<\/code> fills the\n<a href=\"#\/p5.Geometry\/faces\">myGeometry.faces<\/a> array with three-element\narrays that list the vertices that form each face. For example, a geometry\nmade from a rectangle has two faces because a rectangle is made by joining\ntwo triangles. <a href=\"#\/p5.Geometry\/faces\">myGeometry.faces<\/a> for a\nrectangle would be the two-dimensional array\n<code>[[0, 1, 2], [2, 1, 3]]<\/code>. The first face, <code>myGeometry.faces[0]<\/code>, is the\narray <code>[0, 1, 2]<\/code> because it's formed by connecting\n<code>myGeometry.vertices[0]<\/code>, <code>myGeometry.vertices[1]<\/code>,and\n<code>myGeometry.vertices[2]<\/code>. The second face, <code>myGeometry.faces[1]<\/code>, is the\narray <code>[2, 1, 3]<\/code> because it's formed by connecting\n<code>myGeometry.vertices[2]<\/code>, <code>myGeometry.vertices[1]<\/code>, and\n<code>myGeometry.vertices[3]<\/code>.<\/p>\n<p>Note: <code>myGeometry.computeFaces()<\/code> only works when geometries have four or more vertices.<\/p>\n","itemtype":"method","name":"computeFaces","chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  myGeometry = new p5.Geometry();\n\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(0, 40, 0);\n  let v3 = createVector(40, 0, 0);\n\n  \/\/ Add the vertices to myGeometry's vertices array.\n  myGeometry.vertices.push(v0, v1, v2, v3);\n\n  \/\/ Compute myGeometry's faces array.\n  myGeometry.computeFaces();\n\n  describe('A red square drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the shape.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object using a callback function.\n  myGeometry = new p5.Geometry(1, 1, createShape);\n\n  describe('A red square drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Style the shape.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n\nfunction createShape() {\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(0, 40, 0);\n  let v3 = createVector(40, 0, 0);\n\n  \/\/ Add the vertices to the p5.Geometry object's vertices array.\n  this.vertices.push(v0, v1, v2, v3);\n\n  \/\/ Compute the faces array.\n  this.computeFaces();\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":1508,"description":"<p>Calculates the normal vector for each vertex on the geometry.<\/p>\n<p>All 3D shapes are made by connecting sets of points called <em>vertices<\/em>. A\ngeometry's surface is formed by connecting vertices to create triangles\nthat are stitched together. Each triangular patch on the geometry's\nsurface is called a <em>face<\/em>. <code>myGeometry.computeNormals()<\/code> performs the\nmath needed to orient each face. Orientation is important for lighting\nand other effects.<\/p>\n<p>A face's orientation is defined by its <em>normal vector<\/em> which points out\nof the face and is normal (perpendicular) to the surface. Calling\n<code>myGeometry.computeNormals()<\/code> first calculates each face's normal vector.\nThen it calculates the normal vector for each vertex by averaging the\nnormal vectors of the faces surrounding the vertex. The vertex normals\nare stored as <a href=\"#\/p5.Vector\">p5.Vector<\/a> objects in the\n<a href=\"#\/p5.Geometry\/vertexNormals\">myGeometry.vertexNormals<\/a> array.<\/p>\n<p>The first parameter, <code>shadingType<\/code>, is optional. Passing the constant\n<code>FLAT<\/code>, as in <code>myGeometry.computeNormals(FLAT)<\/code>, provides neighboring\nfaces with their own copies of the vertices they share. Surfaces appear\ntiled with flat shading. Passing the constant <code>SMOOTH<\/code>, as in\n<code>myGeometry.computeNormals(SMOOTH)<\/code>, makes neighboring faces reuse their\nshared vertices. Surfaces appear smoother with smooth shading. By\ndefault, <code>shadingType<\/code> is <code>FLAT<\/code>.<\/p>\n<p>The second parameter, <code>options<\/code>, is also optional. If an object with a\n<code>roundToPrecision<\/code> property is passed, as in\n<code>myGeometry.computeNormals(SMOOTH, { roundToPrecision: 5 })<\/code>, it sets the\nnumber of decimal places to use for calculations. By default,\n<code>roundToPrecision<\/code> uses 3 decimal places.<\/p>\n","itemtype":"method","name":"computeNormals","params":[{"name":"shadingType","description":"<p>shading type. either FLAT or SMOOTH. Defaults to <code>FLAT<\/code>.<\/p>\n","type":"String","optional":true},{"name":"options","description":"<p>shading options.<\/p>\n","type":"Object","optional":true}],"chainable":1,"example":["\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  beginGeometry();\n  torus();\n  myGeometry = endGeometry();\n\n  \/\/ Compute the vertex normals.\n  myGeometry.computeNormals();\n\n  describe(\n    \"A white torus drawn on a dark gray background. Red lines extend outward from the torus' vertices.\"\n  );\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateX(1);\n\n  \/\/ Style the helix.\n  stroke(0);\n\n  \/\/ Display the helix.\n  model(myGeometry);\n\n  \/\/ Style the normal vectors.\n  stroke(255, 0, 0);\n\n  \/\/ Iterate over the vertices and vertexNormals arrays.\n  for (let i = 0; i < myGeometry.vertices.length; i += 1) {\n\n    \/\/ Get the vertex p5.Vector object.\n    let v = myGeometry.vertices[i];\n\n    \/\/ Get the vertex normal p5.Vector object.\n    let n = myGeometry.vertexNormals[i];\n\n    \/\/ Calculate a point along the vertex normal.\n    let p = p5.Vector.mult(n, 5);\n\n    \/\/ Draw the vertex normal as a red line.\n    push();\n    translate(v);\n    line(0, 0, 0, p.x, p.y, p.z);\n    pop();\n  }\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object using a callback function.\n  myGeometry = new p5.Geometry();\n\n  \/\/ Create p5.Vector objects to position the vertices.\n  let v0 = createVector(-40, 0, 0);\n  let v1 = createVector(0, -40, 0);\n  let v2 = createVector(0, 40, 0);\n  let v3 = createVector(40, 0, 0);\n\n  \/\/ Add the vertices to the p5.Geometry object's vertices array.\n  myGeometry.vertices.push(v0, v1, v2, v3);\n\n  \/\/ Compute the faces array.\n  myGeometry.computeFaces();\n\n  \/\/ Compute the surface normals.\n  myGeometry.computeNormals();\n\n  describe('A red square drawn on a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Add a white point light.\n  pointLight(255, 255, 255, 0, 0, 10);\n\n  \/\/ Style the p5.Geometry object.\n  noStroke();\n  fill(255, 0, 0);\n\n  \/\/ Draw the p5.Geometry object.\n  model(myGeometry);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  myGeometry = buildGeometry(createShape);\n\n  \/\/ Compute normals using default (FLAT) shading.\n  myGeometry.computeNormals(FLAT);\n\n  describe('A white, helical structure drawn on a dark gray background. Its faces appear faceted.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateX(1);\n\n  \/\/ Style the helix.\n  noStroke();\n\n  \/\/ Display the helix.\n  model(myGeometry);\n}\n\nfunction createShape() {\n  \/\/ Create a helical shape.\n  beginShape();\n  for (let i = 0; i < TWO_PI * 3; i += 0.5) {\n    let x = 30 * cos(i);\n    let y = 30 * sin(i);\n    let z = map(i, 0, TWO_PI * 3, -40, 40);\n    vertex(x, y, z);\n  }\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  myGeometry = buildGeometry(createShape);\n\n  \/\/ Compute normals using smooth shading.\n  myGeometry.computeNormals(SMOOTH);\n\n  describe('A white, helical structure drawn on a dark gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateX(1);\n\n  \/\/ Style the helix.\n  noStroke();\n\n  \/\/ Display the helix.\n  model(myGeometry);\n}\n\nfunction createShape() {\n  \/\/ Create a helical shape.\n  beginShape();\n  for (let i = 0; i < TWO_PI * 3; i += 0.5) {\n    let x = 30 * cos(i);\n    let y = 30 * sin(i);\n    let z = map(i, 0, TWO_PI * 3, -40, 40);\n    vertex(x, y, z);\n  }\n  endShape();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Click and drag the mouse to view the scene from different angles.\n\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Geometry object.\n  myGeometry = buildGeometry(createShape);\n\n  \/\/ Create an options object.\n  let options = { roundToPrecision: 5 };\n\n  \/\/ Compute normals using smooth shading.\n  myGeometry.computeNormals(SMOOTH, options);\n\n  describe('A white, helical structure drawn on a dark gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Enable orbiting with the mouse.\n  orbitControl();\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate the coordinate system.\n  rotateX(1);\n\n  \/\/ Style the helix.\n  noStroke();\n\n  \/\/ Display the helix.\n  model(myGeometry);\n}\n\nfunction createShape() {\n  \/\/ Create a helical shape.\n  beginShape();\n  for (let i = 0; i < TWO_PI * 3; i += 0.5) {\n    let x = 30 * cos(i);\n    let y = 30 * sin(i);\n    let z = map(i, 0, TWO_PI * 3, -40, 40);\n    vertex(x, y, z);\n  }\n  endShape();\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.Geometry.js","line":2228,"description":"<p>Transforms the geometry's vertices to fit snugly within a 100\u00d7100\u00d7100 box\ncentered at the origin.<\/p>\n<p>Calling <code>myGeometry.normalize()<\/code> translates the geometry's vertices so that\nthey're centered at the origin <code>(0, 0, 0)<\/code>. Then it scales the vertices so\nthat they fill a 100\u00d7100\u00d7100 box. As a result, small geometries will grow\nand large geometries will shrink.<\/p>\n<p>Note: <code>myGeometry.normalize()<\/code> only works when called in the\n<a href=\"#\/p5\/setup\">setup()<\/a> function.<\/p>\n","itemtype":"method","name":"normalize","chainable":1,"example":["\n<div>\n<code>\nlet myGeometry;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a very small torus.\n  beginGeometry();\n  torus(1, 0.25);\n  myGeometry = endGeometry();\n\n  \/\/ Normalize the torus so its vertices fill\n  \/\/ the range [-100, 100].\n  myGeometry.normalize();\n\n  describe('A white torus rotates slowly against a dark gray background.');\n}\n\nfunction draw() {\n  background(50);\n\n  \/\/ Turn on the lights.\n  lights();\n\n  \/\/ Rotate around the y-axis.\n  rotateY(frameCount * 0.01);\n\n  \/\/ Style the torus.\n  noStroke();\n\n  \/\/ Draw the torus.\n  model(myGeometry);\n}\n<\/code>\n<\/div>"],"class":"p5.Geometry","module":"Shape","submodule":"3D Primitives"},{"file":"src\/webgl\/p5.RendererGL.Immediate.js","line":1,"description":"<p>Welcome to RendererGL Immediate Mode.\nImmediate mode is used for drawing custom shapes\nfrom a set of vertices.  Immediate Mode is activated\nwhen you call <a href=\"#\/p5\/beginShape\">beginShape()<\/a> & de-activated when you call <a href=\"#\/p5\/endShape\">endShape()<\/a>.\nImmediate mode is a style of programming borrowed\nfrom OpenGL's (now-deprecated) immediate mode.\nIt differs from p5.js' default, Retained Mode, which caches\ngeometries and buffers on the CPU to reduce the number of webgl\ndraw calls. Retained mode is more efficient & performative,\nhowever, Immediate Mode is useful for sketching quick\ngeometric ideas.<\/p>\n","class":"p5","module":"Math"},{"file":"src\/webgl\/p5.RendererGL.Immediate.js","line":191,"description":"<p>End shape drawing and render vertices to screen.<\/p>\n","chainable":1,"class":"p5","module":"Math"},{"file":"src\/webgl\/p5.RendererGL.Retained.js","line":8,"params":[{"name":"geometry","description":"<p>The model whose resources will be freed<\/p>\n","type":"p5.Geometry"}],"class":"p5","module":"Math"},{"file":"src\/webgl\/p5.RendererGL.js","line":118,"description":"<p>Set attributes for the WebGL Drawing context.\nThis is a way of adjusting how the WebGL\nrenderer works to fine-tune the display and performance.<\/p>\n<p>Note that this will reinitialize the drawing context\nif called after the WebGL canvas is made.<\/p>\n<p>If an object is passed as the parameter, all attributes\nnot declared in the object will be set to defaults.<\/p>\n<p>The available attributes are:\n<br>\nalpha - indicates if the canvas contains an alpha buffer\ndefault is true<\/p>\n<p>depth - indicates whether the drawing buffer has a depth buffer\nof at least 16 bits - default is true<\/p>\n<p>stencil - indicates whether the drawing buffer has a stencil buffer\nof at least 8 bits<\/p>\n<p>antialias - indicates whether or not to perform anti-aliasing\ndefault is false (true in Safari)<\/p>\n<p>premultipliedAlpha - indicates that the page compositor will assume\nthe drawing buffer contains colors with pre-multiplied alpha\ndefault is true<\/p>\n<p>preserveDrawingBuffer - if true the buffers will not be cleared and\nand will preserve their values until cleared or overwritten by author\n(note that p5 clears automatically on draw loop)\ndefault is true<\/p>\n<p>perPixelLighting - if true, per-pixel lighting will be used in the\nlighting shader otherwise per-vertex lighting is used.\ndefault is true.<\/p>\n<p>version - either 1 or 2, to specify which WebGL version to ask for. By\ndefault, WebGL 2 will be requested. If WebGL2 is not available, it will\nfall back to WebGL 1. You can check what version is used with by looking at\nthe global <code>webglVersion<\/code> property.<\/p>\n","itemtype":"method","name":"setAttributes","example":["\n<div>\n<code>\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n  background(255);\n  push();\n  rotateZ(frameCount * 0.02);\n  rotateX(frameCount * 0.02);\n  rotateY(frameCount * 0.02);\n  fill(0, 0, 0);\n  box(50);\n  pop();\n}\n<\/code>\n<\/div>\n<br>\nNow with the antialias attribute set to true.\n<br>\n<div>\n<code>\nfunction setup() {\n  setAttributes('antialias', true);\n  createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n  background(255);\n  push();\n  rotateZ(frameCount * 0.02);\n  rotateX(frameCount * 0.02);\n  rotateY(frameCount * 0.02);\n  fill(0, 0, 0);\n  box(50);\n  pop();\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ press the mouse button to disable perPixelLighting\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n  noStroke();\n  fill(255);\n}\n\nlet lights = [\n  { c: '#f00', t: 1.12, p: 1.91, r: 0.2 },\n  { c: '#0f0', t: 1.21, p: 1.31, r: 0.2 },\n  { c: '#00f', t: 1.37, p: 1.57, r: 0.2 },\n  { c: '#ff0', t: 1.12, p: 1.91, r: 0.7 },\n  { c: '#0ff', t: 1.21, p: 1.31, r: 0.7 },\n  { c: '#f0f', t: 1.37, p: 1.57, r: 0.7 }\n];\n\nfunction draw() {\n  let t = millis() \/ 1000 + 1000;\n  background(0);\n  directionalLight(color('#222'), 1, 1, 1);\n\n  for (let i = 0; i < lights.length; i++) {\n    let light = lights[i];\n    pointLight(\n      color(light.c),\n      p5.Vector.fromAngles(t * light.t, t * light.p, width * light.r)\n    );\n  }\n\n  specularMaterial(255);\n  sphere(width * 0.1);\n\n  rotateX(t * 0.77);\n  rotateY(t * 0.83);\n  rotateZ(t * 0.91);\n  torus(width * 0.3, width * 0.07, 24, 10);\n}\n\nfunction mousePressed() {\n  setAttributes('perPixelLighting', false);\n  noStroke();\n  fill(255);\n}\nfunction mouseReleased() {\n  setAttributes('perPixelLighting', true);\n  noStroke();\n  fill(255);\n}\n<\/code>\n<\/div>"],"alt":"a rotating cube with smoother edges","class":"p5","module":"Rendering","submodule":"Rendering","overloads":[{"line":118,"params":[{"name":"key","description":"<p>Name of attribute<\/p>\n","type":"String"},{"name":"value","description":"<p>New value of named attribute<\/p>\n","type":"Boolean"}]},{"line":262,"params":[{"name":"obj","description":"<p>object with key-value pairs<\/p>\n","type":"Object"}]}]},{"file":"src\/webgl\/p5.Shader.js","line":233,"description":"<p>Shaders are written in <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Games\/Techniques\/3D_on_the_web\/GLSL_Shaders\">GLSL<\/a>, but\nthere are different versions of GLSL that it might be written in.<\/p>\n<p>Calling this method on a <code>p5.Shader<\/code> will return the GLSL version it uses, either <code>100 es<\/code> or <code>300 es<\/code>.\nWebGL 1 shaders will only use <code>100 es<\/code>, and WebGL 2 shaders may use either.<\/p>\n","return":{"description":"The GLSL version used by the shader.","type":"String"},"class":"p5.Shader","module":"3D","submodule":"Material"},{"file":"src\/webgl\/p5.Shader.js","line":259,"description":"<p>Logs the hooks available in this shader, and their current implementation.<\/p>\n<p>Each shader may let you override bits of its behavior. Each bit is called\na <em>hook.<\/em> A hook is either for the <em>vertex<\/em> shader, if it affects the\nposition of vertices, or in the <em>fragment<\/em> shader, if it affects the pixel\ncolor. This method logs those values to the console, letting you know what\nyou are able to use in a call to\n<a href=\"#\/p5.Shader\/modify\"><code>modify()<\/code><\/a>.<\/p>\n<p>For example, this shader will produce the following output:<\/p>\n<pre><code class=\"language-js\">myShader = baseMaterialShader().modify({\n  declarations: 'uniform float time;',\n  'vec3 getWorldPosition': `(vec3 pos) {\n    pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);\n    return pos;\n  }`\n});\nmyShader.inspectHooks();\n<\/code><\/pre>\n<pre><code>==== Vertex shader hooks: ====\nvoid beforeVertex() {}\nvec3 getLocalPosition(vec3 position) { return position; }\n[MODIFIED] vec3 getWorldPosition(vec3 pos) {\n      pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);\n      return pos;\n    }\nvec3 getLocalNormal(vec3 normal) { return normal; }\nvec3 getWorldNormal(vec3 normal) { return normal; }\nvec2 getUV(vec2 uv) { return uv; }\nvec4 getVertexColor(vec4 color) { return color; }\nvoid afterVertex() {}\n\n==== Fragment shader hooks: ====\nvoid beforeFragment() {}\nInputs getPixelInputs(Inputs inputs) { return inputs; }\nvec4 combineColors(ColorComponents components) {\n                vec4 color = vec4(0.);\n                color.rgb += components.diffuse * components.baseColor;\n                color.rgb += components.ambient * components.ambientColor;\n                color.rgb += components.specular * components.specularColor;\n                color.rgb += components.emissive;\n                color.a = components.opacity;\n                return color;\n              }\nvec4 getFinalColor(vec4 color) { return color; }\nvoid afterFragment() {}\n<\/code><\/pre>\n","itemtype":"method","name":"inspectHooks","beta":1,"class":"p5.Shader","module":"3D","submodule":"Material"},{"file":"src\/webgl\/p5.Shader.js","line":340,"description":"<p>Returns a new shader, based on the original, but with custom snippets\nof shader code replacing default behaviour.<\/p>\n<p>Each shader may let you override bits of its behavior. Each bit is called\na <em>hook.<\/em> A hook is either for the <em>vertex<\/em> shader, if it affects the\nposition of vertices, or in the <em>fragment<\/em> shader, if it affects the pixel\ncolor. You can inspect the different hooks available by calling\n<a href=\"#\/p5.Shader\/inspectHooks\"><code>yourShader.inspectHooks()<\/code><\/a>. You can\nalso read the reference for the default material, normal material, color, line, and point shaders to\nsee what hooks they have available.<\/p>\n<p><code>modify()<\/code> takes one parameter, <code>hooks<\/code>, an object with the hooks you want\nto override. Each key of the <code>hooks<\/code> object is the name\nof a hook, and the value is a string with the GLSL code for your hook.<\/p>\n<p>If you supply functions that aren't existing hooks, they will get added at the start of\nthe shader as helper functions so that you can use them in your hooks.<\/p>\n<p>To add new <a href=\"#\/p5.Shader\/setUniform\">uniforms<\/a> to your shader, you can pass in a <code>uniforms<\/code> object containing\nthe type and name of the uniform as the key, and a default value or function returning\na default value as its value. These will be automatically set when the shader is set\nwith <code>shader(yourShader)<\/code>.<\/p>\n<p>You can also add a <code>declarations<\/code> key, where the value is a GLSL string declaring\ncustom uniform variables, globals, and functions shared\nbetween hooks. To add declarations just in a vertex or fragment shader, add\n<code>vertexDeclarations<\/code> and <code>fragmentDeclarations<\/code> keys.<\/p>\n","itemtype":"method","name":"modify","beta":1,"params":[{"name":"hooks","description":"<p>The hooks in the shader to replace.<\/p>\n","type":"Object","optional":true}],"return":{"description":"","type":"p5.Shader"},"example":["\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseMaterialShader().modify({\n    uniforms: {\n      'float time': () => millis()\n    },\n    'vec3 getWorldPosition': `(vec3 pos) {\n      pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);\n      return pos;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  lights();\n  noStroke();\n  fill('red');\n  sphere(50);\n}\n<\/code>\n<\/div>","\n<div modernizr='webgl'>\n<code>\nlet myShader;\n\nfunction setup() {\n  createCanvas(200, 200, WEBGL);\n  myShader = baseMaterialShader().modify({\n    \/\/ Manually specifying a uniform\n    declarations: 'uniform float time;',\n    'vec3 getWorldPosition': `(vec3 pos) {\n      pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);\n      return pos;\n    }`\n  });\n}\n\nfunction draw() {\n  background(255);\n  shader(myShader);\n  myShader.setUniform('time', millis());\n  lights();\n  noStroke();\n  fill('red');\n  sphere(50);\n}\n<\/code>\n<\/div>"],"class":"p5.Shader","module":"3D","submodule":"Material"},{"file":"src\/webgl\/p5.Shader.js","line":574,"description":"<p>Copies the shader from one drawing context to another.<\/p>\n<p>Each <code>p5.Shader<\/code> object must be compiled by calling\n<a href=\"#\/p5\/shader\">shader()<\/a> before it can run. Compilation happens\nin a drawing context which is usually the main canvas or an instance of\n<a href=\"#\/p5.Graphics\">p5.Graphics<\/a>. A shader can only be used in the\ncontext where it was compiled. The <code>copyToContext()<\/code> method compiles the\nshader again and copies it to another drawing context where it can be\nreused.<\/p>\n<p>The parameter, <code>context<\/code>, is the drawing context where the shader will be\nused. The shader can be copied to an instance of\n<a href=\"#\/p5.Graphics\">p5.Graphics<\/a>, as in\n<code>myShader.copyToContext(pg)<\/code>. The shader can also be copied from a\n<a href=\"#\/p5.Graphics\">p5.Graphics<\/a> object to the main canvas using\nthe <code>window<\/code> variable, as in <code>myShader.copyToContext(window)<\/code>.<\/p>\n<p>Note: A <a href=\"#\/p5.Shader\">p5.Shader<\/a> object created with\n<a href=\"#\/p5\/createShader\">createShader()<\/a>,\n<a href=\"#\/p5\/createFilterShader\">createFilterShader()<\/a>, or\n<a href=\"#\/p5\/loadShader\">loadShader()<\/a>\ncan be used directly with a <a href=\"#\/p5.Framebuffer\">p5.Framebuffer<\/a>\nobject created with\n<a href=\"#\/p5\/createFramebuffer\">createFramebuffer()<\/a>. Both objects\nhave the same context as the main canvas.<\/p>\n","itemtype":"method","name":"copyToContext","params":[{"name":"context","description":"<p>WebGL context for the copied shader.<\/p>\n","type":"p5|p5.Graphics"}],"return":{"description":"new shader compiled for the target context.","type":"p5.Shader"},"example":["\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision mediump float;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vec2 uv = vTexCoord;\n  vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0));\n  gl_FragColor = vec4(color, 1.0);\\\n}\n`;\n\nlet pg;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  background(200);\n\n  \/\/ Create a p5.Shader object.\n  let original = createShader(vertSrc, fragSrc);\n\n  \/\/ Compile the p5.Shader object.\n  shader(original);\n\n  \/\/ Create a p5.Graphics object.\n  pg = createGraphics(50, 50, WEBGL);\n\n  \/\/ Copy the original shader to the p5.Graphics object.\n  let copied = original.copyToContext(pg);\n\n  \/\/ Apply the copied shader to the p5.Graphics object.\n  pg.shader(copied);\n\n  \/\/ Style the display surface.\n  pg.noStroke();\n\n  \/\/ Add a display surface for the shader.\n  pg.plane(50, 50);\n\n  describe('A square with purple-blue gradient on its surface drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Draw the p5.Graphics object to the main canvas.\n  image(pg, -25, -25);\n}\n<\/code>\n<\/div>\n\n<div class='notest'>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision mediump float;\n\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vec2 uv = vTexCoord;\n  vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0));\n  gl_FragColor = vec4(color, 1.0);\n}\n`;\n\nlet copied;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Graphics object.\n  let pg = createGraphics(25, 25, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  let original = pg.createShader(vertSrc, fragSrc);\n\n  \/\/ Compile the p5.Shader object.\n  pg.shader(original);\n\n  \/\/ Copy the original shader to the main canvas.\n  copied = original.copyToContext(window);\n\n  \/\/ Apply the copied shader to the main canvas.\n  shader(copied);\n\n  describe('A rotating cube with a purple-blue gradient on its surface drawn against a gray background.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Rotate around the x-, y-, and z-axes.\n  rotateX(frameCount * 0.01);\n  rotateY(frameCount * 0.01);\n  rotateZ(frameCount * 0.01);\n\n  \/\/ Draw the box.\n  box(50);\n}\n<\/code>\n<\/div>"],"class":"p5.Shader","module":"3D","submodule":"Material"},{"file":"src\/webgl\/p5.Shader.js","line":990,"description":"<p>Sets the shader\u2019s uniform (global) variables.<\/p>\n<p>Shader programs run on the computer\u2019s graphics processing unit (GPU).\nThey live in part of the computer\u2019s memory that\u2019s completely separate\nfrom the sketch that runs them. Uniforms are global variables within a\nshader program. They provide a way to pass values from a sketch running\non the CPU to a shader program running on the GPU.<\/p>\n<p>The first parameter, <code>uniformName<\/code>, is a string with the uniform\u2019s name.\nFor the shader above, <code>uniformName<\/code> would be <code>'r'<\/code>.<\/p>\n<p>The second parameter, <code>data<\/code>, is the value that should be used to set the\nuniform. For example, calling <code>myShader.setUniform('r', 0.5)<\/code> would set\nthe <code>r<\/code> uniform in the shader above to <code>0.5<\/code>. data should match the\nuniform\u2019s type. Numbers, strings, booleans, arrays, and many types of\nimages can all be passed to a shader with <code>setUniform()<\/code>.<\/p>\n","itemtype":"method","name":"setUniform","chainable":1,"params":[{"name":"uniformName","description":"<p>name of the uniform. Must match the name\n                            used in the vertex and fragment shaders.<\/p>\n","type":"String"},{"name":"data","description":"<p>value to assign to the uniform. Must match the uniform\u2019s data type.<\/p>\n","type":"Boolean|Number|Number[]|p5.Image|p5.Graphics|p5.MediaElement|p5.Texture"}],"example":["\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision mediump float;\n\nuniform float r;\n\nvoid main() {\n  gl_FragColor = vec4(r, 1.0, 1.0, 1.0);\n}\n`;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  let myShader = createShader(vertSrc, fragSrc);\n\n  \/\/ Apply the p5.Shader object.\n  shader(myShader);\n\n  \/\/ Set the r uniform to 0.5.\n  myShader.setUniform('r', 0.5);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a plane as a drawing surface for the shader.\n  plane(100, 100);\n\n  describe('A cyan square.');\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision mediump float;\n\nuniform float r;\n\nvoid main() {\n  gl_FragColor = vec4(r, 1.0, 1.0, 1.0);\n}\n`;\n\nlet myShader;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  myShader = createShader(vertSrc, fragSrc);\n\n  \/\/ Compile and apply the p5.Shader object.\n  shader(myShader);\n\n  describe('A square oscillates color between cyan and white.');\n}\n\nfunction draw() {\n  background(200);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Update the r uniform.\n  let nextR = 0.5 * (sin(frameCount * 0.01) + 1);\n  myShader.setUniform('r', nextR);\n\n  \/\/ Add a plane as a drawing surface.\n  plane(100, 100);\n}\n<\/code>\n<\/div>\n\n<div>\n<code>\n\/\/ Note: A \"uniform\" is a global variable within a shader program.\n\n\/\/ Create a string with the vertex shader program.\n\/\/ The vertex shader is called for each vertex.\nlet vertSrc = `\nprecision highp float;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vTexCoord = aTexCoord;\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n`;\n\n\/\/ Create a string with the fragment shader program.\n\/\/ The fragment shader is called for each pixel.\nlet fragSrc = `\nprecision highp float;\nuniform vec2 p;\nuniform float r;\nconst int numIterations = 500;\nvarying vec2 vTexCoord;\n\nvoid main() {\n  vec2 c = p + gl_FragCoord.xy * r;\n  vec2 z = c;\n  float n = 0.0;\n\n  for (int i = numIterations; i > 0; i--) {\n    if (z.x * z.x + z.y * z.y > 4.0) {\n      n = float(i) \/ float(numIterations);\n      break;\n    }\n\n    z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;\n  }\n\n  gl_FragColor = vec4(\n    0.5 - cos(n * 17.0) \/ 2.0,\n    0.5 - cos(n * 13.0) \/ 2.0,\n    0.5 - cos(n * 23.0) \/ 2.0,\n    1.0\n  );\n}\n`;\n\nlet mandelbrot;\n\nfunction setup() {\n  createCanvas(100, 100, WEBGL);\n\n  \/\/ Create a p5.Shader object.\n  mandelbrot = createShader(vertSrc, fragSrc);\n\n  \/\/ Compile and apply the p5.Shader object.\n  shader(mandelbrot);\n\n  \/\/ Set the shader uniform p to an array.\n  \/\/ p is the center point of the Mandelbrot image.\n  mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]);\n\n  describe('A fractal image zooms in and out of focus.');\n}\n\nfunction draw() {\n  \/\/ Set the shader uniform r to a value that oscillates\n  \/\/ between 0 and 0.005.\n  \/\/ r is the size of the image in Mandelbrot-space.\n  let radius = 0.005 * (sin(frameCount * 0.01) + 1);\n  mandelbrot.setUniform('r', radius);\n\n  \/\/ Style the drawing surface.\n  noStroke();\n\n  \/\/ Add a plane as a drawing surface.\n  plane(100, 100);\n}\n<\/code>\n<\/div>"],"class":"p5.Shader","module":"3D","submodule":"Material"},{"file":"lib\/addons\/p5.sound.js","line":1,"class":"p5.sound","module":"3D"},{"file":"lib\/addons\/p5.sound.js","line":52,"description":"<p>p5.sound \n<a href=\"https:\/\/p5js.org\/reference\/#\/libraries\/p5.sound\">https:\/\/p5js.org\/reference\/#\/libraries\/p5.sound<\/a><\/p>\n<p>From the Processing Foundation and contributors\n<a href=\"https:\/\/github.com\/processing\/p5.js-sound\/graphs\/contributors\">https:\/\/github.com\/processing\/p5.js-sound\/graphs\/contributors<\/a><\/p>\n<p>MIT License (MIT)\n<a href=\"https:\/\/github.com\/processing\/p5.js-sound\/blob\/master\/LICENSE\">https:\/\/github.com\/processing\/p5.js-sound\/blob\/master\/LICENSE<\/a><\/p>\n<p>Some of the many audio libraries & resources that inspire p5.sound:<\/p>\n<ul>\n<li>TONE.js (c) Yotam Mann. Licensed under The MIT License (MIT). <a href=\"https:\/\/github.com\/TONEnoTONE\/Tone.js\">https:\/\/github.com\/TONEnoTONE\/Tone.js<\/a><\/li>\n<li>buzz.js (c) Jay Salvat. Licensed under The MIT License (MIT). <a href=\"http:\/\/buzz.jaysalvat.com\/\">http:\/\/buzz.jaysalvat.com\/<\/a><\/li>\n<li>Boris Smus Web Audio API book, 2013. Licensed under the Apache License <a href=\"http:\/\/www.apache.org\/licenses\/LICENSE-2.0\">http:\/\/www.apache.org\/licenses\/LICENSE-2.0<\/a><\/li>\n<li>wavesurfer.js <a href=\"https:\/\/github.com\/katspaugh\/wavesurfer.js\">https:\/\/github.com\/katspaugh\/wavesurfer.js<\/a><\/li>\n<li>Web Audio Components by Jordan Santell <a href=\"https:\/\/github.com\/web-audio-components\">https:\/\/github.com\/web-audio-components<\/a><\/li>\n<li>Wilm Thoben's Sound library for Processing <a href=\"https:\/\/github.com\/processing\/processing\/tree\/master\/java\/libraries\/sound\">https:\/\/github.com\/processing\/processing\/tree\/master\/java\/libraries\/sound<\/a><\/li>\n<\/ul>\n<p> Web Audio API: <a href=\"http:\/\/w3.org\/TR\/webaudio\/\">http:\/\/w3.org\/TR\/webaudio\/<\/a><\/p>\n","class":"p5.sound","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":159,"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>\n\n<p>Some browsers require users to startAudioContext\nwith a user gesture, such as touchStarted in the example below.<\/p>","itemtype":"method","name":"getAudioContext","return":{"description":"AudioContext for this sketch","type":"Object"},"example":["\n<div><code>\n function draw() {\n   background(255);\n   textAlign(CENTER);\n\n   if (getAudioContext().state !== 'running') {\n     text('click to start audio', width\/2, height\/2);\n   } else {\n     text('audio is enabled', width\/2, height\/2);\n   }\n }\n\n function touchStarted() {\n   if (getAudioContext().state !== 'running') {\n     getAudioContext().resume();\n   }\n   var synth = new p5.MonoSynth();\n   synth.play('A4', 0.5, 0, 0.2);\n }\n\n<\/div><\/code>"],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":198,"description":"<p>It is not only a good practice to give users control over starting\naudio. This policy is enforced by many web browsers, including iOS and\n<a href=\"https:\/\/goo.gl\/7K7WLu\" title=\"Google Chrome's autoplay\npolicy\">Google Chrome<\/a>, which create the Web Audio API's\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/AudioContext\"\ntitle=\"Audio Context @ MDN\">Audio Context<\/a>\nin a suspended state.<\/p>\n\n<p>In these browser-specific policies, sound will not play until a user\ninteraction event (i.e. <code>mousePressed()<\/code>) explicitly resumes\nthe AudioContext, or starts an audio node. This can be accomplished by\ncalling <code>start()<\/code> on a <code>p5.Oscillator<\/code>,\n<code> play()<\/code> on a <code>p5.SoundFile<\/code>, or simply\n<code>userStartAudio()<\/code>.<\/p>\n\n<p><code>userStartAudio()<\/code> starts the AudioContext on a user\ngesture. The default behavior will enable audio on any\nmouseUp or touchEnd event. It can also be placed in a specific\ninteraction function, such as <code>mousePressed()<\/code> as in the\nexample below. This method utilizes\n<a href=\"https:\/\/github.com\/tambien\/StartAudioContext\">StartAudioContext\n<\/a>, a library by Yotam Mann (MIT Licence, 2016).<\/p>","params":[{"name":"elements","description":"<p>This argument can be an Element,\n                              Selector String, NodeList, p5.Element,\n                              jQuery Element, or an Array of any of those.<\/p>\n","type":"Element|Array","optional":true},{"name":"callback","description":"<p>Callback to invoke when the AudioContext\n                              has started<\/p>\n","type":"Function","optional":true}],"return":{"description":"Returns a Promise that resolves when\n                                     the AudioContext state is 'running'","type":"Promise"},"itemtype":"method","name":"userStartAudio","example":["\n<div><code>\nfunction setup() {\n  \/\/ mimics the autoplay policy\n  getAudioContext().suspend();\n\n  let mySynth = new p5.MonoSynth();\n\n  \/\/ This won't play until the context has resumed\n  mySynth.play('A6');\n}\nfunction draw() {\n  background(220);\n  textAlign(CENTER, CENTER);\n  text(getAudioContext().state, width\/2, height\/2);\n}\nfunction mousePressed() {\n  userStartAudio();\n}\n<\/code><\/div>"],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":401,"description":"<p>This module has shims<\/p>\n","class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":536,"description":"<p>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<\/p>\n","class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":726,"description":"<p>Returns a number representing the output volume for sound\nin this sketch.<\/p>\n","itemtype":"method","name":"getOutputVolume","return":{"description":"Output volume for sound in this sketch.\n                 Should be between 0.0 (silence) and 1.0.","type":"Number"},"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":738,"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 Envelope class.\n\n<p>Alternately, you can pass in a signal source such as an\noscillator to modulate the amplitude with an audio signal.<\/p>\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":"outputVolume","params":[{"name":"volume","description":"<p>Volume (amplitude) between 0.0\n                                   and 1.0 or modulating signal\/oscillator<\/p>\n","type":"Number|Object"},{"name":"rampTime","description":"<p>Fade for t seconds<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>Schedule this event to happen at\n                               t seconds in the future<\/p>\n","type":"Number","optional":true}],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":782,"description":"<p><code>p5.soundOut<\/code> is the p5.sound final output bus. 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>.<\/p>\n","itemtype":"property","name":"soundOut","type":"Object","class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":807,"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":811,"description":"<p>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.<\/p>\n","itemtype":"method","name":"sampleRate","return":{"description":"samplerate samples per second","type":"Number"},"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":825,"description":"<p>Returns the closest MIDI note value for\na given frequency.<\/p>\n","itemtype":"method","name":"freqToMidi","params":[{"name":"frequency","description":"<p>A freqeuncy, for example, the \"A\"\n                           above Middle C is 440Hz<\/p>\n","type":"Number"}],"return":{"description":"MIDI note value","type":"Number"},"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":841,"description":"<p>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.<\/p>\n","itemtype":"method","name":"midiToFreq","params":[{"name":"midiNote","description":"<p>The number of a MIDI note<\/p>\n","type":"Number"}],"return":{"description":"Frequency value of the given MIDI note","type":"Number"},"example":["\n<div><code>\nlet midiNotes = [60, 64, 67, 72];\nlet noteIndex = 0;\nlet midiVal, freq;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(startSound);\n  osc = new p5.TriOsc();\n  env = new p5.Envelope();\n}\n\nfunction draw() {\n  background(220);\n  text('tap to play', 10, 20);\n  if (midiVal) {\n    text('MIDI: ' + midiVal, 10, 40);\n    text('Freq: ' + freq, 10, 60);\n  }\n}\n\nfunction startSound() {\n  \/\/ see also: userStartAudio();\n  osc.start();\n\n  midiVal = midiNotes[noteIndex % midiNotes.length];\n  freq = midiToFreq(midiVal);\n  osc.freq(freq);\n  env.ramp(osc, 0, 1.0, 0);\n\n  noteIndex++;\n}\n<\/code><\/div>"],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":925,"description":"<p>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.<\/p>\n","itemtype":"method","name":"soundFormats","params":[{"name":"formats","description":"<p>i.e. 'mp3', 'wav', 'ogg'<\/p>\n","type":"String","optional":true,"multiple":true}],"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('assets\/beatbox.mp3');\n}\n\nfunction setup() {\n     let cnv = createCanvas(100, 100);\n     background(220);\n     text('sound loaded! tap to play', 10, 20, width - 20);\n     cnv.mousePressed(function() {\n       mySound.play();\n     });\n   }\n<\/code><\/div>"],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1040,"description":"<p>Used by Osc and Envelope to chain signal math<\/p>\n","class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1145,"description":"<p>Save a p5.SoundFile as a .wav file. The browser will prompt the user\nto download the file to their device.\nFor uploading audio to a server, use\n<a href=\"\/docs\/reference\/#\/p5.SoundFile\/saveBlob\"><code>p5.SoundFile.saveBlob<\/code><\/a>.<\/p>\n","itemtype":"method","name":"saveSound","params":[{"name":"soundFile","description":"<p>p5.SoundFile that you wish to save<\/p>\n","type":"p5.SoundFile"},{"name":"fileName","description":"<p>name of the resulting .wav file.<\/p>\n","type":"String"}],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1662,"description":"<p>Returns true if the sound file finished loading successfully.<\/p>\n","itemtype":"method","name":"isLoaded","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1679,"description":"<p>Play the p5.SoundFile<\/p>\n","itemtype":"method","name":"play","params":[{"name":"startTime","description":"<p>(optional) schedule playback to start (in seconds from now).<\/p>\n","type":"Number","optional":true},{"name":"rate","description":"<p>(optional) playback rate<\/p>\n","type":"Number","optional":true},{"name":"amp","description":"<p>(optional) amplitude (volume)\n                                    of playback<\/p>\n","type":"Number","optional":true},{"name":"cueStart","description":"<p>(optional) cue start time in seconds<\/p>\n","type":"Number","optional":true},{"name":"duration","description":"<p>(optional) duration of playback in seconds<\/p>\n","type":"Number","optional":true}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1787,"description":"<p>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. With untilDone, a sound will play only if it's\nnot already playing. Sustain is the default mode.<\/p>\n","itemtype":"method","name":"playMode","params":[{"name":"str","description":"<p>'restart' or 'sustain' or 'untilDone'<\/p>\n","type":"String"}],"example":["\n<div><code>\nlet mySound;\nfunction preload(){\n  mySound = loadSound('assets\/Damscray_DancingTiger.mp3');\n}\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n  noFill();\n  rect(0, height\/2, width - 1, height\/2 - 1);\n  rect(0, 0, width - 1, height\/2);\n  textAlign(CENTER, CENTER);\n  fill(20);\n  text('restart', width\/2, 1 * height\/4);\n  text('sustain', width\/2, 3 * height\/4);\n}\nfunction canvasPressed() {\n  if (mouseX < height\/2) {\n    mySound.playMode('restart');\n  } else {\n    mySound.playMode('sustain');\n  }\n  mySound.play();\n}\n\n <\/code><\/div>"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1847,"description":"<p>Pauses a file that is currently playing. If the file is not\nplaying, then nothing will happen.<\/p>\n<p>After pausing, .play() will resume from the paused\nposition.\nIf p5.SoundFile had been set to loop before it was paused,\nit will continue to loop after it is unpaused with .play().<\/p>\n","itemtype":"method","name":"pause","params":[{"name":"startTime","description":"<p>(optional) schedule event to occur\n                             seconds from now<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet soundFile;\nfunction preload() {\n  soundFormats('ogg', 'mp3');\n  soundFile = loadSound('assets\/Damscray_-_Dancing_Tiger_02.mp3');\n}\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n  background(220);\n  text('tap to play, release to pause', 10, 20, width - 20);\n}\nfunction canvasPressed() {\n  soundFile.loop();\n  background(0, 200, 50);\n}\nfunction mouseReleased() {\n  soundFile.pause();\n  background(220);\n}\n<\/code>\n<\/div>"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1905,"description":"<p>Loop the p5.SoundFile. Accepts optional parameters to set the\nplayback rate, playback volume, loopStart, loopEnd.<\/p>\n","itemtype":"method","name":"loop","params":[{"name":"startTime","description":"<p>(optional) schedule event to occur\n                            seconds from now<\/p>\n","type":"Number","optional":true},{"name":"rate","description":"<p>(optional) playback rate<\/p>\n","type":"Number","optional":true},{"name":"amp","description":"<p>(optional) playback volume<\/p>\n","type":"Number","optional":true},{"name":"cueLoopStart","description":"<p>(optional) startTime in seconds<\/p>\n","type":"Number","optional":true},{"name":"duration","description":"<p>(optional) loop duration in seconds<\/p>\n","type":"Number","optional":true}],"example":["\n <div><code>\n let soundFile;\n let loopStart = 0.5;\n let loopDuration = 0.2;\n function preload() {\n   soundFormats('ogg', 'mp3');\n   soundFile = loadSound('assets\/Damscray_-_Dancing_Tiger_02.mp3');\n }\n function setup() {\n   let cnv = createCanvas(100, 100);\n   cnv.mousePressed(canvasPressed);\n   background(220);\n   text('tap to play, release to pause', 10, 20, width - 20);\n }\n function canvasPressed() {\n   soundFile.loop();\n   background(0, 200, 50);\n }\n function mouseReleased() {\n   soundFile.pause();\n   background(220);\n }\n <\/code>\n <\/div>"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1950,"description":"<p>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.<\/p>\n","itemtype":"method","name":"setLoop","params":[{"name":"Boolean","description":"<p>set looping to true or false<\/p>\n","type":"Boolean"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1976,"description":"<p>Returns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.<\/p>\n","itemtype":"method","name":"isLooping","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":1997,"description":"<p>Returns true if a p5.SoundFile is playing, false if not (i.e.\npaused or stopped).<\/p>\n","itemtype":"method","name":"isPlaying","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2011,"description":"<p>Returns true if a p5.SoundFile is paused, false if not (i.e.\nplaying or stopped).<\/p>\n","itemtype":"method","name":"isPaused","return":{"description":"","type":"Boolean"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2025,"description":"<p>Stop soundfile playback.<\/p>\n","itemtype":"method","name":"stop","params":[{"name":"startTime","description":"<p>(optional) schedule event to occur\n                            in seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2087,"description":"<p>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).<\/p>\n","itemtype":"method","name":"pan","params":[{"name":"panValue","description":"<p>Set the stereo panner<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                                seconds from now<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\n let ballX = 0;\n let soundFile;\n\n function preload() {\n   soundFormats('ogg', 'mp3');\n   soundFile = loadSound('assets\/beatbox.mp3');\n }\n\n function draw() {\n   let cnv = createCanvas(100, 100);\n   cnv.mousePressed(canvasPressed);\n   background(220);\n   ballX = constrain(mouseX, 0, width);\n   ellipse(ballX, height\/2, 20, 20);\n }\n\n function canvasPressed(){\n   \/\/ map the ball's x location to a panning degree\n   \/\/ between -1.0 (left) and 1.0 (right)\n   let panning = map(ballX, 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":2131,"description":"<p>Returns the current stereo pan position (-1.0 to 1.0)<\/p>\n","itemtype":"method","name":"getPan","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":2146,"description":"<p>Set the playback rate of a sound file. Will change the speed and the pitch.\nValues less than zero will reverse the audio buffer.<\/p>\n","itemtype":"method","name":"rate","params":[{"name":"playbackRate","description":"<p>Set the playback rate. 1.0 is normal,\n                                   .5 is half-speed, 2.0 is twice as fast.\n                                   Values less than zero play backwards.<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet mySound;\n\nfunction preload() {\n  mySound = loadSound('assets\/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n}\nfunction canvasPressed() {\n  mySound.loop();\n}\nfunction mouseReleased() {\n  mySound.pause();\n}\nfunction draw() {\n  background(220);\n\n  \/\/ Set the rate to a range between 0.1 and 4\n  \/\/ Changing the rate also alters the pitch\n  let playbackRate = map(mouseY, 0.1, height, 2, 0);\n  playbackRate = constrain(playbackRate, 0.01, 4);\n  mySound.rate(playbackRate);\n\n  line(0, mouseY, width, mouseY);\n  text('rate: ' + round(playbackRate * 100) + '%', 10, 20);\n}\n\n <\/code>\n <\/div>\n"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2239,"description":"<p>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 Envelope class.<\/p>\n<p>Alternately, you can pass in a signal source such as an\noscillator to modulate the amplitude with an audio signal.<\/p>\n","itemtype":"method","name":"setVolume","params":[{"name":"volume","description":"<p>Volume (amplitude) between 0.0\n                                   and 1.0 or modulating signal\/oscillator<\/p>\n","type":"Number|Object"},{"name":"rampTime","description":"<p>Fade for t seconds<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>Schedule this event to happen at\n                               t seconds in the future<\/p>\n","type":"Number","optional":true}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2276,"description":"<p>Returns the duration of a sound file in seconds.<\/p>\n","itemtype":"method","name":"duration","return":{"description":"The duration of the soundFile in seconds.","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2293,"description":"<p>Return the current position of the p5.SoundFile playhead, in seconds.\nTime is relative to the normal buffer direction, so if <code>reverseBuffer<\/code>\nhas been called, currentTime will count backwards.<\/p>\n","itemtype":"method","name":"currentTime","return":{"description":"currentTime of the soundFile in seconds.","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2308,"description":"<p>Move the playhead of a soundfile that is currently playing to a\nnew position and a new duration, in seconds.\nIf none are given, will reset the file to play entire duration\nfrom start to finish. To set the position of a soundfile that is\nnot currently playing, use the <code>play<\/code> or <code>loop<\/code> methods.<\/p>\n","itemtype":"method","name":"jump","params":[{"name":"cueTime","description":"<p>cueTime of the soundFile in seconds.<\/p>\n","type":"Number"},{"name":"duration","description":"<p>duration in seconds.<\/p>\n","type":"Number"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2340,"description":"<p>Return the number of channels in a sound file.\nFor example, Mono = 1, Stereo = 2.<\/p>\n","itemtype":"method","name":"channels","return":{"description":"[channels]","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2354,"description":"<p>Return the sample rate of the sound file.<\/p>\n","itemtype":"method","name":"sampleRate","return":{"description":"[sampleRate]","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2367,"description":"<p>Return the number of samples in a sound file.\nEqual to sampleRate * duration.<\/p>\n","itemtype":"method","name":"frames","return":{"description":"[sampleCount]","type":"Number"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2381,"description":"<p>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.<\/p>\n<p>Inspired by Wavesurfer.js.<\/p>\n","itemtype":"method","name":"getPeaks","params":[{"name":"length","description":"<p>length is the size of the returned array.\n                         Larger length results in more precision.\n                         Defaults to 5*width of the browser window.<\/p>\n","type":"Number","optional":true}],"return":{"description":"Array of peaks.","type":"Float32Array"},"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2443,"description":"<p>Reverses the p5.SoundFile's buffer source.\nPlayback must be handled separately (see example).<\/p>\n","itemtype":"method","name":"reverseBuffer","example":["\n<div><code>\nlet drum;\nfunction preload() {\n  drum = loadSound('assets\/drum.mp3');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n  background(220);\n  text('tap to play', 20, 20);\n}\n\nfunction canvasPressed() {\n  drum.stop();\n  drum.reverseBuffer();\n  drum.play();\n}\n <\/code>\n <\/div>"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2497,"description":"<p>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.<\/p>\n","itemtype":"method","name":"onended","params":[{"name":"callback","description":"<p>function to call when the\n                            soundfile has ended.<\/p>\n","type":"Function"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2565,"description":"<p>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 main output. Most p5sound objects connect to the master\noutput when they are created.<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"object","description":"<p>Audio object that accepts an input<\/p>\n","type":"Object","optional":true}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2590,"description":"<p>Disconnects the output of this p5sound object.<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2604,"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2612,"description":"<p>Reset the source for this SoundFile to a\nnew path (URL).<\/p>\n","itemtype":"method","name":"setPath","params":[{"name":"path","description":"<p>path to audio file<\/p>\n","type":"String"},{"name":"callback","description":"<p>Callback<\/p>\n","type":"Function"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2630,"description":"<p>Replace the current Audio Buffer with a new Buffer.<\/p>\n","itemtype":"method","name":"setBuffer","params":[{"name":"buf","description":"<p>Array of Float32 Array(s). 2 Float32 Arrays\n                   will create a stereo source. 1 will create\n                   a mono source.<\/p>\n","type":"Array"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2719,"description":"<p>Schedule events to trigger every time a MediaElement\n(audio\/video) reaches a playback cue point.<\/p>\n<p>Accepts a callback function, a time (in seconds) at which to trigger\nthe callback, and an optional parameter for the callback.<\/p>\n<p>Time will be passed as the first parameter to the callback function,\nand param will be the second parameter.<\/p>\n","itemtype":"method","name":"addCue","params":[{"name":"time","description":"<p>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.<\/p>\n","type":"Number"},{"name":"callback","description":"<p>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.<\/p>\n","type":"Function"},{"name":"value","description":"<p>An object to be passed as the\n                           second parameter to the\n                           callback function.<\/p>\n","type":"Object","optional":true}],"return":{"description":"id ID of this cue,\n                    useful for removeCue(id)","type":"Number"},"example":["\n<div><code>\nlet mySound;\nfunction preload() {\n  mySound = loadSound('assets\/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n  background(220);\n  text('tap to play', 10, 20);\n\n  \/\/ schedule calls to changeText\n  mySound.addCue(0, changeText, \"hello\" );\n  mySound.addCue(0.5, changeText, \"hello,\" );\n  mySound.addCue(1, changeText, \"hello, p5!\");\n  mySound.addCue(1.5, changeText, \"hello, p5!!\");\n  mySound.addCue(2, changeText, \"hello, p5!!!!!\");\n}\n\nfunction changeText(val) {\n  background(220);\n  text(val, 10, 20);\n}\n\nfunction canvasPressed() {\n  mySound.play();\n}\n<\/code><\/div>"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2790,"description":"<p>Remove a callback based on its ID. The ID is returned by the\naddCue method.<\/p>\n","itemtype":"method","name":"removeCue","params":[{"name":"id","description":"<p>ID of the cue, as returned by addCue<\/p>\n","type":"Number"}],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2817,"description":"<p>Remove all of the callbacks that had originally been scheduled\nvia the addCue method.<\/p>\n","itemtype":"method","name":"clearCues","class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2850,"description":"<p>Save a p5.SoundFile as a .wav file. The browser will prompt the user\nto download the file to their device. To upload a file to a server, see\n<a href=\"\/reference\/#\/p5.SoundFile\/getBlob\">getBlob<\/a><\/p>\n","itemtype":"method","name":"save","params":[{"name":"fileName","description":"<p>name of the resulting .wav file.<\/p>\n","type":"String","optional":true}],"example":["\n <div><code>\n let mySound;\n function preload() {\n   mySound = loadSound('assets\/doorbell.mp3');\n }\n function setup() {\n   let cnv = createCanvas(100, 100);\n   cnv.mousePressed(canvasPressed);\n   background(220);\n   text('tap to download', 10, 20);\n }\n\n function canvasPressed() {\n   mySound.save('my cool filename');\n }\n<\/code><\/div>"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2882,"description":"<p>This method is useful for sending a SoundFile to a server. It returns the\n.wav-encoded audio data as a \"<a target=\"_blank\" title=\"Blob reference at\nMDN\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Blob\">Blob<\/a>\".\nA Blob is a file-like data object that can be uploaded to a server\nwith an <a href=\"\/reference\/#\/p5\/httpDo\">http<\/a> request. We'll\nuse the <code>httpDo<\/code> options object to send a POST request with some\nspecific options: we encode the request as <code>multipart\/form-data<\/code>,\nand attach the blob as one of the form values using <code>FormData<\/code>.<\/p>\n","itemtype":"method","name":"getBlob","return":{"description":"A file-like data object","type":"Blob"},"example":["\n <div><code>\n function preload() {\n   mySound = loadSound('assets\/doorbell.mp3');\n }\n\n function setup() {\n   noCanvas();\n   let soundBlob = mySound.getBlob();\n\n   \/\/ Now we can send the blob to a server...\n   let serverUrl = 'https:\/\/jsonplaceholder.typicode.com\/posts';\n   let httpRequestOptions = {\n     method: 'POST',\n     body: new FormData().append('soundBlob', soundBlob),\n     headers: new Headers({\n       'Content-Type': 'multipart\/form-data'\n     })\n   };\n   httpDo(serverUrl, httpRequestOptions);\n\n   \/\/ We can also create an `ObjectURL` pointing to the Blob\n   let blobUrl = URL.createObjectURL(soundBlob);\n\n   \/\/ The `<Audio>` Element accepts Object URL's\n   createAudio(blobUrl).showControls();\n\n   createDiv();\n\n   \/\/ The ObjectURL exists as long as this tab is open\n   let input = createInput(blobUrl);\n   input.attribute('readonly', true);\n   input.mouseClicked(function() { input.elt.select() });\n }\n\n<\/code><\/div>"],"class":"p5.SoundFile","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":2946,"description":"<p>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.<\/p>\n","itemtype":"method","name":"loadSound","params":[{"name":"path","description":"<p>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.<\/p>\n","type":"String|Array"},{"name":"successCallback","description":"<p>Name of a function to call once file loads<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>Name of a function to call if there is\n                                    an error loading the file.<\/p>\n","type":"Function","optional":true},{"name":"whileLoading","description":"<p>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.<\/p>\n","type":"Function","optional":true}],"return":{"description":"Returns a p5.SoundFile","type":"SoundFile"},"example":["\n<div><code>\nlet mySound;\nfunction preload() {\n  soundFormats('mp3', 'ogg');\n  mySound = loadSound('assets\/doorbell');\n}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(canvasPressed);\n  background(220);\n  text('tap here to play', 10, 20);\n}\n\nfunction canvasPressed() {\n  \/\/ playing a sound file on a user gesture\n  \/\/ is equivalent to `userStartAudio()`\n  mySound.play();\n}\n<\/code><\/div>"],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3117,"description":"<p>Connects to the p5sound instance (main output) by default.\nOptionally, you can pass in a specific source (i.e. a soundfile).<\/p>\n","itemtype":"method","name":"setInput","params":[{"name":"snd","description":"<p>set the sound source\n                                     (optional, defaults to\n                                     main output)<\/p>\n","type":"SoundObject|undefined","optional":true},{"name":"smoothing","description":"<p>a range between 0.0 and 1.0\n                                      to smooth amplitude readings<\/p>\n","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  cnv = createCanvas(100, 100);\n  cnv.mouseClicked(toggleSound);\n\n  amplitude = new p5.Amplitude();\n  amplitude.setInput(sound2);\n}\n\nfunction draw() {\n  background(220);\n  text('tap to play', 20, 20);\n\n  let level = amplitude.getLevel();\n  let size = map(level, 0, 1, 0, 200);\n  ellipse(width\/2, height\/2, size, size);\n}\n\nfunction toggleSound(){\n  if (sound1.isPlaying() && sound2.isPlaying()) {\n    sound1.stop();\n    sound2.stop();\n  } else {\n    sound1.play();\n    sound2.play();\n  }\n}\n<\/code><\/div>"],"class":"p5.Amplitude","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3209,"description":"<p>Returns a single Amplitude reading at the moment it is called.\nFor continuous readings, run in the draw loop.<\/p>\n","itemtype":"method","name":"getLevel","params":[{"name":"channel","description":"<p>Optionally return only channel 0 (left) or 1 (right)<\/p>\n","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}\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mouseClicked(toggleSound);\n  amplitude = new p5.Amplitude();\n}\n\nfunction draw() {\n  background(220, 150);\n  textAlign(CENTER);\n  text('tap to play', width\/2, 20);\n\n  let level = amplitude.getLevel();\n  let size = map(level, 0, 1, 0, 200);\n  ellipse(width\/2, height\/2, size, size);\n}\n\nfunction toggleSound(){\n  if (sound.isPlaying()) {\n    sound.stop();\n  } else {\n    sound.play();\n  }\n}\n<\/code><\/div>"],"class":"p5.Amplitude","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3264,"description":"<p>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.<\/p>\n","itemtype":"method","name":"toggleNormalize","params":[{"name":"boolean","description":"<p>set normalize to true (1) or false (0)<\/p>\n","type":"Boolean","optional":true}],"class":"p5.Amplitude","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3293,"description":"<p>Smooth Amplitude analysis by averaging with the last analysis\nframe. Off by default.<\/p>\n","itemtype":"method","name":"smooth","params":[{"name":"set","description":"<p>smoothing from 0.0 <= 1<\/p>\n","type":"Number"}],"class":"p5.Amplitude","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3476,"description":"<p>Set the input source for the FFT analysis. If no source is\nprovided, FFT will analyze all sound in the sketch.<\/p>\n","itemtype":"method","name":"setInput","params":[{"name":"source","description":"<p>p5.sound object (or web audio API source node)<\/p>\n","type":"Object","optional":true}],"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3501,"description":"<p>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.<\/p>\n","itemtype":"method","name":"waveform","params":[{"name":"bins","description":"<p>Must be a power of two between\n                          16 and 1024. Defaults to 1024.<\/p>\n","type":"Number","optional":true},{"name":"precision","description":"<p>If any value is provided, will return results\n                            in a Float32 Array which is more precise\n                            than a regular array.<\/p>\n","type":"String","optional":true}],"return":{"description":"Array    Array of amplitude values (-1 to 1)\n                          over time. Array length = bins.","type":"Array"},"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3553,"description":"<p>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>.<\/p>\n","itemtype":"method","name":"analyze","params":[{"name":"bins","description":"<p>Must be a power of two between\n                           16 and 1024. Defaults to 1024.<\/p>\n","type":"Number","optional":true},{"name":"scale","description":"<p>If \"dB,\" returns decibel\n                           float measurements between\n                           -140 and 0 (max).\n                           Otherwise returns integers from 0-255.<\/p>\n","type":"Number","optional":true}],"return":{"description":"spectrum    Array of energy (amplitude\/volume)\n                            values across the frequency spectrum.\n                            Lowest energy (silence) = 0, highest\n                            possible is 255.","type":"Array"},"example":["\n<div><code>\nlet osc, fft;\n\nfunction setup(){\n  let cnv = createCanvas(100,100);\n  cnv.mousePressed(startSound);\n  osc = new p5.Oscillator();\n  osc.amp(0);\n  fft = new p5.FFT();\n}\n\nfunction draw(){\n  background(220);\n\n  let freq = map(mouseX, 0, windowWidth, 20, 10000);\n  freq = constrain(freq, 1, 20000);\n  osc.freq(freq);\n\n  let spectrum = fft.analyze();\n  noStroke();\n  fill(255, 0, 255);\n  for (let i = 0; i< spectrum.length; i++){\n    let x = map(i, 0, spectrum.length, 0, width);\n    let h = -height + map(spectrum[i], 0, 255, height, 0);\n    rect(x, height, width \/ spectrum.length, h );\n  }\n\n  stroke(255);\n  if (!osc.started) {\n    text('tap here and drag to change frequency', 10, 20, width - 20);\n  } else {\n    text(round(freq)+'Hz', 10, 20);\n  }\n}\n\nfunction startSound() {\n  osc.start();\n  osc.amp(0.5, 0.2);\n}\n\nfunction mouseReleased() {\n  osc.amp(0, 0.2);\n}\n<\/code><\/div>\n\n"],"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3650,"description":"<p>Returns the amount of energy (volume) at a specific\n<a href=\"https:\/\/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 to determine the value at a specific frequency or\nrange of frequencies.<\/em><\/p><\/p>\n","itemtype":"method","name":"getEnergy","params":[{"name":"frequency1","description":"<p>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.<\/p>\n","type":"Number|String"},{"name":"frequency2","description":"<p>If a second frequency is given,\n                              will return average amount of\n                              energy that exists between the\n                              two frequencies.<\/p>\n","type":"Number","optional":true}],"return":{"description":"Energy   Energy (volume\/amplitude) from\n                            0 and 255.","type":"Number"},"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3739,"description":"<p>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><\/p>\n","itemtype":"method","name":"getCentroid","return":{"description":"Spectral Centroid Frequency  of the spectral centroid in Hz.","type":"Number"},"example":["\n<div><code>\n function setup(){\ncnv = createCanvas(100,100);\ncnv.mousePressed(userStartAudio);\nsound = new p5.AudioIn();\nsound.start();\nfft = new p5.FFT();\nsound.connect(fft);\n}\n\nfunction draw() {\nif (getAudioContext().state !== 'running') {\n  background(220);\n  text('tap here and enable mic to begin', 10, 20, width - 20);\n  return;\n}\nlet centroidplot = 0.0;\nlet spectralCentroid = 0;\n\nbackground(0);\nstroke(0,255,0);\nlet spectrum = fft.analyze();\nfill(0,255,0); \/\/ spectrum is green\n\n\/\/draw the spectrum\nfor (let i = 0; i < spectrum.length; i++){\n  let x = map(log(i), 0, log(spectrum.length), 0, width);\n  let h = map(spectrum[i], 0, 255, 0, height);\n  let rectangle_width = (log(i+1)-log(i))*(width\/log(spectrum.length));\n  rect(x, height, rectangle_width, -h )\n}\nlet nyquist = 22050;\n\n\/\/ get the centroid\nspectralCentroid = fft.getCentroid();\n\n\/\/ the mean_freq_index calculation is for the display.\nlet mean_freq_index = spectralCentroid\/(nyquist\/spectrum.length);\n\ncentroidplot = map(log(mean_freq_index), 0, log(spectrum.length), 0, width);\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\ntext('centroid: ', 10, 20);\ntext(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":3826,"description":"<p>Smooth FFT analysis by averaging with the last analysis frame.<\/p>\n","itemtype":"method","name":"smooth","params":[{"name":"smoothing","description":"<p>0.0 < smoothing < 1.0.\n                             Defaults to 0.8.<\/p>\n","type":"Number"}],"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3854,"description":"<p>Returns an array of average amplitude values for a given number\nof frequency bands split equally. N defaults to 16.\n<em>NOTE: analyze() must be called prior to linAverages(). Analyze()\ntells the FFT to analyze frequency data, and linAverages() uses\nthe results to group them into a smaller set of averages.<\/em><\/p><\/p>\n","itemtype":"method","name":"linAverages","params":[{"name":"N","description":"<p>Number of returned frequency groups<\/p>\n","type":"Number"}],"return":{"description":"linearAverages   Array of average amplitude values for each group","type":"Array"},"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3889,"description":"<p>Returns an array of average amplitude values of the spectrum, for a given\nset of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Octave_band\" target=\"_blank\">\nOctave Bands<\/a>\n<em>NOTE: analyze() must be called prior to logAverages(). Analyze()\ntells the FFT to analyze frequency data, and logAverages() uses\nthe results to group them into a smaller set of averages.<\/em><\/p><\/p>\n","itemtype":"method","name":"logAverages","params":[{"name":"octaveBands","description":"<p>Array of Octave Bands objects for grouping<\/p>\n","type":"Array"}],"return":{"description":"logAverages    Array of average amplitude values for each group","type":"Array"},"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":3925,"description":"<p>Calculates and Returns the 1\/N\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Octave_band\" target=\"_blank\">Octave Bands<\/a>\nN defaults to 3 and minimum central frequency to 15.625Hz.\n(1\/3 Octave Bands ~= 31 Frequency Bands)\nSetting fCtr0 to a central value of a higher octave will ignore the lower bands\nand produce less frequency groups.<\/p>\n","itemtype":"method","name":"getOctaveBands","params":[{"name":"N","description":"<p>Specifies the 1\/N type of generated octave bands<\/p>\n","type":"Number"},{"name":"fCtr0","description":"<p>Minimum central frequency for the lowest band<\/p>\n","type":"Number"}],"return":{"description":"octaveBands   Array of octave band objects with their bounds","type":"Array"},"class":"p5.FFT","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4168,"description":"<p>Start an oscillator.<\/p>\n<p>Starting an oscillator on a user gesture will enable audio in browsers\nthat have a strict autoplay policy, including Chrome and most mobile\ndevices. See also: <code>userStartAudio()<\/code>.<\/p>\n","itemtype":"method","name":"start","params":[{"name":"time","description":"<p>startTime in seconds from now.<\/p>\n","type":"Number","optional":true},{"name":"frequency","description":"<p>frequency in Hz.<\/p>\n","type":"Number","optional":true}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4218,"description":"<p>Stop an oscillator. Accepts an optional parameter\nto determine how long (in seconds from now) until the\noscillator stops.<\/p>\n","itemtype":"method","name":"stop","params":[{"name":"secondsFromNow","description":"<p>Time, in seconds from now.<\/p>\n","type":"Number"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4238,"description":"<p>Set the amplitude between 0 and 1.0. Or, pass in an object\nsuch as an oscillator to modulate amplitude with an audio signal.<\/p>\n","itemtype":"method","name":"amp","params":[{"name":"vol","description":"<p>between 0 and 1.0\n                            or a modulating signal\/oscillator<\/p>\n","type":"Number|Object"},{"name":"rampTime","description":"<p>create a fade that lasts rampTime<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number","optional":true}],"return":{"description":"gain  If no value is provided,\n                            returns the Web Audio API\n                            AudioParam that controls\n                            this oscillator's\n                            gain\/amplitude\/volume)","type":"AudioParam"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4271,"description":"<p>Returns the value of output gain<\/p>\n","itemtype":"method","name":"getAmp","return":{"description":"Amplitude value between 0.0 and 1.0","type":"Number"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4285,"description":"<p>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.<\/p>\n","itemtype":"method","name":"freq","params":[{"name":"Frequency","description":"<p>Frequency in Hz\n                                      or modulating signal\/oscillator<\/p>\n","type":"Number|Object"},{"name":"rampTime","description":"<p>Ramp time (in seconds)<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>Schedule this event to happen\n                                 at x seconds from now<\/p>\n","type":"Number","optional":true}],"return":{"description":"Frequency If no value is provided,\n                                returns the Web Audio API\n                                AudioParam that controls\n                                this oscillator's frequency","type":"AudioParam"},"example":["\n<div><code>\nlet osc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playOscillator);\n  osc = new p5.Oscillator(300);\n  background(220);\n  text('tap to play', 20, 20);\n}\n\nfunction playOscillator() {\n  osc.start();\n  osc.amp(0.5);\n  \/\/ start at 700Hz\n  osc.freq(700);\n  \/\/ ramp to 60Hz over 0.7 seconds\n  osc.freq(60, 0.7);\n  osc.amp(0, 0.1, 0.7);\n}\n<\/code><\/div>"],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4360,"description":"<p>Returns the value of frequency of oscillator<\/p>\n","itemtype":"method","name":"getFreq","return":{"description":"Frequency of oscillator in Hertz","type":"Number"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4373,"description":"<p>Set type to 'sine', 'triangle', 'sawtooth' or 'square'.<\/p>\n","itemtype":"method","name":"setType","params":[{"name":"type","description":"<p>'sine', 'triangle', 'sawtooth' or 'square'.<\/p>\n","type":"String"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4386,"description":"<p>Returns  current type of oscillator eg. 'sine', 'triangle', 'sawtooth' or 'square'.<\/p>\n","itemtype":"method","name":"getType","return":{"description":"type of oscillator  eg . 'sine', 'triangle', 'sawtooth' or 'square'.","type":"String"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4399,"description":"<p>Connect to a p5.sound \/ Web Audio object.<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"<p>A p5.sound or Web Audio object<\/p>\n","type":"Object"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4420,"description":"<p>Disconnect all outputs<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4444,"description":"<p>Pan between Left (-1) and Right (1)<\/p>\n","itemtype":"method","name":"pan","params":[{"name":"panning","description":"<p>Number between -1 and 1<\/p>\n","type":"Number"},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4460,"description":"<p>Returns the current value of panPosition , between Left (-1) and Right (1)<\/p>\n","itemtype":"method","name":"getPan","return":{"description":"panPosition of oscillator , between Left (-1) and Right (1)","type":"Number"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4494,"description":"<p>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.<\/p>\n","itemtype":"method","name":"phase","params":[{"name":"phase","description":"<p>float between 0.0 and 1.0<\/p>\n","type":"Number"}],"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4522,"description":"<p>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.<\/p>\n","itemtype":"method","name":"add","params":[{"name":"number","description":"<p>Constant number to add<\/p>\n","type":"Number"}],"return":{"description":"Oscillator Returns this oscillator\n                                   with scaled output","type":"p5.Oscillator"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4543,"description":"<p>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.<\/p>\n","itemtype":"method","name":"mult","params":[{"name":"number","description":"<p>Constant number to multiply<\/p>\n","type":"Number"}],"return":{"description":"Oscillator Returns this oscillator\n                                   with multiplied output","type":"p5.Oscillator"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4563,"description":"<p>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.<\/p>\n","itemtype":"method","name":"scale","params":[{"name":"inMin","description":"<p>input range minumum<\/p>\n","type":"Number"},{"name":"inMax","description":"<p>input range maximum<\/p>\n","type":"Number"},{"name":"outMin","description":"<p>input range minumum<\/p>\n","type":"Number"},{"name":"outMax","description":"<p>input range maximum<\/p>\n","type":"Number"}],"return":{"description":"Oscillator Returns this oscillator\n                                   with scaled output","type":"p5.Oscillator"},"class":"p5.Oscillator","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4767,"description":"<p>Time until envelope reaches attackLevel<\/p>\n","itemtype":"property","name":"attackTime","class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4772,"description":"<p>Level once attack is complete.<\/p>\n","itemtype":"property","name":"attackLevel","class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4778,"description":"<p>Time until envelope reaches decayLevel.<\/p>\n","itemtype":"property","name":"decayTime","class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4784,"description":"<p>Level after decay. The envelope will sustain here until it is released.<\/p>\n","itemtype":"property","name":"decayLevel","class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4790,"description":"<p>Duration of the release portion of the envelope.<\/p>\n","itemtype":"property","name":"releaseTime","class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4796,"description":"<p>Level at the end of the release.<\/p>\n","itemtype":"property","name":"releaseLevel","class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4833,"description":"<p>Reset the envelope with a series of time\/value pairs.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"attackTime","description":"<p>Time (in seconds) before level\n                               reaches attackLevel<\/p>\n","type":"Number"},{"name":"attackLevel","description":"<p>Typically an amplitude between\n                               0.0 and 1.0<\/p>\n","type":"Number"},{"name":"decayTime","description":"<p>Time<\/p>\n","type":"Number"},{"name":"decayLevel","description":"<p>Amplitude (In a standard ADSR envelope,\n                               decayLevel = sustainLevel)<\/p>\n","type":"Number"},{"name":"releaseTime","description":"<p>Release Time (in seconds)<\/p>\n","type":"Number"},{"name":"releaseLevel","description":"<p>Amplitude<\/p>\n","type":"Number"}],"example":["\n<div><code>\nlet attackTime;\nlet l1 = 0.7; \/\/ attack level 0.0 to 1.0\nlet t2 = 0.3; \/\/ decay time in seconds\nlet l2 = 0.1; \/\/ decay level  0.0 to 1.0\nlet l3 = 0.2; \/\/ release time in seconds\n\nlet env, triOsc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSound);\n\n  env = new p5.Envelope();\n  triOsc = new p5.Oscillator('triangle');\n}\n\nfunction draw() {\n  background(220);\n  text('tap here to play', 5, 20);\n\n  attackTime = map(mouseX, 0, width, 0.0, 1.0);\n  text('attack time: ' + attackTime, 5, height - 20);\n}\n\n\/\/ mouseClick triggers envelope if over canvas\nfunction playSound() {\n  env.set(attackTime, l1, t2, l2, l3);\n\n  triOsc.start();\n  env.play(triOsc);\n}\n<\/code><\/div>\n"],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4895,"description":"<p>Set values like a traditional\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Synthesizer#\/media\/File:ADSR_parameter.svg\">\nADSR envelope\n<\/a>.<\/p>\n","itemtype":"method","name":"setADSR","params":[{"name":"attackTime","description":"<p>Time (in seconds before envelope\n                              reaches Attack Level<\/p>\n","type":"Number"},{"name":"decayTime","description":"<p>Time (in seconds) before envelope\n                              reaches Decay\/Sustain Level<\/p>\n","type":"Number","optional":true},{"name":"susRatio","description":"<p>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.<\/p>\n","type":"Number","optional":true},{"name":"releaseTime","description":"<p>Time in seconds from now (defaults to 0)<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet attackLevel = 1.0;\nlet releaseLevel = 0;\n\nlet attackTime = 0.001;\nlet decayTime = 0.2;\nlet susPercent = 0.2;\nlet releaseTime = 0.5;\n\nlet env, triOsc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playEnv);\n\n  env = new p5.Envelope();\n  triOsc = new p5.Oscillator('triangle');\n  triOsc.amp(env);\n  triOsc.freq(220);\n}\n\nfunction draw() {\n  background(220);\n  text('tap here to play', 5, 20);\n  attackTime = map(mouseX, 0, width, 0, 1.0);\n  text('attack time: ' + attackTime, 5, height - 40);\n}\n\nfunction playEnv() {\n  triOsc.start();\n  env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n  env.play();\n}\n<\/code><\/div>"],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":4964,"description":"<p>Set max (attackLevel) and min (releaseLevel) of envelope.<\/p>\n","itemtype":"method","name":"setRange","params":[{"name":"aLevel","description":"<p>attack level (defaults to 1)<\/p>\n","type":"Number"},{"name":"rLevel","description":"<p>release level (defaults to 0)<\/p>\n","type":"Number"}],"example":["\n<div><code>\nlet attackLevel = 1.0;\nlet releaseLevel = 0;\n\nlet attackTime = 0.001;\nlet decayTime = 0.2;\nlet susPercent = 0.2;\nlet releaseTime = 0.5;\n\nlet env, triOsc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playEnv);\n\n  env = new p5.Envelope();\n  triOsc = new p5.Oscillator('triangle');\n  triOsc.amp(env);\n  triOsc.freq(220);\n}\n\nfunction draw() {\n  background(220);\n  text('tap here to play', 5, 20);\n  attackLevel = map(mouseY, height, 0, 0, 1.0);\n  text('attack level: ' + attackLevel, 5, height - 20);\n}\n\nfunction playEnv() {\n  triOsc.start();\n  env.setRange(attackLevel, releaseLevel);\n  env.play();\n}\n<\/code><\/div>"],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5037,"description":"<p>Assign a parameter to be controlled by this envelope.\nIf a p5.Sound object is given, then the p5.Envelope will control its\noutput gain. If multiple inputs are provided, the env will\ncontrol all of them.<\/p>\n","itemtype":"method","name":"setInput","params":[{"name":"inputs","description":"<p>A p5.sound object or\n                              Web Audio Param.<\/p>\n","type":"Object","optional":true,"multiple":true}],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5055,"description":"<p>Set whether the envelope ramp is linear (default) or exponential.\nExponential ramps can be useful because we perceive amplitude\nand frequency logarithmically.<\/p>\n","itemtype":"method","name":"setExp","params":[{"name":"isExp","description":"<p>true is exponential, false is linear<\/p>\n","type":"Boolean"}],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5078,"description":"<p>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 Envelope 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><\/p>","itemtype":"method","name":"play","params":[{"name":"unit","description":"<p>A p5.sound object or\n                              Web Audio Param.<\/p>\n","type":"Object"},{"name":"startTime","description":"<p>time from now (in seconds) at which to play<\/p>\n","type":"Number","optional":true},{"name":"sustainTime","description":"<p>time to sustain before releasing the envelope<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet attackLevel = 1.0;\nlet releaseLevel = 0;\n\nlet attackTime = 0.001;\nlet decayTime = 0.2;\nlet susPercent = 0.2;\nlet releaseTime = 0.5;\n\nlet env, triOsc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playEnv);\n\n  env = new p5.Envelope();\n  triOsc = new p5.Oscillator('triangle');\n  triOsc.amp(env);\n  triOsc.freq(220);\n  triOsc.start();\n}\n\nfunction draw() {\n  background(220);\n  text('tap here to play', 5, 20);\n  attackTime = map(mouseX, 0, width, 0, 1.0);\n  attackLevel = map(mouseY, height, 0, 0, 1.0);\n  text('attack time: ' + attackTime, 5, height - 40);\n  text('attack level: ' + attackLevel, 5, height - 20);\n}\n\nfunction playEnv() {\n  \/\/ ensure that audio is enabled\n  userStartAudio();\n\n  env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n  env.setRange(attackLevel, releaseLevel);\n  env.play();\n}\n<\/code><\/div>"],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5148,"description":"<p>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>.<\/p>\n","itemtype":"method","name":"triggerAttack","params":[{"name":"unit","description":"<p>p5.sound Object or Web Audio Param<\/p>\n","type":"Object"},{"name":"secondsFromNow","description":"<p>time from now (in seconds)<\/p>\n","type":"Number"}],"example":["\n<div><code>\nlet attackTime = 0.001;\nlet decayTime = 0.2;\nlet susPercent = 0.3;\nlet releaseTime = 0.4;\nlet env, triOsc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  background(220);\n  textAlign(CENTER);\n  textSize(10);\n  text('tap to triggerAttack', width\/2, height\/2);\n\n  env = new p5.Envelope();\n  env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n  env.setRange(1.0, 0.0);\n  triOsc = new p5.Oscillator('triangle');\n  triOsc.freq(220);\n\n  cnv.mousePressed(envAttack);\n}\n\nfunction envAttack()  {\n  background(0, 255, 255);\n  text('release to release', width\/2, height\/2);\n\n  \/\/ ensures audio is enabled. See also: `userStartAudio`\n  triOsc.start();\n\n  env.triggerAttack(triOsc);\n}\n\nfunction mouseReleased() {\n  background(220);\n  text('tap to triggerAttack', width\/2, height\/2);\n\n  env.triggerRelease(triOsc);\n}\n<\/code><\/div>"],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5256,"description":"<p>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.<\/p>\n","itemtype":"method","name":"triggerRelease","params":[{"name":"unit","description":"<p>p5.sound Object or Web Audio Param<\/p>\n","type":"Object"},{"name":"secondsFromNow","description":"<p>time to trigger the release<\/p>\n","type":"Number"}],"example":["\n<div><code>\nlet attackTime = 0.001;\nlet decayTime = 0.2;\nlet susPercent = 0.3;\nlet releaseTime = 0.4;\nlet env, triOsc;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  background(220);\n  textAlign(CENTER);\n  textSize(10);\n  text('tap to triggerAttack', width\/2, height\/2);\n\n  env = new p5.Envelope();\n  env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n  env.setRange(1.0, 0.0);\n  triOsc = new p5.Oscillator('triangle');\n  triOsc.freq(220);\n\n  cnv.mousePressed(envAttack);\n}\n\nfunction envAttack()  {\n  background(0, 255, 255);\n  text('release to release', width\/2, height\/2);\n\n  \/\/ ensures audio is enabled. See also: `userStartAudio`\n  triOsc.start();\n\n  env.triggerAttack(triOsc);\n}\n\nfunction mouseReleased() {\n  background(220);\n  text('tap to triggerAttack', width\/2, height\/2);\n\n  env.triggerRelease(triOsc);\n}\n<\/code><\/div>"],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5350,"description":"<p>Exponentially ramp to a value using the first two\nvalues from <code><a href=\"#\/p5.Envelope\/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.<\/p>\n","itemtype":"method","name":"ramp","params":[{"name":"unit","description":"<p>p5.sound Object or Web Audio Param<\/p>\n","type":"Object"},{"name":"secondsFromNow","description":"<p>When to trigger the ramp<\/p>\n","type":"Number"},{"name":"v","description":"<p>Target value<\/p>\n","type":"Number"},{"name":"v2","description":"<p>Second target value<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet env, osc, amp;\n\nlet attackTime = 0.001;\nlet decayTime = 0.2;\nlet attackLevel = 1;\nlet decayLevel = 0;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  fill(0,255,0);\n  noStroke();\n\n  env = new p5.Envelope();\n  env.setADSR(attackTime, decayTime);\n  osc = new p5.Oscillator();\n  osc.amp(env);\n  amp = new p5.Amplitude();\n\n  cnv.mousePressed(triggerRamp);\n}\n\nfunction triggerRamp() {\n  \/\/ ensures audio is enabled. See also: `userStartAudio`\n  osc.start();\n\n  env.ramp(osc, 0, attackLevel, decayLevel);\n}\n\nfunction draw() {\n  background(20);\n  text('tap to play', 10, 20);\n  let h = map(amp.getLevel(), 0, 0.4, 0, height);;\n  rect(0, height, width, -h);\n}\n<\/code><\/div>"],"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5460,"description":"<p>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.<\/p>\n","itemtype":"method","name":"add","params":[{"name":"number","description":"<p>Constant number to add<\/p>\n","type":"Number"}],"return":{"description":"Envelope Returns this envelope\n                                   with scaled output","type":"p5.Envelope"},"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5479,"description":"<p>Multiply the p5.Envelope's output amplitude\nby a fixed value. Calling this method\nagain will override the initial mult() with new values.<\/p>\n","itemtype":"method","name":"mult","params":[{"name":"number","description":"<p>Constant number to multiply<\/p>\n","type":"Number"}],"return":{"description":"Envelope Returns this envelope\n                                   with scaled output","type":"p5.Envelope"},"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5498,"description":"<p>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.<\/p>\n","itemtype":"method","name":"scale","params":[{"name":"inMin","description":"<p>input range minumum<\/p>\n","type":"Number"},{"name":"inMax","description":"<p>input range maximum<\/p>\n","type":"Number"},{"name":"outMin","description":"<p>input range minumum<\/p>\n","type":"Number"},{"name":"outMax","description":"<p>input range maximum<\/p>\n","type":"Number"}],"return":{"description":"Envelope Returns this envelope\n                                   with scaled output","type":"p5.Envelope"},"class":"p5.Envelope","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5657,"description":"<p>Set type of noise to 'white', 'pink' or 'brown'.\nWhite is the default.<\/p>\n","itemtype":"method","name":"setType","params":[{"name":"type","description":"<p>'white', 'pink' or 'brown'<\/p>\n","type":"String","optional":true}],"class":"p5.Noise","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":5871,"description":"<p>Set the width of a Pulse object (an oscillator that implements\nPulse Width Modulation).<\/p>\n","itemtype":"method","name":"width","params":[{"name":"width","description":"<p>Width between the pulses (0 to 1.0,\n                       defaults to 0)<\/p>\n","type":"Number","optional":true}],"class":"p5.Pulse","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6066,"itemtype":"property","name":"input","type":"GainNode","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6070,"itemtype":"property","name":"output","type":"GainNode","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6075,"itemtype":"property","name":"stream","type":"MediaStream|null","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6080,"itemtype":"property","name":"mediaStream","type":"MediaStreamAudioSourceNode|null","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6085,"itemtype":"property","name":"currentSource","type":"Number|null","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6090,"description":"<p>Client must allow browser to access their microphone \/ audioin source.\nDefault: false. Will become true when the client enables access.<\/p>\n","itemtype":"property","name":"enabled","type":"Boolean","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6098,"description":"<p>Input amplitude, connect to it by default but not to master out<\/p>\n","itemtype":"property","name":"amplitude","type":"p5.Amplitude","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6114,"description":"<p>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\/><\/p>\n<p>Certain browsers limit access to the user's microphone. For example,\nChrome only allows access from localhost and over https. For this reason,\nyou may want to include an errorCallback\u2014a function that is called in case\nthe browser won't provide mic access.<\/p>\n","itemtype":"method","name":"start","params":[{"name":"successCallback","description":"<p>Name of a function to call on\n                                  success.<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>Name of a function to call if\n                                  there was an error. For example,\n                                  some browsers do not support\n                                  getUserMedia.<\/p>\n","type":"Function","optional":true}],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6171,"description":"<p>Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\nIf re-starting, the user may be prompted for permission access.<\/p>\n","itemtype":"method","name":"stop","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6191,"description":"<p>Connect to an audio unit. If no parameter is provided, will\nconnect to the main output (i.e. your speakers).<br\/><\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"<p>An object that accepts audio input,\n                        such as an FFT<\/p>\n","type":"Object","optional":true}],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6216,"description":"<p>Disconnect the AudioIn from all audio units. For example, if\nconnect() had been called, disconnect() will stop sending\nsignal to your speakers.<br\/><\/p>\n","itemtype":"method","name":"disconnect","class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6234,"description":"<p>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\/><\/p>\n","itemtype":"method","name":"getLevel","params":[{"name":"smoothing","description":"<p>Smoothing is 0.0 by default.\n                             Smooths values based on previous values.<\/p>\n","type":"Number","optional":true}],"return":{"description":"Volume level (between 0.0 and 1.0)","type":"Number"},"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6257,"description":"<p>Set amplitude (volume) of a mic input between 0 and 1.0. <br\/><\/p>\n","itemtype":"method","name":"amp","params":[{"name":"vol","description":"<p>between 0 and 1.0<\/p>\n","type":"Number"},{"name":"time","description":"<p>ramp time (optional)<\/p>\n","type":"Number","optional":true}],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6280,"description":"<p>Returns a list of available input sources. This is a wrapper\nfor <a href=\"https:\/\/developer.mozilla.org\/\nen-US\/docs\/Web\/API\/MediaDevices\/enumerateDevices\" target=\"_blank\">\nMediaDevices.enumerateDevices() - Web APIs | MDN<\/a>\nand it returns a Promise.<\/p>\n","itemtype":"method","name":"getSources","params":[{"name":"successCallback","description":"<p>This callback function handles the sources when they\n                                     have been enumerated. The callback function\n                                     receives the deviceList array as its only argument<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>This optional callback receives the error\n                                   message as its argument.<\/p>\n","type":"Function","optional":true}],"return":{"description":"Returns a Promise that can be used in place of the callbacks, similar\n                           to the enumerateDevices() method","type":"Promise"},"example":["\n <div><code>\n let audioIn;\n\n function setup(){\n   text('getting sources...', 0, 20);\n   audioIn = new p5.AudioIn();\n   audioIn.getSources(gotSources);\n }\n\n function gotSources(deviceList) {\n   if (deviceList.length > 0) {\n     \/\/set the source to the first item in the deviceList array\n     audioIn.setSource(0);\n     let currentSource = deviceList[audioIn.currentSource];\n     text('set source to: ' + currentSource.deviceId, 5, 20, width);\n   }\n }\n <\/code><\/div>"],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6340,"description":"<p>Set the input source. Accepts a number representing a\nposition in the array returned by getSources().\nThis is only available in browsers that support\n <a href=\"https:\/\/developer.mozilla.org\/\n en-US\/docs\/Web\/API\/MediaDevices\/enumerateDevices\" target=\"_blank\">\n navigator.mediaDevices.enumerateDevices()<\/a><\/p>\n","itemtype":"method","name":"setSource","params":[{"name":"num","description":"<p>position of input source in the array<\/p>\n","type":"Number"}],"example":["\n<div><code>\nlet audioIn;\n\nfunction setup(){\n  text('getting sources...', 0, 20);\n  audioIn = new p5.AudioIn();\n  audioIn.getSources(gotSources);\n}\n\nfunction gotSources(deviceList) {\n  if (deviceList.length > 0) {\n    \/\/set the source to the first item in the deviceList array\n    audioIn.setSource(0);\n    let currentSource = deviceList[audioIn.currentSource];\n    text('set source to: ' + currentSource.deviceId, 5, 20, width);\n  }\n}\n<\/code><\/div>"],"class":"p5.AudioIn","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6462,"description":"<p>In classes that extend\np5.Effect, connect effect nodes\nto the wet parameter<\/p>\n","class":"p5.Effect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6478,"description":"<p>Set the output volume of the filter.<\/p>\n","itemtype":"method","name":"amp","params":[{"name":"vol","description":"<p>amplitude between 0 and 1.0<\/p>\n","type":"Number","optional":true},{"name":"rampTime","description":"<p>create a fade that lasts until rampTime<\/p>\n","type":"Number","optional":true},{"name":"tFromNow","description":"<p>schedule this event to happen in tFromNow seconds<\/p>\n","type":"Number","optional":true}],"class":"p5.Effect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6502,"description":"<p>Link effects together in a chain\nExample usage: filter.chain(reverb, delay, panner);\nMay be used with an open-ended number of arguments<\/p>\n","itemtype":"method","name":"chain","params":[{"name":"arguments","description":"<p>Chain together multiple sound objects<\/p>\n","type":"Object","optional":true}],"class":"p5.Effect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6525,"description":"<p>Adjust the dry\/wet value.<\/p>\n","itemtype":"method","name":"drywet","params":[{"name":"fade","description":"<p>The desired drywet value (0 - 1.0)<\/p>\n","type":"Number","optional":true}],"class":"p5.Effect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6542,"description":"<p>Send output to a p5.js-sound, Web Audio Node, or use signal to\ncontrol an AudioParam<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Effect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6557,"description":"<p>Disconnect all output.<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.Effect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6719,"description":"<p>The p5.Filter is built with a\n<a href=\"http:\/\/www.w3.org\/TR\/webaudio\/#BiquadFilterNode\">\nWeb Audio BiquadFilter Node<\/a>.<\/p>\n","itemtype":"property","name":"biquadFilter","type":"DelayNode","class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6742,"description":"<p>Filter an audio signal according to a set\nof filter parameters.<\/p>\n","itemtype":"method","name":"process","params":[{"name":"Signal","description":"<p>An object that outputs audio<\/p>\n","type":"Object"},{"name":"freq","description":"<p>Frequency in Hz, from 10 to 22050<\/p>\n","type":"Number","optional":true},{"name":"res","description":"<p>Resonance\/Width of the filter frequency\n                      from 0.001 to 1000<\/p>\n","type":"Number","optional":true}],"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6760,"description":"<p>Set the frequency and the resonance of the filter.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"freq","description":"<p>Frequency in Hz, from 10 to 22050<\/p>\n","type":"Number","optional":true},{"name":"res","description":"<p>Resonance (Q) from 0.001 to 1000<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6781,"description":"<p>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).<\/p>\n","itemtype":"method","name":"freq","params":[{"name":"freq","description":"<p>Filter Frequency<\/p>\n","type":"Number"},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number","optional":true}],"return":{"description":"value  Returns the current frequency value","type":"Number"},"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6811,"description":"<p>Controls either width of a bandpass frequency,\nor the resonance of a low\/highpass cutoff frequency.<\/p>\n","itemtype":"method","name":"res","params":[{"name":"res","description":"<p>Resonance\/Width of filter freq\n                     from 0.001 to 1000<\/p>\n","type":"Number"},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number","optional":true}],"return":{"description":"value Returns the current res value","type":"Number"},"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6838,"description":"<p>Controls the gain attribute of a Biquad Filter.\nThis is distinctly different from .amp() which is inherited from p5.Effect\n.amp() controls the volume via the output gain node\np5.Filter.gain() controls the gain parameter of a Biquad Filter node.<\/p>\n","itemtype":"method","name":"gain","params":[{"name":"gain","description":"","type":"Number"}],"return":{"description":"Returns the current or updated gain value","type":"Number"},"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6864,"description":"<p>Toggle function. Switches between the specified type and allpass<\/p>\n","itemtype":"method","name":"toggle","return":{"description":"[Toggle value]","type":"Boolean"},"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":6884,"description":"<p>Set the type of a p5.Filter. Possible types include:\n\"lowpass\" (default), \"highpass\", \"bandpass\",\n\"lowshelf\", \"highshelf\", \"peaking\", \"notch\",\n\"allpass\".<\/p>\n","itemtype":"method","name":"setType","params":[{"name":"t","description":"","type":"String"}],"class":"p5.Filter","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7198,"description":"<p>The p5.EQ is built with abstracted p5.Filter objects.\nTo modify any bands, use methods of the <a\nhref=\"\/reference\/#\/p5.Filter\" title=\"p5.Filter reference\">\np5.Filter<\/a> API, especially <code>gain<\/code> and <code>freq<\/code>.\nBands are stored in an array, with indices 0 - 3, or 0 - 7<\/p>\n","itemtype":"property","name":"bands","type":"Array","class":"p5.EQ","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7239,"description":"<p>Process an input by connecting it to the EQ<\/p>\n","itemtype":"method","name":"process","params":[{"name":"src","description":"<p>Audio source<\/p>\n","type":"Object"}],"class":"p5.EQ","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7629,"description":"<p><a title=\"Web Audio Panner docs\"  href=\n\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/PannerNode\">\nWeb Audio Spatial Panner Node<\/a><\/p>\n<p>Properties include<br>\n <a href=\"https:\/\/www.w3.org\/TR\/webaudio\/#idl-def-PanningModelType\">Panning Model<\/a>\n : \"equal power\" or \"HRTF\"<br>\n <a href=\"https:\/\/www.w3.org\/TR\/webaudio\/#idl-def-DistanceModelType\">DistanceModel<\/a>\n: \"linear\", \"inverse\", or \"exponential\"<\/p>\n","itemtype":"property","name":"panner","type":"AudioNode","class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7654,"description":"<p>Connect an audio sorce<\/p>\n","itemtype":"method","name":"process","params":[{"name":"src","description":"<p>Input source<\/p>\n","type":"Object"}],"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7668,"description":"<p>Set the X,Y,Z position of the Panner<\/p>\n","itemtype":"method","name":"set","params":[{"name":"xVal","description":"","type":"Number"},{"name":"yVal","description":"","type":"Number"},{"name":"zVal","description":"","type":"Number"},{"name":"time","description":"","type":"Number"}],"return":{"description":"Updated x, y, z values as an array","type":"Array"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7687,"description":"<p>Getter and setter methods for position coordinates<\/p>\n","itemtype":"method","name":"positionX","return":{"description":"updated coordinate value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7694,"description":"<p>Getter and setter methods for position coordinates<\/p>\n","itemtype":"method","name":"positionY","return":{"description":"updated coordinate value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7701,"description":"<p>Getter and setter methods for position coordinates<\/p>\n","itemtype":"method","name":"positionZ","return":{"description":"updated coordinate value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7753,"description":"<p>Set the X,Y,Z position of the Panner<\/p>\n","itemtype":"method","name":"orient","params":[{"name":"xVal","description":"","type":"Number"},{"name":"yVal","description":"","type":"Number"},{"name":"zVal","description":"","type":"Number"},{"name":"time","description":"","type":"Number"}],"return":{"description":"Updated x, y, z values as an array","type":"Array"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7772,"description":"<p>Getter and setter methods for orient coordinates<\/p>\n","itemtype":"method","name":"orientX","return":{"description":"updated coordinate value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7779,"description":"<p>Getter and setter methods for orient coordinates<\/p>\n","itemtype":"method","name":"orientY","return":{"description":"updated coordinate value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7786,"description":"<p>Getter and setter methods for orient coordinates<\/p>\n","itemtype":"method","name":"orientZ","return":{"description":"updated coordinate value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7838,"description":"<p>Set the rolloff factor and max distance<\/p>\n","itemtype":"method","name":"setFalloff","params":[{"name":"maxDistance","description":"","type":"Number","optional":true},{"name":"rolloffFactor","description":"","type":"Number","optional":true}],"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7852,"description":"<p>Maxium distance between the source and the listener<\/p>\n","itemtype":"method","name":"maxDist","params":[{"name":"maxDistance","description":"","type":"Number"}],"return":{"description":"updated value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7869,"description":"<p>How quickly the volume is reduced as the source moves away from the listener<\/p>\n","itemtype":"method","name":"rollof","params":[{"name":"rolloffFactor","description":"","type":"Number"}],"return":{"description":"updated value","type":"Number"},"class":"p5.Panner3D","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7989,"description":"<p>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.<\/p>\n","itemtype":"property","name":"leftDelay","type":"DelayNode","class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":7999,"description":"<p>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.<\/p>\n","itemtype":"property","name":"rightDelay","type":"DelayNode","class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8049,"description":"<p>Add delay to an audio signal according to a set\nof delay parameters.<\/p>\n","itemtype":"method","name":"process","params":[{"name":"Signal","description":"<p>An object that outputs audio<\/p>\n","type":"Object"},{"name":"delayTime","description":"<p>Time (in seconds) of the delay\/echo.\n                             Some browsers limit delayTime to\n                             1 second.<\/p>\n","type":"Number","optional":true},{"name":"feedback","description":"<p>sends the delay back through itself\n                             in a loop that decreases in volume\n                             each time.<\/p>\n","type":"Number","optional":true},{"name":"lowPass","description":"<p>Cutoff frequency. Only frequencies\n                             below the lowPass will be part of the\n                             delay.<\/p>\n","type":"Number","optional":true}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8094,"description":"<p>Set the delay (echo) time, in seconds. Usually this value will be\na floating point number between 0.0 and 1.0.<\/p>\n","itemtype":"method","name":"delayTime","params":[{"name":"delayTime","description":"<p>Time (in seconds) of the delay<\/p>\n","type":"Number"}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8116,"description":"<p>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. The default value is 0.5<\/p>\n","itemtype":"method","name":"feedback","params":[{"name":"feedback","description":"<p>0.0 to 1.0, or an object such as an\n                                Oscillator that can be used to\n                                modulate this param<\/p>\n","type":"Number|Object"}],"return":{"description":"Feedback value","type":"Number"},"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8148,"description":"<p>Set a lowpass filter frequency for the delay. A lowpass filter\nwill cut off any frequencies higher than the filter frequency.<\/p>\n","itemtype":"method","name":"filter","params":[{"name":"cutoffFreq","description":"<p>A lowpass filter will cut off any\n                            frequencies higher than the filter frequency.<\/p>\n","type":"Number|Object"},{"name":"res","description":"<p>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.<\/p>\n","type":"Number|Object"}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8170,"description":"<p>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.<\/p>\n","itemtype":"method","name":"setType","params":[{"name":"type","description":"<p>'pingPong' (1) or 'default' (0)<\/p>\n","type":"String|Number"}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8223,"description":"<p>Set the output level of the delay effect.<\/p>\n","itemtype":"method","name":"amp","params":[{"name":"volume","description":"<p>amplitude between 0 and 1.0<\/p>\n","type":"Number"},{"name":"rampTime","description":"<p>create a fade that lasts rampTime<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8234,"description":"<p>Send output to a p5.sound or web audio object<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8242,"description":"<p>Disconnect all output.<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.Delay","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8409,"description":"<p>Connect a source to the reverb, and assign reverb parameters.<\/p>\n","itemtype":"method","name":"process","params":[{"name":"src","description":"<p>p5.sound \/ Web Audio object with a sound\n                         output.<\/p>\n","type":"Object"},{"name":"seconds","description":"<p>Duration of the reverb, in seconds.\n                         Min: 0, Max: 10. Defaults to 3.<\/p>\n","type":"Number","optional":true},{"name":"decayRate","description":"<p>Percentage of decay with each echo.\n                          Min: 0, Max: 100. Defaults to 2.<\/p>\n","type":"Number","optional":true},{"name":"reverse","description":"<p>Play the reverb backwards or forwards.<\/p>\n","type":"Boolean","optional":true}],"class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8446,"description":"<p>Set the reverb settings. Similar to .process(), but without\nassigning a new input.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"seconds","description":"<p>Duration of the reverb, in seconds.\n                         Min: 0, Max: 10. Defaults to 3.<\/p>\n","type":"Number","optional":true},{"name":"decayRate","description":"<p>Percentage of decay with each echo.\n                          Min: 0, Max: 100. Defaults to 2.<\/p>\n","type":"Number","optional":true},{"name":"reverse","description":"<p>Play the reverb backwards or forwards.<\/p>\n","type":"Boolean","optional":true}],"class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8482,"description":"<p>Set the output level of the reverb effect.<\/p>\n","itemtype":"method","name":"amp","params":[{"name":"volume","description":"<p>amplitude between 0 and 1.0<\/p>\n","type":"Number"},{"name":"rampTime","description":"<p>create a fade that lasts rampTime<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8493,"description":"<p>Send output to a p5.sound or web audio object<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8501,"description":"<p>Disconnect all output.<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.Reverb","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8621,"description":"<p>Internally, the p5.Convolver uses the a\n<a href=\"http:\/\/www.w3.org\/TR\/webaudio\/#ConvolverNode\">\nWeb Audio Convolver Node<\/a>.<\/p>\n","itemtype":"property","name":"convolverNode","type":"ConvolverNode","class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8645,"description":"<p>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.<\/p>\n","itemtype":"property","name":"impulses","type":"Array","class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8737,"description":"<p>Connect a source to the convolver.<\/p>\n","itemtype":"method","name":"process","params":[{"name":"src","description":"<p>p5.sound \/ Web Audio object with a sound\n                         output.<\/p>\n","type":"Object"}],"example":["\n<div><code>\nlet 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  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSound);\n  background(220);\n  text('tap to play', 20, 20);\n\n  \/\/ disconnect from main output...\n  sound.disconnect();\n\n  \/\/ ...and process with cVerb\n  \/\/ so that we only hear the convolution\n  cVerb.process(sound);\n}\n\nfunction playSound() {\n  sound.play();\n}\n\n<\/code><\/div>"],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8786,"description":"<p>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.<\/p>\n","itemtype":"method","name":"addImpulse","params":[{"name":"path","description":"<p>path to a sound file<\/p>\n","type":"String"},{"name":"callback","description":"<p>function (optional)<\/p>\n","type":"Function"},{"name":"errorCallback","description":"<p>function (optional)<\/p>\n","type":"Function"}],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8808,"description":"<p>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.<\/p>\n","itemtype":"method","name":"resetImpulse","params":[{"name":"path","description":"<p>path to a sound file<\/p>\n","type":"String"},{"name":"callback","description":"<p>function (optional)<\/p>\n","type":"Function"},{"name":"errorCallback","description":"<p>function (optional)<\/p>\n","type":"Function"}],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8831,"description":"<p>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.<\/p>\n","itemtype":"method","name":"toggleImpulse","params":[{"name":"id","description":"<p>Identify the impulse by its original filename\n                          (String), or by its position in the\n                          <code>.impulses<\/code> Array (Number).<\/p>\n","type":"String|Number"}],"class":"p5.Convolver","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":8885,"description":"<p>Create a p5.Convolver. Accepts a path to a soundfile\nthat will be used to generate an impulse response.<\/p>\n","itemtype":"method","name":"createConvolver","params":[{"name":"path","description":"<p>path to a sound file<\/p>\n","type":"String"},{"name":"callback","description":"<p>function to call if loading is successful.\n                              The object will be passed in as the argument\n                              to the callback function.<\/p>\n","type":"Function","optional":true},{"name":"errorCallback","description":"<p>function to call if loading is not successful.\n                              A custom error will be passed in as the argument\n                              to the callback function.<\/p>\n","type":"Function","optional":true}],"return":{"description":"","type":"p5.Convolver"},"example":["\n<div><code>\nlet 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  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSound);\n  background(220);\n  text('tap to play', 20, 20);\n\n  \/\/ disconnect from main output...\n  sound.disconnect();\n\n  \/\/ ...and process with cVerb\n  \/\/ so that we only hear the convolution\n  cVerb.process(sound);\n}\n\nfunction playSound() {\n  sound.play();\n}\n<\/code><\/div>"],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9084,"description":"<p>Set the global tempo, in beats per minute, for all\np5.Parts. This method will impact all active p5.Parts.<\/p>\n","itemtype":"method","name":"setBPM","params":[{"name":"BPM","description":"<p>Beats Per Minute<\/p>\n","type":"Number"},{"name":"rampTime","description":"<p>Seconds from now<\/p>\n","type":"Number"}],"class":"p5","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9173,"description":"<p>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.<\/p>\n","itemtype":"property","name":"sequence","type":"Array","class":"p5.Phrase","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9263,"description":"<p>Set the tempo of this part, in Beats Per Minute.<\/p>\n","itemtype":"method","name":"setBPM","params":[{"name":"BPM","description":"<p>Beats Per Minute<\/p>\n","type":"Number"},{"name":"rampTime","description":"<p>Seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9278,"description":"<p>Returns the tempo, in Beats Per Minute, of this part.<\/p>\n","itemtype":"method","name":"getBPM","return":{"description":"","type":"Number"},"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9291,"description":"<p>Start playback of this part. It will play\nthrough all of its phrases at a speed\ndetermined by setBPM.<\/p>\n","itemtype":"method","name":"start","params":[{"name":"time","description":"<p>seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9311,"description":"<p>Loop playback of this part. It will begin\nlooping through all of its phrases at a speed\ndetermined by setBPM.<\/p>\n","itemtype":"method","name":"loop","params":[{"name":"time","description":"<p>seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9333,"description":"<p>Tell the part to stop looping.<\/p>\n","itemtype":"method","name":"noLoop","class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9349,"description":"<p>Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.<\/p>\n","itemtype":"method","name":"stop","params":[{"name":"time","description":"<p>seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9363,"description":"<p>Pause the part. Playback will resume\nfrom the current step.<\/p>\n","itemtype":"method","name":"pause","params":[{"name":"time","description":"<p>seconds from now<\/p>\n","type":"Number"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9379,"description":"<p>Add a p5.Phrase to this Part.<\/p>\n","itemtype":"method","name":"addPhrase","params":[{"name":"phrase","description":"<p>reference to a p5.Phrase<\/p>\n","type":"p5.Phrase"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9406,"description":"<p>Remove a phrase from this part, based on the name it was\ngiven when it was created.<\/p>\n","itemtype":"method","name":"removePhrase","params":[{"name":"phraseName","description":"","type":"String"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9424,"description":"<p>Get a phrase from this part, based on the name it was\ngiven when it was created. Now you can modify its array.<\/p>\n","itemtype":"method","name":"getPhrase","params":[{"name":"phraseName","description":"","type":"String"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9442,"description":"<p>Find all sequences with the specified name, and replace their patterns with the specified array.<\/p>\n","itemtype":"method","name":"replaceSequence","params":[{"name":"phraseName","description":"","type":"String"},{"name":"sequence","description":"<p>Array of values to pass into the callback\n                          at each step of the phrase.<\/p>\n","type":"Array"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9473,"description":"<p>Set the function that will be called at every step. This will clear the previous function.<\/p>\n","itemtype":"method","name":"onStep","params":[{"name":"callback","description":"<p>The name of the callback\n                            you want to fire\n                            on every beat\/tatum.<\/p>\n","type":"Function"}],"class":"p5.Part","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9542,"description":"<p>Start playback of the score.<\/p>\n","itemtype":"method","name":"start","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9555,"description":"<p>Stop playback of the score.<\/p>\n","itemtype":"method","name":"stop","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9569,"description":"<p>Pause playback of the score.<\/p>\n","itemtype":"method","name":"pause","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9581,"description":"<p>Loop playback of the score.<\/p>\n","itemtype":"method","name":"loop","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9594,"description":"<p>Stop looping playback of the score. If it\nis currently playing, this will go into effect\nafter the current round of playback completes.<\/p>\n","itemtype":"method","name":"noLoop","class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9628,"description":"<p>Set the tempo for all parts in the score<\/p>\n","itemtype":"method","name":"setBPM","params":[{"name":"BPM","description":"<p>Beats Per Minute<\/p>\n","type":"Number"},{"name":"rampTime","description":"<p>Seconds from now<\/p>\n","type":"Number"}],"class":"p5.Score","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9729,"description":"<p>Getters and Setters, setting any parameter will result in a change in the clock's\nfrequency, that will be reflected after the next callback\nbeats per minute (defaults to 60)<\/p>\n","itemtype":"property","name":"bpm","type":"Number","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9750,"description":"<p>number of quarter notes in a measure (defaults to 4)<\/p>\n","itemtype":"property","name":"timeSignature","type":"Number","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9770,"description":"<p>length of the loops interval<\/p>\n","itemtype":"property","name":"interval","type":"Number|String","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9787,"description":"<p>how many times the callback has been called so far<\/p>\n","itemtype":"property","name":"iterations","type":"Number","readonly":"","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9800,"description":"<p>musicalTimeMode uses <a href = \"https:\/\/github.com\/Tonejs\/Tone.js\/wiki\/Time\">Tone.Time<\/a> convention\ntrue if string, false if number<\/p>\n","itemtype":"property","name":"musicalTimeMode","type":"Boolean","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9808,"description":"<p>musicalTimeMode variables\nmodify these only when the interval is specified in musicalTime format as a string<\/p>\n","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9816,"description":"<p>Set a limit to the number of loops to play. defaults to Infinity<\/p>\n","itemtype":"property","name":"maxIterations","type":"Number","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9826,"description":"<p>Do not initiate the callback if timeFromNow is < 0\nThis ususually occurs for a few milliseconds when the page\nis not fully loaded<\/p>\n<p>The callback should only be called until maxIterations is reached<\/p>\n","class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9841,"description":"<p>Start the loop<\/p>\n","itemtype":"method","name":"start","params":[{"name":"timeFromNow","description":"<p>schedule a starting time<\/p>\n","type":"Number","optional":true}],"class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9860,"description":"<p>Stop the loop<\/p>\n","itemtype":"method","name":"stop","params":[{"name":"timeFromNow","description":"<p>schedule a stopping time<\/p>\n","type":"Number","optional":true}],"class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9878,"description":"<p>Pause the loop<\/p>\n","itemtype":"method","name":"pause","params":[{"name":"timeFromNow","description":"<p>schedule a pausing time<\/p>\n","type":"Number","optional":true}],"class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":9896,"description":"<p>Synchronize loops. Use this method to start two or more loops in synchronization\nor to start a loop in synchronization with a loop that is already playing\nThis method will schedule the implicit loop in sync with the explicit master loop\ni.e. loopToStart.syncedStart(loopToSyncWith)<\/p>\n","itemtype":"method","name":"syncedStart","params":[{"name":"otherLoop","description":"<p>a p5.SoundLoop to sync with<\/p>\n","type":"Object"},{"name":"timeFromNow","description":"<p>Start the loops in sync after timeFromNow seconds<\/p>\n","type":"Number","optional":true}],"class":"p5.SoundLoop","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10068,"description":"<p>The p5.Compressor is built with a <a href=\"https:\/\/www.w3.org\/TR\/webaudio\/#the-dynamicscompressornode-interface\"\n   target=\"_blank\" title=\"W3 spec for Dynamics Compressor Node\">Web Audio Dynamics Compressor Node\n   <\/a><\/p>\n","itemtype":"property","name":"compressor","type":"AudioNode","class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10084,"description":"<p>Performs the same function as .connect, but also accepts\noptional parameters to set compressor's audioParams<\/p>\n","itemtype":"method","name":"process","params":[{"name":"src","description":"<p>Sound source to be connected<\/p>\n","type":"Object"},{"name":"attack","description":"<p>The amount of time (in seconds) to reduce the gain by 10dB,\n                           default = .003, range 0 - 1<\/p>\n","type":"Number","optional":true},{"name":"knee","description":"<p>A decibel value representing the range above the\n                           threshold where the curve smoothly transitions to the \"ratio\" portion.\n                           default = 30, range 0 - 40<\/p>\n","type":"Number","optional":true},{"name":"ratio","description":"<p>The amount of dB change in input for a 1 dB change in output\n                           default = 12, range 1 - 20<\/p>\n","type":"Number","optional":true},{"name":"threshold","description":"<p>The decibel value above which the compression will start taking effect\n                           default = -24, range -100 - 0<\/p>\n","type":"Number","optional":true},{"name":"release","description":"<p>The amount of time (in seconds) to increase the gain by 10dB\n                           default = .25, range 0 - 1<\/p>\n","type":"Number","optional":true}],"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10112,"description":"<p>Set the parameters of a compressor.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"attack","description":"<p>The amount of time (in seconds) to reduce the gain by 10dB,\n                           default = .003, range 0 - 1<\/p>\n","type":"Number"},{"name":"knee","description":"<p>A decibel value representing the range above the\n                           threshold where the curve smoothly transitions to the \"ratio\" portion.\n                           default = 30, range 0 - 40<\/p>\n","type":"Number"},{"name":"ratio","description":"<p>The amount of dB change in input for a 1 dB change in output\n                           default = 12, range 1 - 20<\/p>\n","type":"Number"},{"name":"threshold","description":"<p>The decibel value above which the compression will start taking effect\n                           default = -24, range -100 - 0<\/p>\n","type":"Number"},{"name":"release","description":"<p>The amount of time (in seconds) to increase the gain by 10dB\n                           default = .25, range 0 - 1<\/p>\n","type":"Number"}],"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10152,"description":"<p>Get current attack or set value w\/ time ramp<\/p>\n","itemtype":"method","name":"attack","params":[{"name":"attack","description":"<p>Attack is the amount of time (in seconds) to reduce the gain by 10dB,\n                         default = .003, range 0 - 1<\/p>\n","type":"Number","optional":true},{"name":"time","description":"<p>Assign time value to schedule the change in value<\/p>\n","type":"Number","optional":true}],"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10178,"description":"<p>Get current knee or set value w\/ time ramp<\/p>\n","itemtype":"method","name":"knee","params":[{"name":"knee","description":"<p>A decibel value representing the range above the\n                       threshold where the curve smoothly transitions to the \"ratio\" portion.\n                       default = 30, range 0 - 40<\/p>\n","type":"Number","optional":true},{"name":"time","description":"<p>Assign time value to schedule the change in value<\/p>\n","type":"Number","optional":true}],"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10204,"description":"<p>Get current ratio or set value w\/ time ramp<\/p>\n","itemtype":"method","name":"ratio","params":[{"name":"ratio","description":"<p>The amount of dB change in input for a 1 dB change in output\n                           default = 12, range 1 - 20<\/p>\n","type":"Number","optional":true},{"name":"time","description":"<p>Assign time value to schedule the change in value<\/p>\n","type":"Number","optional":true}],"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10228,"description":"<p>Get current threshold or set value w\/ time ramp<\/p>\n","itemtype":"method","name":"threshold","params":[{"name":"threshold","description":"<p>The decibel value above which the compression will start taking effect\n                           default = -24, range -100 - 0<\/p>\n","type":"Number"},{"name":"time","description":"<p>Assign time value to schedule the change in value<\/p>\n","type":"Number","optional":true}],"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10252,"description":"<p>Get current release or set value w\/ time ramp<\/p>\n","itemtype":"method","name":"release","params":[{"name":"release","description":"<p>The amount of time (in seconds) to increase the gain by 10dB\n                           default = .25, range 0 - 1<\/p>\n","type":"Number"},{"name":"time","description":"<p>Assign time value to schedule the change in value<\/p>\n","type":"Number","optional":true}],"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10277,"description":"<p>Return the current reduction value<\/p>\n","itemtype":"method","name":"reduction","return":{"description":"Value of the amount of gain reduction that is applied to the signal","type":"Number"},"class":"p5.Compressor","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10419,"description":"<p>isDetected is set to true when a peak is detected.<\/p>\n","itemtype":"attribute","name":"isDetected","type":"Boolean","default":"false","class":"p5.PeakDetect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10432,"description":"<p>The update method is run in the draw loop.<\/p>\n<p>Accepts an FFT object. You must call .analyze()\non the FFT object prior to updating the peakDetect\nbecause it relies on a completed FFT analysis.<\/p>\n","itemtype":"method","name":"update","params":[{"name":"fftObject","description":"<p>A p5.FFT object<\/p>\n","type":"p5.FFT"}],"class":"p5.PeakDetect","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10470,"description":"<p>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.<\/p>\n","itemtype":"method","name":"onPeak","params":[{"name":"callback","description":"<p>Name of a function that will\n                            be called when a peak is\n                            detected.<\/p>\n","type":"Function"},{"name":"val","description":"<p>Optional value to pass\n                            into the function when\n                            a peak is detected.<\/p>\n","type":"Object","optional":true}],"example":["\n<div><code>\nvar cnv, soundFile, fft, peakDetect;\nvar ellipseWidth = 0;\n\nfunction preload() {\n  soundFile = loadSound('assets\/beat.mp3');\n}\n\nfunction setup() {\n  cnv = createCanvas(100,100);\n  textAlign(CENTER);\n\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":10676,"description":"<p>Connect a specific device to the p5.SoundRecorder.\nIf no parameter is given, p5.SoundRecorer will record\nall audible p5.sound from your sketch.<\/p>\n","itemtype":"method","name":"setInput","params":[{"name":"unit","description":"<p>p5.sound object or a web audio unit\n                       that outputs sound<\/p>\n","type":"Object","optional":true}],"class":"p5.SoundRecorder","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10703,"description":"<p>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.<\/p>\n","itemtype":"method","name":"record","params":[{"name":"soundFile","description":"<p>p5.SoundFile<\/p>\n","type":"p5.SoundFile"},{"name":"duration","description":"<p>Time (in seconds)<\/p>\n","type":"Number","optional":true},{"name":"callback","description":"<p>The name of a function that will be\n                              called once the recording completes<\/p>\n","type":"Function","optional":true}],"class":"p5.SoundRecorder","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10739,"description":"<p>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.<\/p>\n","itemtype":"method","name":"stop","class":"p5.SoundRecorder","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10864,"description":"<p>The p5.Distortion is built with a\n<a href=\"http:\/\/www.w3.org\/TR\/webaudio\/#WaveShaperNode\">\nWeb Audio WaveShaper Node<\/a>.<\/p>\n","itemtype":"property","name":"WaveShaperNode","type":"AudioNode","class":"p5.Distortion","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10883,"description":"<p>Process a sound source, optionally specify amount and oversample values.<\/p>\n","itemtype":"method","name":"process","params":[{"name":"amount","description":"<p>Unbounded distortion amount.\n                               Normal values range from 0-1.<\/p>\n","type":"Number","optional":true,"optdefault":"0.25"},{"name":"oversample","description":"<p>'none', '2x', or '4x'.<\/p>\n","type":"String","optional":true,"optdefault":"'none'"}],"class":"p5.Distortion","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10900,"description":"<p>Set the amount and oversample of the waveshaper distortion.<\/p>\n","itemtype":"method","name":"set","params":[{"name":"amount","description":"<p>Unbounded distortion amount.\n                               Normal values range from 0-1.<\/p>\n","type":"Number","optional":true,"optdefault":"0.25"},{"name":"oversample","description":"<p>'none', '2x', or '4x'.<\/p>\n","type":"String","optional":true,"optdefault":"'none'"}],"class":"p5.Distortion","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10923,"description":"<p>Return the distortion amount, typically between 0-1.<\/p>\n","itemtype":"method","name":"getAmount","return":{"description":"Unbounded distortion amount.\n                 Normal values range from 0-1.","type":"Number"},"class":"p5.Distortion","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":10937,"description":"<p>Return the oversampling.<\/p>\n","itemtype":"method","name":"getOversample","return":{"description":"Oversample can either be 'none', '2x', or '4x'.","type":"String"},"class":"p5.Distortion","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11055,"description":"<p>Connect a source to the gain node.<\/p>\n","itemtype":"method","name":"setInput","params":[{"name":"src","description":"<p>p5.sound \/ Web Audio object with a sound\n                         output.<\/p>\n","type":"Object"}],"class":"p5.Gain","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11070,"description":"<p>Send output to a p5.sound or web audio object<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.Gain","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11084,"description":"<p>Disconnect all output.<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.Gain","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11098,"description":"<p>Set the output level of the gain node.<\/p>\n","itemtype":"method","name":"amp","params":[{"name":"volume","description":"<p>amplitude between 0 and 1.0<\/p>\n","type":"Number"},{"name":"rampTime","description":"<p>create a fade that lasts rampTime<\/p>\n","type":"Number","optional":true},{"name":"timeFromNow","description":"<p>schedule this event to happen\n                              seconds from now<\/p>\n","type":"Number","optional":true}],"class":"p5.Gain","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11181,"description":"<p>Connect to p5 objects or Web Audio Nodes<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"","type":"Object"}],"class":"p5.AudioVoice","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11194,"description":"<p>Disconnect from soundOut<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.AudioVoice","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11322,"description":"<p>Getters and Setters<\/p>\n","itemtype":"property","name":"attack","type":"Number","class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11328,"itemtype":"property","name":"decay","type":"Number","class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11333,"itemtype":"property","name":"sustain","type":"Number","class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11338,"itemtype":"property","name":"release","type":"Number","class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11379,"description":"<p>Play tells the MonoSynth to start playing a note. This method schedules\nthe calling of .triggerAttack and .triggerRelease.<\/p>\n","itemtype":"method","name":"play","params":[{"name":"note","description":"<p>the note you want to play, specified as a\n                               frequency in Hertz (Number) or as a midi\n                               value in Note\/Octave format (\"C4\", \"Eb3\"...etc\")\n                               See <a href = \"https:\/\/github.com\/Tonejs\/Tone.js\/wiki\/Instruments\">\n                               Tone<\/a>. Defaults to 440 hz.<\/p>\n","type":"String | Number"},{"name":"velocity","description":"<p>velocity of the note to play (ranging from 0 to 1)<\/p>\n","type":"Number","optional":true},{"name":"secondsFromNow","description":"<p>time from now (in seconds) at which to play<\/p>\n","type":"Number","optional":true},{"name":"sustainTime","description":"<p>time to sustain before releasing the envelope. Defaults to 0.15 seconds.<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet monoSynth;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSynth);\n  background(220);\n  textAlign(CENTER);\n  text('tap to play', width\/2, height\/2);\n\n  monoSynth = new p5.MonoSynth();\n}\n\nfunction playSynth() {\n  userStartAudio();\n\n  let note = random(['Fb4', 'G4']);\n  \/\/ note velocity (volume, from 0 to 1)\n  let velocity = random();\n  \/\/ time from now (in seconds)\n  let time = 0;\n  \/\/ note duration (in seconds)\n  let dur = 1\/6;\n\n  monoSynth.play(note, velocity, time, dur);\n}\n<\/code><\/div>\n"],"class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11431,"description":"<p>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.<\/p>\n","params":[{"name":"note","description":"<p>the note you want to play, specified as a\n                               frequency in Hertz (Number) or as a midi\n                               value in Note\/Octave format (\"C4\", \"Eb3\"...etc\")\n                               See <a href = \"https:\/\/github.com\/Tonejs\/Tone.js\/wiki\/Instruments\">\n                               Tone<\/a>. Defaults to 440 hz<\/p>\n","type":"String | Number"},{"name":"velocity","description":"<p>velocity of the note to play (ranging from 0 to 1)<\/p>\n","type":"Number","optional":true},{"name":"secondsFromNow","description":"<p>time from now (in seconds) at which to play<\/p>\n","type":"Number","optional":true}],"itemtype":"method","name":"triggerAttack","example":["\n<div><code>\nlet monoSynth;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(triggerAttack);\n  background(220);\n  text('tap here for attack, let go to release', 5, 20, width - 20);\n  monoSynth = new p5.MonoSynth();\n}\n\nfunction triggerAttack() {\n  userStartAudio();\n\n  monoSynth.triggerAttack(\"E3\");\n}\n\nfunction mouseReleased() {\n  monoSynth.triggerRelease();\n}\n<\/code><\/div>"],"class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11478,"description":"<p>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.<\/p>\n","params":[{"name":"secondsFromNow","description":"<p>time to trigger the release<\/p>\n","type":"Number"}],"itemtype":"method","name":"triggerRelease","example":["\n<div><code>\nlet monoSynth;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(triggerAttack);\n  background(220);\n  text('tap here for attack, let go to release', 5, 20, width - 20);\n  monoSynth = new p5.MonoSynth();\n}\n\nfunction triggerAttack() {\n  userStartAudio();\n\n  monoSynth.triggerAttack(\"E3\");\n}\n\nfunction mouseReleased() {\n  monoSynth.triggerRelease();\n}\n<\/code><\/div>"],"class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11516,"description":"<p>Set values like a traditional\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Synthesizer#\/media\/File:ADSR_parameter.svg\">\nADSR envelope\n<\/a>.<\/p>\n","itemtype":"method","name":"setADSR","params":[{"name":"attackTime","description":"<p>Time (in seconds before envelope\n                              reaches Attack Level<\/p>\n","type":"Number"},{"name":"decayTime","description":"<p>Time (in seconds) before envelope\n                              reaches Decay\/Sustain Level<\/p>\n","type":"Number","optional":true},{"name":"susRatio","description":"<p>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.<\/p>\n","type":"Number","optional":true},{"name":"releaseTime","description":"<p>Time in seconds from now (defaults to 0)<\/p>\n","type":"Number","optional":true}],"class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11544,"description":"<p>MonoSynth amp<\/p>\n","itemtype":"method","name":"amp","params":[{"name":"vol","description":"<p>desired volume<\/p>\n","type":"Number"},{"name":"rampTime","description":"<p>Time to reach new volume<\/p>\n","type":"Number","optional":true}],"return":{"description":"new volume value","type":"Number"},"class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11564,"description":"<p>Connect to a p5.sound \/ Web Audio object.<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"<p>A p5.sound or Web Audio object<\/p>\n","type":"Object"}],"class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11578,"description":"<p>Disconnect all outputs<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11592,"description":"<p>Get rid of the MonoSynth and free up its resources \/ memory.<\/p>\n","itemtype":"method","name":"dispose","class":"p5.MonoSynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11742,"description":"<p>An object that holds information about which notes have been played and\nwhich notes are currently being played. New notes are added as keys\non the fly. While a note has been attacked, but not released, the value of the\nkey is the audiovoice which is generating that note. When notes are released,\nthe value of the key becomes undefined.<\/p>\n","itemtype":"property","name":"notes","class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11755,"description":"<p>A PolySynth must have at least 1 voice, defaults to 8<\/p>\n","itemtype":"property","name":"polyvalue","class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11761,"description":"<p>Monosynth that generates the sound for each note that is triggered. The\np5.PolySynth defaults to using the p5.MonoSynth as its voice.<\/p>\n","itemtype":"property","name":"AudioVoice","class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11800,"description":"<p>Play a note by triggering noteAttack and noteRelease with sustain time<\/p>\n","itemtype":"method","name":"play","params":[{"name":"note","description":"<p>midi note to play (ranging from 0 to 127 - 60 being a middle C)<\/p>\n","type":"Number","optional":true},{"name":"velocity","description":"<p>velocity of the note to play (ranging from 0 to 1)<\/p>\n","type":"Number","optional":true},{"name":"secondsFromNow","description":"<p>time from now (in seconds) at which to play<\/p>\n","type":"Number","optional":true},{"name":"sustainTime","description":"<p>time to sustain before releasing the envelope<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet polySynth;\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playSynth);\n  background(220);\n  text('click to play', 20, 20);\n\n  polySynth = new p5.PolySynth();\n}\n\nfunction playSynth() {\n  userStartAudio();\n\n  \/\/ note duration (in seconds)\n  let dur = 1.5;\n\n  \/\/ time from now (in seconds)\n  let time = 0;\n\n  \/\/ velocity (volume, from 0 to 1)\n  let vel = 0.1;\n\n  \/\/ notes can overlap with each other\n  polySynth.play('G2', vel, 0, dur);\n  polySynth.play('C3', vel, time += 1\/3, dur);\n  polySynth.play('G3', vel, time += 1\/3, dur);\n}\n<\/code><\/div>"],"class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11849,"description":"<p>noteADSR sets the envelope for a specific note that has just been triggered.\nUsing this method modifies the envelope of whichever audiovoice is being used\nto play the desired note. The envelope should be reset before noteRelease is called\nin order to prevent the modified envelope from being used on other notes.<\/p>\n","itemtype":"method","name":"noteADSR","params":[{"name":"note","description":"<p>Midi note on which ADSR should be set.<\/p>\n","type":"Number","optional":true},{"name":"attackTime","description":"<p>Time (in seconds before envelope\n                              reaches Attack Level<\/p>\n","type":"Number","optional":true},{"name":"decayTime","description":"<p>Time (in seconds) before envelope\n                              reaches Decay\/Sustain Level<\/p>\n","type":"Number","optional":true},{"name":"susRatio","description":"<p>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.<\/p>\n","type":"Number","optional":true},{"name":"releaseTime","description":"<p>Time in seconds from now (defaults to 0)<\/p>\n","type":"Number","optional":true}],"class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11881,"description":"<p>Set the PolySynths global envelope. This method modifies the envelopes of each\nmonosynth so that all notes are played with this envelope.<\/p>\n","itemtype":"method","name":"setADSR","params":[{"name":"attackTime","description":"<p>Time (in seconds before envelope\n                               reaches Attack Level<\/p>\n","type":"Number","optional":true},{"name":"decayTime","description":"<p>Time (in seconds) before envelope\n                               reaches Decay\/Sustain Level<\/p>\n","type":"Number","optional":true},{"name":"susRatio","description":"<p>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.<\/p>\n","type":"Number","optional":true},{"name":"releaseTime","description":"<p>Time in seconds from now (defaults to 0)<\/p>\n","type":"Number","optional":true}],"class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":11909,"description":"<p>Trigger the Attack, and Decay portion of a MonoSynth.\nSimilar to holding down a key on a piano, but it will\nhold the sustain level until you let go.<\/p>\n","itemtype":"method","name":"noteAttack","params":[{"name":"note","description":"<p>midi note on which attack should be triggered.<\/p>\n","type":"Number","optional":true},{"name":"velocity","description":"<p>velocity of the note to play (ranging from 0 to 1)\/<\/p>\n","type":"Number","optional":true},{"name":"secondsFromNow","description":"<p>time from now (in seconds)<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet polySynth = new p5.PolySynth();\nlet pitches = ['G', 'D', 'G', 'C'];\nlet octaves = [2, 3, 4];\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playChord);\n  background(220);\n  text('tap to play', 20, 20);\n}\n\nfunction playChord() {\n  userStartAudio();\n\n  \/\/ play a chord: multiple notes at the same time\n  for (let i = 0; i < 4; i++) {\n    let note = random(pitches) + random(octaves);\n    polySynth.noteAttack(note, 0.1);\n  }\n}\n\nfunction mouseReleased() {\n  \/\/ release all voices\n  polySynth.noteRelease();\n}\n<\/code><\/div>"],"class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":12021,"description":"<p>Trigger the Release of an AudioVoice note. This is similar to releasing\nthe key on a piano and letting the sound fade according to the\nrelease level and release time.<\/p>\n","itemtype":"method","name":"noteRelease","params":[{"name":"note","description":"<p>midi note on which attack should be triggered.\n                                  If no value is provided, all notes will be released.<\/p>\n","type":"Number","optional":true},{"name":"secondsFromNow","description":"<p>time to trigger the release<\/p>\n","type":"Number","optional":true}],"example":["\n<div><code>\nlet polySynth = new p5.PolySynth();\nlet pitches = ['G', 'D', 'G', 'C'];\nlet octaves = [2, 3, 4];\n\nfunction setup() {\n  let cnv = createCanvas(100, 100);\n  cnv.mousePressed(playChord);\n  background(220);\n  text('tap to play', 20, 20);\n}\n\nfunction playChord() {\n  userStartAudio();\n\n  \/\/ play a chord: multiple notes at the same time\n  for (let i = 0; i < 4; i++) {\n    let note = random(pitches) + random(octaves);\n    polySynth.noteAttack(note, 0.1);\n  }\n}\n\nfunction mouseReleased() {\n  \/\/ release all voices\n  polySynth.noteRelease();\n}\n<\/code><\/div>\n"],"class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":12105,"description":"<p>Connect to a p5.sound \/ Web Audio object.<\/p>\n","itemtype":"method","name":"connect","params":[{"name":"unit","description":"<p>A p5.sound or Web Audio object<\/p>\n","type":"Object"}],"class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":12119,"description":"<p>Disconnect all outputs<\/p>\n","itemtype":"method","name":"disconnect","class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"},{"file":"lib\/addons\/p5.sound.js","line":12133,"description":"<p>Get rid of the MonoSynth and free up its resources \/ memory.<\/p>\n","itemtype":"method","name":"dispose","class":"p5.PolySynth","module":"p5.sound","submodule":"p5.sound"}],"warnings":[{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/fes_core.js:123"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/fes_core.js:223"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/fes_core.js:323"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/fes_core.js:464"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/fes_core.js:1018"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/sketch_reader.js:243"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/sketch_reader.js:268"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/friendly_errors\/validate_params.js:336"},{"message":"unknown tag: alt","line":" src\/core\/environment.js:590"},{"message":"unknown tag: alt","line":" src\/core\/environment.js:621"},{"message":"unknown tag: alt","line":" src\/core\/environment.js:652"},{"message":"unknown tag: alt","line":" src\/core\/environment.js:680"},{"message":"unknown tag: alt","line":" src\/core\/environment.js:708"},{"message":"unknown tag: alt","line":" src\/core\/environment.js:708"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/environment.js:1059"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/environment.js:1078"},{"message":"unknown tag: alt","line":" src\/core\/environment.js:1208"},{"message":"replacing incorrect tag: function with method","line":" src\/core\/internationalization.js:107"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/internationalization.js:107"},{"message":"unknown tag: name","line":" src\/core\/p5.Element.js:56"},{"message":"unknown tag: name","line":" src\/core\/p5.Element.js:87"},{"message":"unknown tag: name","line":" src\/core\/p5.Element.js:94"},{"message":"unknown tag: name","line":" src\/core\/p5.Element.js:102"},{"message":"unknown tag: alt","line":" src\/core\/p5.Element.js:966"},{"message":"replacing incorrect tag: returns with return","line":" src\/core\/structure.js:224"},{"message":"replacing incorrect tag: returns with return","line":" src\/dom\/dom.js:2636"},{"message":"replacing incorrect tag: returns with return","line":" src\/dom\/dom.js:2722"},{"message":"replacing incorrect tag: returns with return","line":" src\/dom\/dom.js:2893"},{"message":"replacing incorrect tag: returns with return","line":" src\/dom\/dom.js:2980"},{"message":"replacing incorrect tag: returns with return","line":" src\/dom\/dom.js:3118"},{"message":"replacing incorrect tag: returns with return","line":" src\/image\/loading_displaying.js:761"},{"message":"replacing incorrect tag: returns with return","line":" src\/image\/loading_displaying.js:794"},{"message":"replacing incorrect tag: returns with return","line":" src\/image\/loading_displaying.js:828"},{"message":"replacing incorrect tag: returns with return","line":" src\/image\/loading_displaying.js:871"},{"message":"unknown tag: name","line":" src\/image\/p5.Image.js:114"},{"message":"unknown tag: name","line":" src\/image\/p5.Image.js:151"},{"message":"unknown tag: name","line":" src\/image\/p5.Image.js:198"},{"message":"replacing incorrect tag: returns with return","line":" src\/image\/p5.Image.js:299"},{"message":"replacing incorrect tag: returns with return","line":" src\/image\/pixels.js:706"},{"message":"replacing incorrect tag: returns with return","line":" src\/io\/files.js:986"},{"message":"unknown tag: name","line":" src\/io\/p5.Table.js:43"},{"message":"unknown tag: name","line":" src\/io\/p5.Table.js:80"},{"message":"replacing incorrect tag: returns with return","line":" src\/math\/calculation.js:1048"},{"message":"unknown tag: name","line":" src\/math\/p5.Vector.js:113"},{"message":"unknown tag: name","line":" src\/math\/p5.Vector.js:120"},{"message":"unknown tag: name","line":" src\/math\/p5.Vector.js:127"},{"message":"replacing incorrect tag: returns with return","line":" src\/math\/trigonometry.js:775"},{"message":"replacing incorrect tag: returns with return","line":" src\/math\/trigonometry.js:790"},{"message":"replacing incorrect tag: returns with return","line":" src\/math\/trigonometry.js:805"},{"message":"replacing incorrect tag: returns with return","line":" src\/math\/trigonometry.js:820"},{"message":"unknown tag: name","line":" src\/typography\/p5.Font.js:51"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/3d_primitives.js:266"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/3d_primitives.js:520"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/GeometryBuilder.js:122"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/material.js:173"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/material.js:540"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/material.js:886"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/material.js:1197"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/material.js:1292"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/material.js:1355"},{"message":"unknown tag: alt","line":" src\/webgl\/p5.Camera.js:2472"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.Framebuffer.js:297"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.Framebuffer.js:402"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.Framebuffer.js:892"},{"message":"unknown tag: name","line":" src\/webgl\/p5.Geometry.js:252"},{"message":"unknown tag: name","line":" src\/webgl\/p5.Geometry.js:375"},{"message":"unknown tag: name","line":" src\/webgl\/p5.Geometry.js:505"},{"message":"unknown tag: name","line":" src\/webgl\/p5.Geometry.js:591"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.Geometry.js:682"},{"message":"param name missing: {Number}","line":" src\/webgl\/p5.Matrix.js:754"},{"message":"param name missing: {p5.Vector}","line":" src\/webgl\/p5.Matrix.js:773"},{"message":"param name missing: {p5.Vector}","line":" src\/webgl\/p5.Matrix.js:788"},{"message":"param name missing: {p5.Vector}","line":" src\/webgl\/p5.Matrix.js:806"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.Immediate.js:320"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.Retained.js:19"},{"message":"unknown tag: alt","line":" src\/webgl\/p5.RendererGL.js:118"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.js:318"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.js:389"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.js:832"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.js:850"},{"message":"unknown tag: alt","line":" src\/webgl\/p5.RendererGL.js:1102"},{"message":"unknown tag: alt","line":" src\/webgl\/p5.RendererGL.js:1143"},{"message":"unknown tag: alt","line":" src\/webgl\/p5.RendererGL.js:1458"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.js:1572"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.js:2101"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.RendererGL.js:2352"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.Shader.js:233"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.Shader.js:340"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/p5.Shader.js:574"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:118"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/text.js:162"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:194"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:206"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:255"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:269"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:408"},{"message":"replacing incorrect tag: returns with return","line":" src\/webgl\/text.js:408"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:476"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:491"},{"message":"replacing incorrect tag: function with method","line":" src\/webgl\/text.js:576"},{"message":"replacing incorrect tag: params with param","line":" lib\/addons\/p5.sound.js:2381"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:2381"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:2882"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:4271"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:4360"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:4386"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:4460"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:6280"},{"message":"replacing incorrect tag: returns with return","line":" lib\/addons\/p5.sound.js:8116"},{"message":"Missing item type\nConversions adapted from <http:\/\/www.easyrgb.com\/en\/math.php>.\n\nIn these functions, hue is always in the range [0, 1], just like all other\ncomponents are in the range [0, 1]. 'Brightness' and 'value' are used\ninterchangeably.","line":" src\/color\/color_conversion.js:8"},{"message":"Missing item type\nConvert an HSBA array to HSLA.","line":" src\/color\/color_conversion.js:18"},{"message":"Missing item type\nConvert an HSBA array to RGBA.","line":" src\/color\/color_conversion.js:44"},{"message":"Missing item type\nConvert an HSLA array to HSBA.","line":" src\/color\/color_conversion.js:99"},{"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:122"},{"message":"Missing item type\nConvert an RGBA array to HSBA.","line":" src\/color\/color_conversion.js:186"},{"message":"Missing item type\nConvert an RGBA array to HSLA.","line":" src\/color\/color_conversion.js:225"},{"message":"Missing item type\nCSS named colors.","line":" src\/color\/p5.Color.js:14"},{"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:168"},{"message":"Missing item type\nFull color string patterns. The capture groups are necessary.","line":" src\/color\/p5.Color.js:181"},{"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:789"},{"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:820"},{"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:838"},{"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:1048"},{"message":"Missing item type","line":" src\/core\/friendly_errors\/fes_core.js:1"},{"message":"Missing item type\nPrints out all the colors in the color pallete with white text.\nFor color blindness testing.","line":" src\/core\/friendly_errors\/fes_core.js:932"},{"message":"Missing item type","line":" src\/core\/friendly_errors\/file_errors.js:1"},{"message":"Missing item type","line":" src\/core\/friendly_errors\/sketch_reader.js:1"},{"message":"Missing item type","line":" src\/core\/friendly_errors\/stacktrace.js:1"},{"message":"Missing item type\nGiven an Error object, extract the most information from it.","line":" src\/core\/friendly_errors\/stacktrace.js:32"},{"message":"Missing item type","line":" src\/core\/friendly_errors\/validate_params.js:1"},{"message":"Missing item type\nThis function does 3 things:\n\n  1. Bounds the desired start\/stop angles for an arc (in radians) so that:\n\n         0 <= start < TWO_PI ;    start <= stop < start + TWO_PI\n\n     This means that the arc rendering functions don't have to be concerned\n     with what happens if stop is smaller than start, or if the arc 'goes\n     round more than once', etc.: they can just start at start and increase\n     until stop and the correct arc will be drawn.\n\n  2. Optionally adjusts the angles within each quadrant to counter the naive\n     scaling of the underlying ellipse up from the unit circle.  Without\n     this, the angles become arbitrary when width != height: 45 degrees\n     might be drawn at 5 degrees on a 'wide' ellipse, or at 85 degrees on\n     a 'tall' ellipse.\n\n  3. Flags up when start and stop correspond to the same place on the\n     underlying ellipse.  This is useful if you want to do something special\n     there (like rendering a whole ellipse instead).","line":" src\/core\/shape\/2d_primitives.js:16"},{"message":"Missing item type\nReturns the current framerate.","line":" src\/core\/environment.js:421"},{"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 <a href=\"#\/p5\/setup\">setup()<\/a> is\nrecommended. The default rate is 60 frames per second.\n\nCalling `frameRate()` with no arguments returns the current frame rate.","line":" src\/core\/environment.js:431"},{"message":"Missing item type\nCalled upon each p5 instantiation instead of module import due to the\npossibility of the window being resized when no sketch is active.","line":" src\/core\/environment.js:803"},{"message":"Missing item type","line":" src\/core\/helpers.js:1"},{"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\/core\/init.js:4"},{"message":"Missing item type\nThis is our i18next \"backend\" plugin. It tries to fetch languages\nfrom a CDN.","line":" src\/core\/internationalization.js:32"},{"message":"Missing item type\nSet up our translation function, with loaded languages","line":" src\/core\/internationalization.js:128"},{"message":"Missing item type\nReturns a list of languages we have translations loaded for","line":" src\/core\/internationalization.js:177"},{"message":"Missing item type\nReturns the current language selected for translation","line":" src\/core\/internationalization.js:184"},{"message":"Missing item type\nSets the current language for translation\nReturns a promise that resolved when loading is finished,\nor rejects if it fails.","line":" src\/core\/internationalization.js:191"},{"message":"Missing item type","line":" src\/core\/legacy.js:1"},{"message":"Missing item type","line":" src\/core\/p5.Element.js:87"},{"message":"Missing item type","line":" src\/core\/p5.Element.js:966"},{"message":"Missing item type","line":" src\/core\/p5.Element.js:985"},{"message":"Missing item type","line":" src\/core\/p5.Element.js:1002"},{"message":"Missing item type\nHelper fxn for sharing pixel methods","line":" src\/core\/p5.Element.js:1015"},{"message":"Missing item type\nResize our canvas element.","line":" src\/core\/p5.Renderer.js:120"},{"message":"Missing item type\nHelper function to check font type (system or otf)","line":" src\/core\/p5.Renderer.js:468"},{"message":"Missing item type\nHelper fxn to measure ascent and descent.\nAdapted from http:\/\/stackoverflow.com\/a\/25355178","line":" src\/core\/p5.Renderer.js:520"},{"message":"Missing item type\np5.Renderer2D\nThe 2D graphics canvas renderer class.\nextends p5.Renderer","line":" src\/core\/p5.Renderer2D.js:6"},{"message":"Missing item type\nargs[0] is expected to be renderer\nargs[1] is expected to be canvas","line":" src\/core\/rendering.js:483"},{"message":"Missing item type\nprivate helper function to handle the user passing in objects\nduring construction or calls to create()","line":" src\/data\/p5.TypedDict.js:198"},{"message":"Missing item type\nprivate helper function to ensure that the user passed in valid\nvalues for the Dictionary type","line":" src\/data\/p5.TypedDict.js:388"},{"message":"Missing item type\nprivate helper function to ensure that the user passed in valid\nvalues for the Dictionary type","line":" src\/data\/p5.TypedDict.js:430"},{"message":"Missing item type\nprivate helper function for finding lowest or highest value\nthe argument 'flip' is used to flip the comparison arrow\nfrom 'less than' to 'greater than'","line":" src\/data\/p5.TypedDict.js:543"},{"message":"Missing item type\nprivate helper function for finding lowest or highest key\nthe argument 'flip' is used to flip the comparison arrow\nfrom 'less than' to 'greater than'","line":" src\/data\/p5.TypedDict.js:607"},{"message":"Missing item type\nHelper function for select and selectAll","line":" src\/dom\/dom.js:206"},{"message":"Missing item type\nHelper function for getElement and getElements.","line":" src\/dom\/dom.js:221"},{"message":"Missing item type\nHelpers for create methods.","line":" src\/dom\/dom.js:478"},{"message":"Missing item type","line":" src\/dom\/dom.js:787"},{"message":"Missing item type","line":" src\/dom\/dom.js:2068"},{"message":"Missing item type","line":" src\/dom\/dom.js:2211"},{"message":"Missing item type","line":" src\/dom\/dom.js:2259"},{"message":"Missing item type","line":" src\/dom\/dom.js:4081"},{"message":"Missing item type","line":" src\/dom\/dom.js:5093"},{"message":"Missing item type","line":" src\/dom\/dom.js:5164"},{"message":"Missing item type\n_updatePAccelerations updates the pAcceleration values","line":" src\/events\/acceleration.js:120"},{"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:801"},{"message":"Missing item type\nThe _areDownKeys function returns a boolean true if any keys pressed\nand a false if no keys are currently pressed.\n\nHelps avoid instances where multiple keys are pressed simultaneously and\nreleasing a single key will then switch the\nkeyIsPressed property to true.","line":" src\/events\/keyboard.js:927"},{"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:1"},{"message":"Missing item type\nReturns the pixel buffer for a canvas.","line":" src\/image\/filters.js:22"},{"message":"Missing item type\nReturns a 32-bit number containing ARGB data at the ith pixel in the\n1D array containing pixels data.","line":" src\/image\/filters.js:65"},{"message":"Missing item type\nModifies pixels RGBA values to values contained in the data object.","line":" src\/image\/filters.js:88"},{"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:109"},{"message":"Missing item type\nReturns a blank ImageData object.","line":" src\/image\/filters.js:130"},{"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:145"},{"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:200"},{"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:233"},{"message":"Missing item type\nSets the alpha channel to entirely opaque. No parameter is used.","line":" src\/image\/filters.js:256"},{"message":"Missing item type\nSets each pixel to its inverse value. No parameter is used.","line":" src\/image\/filters.js:272"},{"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:287"},{"message":"Missing item type\nIncreases the bright areas in an image.","line":" src\/image\/filters.js:319"},{"message":"Missing item type\nReduces the bright areas in an image.\nSimilar to `dilate()`, but updates the output color based on the lowest luminance value.","line":" src\/image\/filters.js:411"},{"message":"Missing item type\nThis module defines the p5 methods for the <a href=\"#\/p5.Image\">p5.Image<\/a> class\nfor drawing images to the main display canvas.","line":" src\/image\/image.js:8"},{"message":"Missing item type\nHelper function for loading GIF-based images","line":" src\/image\/loading_displaying.js:639"},{"message":"Missing item type","line":" src\/image\/loading_displaying.js:761"},{"message":"Missing item type","line":" src\/image\/loading_displaying.js:794"},{"message":"Missing item type","line":" src\/image\/loading_displaying.js:828"},{"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:871"},{"message":"Missing item type\nApply the current tint color to the input image, return the resulting\ncanvas.","line":" src\/image\/loading_displaying.js:1384"},{"message":"Missing item type\nThis module defines the <a href=\"#\/p5.Image\">p5.Image<\/a> class and P5 methods for\ndrawing images to the main display canvas.","line":" src\/image\/p5.Image.js:9"},{"message":"Missing item type\nHelper function for animating GIF-based images with time","line":" src\/image\/p5.Image.js:342"},{"message":"Missing item type\nHelper fxn for sharing pixel methods","line":" src\/image\/p5.Image.js:373"},{"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 <a href=\"#\/p5\/saveStrings\">saveStrings<\/a>, <a href=\"#\/p5\/saveJSON\">saveJSON<\/a>, <a href=\"#\/p5\/saveTable\">saveTable<\/a> etc.","line":" src\/io\/files.js:2407"},{"message":"Missing item type\nReturns a file extension, or another string\nif the provided parameter has no extension.","line":" src\/io\/files.js:2475"},{"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:2508"},{"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:2519"},{"message":"Missing item type\nTable Options\nGeneric class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.\nCSV 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.\nFile names should end with .csv if they're comma separated.\nA rough \"spec\" for CSV can be found\n<a href=\"http:\/\/tools.ietf.org\/html\/rfc4180\">here<\/a>.\nTo load files, use the <a href=\"#\/p5\/loadTable\">loadTable<\/a> method.\nTo save tables to your computer, use the <a href=\"#\/p5\/save\">save<\/a> method\n or the <a href=\"#\/p5\/saveTable\">saveTable<\/a> method.\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:9"},{"message":"Missing item type","line":" src\/math\/p5.Vector.js:435"},{"message":"Missing item type","line":" src\/math\/p5.Vector.js:449"},{"message":"Missing item type\nMultiplies a vector by a scalar and returns a new vector.","line":" src\/math\/p5.Vector.js:3431"},{"message":"Missing item type\nRotates the vector (only 2D vectors) by the given angle; magnitude remains the same. Returns a new vector.","line":" src\/math\/p5.Vector.js:3487"},{"message":"Missing item type\nDivides a vector by a scalar and returns a new vector.","line":" src\/math\/p5.Vector.js:3516"},{"message":"Missing item type\nCalculates the dot product of two vectors.","line":" src\/math\/p5.Vector.js:3573"},{"message":"Missing item type\nCalculates the cross product of two vectors.","line":" src\/math\/p5.Vector.js:3587"},{"message":"Missing item type\nCalculates the Euclidean distance between two points (considering a\npoint as a vector object).","line":" src\/math\/p5.Vector.js:3601"},{"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:3616"},{"message":"Missing item type\nPerforms spherical linear interpolation with the other vector\nand returns the resulting vector.\nThis works in both 3D and 2D. As for 2D, the result of slerping\nbetween 2D vectors is always a 2D vector.","line":" src\/math\/p5.Vector.js:3646"},{"message":"Missing item type\nCalculates 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)`.)","line":" src\/math\/p5.Vector.js:3678"},{"message":"Missing item type\nCalculates 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.","line":" src\/math\/p5.Vector.js:3692"},{"message":"Missing item type\nNormalize the vector to length 1 (make it a unit vector).","line":" src\/math\/p5.Vector.js:3708"},{"message":"Missing item type\nLimit the magnitude of the vector to the value used for the <b>max<\/b>\nparameter.","line":" src\/math\/p5.Vector.js:3734"},{"message":"Missing item type\nSet the magnitude of the vector to the value used for the <b>len<\/b>\nparameter.","line":" src\/math\/p5.Vector.js:3762"},{"message":"Missing item type\nCalculate the angle of rotation for this vector (only 2D vectors).\np5.Vectors created using <a href=\"#\/p5\/createVector\">createVector()<\/a>\nwill take the current <a href=\"#\/p5\/angleMode\">angleMode<\/a> into\nconsideration, and give the angle in radians or degrees accordingly.","line":" src\/math\/p5.Vector.js:3790"},{"message":"Missing item type\nCalculates and returns the angle between two vectors. This function will take\nthe <a href=\"#\/p5\/angleMode\">angleMode<\/a> on v1 into consideration, and\ngive the angle in radians or degrees accordingly.","line":" src\/math\/p5.Vector.js:3806"},{"message":"Missing item type\nReflect a vector about a normal to a line in 2D, or about a normal to a\nplane in 3D.","line":" src\/math\/p5.Vector.js:3822"},{"message":"Missing item type\nReturn 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.<a href=\"#\/p5.Vector\/copy\">copy()<\/a><\/b>\nmethod to copy into your own vector.","line":" src\/math\/p5.Vector.js:3850"},{"message":"Missing item type\nEquality check against a <a href=\"#\/p5.Vector\">p5.Vector<\/a>","line":" src\/math\/p5.Vector.js:3866"},{"message":"Missing item type\nHelper function for clampToZero","line":" src\/math\/p5.Vector.js:3912"},{"message":"Missing item type\nHelper function to measure ascent and descent.","line":" src\/typography\/attributes.js:455"},{"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:403"},{"message":"Missing item type\nReturns an opentype path for the supplied string and position.","line":" src\/typography\/p5.Font.js:418"},{"message":"Missing item type","line":" src\/webgl\/3d_primitives.js:1359"},{"message":"Missing item type\nDraws a point, a coordinate in space at the dimension of one pixel,\ngiven x, y and z coordinates. The color of the point is determined\nby the current stroke, while the point size is determined by current\nstroke weight.","line":" src\/webgl\/3d_primitives.js:2411"},{"message":"Missing item type\nDraw a line given two points","line":" src\/webgl\/3d_primitives.js:2923"},{"message":"Missing item type","line":" src\/webgl\/GeometryBuilder.js:4"},{"message":"Missing item type","line":" src\/webgl\/GeometryBuilder.js:21"},{"message":"Missing item type","line":" src\/webgl\/GeometryBuilder.js:31"},{"message":"Missing item type","line":" src\/webgl\/GeometryBuilder.js:43"},{"message":"Missing item type\nAdds geometry from the renderer's immediate mode into the builder's\ncombined geometry.","line":" src\/webgl\/GeometryBuilder.js:80"},{"message":"Missing item type\nAdds geometry from the renderer's retained mode into the builder's\ncombined geometry.","line":" src\/webgl\/GeometryBuilder.js:114"},{"message":"Missing item type\nCleans up the state of the renderer and returns the combined geometry that\nwas built.","line":" src\/webgl\/GeometryBuilder.js:122"},{"message":"Missing item type\nKeeps track of how many custom geometry objects have been made so that each\ncan be assigned a unique ID.","line":" src\/webgl\/GeometryBuilder.js:133"},{"message":"Missing item type\nParse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:\n\nv -0.5 -0.5 0.5\nv -0.5 -0.5 -0.5\nv -0.5 0.5 -0.5\nv -0.5 0.5 0.5\n\nf 4 3 2 1","line":" src\/webgl\/loading.js:551"},{"message":"Missing item type\nSTL files can be of two types, ASCII and Binary,\n\nWe need to convert the arrayBuffer to an array of strings,\nto parse it as an ASCII file.","line":" src\/webgl\/loading.js:693"},{"message":"Missing item type\nThis function checks if the file is in ASCII format or in Binary format\n\nIt is done by searching keyword `solid` at the start of the file.\n\nAn ASCII STL data must begin with `solid` as the first six bytes.\nHowever, ASCII STLs lacking the SPACE after the `d` are known to be\nplentiful. So, check the first 5 bytes for `solid`.\n\nSeveral encodings, such as UTF-8, precede the text with up to 5 bytes:\nhttps:\/\/en.wikipedia.org\/wiki\/Byte_order_mark#Byte_order_marks_by_encoding\nSearch for `solid` to start anywhere after those prefixes.","line":" src\/webgl\/loading.js:720"},{"message":"Missing item type\nThis function matches the `query` at the provided `offset`","line":" src\/webgl\/loading.js:747"},{"message":"Missing item type\nThis function parses the Binary STL files.\nhttps:\/\/en.wikipedia.org\/wiki\/STL_%28file_format%29#Binary_STL\n\nCurrently there is no support for the colors provided in STL files.","line":" src\/webgl\/loading.js:759"},{"message":"Missing item type\nASCII STL file starts with `solid 'nameOfFile'`\nThen contain the normal of the face, starting with `facet normal`\nNext contain a keyword indicating the start of face vertex, `outer loop`\nNext comes the three vertex, starting with `vertex x y z`\nVertices ends with `endloop`\nFace ends with `endfacet`\nNext face starts with `facet normal`\nThe end of the file is indicated by `endsolid`","line":" src\/webgl\/loading.js:847"},{"message":"Missing item type","line":" src\/webgl\/material.js:3185"},{"message":"Missing item type","line":" src\/webgl\/material.js:3225"},{"message":"Missing item type\nAn internal class to store data that will be sent to a p5.RenderBuffer.\nThose need to eventually go into a Float32Array, so this class provides a\nvariable-length array container backed by a Float32Array so that it can be\nsent to the GPU without allocating a new array each frame.\n\nLike a C++ vector, its fixed-length Float32Array backing its contents will\ndouble in size when it goes over its capacity.","line":" src\/webgl\/p5.DataArray.js:3"},{"message":"Missing item type\nReturns a Float32Array window sized to the exact length of the data","line":" src\/webgl\/p5.DataArray.js:35"},{"message":"Missing item type\nA \"soft\" clear, which keeps the underlying storage size the same, but\nempties the contents of its dataArray()","line":" src\/webgl\/p5.DataArray.js:42"},{"message":"Missing item type\nCan be used to scale a DataArray back down to fit its contents.","line":" src\/webgl\/p5.DataArray.js:50"},{"message":"Missing item type\nA full reset, which allocates a new underlying Float32Array at its initial\nlength","line":" src\/webgl\/p5.DataArray.js:63"},{"message":"Missing item type\nAdds values to the DataArray, expanding its internal storage to\naccommodate the new items.","line":" src\/webgl\/p5.DataArray.js:72"},{"message":"Missing item type\nReturns a copy of the data from the index `from`, inclusive, to the index\n`to`, exclusive","line":" src\/webgl\/p5.DataArray.js:82"},{"message":"Missing item type\nReturns a mutable Float32Array window from the index `from`, inclusive, to\nthe index `to`, exclusive","line":" src\/webgl\/p5.DataArray.js:90"},{"message":"Missing item type\nExpand capacity of the internal storage until it can fit a target size","line":" src\/webgl\/p5.DataArray.js:98"},{"message":"Missing item type\nChecks the capabilities of the current WebGL environment to see if the\nsettings supplied by the user are capable of being fulfilled. If they\nare not, warnings will be logged and the settings will be changed to\nsomething close that can be fulfilled.","line":" src\/webgl\/p5.Framebuffer.js:471"},{"message":"Missing item type\nCreates new textures and renderbuffers given the current size of the\nframebuffer.","line":" src\/webgl\/p5.Framebuffer.js:568"},{"message":"Missing item type\nTo create a WebGL texture, one needs to supply three pieces of information:\nthe type (the data type each channel will be stored as, e.g. int or float),\nthe format (the color channels that will each be stored in the previously\nspecified type, e.g. rgb or rgba), and the internal format (the specifics\nof how data for each channel, in the aforementioned type, will be packed\ntogether, such as how many bits to use, e.g. RGBA32F or RGB565.)\n\nThe format and channels asked for by the user hint at what these values\nneed to be, and the WebGL version affects what options are avaiable.\nThis method returns the values for these three properties, given the\nframebuffer's settings.","line":" src\/webgl\/p5.Framebuffer.js:719"},{"message":"Missing item type\nTo create a WebGL texture, one needs to supply three pieces of information:\nthe type (the data type each channel will be stored as, e.g. int or float),\nthe format (the color channels that will each be stored in the previously\nspecified type, e.g. rgb or rgba), and the internal format (the specifics\nof how data for each channel, in the aforementioned type, will be packed\ntogether, such as how many bits to use, e.g. RGBA32F or RGB565.)\n\nThis method takes into account the settings asked for by the user and\nreturns values for these three properties that can be used for the\ntexture storing depth information.","line":" src\/webgl\/p5.Framebuffer.js:780"},{"message":"Missing item type\nA method that will be called when recreating textures. If the framebuffer\nis auto-sized, it will update its width, height, and density properties.","line":" src\/webgl\/p5.Framebuffer.js:841"},{"message":"Missing item type\nCalled when the canvas that the framebuffer is attached to resizes. If the\nframebuffer is auto-sized, it will update its textures to match the new\nsize.","line":" src\/webgl\/p5.Framebuffer.js:855"},{"message":"Missing item type\nCalled when the size of the framebuffer has changed (either by being\nmanually updated or from auto-size updates when its canvas changes size.)\nOld textures and renderbuffers will be deleted, and then recreated with the\nnew size.","line":" src\/webgl\/p5.Framebuffer.js:868"},{"message":"Missing item type\nGiven a raw texture wrapper, delete its stored texture from WebGL memory,\nand remove it from p5's list of active textures.","line":" src\/webgl\/p5.Framebuffer.js:1017"},{"message":"Missing item type\nAverages the vertex normals. Used in curved\nsurfaces","line":" src\/webgl\/p5.Geometry.js:1891"},{"message":"Missing item type\nAverages pole normals.  Used in spherical primitives","line":" src\/webgl\/p5.Geometry.js:1912"},{"message":"Missing item type\nCreate a 2D array for establishing stroke connections","line":" src\/webgl\/p5.Geometry.js:1950"},{"message":"Missing item type\nConverts each line segment into the vertices and vertex attributes needed\nto turn the line into a polygon on screen. This will include:\n- Two triangles line segment to create a rectangle\n- Two triangles per endpoint to create a stroke cap rectangle. A fragment\n  shader is responsible for displaying the appropriate cap style within\n  that rectangle.\n- Four triangles per join between adjacent line segments, creating a quad on\n  either side of the join, perpendicular to the lines. A vertex shader will\n  discard the quad in the \"elbow\" of the join, and a fragment shader will\n  display the appropriate join style within the remaining quad.","line":" src\/webgl\/p5.Geometry.js:1967"},{"message":"Missing item type\nAdds the vertices and vertex attributes for two triangles making a rectangle\nfor a straight line segment. A vertex shader is responsible for picking\nproper coordinates on the screen given the centerline positions, the tangent,\nand the side of the centerline each vertex belongs to. Sides follow the\nfollowing scheme:\n\n -1            -1\n  o-------------o\n  |             |\n  o-------------o\n  1             1","line":" src\/webgl\/p5.Geometry.js:2111"},{"message":"Missing item type\nAdds the vertices and vertex attributes for two triangles representing the\nstroke cap of a line. A fragment shader is responsible for displaying the\nappropriate cap style within the rectangle they make.\n\nThe lineSides buffer will include the following values for the points on\nthe cap rectangle:\n\n          -1  -2\n-----------o---o\n           |   |\n-----------o---o\n           1   2","line":" src\/webgl\/p5.Geometry.js:2155"},{"message":"Missing item type\nAdds the vertices and vertex attributes for four triangles representing a\njoin between two adjacent line segments. This creates a quad on either side\nof the shared vertex of the two line segments, with each quad perpendicular\nto the lines. A vertex shader will discard all but the quad in the \"elbow\" of\nthe join, and a fragment shader will display the appropriate join style\nwithin the remaining quad.\n\nThe lineSides buffer will include the following values for the points on\nthe join rectangles:\n\n           -1     -2\n-------------o----o\n             |    |\n      1 o----o----o -3\n        |    | 0  |\n--------o----o    |\n       2|    3    |\n        |         |\n        |         |","line":" src\/webgl\/p5.Geometry.js:2185"},{"message":"Missing item type","line":" src\/webgl\/p5.Matrix.js:1"},{"message":"Missing item type\nPRIVATE","line":" src\/webgl\/p5.Matrix.js:962"},{"message":"Missing item type\nThis is similar to quaternion multiplication\nbut when multipying vector with quaternion\nthe multiplication can be simplified to the below formula.\nThis was taken from the below stackexchange link\nhttps:\/\/gamedev.stackexchange.com\/questions\/28395\/rotating-vector3-by-a-quaternion\/50545#50545","line":" src\/webgl\/p5.Quat.js:65"},{"message":"Missing item type\nEnables and binds the buffers used by shader when the appropriate data exists in geometry.\nMust always be done prior to drawing geometry in WebGL.","line":" src\/webgl\/p5.RenderBuffer.js:13"},{"message":"Missing item type\nWelcome to RendererGL Immediate Mode.\nImmediate mode is used for drawing custom shapes\nfrom a set of vertices.  Immediate Mode is activated\nwhen you call <a href=\"#\/p5\/beginShape\">beginShape()<\/a> & de-activated when you call <a href=\"#\/p5\/endShape\">endShape()<\/a>.\nImmediate mode is a style of programming borrowed\nfrom OpenGL's (now-deprecated) immediate mode.\nIt differs from p5.js' default, Retained Mode, which caches\ngeometries and buffers on the CPU to reduce the number of webgl\ndraw calls. Retained mode is more efficient & performative,\nhowever, Immediate Mode is useful for sketching quick\ngeometric ideas.","line":" src\/webgl\/p5.RendererGL.Immediate.js:1"},{"message":"Missing item type\nEnd shape drawing and render vertices to screen.","line":" src\/webgl\/p5.RendererGL.Immediate.js:191"},{"message":"Missing item type\nCalled from endShape(). This function calculates the stroke vertices for custom shapes and\ntesselates shapes when applicable.","line":" src\/webgl\/p5.RendererGL.Immediate.js:274"},{"message":"Missing item type\nCalled from _processVertices(). This function calculates the stroke vertices for custom shapes and\ntesselates shapes when applicable.","line":" src\/webgl\/p5.RendererGL.Immediate.js:320"},{"message":"Missing item type\nCalled from _processVertices() when applicable. This function tesselates immediateMode.geometry.","line":" src\/webgl\/p5.RendererGL.Immediate.js:408"},{"message":"Missing item type\nCalled from endShape(). Responsible for calculating normals, setting shader uniforms,\nenabling all appropriate buffers, applying color blend, and drawing the fill geometry.","line":" src\/webgl\/p5.RendererGL.Immediate.js:505"},{"message":"Missing item type\nCalled from endShape(). Responsible for calculating normals, setting shader uniforms,\nenabling all appropriate buffers, applying color blend, and drawing the stroke geometry.","line":" src\/webgl\/p5.RendererGL.Immediate.js:552"},{"message":"Missing item type","line":" src\/webgl\/p5.RendererGL.Retained.js:8"},{"message":"Missing item type\ninitializes buffer defaults. runs each time a new geometry is\nregistered","line":" src\/webgl\/p5.RendererGL.Retained.js:19"},{"message":"Missing item type\ncreates a buffers object that holds the WebGL render buffers\nfor a geometry.","line":" src\/webgl\/p5.RendererGL.Retained.js:67"},{"message":"Missing item type\nDraws buffers given a geometry key ID","line":" src\/webgl\/p5.RendererGL.Retained.js:120"},{"message":"Missing item type","line":" src\/webgl\/p5.RendererGL.js:318"},{"message":"Missing item type","line":" src\/webgl\/p5.RendererGL.js:389"},{"message":"Missing item type\nmodel view, projection, & normal\nmatrices","line":" src\/webgl\/p5.RendererGL.js:535"},{"message":"Missing item type\n[background description]","line":" src\/webgl\/p5.RendererGL.js:1063"},{"message":"Missing item type","line":" src\/webgl\/p5.RendererGL.js:1572"},{"message":"Missing item type\n[resize description]","line":" src\/webgl\/p5.RendererGL.js:1605"},{"message":"Missing item type\nclears color and depth buffers\nwith r,g,b,a","line":" src\/webgl\/p5.RendererGL.js:1642"},{"message":"Missing item type\nResets all depth information so that nothing previously drawn will\nocclude anything subsequently drawn.","line":" src\/webgl\/p5.RendererGL.js:1677"},{"message":"Missing item type\n[translate description]","line":" src\/webgl\/p5.RendererGL.js:1699"},{"message":"Missing item type\nScales the Model View Matrix by a vector","line":" src\/webgl\/p5.RendererGL.js:1718"},{"message":"Missing item type\nTODO(dave): un-private this when there is a way to actually override the\nshader used for points\n\nGet the shader used when drawing points with <a href=\"#\/p5\/point\">`point()`<\/a>.\n\nYou can call <a href=\"#\/p5.Shader\/modify\">`pointShader().modify()`<\/a>\nand change any of the following hooks:\n- `void beforeVertex`: Called at the start of the vertex shader.\n- `vec3 getLocalPosition`: Update the position of vertices before transforms are applied. It takes in `vec3 position` and must return a modified version.\n- `vec3 getWorldPosition`: Update the position of vertices after transforms are applied. It takes in `vec3 position` and pust return a modified version.\n- `float getPointSize`: Update the size of the point. It takes in `float size` and must return a modified version.\n- `void afterVertex`: Called at the end of the vertex shader.\n- `void beforeFragment`: Called at the start of the fragment shader.\n- `bool shouldDiscard`: Points are drawn inside a square, with the corners discarded in the fragment shader to create a circle. Use this to change this logic. It takes in a `bool willDiscard` and must return a modified version.\n- `vec4 getFinalColor`: Update the final color after mixing. It takes in a `vec4 color` and must return a modified version.\n- `void afterFragment`: Called at the end of the fragment shader.\n\nCall `pointShader().inspectHooks()` to see all the possible hooks and\ntheir default implementations.","line":" src\/webgl\/p5.RendererGL.js:2101"},{"message":"Missing item type\nturn a two dimensional array into one dimensional array","line":" src\/webgl\/p5.RendererGL.js:2545"},{"message":"Missing item type\nturn a p5.Vector Array into a one dimensional number array","line":" src\/webgl\/p5.RendererGL.js:2556"},{"message":"Missing item type\nensures that p5 is using a 3d renderer. throws an error if not.","line":" src\/webgl\/p5.RendererGL.js:2695"},{"message":"Missing item type\nShaders are written in <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Games\/Techniques\/3D_on_the_web\/GLSL_Shaders\">GLSL<\/a>, but\nthere are different versions of GLSL that it might be written in.\n\nCalling this method on a `p5.Shader` will return the GLSL version it uses, either `100 es` or `300 es`.\nWebGL 1 shaders will only use `100 es`, and WebGL 2 shaders may use either.","line":" src\/webgl\/p5.Shader.js:233"},{"message":"Missing item type","line":" src\/webgl\/p5.Shader.js:554"},{"message":"Missing item type","line":" src\/webgl\/p5.Shader.js:764"},{"message":"Missing item type","line":" lib\/addons\/p5.sound.js:1"},{"message":"Missing item type\np5.sound \nhttps:\/\/p5js.org\/reference\/#\/libraries\/p5.sound\n\nFrom the Processing Foundation and contributors\nhttps:\/\/github.com\/processing\/p5.js-sound\/graphs\/contributors\n\nMIT License (MIT)\nhttps:\/\/github.com\/processing\/p5.js-sound\/blob\/master\/LICENSE\n\nSome of the many audio libraries & resources that inspire p5.sound:\n - TONE.js (c) Yotam Mann. Licensed under The MIT License (MIT). https:\/\/github.com\/TONEnoTONE\/Tone.js\n - buzz.js (c) Jay Salvat. 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:52"},{"message":"Missing item type\nThis module has shims","line":" lib\/addons\/p5.sound.js:401"},{"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:536"},{"message":"Missing item type","line":" lib\/addons\/p5.sound.js:807"},{"message":"Missing item type\nUsed by Osc and Envelope to chain signal math","line":" lib\/addons\/p5.sound.js:1040"},{"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:1542"},{"message":"Missing item type\nStop playback on all of this soundfile's sources.","line":" lib\/addons\/p5.sound.js:2056"},{"message":"Missing item type","line":" lib\/addons\/p5.sound.js:2604"},{"message":"Missing item type\nThe p5.Effect class is built\n \tusing Tone.js CrossFade","line":" lib\/addons\/p5.sound.js:6455"},{"message":"Missing item type\nIn classes that extend\np5.Effect, connect effect nodes\nto the wet parameter","line":" lib\/addons\/p5.sound.js:6462"},{"message":"Missing item type\nEQFilter extends p5.Filter with constraints\nnecessary for the p5.EQ","line":" lib\/addons\/p5.sound.js:7009"},{"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:8508"},{"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:8659"},{"message":"Missing item type\nmusicalTimeMode variables\nmodify these only when the interval is specified in musicalTime format as a string","line":" lib\/addons\/p5.sound.js:9808"},{"message":"Missing item type\nDo not initiate the callback if timeFromNow is < 0\nThis ususually occurs for a few milliseconds when the page\nis not fully loaded\n\nThe callback should only be called until maxIterations is reached","line":" lib\/addons\/p5.sound.js:9826"},{"message":"Missing item type\ncallback invoked when the recording is over","line":" lib\/addons\/p5.sound.js:10660"},{"message":"Missing item type\nPrivate method to ensure accurate values of this._voicesInUse\nAny time a new value is scheduled, it is necessary to increment all subsequent\nscheduledValues after attack, and decrement all subsequent\nscheduledValues after release","line":" lib\/addons\/p5.sound.js:11995"},{"message":"Missing item type","line":" lib\/addons\/p5.sound.min.js:1"}],"consts":{"LABEL":["p5.describe","p5.describeElement","p5.textOutput","p5.gridOutput"],"FALLBACK":["p5.describe","p5.describeElement","p5.textOutput","p5.gridOutput"],"RGB":["p5.colorMode"],"HSB":["p5.colorMode"],"HSL":["p5.colorMode"],"CHORD":["p5.arc"],"PIE":["p5.arc"],"OPEN":["p5.arc"],"CENTER":["p5.ellipseMode","p5.rectMode","p5.imageMode","p5.textAlign"],"RADIUS":["p5.ellipseMode","p5.rectMode"],"CORNER":["p5.ellipseMode","p5.rectMode","p5.imageMode"],"CORNERS":["p5.ellipseMode","p5.rectMode","p5.imageMode"],"ROUND":["p5.strokeCap","p5.strokeJoin"],"SQUARE":["p5.strokeCap"],"PROJECT":["p5.strokeCap"],"MITER":["p5.strokeJoin"],"BEVEL":["p5.strokeJoin"],"POINTS":["p5.beginShape"],"LINES":["p5.beginShape"],"TRIANGLES":["p5.beginShape"],"TRIANGLE_FAN":["p5.beginShape"],"TRIANGLE_STRIP":["p5.beginShape"],"QUADS":["p5.beginShape"],"QUAD_STRIP":["p5.beginShape"],"TESS":["p5.beginShape"],"CLOSE":["p5.endShape"],"ARROW":["p5.cursor"],"CROSS":["p5.cursor"],"HAND":["p5.cursor"],"MOVE":["p5.cursor"],"TEXT":["p5.cursor"],"WAIT":["p5.cursor"],"P2D":["p5.createCanvas","p5.createGraphics"],"WEBGL":["p5.createCanvas","p5.createGraphics"],"BLEND":["p5.blendMode","p5.Image.blend","p5.blend"],"DARKEST":["p5.blendMode","p5.Image.blend","p5.blend"],"LIGHTEST":["p5.blendMode","p5.Image.blend","p5.blend"],"DIFFERENCE":["p5.blendMode","p5.Image.blend","p5.blend"],"MULTIPLY":["p5.blendMode","p5.Image.blend","p5.blend"],"EXCLUSION":["p5.blendMode","p5.Image.blend","p5.blend"],"SCREEN":["p5.blendMode","p5.Image.blend","p5.blend"],"REPLACE":["p5.blendMode","p5.Image.blend","p5.blend"],"OVERLAY":["p5.blendMode","p5.Image.blend","p5.blend"],"HARD_LIGHT":["p5.blendMode","p5.Image.blend","p5.blend"],"SOFT_LIGHT":["p5.blendMode","p5.Image.blend","p5.blend"],"DODGE":["p5.blendMode","p5.Image.blend","p5.blend"],"BURN":["p5.blendMode","p5.Image.blend","p5.blend"],"ADD":["p5.blendMode","p5.Image.blend","p5.blend"],"REMOVE":["p5.blendMode"],"SUBTRACT":["p5.blendMode"],"AUDIO":["p5.createCapture"],"VIDEO":["p5.createCapture"],"THRESHOLD":["p5.Image.filter","p5.filter"],"GRAY":["p5.Image.filter","p5.filter"],"OPAQUE":["p5.Image.filter","p5.filter"],"INVERT":["p5.Image.filter","p5.filter"],"POSTERIZE":["p5.Image.filter","p5.filter"],"ERODE":["p5.Image.filter","p5.filter"],"DILATE":["p5.Image.filter","p5.filter"],"BLUR":["p5.Image.filter","p5.filter"],"NORMAL":["p5.Image.blend","p5.blend","p5.textStyle","p5.textureMode"],"RADIANS":["p5.angleMode"],"DEGREES":["p5.angleMode"],"LEFT":["p5.textAlign"],"RIGHT":["p5.textAlign"],"TOP":["p5.textAlign"],"BOTTOM":["p5.textAlign"],"BASELINE":["p5.textAlign"],"ITALIC":["p5.textStyle"],"BOLD":["p5.textStyle"],"BOLDITALIC":["p5.textStyle"],"WORD":["p5.textWrap"],"CHAR":["p5.textWrap"],"IMAGE":["p5.textureMode"],"CLAMP":["p5.textureWrap"],"REPEAT":["p5.textureWrap"],"MIRROR":["p5.textureWrap"]}}