\np5.HighPass
:\nThe opposite of a lowpass filter.
\np5.BandPass
:\nAllows a range of frequencies to pass through and attenuates\nthe frequencies below and above this frequency range.
\n\n
The .res()
method controls either width of the\nbandpass, or resonance of the low/highpass cutoff frequency.
This class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n',extends:"p5.Effect",is_constructor:1,params:[{name:"type",description:"'lowpass' (default), 'highpass', 'bandpass'
\n",type:"String",optional:!0}],example:["\n\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
Constructor: new p5.LowPass()
Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('lowpass')
.\nSee p5.Filter for methods.
Constructor: new p5.HighPass()
Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('highpass')
.\nSee p5.Filter for methods.
Constructor: new p5.BandPass()
Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('bandpass')
.\nSee p5.Filter for methods.
Creates a signal that oscillates between -1.0 and 1.0.\nBy default, the oscillation takes the form of a sinusoidal\nshape ('sine'). Additional types include 'triangle',\n'sawtooth' and 'square'. The frequency defaults to\n440 oscillations per second (440Hz, equal to the pitch of an\n'A' note).
\n\nSet the type of oscillation with setType(), or by instantiating a\nspecific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.\n
",is_constructor:1,params:[{name:"freq",description:"frequency defaults to 440Hz
\n",type:"Number",optional:!0},{name:"type",description:"type of oscillator. Options:\n 'sine' (default), 'triangle',\n 'sawtooth', 'square'
\n",type:"String",optional:!0}],example:["\n\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
Constructor: new p5.SinOsc()
.\nThis creates a Sine Wave Oscillator and is\nequivalent to new p5.Oscillator('sine')\n
or creating a p5.Oscillator and then calling\nits method setType('sine')
.\nSee p5.Oscillator for methods.
Set the frequency
\n",type:"Number",optional:!0}]},"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:1910,description:"Constructor: new p5.TriOsc()
.\nThis creates a Triangle Wave Oscillator and is\nequivalent to new p5.Oscillator('triangle')\n
or creating a p5.Oscillator and then calling\nits method setType('triangle')
.\nSee p5.Oscillator for methods.
Set the frequency
\n",type:"Number",optional:!0}]},"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:1929,description:"Constructor: new p5.SawOsc()
.\nThis creates a SawTooth Wave Oscillator and is\nequivalent to new p5.Oscillator('sawtooth')\n
or creating a p5.Oscillator and then calling\nits method setType('sawtooth')
.\nSee p5.Oscillator for methods.
Set the frequency
\n",type:"Number",optional:!0}]},"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:1948,description:"Constructor: new p5.SqrOsc()
.\nThis creates a Square Wave Oscillator and is\nequivalent to new p5.Oscillator('square')\n
or creating a p5.Oscillator and then calling\nits method setType('square')
.\nSee p5.Oscillator for methods.
Set the frequency
\n",type:"Number",optional:!0}]},"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:2008,description:"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.
\n",is_constructor:1,example:["\n\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
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();
\n",is_constructor:1},"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:2426,description:"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.
\n",is_constructor:1,params:[{name:"synthVoice",description:"A monophonic synth voice inheriting\n the AudioVoice class. Defaults to p5.MonoSynth
\n",type:"Number",optional:!0},{name:"maxVoices",description:"Number of voices, defaults to 8;
\n",type:"Number",optional:!0}],example:["\n\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
SoundFile object with a path to a file.
\n\nThe p5.SoundFile may not be available immediately because\nit loads the file information asynchronously.
\n\nTo do something with the sound as soon as it loads\npass the name of a function as the second parameter.
\n\nOnly one file path is required. However, audio file formats\n(i.e. mp3, ogg, wav and m4a/aac) are not supported by all\nweb browsers. If you want to ensure compatability, instead of a single\nfile path, you may include an Array of filepaths, and the browser will\nchoose a format that works.
",is_constructor:1,params:[{name:"path",description:"path to a sound file (String). Optionally,\n you may include multiple file formats in\n an array. Alternately, accepts an object\n from the HTML5 File API, or a p5.File.
\n",type:"String|Array"},{name:"successCallback",description:"Name of a function to call once file loads
\n",type:"Function",optional:!0},{name:"errorCallback",description:"Name of a function to call if file fails to\n load. This function will receive an error or\n XMLHttpRequest object with information\n about what went wrong.
\n",type:"Function",optional:!0},{name:"whileLoadingCallback",description:"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.
\n",type:"Function",optional:!0}],example:["\n\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
Amplitude measures volume between 0.0 and 1.0.\nListens to all p5sound by default, or use setInput()\nto listen to a specific sound source. Accepts an optional\nsmoothing value, which defaults to 0.
\n",is_constructor:1,params:[{name:"smoothing",description:"between 0.0 and .999 to smooth\n amplitude readings (defaults to 0)
\n",type:"Number",optional:!0}],example:["\n\nlet sound, amplitude;\n\nfunction preload(){\n sound = loadSound('assets/beat.mp3');\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);\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 (sound.isPlaying() ){\n sound.stop();\n } else {\n sound.play();\n }\n}\n\n
FFT (Fast Fourier Transform) is an analysis algorithm that\nisolates individual\n\naudio frequencies within a waveform.
\n\nOnce instantiated, a p5.FFT object can return an array based on\ntwo types of analyses:
• FFT.waveform()
computes\namplitude values along the time domain. The array indices correspond\nto samples across a brief moment in time. Each value represents\namplitude of the waveform at that sample of time.
\n• FFT.analyze()
computes amplitude values along the\nfrequency domain. The array indices correspond to frequencies (i.e.\npitches), from the lowest to the highest that humans can hear. Each\nvalue represents amplitude at that slice of the frequency spectrum.\nUse with getEnergy()
to measure amplitude at specific\nfrequencies, or within a range of frequencies.
FFT analyzes a very short snapshot of sound called a sample\nbuffer. It returns an array of amplitude measurements, referred\nto as bins
. The array is 1024 bins long by default.\nYou can change the bin array length, but it must be a power of 2\nbetween 16 and 1024 in order for the FFT algorithm to function\ncorrectly. The actual size of the FFT buffer is twice the\nnumber of bins, so given a standard sample rate, the buffer is\n2048/44100 seconds long.
Smooth results of Freq Spectrum.\n 0.0 < smoothing < 1.0.\n Defaults to 0.8.
\n",type:"Number",optional:!0},{name:"bins",description:"Length of resulting array.\n Must be a power of two between\n 16 and 1024. Defaults to 1024.
\n",type:"Number",optional:!0}],example:["\n\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
p5.Signal is a constant audio-rate signal used by p5.Oscillator\nand p5.Envelope for modulation math.
\n\nThis is necessary because Web Audio is processed on a seprate clock.\nFor example, the p5 draw loop runs about 60 times per second. But\nthe audio clock must process samples 44100 times per second. If we\nwant to add a value to each of those samples, we can't do it in the\ndraw loop, but we can do it by adding a constant-rate audio signal.This class mostly functions behind the scenes in p5.sound, and returns\na Tone.Signal from the Tone.js library by Yotam Mann.\nIf you want to work directly with audio signals for modular\nsynthesis, check out\ntone.js.
",is_constructor:1,return:{description:"A Signal object from the Tone.js library",type:"Tone.Signal"},example:["\n\nlet carrier, modulator;\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 carrier = new p5.Oscillator('sine');\n carrier.start();\n carrier.amp(1); // set amplitude\n carrier.freq(220); // set frequency\n\n modulator = new p5.Oscillator('sawtooth');\n modulator.disconnect();\n modulator.start();\n modulator.amp(1);\n modulator.freq(4);\n\n // Modulator's default amplitude range is -1 to 1.\n // Multiply it by -200, so the range is -200 to 200\n // then add 220 so the range is 20 to 420\n carrier.freq( modulator.mult(-400).add(220) );\n}\n\nfunction canvasPressed() {\n userStartAudio();\n carrier.amp(1.0);\n}\n\nfunction mouseReleased() {\n carrier.amp(0);\n}\n
Envelopes are pre-defined amplitude distribution over time.\nTypically, envelopes are used to control the output volume\nof an object, a series of fades referred to as Attack, Decay,\nSustain and Release (\nADSR\n). Envelopes can also control other Web Audio Parameters—for example, a p5.Envelope can\ncontrol an Oscillator\'s frequency like this: osc.freq(env)
.
Use setRange
to change the attack/release level.\nUse setADSR
to change attackTime, decayTime, sustainPercent and releaseTime.
Use the play
method to play the entire envelope,\nthe ramp
method for a pingable trigger,\nor triggerAttack
/\ntriggerRelease
to trigger noteOn/noteOff.
\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
Creates a Pulse object, an oscillator that implements\nPulse Width Modulation.\nThe pulse is created with two oscillators.\nAccepts a parameter for frequency, and to set the\nwidth between the pulses. See \np5.Oscillator
for a full list of methods.
Frequency in oscillations per second (Hz)
\n",type:"Number",optional:!0},{name:"w",description:"Width between the pulses (0 to 1.0,\n defaults to 0)
\n",type:"Number",optional:!0}],example:["\n\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
Noise is a type of oscillator that generates a buffer with random values.
\n",extends:"p5.Oscillator",is_constructor:1,params:[{name:"type",description:"Type of noise can be 'white' (default),\n 'brown' or 'pink'.
\n",type:"String"}]},"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:7583,description:'Get audio from an input, i.e. your computer\'s microphone.
\n\nTurn the mic on/off with the start() and stop() methods. When the mic\nis on, its volume can be measured with getLevel or by connecting an\nFFT object.
\n\nIf you want to hear the AudioIn, use the .connect() method.\nAudioIn does not connect to p5.sound output by default to prevent\nfeedback.
\n\nNote: This uses the getUserMedia/\nStream 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.
',is_constructor:1,params:[{name:"errorCallback",description:"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.
\n",type:"Function",optional:!0}],example:["\n\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
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).
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n',is_constructor:1,extends:"p5.Effect",params:[{name:"_eqsize",description:"Constructor will accept 3 or 8, defaults to 3
\n",type:"Number",optional:!0}],return:{description:"p5.EQ object",type:"Object"},example:["\n\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
Panner3D is based on the \nWeb Audio Spatial Panner Node.\nThis panner is a spatial processing node that allows audio to be positioned\nand oriented in 3D space.
\nThe position is relative to an \nAudio Context Listener, which can be accessed\nby p5.soundOut.audiocontext.listener
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.
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n',extends:"p5.Effect",is_constructor:1,example:["\n\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
Reverb adds depth to a sound through a large number of decaying\nechoes. It creates the perception that sound is occurring in a\nphysical space. The p5.Reverb has paramters for Time (how long does the\nreverb last) and decayRate (how much the sound decays with each echo)\nthat can be set with the .set() or .process() methods. The p5.Convolver\nextends p5.Reverb allowing you to recreate the sound of actual physical\nspaces through convolution.
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n',extends:"p5.Effect",is_constructor:1,example:["\n\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
p5.Convolver extends p5.Reverb. It can emulate the sound of real\nphysical spaces through a process called \nconvolution.
\n\nConvolution multiplies any audio input by an "impulse response"\nto simulate the dispersion of sound over time. The impulse response is\ngenerated from an audio file that you provide. One way to\ngenerate an impulse response is to pop a balloon in a reverberant space\nand record the echo. Convolution can also be used to experiment with\nsound.
\n\nUse the method createConvolution(path)
to instantiate a\np5.Convolver with a path to your impulse response audio file.
path to a sound file
\n",type:"String"},{name:"callback",description:"function to call when loading succeeds
\n",type:"Function",optional:!0},{name:"errorCallback",description:"function to call if loading fails.\n This function will receive an error or\n XMLHttpRequest object with information\n about what went wrong.
\n",type:"Function",optional:!0}],example:["\n\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 master output...\n sound.disconnect();\n\n // ...and process with cVerb\n // so that we only hear the convolution\n cVerb.process(sound);\n}\n\nfunction playSound() {\n sound.play();\n}\n
A phrase is a pattern of musical events over time, i.e.\na series of notes and rests.
\n\nPhrases must be added to a p5.Part for playback, and\neach part can play multiple phrases at the same time.\nFor example, one Phrase might be a kick drum, another\ncould be a snare, and another could be the bassline.
\n\nThe first parameter is a name so that the phrase can be\nmodified or deleted later. The callback is a a function that\nthis phrase will call at every step—for example it might be\ncalled playNote(value){}
. The array determines\nwhich value is passed into the callback at each step of the\nphrase. It can be numbers, an object with multiple numbers,\nor a zero (0) indicates a rest so the callback won't be called).
Name so that you can access the Phrase.
\n",type:"String"},{name:"callback",description:"The name of a function that this phrase\n will call. Typically it will play a sound,\n and accept two parameters: a time at which\n to play the sound (in seconds from now),\n and a value from the sequence array. The\n time should be passed into the play() or\n start() method to ensure precision.
\n",type:"Function"},{name:"sequence",description:"Array of values to pass into the callback\n at each step of the phrase.
\n",type:"Array"}],example:["\n\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
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.
\n\nSee p5.Phrase for more about musical timing.
",is_constructor:1,params:[{name:"steps",description:"Steps in the part
\n",type:"Number",optional:!0},{name:"tatums",description:"Divisions of a beat, e.g. use 1/4, or 0.25 for a quater note (default is 1/16, a sixteenth note)
\n",type:"Number",optional:!0}],example:["\n\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
A Score consists of a series of Parts. The parts will\nbe played back in order. For example, you could have an\nA part, a B part, and a C part, and play them back in this order\nnew p5.Score(a, a, b, a, c)
One or multiple parts, to be played in sequence.
\n",type:"p5.Part",optional:!0,multiple:!0}]},"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:10454,description:"SoundLoop
\n",is_constructor:1,params:[{name:"callback",description:"this function will be called on each iteration of theloop
\n",type:"Function"},{name:"interval",description:'amount of time (if a number) or beats (if a string, following Tone.Time convention) for each iteration of the loop. Defaults to 1 second.
\n',type:"Number|String",optional:!0}],example:["\n\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
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 master output.
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n',is_constructor:1,extends:"p5.Effect"},"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:11056,description:"Record sounds for playback and/or to save as a .wav file.\nThe p5.SoundRecorder records all sound output from your sketch,\nor can be assigned a specific source with setInput().
\nThe record() method accepts a p5.SoundFile as a parameter.\nWhen playback is stopped (either after the given amount of time,\nor with the stop() method), the p5.SoundRecorder will send its\nrecording to that p5.SoundFile for playback.
",is_constructor:1,example:["\n\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
PeakDetect works in conjunction with p5.FFT to\nlook for onsets in some or all of the frequency spectrum.\n
\n\nTo use p5.PeakDetect, call update
in the draw loop\nand pass in a p5.FFT object.\n
\nYou can listen for a specific part of the frequency spectrum by\nsetting the range between freq1
and freq2
.\n
threshold
is the threshold for detecting a peak,\nscaled between 0 and 1. It is logarithmic, so 0.1 is half as loud\nas 1.0.
\nThe update method is meant to be run in the draw loop, and\nframes determines how many loops must pass before\nanother peak can be detected.\nFor example, if the frameRate() = 60, you could detect the beat of a\n120 beat-per-minute song with this equation:\n framesPerPeak = 60 / (estimatedBPM / 60 );
\n
\nBased on example contribtued by @b2renger, and a simple beat detection\nexplanation by Felix Turner.\n
',is_constructor:1,params:[{name:"freq1",description:"lowFrequency - defaults to 20Hz
\n",type:"Number",optional:!0},{name:"freq2",description:"highFrequency - defaults to 20000 Hz
\n",type:"Number",optional:!0},{name:"threshold",description:"Threshold for detecting a beat between 0 and 1\n scaled logarithmically where 0.1 is 1/2 the loudness\n of 1.0. Defaults to 0.35.
\n",type:"Number",optional:!0},{name:"framesPerPeak",description:"Defaults to 20.
\n",type:"Number",optional:!0}],example:["\n\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
A gain node is usefull to set the relative volume of sound.\nIt's typically used to build mixers.
\n",is_constructor:1,example:["\n\n\n// load two soundfile and crossfade beetween them\nlet sound1,sound2;\nlet sound1Gain, sound2Gain, masterGain;\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 'master' gain to which we will connect both soundfiles\n masterGain = new p5.Gain();\n masterGain.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(masterGain); // connect its output to the 'master'\n sound2.disconnect();\n sound2Gain = new p5.Gain();\n sound2Gain.setInput(sound2);\n sound2Gain.connect(masterGain);\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 'master * volume control'\n var masterVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\n masterGain.amp(masterVolume);\n text('master', width/2, height - masterVolume * 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
A Distortion effect created with a Waveshaper Node,\nwith an approach adapted from\nKevin Ennis
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n',extends:"p5.Effect",is_constructor:1,params:[{name:"amount",description:"Unbounded distortion amount.\n Normal values range from 0-1.
\n",type:"Number",optional:!0,optdefault:"0.25"},{name:"oversample",description:"'none', '2x', or '4x'.
\n",type:"String",optional:!0,optdefault:"'none'"}]}},elements:{},classitems:[{file:"src/color/color_conversion.js",line:8,description:'Conversions adapted from http://www.easyrgb.com/en/math.php.
\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.
\n',class:"p5",module:"Color",submodule:"Color Conversion"},{file:"src/color/color_conversion.js",line:19,description:"Convert an HSBA array to HSLA.
\n",class:"p5",module:"Color",submodule:"Color Conversion"},{file:"src/color/color_conversion.js",line:45,description:"Convert an HSBA array to RGBA.
\n",class:"p5",module:"Color",submodule:"Color Conversion"},{file:"src/color/color_conversion.js",line:100,description:"Convert an HSLA array to HSBA.
\n",class:"p5",module:"Color",submodule:"Color Conversion"},{file:"src/color/color_conversion.js",line:123,description:"Convert an HSLA array to RGBA.
\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.
\n",class:"p5",module:"Color",submodule:"Color Conversion"},{file:"src/color/color_conversion.js",line:187,description:"Convert an RGBA array to HSBA.
\n",class:"p5",module:"Color",submodule:"Color Conversion"},{file:"src/color/color_conversion.js",line:226,description:"Convert an RGBA array to HSLA.
\n",class:"p5",module:"Color",submodule:"Color Conversion"},{file:"src/color/creating_reading.js",line:14,description:"Extracts the alpha value from a color or pixel array.
\n",itemtype:"method",name:"alpha",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the alpha value",type:"Number"},example:["\n\nnoStroke();\nlet c = color(0, 126, 255, 102);\nfill(c);\nrect(15, 15, 35, 70);\nlet value = alpha(c); // Sets 'value' to 102\nfill(value);\nrect(50, 15, 35, 70);\n
\nExtracts the blue value from a color or pixel array.
\n",itemtype:"method",name:"blue",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the blue value",type:"Number"},example:["\n\nlet c = color(175, 100, 220); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(15, 20, 35, 60); // Draw left rectangle\n\nlet blueValue = blue(c); // Get blue in 'c'\nprint(blueValue); // Prints \"220.0\"\nfill(0, 0, blueValue); // Use 'blueValue' in new fill\nrect(50, 20, 35, 60); // Draw right rectangle\n
\nExtracts the HSB brightness value from a color or pixel array.
\n",itemtype:"method",name:"brightness",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the brightness value",type:"Number"},example:["\n\nnoStroke();\ncolorMode(HSB, 255);\nlet c = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\nlet value = brightness(c); // Sets 'value' to 255\nfill(value);\nrect(50, 20, 35, 60);\n
\n\nnoStroke();\ncolorMode(HSB, 255);\nlet c = color('hsb(60, 100%, 50%)');\nfill(c);\nrect(15, 20, 35, 60);\nlet value = brightness(c); // A 'value' of 50% is 127.5\nfill(value);\nrect(50, 20, 35, 60);\n
\nCreates colors for storing in variables of the color datatype. The\nparameters are interpreted as RGB or HSB values depending on the\ncurrent colorMode(). The default mode is RGB values from 0 to 255\nand, therefore, the function call color(255, 204, 0) will return a\nbright yellow color.\n
\nNote that if only one value is provided to color(), it will be interpreted\nas a grayscale value. Add a second value, and it will be used for alpha\ntransparency. When three values are specified, they are interpreted as\neither RGB or HSB values. Adding a fourth value applies alpha\ntransparency.\n
\nIf a single string argument is provided, RGB, RGBA and Hex CSS color\nstrings and all named color strings are supported. In this case, an alpha\nnumber value as a second argument is not supported, the RGBA form should be\nused.
\nlet c = color(255, 204, 0); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nnoStroke(); // Don't draw a stroke around shapes\nrect(30, 20, 55, 55); // Draw rectangle\n
\n\nlet c = color(255, 204, 0); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nnoStroke(); // Don't draw a stroke around shapes\nellipse(25, 25, 80, 80); // Draw left circle\n\n// Using only one value with color()\n// generates a grayscale value.\nc = color(65); // Update 'c' with grayscale value\nfill(c); // Use updated 'c' as fill color\nellipse(75, 75, 80, 80); // Draw right circle\n
\n\n// Named SVG & CSS colors may be used,\nlet c = color('magenta');\nfill(c); // Use 'c' as fill color\nnoStroke(); // Don't draw a stroke around shapes\nrect(20, 20, 60, 60); // Draw rectangle\n
\n\n// as can hex color codes:\nnoStroke(); // Don't draw a stroke around shapes\nlet c = color('#0f0');\nfill(c); // Use 'c' as fill color\nrect(0, 10, 45, 80); // Draw rectangle\n\nc = color('#00ff00');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw rectangle\n
\n\n// RGB and RGBA color strings are also supported:\n// these all set to the same color (solid blue)\nlet c;\nnoStroke(); // Don't draw a stroke around shapes\nc = color('rgb(0,0,255)');\nfill(c); // Use 'c' as fill color\nrect(10, 10, 35, 35); // Draw rectangle\n\nc = color('rgb(0%, 0%, 100%)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 35, 35); // Draw rectangle\n\nc = color('rgba(0, 0, 255, 1)');\nfill(c); // Use updated 'c' as fill color\nrect(10, 55, 35, 35); // Draw rectangle\n\nc = color('rgba(0%, 0%, 100%, 1)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 55, 35, 35); // Draw rectangle\n
\n\n// HSL color is also supported and can be specified\n// by value\nlet c;\nnoStroke(); // Don't draw a stroke around shapes\nc = color('hsl(160, 100%, 50%)');\nfill(c); // Use 'c' as fill color\nrect(0, 10, 45, 80); // Draw rectangle\n\nc = color('hsla(160, 100%, 50%, 0.5)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw rectangle\n
\n\n// HSB color is also supported and can be specified\n// by value\nlet c;\nnoStroke(); // Don't draw a stroke around shapes\nc = color('hsb(160, 100%, 50%)');\nfill(c); // Use 'c' as fill color\nrect(0, 10, 45, 80); // Draw rectangle\n\nc = color('hsba(160, 100%, 50%, 0.5)');\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw rectangle\n
\n\nlet c; // Declare color 'c'\nnoStroke(); // Don't draw a stroke around shapes\n\n// If no colorMode is specified, then the\n// default of RGB with scale of 0-255 is used.\nc = color(50, 55, 100); // Create a color for 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(0, 10, 45, 80); // Draw left rect\n\ncolorMode(HSB, 100); // Use HSB with scale of 0-100\nc = color(50, 55, 100); // Update 'c' with new color\nfill(c); // Use updated 'c' as fill color\nrect(55, 10, 45, 80); // Draw right rect\n
\nnumber specifying value between white\n and black.
\n",type:"Number"},{name:"alpha",description:"alpha value relative to current color range\n (default is 0-255)
\n",type:"Number",optional:!0}],return:{description:"resulting color",type:"p5.Color"}},{line:291,params:[{name:"v1",description:"red or hue value relative to\n the current color range
\n",type:"Number"},{name:"v2",description:"green or saturation value\n relative to the current color range
\n",type:"Number"},{name:"v3",description:"blue or brightness value\n relative to the current color range
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}],return:{description:"",type:"p5.Color"}},{line:303,params:[{name:"value",description:"a color string
\n",type:"String"}],return:{description:"",type:"p5.Color"}},{line:308,params:[{name:"values",description:"an array containing the red,green,blue &\n and alpha components of the color
\n",type:"Number[]"}],return:{description:"",type:"p5.Color"}},{line:314,params:[{name:"color",description:"",type:"p5.Color"}],return:{description:"",type:"p5.Color"}}]},{file:"src/color/creating_reading.js",line:330,description:"Extracts the green value from a color or pixel array.
\n",itemtype:"method",name:"green",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the green value",type:"Number"},example:["\n\nlet c = color(20, 75, 200); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(15, 20, 35, 60); // Draw left rectangle\n\nlet greenValue = green(c); // Get green in 'c'\nprint(greenValue); // Print \"75.0\"\nfill(0, greenValue, 0); // Use 'greenValue' in new fill\nrect(50, 20, 35, 60); // Draw right rectangle\n
\nExtracts the hue value from a color or pixel array.
\nHue exists in both HSB and HSL. This function will return the\nHSB-normalized hue when supplied with an HSB color object (or when supplied\nwith a pixel array while the color mode is HSB), but will default to the\nHSL-normalized hue otherwise. (The values will only be different if the\nmaximum hue setting for each system is different.)
\n",itemtype:"method",name:"hue",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the hue",type:"Number"},example:["\n\nnoStroke();\ncolorMode(HSB, 255);\nlet c = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\nlet value = hue(c); // Sets 'value' to \"0\"\nfill(value);\nrect(50, 20, 35, 60);\n
\nBlends two colors to find a third color somewhere between them. The amt\nparameter is the amount to interpolate between the two values where 0.0\nequal to the first color, 0.1 is very near the first color, 0.5 is halfway\nin between, etc. An amount below 0 will be treated as 0. Likewise, amounts\nabove 1 will be capped at 1. This is different from the behavior of lerp(),\nbut necessary because otherwise numbers outside the range will produce\nstrange and unexpected colors.\n
\nThe way that colours are interpolated depends on the current color mode.
interpolate from this color
\n",type:"p5.Color"},{name:"c2",description:"interpolate to this color
\n",type:"p5.Color"},{name:"amt",description:"number between 0 and 1
\n",type:"Number"}],return:{description:"interpolated color",type:"p5.Color"},example:["\n\ncolorMode(RGB);\nstroke(255);\nbackground(51);\nlet from = color(218, 165, 32);\nlet to = color(72, 61, 139);\ncolorMode(RGB); // Try changing to HSB.\nlet interA = lerpColor(from, to, 0.33);\nlet interB = lerpColor(from, to, 0.66);\nfill(from);\nrect(10, 20, 20, 60);\nfill(interA);\nrect(30, 20, 20, 60);\nfill(interB);\nrect(50, 20, 20, 60);\nfill(to);\nrect(70, 20, 20, 60);\n
\nExtracts the HSL lightness value from a color or pixel array.
\n",itemtype:"method",name:"lightness",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the lightness",type:"Number"},example:["\n\nnoStroke();\ncolorMode(HSL);\nlet c = color(156, 100, 50, 1);\nfill(c);\nrect(15, 20, 35, 60);\nlet value = lightness(c); // Sets 'value' to 50\nfill(value);\nrect(50, 20, 35, 60);\n
\nExtracts the red value from a color or pixel array.
\n",itemtype:"method",name:"red",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the red value",type:"Number"},example:["\n\nlet c = color(255, 204, 0); // Define color 'c'\nfill(c); // Use color variable 'c' as fill color\nrect(15, 20, 35, 60); // Draw left rectangle\n\nlet redValue = red(c); // Get red in 'c'\nprint(redValue); // Print \"255.0\"\nfill(redValue, 0, 0); // Use 'redValue' in new fill\nrect(50, 20, 35, 60); // Draw right rectangle\n
\n\ncolorMode(RGB, 255); // Sets the range for red, green, and blue to 255\nlet c = color(127, 255, 0);\ncolorMode(RGB, 1); // Sets the range for red, green, and blue to 1\nlet myColor = red(c);\nprint(myColor); // 0.4980392156862745\n
\nExtracts the saturation value from a color or pixel array.
\nSaturation is scaled differently in HSB and HSL. This function will return\nthe HSB saturation when supplied with an HSB color object (or when supplied\nwith a pixel array while the color mode is HSB), but will default to the\nHSL saturation otherwise.
\n",itemtype:"method",name:"saturation",params:[{name:"color",description:'p5.Color object, color components,\n or CSS color
\n',type:"p5.Color|Number[]|String"}],return:{description:"the saturation value",type:"Number"},example:["\n\nnoStroke();\ncolorMode(HSB, 255);\nlet c = color(0, 126, 255);\nfill(c);\nrect(15, 20, 35, 60);\nlet value = saturation(c); // Sets 'value' to 126\nfill(value);\nrect(50, 20, 35, 60);\n
\nThis function returns the color formatted as a string. This can be useful\nfor debugging, or for using p5.js with other libraries.
\n",itemtype:"method",name:"toString",params:[{name:"format",description:"How the color string will be formatted.\nLeaving this empty formats the string as rgba(r, g, b, a).\n'#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes.\n'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode.\n'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels.\n'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.
\n",type:"String",optional:!0}],return:{description:"the formatted string",type:"String"},example:["\n\nlet myColor;\nfunction setup() {\n createCanvas(200, 200);\n stroke(255);\n myColor = color(100, 100, 250);\n fill(myColor);\n}\n\nfunction draw() {\n rotate(HALF_PI);\n text(myColor.toString(), 0, -5);\n text(myColor.toString('#rrggbb'), 0, -30);\n text(myColor.toString('rgba%'), 0, -55);\n}\n
\nThe setRed function sets the red component of a color.\nThe range depends on your color mode, in the default RGB mode it's between 0 and 255.
\n",itemtype:"method",name:"setRed",params:[{name:"red",description:"the new red value
\n",type:"Number"}],example:["\n\nlet backgroundColor;\n\nfunction setup() {\n backgroundColor = color(100, 50, 150);\n}\n\nfunction draw() {\n backgroundColor.setRed(128 + 128 * sin(millis() / 1000));\n background(backgroundColor);\n}\n
\nThe setGreen function sets the green component of a color.\nThe range depends on your color mode, in the default RGB mode it's between 0 and 255.
\n",itemtype:"method",name:"setGreen",params:[{name:"green",description:"the new green value
\n",type:"Number"}],example:["\n\nlet backgroundColor;\n\nfunction setup() {\n backgroundColor = color(100, 50, 150);\n}\n\nfunction draw() {\n backgroundColor.setGreen(128 + 128 * sin(millis() / 1000));\n background(backgroundColor);\n}\n
\nThe setBlue function sets the blue component of a color.\nThe range depends on your color mode, in the default RGB mode it's between 0 and 255.
\n",itemtype:"method",name:"setBlue",params:[{name:"blue",description:"the new blue value
\n",type:"Number"}],example:["\n\nlet backgroundColor;\n\nfunction setup() {\n backgroundColor = color(100, 50, 150);\n}\n\nfunction draw() {\n backgroundColor.setBlue(128 + 128 * sin(millis() / 1000));\n background(backgroundColor);\n}\n
\nThe setAlpha function sets the transparency (alpha) value of a color.\nThe range depends on your color mode, in the default RGB mode it's between 0 and 255.
\n",itemtype:"method",name:"setAlpha",params:[{name:"alpha",description:"the new alpha value
\n",type:"Number"}],example:["\n\nlet squareColor;\n\nfunction setup() {\n ellipseMode(CORNERS);\n strokeWeight(4);\n squareColor = color(100, 50, 150);\n}\n\nfunction draw() {\n background(255);\n\n noFill();\n stroke(0);\n ellipse(10, 10, width - 10, height - 10);\n\n squareColor.setAlpha(128 + 128 * sin(millis() / 1000));\n fill(squareColor);\n noStroke();\n rect(13, 13, width - 26, height - 26);\n}\n
\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.
\n",class:"p5.Color",module:"Color",submodule:"Creating & Reading"},{file:"src/color/p5.Color.js",line:453,description:"Saturation is scaled differently in HSB and HSL. This function will return\nthe HSB saturation when supplied with an HSB color object, but will default\nto the HSL saturation otherwise.
\n",class:"p5.Color",module:"Color",submodule:"Creating & Reading"},{file:"src/color/p5.Color.js",line:472,description:"CSS named colors.
\n",class:"p5.Color",module:"Color",submodule:"Creating & Reading"},{file:"src/color/p5.Color.js",line:626,description:"These regular expressions are used to build up the patterns for matching\nviable CSS color strings: fragmenting the regexes in this way increases the\nlegibility and comprehensibility of the code.
\nNote that RGB values of .9 are not parsed by IE, but are supported here for\ncolor string consistency.
\n",class:"p5.Color",module:"Color",submodule:"Creating & Reading"},{file:"src/color/p5.Color.js",line:639,description:"Full color string patterns. The capture groups are necessary.
\n",class:"p5.Color",module:"Color",submodule:"Creating & Reading"},{file:"src/color/p5.Color.js",line:988,description:"For HSB and HSL, interpret the gray level as a brightness/lightness\nvalue (they are equivalent when chroma is zero). For RGB, normalize the\ngray level according to the blue maximum.
\n",class:"p5.Color",module:"Color",submodule:"Creating & Reading"},{file:"src/color/setting.js",line:13,description:'The background() function sets the color used for the background of the\np5.js canvas. The default background is transparent. This function is\ntypically used within draw() to clear the display window at the beginning\nof each frame, but it can be used inside setup() to set the background on\nthe first frame of animation or if the background need only be set once.\n
\nThe color is either specified in terms of the RGB, HSB, or HSL color\ndepending on the current colorMode. (The default color space is RGB, with\neach value in the range from 0 to 255). The alpha range by default is also 0 to 255.\n
\nIf a single string argument is provided, RGB, RGBA and Hex CSS color strings\nand all named color strings are supported. In this case, an alpha number\nvalue as a second argument is not supported, the RGBA form should be used.\n
\nA p5.Color object can also be provided to set the background color.\n
\nA p5.Image can also be provided to set the background image.
\n// Grayscale integer value\nbackground(51);\n
\n\n// R, G & B integer values\nbackground(255, 204, 0);\n
\n\n// H, S & B integer values\ncolorMode(HSB);\nbackground(255, 204, 100);\n
\n\n// Named SVG/CSS color string\nbackground('red');\n
\n\n// three-digit hexadecimal RGB notation\nbackground('#fae');\n
\n\n// six-digit hexadecimal RGB notation\nbackground('#222222');\n
\n\n// integer RGB notation\nbackground('rgb(0,255,0)');\n
\n\n// integer RGBA notation\nbackground('rgba(0,255,0, 0.25)');\n
\n\n// percentage RGB notation\nbackground('rgb(100%,0%,10%)');\n
\n\n// percentage RGBA notation\nbackground('rgba(100%,0%,100%,0.5)');\n
\n\n// p5 Color object\nbackground(color(0, 0, 255));\n
\nany value created by the color() function
\n',type:"p5.Color"}],chainable:1},{line:129,params:[{name:"colorstring",description:"color string, possible formats include: integer\n rgb() or rgba(), percentage rgb() or rgba(),\n 3-digit hex, 6-digit hex
\n",type:"String"},{name:"a",description:"opacity of the background relative to current\n color range (default is 0-255)
\n",type:"Number",optional:!0}],chainable:1},{line:139,params:[{name:"gray",description:"specifies a value between white and black
\n",type:"Number"},{name:"a",description:"",type:"Number",optional:!0}],chainable:1},{line:146,params:[{name:"v1",description:"red or hue value (depending on the current color\n mode)
\n",type:"Number"},{name:"v2",description:"green or saturation value (depending on the current\n color mode)
\n",type:"Number"},{name:"v3",description:"blue or brightness value (depending on the current\n color mode)
\n",type:"Number"},{name:"a",description:"",type:"Number",optional:!0}],chainable:1},{line:158,params:[{name:"values",description:"an array containing the red, green, blue\n and alpha components of the color
\n",type:"Number[]"}],chainable:1},{line:165,params:[{name:"image",description:'image created with loadImage() or createImage(),\n to set as background\n (must be same size as the sketch window)
\n',type:"p5.Image"},{name:"a",description:"",type:"Number",optional:!0}],chainable:1}]},{file:"src/color/setting.js",line:179,description:'Clears the pixels within a buffer. This function only clears the canvas.\nIt will not clear objects created by createX() methods such as\ncreateVideo() or createDiv().\nUnlike the main graphics context, pixels in additional graphics areas created\nwith createGraphics() can be entirely\nor partially transparent. This function clears everything to make all of\nthe pixels 100% transparent.
\n',itemtype:"method",name:"clear",chainable:1,example:["\n\n// Clear the screen on mouse press.\nfunction setup() {\n createCanvas(100, 100);\n}\n\nfunction draw() {\n ellipse(mouseX, mouseY, 20, 20);\n}\n\nfunction mousePressed() {\n clear();\n}\n
\ncolorMode() changes the way p5.js interprets color data. By default, the\nparameters for fill(), stroke(), background(), and color() are defined by\nvalues between 0 and 255 using the RGB color model. This is equivalent to\nsetting colorMode(RGB, 255). Setting colorMode(HSB) lets you use the HSB\nsystem instead. By default, this is colorMode(HSB, 360, 100, 100, 1). You\ncan also use HSL.\n
\nNote: existing color objects remember the mode that they were created in,\nso you can change modes as you like without affecting their appearance.
\nnoStroke();\ncolorMode(RGB, 100);\nfor (let i = 0; i < 100; i++) {\n for (let j = 0; j < 100; j++) {\n stroke(i, j, 0);\n point(i, j);\n }\n}\n
\n\nnoStroke();\ncolorMode(HSB, 100);\nfor (let i = 0; i < 100; i++) {\n for (let j = 0; j < 100; j++) {\n stroke(i, j, 100);\n point(i, j);\n }\n}\n
\n\ncolorMode(RGB, 255);\nlet c = color(127, 255, 0);\n\ncolorMode(RGB, 1);\nlet myColor = c._getRed();\ntext(myColor, 10, 10, 80, 80);\n
\n\nnoFill();\ncolorMode(RGB, 255, 255, 255, 1);\nbackground(255);\n\nstrokeWeight(4);\nstroke(255, 0, 10, 0.3);\nellipse(40, 40, 50, 50);\nellipse(50, 50, 40, 40);\n
\neither RGB, HSB or HSL, corresponding to\n Red/Green/Blue and Hue/Saturation/Brightness\n (or Lightness)
\n",type:"Constant"},{name:"max",description:"range for all values
\n",type:"Number",optional:!0}],chainable:1},{line:295,params:[{name:"mode",description:"",type:"Constant"},{name:"max1",description:"range for the red or hue depending on the\n current color mode
\n",type:"Number"},{name:"max2",description:"range for the green or saturation depending\n on the current color mode
\n",type:"Number"},{name:"max3",description:"range for the blue or brightness/lightness\n depending on the current color mode
\n",type:"Number"},{name:"maxA",description:"range for the alpha
\n",type:"Number",optional:!0}],chainable:1}]},{file:"src/color/setting.js",line:339,description:'Sets the color used to fill shapes. For example, if you run\nfill(204, 102, 0), all shapes drawn after the fill command will be filled with the color orange. This\ncolor is either specified in terms of the RGB or HSB color depending on\nthe current colorMode(). (The default color space is RGB, with each value\nin the range from 0 to 255). The alpha range by default is also 0 to 255.\n
\nIf a single string argument is provided, RGB, RGBA and Hex CSS color strings\nand all named color strings are supported. In this case, an alpha number\nvalue as a second argument is not supported, the RGBA form should be used.\n
\nA p5 Color object can also be provided to set the fill color.
\n// Grayscale integer value\nfill(51);\nrect(20, 20, 60, 60);\n
\n\n// R, G & B integer values\nfill(255, 204, 0);\nrect(20, 20, 60, 60);\n
\n\n// H, S & B integer values\ncolorMode(HSB);\nfill(255, 204, 100);\nrect(20, 20, 60, 60);\n
\n\n// Named SVG/CSS color string\nfill('red');\nrect(20, 20, 60, 60);\n
\n\n// three-digit hexadecimal RGB notation\nfill('#fae');\nrect(20, 20, 60, 60);\n
\n\n// six-digit hexadecimal RGB notation\nfill('#222222');\nrect(20, 20, 60, 60);\n
\n\n// integer RGB notation\nfill('rgb(0,255,0)');\nrect(20, 20, 60, 60);\n
\n\n// integer RGBA notation\nfill('rgba(0,255,0, 0.25)');\nrect(20, 20, 60, 60);\n
\n\n// percentage RGB notation\nfill('rgb(100%,0%,10%)');\nrect(20, 20, 60, 60);\n
\n\n// percentage RGBA notation\nfill('rgba(100%,0%,100%,0.5)');\nrect(20, 20, 60, 60);\n
\n\n// p5 Color object\nfill(color(0, 0, 255));\nrect(20, 20, 60, 60);\n
\nred or hue value relative to\n the current color range
\n",type:"Number"},{name:"v2",description:"green or saturation value\n relative to the current color range
\n",type:"Number"},{name:"v3",description:"blue or brightness value\n relative to the current color range
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}],chainable:1},{line:464,params:[{name:"value",description:"a color string
\n",type:"String"}],chainable:1},{line:470,params:[{name:"gray",description:"a gray value
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}],chainable:1},{line:477,params:[{name:"values",description:"an array containing the red,green,blue &\n and alpha components of the color
\n",type:"Number[]"}],chainable:1},{line:484,params:[{name:"color",description:"the fill color
\n",type:"p5.Color"}],chainable:1}]},{file:"src/color/setting.js",line:496,description:'Disables filling geometry. If both noStroke() and noFill() are called,\nnothing will be drawn to the screen.
\n',itemtype:"method",name:"noFill",chainable:1,example:["\n\nrect(15, 10, 55, 55);\nnoFill();\nrect(20, 20, 60, 60);\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(0);\n noFill();\n stroke(100, 100, 240);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(45, 45, 45);\n}\n
\nDisables drawing the stroke (outline). If both noStroke() and noFill()\nare called, nothing will be drawn to the screen.
\n',itemtype:"method",name:"noStroke",chainable:1,example:["\n\nnoStroke();\nrect(20, 20, 60, 60);\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(0);\n noStroke();\n fill(240, 150, 150);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(45, 45, 45);\n}\n
\nSets the color used to draw lines and borders around shapes. This color\nis either specified in terms of the RGB or HSB color depending on the\ncurrent colorMode() (the default color space is RGB, with each value in\nthe range from 0 to 255). The alpha range by default is also 0 to 255.\n
\nIf a single string argument is provided, RGB, RGBA and Hex CSS color\nstrings and all named color strings are supported. In this case, an alpha\nnumber value as a second argument is not supported, the RGBA form should be\nused.\n
\nA p5 Color object can also be provided to set the stroke color.
\n// Grayscale integer value\nstrokeWeight(4);\nstroke(51);\nrect(20, 20, 60, 60);\n
\n\n// R, G & B integer values\nstroke(255, 204, 0);\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// H, S & B integer values\ncolorMode(HSB);\nstrokeWeight(4);\nstroke(255, 204, 100);\nrect(20, 20, 60, 60);\n
\n\n// Named SVG/CSS color string\nstroke('red');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// three-digit hexadecimal RGB notation\nstroke('#fae');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// six-digit hexadecimal RGB notation\nstroke('#222222');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// integer RGB notation\nstroke('rgb(0,255,0)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// integer RGBA notation\nstroke('rgba(0,255,0,0.25)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// percentage RGB notation\nstroke('rgb(100%,0%,10%)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// percentage RGBA notation\nstroke('rgba(100%,0%,100%,0.5)');\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\n\n// p5 Color object\nstroke(color(0, 0, 255));\nstrokeWeight(4);\nrect(20, 20, 60, 60);\n
\nred or hue value relative to\n the current color range
\n",type:"Number"},{name:"v2",description:"green or saturation value\n relative to the current color range
\n",type:"Number"},{name:"v3",description:"blue or brightness value\n relative to the current color range
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}],chainable:1},{line:716,params:[{name:"value",description:"a color string
\n",type:"String"}],chainable:1},{line:722,params:[{name:"gray",description:"a gray value
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}],chainable:1},{line:729,params:[{name:"values",description:"an array containing the red,green,blue &\n and alpha components of the color
\n",type:"Number[]"}],chainable:1},{line:736,params:[{name:"color",description:"the stroke color
\n",type:"p5.Color"}],chainable:1}]},{file:"src/color/setting.js",line:749,description:'All drawing that follows erase() will subtract from the canvas.\nErased areas will reveal the web page underneath the canvas.\nErasing can be canceled with noErase().\n
\nDrawing done with image()\nand background() will not be affected by erase()\n
A number (0-255) for the strength of erasing for a shape's fill.\n This will default to 255 when no argument is given, which\n is full strength.
\n",type:"Number",optional:!0},{name:"strengthStroke",description:"A number (0-255) for the strength of erasing for a shape's stroke.\n This will default to 255 when no argument is given, which\n is full strength.
\n",type:"Number",optional:!0}],chainable:1,example:["\n\nbackground(100, 100, 250);\nfill(250, 100, 100);\nrect(20, 20, 60, 60);\nerase();\nellipse(25, 30, 30);\nnoErase();\n
\n\nbackground(150, 250, 150);\nfill(100, 100, 250);\nrect(20, 20, 60, 60);\nstrokeWeight(5);\nerase(150, 255);\ntriangle(50, 10, 70, 50, 90, 10);\nnoErase();\n
\n\nfunction setup() {\n smooth();\n createCanvas(100, 100, WEBGL);\n // Make a <p> element and put it behind the canvas\n let p = createP('I am a dom element');\n p.center();\n p.style('font-size', '20px');\n p.style('text-align', 'center');\n p.style('z-index', '-9999');\n}\n\nfunction draw() {\n background(250, 250, 150);\n fill(15, 195, 185);\n noStroke();\n sphere(30);\n erase();\n rotateY(frameCount * 0.02);\n translate(0, 0, 40);\n torus(15, 5);\n noErase();\n}\n
\nEnds erasing that was started with erase().\nThe fill(), stroke(), and\nblendMode() settings will return to what they were\nprior to calling erase().
\n',itemtype:"method",name:"noErase",chainable:1,example:["\n\nbackground(235, 145, 15);\nnoStroke();\nfill(30, 45, 220);\nrect(30, 10, 10, 80);\nerase();\nellipse(50, 50, 60);\nnoErase();\nrect(70, 10, 10, 80);\n
\nThis function does 3 things:
\nBounds the desired start/stop angles for an arc (in radians) so that:
\n0 <= start < TWO_PI ; start <= stop < start + TWO_PI
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.
\nOptionally 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.
\nFlags 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).
\nDraw an arc to the screen. If called with only x, y, w, h, start, and\nstop, the arc will be drawn and filled as an open pie segment. If a mode parameter is provided, the arc\nwill be filled like an open semi-circle (OPEN) , a closed semi-circle (CHORD), or as a closed pie segment (PIE). The\norigin may be changed with the ellipseMode() function.
\nThe arc is always drawn clockwise from wherever start falls to wherever stop falls on the ellipse.\nAdding or subtracting TWO_PI to either angle does not change where they fall.\nIf both start and stop fall at the same place, a full ellipse will be drawn. Be aware that the the\ny-axis increases in the downward direction, therefore angles are measured clockwise from the positive\nx-direction ("3 o'clock").
x-coordinate of the arc's ellipse
\n",type:"Number"},{name:"y",description:"y-coordinate of the arc's ellipse
\n",type:"Number"},{name:"w",description:"width of the arc's ellipse by default
\n",type:"Number"},{name:"h",description:"height of the arc's ellipse by default
\n",type:"Number"},{name:"start",description:"angle to start the arc, specified in radians
\n",type:"Number"},{name:"stop",description:"angle to stop the arc, specified in radians
\n",type:"Number"},{name:"mode",description:"optional parameter to determine the way of drawing\n the arc. either CHORD, PIE or OPEN
\n",type:"Constant",optional:!0},{name:"detail",description:"optional parameter for WebGL mode only. This is to\n specify the number of vertices that makes up the\n perimeter of the arc. Default value is 25.
\n",type:"Number",optional:!0}],chainable:1,example:["\n\narc(50, 55, 50, 50, 0, HALF_PI);\nnoFill();\narc(50, 55, 60, 60, HALF_PI, PI);\narc(50, 55, 70, 70, PI, PI + QUARTER_PI);\narc(50, 55, 80, 80, PI + QUARTER_PI, TWO_PI);\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI);\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN);\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD);\n
\n\narc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE);\n
\nDraws an ellipse (oval) to the screen. An ellipse with equal width and\nheight is a circle. By default, the first two parameters set the location,\nand the third and fourth parameters set the shape's width and height. If\nno height is specified, the value of width is used for both the width and\nheight. If a negative height or width is specified, the absolute value is taken.\nThe origin may be changed with the ellipseMode() function.
\n',itemtype:"method",name:"ellipse",chainable:1,example:["\n\nellipse(56, 46, 55, 55);\n
\nx-coordinate of the ellipse.
\n",type:"Number"},{name:"y",description:"y-coordinate of the ellipse.
\n",type:"Number"},{name:"w",description:"width of the ellipse.
\n",type:"Number"},{name:"h",description:"height of the ellipse.
\n",type:"Number",optional:!0}],chainable:1},{line:236,params:[{name:"x",description:"",type:"Number"},{name:"y",description:"",type:"Number"},{name:"w",description:"",type:"Number"},{name:"h",description:"",type:"Number"},{name:"detail",description:"number of radial sectors to draw (for WebGL mode)
\n",type:"Integer"}]}]},{file:"src/core/shape/2d_primitives.js",line:249,description:"Draws a circle to the screen. A circle is a simple closed shape.\nIt is the set of all points in a plane that are at a given distance from a given point, the centre.\nThis function is a special case of the ellipse() function, where the width and height of the ellipse are the same.\nHeight and width of the ellipse correspond to the diameter of the circle.\nBy default, the first two parameters set the location of the centre of the circle, the third sets the diameter of the circle.
\n",itemtype:"method",name:"circle",params:[{name:"x",description:"x-coordinate of the centre of the circle.
\n",type:"Number"},{name:"y",description:"y-coordinate of the centre of the circle.
\n",type:"Number"},{name:"d",description:"diameter of the circle.
\n",type:"Number"}],chainable:1,example:["\n\n// Draw a circle at location (30, 30) with a diameter of 20.\ncircle(30, 30, 20);\n
\nDraws a line (a direct path between two points) to the screen. The version\nof line() with four parameters draws the line in 2D. To color a line, use\nthe stroke() function. A line cannot be filled, therefore the fill()\nfunction will not affect the color of a line. 2D lines are drawn with a\nwidth of one pixel by default, but this can be changed with the\nstrokeWeight() function.
\n',itemtype:"method",name:"line",chainable:1,example:["\n\nline(30, 20, 85, 75);\n
\n\nline(30, 20, 85, 20);\nstroke(126);\nline(85, 20, 85, 75);\nstroke(255);\nline(85, 75, 30, 75);\n
\nthe x-coordinate of the first point
\n",type:"Number"},{name:"y1",description:"the y-coordinate of the first point
\n",type:"Number"},{name:"x2",description:"the x-coordinate of the second point
\n",type:"Number"},{name:"y2",description:"the y-coordinate of the second point
\n",type:"Number"}],chainable:1},{line:342,params:[{name:"x1",description:"",type:"Number"},{name:"y1",description:"",type:"Number"},{name:"z1",description:"the z-coordinate of the first point
\n",type:"Number"},{name:"x2",description:"",type:"Number"},{name:"y2",description:"",type:"Number"},{name:"z2",description:"the z-coordinate of the second point
\n",type:"Number"}],chainable:1}]},{file:"src/core/shape/2d_primitives.js",line:362,description:'Draws a point, a coordinate in space at the dimension of one pixel.\nThe first parameter is the horizontal value for the point, the second\nvalue is the vertical value for the point. The color of the point is\nchanged with the stroke() function. The size of the point\nis changed with the strokeWeight() function.
\n',itemtype:"method",name:"point",chainable:1,example:["\n\npoint(30, 20);\npoint(85, 20);\npoint(85, 75);\npoint(30, 75);\n
\n\nstroke('purple'); // Change the color\nstrokeWeight(10); // Make the points 10 pixels in size\npoint(30, 20);\npoint(85, 20);\npoint(85, 75);\npoint(30, 75);\n
\n\nlet a = createVector(10, 10);\npoint(a);\nlet b = createVector(10, 20);\npoint(b);\npoint(createVector(20, 10));\npoint(createVector(20, 20));\n
\nthe x-coordinate
\n",type:"Number"},{name:"y",description:"the y-coordinate
\n",type:"Number"},{name:"z",description:"the z-coordinate (for WebGL mode)
\n",type:"Number",optional:!0}],chainable:1},{line:412,params:[{name:"coordinate_vector",description:"the coordinate vector
\n",type:"p5.Vector"}],chainable:1}]},{file:"src/core/shape/2d_primitives.js",line:437,description:"Draw a quad. A quad is a quadrilateral, a four sided polygon. It is\nsimilar to a rectangle, but the angles between its edges are not\nconstrained to ninety degrees. The first pair of parameters (x1,y1)\nsets the first vertex and the subsequent pairs should proceed\nclockwise or counter-clockwise around the defined shape.\nz-arguments only work when quad() is used in WEBGL mode.
\n",itemtype:"method",name:"quad",chainable:1,example:["\n\nquad(38, 31, 86, 20, 69, 63, 30, 76);\n
\nthe x-coordinate of the first point
\n",type:"Number"},{name:"y1",description:"the y-coordinate of the first point
\n",type:"Number"},{name:"x2",description:"the x-coordinate of the second point
\n",type:"Number"},{name:"y2",description:"the y-coordinate of the second point
\n",type:"Number"},{name:"x3",description:"the x-coordinate of the third point
\n",type:"Number"},{name:"y3",description:"the y-coordinate of the third point
\n",type:"Number"},{name:"x4",description:"the x-coordinate of the fourth point
\n",type:"Number"},{name:"y4",description:"the y-coordinate of the fourth point
\n",type:"Number"}],chainable:1},{line:467,params:[{name:"x1",description:"",type:"Number"},{name:"y1",description:"",type:"Number"},{name:"z1",description:"the z-coordinate of the first point
\n",type:"Number"},{name:"x2",description:"",type:"Number"},{name:"y2",description:"",type:"Number"},{name:"z2",description:"the z-coordinate of the second point
\n",type:"Number"},{name:"x3",description:"",type:"Number"},{name:"y3",description:"",type:"Number"},{name:"z3",description:"the z-coordinate of the third point
\n",type:"Number"},{name:"x4",description:"",type:"Number"},{name:"y4",description:"",type:"Number"},{name:"z4",description:"the z-coordinate of the fourth point
\n",type:"Number"}],chainable:1}]},{file:"src/core/shape/2d_primitives.js",line:504,description:'Draws a rectangle to the screen. A rectangle is a four-sided shape with\nevery angle at ninety degrees. By default, the first two parameters set\nthe location of the upper-left corner, the third sets the width, and the\nfourth sets the height. The way these parameters are interpreted, however,\nmay be changed with the rectMode() function.\n
\nThe fifth, sixth, seventh and eighth parameters, if specified,\ndetermine corner radius for the top-left, top-right, lower-right and\nlower-left corners, respectively. An omitted corner radius parameter is set\nto the value of the previously specified radius value in the parameter list.
\n// Draw a rectangle at location (30, 20) with a width and height of 55.\nrect(30, 20, 55, 55);\n
\n\n// Draw a rectangle with rounded corners, each having a radius of 20.\nrect(30, 20, 55, 55, 20);\n
\n\n// Draw a rectangle with rounded corners having the following radii:\n// top-left = 20, top-right = 15, bottom-right = 10, bottom-left = 5.\nrect(30, 20, 55, 55, 20, 15, 10, 5);\n
\nx-coordinate of the rectangle.
\n",type:"Number"},{name:"y",description:"y-coordinate of the rectangle.
\n",type:"Number"},{name:"w",description:"width of the rectangle.
\n",type:"Number"},{name:"h",description:"height of the rectangle.
\n",type:"Number",optional:!0},{name:"tl",description:"optional radius of top-left corner.
\n",type:"Number",optional:!0},{name:"tr",description:"optional radius of top-right corner.
\n",type:"Number",optional:!0},{name:"br",description:"optional radius of bottom-right corner.
\n",type:"Number",optional:!0},{name:"bl",description:"optional radius of bottom-left corner.
\n",type:"Number",optional:!0}],chainable:1},{line:554,params:[{name:"x",description:"",type:"Number"},{name:"y",description:"",type:"Number"},{name:"w",description:"",type:"Number"},{name:"h",description:"",type:"Number"},{name:"detailX",description:"number of segments in the x-direction (for WebGL mode)
\n",type:"Integer",optional:!0},{name:"detailY",description:"number of segments in the y-direction (for WebGL mode)
\n",type:"Integer",optional:!0}],chainable:1}]},{file:"src/core/shape/2d_primitives.js",line:569,description:'Draws a square to the screen. A square is a four-sided shape with\nevery angle at ninety degrees, and equal side size.\nThis function is a special case of the rect() function, where the width and height are the same, and the parameter is called "s" for side size.\nBy default, the first two parameters set the location of the upper-left corner, the third sets the side size of the square.\nThe way these parameters are interpreted, however,\nmay be changed with the rectMode() function.\n
\nThe fourth, fifth, sixth and seventh parameters, if specified,\ndetermine corner radius for the top-left, top-right, lower-right and\nlower-left corners, respectively. An omitted corner radius parameter is set\nto the value of the previously specified radius value in the parameter list.
x-coordinate of the square.
\n",type:"Number"},{name:"y",description:"y-coordinate of the square.
\n",type:"Number"},{name:"s",description:"side size of the square.
\n",type:"Number"},{name:"tl",description:"optional radius of top-left corner.
\n",type:"Number",optional:!0},{name:"tr",description:"optional radius of top-right corner.
\n",type:"Number",optional:!0},{name:"br",description:"optional radius of bottom-right corner.
\n",type:"Number",optional:!0},{name:"bl",description:"optional radius of bottom-left corner.
\n",type:"Number",optional:!0}],chainable:1,example:["\n\n// Draw a square at location (30, 20) with a side size of 55.\nsquare(30, 20, 55);\n
\n\n// Draw a square with rounded corners, each having a radius of 20.\nsquare(30, 20, 55, 20);\n
\n\n// Draw a square with rounded corners having the following radii:\n// top-left = 20, top-right = 15, bottom-right = 10, bottom-left = 5.\nsquare(30, 20, 55, 20, 15, 10, 5);\n
\nA triangle is a plane created by connecting three points. The first two\narguments specify the first point, the middle two arguments specify the\nsecond point, and the last two arguments specify the third point.
\n",itemtype:"method",name:"triangle",params:[{name:"x1",description:"x-coordinate of the first point
\n",type:"Number"},{name:"y1",description:"y-coordinate of the first point
\n",type:"Number"},{name:"x2",description:"x-coordinate of the second point
\n",type:"Number"},{name:"y2",description:"y-coordinate of the second point
\n",type:"Number"},{name:"x3",description:"x-coordinate of the third point
\n",type:"Number"},{name:"y3",description:"y-coordinate of the third point
\n",type:"Number"}],chainable:1,example:["\n\ntriangle(30, 75, 58, 20, 86, 75);\n
\nModifies the location from which ellipses are drawn by changing the way\nin which parameters given to ellipse(),\ncircle() and arc() are interpreted.\n
\nThe default mode is ellipseMode(CENTER), which interprets the first two\nparameters of ellipse() as the shape's center point, while the third and\nfourth parameters are its width and height.\n
\nellipseMode(RADIUS) also uses the first two parameters of ellipse() as\nthe shape's center point, but uses the third and fourth parameters to\nspecify half of the shapes's width and height.\n
\nellipseMode(CORNER) interprets the first two parameters of ellipse() as\nthe upper-left corner of the shape, while the third and fourth parameters\nare its width and height.\n
\nellipseMode(CORNERS) interprets the first two parameters of ellipse() as\nthe location of one corner of the ellipse's bounding box, and the third\nand fourth parameters as the location of the opposite corner.\n
\nThe parameter must be written in ALL CAPS because Javascript is a\ncase-sensitive language.
either CENTER, RADIUS, CORNER, or CORNERS
\n",type:"Constant"}],chainable:1,example:["\n\nellipseMode(RADIUS); // Set ellipseMode to RADIUS\nfill(255); // Set fill to white\nellipse(50, 50, 30, 30); // Draw white ellipse using RADIUS mode\n\nellipseMode(CENTER); // Set ellipseMode to CENTER\nfill(100); // Set fill to gray\nellipse(50, 50, 30, 30); // Draw gray ellipse using CENTER mode\n
\n\nellipseMode(CORNER); // Set ellipseMode is CORNER\nfill(255); // Set fill to white\nellipse(25, 25, 50, 50); // Draw white ellipse using CORNER mode\n\nellipseMode(CORNERS); // Set ellipseMode to CORNERS\nfill(100); // Set fill to gray\nellipse(25, 25, 50, 50); // Draw gray ellipse using CORNERS mode\n
\nDraws all geometry with jagged (aliased) edges. Note that smooth() is\nactive by default in 2D mode, so it is necessary to call noSmooth() to disable\nsmoothing of geometry, images, and fonts. In 3D mode, noSmooth() is enabled\nby default, so it is necessary to call smooth() if you would like\nsmooth (antialiased) edges on your geometry.
\n',itemtype:"method",name:"noSmooth",chainable:1,example:["\n\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\n
\nModifies the location from which rectangles are drawn by changing the way\nin which parameters given to rect() are interpreted.\n
\nThe default mode is rectMode(CORNER), which interprets the first two\nparameters of rect() as the upper-left corner of the shape, while the\nthird and fourth parameters are its width and height.\n
\nrectMode(CORNERS) interprets the first two parameters of rect() as the\nlocation of one corner, and the third and fourth parameters as the\nlocation of the opposite corner.\n
\nrectMode(CENTER) interprets the first two parameters of rect() as the\nshape's center point, while the third and fourth parameters are its\nwidth and height.\n
\nrectMode(RADIUS) also uses the first two parameters of rect() as the\nshape's center point, but uses the third and fourth parameters to specify\nhalf of the shapes's width and height.\n
\nThe parameter must be written in ALL CAPS because Javascript is a\ncase-sensitive language.
either CORNER, CORNERS, CENTER, or RADIUS
\n",type:"Constant"}],chainable:1,example:["\n\nrectMode(CORNER); // Default rectMode is CORNER\nfill(255); // Set fill to white\nrect(25, 25, 50, 50); // Draw white rect using CORNER mode\n\nrectMode(CORNERS); // Set rectMode to CORNERS\nfill(100); // Set fill to gray\nrect(25, 25, 50, 50); // Draw gray rect using CORNERS mode\n
\n\nrectMode(RADIUS); // Set rectMode to RADIUS\nfill(255); // Set fill to white\nrect(50, 50, 30, 30); // Draw white rect using RADIUS mode\n\nrectMode(CENTER); // Set rectMode to CENTER\nfill(100); // Set fill to gray\nrect(50, 50, 30, 30); // Draw gray rect using CENTER mode\n
\nDraws all geometry with smooth (anti-aliased) edges. smooth() will also\nimprove image quality of resized images. Note that smooth() is active by\ndefault in 2D mode; noSmooth() can be used to disable smoothing of geometry,\nimages, and fonts. In 3D mode, noSmooth() is enabled\nby default, so it is necessary to call smooth() if you would like\nsmooth (antialiased) edges on your geometry.
\n',itemtype:"method",name:"smooth",chainable:1,example:["\n\nbackground(0);\nnoStroke();\nsmooth();\nellipse(30, 48, 36, 36);\nnoSmooth();\nellipse(70, 48, 36, 36);\n
\nSets the style for rendering line endings. These ends are either squared,\nextended, or rounded, each of which specified with the corresponding\nparameters: SQUARE, PROJECT, and ROUND. The default cap is ROUND.
\n",itemtype:"method",name:"strokeCap",params:[{name:"cap",description:"either SQUARE, PROJECT, or ROUND
\n",type:"Constant"}],chainable:1,example:["\n\nstrokeWeight(12.0);\nstrokeCap(ROUND);\nline(20, 30, 80, 30);\nstrokeCap(SQUARE);\nline(20, 50, 80, 50);\nstrokeCap(PROJECT);\nline(20, 70, 80, 70);\n
\nSets the style of the joints which connect line segments. These joints\nare either mitered, beveled, or rounded and specified with the\ncorresponding parameters MITER, BEVEL, and ROUND. The default joint is\nMITER.
\n",itemtype:"method",name:"strokeJoin",params:[{name:"join",description:"either MITER, BEVEL, ROUND
\n",type:"Constant"}],chainable:1,example:["\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(MITER);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n
\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(BEVEL);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n
\n\nnoFill();\nstrokeWeight(10.0);\nstrokeJoin(ROUND);\nbeginShape();\nvertex(35, 20);\nvertex(65, 50);\nvertex(35, 80);\nendShape();\n
\nSets the width of the stroke used for lines, points, and the border\naround shapes. All widths are set in units of pixels.
\n",itemtype:"method",name:"strokeWeight",params:[{name:"weight",description:"the weight (in pixels) of the stroke
\n",type:"Number"}],chainable:1,example:["\n\nstrokeWeight(1); // Default\nline(20, 20, 80, 20);\nstrokeWeight(4); // Thicker\nline(20, 40, 80, 40);\nstrokeWeight(10); // Beastly\nline(20, 70, 80, 70);\n
\nDraws a cubic Bezier curve on the screen. These curves are defined by a\nseries of anchor and control points. The first two parameters specify\nthe first anchor point and the last two parameters specify the other\nanchor point, which become the first and last points on the curve. The\nmiddle parameters specify the two control points which define the shape\nof the curve. Approximately speaking, control points "pull" the curve\ntowards them.
Bezier curves were developed by French\nautomotive engineer Pierre Bezier, and are commonly used in computer\ngraphics to define gently sloping curves. See also curve().
\nnoFill();\nstroke(255, 102, 0);\nline(85, 20, 10, 10);\nline(90, 90, 15, 80);\nstroke(0, 0, 0);\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\n
\n\nbackground(0, 0, 0);\nnoFill();\nstroke(255);\nbezier(250, 250, 0, 100, 100, 0, 100, 0, 0, 0, 100, 0);\n
\nx-coordinate for the first anchor point
\n",type:"Number"},{name:"y1",description:"y-coordinate for the first anchor point
\n",type:"Number"},{name:"x2",description:"x-coordinate for the first control point
\n",type:"Number"},{name:"y2",description:"y-coordinate for the first control point
\n",type:"Number"},{name:"x3",description:"x-coordinate for the second control point
\n",type:"Number"},{name:"y3",description:"y-coordinate for the second control point
\n",type:"Number"},{name:"x4",description:"x-coordinate for the second anchor point
\n",type:"Number"},{name:"y4",description:"y-coordinate for the second anchor point
\n",type:"Number"}],chainable:1},{line:64,params:[{name:"x1",description:"",type:"Number"},{name:"y1",description:"",type:"Number"},{name:"z1",description:"z-coordinate for the first anchor point
\n",type:"Number"},{name:"x2",description:"",type:"Number"},{name:"y2",description:"",type:"Number"},{name:"z2",description:"z-coordinate for the first control point
\n",type:"Number"},{name:"x3",description:"",type:"Number"},{name:"y3",description:"",type:"Number"},{name:"z3",description:"z-coordinate for the second control point
\n",type:"Number"},{name:"x4",description:"",type:"Number"},{name:"y4",description:"",type:"Number"},{name:"z4",description:"z-coordinate for the second anchor point
\n",type:"Number"}],chainable:1}]},{file:"src/core/shape/curves.js",line:94,description:"Sets the resolution at which Beziers display.
\nThe default value is 20.
\nThis function is only useful when using the WEBGL renderer\nas the default canvas renderer does not use this information.
\n",itemtype:"method",name:"bezierDetail",params:[{name:"detail",description:"resolution of the curves
\n",type:"Number"}],chainable:1,example:["\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noFill();\n\n bezierDetail(5);\n}\n\nfunction draw() {\n background(200);\n\n bezier(-40, -40, 0,\n 90, -40, 0,\n -90, 40, 0,\n 40, 40, 0);\n}\n
\nEvaluates the Bezier at position t for points a, b, c, d.\nThe parameters a and d are the first and last points\non the curve, and b and c are the control points.\nThe final parameter t varies between 0 and 1.\nThis can be done once with the x coordinates and a second time\nwith the y coordinates to get the location of a bezier curve at t.
\n",itemtype:"method",name:"bezierPoint",params:[{name:"a",description:"coordinate of first point on the curve
\n",type:"Number"},{name:"b",description:"coordinate of first control point
\n",type:"Number"},{name:"c",description:"coordinate of second control point
\n",type:"Number"},{name:"d",description:"coordinate of second point on the curve
\n",type:"Number"},{name:"t",description:"value between 0 and 1
\n",type:"Number"}],return:{description:"the value of the Bezier at position t",type:"Number"},example:["\n\nnoFill();\nlet x1 = 85,\n x2 = 10,\n x3 = 90,\n x4 = 15;\nlet y1 = 20,\n y2 = 10,\n y3 = 90,\n y4 = 80;\nbezier(x1, y1, x2, y2, x3, y3, x4, y4);\nfill(255);\nlet steps = 10;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = bezierPoint(x1, x2, x3, x4, t);\n let y = bezierPoint(y1, y2, y3, y4, t);\n ellipse(x, y, 5, 5);\n}\n
\nEvaluates the tangent to the Bezier at position t for points a, b, c, d.\nThe parameters a and d are the first and last points\non the curve, and b and c are the control points.\nThe final parameter t varies between 0 and 1.
\n",itemtype:"method",name:"bezierTangent",params:[{name:"a",description:"coordinate of first point on the curve
\n",type:"Number"},{name:"b",description:"coordinate of first control point
\n",type:"Number"},{name:"c",description:"coordinate of second control point
\n",type:"Number"},{name:"d",description:"coordinate of second point on the curve
\n",type:"Number"},{name:"t",description:"value between 0 and 1
\n",type:"Number"}],return:{description:"the tangent at position t",type:"Number"},example:["\n\nnoFill();\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\nlet steps = 6;\nfill(255);\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n // Get the location of the point\n let x = bezierPoint(85, 10, 90, 15, t);\n let y = bezierPoint(20, 10, 90, 80, t);\n // Get the tangent points\n let tx = bezierTangent(85, 10, 90, 15, t);\n let ty = bezierTangent(20, 10, 90, 80, t);\n // Calculate an angle from the tangent points\n let a = atan2(ty, tx);\n a += PI;\n stroke(255, 102, 0);\n line(x, y, cos(a) * 30 + x, sin(a) * 30 + y);\n // The following line of code makes a line\n // inverse of the above line\n //line(x, y, cos(a)*-30 + x, sin(a)*-30 + y);\n stroke(0);\n ellipse(x, y, 5, 5);\n}\n
\n\nnoFill();\nbezier(85, 20, 10, 10, 90, 90, 15, 80);\nstroke(255, 102, 0);\nlet steps = 16;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = bezierPoint(85, 10, 90, 15, t);\n let y = bezierPoint(20, 10, 90, 80, t);\n let tx = bezierTangent(85, 10, 90, 15, t);\n let ty = bezierTangent(20, 10, 90, 80, t);\n let a = atan2(ty, tx);\n a -= HALF_PI;\n line(x, y, cos(a) * 8 + x, sin(a) * 8 + y);\n}\n
\nDraws a curved line on the screen between two points, given as the\nmiddle four parameters. The first two parameters are a control point, as\nif the curve came from this point even though it's not drawn. The last\ntwo parameters similarly describe the other control point.
\nLonger curves can be created by putting a series of curve() functions\ntogether or using curveVertex(). An additional function called\ncurveTightness() provides control for the visual quality of the curve.\nThe curve() function is an implementation of Catmull-Rom splines.
\nnoFill();\nstroke(255, 102, 0);\ncurve(5, 26, 5, 26, 73, 24, 73, 61);\nstroke(0);\ncurve(5, 26, 73, 24, 73, 61, 15, 65);\nstroke(255, 102, 0);\ncurve(73, 24, 73, 61, 15, 65, 15, 65);\n
\n\n// Define the curve points as JavaScript objects\nlet p1 = { x: 5, y: 26 },\n p2 = { x: 73, y: 24 };\nlet p3 = { x: 73, y: 61 },\n p4 = { x: 15, y: 65 };\nnoFill();\nstroke(255, 102, 0);\ncurve(p1.x, p1.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);\nstroke(0);\ncurve(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);\nstroke(255, 102, 0);\ncurve(p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, p4.x, p4.y);\n
\n\nnoFill();\nstroke(255, 102, 0);\ncurve(5, 26, 0, 5, 26, 0, 73, 24, 0, 73, 61, 0);\nstroke(0);\ncurve(5, 26, 0, 73, 24, 0, 73, 61, 0, 15, 65, 0);\nstroke(255, 102, 0);\ncurve(73, 24, 0, 73, 61, 0, 15, 65, 0, 15, 65, 0);\n
\nx-coordinate for the beginning control point
\n",type:"Number"},{name:"y1",description:"y-coordinate for the beginning control point
\n",type:"Number"},{name:"x2",description:"x-coordinate for the first point
\n",type:"Number"},{name:"y2",description:"y-coordinate for the first point
\n",type:"Number"},{name:"x3",description:"x-coordinate for the second point
\n",type:"Number"},{name:"y3",description:"y-coordinate for the second point
\n",type:"Number"},{name:"x4",description:"x-coordinate for the ending control point
\n",type:"Number"},{name:"y4",description:"y-coordinate for the ending control point
\n",type:"Number"}],chainable:1},{line:336,params:[{name:"x1",description:"",type:"Number"},{name:"y1",description:"",type:"Number"},{name:"z1",description:"z-coordinate for the beginning control point
\n",type:"Number"},{name:"x2",description:"",type:"Number"},{name:"y2",description:"",type:"Number"},{name:"z2",description:"z-coordinate for the first point
\n",type:"Number"},{name:"x3",description:"",type:"Number"},{name:"y3",description:"",type:"Number"},{name:"z3",description:"z-coordinate for the second point
\n",type:"Number"},{name:"x4",description:"",type:"Number"},{name:"y4",description:"",type:"Number"},{name:"z4",description:"z-coordinate for the ending control point
\n",type:"Number"}],chainable:1}]},{file:"src/core/shape/curves.js",line:362,description:"Sets the resolution at which curves display.
\nThe default value is 20 while the minimum value is 3.
\nThis function is only useful when using the WEBGL renderer\nas the default canvas renderer does not use this\ninformation.
\n",itemtype:"method",name:"curveDetail",params:[{name:"resolution",description:"resolution of the curves
\n",type:"Number"}],chainable:1,example:["\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n curveDetail(5);\n}\nfunction draw() {\n background(200);\n\n curve(250, 600, 0, -30, 40, 0, 30, 30, 0, -250, 600, 0);\n}\n
\nModifies the quality of forms created with curve() and curveVertex().\nThe parameter tightness determines how the curve fits to the vertex\npoints. The value 0.0 is the default value for tightness (this value\ndefines the curves to be Catmull-Rom splines) and the value 1.0 connects\nall the points with straight lines. Values within the range -5.0 and 5.0\nwill deform the curves but will leave them recognizable and as values\nincrease in magnitude, they will continue to deform.
\n',itemtype:"method",name:"curveTightness",params:[{name:"amount",description:"amount of deformation from the original vertices
\n",type:"Number"}],chainable:1,example:["\n\n// Move the mouse left and right to see the curve change\n\nfunction setup() {\n createCanvas(100, 100);\n noFill();\n}\n\nfunction draw() {\n background(204);\n let t = map(mouseX, 0, width, -5, 5);\n curveTightness(t);\n beginShape();\n curveVertex(10, 26);\n curveVertex(10, 26);\n curveVertex(83, 24);\n curveVertex(83, 61);\n curveVertex(25, 65);\n curveVertex(25, 65);\n endShape();\n}\n
\nEvaluates the curve at position t for points a, b, c, d.\nThe parameter t varies between 0 and 1, a and d are control points\nof the curve, and b and c are the start and end points of the curve.\nThis can be done once with the x coordinates and a second time\nwith the y coordinates to get the location of a curve at t.
\n",itemtype:"method",name:"curvePoint",params:[{name:"a",description:"coordinate of first control point of the curve
\n",type:"Number"},{name:"b",description:"coordinate of first point
\n",type:"Number"},{name:"c",description:"coordinate of second point
\n",type:"Number"},{name:"d",description:"coordinate of second control point
\n",type:"Number"},{name:"t",description:"value between 0 and 1
\n",type:"Number"}],return:{description:"bezier value at position t",type:"Number"},example:["\n\nnoFill();\ncurve(5, 26, 5, 26, 73, 24, 73, 61);\ncurve(5, 26, 73, 24, 73, 61, 15, 65);\nfill(255);\nellipseMode(CENTER);\nlet steps = 6;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = curvePoint(5, 5, 73, 73, t);\n let y = curvePoint(26, 26, 24, 61, t);\n ellipse(x, y, 5, 5);\n x = curvePoint(5, 73, 73, 15, t);\n y = curvePoint(26, 24, 61, 65, t);\n ellipse(x, y, 5, 5);\n}\n
\nEvaluates the tangent to the curve at position t for points a, b, c, d.\nThe parameter t varies between 0 and 1, a and d are points on the curve,\nand b and c are the control points.
\n",itemtype:"method",name:"curveTangent",params:[{name:"a",description:"coordinate of first point on the curve
\n",type:"Number"},{name:"b",description:"coordinate of first control point
\n",type:"Number"},{name:"c",description:"coordinate of second control point
\n",type:"Number"},{name:"d",description:"coordinate of second point on the curve
\n",type:"Number"},{name:"t",description:"value between 0 and 1
\n",type:"Number"}],return:{description:"the tangent at position t",type:"Number"},example:["\n\nnoFill();\ncurve(5, 26, 73, 24, 73, 61, 15, 65);\nlet steps = 6;\nfor (let i = 0; i <= steps; i++) {\n let t = i / steps;\n let x = curvePoint(5, 73, 73, 15, t);\n let y = curvePoint(26, 24, 61, 65, t);\n //ellipse(x, y, 5, 5);\n let tx = curveTangent(5, 73, 73, 15, t);\n let ty = curveTangent(26, 24, 61, 65, t);\n let a = atan2(ty, tx);\n a -= PI / 2.0;\n line(x, y, cos(a) * 8 + x, sin(a) * 8 + y);\n}\n
\nUse the beginContour() and endContour() functions to create negative\nshapes within shapes such as the center of the letter 'O'. beginContour()\nbegins recording vertices for the shape and endContour() stops recording.\nThe vertices that define a negative shape must "wind" in the opposite\ndirection from the exterior shape. First draw vertices for the exterior\nclockwise order, then for internal shapes, draw vertices\nshape in counter-clockwise.\n
\nThese functions can only be used within a beginShape()/endShape() pair and\ntransformations such as translate(), rotate(), and scale() do not work\nwithin a beginContour()/endContour() pair. It is also not possible to use\nother shapes, such as ellipse() or rect() within.
\ntranslate(50, 50);\nstroke(255, 0, 0);\nbeginShape();\n// Exterior part of shape, clockwise winding\nvertex(-40, -40);\nvertex(40, -40);\nvertex(40, 40);\nvertex(-40, 40);\n// Interior part of shape, counter-clockwise winding\nbeginContour();\nvertex(-20, -20);\nvertex(-20, 20);\nvertex(20, 20);\nvertex(20, -20);\nendContour();\nendShape(CLOSE);\n
\nUsing the beginShape() and endShape() functions allow creating more\ncomplex forms. beginShape() begins recording vertices for a shape and\nendShape() stops recording. The value of the kind parameter tells it which\ntypes of shapes to create from the provided vertices. With no mode\nspecified, the shape can be any irregular polygon.\n
\nThe parameters available for beginShape() are POINTS, LINES, TRIANGLES,\nTRIANGLE_FAN, TRIANGLE_STRIP, QUADS, QUAD_STRIP, and TESS (WebGL only). After calling the\nbeginShape() function, a series of vertex() commands must follow. To stop\ndrawing the shape, call endShape(). Each shape will be outlined with the\ncurrent stroke color and filled with the fill color.\n
\nTransformations such as translate(), rotate(), and scale() do not work\nwithin beginShape(). It is also not possible to use other shapes, such as\nellipse() or rect() within beginShape().
either POINTS, LINES, TRIANGLES, TRIANGLE_FAN\n TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS
\n",type:"Constant",optional:!0}],chainable:1,example:["\n\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n
\n\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\nbeginShape(LINES);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\nnoFill();\nbeginShape();\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape(CLOSE);\n
\n\nbeginShape(TRIANGLES);\nvertex(30, 75);\nvertex(40, 20);\nvertex(50, 75);\nvertex(60, 20);\nvertex(70, 75);\nvertex(80, 20);\nendShape();\n
\n\nbeginShape(TRIANGLE_STRIP);\nvertex(30, 75);\nvertex(40, 20);\nvertex(50, 75);\nvertex(60, 20);\nvertex(70, 75);\nvertex(80, 20);\nvertex(90, 75);\nendShape();\n
\n\nbeginShape(TRIANGLE_FAN);\nvertex(57.5, 50);\nvertex(57.5, 15);\nvertex(92, 50);\nvertex(57.5, 85);\nvertex(22, 50);\nvertex(57.5, 15);\nendShape();\n
\n\nbeginShape(QUADS);\nvertex(30, 20);\nvertex(30, 75);\nvertex(50, 75);\nvertex(50, 20);\nvertex(65, 20);\nvertex(65, 75);\nvertex(85, 75);\nvertex(85, 20);\nendShape();\n
\n\nbeginShape(QUAD_STRIP);\nvertex(30, 20);\nvertex(30, 75);\nvertex(50, 20);\nvertex(50, 75);\nvertex(65, 20);\nvertex(65, 75);\nvertex(85, 20);\nvertex(85, 75);\nendShape();\n
\n\nbeginShape();\nvertex(20, 20);\nvertex(40, 20);\nvertex(40, 40);\nvertex(60, 40);\nvertex(60, 60);\nvertex(20, 60);\nendShape(CLOSE);\n
\nSpecifies vertex coordinates for Bezier curves. Each call to\nbezierVertex() defines the position of two control points and\none anchor point of a Bezier curve, adding a new segment to a\nline or shape. For WebGL mode bezierVertex() can be used in 2D\nas well as 3D mode. 2D mode expects 6 parameters, while 3D mode\nexpects 9 parameters (including z coordinates).\n
\nThe first time bezierVertex() is used within a beginShape()\ncall, it must be prefaced with a call to vertex() to set the first anchor\npoint. This function must be used between beginShape() and endShape()\nand only when there is no MODE or POINTS parameter specified to\nbeginShape().
\nnoFill();\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nendShape();\n
\n\nbeginShape();\nvertex(30, 20);\nbezierVertex(80, 0, 80, 75, 30, 75);\nbezierVertex(50, 80, 60, 25, 30, 20);\nendShape();\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n}\nfunction draw() {\n orbitControl();\n background(50);\n strokeWeight(4);\n stroke(255);\n point(-25, 30);\n point(25, 30);\n point(25, -30);\n point(-25, -30);\n\n strokeWeight(1);\n noFill();\n\n beginShape();\n vertex(-25, 30);\n bezierVertex(25, 30, 25, -30, -25, -30);\n endShape();\n\n beginShape();\n vertex(-25, 30, 20);\n bezierVertex(25, 30, 20, 25, -30, 20, -25, -30, 20);\n endShape();\n}\n
\nx-coordinate for the first control point
\n",type:"Number"},{name:"y2",description:"y-coordinate for the first control point
\n",type:"Number"},{name:"x3",description:"x-coordinate for the second control point
\n",type:"Number"},{name:"y3",description:"y-coordinate for the second control point
\n",type:"Number"},{name:"x4",description:"x-coordinate for the anchor point
\n",type:"Number"},{name:"y4",description:"y-coordinate for the anchor point
\n",type:"Number"}],chainable:1},{line:356,params:[{name:"x2",description:"",type:"Number"},{name:"y2",description:"",type:"Number"},{name:"z2",description:"z-coordinate for the first control point (for WebGL mode)
\n",type:"Number"},{name:"x3",description:"",type:"Number"},{name:"y3",description:"",type:"Number"},{name:"z3",description:"z-coordinate for the second control point (for WebGL mode)
\n",type:"Number"},{name:"x4",description:"",type:"Number"},{name:"y4",description:"",type:"Number"},{name:"z4",description:"z-coordinate for the anchor point (for WebGL mode)
\n",type:"Number"}],chainable:1}]},{file:"src/core/shape/vertex.js",line:396,description:'Specifies vertex coordinates for curves. This function may only\nbe used between beginShape() and endShape() and only when there\nis no MODE parameter specified to beginShape().\nFor WebGL mode curveVertex() can be used in 2D as well as 3D mode.\n2D mode expects 2 parameters, while 3D mode expects 3 parameters.\n
\nThe first and last points in a series of curveVertex() lines will be used to\nguide the beginning and end of a the curve. A minimum of four\npoints is required to draw a tiny curve between the second and\nthird points. Adding a fifth point with curveVertex() will draw\nthe curve between the second, third, and fourth points. The\ncurveVertex() function is an implementation of Catmull-Rom\nsplines.
\nstrokeWeight(5);\npoint(84, 91);\npoint(68, 19);\npoint(21, 17);\npoint(32, 91);\nstrokeWeight(1);\n\nnoFill();\nbeginShape();\ncurveVertex(84, 91);\ncurveVertex(84, 91);\ncurveVertex(68, 19);\ncurveVertex(21, 17);\ncurveVertex(32, 91);\ncurveVertex(32, 91);\nendShape();\n
\nx-coordinate of the vertex
\n",type:"Number"},{name:"y",description:"y-coordinate of the vertex
\n",type:"Number"}],chainable:1},{line:441,params:[{name:"x",description:"",type:"Number"},{name:"y",description:"",type:"Number"},{name:"z",description:"z-coordinate of the vertex (for WebGL mode)
\n",type:"Number",optional:!0}],chainable:1}]},{file:"src/core/shape/vertex.js",line:506,description:'Use the beginContour() and endContour() functions to create negative\nshapes within shapes such as the center of the letter 'O'. beginContour()\nbegins recording vertices for the shape and endContour() stops recording.\nThe vertices that define a negative shape must "wind" in the opposite\ndirection from the exterior shape. First draw vertices for the exterior\nclockwise order, then for internal shapes, draw vertices\nshape in counter-clockwise.\n
\nThese functions can only be used within a beginShape()/endShape() pair and\ntransformations such as translate(), rotate(), and scale() do not work\nwithin a beginContour()/endContour() pair. It is also not possible to use\nother shapes, such as ellipse() or rect() within.
\ntranslate(50, 50);\nstroke(255, 0, 0);\nbeginShape();\n// Exterior part of shape, clockwise winding\nvertex(-40, -40);\nvertex(40, -40);\nvertex(40, 40);\nvertex(-40, 40);\n// Interior part of shape, counter-clockwise winding\nbeginContour();\nvertex(-20, -20);\nvertex(-20, 20);\nvertex(20, 20);\nvertex(20, -20);\nendContour();\nendShape(CLOSE);\n
\nThe endShape() function is the companion to beginShape() and may only be\ncalled after beginShape(). When endShape() is called, all of image data\ndefined since the previous call to beginShape() is written into the image\nbuffer. The constant CLOSE as the value for the MODE parameter to close\nthe shape (to connect the beginning and the end).
\n',itemtype:"method",name:"endShape",params:[{name:"mode",description:"use CLOSE to close the shape
\n",type:"Constant",optional:!0}],chainable:1,example:["\n\nnoFill();\n\nbeginShape();\nvertex(20, 20);\nvertex(45, 20);\nvertex(45, 80);\nendShape(CLOSE);\n\nbeginShape();\nvertex(50, 20);\nvertex(75, 20);\nvertex(75, 80);\nendShape();\n
\nSpecifies vertex coordinates for quadratic Bezier curves. Each call to\nquadraticVertex() defines the position of one control points and one\nanchor point of a Bezier curve, adding a new segment to a line or shape.\nThe first time quadraticVertex() is used within a beginShape() call, it\nmust be prefaced with a call to vertex() to set the first anchor point.\nFor WebGL mode quadraticVertex() can be used in 2D as well as 3D mode.\n2D mode expects 4 parameters, while 3D mode expects 6 parameters\n(including z coordinates).\n
\nThis function must be used between beginShape() and endShape()\nand only when there is no MODE or POINTS parameter specified to\nbeginShape().
\nstrokeWeight(5);\npoint(20, 20);\npoint(80, 20);\npoint(50, 50);\n\nnoFill();\nstrokeWeight(1);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nendShape();\n
\n\nstrokeWeight(5);\npoint(20, 20);\npoint(80, 20);\npoint(50, 50);\n\npoint(20, 80);\npoint(80, 80);\npoint(80, 60);\n\nnoFill();\nstrokeWeight(1);\nbeginShape();\nvertex(20, 20);\nquadraticVertex(80, 20, 50, 50);\nquadraticVertex(20, 80, 80, 80);\nvertex(80, 60);\nendShape();\n
\nx-coordinate for the control point
\n",type:"Number"},{name:"cy",description:"y-coordinate for the control point
\n",type:"Number"},{name:"x3",description:"x-coordinate for the anchor point
\n",type:"Number"},{name:"y3",description:"y-coordinate for the anchor point
\n",type:"Number"}],chainable:1},{line:718,params:[{name:"cx",description:"",type:"Number"},{name:"cy",description:"",type:"Number"},{name:"cz",description:"z-coordinate for the control point (for WebGL mode)
\n",type:"Number"},{name:"x3",description:"",type:"Number"},{name:"y3",description:"",type:"Number"},{name:"z3",description:"z-coordinate for the anchor point (for WebGL mode)
\n",type:"Number"}],chainable:1}]},{file:"src/core/shape/vertex.js",line:811,description:'All shapes are constructed by connecting a series of vertices. vertex()\nis used to specify the vertex coordinates for points, lines, triangles,\nquads, and polygons. It is used exclusively within the beginShape() and\nendShape() functions.
\n',itemtype:"method",name:"vertex",chainable:1,example:["\n\nstrokeWeight(3);\nbeginShape(POINTS);\nvertex(30, 20);\nvertex(85, 20);\nvertex(85, 75);\nvertex(30, 75);\nendShape();\n
\n\ncreateCanvas(100, 100, WEBGL);\nbackground(240, 240, 240);\nfill(237, 34, 93);\nnoStroke();\nbeginShape();\nvertex(0, 35);\nvertex(35, 0);\nvertex(0, -35);\nvertex(-35, 0);\nendShape();\n
\n\ncreateCanvas(100, 100, WEBGL);\nbackground(240, 240, 240);\nfill(237, 34, 93);\nnoStroke();\nbeginShape();\nvertex(-10, 10);\nvertex(0, 35);\nvertex(10, 10);\nvertex(35, 0);\nvertex(10, -8);\nvertex(0, -35);\nvertex(-10, -8);\nvertex(-35, 0);\nendShape();\n
\n\nstrokeWeight(3);\nstroke(237, 34, 93);\nbeginShape(LINES);\nvertex(10, 35);\nvertex(90, 35);\nvertex(10, 65);\nvertex(90, 65);\nvertex(35, 10);\nvertex(35, 90);\nvertex(65, 10);\nvertex(65, 90);\nendShape();\n
\n\n// Click to change the number of sides.\n// In WebGL mode, custom shapes will only\n// display hollow fill sections when\n// all calls to vertex() use the same z-value.\n\nlet sides = 3;\nlet angle, px, py;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n fill(237, 34, 93);\n strokeWeight(3);\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n ngon(sides, 0, 0, 80);\n}\n\nfunction mouseClicked() {\n if (sides > 6) {\n sides = 3;\n } else {\n sides++;\n }\n}\n\nfunction ngon(n, x, y, d) {\n beginShape(TESS);\n for (let i = 0; i < n + 1; i++) {\n angle = TWO_PI / n * i;\n px = x + sin(angle) * d / 2;\n py = y - cos(angle) * d / 2;\n vertex(px, py, 0);\n }\n for (let i = 0; i < n + 1; i++) {\n angle = TWO_PI / n * i;\n px = x + sin(angle) * d / 4;\n py = y - cos(angle) * d / 4;\n vertex(px, py, 0);\n }\n endShape();\n}\n
\nx-coordinate of the vertex
\n",type:"Number"},{name:"y",description:"y-coordinate of the vertex
\n",type:"Number"}],chainable:1},{line:943,params:[{name:"x",description:"",type:"Number"},{name:"y",description:"",type:"Number"},{name:"z",description:"z-coordinate of the vertex
\n",type:"Number"},{name:"u",description:"the vertex's texture u-coordinate
\n",type:"Number",optional:!0},{name:"v",description:"the vertex's texture v-coordinate
\n",type:"Number",optional:!0}],chainable:1}]},{file:"src/core/constants.js",line:10,description:"The default, two-dimensional renderer.
\n",itemtype:"property",name:"P2D",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:16,description:"One of the two render modes in p5.js: P2D (default renderer) and WEBGL\nEnables 3D render by introducing the third dimension: Z
\n",itemtype:"property",name:"WEBGL",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:25,itemtype:"property",name:"ARROW",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:30,itemtype:"property",name:"CROSS",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:35,itemtype:"property",name:"HAND",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:40,itemtype:"property",name:"MOVE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:45,itemtype:"property",name:"TEXT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:50,itemtype:"property",name:"WAIT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:58,description:'HALF_PI is a mathematical constant with the value\n1.57079632679489661923. It is half the ratio of the\ncircumference of a circle to its diameter. It is useful in\ncombination with the trigonometric functions sin() and cos().
\n',itemtype:"property",name:"HALF_PI",type:"Number",final:1,example:["\n\narc(50, 50, 80, 80, 0, HALF_PI);\n
PI is a mathematical constant with the value\n3.14159265358979323846. It is the ratio of the circumference\nof a circle to its diameter. It is useful in combination with\nthe trigonometric functions sin() and cos().
\n',itemtype:"property",name:"PI",type:"Number",final:1,example:["\n\narc(50, 50, 80, 80, 0, PI);\n
QUARTER_PI is a mathematical constant with the value 0.7853982.\nIt is one quarter the ratio of the circumference of a circle to\nits diameter. It is useful in combination with the trigonometric\nfunctions sin() and cos().
\n',itemtype:"property",name:"QUARTER_PI",type:"Number",final:1,example:["\n\narc(50, 50, 80, 80, 0, QUARTER_PI);\n
TAU is an alias for TWO_PI, a mathematical constant with the\nvalue 6.28318530717958647693. It is twice the ratio of the\ncircumference of a circle to its diameter. It is useful in\ncombination with the trigonometric functions sin() and cos().
\n',itemtype:"property",name:"TAU",type:"Number",final:1,example:["\n\narc(50, 50, 80, 80, 0, TAU);\n
TWO_PI is a mathematical constant with the value\n6.28318530717958647693. It is twice the ratio of the\ncircumference of a circle to its diameter. It is useful in\ncombination with the trigonometric functions sin() and cos().
\n',itemtype:"property",name:"TWO_PI",type:"Number",final:1,example:["\n\narc(50, 50, 80, 80, 0, TWO_PI);\n
Constant to be used with angleMode() function, to set the mode which\np5.js interprates and calculates angles (either DEGREES or RADIANS).
\n',itemtype:"property",name:"DEGREES",type:"String",final:1,example:["\n\nfunction setup() {\n angleMode(DEGREES);\n}\n
Constant to be used with angleMode() function, to set the mode which\np5.js interprates and calculates angles (either RADIANS or DEGREES).
\n',itemtype:"property",name:"RADIANS",type:"String",final:1,example:["\n\nfunction setup() {\n angleMode(RADIANS);\n}\n
AUTO allows us to automatically set the width or height of an element (but not both),\nbased on the current height and width of the element. Only one parameter can\nbe passed to the size function as AUTO, at a time.
\n',itemtype:"property",name:"AUTO",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:366,itemtype:"property",name:"ALT",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:372,itemtype:"property",name:"BACKSPACE",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:377,itemtype:"property",name:"CONTROL",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:382,itemtype:"property",name:"DELETE",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:387,itemtype:"property",name:"DOWN_ARROW",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:392,itemtype:"property",name:"ENTER",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:397,itemtype:"property",name:"ESCAPE",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:402,itemtype:"property",name:"LEFT_ARROW",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:407,itemtype:"property",name:"OPTION",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:412,itemtype:"property",name:"RETURN",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:417,itemtype:"property",name:"RIGHT_ARROW",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:422,itemtype:"property",name:"SHIFT",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:427,itemtype:"property",name:"TAB",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:432,itemtype:"property",name:"UP_ARROW",type:"Number",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:439,itemtype:"property",name:"BLEND",type:"String",final:1,default:"source-over",class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:445,itemtype:"property",name:"REMOVE",type:"String",final:1,default:"destination-out",class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:451,itemtype:"property",name:"ADD",type:"String",final:1,default:"lighter",class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:459,itemtype:"property",name:"DARKEST",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:464,itemtype:"property",name:"LIGHTEST",type:"String",final:1,default:"lighten",class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:470,itemtype:"property",name:"DIFFERENCE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:475,itemtype:"property",name:"SUBTRACT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:480,itemtype:"property",name:"EXCLUSION",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:485,itemtype:"property",name:"MULTIPLY",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:490,itemtype:"property",name:"SCREEN",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:495,itemtype:"property",name:"REPLACE",type:"String",final:1,default:"copy",class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:501,itemtype:"property",name:"OVERLAY",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:506,itemtype:"property",name:"HARD_LIGHT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:511,itemtype:"property",name:"SOFT_LIGHT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:516,itemtype:"property",name:"DODGE",type:"String",final:1,default:"color-dodge",class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:522,itemtype:"property",name:"BURN",type:"String",final:1,default:"color-burn",class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:530,itemtype:"property",name:"THRESHOLD",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:535,itemtype:"property",name:"GRAY",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:540,itemtype:"property",name:"OPAQUE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:545,itemtype:"property",name:"INVERT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:550,itemtype:"property",name:"POSTERIZE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:555,itemtype:"property",name:"DILATE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:560,itemtype:"property",name:"ERODE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:565,itemtype:"property",name:"BLUR",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:572,itemtype:"property",name:"NORMAL",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:577,itemtype:"property",name:"ITALIC",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:582,itemtype:"property",name:"BOLD",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:587,itemtype:"property",name:"BOLDITALIC",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:599,itemtype:"property",name:"LINEAR",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:604,itemtype:"property",name:"QUADRATIC",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:609,itemtype:"property",name:"BEZIER",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:614,itemtype:"property",name:"CURVE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:621,itemtype:"property",name:"STROKE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:626,itemtype:"property",name:"FILL",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:631,itemtype:"property",name:"TEXTURE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:636,itemtype:"property",name:"IMMEDIATE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:644,itemtype:"property",name:"IMAGE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:652,itemtype:"property",name:"NEAREST",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:657,itemtype:"property",name:"REPEAT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:662,itemtype:"property",name:"CLAMP",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:667,itemtype:"property",name:"MIRROR",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:674,itemtype:"property",name:"LANDSCAPE",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:679,itemtype:"property",name:"PORTRAIT",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:689,itemtype:"property",name:"GRID",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/constants.js",line:695,itemtype:"property",name:"AXES",type:"String",final:1,class:"p5",module:"Constants",submodule:"Constants"},{file:"src/core/environment.js",line:20,description:'The print() function writes to the console area of your browser.\nThis function is often helpful for looking at the data a program is\nproducing. This function creates a new line of text for each call to\nthe function. Individual elements can be\nseparated with quotes ("") and joined with the addition operator (+).
\nNote that calling print() without any arguments invokes the window.print()\nfunction which opens the browser's print dialog. To print a blank line\nto console you can write print('\\n').
\n',itemtype:"method",name:"print",params:[{name:"contents",description:"any combination of Number, String, Object, Boolean,\n Array to print
\n",type:"Any"}],example:["\n\nlet x = 10;\nprint('The value of x is ' + x);\n// prints \"The value of x is 10\"\n
The system variable frameCount contains the number of frames that have\nbeen displayed since the program started. Inside setup() the value is 0,\nafter the first iteration of draw it is 1, etc.
\n',itemtype:"property",name:"frameCount",type:"Integer",readonly:"",example:["\n\nfunction setup() {\n frameRate(30);\n textSize(30);\n textAlign(CENTER);\n}\n\nfunction draw() {\n background(200);\n text(frameCount, width / 2, height / 2);\n}\n
The system variable deltaTime contains the time\ndifference between the beginning of the previous frame and the beginning\nof the current frame in milliseconds.\n
\nThis variable is useful for creating time sensitive animation or physics\ncalculation that should stay constant regardless of frame rate.
\nlet rectX = 0;\nlet fr = 30; //starting FPS\nlet clr;\n\nfunction setup() {\n background(200);\n frameRate(fr); // Attempt to refresh at starting FPS\n clr = color(255, 0, 0);\n}\n\nfunction draw() {\n background(200);\n rectX = rectX + 1 * (deltaTime / 50); // Move Rectangle in relation to deltaTime\n\n if (rectX >= width) {\n // If you go off screen.\n if (fr === 30) {\n clr = color(0, 0, 255);\n fr = 10;\n frameRate(fr); // make frameRate 10 FPS\n } else {\n clr = color(255, 0, 0);\n fr = 30;\n frameRate(fr); // make frameRate 30 FPS\n }\n rectX = 0;\n }\n fill(clr);\n rect(rectX, 40, 20, 20);\n}\n
Confirms if the window a p5.js program is in is "focused," meaning that\nthe sketch will accept mouse or keyboard input. This variable is\n"true" if the window is focused and "false" if not.
\n",itemtype:"property",name:"focused",type:"Boolean",readonly:"",example:['\n\n// To demonstrate, put two windows side by side.\n// Click on the window that the p5 sketch isn\'t in!\nfunction draw() {\n background(200);\n noStroke();\n fill(0, 200, 0);\n ellipse(25, 25, 50, 50);\n\n if (!focused) {\n // or "if (focused === false)"\n stroke(200, 0, 0);\n line(0, 0, 100, 100);\n line(100, 0, 0, 100);\n }\n}\n
Sets the cursor to a predefined symbol or an image, or makes it visible\nif already hidden. If you are trying to set an image as the cursor, the\nrecommended size is 16x16 or 32x32 pixels. The values for parameters x and y\nmust be less than the dimensions of the image.
\n",itemtype:"method",name:"cursor",params:[{name:"type",description:'Built-In: either ARROW, CROSS, HAND, MOVE, TEXT and WAIT\n Native CSS properties: 'grab', 'progress', 'cell' etc.\n External: path for cursor's images\n (Allowed File extensions: .cur, .gif, .jpg, .jpeg, .png)\n For more information on Native CSS cursors and url visit:\n https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
\n',type:"String|Constant"},{name:"x",description:"the horizontal active spot of the cursor (must be less than 32)
\n",type:"Number",optional:!0},{name:"y",description:"the vertical active spot of the cursor (must be less than 32)
\n",type:"Number",optional:!0}],example:["\n\n// Move the mouse across the quadrants\n// to see the cursor change\nfunction draw() {\n line(width / 2, 0, width / 2, height);\n line(0, height / 2, width, height / 2);\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://s3.amazonaws.com/mupublicdata/cursor.cur');\n } else {\n cursor('grab');\n }\n}\n
Specifies the number of frames to be displayed every second. For example,\nthe function call frameRate(30) will attempt to refresh 30 times a second.\nIf the processor is not fast enough to maintain the specified rate, the\nframe rate will not be achieved. Setting the frame rate within setup() is\nrecommended. The default frame rate is based on the frame rate of the display\n(here also called "refresh rate"), which is set to 60 frames per second on most\ncomputers. A frame rate of 24 frames per second (usual for movies) or above\nwill be enough for smooth animations\nThis is the same as setFrameRate(val).\n
\nCalling frameRate() with no arguments returns the current framerate. The\ndraw function must run at least once before it will return a value. This\nis the same as getFrameRate().\n
\nCalling frameRate() with arguments that are not of the type numbers\nor are non positive also returns current framerate.
\nlet rectX = 0;\nlet fr = 30; //starting FPS\nlet clr;\n\nfunction setup() {\n background(200);\n frameRate(fr); // Attempt to refresh at starting FPS\n clr = color(255, 0, 0);\n}\n\nfunction draw() {\n background(200);\n rectX = rectX += 1; // Move Rectangle\n\n if (rectX >= width) {\n // If you go off screen.\n if (fr === 30) {\n clr = color(0, 0, 255);\n fr = 10;\n frameRate(fr); // make frameRate 10 FPS\n } else {\n clr = color(255, 0, 0);\n fr = 30;\n frameRate(fr); // make frameRate 30 FPS\n }\n rectX = 0;\n }\n fill(clr);\n rect(rectX, 40, 20, 20);\n}\n
number of frames to be displayed every second
\n",type:"Number"}],chainable:1},{line:291,params:[],return:{description:"current frameRate",type:"Number"}}]},{file:"src/core/environment.js",line:333,description:"Hides the cursor from view.
\n",itemtype:"method",name:"noCursor",example:["\n\nfunction setup() {\n noCursor();\n}\n\nfunction draw() {\n background(200);\n ellipse(mouseX, mouseY, 10, 10);\n}\n
System variable that stores the width of the screen display according to The\ndefault pixelDensity. This is used to run a\nfull-screen program on any display size. To return actual screen size,\nmultiply this by pixelDensity.
\n',itemtype:"property",name:"displayWidth",type:"Number",readonly:"",example:['\n\ncreateCanvas(displayWidth, displayHeight);\n
System variable that stores the height of the screen display according to The\ndefault pixelDensity. This is used to run a\nfull-screen program on any display size. To return actual screen size,\nmultiply this by pixelDensity.
\n',itemtype:"property",name:"displayHeight",type:"Number",readonly:"",example:['\n\ncreateCanvas(displayWidth, displayHeight);\n
System variable that stores the width of the inner window, it maps to\nwindow.innerWidth.
\n",itemtype:"property",name:"windowWidth",type:"Number",readonly:"",example:['\n\ncreateCanvas(windowWidth, windowHeight);\n
System variable that stores the height of the inner window, it maps to\nwindow.innerHeight.
\n",itemtype:"property",name:"windowHeight",type:"Number",readonly:"",example:['\n\ncreateCanvas(windowWidth, windowHeight);\n
The windowResized() function is called once every time the browser window\nis resized. This is a good place to resize the canvas or do any other\nadjustments to accommodate the new window size.
\n',itemtype:"method",name:"windowResized",example:['\n\nfunction setup() {\n createCanvas(windowWidth, windowHeight);\n}\n\nfunction draw() {\n background(0, 100, 200);\n}\n\nfunction windowResized() {\n resizeCanvas(windowWidth, windowHeight);\n}\n
System variable that stores the width of the drawing canvas. This value\nis set by the first parameter of the createCanvas() function.\nFor example, the function call createCanvas(320, 240) sets the width\nvariable to the value 320. The value of width defaults to 100 if\ncreateCanvas() is not used in a program.
\n',itemtype:"property",name:"width",type:"Number",readonly:"",class:"p5",module:"Environment",submodule:"Environment"},{file:"src/core/environment.js",line:494,description:'System variable that stores the height of the drawing canvas. This value\nis set by the second parameter of the createCanvas() function. For\nexample, the function call createCanvas(320, 240) sets the height\nvariable to the value 240. The value of height defaults to 100 if\ncreateCanvas() is not used in a program.
\n',itemtype:"property",name:"height",type:"Number",readonly:"",class:"p5",module:"Environment",submodule:"Environment"},{file:"src/core/environment.js",line:506,description:"If argument is given, sets the sketch to fullscreen or not based on the\nvalue of the argument. If no argument is given, returns the current\nfullscreen state. Note that due to browser restrictions this can only\nbe called on user input, for example, on mouse press like the example\nbelow.
\n",itemtype:"method",name:"fullscreen",params:[{name:"val",description:"whether the sketch should be in fullscreen mode\nor not
\n",type:"Boolean",optional:!0}],return:{description:"current fullscreen state",type:"Boolean"},example:["\n\n// Clicking in the box toggles fullscreen on and off.\nfunction setup() {\n background(200);\n}\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) {\n let fs = fullscreen();\n fullscreen(!fs);\n }\n}\n
\nSets the pixel scaling for high pixel density displays. By default\npixel density is set to match display density, call pixelDensity(1)\nto turn this off. Calling pixelDensity() with no arguments returns\nthe current pixel density of the sketch.
\n',itemtype:"method",name:"pixelDensity",chainable:1,example:["\n\nfunction setup() {\n pixelDensity(1);\n createCanvas(100, 100);\n background(200);\n ellipse(width / 2, height / 2, 50, 50);\n}\n
\n\nfunction setup() {\n pixelDensity(3.0);\n createCanvas(100, 100);\n background(200);\n ellipse(width / 2, height / 2, 50, 50);\n}\n
\nwhether or how much the sketch should scale
\n",type:"Number"}],chainable:1},{line:592,params:[],return:{description:"current pixel density of the sketch",type:"Number"}}]},{file:"src/core/environment.js",line:611,description:"Returns the pixel density of the current display the sketch is running on.
\n",itemtype:"method",name:"displayDensity",return:{description:"current pixel density of the display",type:"Number"},example:["\n\nfunction setup() {\n let density = displayDensity();\n pixelDensity(density);\n createCanvas(100, 100);\n background(200);\n ellipse(width / 2, height / 2, 50, 50);\n}\n
\nGets the current URL.
\n",itemtype:"method",name:"getURL",return:{description:"url",type:"String"},example:["\n\nlet url;\nlet x = 100;\n\nfunction setup() {\n fill(0);\n noStroke();\n url = getURL();\n}\n\nfunction draw() {\n background(200);\n text(url, x, height / 2);\n x--;\n}\n
\nGets the current URL path as an array.
\n",itemtype:"method",name:"getURLPath",return:{description:"path components",type:"String[]"},example:["\n\nfunction setup() {\n let urlPath = getURLPath();\n for (let i = 0; i < urlPath.length; i++) {\n text(urlPath[i], 10, i * 20 + 20);\n }\n}\n
Gets the current URL params as an Object.
\n",itemtype:"method",name:"getURLParams",return:{description:"URL params",type:"Object"},example:["\n\n// Example: http://p5js.org?year=2014&month=May&day=15\n\nfunction setup() {\n let params = getURLParams();\n text(params.day, 10, 20);\n text(params.month, 10, 40);\n text(params.year, 10, 60);\n}\n
\nValidates parameters\nparam {String} func the name of the function\nparam {Array} args user input arguments
\nexample:\n const a;\n ellipse(10,10,a,5);\nconsole ouput:\n "It looks like ellipse received an empty variable in spot #2."
\nexample:\n ellipse(10,"foo",5,5);\nconsole output:\n "ellipse was expecting a number for parameter #1,\n received "foo" instead."
\n",class:"p5",module:"Environment"},{file:"src/core/error_helpers.js",line:691,description:"Prints out all the colors in the color pallete with white text.\nFor color blindness testing.
\n",class:"p5",module:"Environment"},{file:"src/core/helpers.js",line:1,requires:["constants"],class:"p5",module:"Environment"},{file:"src/core/internationalization.js",line:22,description:"Set up our translation function, with loaded languages
\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:'Called directly before setup(), the preload() function is used to handle\nasynchronous loading of external files in a blocking way. If a preload\nfunction is defined, setup() will wait until any load calls within have\nfinished. Nothing besides load calls (loadImage, loadJSON, loadFont,\nloadStrings, etc.) should be inside the preload function. If asynchronous\nloading is preferred, the load methods can instead be called in setup()\nor anywhere else with the use of a callback parameter.\n
\nBy default the text "loading..." will be displayed. To make your own\nloading page, include an HTML element with id "p5_loading" in your\npage. More information here.
\nlet img;\nlet c;\nfunction preload() {\n // preload() runs once\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n // setup() waits until preload() is done\n img.loadPixels();\n // get color of middle pixel\n c = img.get(img.width / 2, img.height / 2);\n}\n\nfunction draw() {\n background(c);\n image(img, 25, 25, 50, 50);\n}\n
The setup() function is called once when the program starts. It's used to\ndefine initial environment properties such as screen size and background\ncolor and to load media such as images and fonts as the program starts.\nThere can only be one setup() function for each program and it shouldn't\nbe called again after its initial execution.\n
\nNote: Variables declared within setup() are not accessible within other\nfunctions, including draw().
\nlet a = 0;\n\nfunction setup() {\n background(0);\n noStroke();\n fill(102);\n}\n\nfunction draw() {\n rect(a++ % width, 10, 2, 80);\n}\n
Called directly after setup(), the draw() function continuously executes\nthe lines of code contained inside its block until the program is stopped\nor noLoop() is called. Note if noLoop() is called in setup(), draw() will\nstill be executed once before stopping. draw() is called automatically and\nshould never be called explicitly.\n
\nIt should always be controlled with noLoop(), redraw() and loop(). After\nnoLoop() stops the code in draw() from executing, redraw() causes the\ncode inside draw() to execute once, and loop() will cause the code\ninside draw() to resume executing continuously.\n
\nThe number of times draw() executes in each second may be controlled with\nthe frameRate() function.\n
\nThere can only be one draw() function for each sketch, and draw() must\nexist if you want the code to run continuously, or to process events such\nas mousePressed(). Sometimes, you might have an empty call to draw() in\nyour program, as shown in the above example.\n
\nIt is important to note that the drawing coordinate system will be reset\nat the beginning of each draw() call. If any transformations are performed\nwithin draw() (ex: scale, rotate, translate), their effects will be\nundone at the beginning of draw(), so transformations will not accumulate\nover time. On the other hand, styling applied (ex: fill, stroke, etc) will\nremain in effect.
\nlet yPos = 0;\nfunction setup() {\n // setup() runs once\n frameRate(30);\n}\nfunction draw() {\n // draw() loops forever, until stopped\n background(204);\n yPos = yPos - 1;\n if (yPos < 0) {\n yPos = height;\n }\n line(0, yPos, width, yPos);\n}\n
Removes the entire p5 sketch. This will remove the canvas and any\nelements created by p5.js. It will also stop the draw loop and unbind\nany properties or methods from the window global scope. It will\nleave a variable p5 in case you wanted to create a new p5 sketch.\nIf you like, you can set p5 = null to erase it. While all functions and\nvariables and objects created by the p5 library will be removed, any\nother global variables created by your code will remain.
\n",itemtype:"method",name:"remove",example:["\n\nfunction draw() {\n ellipse(50, 50, 10, 10);\n}\n\nfunction mousePressed() {\n remove(); // remove whole sketch on mouse press\n}\n
Allows for the friendly error system (FES) to be turned off when creating a sketch,\nwhich can give a significant boost to performance when needed.\nSee \ndisabling the friendly error system.
\n",itemtype:"property",name:"disableFriendlyErrors",type:"Boolean",example:['\n\np5.disableFriendlyErrors = true;\n\nfunction setup() {\n createCanvas(100, 50);\n}\n
Underlying HTML element. All normal HTML methods can be called on this.
\n",example:["\n\nfunction setup() {\n let c = createCanvas(50, 50);\n c.elt.style.border = '5px solid red';\n}\n\nfunction draw() {\n background(220);\n}\n
\nAttaches the element to the parent specified. A way of setting\n the container for the element. Accepts either a string ID, DOM\n node, or p5.Element. If no arguments given, parent node is returned.\n For more ways to position the canvas, see the\n \n positioning the canvas wiki page.
\n",itemtype:"method",name:"parent",chainable:1,example:["\n\n // in the html file:\n // <div id=\"myContainer\"></div>\n// in the js file:\n let cnv = createCanvas(100, 100);\n cnv.parent('myContainer');\n
\n let div0 = createDiv('this is the parent');\n let div1 = createDiv('this is the child');\n div1.parent(div0); // use p5.Element\n
\n let div0 = createDiv('this is the parent');\n div0.id('apples');\n let div1 = createDiv('this is the child');\n div1.parent('apples'); // use id\n
\n let elt = document.getElementById('myParentDiv');\n let div1 = createDiv('this is the child');\n div1.parent(elt); // use element from page\n
the ID, DOM node, or p5.Element\n of desired parent element
\n',type:"String|p5.Element|Object"}],chainable:1},{line:90,params:[],return:{description:"",type:"p5.Element"}}]},{file:"src/core/p5.Element.js",line:112,description:'Sets the ID of the element. If no ID argument is passed in, it instead\n returns the current ID of the element.\n Note that only one element can have a particular id in a page.\n The .class() function can be used\n to identify multiple elements with the same class name.
\n',itemtype:"method",name:"id",chainable:1,example:["\n\n function setup() {\n let cnv = createCanvas(100, 100);\n // Assigns a CSS selector ID to\n // the canvas element.\n cnv.id('mycanvas');\n }\n
ID of the element
\n",type:"String"}],chainable:1},{line:137,params:[],return:{description:"the id of the element",type:"String"}}]},{file:"src/core/p5.Element.js",line:152,description:"Adds given class to the element. If no class argument is passed in, it\n instead returns a string containing the current class(es) of the element.
\n",itemtype:"method",name:"class",chainable:1,example:["\n\n function setup() {\n let cnv = createCanvas(100, 100);\n // Assigns a CSS selector class 'small'\n // to the canvas element.\n cnv.class('small');\n }\n
class to add
\n",type:"String"}],chainable:1},{line:174,params:[],return:{description:"the class of the element",type:"String"}}]},{file:"src/core/p5.Element.js",line:187,description:'The .mousePressed() function is called once after every time a\nmouse button is pressed over the element.\nSome mobile browsers may also trigger this event on a touch screen,\nif the user performs a quick tap.\nThis can be used to attach element specific event listeners.
\n',itemtype:"method",name:"mousePressed",params:[{name:"fxn",description:"function to be fired when mouse is\n pressed over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mousePressed(changeGray); // attach listener for\n // canvas click only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires with any click anywhere\nfunction mousePressed() {\n d = d + 10;\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
The .doubleClicked() function is called once after every time a\nmouse button is pressed twice over the element. This can be used to\nattach element and action specific event listeners.
\n',itemtype:"method",name:"doubleClicked",params:[{name:"fxn",description:"function to be fired when mouse is\n double clicked over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.doubleClicked(changeGray); // attach listener for\n // canvas double click only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires with any double click anywhere\nfunction doubleClicked() {\n d = d + 10;\n}\n\n// this function fires only when cnv is double clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
The .mouseWheel() function is called once after every time a\nmouse wheel is scrolled over the element. This can be used to\nattach element specific event listeners.\n
\nThe function accepts a callback function as argument which will be executed\nwhen the wheel
event is triggered on the element, the callback function is\npassed one argument event
. The event.deltaY
property returns negative\nvalues if the mouse wheel is rotated up or away from the user and positive\nin the other direction. The event.deltaX
does the same as event.deltaY
\nexcept it reads the horizontal wheel scroll of the mouse wheel.\n
\nOn OS X with "natural" scrolling enabled, the event.deltaY
values are\nreversed.
function to be fired when mouse is\n scrolled over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseWheel(changeSize); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires with mousewheel movement\n// anywhere on screen\nfunction mouseWheel() {\n g = g + 10;\n}\n\n// this function fires with mousewheel movement\n// over canvas only\nfunction changeSize(event) {\n if (event.deltaY > 0) {\n d = d + 10;\n } else {\n d = d - 10;\n }\n}\n
The .mouseReleased() function is called once after every time a\nmouse button is released over the element.\nSome mobile browsers may also trigger this event on a touch screen,\nif the user performs a quick tap.\nThis can be used to attach element specific event listeners.
\n',itemtype:"method",name:"mouseReleased",params:[{name:"fxn",description:"function to be fired when mouse is\n released over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseReleased(changeGray); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires after the mouse has been\n// released\nfunction mouseReleased() {\n d = d + 10;\n}\n\n// this function fires after the mouse has been\n// released while on canvas\nfunction changeGray() {\n g = random(0, 255);\n}\n
The .mouseClicked() function is called once after a mouse button is\npressed and released over the element.\nSome mobile browsers may also trigger this event on a touch screen,\nif the user performs a quick tap.\nThis can be used to attach element specific event listeners.
\n',itemtype:"method",name:"mouseClicked",params:[{name:"fxn",description:"function to be fired when mouse is\n clicked over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nlet g;\n\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseClicked(changeGray); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires after the mouse has been\n// clicked anywhere\nfunction mouseClicked() {\n d = d + 10;\n}\n\n// this function fires after the mouse has been\n// clicked on canvas\nfunction changeGray() {\n g = random(0, 255);\n}\n
\nThe .mouseMoved() function is called once every time a\nmouse moves over the element. This can be used to attach an\nelement specific event listener.
\n',itemtype:"method",name:"mouseMoved",params:[{name:"fxn",description:"function to be fired when a mouse moves\n over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d = 30;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseMoved(changeSize); // attach listener for\n // activity on canvas only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n fill(200);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires when mouse moves anywhere on\n// page\nfunction mouseMoved() {\n g = g + 5;\n if (g > 255) {\n g = 0;\n }\n}\n\n// this function fires when mouse moves over canvas\nfunction changeSize() {\n d = d + 2;\n if (d > 100) {\n d = 0;\n }\n}\n
The .mouseOver() function is called once after every time a\nmouse moves onto the element. This can be used to attach an\nelement specific event listener.
\n',itemtype:"method",name:"mouseOver",params:[{name:"fxn",description:"function to be fired when a mouse moves\n onto the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseOver(changeGray);\n d = 10;\n}\n\nfunction draw() {\n ellipse(width / 2, height / 2, d, d);\n}\n\nfunction changeGray() {\n d = d + 10;\n if (d > 100) {\n d = 0;\n }\n}\n
The .mouseOut() function is called once after every time a\nmouse moves off the element. This can be used to attach an\nelement specific event listener.
\n',itemtype:"method",name:"mouseOut",params:[{name:"fxn",description:"function to be fired when a mouse\n moves off of an element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mouseOut(changeGray);\n d = 10;\n}\n\nfunction draw() {\n ellipse(width / 2, height / 2, d, d);\n}\n\nfunction changeGray() {\n d = d + 10;\n if (d > 100) {\n d = 0;\n }\n}\n
The .touchStarted() function is called once after every time a touch is\nregistered. This can be used to attach element specific event listeners.
\n',itemtype:"method",name:"touchStarted",params:[{name:"fxn",description:"function to be fired when a touch\n starts over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.touchStarted(changeGray); // attach listener for\n // canvas click only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires with any touch anywhere\nfunction touchStarted() {\n d = d + 10;\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
The .touchMoved() function is called once after every time a touch move is\nregistered. This can be used to attach element specific event listeners.
\n',itemtype:"method",name:"touchMoved",params:[{name:"fxn",description:"function to be fired when a touch moves over\n the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.touchMoved(changeGray); // attach listener for\n // canvas click only\n g = 100;\n}\n\nfunction draw() {\n background(g);\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
The .touchEnded() function is called once after every time a touch is\nregistered. This can be used to attach element specific event listeners.
\n',itemtype:"method",name:"touchEnded",params:[{name:"fxn",description:"function to be fired when a touch ends\n over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet cnv;\nlet d;\nlet g;\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.touchEnded(changeGray); // attach listener for\n // canvas click only\n d = 10;\n g = 100;\n}\n\nfunction draw() {\n background(g);\n ellipse(width / 2, height / 2, d, d);\n}\n\n// this function fires with any touch anywhere\nfunction touchEnded() {\n d = d + 10;\n}\n\n// this function fires only when cnv is clicked\nfunction changeGray() {\n g = random(0, 255);\n}\n
The .dragOver() function is called once after every time a\nfile is dragged over the element. This can be used to attach an\nelement specific event listener.
\n',itemtype:"method",name:"dragOver",params:[{name:"fxn",description:"function to be fired when a file is\n dragged over the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\n// To test this sketch, simply drag a\n// file over the canvas\nfunction setup() {\n let c = createCanvas(100, 100);\n background(200);\n textAlign(CENTER);\n text('Drag file', width / 2, height / 2);\n c.dragOver(dragOverCallback);\n}\n\n// This function will be called whenever\n// a file is dragged over the canvas\nfunction dragOverCallback() {\n background(240);\n text('Dragged over', width / 2, height / 2);\n}\n
The .dragLeave() function is called once after every time a\ndragged file leaves the element area. This can be used to attach an\nelement specific event listener.
\n",itemtype:"method",name:"dragLeave",params:[{name:"fxn",description:"function to be fired when a file is\n dragged off the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\n// To test this sketch, simply drag a file\n// over and then out of the canvas area\nfunction setup() {\n let c = createCanvas(100, 100);\n background(200);\n textAlign(CENTER);\n text('Drag file', width / 2, height / 2);\n c.dragLeave(dragLeaveCallback);\n}\n\n// This function will be called whenever\n// a file is dragged out of the canvas\nfunction dragLeaveCallback() {\n background(240);\n text('Dragged off', width / 2, height / 2);\n}\n
Helper fxn for sharing pixel methods
\n",class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/core/p5.Graphics.js",line:64,description:"Resets certain values such as those modified by functions in the Transform category\nand in the Lights category that are not automatically reset\nwith graphics buffer objects. Calling this in draw() will copy the behavior\nof the standard canvas.
\n",itemtype:"method",name:"reset",example:["\n\n\nlet pg;\nfunction setup() {\n createCanvas(100, 100);\n background(0);\n pg = createGraphics(50, 100);\n pg.fill(0);\n frameRate(5);\n}\nfunction draw() {\n image(pg, width / 2, 0);\n pg.background(255);\n // p5.Graphics object behave a bit differently in some cases\n // The normal canvas on the left resets the translate\n // with every loop through draw()\n // the graphics object on the right doesn't automatically reset\n // so translate() is additive and it moves down the screen\n rect(0, 0, width / 2, 5);\n pg.rect(0, 0, width / 2, 5);\n translate(0, 5, 0);\n pg.translate(0, 5, 0);\n}\nfunction mouseClicked() {\n // if you click you will see that\n // reset() resets the translate back to the initial state\n // of the Graphics object\n pg.reset();\n}\n
Removes a Graphics object from the page and frees any resources\nassociated with it.
\n",itemtype:"method",name:"remove",example:["\n\nlet bg;\nfunction setup() {\n bg = createCanvas(100, 100);\n bg.background(0);\n image(bg, 0, 0);\n bg.remove();\n}\n
\nlet bg;\nfunction setup() {\n pixelDensity(1);\n createCanvas(100, 100);\n stroke(255);\n fill(0);\n\n // create and draw the background image\n bg = createGraphics(100, 100);\n bg.background(200);\n bg.ellipse(50, 50, 80, 80);\n}\nfunction draw() {\n let t = millis() / 1000;\n // draw the background\n if (bg) {\n image(bg, frameCount % 100, 0);\n image(bg, frameCount % 100 - 100, 0);\n }\n // draw the foreground\n let p = p5.Vector.fromAngle(t, 35).add(50, 50);\n ellipse(p.x, p.y, 30);\n}\nfunction mouseClicked() {\n // remove the background\n if (bg) {\n bg.remove();\n bg = null;\n }\n}\n
Resize our canvas element.
\n",class:"p5.Renderer",module:"Rendering",submodule:"Rendering"},{file:"src/core/p5.Renderer.js",line:334,description:"Helper fxn to check font type (system or otf)
\n",class:"p5.Renderer",module:"Rendering",submodule:"Rendering"},{file:"src/core/p5.Renderer.js",line:386,description:'Helper fxn to measure ascent and descent.\nAdapted from http://stackoverflow.com/a/25355178
\n',class:"p5.Renderer",module:"Rendering",submodule:"Rendering"},{file:"src/core/p5.Renderer2D.js",line:7,description:"p5.Renderer2D\nThe 2D graphics canvas renderer class.\nextends p5.Renderer
\n",class:"p5",module:"Rendering"},{file:"src/core/p5.Renderer2D.js",line:385,description:'Generate a cubic Bezier representing an arc on the unit circle of total\nangle size
radians, beginning start
radians above the x-axis. Up to\nfour of these curves are combined to make a full arc.
See www.joecridge.me/bezier.pdf for an explanation of the method.
\n',class:"p5",module:"Rendering"},{file:"src/core/reference.js",line:6,description:'Creates and names a new variable. A variable is a container for a value.
\nVariables that are declared with let will have block-scope.\nThis means that the variable only exists within the \nblock that it is created within.
\nFrom the MDN entry:\nDeclares a block scope local variable, optionally initializing it to a value.
\n',itemtype:"property",name:"let",example:["\n\nlet x = 2;\nconsole.log(x); // prints 2 to the console\nx = 1;\nconsole.log(x); // prints 1 to the console\n
\nCreates and names a new constant. Like a variable created with let, a constant\nthat is created with const is a container for a value,\nhowever constants cannot be changed once they are declared.
\nConstants have block-scope. This means that the constant only exists within\nthe \nblock that it is created within. A constant cannot be redeclared within a scope in which it\nalready exists.
\nFrom the MDN entry:\nDeclares a read-only named constant.\nConstants are block-scoped, much like variables defined using the 'let' statement.\nThe value of a constant can't be changed through reassignment, and it can't be redeclared.
\n',itemtype:"property",name:"const",example:["\n\n// define myFavNumber as a constant and give it the value 7\nconst myFavNumber = 7;\nconsole.log('my favorite number is: ' + myFavNumber);\n
\n\nconst bigCats = ['lion', 'tiger', 'panther'];\nbigCats.push('leopard');\nconsole.log(bigCats);\n// bigCats = ['cat']; // throws error as re-assigning not allowed for const\n
\n\nconst wordFrequency = {};\nwordFrequency['hello'] = 2;\nwordFrequency['bye'] = 1;\nconsole.log(wordFrequency);\n// wordFrequency = { 'a': 2, 'b': 3}; // throws error here\n
\nThe strict equality operator ===\nchecks to see if two values are equal and of the same type.
\nA comparison expression always evaluates to a boolean.
\nFrom the MDN entry:\nThe non-identity operator returns true if the operands are not equal and/or not of the same type.
\nNote: In some examples around the web you may see a double-equals-sign\n==,\nused for comparison instead. This is the non-strict equality operator in Javascript.\nThis will convert the two values being compared to the same type before comparing them.
\n',itemtype:"property",name:"===",example:["\n\nconsole.log(1 === 1); // prints true to the console\nconsole.log(1 === '1'); // prints false to the console\n
\nThe greater than operator >\nevaluates to true if the left value is greater than\nthe right value.
\nThere is more info on comparison operators on MDN.
\n',itemtype:"property",name:">",example:["\n\nconsole.log(100 > 1); // prints true to the console\nconsole.log(1 > 100); // prints false to the console\n
\nThe greater than or equal to operator >=\nevaluates to true if the left value is greater than or equal to\nthe right value.
\nThere is more info on comparison operators on MDN.
\n',itemtype:"property",name:">=",example:["\n\nconsole.log(100 >= 100); // prints true to the console\nconsole.log(101 >= 100); // prints true to the console\n
\nThe less than operator <\nevaluates to true if the left value is less than\nthe right value.
\nThere is more info on comparison operators on MDN.
\n',itemtype:"property",name:"<",example:["\n\nconsole.log(1 < 100); // prints true to the console\nconsole.log(100 < 99); // prints false to the console\n
\nThe less than or equal to operator <=\nevaluates to true if the left value is less than or equal to\nthe right value.
\nThere is more info on comparison operators on MDN.
\n',itemtype:"property",name:"<=",example:["\n\nconsole.log(100 <= 100); // prints true to the console\nconsole.log(99 <= 100); // prints true to the console\n
\nThe if-else statement helps control the flow of your code.
\nA condition is placed between the parenthesis following 'if',\nwhen that condition evalues to truthy,\nthe code between the following curly braces is run.\nAlternatively, when the condition evaluates to falsy,\nthe code between the curly braces that follow 'else' is run instead.
\nFrom the MDN entry:\nThe 'if' statement executes a statement if a specified condition is truthy.\nIf the condition is falsy, another statement can be executed
\n',itemtype:"property",name:"if-else",example:["\n\nlet a = 4;\nif (a > 0) {\n console.log('positive');\n} else {\n console.log('negative');\n}\n
\nCreates and names a function.\nA function is a set of statements that perform a task.
\nOptionally, functions can have parameters. Parameters\nare variables that are scoped to the function, that can be assigned a value when calling the function.
\nFrom the MDN entry:\nDeclares a function with the specified parameters.
\n',itemtype:"property",name:"function",example:["\n\nlet myName = 'Hridi';\nfunction sayHello(name) {\n console.log('Hello ' + name + '!');\n}\nsayHello(myName); // calling the function, prints \"Hello Hridi!\" to console.\n
\n\nlet square = number => number * number;\nconsole.log(square(5));\n
\nSpecifies the value to be returned by a function.\nFor more info checkout \nthe MDN entry for return.
\n',itemtype:"property",name:"return",example:["\n\nfunction calculateSquare(x) {\n return x * x;\n}\ncalculateSquare(4); // returns 16\n
\nA boolean is one of the 7 primitive data types in Javascript.\nA boolean can only be true
or false
.
From the MDN entry:\nBoolean represents a logical entity and can have two values: true, and false.
\n',itemtype:"property",name:"boolean",example:["\n\nlet myBoolean = false;\nconsole.log(typeof myBoolean); // prints 'boolean' to the console\n
\nA string is one of the 7 primitive data types in Javascript.\nA string is a series of text characters. In Javascript, a string value must be surrounded by either single-quotation marks(') or double-quotation marks(").
\nFrom the MDN entry:\nA string is a sequence of characters used to represent text.
\n',itemtype:"property",name:"string",example:["\n\nlet mood = 'chill';\nconsole.log(typeof mood); // prints 'string' to the console\n
\nA number is one of the 7 primitive data types in Javascript.\nA number can be a whole number or a decimal number.
\n\n',itemtype:"property",name:"number",example:["\n\nlet num = 46.5;\nconsole.log(typeof num); // prints 'number' to the console\n
\nFrom MDN's object basics:\n An object is a collection of related data and/or functionality (which usually consists of several variables and functions —\n which are called properties and methods when they are inside objects.)
\n',itemtype:"property",name:"object",example:["\n\n let author = {\n name: 'Ursula K Le Guin',\n books: [\n 'The Left Hand of Darkness',\n 'The Dispossessed',\n 'A Wizard of Earthsea'\n ]\n };\n console.log(author.name); // prints 'Ursula K Le Guin' to the console\n
\n Creates and names a class which is a template for the creation of objects.
\nFrom the MDN entry:\nThe class declaration creates a new Class with a given name using prototype-based inheritance.
\n',itemtype:"property",name:"class",example:["\n\nclass Rectangle {\n constructor(name, height, width) {\n this.name = name;\n this.height = height;\n this.width = width;\n }\n}\nlet square = new Rectangle('square', 1, 1); // creating new instance of Polygon Class.\nconsole.log(square.width); // prints '1' to the console\n
\nfor creates a loop that is useful for executing one section of code multiple times.
\nA 'for loop' consists of three different expressions inside of a parenthesis, all of which are optional.\nThese expressions are used to control the number of times the loop is run.\nThe first expression is a statement that is used to set the initial state for the loop.\nThe second expression is a condition that you would like to check before each loop. If this expression returns\nfalse then the loop will exit.\nThe third expression is executed at the end of each loop.
\nThe code inside of the loop body (in between the curly braces) is executed between the evaluation of the second\nand third expression.
\nAs with any loop, it is important to ensure that the loop can 'exit', or that\nthe test condition will eventually evaluate to false. The test condition with a for loop\nis the second expression detailed above. Ensuring that this expression can eventually\nbecome false ensures that your loop doesn't attempt to run an infinite amount of times,\nwhich can crash your browser.
\nFrom the MDN entry:\nCreates a loop that executes a specified statement until the test condition evaluates to false.\nThe condition is evaluated after executing the statement, resulting in the specified statement executing at least once.
\n',itemtype:"property",name:"for",example:["\n\nfor (let i = 0; i < 9; i++) {\n console.log(i);\n}\n
\nwhile creates a loop that is useful for executing one section of code multiple times.
\nWith a 'while loop', the code inside of the loop body (between the curly braces) is run repeatedly until the test condition\n(inside of the parenthesis) evaluates to false. Unlike a for loop, the condition is tested before executing the code body with while,\nso if the condition is initially false the loop body, or statement, will never execute.
\nAs with any loop, it is important to ensure that the loop can 'exit', or that\nthe test condition will eventually evaluate to false. This is to keep your loop from trying to run an infinite amount of times,\nwhich can crash your browser.
\nFrom the MDN entry:\nThe while statement creates a loop that executes a specified statement as long as the test condition evaluates to true.\nThe condition is evaluated before executing the statement.
\n',itemtype:"property",name:"while",example:["\n\n// This example logs the lines below to the console\n// 4\n// 3\n// 2\n// 1\n// 0\nlet num = 5;\nwhile (num > 0) {\n num = num - 1;\n console.log(num);\n}\n
\nFrom the MDN entry:\nThe JSON.stringify() method converts a JavaScript object or value to a JSON string.
\n',itemtype:"method",name:"stringify",static:1,params:[{name:"object",description:":Javascript object that you would like to convert to JSON
\n",type:"Object"}],example:['\n\nlet myObject = { x: 5, y: 6 };\nlet myObjectAsString = JSON.stringify(myObject);\nconsole.log(myObjectAsString); // prints "{"x":5,"y":6}" to the console\nconsole.log(typeof myObjectAsString); // prints \'string\' to the console\n
\nPrints a message to your browser's web console. When using p5, you can use print\nand console.log interchangeably.
\nThe console is opened differently depending on which browser you are using.\nHere are links on how to open the console in Firefox\n, Chrome, Edge,\nand Safari. With the online p5 editor the\nconsole is embedded directly in the page underneath the code editor.
\nFrom the MDN entry:\nThe Console method log() outputs a message to the web console. The message may be a single string (with optional substitution values),\nor it may be any one or more JavaScript objects.
\n',itemtype:"method",name:"log",static:1,params:[{name:"message",description:":Message that you would like to print to the console
\n",type:"String|Expression|Object"}],example:["\n\nlet myNum = 5;\nconsole.log(myNum); // prints 5 to the console\nconsole.log(myNum + 12); // prints 17 to the console\n
\nCreates a canvas element in the document, and sets the dimensions of it\nin pixels. This method should be called only once at the start of setup.\nCalling createCanvas more than once in a sketch will result in very\nunpredictable behavior. If you want more than one drawing canvas\nyou could use createGraphics (hidden by default but it can be shown).\n
\nThe system variables width and height are set by the parameters passed\nto this function. If createCanvas() is not used, the window will be\ngiven a default size of 100x100 pixels.\n
\nFor more ways to position the canvas, see the\n\npositioning the canvas wiki page.
width of the canvas
\n",type:"Number"},{name:"h",description:"height of the canvas
\n",type:"Number"},{name:"renderer",description:"either P2D or WEBGL
\n",type:"Constant",optional:!0}],return:{description:"",type:"p5.Renderer"},example:["\n\nfunction setup() {\n createCanvas(100, 50);\n background(153);\n line(0, 0, width, height);\n}\n
\nResizes the canvas to given width and height. The canvas will be cleared\nand draw will be called immediately, allowing the sketch to re-render itself\nin the resized canvas.
\n",itemtype:"method",name:"resizeCanvas",params:[{name:"w",description:"width of the canvas
\n",type:"Number"},{name:"h",description:"height of the canvas
\n",type:"Number"},{name:"noRedraw",description:"don't redraw the canvas immediately
\n",type:"Boolean",optional:!0}],example:['\n\nfunction setup() {\n createCanvas(windowWidth, windowHeight);\n}\n\nfunction draw() {\n background(0, 100, 200);\n}\n\nfunction windowResized() {\n resizeCanvas(windowWidth, windowHeight);\n}\n
Removes the default canvas for a p5 sketch that doesn't\nrequire a canvas
\n",itemtype:"method",name:"noCanvas",example:["\n\nfunction setup() {\n noCanvas();\n}\n
\nCreates and returns a new p5.Renderer object. Use this class if you need\nto draw into an off-screen graphics buffer. The two parameters define the\nwidth and height in pixels.
\n",itemtype:"method",name:"createGraphics",params:[{name:"w",description:"width of the offscreen graphics buffer
\n",type:"Number"},{name:"h",description:"height of the offscreen graphics buffer
\n",type:"Number"},{name:"renderer",description:"either P2D or WEBGL\nundefined defaults to p2d
\n",type:"Constant",optional:!0}],return:{description:"offscreen graphics buffer",type:"p5.Graphics"},example:["\n\nlet pg;\nfunction setup() {\n createCanvas(100, 100);\n pg = createGraphics(100, 100);\n}\nfunction draw() {\n background(200);\n pg.background(100);\n pg.noStroke();\n pg.ellipse(pg.width / 2, pg.height / 2, 50, 50);\n image(pg, 50, 50);\n image(pg, 0, 0, 50, 50);\n}\n
\nBlends the pixels in the display window according to the defined mode.\nThere is a choice of the following modes to blend the source pixels (A)\nwith the ones of pixels already in the display window (B):
\nBLEND
- linear interpolation of colours: C =\nA\\*factor + B. This is the default blending mode.ADD
- sum of A and BDARKEST
- only the darkest colour succeeds: C =\nmin(A\\*factor, B).LIGHTEST
- only the lightest colour succeeds: C =\nmax(A\\*factor, B).DIFFERENCE
- subtract colors from underlying image.EXCLUSION
- similar to DIFFERENCE
, but less\nextreme.MULTIPLY
- multiply the colors, result will always be\ndarker.SCREEN
- opposite multiply, uses inverse values of the\ncolors.REPLACE
- the pixels entirely replace the others and\ndon't utilize alpha (transparency) values.REMOVE
- removes pixels from B with the alpha strength of A.OVERLAY
- mix of MULTIPLY
and SCREEN\n
. Multiplies dark values, and screens light values. (2D)HARD_LIGHT
- SCREEN
when greater than 50%\ngray, MULTIPLY
when lower. (2D)SOFT_LIGHT
- mix of DARKEST
and\nLIGHTEST
. Works like OVERLAY
, but not as harsh. (2D)\nDODGE
- lightens light tones and increases contrast,\nignores darks. (2D)BURN
- darker areas are applied, increasing contrast,\nignores lights. (2D)SUBTRACT
- remainder of A and B (3D)blend mode to set for canvas.\n either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY,\n EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT
\n",type:"Constant"}],example:["\n\nblendMode(LIGHTEST);\nstrokeWeight(30);\nstroke(80, 150, 255);\nline(25, 25, 75, 75);\nstroke(255, 50, 50);\nline(75, 25, 25, 75);\n
\n\nblendMode(MULTIPLY);\nstrokeWeight(30);\nstroke(80, 150, 255);\nline(25, 25, 75, 75);\nstroke(255, 50, 50);\nline(75, 25, 25, 75);\n
\n\nfunction setup() {\n drawingContext.shadowOffsetX = 5;\n drawingContext.shadowOffsetY = -5;\n drawingContext.shadowBlur = 10;\n drawingContext.shadowColor = 'black';\n background(200);\n ellipse(width / 2, height / 2, 50, 50);\n}\n
shim for Uint8ClampedArray.slice\n(allows arrayCopy to work with pixels[])\nwith thanks to http://halfpapstudios.com/blog/tag/html5-canvas/\nEnumerable set to false to protect for...in from\nUint8ClampedArray.prototype pollution.
\n',class:"p5",module:"Rendering"},{file:"src/core/shim.js",line:39,description:'this is implementation of Object.assign() which is unavailable in\nIE11 and (non-Chrome) Android browsers.\nThe assign() method is used to copy the values of all enumerable\nown properties from one or more source objects to a target object.\nIt will return the target object.\nModified from https://github.com/ljharb/object.assign
\n',class:"p5",module:"Rendering"},{file:"src/core/structure.js",line:10,description:'Stops p5.js from continuously executing the code within draw().\nIf loop() is called, the code in draw() begins to run continuously again.\nIf using noLoop() in setup(), it should be the last line inside the block.\n
\nWhen noLoop() is used, it's not possible to manipulate or access the\nscreen inside event handling functions such as mousePressed() or\nkeyPressed(). Instead, use those functions to call redraw() or loop(),\nwhich will run draw(), which can update the screen properly. This means\nthat when noLoop() has been called, no drawing can happen, and functions\nlike saveFrame() or loadPixels() may not be used.\n
\nNote that if the sketch is resized, redraw() will be called to update\nthe sketch, even after noLoop() has been specified. Otherwise, the sketch\nwould enter an odd state until loop() was called.
\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n noLoop();\n}\n\nfunction draw() {\n line(10, 10, 90, 90);\n}\n
\nlet x = 0;\nfunction setup() {\n createCanvas(100, 100);\n}\n\nfunction draw() {\n background(204);\n x = x + 0.1;\n if (x > width) {\n x = 0;\n }\n line(x, 0, x, height);\n}\n\nfunction mousePressed() {\n noLoop();\n}\n\nfunction mouseReleased() {\n loop();\n}\n
By default, p5.js loops through draw() continuously, executing the code\nwithin it. However, the draw() loop may be stopped by calling noLoop().\nIn that case, the draw() loop can be resumed with loop().
\nAvoid calling loop() from inside setup().
\n',itemtype:"method",name:"loop",example:["\n\nlet x = 0;\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n}\n\nfunction draw() {\n background(204);\n x = x + 0.1;\n if (x > width) {\n x = 0;\n }\n line(x, 0, x, height);\n}\n\nfunction mousePressed() {\n loop();\n}\n\nfunction mouseReleased() {\n noLoop();\n}\n
The push() function saves the current drawing style settings and\ntransformations, while pop() restores these settings. Note that these\nfunctions are always used together. They allow you to change the style\nand transformation settings and later return to what you had. When a new\nstate is started with push(), it builds on the current style and transform\ninformation. The push() and pop() functions can be embedded to provide\nmore control. (See the second example for a demonstration.)\n
\npush() stores information related to the current transformation state\nand style settings controlled by the following functions:\nfill(),\nnoFill(),\nnoStroke(),\nstroke(),\ntint(),\nnoTint(),\nstrokeWeight(),\nstrokeCap(),\nstrokeJoin(),\nimageMode(),\nrectMode(),\nellipseMode(),\ncolorMode(),\ntextAlign(),\ntextFont(),\ntextSize(),\ntextLeading(),\napplyMatrix(),\nresetMatrix(),\nrotate(),\nscale(),\nshearX(),\nshearY(),\ntranslate(),\nnoiseSeed().\n
\nIn WEBGL mode additional style settings are stored. These are controlled by the following functions: setCamera(), ambientLight(), directionalLight(),\npointLight(), texture(), specularMaterial(), shininess(), normalMaterial()\nand shader().
\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\nstrokeWeight(10);\nfill(204, 153, 0);\ntranslate(50, 0);\nellipse(0, 50, 33, 33); // Middle circle\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\n\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\nstrokeWeight(10);\nfill(204, 153, 0);\nellipse(33, 50, 33, 33); // Left-middle circle\n\npush(); // Start another new drawing state\nstroke(0, 102, 153);\nellipse(66, 50, 33, 33); // Right-middle circle\npop(); // Restore previous state\n\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\nThe push() function saves the current drawing style settings and\ntransformations, while pop() restores these settings. Note that these\nfunctions are always used together. They allow you to change the style\nand transformation settings and later return to what you had. When a new\nstate is started with push(), it builds on the current style and transform\ninformation. The push() and pop() functions can be embedded to provide\nmore control. (See the second example for a demonstration.)\n
\npush() stores information related to the current transformation state\nand style settings controlled by the following functions:\nfill(),\nnoFill(),\nnoStroke(),\nstroke(),\ntint(),\nnoTint(),\nstrokeWeight(),\nstrokeCap(),\nstrokeJoin(),\nimageMode(),\nrectMode(),\nellipseMode(),\ncolorMode(),\ntextAlign(),\ntextFont(),\ntextSize(),\ntextLeading(),\napplyMatrix(),\nresetMatrix(),\nrotate(),\nscale(),\nshearX(),\nshearY(),\ntranslate(),\nnoiseSeed().\n
\nIn WEBGL mode additional style settings are stored. These are controlled by the following functions: setCamera(), ambientLight(), directionalLight(),\npointLight(), texture(), specularMaterial(), shininess(), normalMaterial()\nand shader().
\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\ntranslate(50, 0);\nstrokeWeight(10);\nfill(204, 153, 0);\nellipse(0, 50, 33, 33); // Middle circle\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\n\nellipse(0, 50, 33, 33); // Left circle\n\npush(); // Start a new drawing state\nstrokeWeight(10);\nfill(204, 153, 0);\nellipse(33, 50, 33, 33); // Left-middle circle\n\npush(); // Start another new drawing state\nstroke(0, 102, 153);\nellipse(66, 50, 33, 33); // Right-middle circle\npop(); // Restore previous state\n\npop(); // Restore original state\n\nellipse(100, 50, 33, 33); // Right circle\n
\nExecutes the code within draw() one time. This functions allows the\n program to update the display window only when necessary, for example\n when an event registered by mousePressed() or keyPressed() occurs.\n
\n In structuring a program, it only makes sense to call redraw() within\n events such as mousePressed(). This is because redraw() does not run\n draw() immediately (it only sets a flag that indicates an update is\n needed).\n
\n The redraw() function does not work properly when called inside draw().\n To enable/disable animations, use loop() and noLoop().\n
\n In addition you can set the number of redraws per method call. Just\n add an integer as single parameter for the number of redraws.
Redraw for n-times. The default value is 1.
\n",type:"Integer",optional:!0}],example:["\n\n let x = 0;\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n }\nfunction draw() {\n background(204);\n line(x, 0, x, height);\n }\nfunction mousePressed() {\n x += 1;\n redraw();\n }\n
\n let x = 0;\nfunction setup() {\n createCanvas(100, 100);\n noLoop();\n }\nfunction draw() {\n background(204);\n x += 1;\n line(x, 0, x, height);\n }\nfunction mousePressed() {\n redraw(5);\n }\n
The p5()
constructor enables you to activate "instance mode" instead of normal\n"global mode". This is an advanced topic. A short description and example is\nincluded below. Please see\n\nDan Shiffman's Coding Train video tutorial or this\ntutorial page\nfor more info.
By default, all p5.js functions are in the global namespace (i.e. bound to the window\nobject), meaning you can call them simply ellipse()
, fill()
, etc. However, this\nmight be inconvenient if you are mixing with other JS libraries (synchronously or\nasynchronously) or writing long programs of your own. p5.js currently supports a\nway around this problem called "instance mode". In instance mode, all p5 functions\nare bound up in a single variable instead of polluting your global namespace.
Optionally, you can specify a default container for the canvas and any other elements\nto append to with a second argument. You can give the ID of an element in your html,\nor an html node itself.
\nNote that creating instances like this also allows you to have more than one p5 sketch on\na single web page, as they will each be wrapped up with their own set up variables. Of\ncourse, you could also use iframes to have multiple sketches in global mode.
\n',itemtype:"method",name:"p5",params:[{name:"sketch",description:"a function containing a p5.js sketch
\n",type:"Object"},{name:"node",description:"ID or pointer to HTML DOM node to contain sketch in
\n",type:"String|Object"}],example:["\n\nconst s = p => {\n let x = 100;\n let y = 100;\n\n p.setup = function() {\n p.createCanvas(700, 410);\n };\n\n p.draw = function() {\n p.background(0);\n p.fill(255);\n p.rect(x, y, 50, 50);\n };\n};\n\nnew p5(s); // invoke p5\n
Multiplies the current matrix by the one specified through the parameters.\nThis is a powerful operation that can perform the equivalent of translate,\nscale, shear and rotate all at once. You can learn more about transformation\nmatrices on \nWikipedia.
\nThe naming of the arguments here follows the naming of the \nWHATWG specification and corresponds to a\ntransformation matrix of the\nform:
\n\n\n\n',itemtype:"method",name:"applyMatrix",params:[{name:"a",description:"
numbers which define the 2x3 matrix to be multiplied
\n",type:"Number"},{name:"b",description:"numbers which define the 2x3 matrix to be multiplied
\n",type:"Number"},{name:"c",description:"numbers which define the 2x3 matrix to be multiplied
\n",type:"Number"},{name:"d",description:"numbers which define the 2x3 matrix to be multiplied
\n",type:"Number"},{name:"e",description:"numbers which define the 2x3 matrix to be multiplied
\n",type:"Number"},{name:"f",description:"numbers which define the 2x3 matrix to be multiplied
\n",type:"Number"}],chainable:1,example:["\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n background(200);\n // Equivalent to translate(x, y);\n applyMatrix(1, 0, 0, 1, 40 + step, 50);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n background(200);\n translate(50, 50);\n // Equivalent to scale(x, y);\n applyMatrix(1 / step, 0, 0, 1 / step, 0, 0);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n let angle = map(step, 0, 20, 0, TWO_PI);\n let cos_a = cos(angle);\n let sin_a = sin(angle);\n background(200);\n translate(50, 50);\n // Equivalent to rotate(angle);\n applyMatrix(cos_a, sin_a, -sin_a, cos_a, 0, 0);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n frameRate(10);\n rectMode(CENTER);\n}\n\nfunction draw() {\n let step = frameCount % 20;\n let angle = map(step, 0, 20, -PI / 4, PI / 4);\n background(200);\n translate(50, 50);\n // equivalent to shearX(angle);\n let shear_factor = 1 / tan(PI / 2 - angle);\n applyMatrix(1, 0, shear_factor, 1, 0, 0);\n rect(0, 0, 50, 50);\n}\n
\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noFill();\n}\n\nfunction draw() {\n background(200);\n rotateY(PI / 6);\n stroke(153);\n box(35);\n let rad = millis() / 1000;\n // Set rotation angles\n let ct = cos(rad);\n let st = sin(rad);\n // Matrix for rotation around the Y axis\n applyMatrix( ct, 0.0, st, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n -st, 0.0, ct, 0.0,\n 0.0, 0.0, 0.0, 1.0);\n stroke(255);\n box(50);\n}\n
\nReplaces the current matrix with the identity matrix.
\n",itemtype:"method",name:"resetMatrix",chainable:1,example:["\n\ntranslate(50, 50);\napplyMatrix(0.5, 0.5, -0.5, 0.5, 0, 0);\nrect(0, 0, 20, 20);\n// Note that the translate is also reset.\nresetMatrix();\nrect(0, 0, 20, 20);\n
\nRotates a shape the amount specified by the angle parameter. This\nfunction accounts for angleMode, so angles can be entered in either\nRADIANS or DEGREES.\n
\nObjects are always rotated around their relative position to the\norigin and positive numbers rotate objects in a clockwise direction.\nTransformations apply to everything that happens after and subsequent\ncalls to the function accumulates the effect. For example, calling\nrotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI).\nAll tranformations are reset when draw() begins again.\n
\nTechnically, rotate() multiplies the current transformation matrix\nby a rotation matrix. This function can be further controlled by\nthe push() and pop().
the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n",type:"Number"},{name:"axis",description:"(in 3d) the axis to rotate around
\n",type:"p5.Vector|Number[]",optional:!0}],chainable:1,example:["\n\ntranslate(width / 2, height / 2);\nrotate(PI / 3.0);\nrect(-26, -26, 52, 52);\n
\nRotates around X axis.
\n",itemtype:"method",name:"rotateX",params:[{name:"angle",description:"the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n",type:"Number"}],chainable:1,example:["\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(255);\n rotateX(millis() / 1000);\n box();\n}\n
\nRotates around Y axis.
\n",itemtype:"method",name:"rotateY",params:[{name:"angle",description:"the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n",type:"Number"}],chainable:1,example:["\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(255);\n rotateY(millis() / 1000);\n box();\n}\n
\nRotates around Z axis. Webgl mode only.
\n",itemtype:"method",name:"rotateZ",params:[{name:"angle",description:"the angle of rotation, specified in radians\n or degrees, depending on current angleMode
\n",type:"Number"}],chainable:1,example:["\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(255);\n rotateZ(millis() / 1000);\n box();\n}\n
\nIncreases or decreases the size of a shape by expanding and contracting\nvertices. Objects always scale from their relative origin to the\ncoordinate system. Scale values are specified as decimal percentages.\nFor example, the function call scale(2.0) increases the dimension of a\nshape by 200%.\n
\nTransformations apply to everything that happens after and subsequent\ncalls to the function multiply the effect. For example, calling scale(2.0)\nand then scale(1.5) is the same as scale(3.0). If scale() is called\nwithin draw(), the transformation is reset when the loop begins again.\n
\nUsing this function with the z parameter is only available in WEBGL mode.\nThis function can be further controlled with push() and pop().
\nrect(30, 20, 50, 50);\nscale(0.5);\nrect(30, 20, 50, 50);\n
\n\nrect(30, 20, 50, 50);\nscale(0.5, 1.3);\nrect(30, 20, 50, 50);\n
\npercent to scale the object, or percentage to\n scale the object in the x-axis if multiple arguments\n are given
\n",type:"Number|p5.Vector|Number[]"},{name:"y",description:"percent to scale the object in the y-axis
\n",type:"Number",optional:!0},{name:"z",description:"percent to scale the object in the z-axis (webgl only)
\n",type:"Number",optional:!0}],chainable:1},{line:349,params:[{name:"scales",description:"per-axis percents to scale the object
\n",type:"p5.Vector|Number[]"}],chainable:1}]},{file:"src/core/transform.js",line:379,description:'Shears a shape around the x-axis the amount specified by the angle\nparameter. Angles should be specified in the current angleMode.\nObjects are always sheared around their relative position to the origin\nand positive numbers shear objects in a clockwise direction.\n
\nTransformations apply to everything that happens after and subsequent\ncalls to the function accumulates the effect. For example, calling\nshearX(PI/2) and then shearX(PI/2) is the same as shearX(PI).\nIf shearX() is called within the draw(), the transformation is reset when\nthe loop begins again.\n
\nTechnically, shearX() multiplies the current transformation matrix by a\nrotation matrix. This function can be further controlled by the\npush() and pop() functions.
angle of shear specified in radians or degrees,\n depending on current angleMode
\n",type:"Number"}],chainable:1,example:["\n\ntranslate(width / 4, height / 4);\nshearX(PI / 4.0);\nrect(0, 0, 30, 30);\n
\nShears a shape around the y-axis the amount specified by the angle\nparameter. Angles should be specified in the current angleMode. Objects\nare always sheared around their relative position to the origin and\npositive numbers shear objects in a clockwise direction.\n
\nTransformations apply to everything that happens after and subsequent\ncalls to the function accumulates the effect. For example, calling\nshearY(PI/2) and then shearY(PI/2) is the same as shearY(PI). If\nshearY() is called within the draw(), the transformation is reset when\nthe loop begins again.\n
\nTechnically, shearY() multiplies the current transformation matrix by a\nrotation matrix. This function can be further controlled by the\npush() and pop() functions.
angle of shear specified in radians or degrees,\n depending on current angleMode
\n",type:"Number"}],chainable:1,example:["\n\ntranslate(width / 4, height / 4);\nshearY(PI / 4.0);\nrect(0, 0, 30, 30);\n
\nSpecifies an amount to displace objects within the display window.\nThe x parameter specifies left/right translation, the y parameter\nspecifies up/down translation.\n
\nTransformations are cumulative and apply to everything that happens after\nand subsequent calls to the function accumulates the effect. For example,\ncalling translate(50, 0) and then translate(20, 0) is the same as\ntranslate(70, 0). If translate() is called within draw(), the\ntransformation is reset when the loop begins again. This function can be\nfurther controlled by using push() and pop().
\ntranslate(30, 20);\nrect(0, 0, 55, 55);\n
\n\nrect(0, 0, 55, 55); // Draw rect at original 0,0\ntranslate(30, 20);\nrect(0, 0, 55, 55); // Draw rect at new 0,0\ntranslate(14, 14);\nrect(0, 0, 55, 55); // Draw rect at new 0,0\n
\n\nfunction draw() {\n background(200);\n rectMode(CENTER);\n translate(width / 2, height / 2);\n translate(p5.Vector.fromAngle(millis() / 1000, 40));\n rect(0, 0, 20, 20);\n}\n
\nleft/right translation
\n",type:"Number"},{name:"y",description:"up/down translation
\n",type:"Number"},{name:"z",description:"forward/backward translation (webgl only)
\n",type:"Number",optional:!0}],chainable:1},{line:513,params:[{name:"vector",description:"the vector to translate by
\n",type:"p5.Vector"}],chainable:1}]},{file:"src/data/local_storage.js",line:10,description:'Stores a value in local storage under the key name.\n Local storage is saved in the browser and persists\n between browsing sessions and page reloads.\n The key can be the name of the variable but doesn't\n have to be. To retrieve stored items\n see getItem.\n
\n Sensitive data such as passwords or personal information\n should not be stored in local storage.
\n // Type to change the letter in the\n // center of the canvas.\n // If you reload the page, it will\n // still display the last key you entered\nlet myText;\nfunction setup() {\n createCanvas(100, 100);\n myText = getItem('myText');\n if (myText === null) {\n myText = '';\n }\n }\nfunction draw() {\n textSize(40);\n background(255);\n text(myText, width / 2, height / 2);\n }\nfunction keyPressed() {\n myText = key;\n storeItem('myText', myText);\n }\n
Returns the value of an item that was stored in local storage\n using storeItem()
\n",itemtype:"method",name:"getItem",params:[{name:"key",description:"name that you wish to use to store in local storage
\n",type:"String"}],return:{description:"Value of stored item",type:"Number|Object|String|Boolean|p5.Color|p5.Vector"},example:["\n\n // Click the mouse to change\n // the color of the background\n // Once you have changed the color\n // it will stay changed even when you\n // reload the page.\nlet myColor;\nfunction setup() {\n createCanvas(100, 100);\n myColor = getItem('myColor');\n }\nfunction draw() {\n if (myColor !== null) {\n background(myColor);\n }\n }\nfunction mousePressed() {\n myColor = color(random(255), random(255), random(255));\n storeItem('myColor', myColor);\n }\n
Clears all local storage items set with storeItem()\n for the current domain.
\n",itemtype:"method",name:"clearStorage",example:["\n\n function setup() {\n let myNum = 10;\n let myBool = false;\n storeItem('myNum', myNum);\n storeItem('myBool', myBool);\n print(getItem('myNum')); // logs 10 to the console\n print(getItem('myBool')); // logs false to the console\n clearStorage();\n print(getItem('myNum')); // logs null to the console\n print(getItem('myBool')); // logs null to the console\n }\n
Removes an item that was stored with storeItem()
\n",itemtype:"method",name:"removeItem",params:[{name:"key",description:"",type:"String"}],example:["\n\n function setup() {\n let myVar = 10;\n storeItem('myVar', myVar);\n print(getItem('myVar')); // logs 10 to the console\n removeItem('myVar');\n print(getItem('myVar')); // logs null to the console\n }\n
Creates a new instance of p5.StringDict using the key-value pair\n or the object you provide.
\n",itemtype:"method",name:"createStringDict",return:{description:"",type:"p5.StringDict"},example:["\n\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
object
\n",type:"Object"}],return:{description:"",type:"p5.StringDict"}}]},{file:"src/data/p5.TypedDict.js",line:48,description:'Creates a new instance of p5.NumberDict using the key-value pair\n or object you provide.
\n',itemtype:"method",name:"createNumberDict",return:{description:"",type:"p5.NumberDict"},example:['\n\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
object
\n",type:"Object"}],return:{description:"",type:"p5.NumberDict"}}]},{file:"src/data/p5.TypedDict.js",line:102,description:"Returns the number of key-value pairs currently stored in the Dictionary.
\n",itemtype:"method",name:"size",return:{description:"the number of key-value pairs in the Dictionary",type:"Integer"},example:['\n\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
Returns true if the given key exists in the Dictionary,\notherwise returns false.
\n",itemtype:"method",name:"hasKey",params:[{name:"key",description:"that you want to look up
\n",type:"Number|String"}],return:{description:"whether that key exists in Dictionary",type:"Boolean"},example:["\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n print(myDictionary.hasKey('p5')); // logs true to console\n}\n
Returns the value stored at the given key.
\n",itemtype:"method",name:"get",params:[{name:"the",description:"key you want to access
\n",type:"Number|String"}],return:{description:"the value stored at that key",type:"Number|String"},example:["\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n let myValue = myDictionary.get('p5');\n print(myValue === 'js'); // logs true to console\n}\n
Updates the value associated with the given key in case it already exists\nin the Dictionary. Otherwise a new key-value pair is added.
\n",itemtype:"method",name:"set",params:[{name:"key",description:"",type:"Number|String"},{name:"value",description:"",type:"Number|String"}],example:["\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.set('p5', 'JS');\n myDictionary.print(); // logs \"key: p5 - value: JS\" to console\n}\n
private helper function to handle the user passing in objects\nduring construction or calls to create()
\n",class:"p5.TypedDict",module:"Data",submodule:"Dictionary"},{file:"src/data/p5.TypedDict.js",line:213,description:"Creates a new key-value pair in the Dictionary.
\n",itemtype:"method",name:"create",example:["\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.create('happy', 'coding');\n myDictionary.print();\n // above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n}\n
key/value pair
\n",type:"Object"}]}]},{file:"src/data/p5.TypedDict.js",line:249,description:"Removes all previously stored key-value pairs from the Dictionary.
\n",itemtype:"method",name:"clear",example:["\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n print(myDictionary.hasKey('p5')); // prints 'true'\n myDictionary.clear();\n print(myDictionary.hasKey('p5')); // prints 'false'\n}\n
\nRemoves the key-value pair stored at the given key from the Dictionary.
\n",itemtype:"method",name:"remove",params:[{name:"key",description:"for the pair to remove
\n",type:"Number|String"}],example:["\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.create('happy', 'coding');\n myDictionary.print();\n // above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n myDictionary.remove('p5');\n myDictionary.print();\n // above logs \"key: happy value: coding\" to console\n}\n
Logs the set of items currently stored in the Dictionary to the console.
\n",itemtype:"method",name:"print",example:["\n\nfunction setup() {\n let myDictionary = createStringDict('p5', 'js');\n myDictionary.create('happy', 'coding');\n myDictionary.print();\n // above logs \"key: p5 - value: js, key: happy - value: coding\" to console\n}\n
\nConverts the Dictionary into a CSV file for local download.
\n",itemtype:"method",name:"saveTable",example:["\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n createStringDict({\n john: 1940,\n paul: 1942,\n george: 1943,\n ringo: 1940\n }).saveTable('beatles');\n }\n}\n
\nConverts the Dictionary into a JSON file for local download.
\n",itemtype:"method",name:"saveJSON",example:["\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n createStringDict({\n john: 1940,\n paul: 1942,\n george: 1943,\n ringo: 1940\n }).saveJSON('beatles');\n }\n}\n
\nprivate helper function to ensure that the user passed in valid\nvalues for the Dictionary type
\n",class:"p5.TypedDict",module:"Data",submodule:"Dictionary"},{file:"src/data/p5.TypedDict.js",line:433,description:"private helper function to ensure that the user passed in valid\nvalues for the Dictionary type
\n",class:"p5.NumberDict",module:"Data",submodule:"Dictionary"},{file:"src/data/p5.TypedDict.js",line:440,description:"Add the given number to the value currently stored at the given key.\nThe sum then replaces the value previously stored in the Dictionary.
\n",itemtype:"method",name:"add",params:[{name:"Key",description:"for the value you wish to add to
\n",type:"Number"},{name:"Number",description:"to add to the value
\n",type:"Number"}],example:["\n\nfunction setup() {\n let myDictionary = createNumberDict(2, 5);\n myDictionary.add(2, 2);\n print(myDictionary.get(2)); // logs 7 to console.\n}\n
Subtract the given number from the value currently stored at the given key.\nThe difference then replaces the value previously stored in the Dictionary.
\n",itemtype:"method",name:"sub",params:[{name:"Key",description:"for the value you wish to subtract from
\n",type:"Number"},{name:"Number",description:"to subtract from the value
\n",type:"Number"}],example:["\n\nfunction setup() {\n let myDictionary = createNumberDict(2, 5);\n myDictionary.sub(2, 2);\n print(myDictionary.get(2)); // logs 3 to console.\n}\n
Multiply the given number with the value currently stored at the given key.\nThe product then replaces the value previously stored in the Dictionary.
\n",itemtype:"method",name:"mult",params:[{name:"Key",description:"for value you wish to multiply
\n",type:"Number"},{name:"Amount",description:"to multiply the value by
\n",type:"Number"}],example:["\n\nfunction setup() {\n let myDictionary = createNumberDict(2, 4);\n myDictionary.mult(2, 2);\n print(myDictionary.get(2)); // logs 8 to console.\n}\n
Divide the given number with the value currently stored at the given key.\nThe quotient then replaces the value previously stored in the Dictionary.
\n",itemtype:"method",name:"div",params:[{name:"Key",description:"for value you wish to divide
\n",type:"Number"},{name:"Amount",description:"to divide the value by
\n",type:"Number"}],example:["\n\nfunction setup() {\n let myDictionary = createNumberDict(2, 8);\n myDictionary.div(2, 2);\n print(myDictionary.get(2)); // logs 4 to console.\n}\n
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'
\n",class:"p5.NumberDict",module:"Data",submodule:"Dictionary"},{file:"src/data/p5.TypedDict.js",line:573,description:"Return the lowest number currently stored in the Dictionary.
\n",itemtype:"method",name:"minValue",return:{description:"",type:"Number"},example:["\n\nfunction setup() {\n let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });\n let lowestValue = myDictionary.minValue(); // value is -10\n print(lowestValue);\n}\n
Return the highest number currently stored in the Dictionary.
\n",itemtype:"method",name:"maxValue",return:{description:"",type:"Number"},example:["\n\nfunction setup() {\n let myDictionary = createNumberDict({ 2: -10, 4: 0.65, 1.2: 3 });\n let highestValue = myDictionary.maxValue(); // value is 3\n print(highestValue);\n}\n
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'
\n",class:"p5.NumberDict",module:"Data",submodule:"Dictionary"},{file:"src/data/p5.TypedDict.js",line:638,description:"Return the lowest key currently used in the Dictionary.
\n",itemtype:"method",name:"minKey",return:{description:"",type:"Number"},example:["\n\nfunction setup() {\n let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });\n let lowestKey = myDictionary.minKey(); // value is 1.2\n print(lowestKey);\n}\n
Return the highest key currently used in the Dictionary.
\n",itemtype:"method",name:"maxKey",return:{description:"",type:"Number"},example:["\n\nfunction setup() {\n let myDictionary = createNumberDict({ 2: 4, 4: 6, 1.2: 3 });\n let highestKey = myDictionary.maxKey(); // value is 4\n print(highestKey);\n}\n
Searches the page for an element with the given ID, class, or tag name (using the '#' or '.'\nprefixes to specify an ID or class respectively, and none for a tag) and returns it as\na p5.Element. If a class or tag name is given with more than 1 element,\nonly the first element will be returned.\nThe DOM node itself can be accessed with .elt.\nReturns null if none found. You can also specify a container to search within.
\n',itemtype:"method",name:"select",params:[{name:"name",description:"id, class, or tag name of element to search for
\n",type:"String"},{name:"container",description:'id, p5.Element, or\n HTML element to search within
\n',type:"String|p5.Element|HTMLElement",optional:!0}],return:{description:'p5.Element containing node found',type:"p5.Element|null"},example:["\n\nfunction setup() {\n createCanvas(100, 100);\n //translates canvas 50px down\n select('canvas').position(100, 100);\n}\n
\n// these are all valid calls to select()\nlet a = select('#moo');\nlet b = select('#blah', '#myContainer');\nlet c, e;\nif (b) {\n c = select('#foo', b);\n}\nlet d = document.getElementById('beep');\nif (d) {\n e = select('p', d);\n}\n[a, b, c, d, e]; // unused\n
Searches the page for elements with the given class or tag name (using the '.' prefix\nto specify a class and no prefix for a tag) and returns them as p5.Elements\nin an array.\nThe DOM node itself can be accessed with .elt.\nReturns an empty array if none found.\nYou can also specify a container to search within.
\n',itemtype:"method",name:"selectAll",params:[{name:"name",description:"class or tag name of elements to search for
\n",type:"String"},{name:"container",description:'id, p5.Element, or HTML element to search within
\n',type:"String",optional:!0}],return:{description:'Array of p5.Elements containing nodes found',type:"p5.Element[]"},example:["\n\nfunction setup() {\n createButton('btn');\n createButton('2nd btn');\n createButton('3rd btn');\n let buttons = selectAll('button');\n\n for (let i = 0; i < buttons.length; i++) {\n buttons[i].size(100, 100);\n }\n}\n
\n// these are all valid calls to selectAll()\nlet a = selectAll('.moo');\na = selectAll('div');\na = selectAll('button', '#myContainer');\n\nlet d = select('#container');\na = selectAll('p', d);\n\nlet f = document.getElementById('beep');\na = select('.blah', f);\n\na; // unused\n
Helper function for select and selectAll
\n",class:"p5",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:165,description:"Helper function for getElement and getElements.
\n",class:"p5",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:199,description:'Removes all elements created by p5, except any canvas / graphics\nelements created by createCanvas or createGraphics.\nEvent handlers are removed, and element is removed from the DOM.
\n',itemtype:"method",name:"removeElements",example:["\n\nfunction setup() {\n createCanvas(100, 100);\n createDiv('this is some text');\n createP('this is a paragraph');\n}\nfunction mousePressed() {\n removeElements(); // this will remove the div and p, not canvas\n}\n
The .changed() function is called when the value of an\nelement changes.\nThis can be used to attach an element specific event listener.
\n',itemtype:"method",name:"changed",params:[{name:"fxn",description:"function to be fired when the value of\n an element changes.\n if false
is passed instead, the previously\n firing function will no longer fire.
\nlet sel;\n\nfunction setup() {\n textAlign(CENTER);\n background(200);\n sel = createSelect();\n sel.position(10, 10);\n sel.option('pear');\n sel.option('kiwi');\n sel.option('grape');\n sel.changed(mySelectEvent);\n}\n\nfunction mySelectEvent() {\n let item = sel.value();\n background(200);\n text(\"it's a \" + item + '!', 50, 50);\n}\n
\nlet checkbox;\nlet cnv;\n\nfunction setup() {\n checkbox = createCheckbox(' fill');\n checkbox.changed(changeFill);\n cnv = createCanvas(100, 100);\n cnv.position(0, 30);\n noFill();\n}\n\nfunction draw() {\n background(200);\n ellipse(50, 50, 50, 50);\n}\n\nfunction changeFill() {\n if (checkbox.checked()) {\n fill(0);\n } else {\n noFill();\n }\n}\n
The .input() function is called when any user input is\ndetected with an element. The input event is often used\nto detect keystrokes in a input element, or changes on a\nslider element. This can be used to attach an element specific\nevent listener.
\n',itemtype:"method",name:"input",params:[{name:"fxn",description:"function to be fired when any user input is\n detected within the element.\n if false
is passed instead, the previously\n firing function will no longer fire.
\n// Open your console to see the output\nfunction setup() {\n let inp = createInput('');\n inp.input(myInputEvent);\n}\n\nfunction myInputEvent() {\n console.log('you are typing: ', this.value());\n}\n
Helpers for create methods.
\n",class:"p5",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:340,description:"Creates a <div></div> element in the DOM with given inner HTML.
\n",itemtype:"method",name:"createDiv",params:[{name:"html",description:"inner HTML for element created
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\ncreateDiv('this is some text');\n
Creates a <p></p> element in the DOM with given inner HTML. Used\nfor paragraph length text.
\n",itemtype:"method",name:"createP",params:[{name:"html",description:"inner HTML for element created
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\ncreateP('this is some text');\n
Creates a <span></span> element in the DOM with given inner HTML.
\n",itemtype:"method",name:"createSpan",params:[{name:"html",description:"inner HTML for element created
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\ncreateSpan('this is some text');\n
Creates an <img> element in the DOM with given src and\nalternate text.
\n",itemtype:"method",name:"createImg",return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\ncreateImg(\n 'https://p5js.org/assets/img/asterisk-01.png',\n 'the p5 magenta asterisk'\n);\n
src path or url for image
\n",type:"String"},{name:"alt",description:'alternate text to be used if image does not load. You can use also an empty string (""
) if that an image is not intended to be viewed.
crossOrigin property of the img
element; use either 'anonymous' or 'use-credentials' to retrieve the image with cross-origin access (for later use with canvas
. if an empty string(""
) is passed, CORS is not used
callback to be called once image data is loaded with the p5.Element as argument
\n',type:"Function",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"}}]},{file:"src/dom/dom.js",line:432,description:"Creates an <a></a> element in the DOM for including a hyperlink.
\n",itemtype:"method",name:"createA",params:[{name:"href",description:"url of page to link to
\n",type:"String"},{name:"html",description:"inner html of link element to display
\n",type:"String"},{name:"target",description:"target where new link should open,\n could be _blank, _self, _parent, _top.
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\ncreateA('http://p5js.org/', 'this is a link');\n
Creates a slider <input></input> element in the DOM.\nUse .size() to set the display length of the slider.
\n",itemtype:"method",name:"createSlider",params:[{name:"min",description:"minimum value of the slider
\n",type:"Number"},{name:"max",description:"maximum value of the slider
\n",type:"Number"},{name:"value",description:"default value of the slider
\n",type:"Number",optional:!0},{name:"step",description:"step size for each tick of the slider (if step is set to 0, the slider will move continuously from the minimum to the maximum value)
\n",type:"Number",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\nlet slider;\nfunction setup() {\n slider = createSlider(0, 255, 100);\n slider.position(10, 10);\n slider.style('width', '80px');\n}\n\nfunction draw() {\n let val = slider.value();\n background(val);\n}\n
\nlet slider;\nfunction setup() {\n colorMode(HSB);\n slider = createSlider(0, 360, 60, 40);\n slider.position(10, 10);\n slider.style('width', '80px');\n}\n\nfunction draw() {\n let val = slider.value();\n background(val, 100, 100, 1);\n}\n
Creates a <button></button> element in the DOM.\nUse .size() to set the display size of the button.\nUse .mousePressed() to specify behavior on press.
\n",itemtype:"method",name:"createButton",params:[{name:"label",description:"label displayed on the button
\n",type:"String"},{name:"value",description:"value of the button
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\nlet button;\nfunction setup() {\n createCanvas(100, 100);\n background(0);\n button = createButton('click me');\n button.position(19, 19);\n button.mousePressed(changeBG);\n}\n\nfunction changeBG() {\n let val = random(255);\n background(val);\n}\n
Creates a checkbox <input></input> element in the DOM.\nCalling .checked() on a checkbox returns if it is checked or not
\n",itemtype:"method",name:"createCheckbox",params:[{name:"label",description:"label displayed after checkbox
\n",type:"String",optional:!0},{name:"value",description:"value of the checkbox; checked is true, unchecked is false
\n",type:"Boolean",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\nlet checkbox;\n\nfunction setup() {\n checkbox = createCheckbox('label', false);\n checkbox.changed(myCheckedEvent);\n}\n\nfunction myCheckedEvent() {\n if (this.checked()) {\n console.log('Checking!');\n } else {\n console.log('Unchecking!');\n }\n}\n
Creates a dropdown menu <select></select> element in the DOM.\nIt also helps to assign select-box methods to p5.Element when selecting existing select box.\nThe .option() method can be used to set options for the select after it is created.\nThe .value() method will return the currently selected option.\nThe .selected() method will return current dropdown element which is an instance of p5.Element\nThe .selected() method can be used to make given option selected by default when the page first loads.\nThe .disable() method marks given option as disabled and marks whole of dropdown element as disabled when invoked with no parameter.
\n',itemtype:"method",name:"createSelect",return:{description:"",type:"p5.Element"},example:["\n\nlet sel;\n\nfunction setup() {\n textAlign(CENTER);\n background(200);\n sel = createSelect();\n sel.position(10, 10);\n sel.option('pear');\n sel.option('kiwi');\n sel.option('grape');\n sel.selected('kiwi');\n sel.changed(mySelectEvent);\n}\n\nfunction mySelectEvent() {\n let item = sel.value();\n background(200);\n text('It is a ' + item + '!', 50, 50);\n}\n
\nlet sel;\n\nfunction setup() {\n textAlign(CENTER);\n background(200);\n sel = createSelect();\n sel.position(10, 10);\n sel.option('oil');\n sel.option('milk');\n sel.option('bread');\n sel.disable('milk');\n}\n
true if dropdown should support multiple selections
\n",type:"Boolean",optional:!0}],return:{description:"",type:"p5.Element"}},{line:664,params:[{name:"existing",description:"DOM select element
\n",type:"Object"}],return:{description:"",type:"p5.Element"}}]},{file:"src/dom/dom.js",line:756,description:"Creates a radio button <input></input> element in the DOM.\nThe .option() method can be used to set options for the radio after it is\ncreated. The .value() method will return the currently selected option.
\n",itemtype:"method",name:"createRadio",params:[{name:"divId",description:"the id and name of the created div and input field respectively
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\nlet radio;\n\nfunction setup() {\n radio = createRadio();\n radio.option('black');\n radio.option('white');\n radio.option('gray');\n radio.style('width', '60px');\n textAlign(CENTER);\n fill(255, 0, 0);\n}\n\nfunction draw() {\n let val = radio.value();\n background(val);\n text(val, width / 2, height / 2);\n}\n
\nlet radio;\n\nfunction setup() {\n radio = createRadio();\n radio.option('apple', 1);\n radio.option('bread', 2);\n radio.option('juice', 3);\n radio.style('width', '60px');\n textAlign(CENTER);\n}\n\nfunction draw() {\n background(200);\n let val = radio.value();\n if (val) {\n text('item cost is $' + val, width / 2, height / 2);\n }\n}\n
Creates a colorPicker element in the DOM for color input.\nThe .value() method will return a hex string (#rrggbb) of the color.\nThe .color() method will return a p5.Color object with the current chosen color.
\n",itemtype:"method",name:"createColorPicker",params:[{name:"value",description:"default color of element
\n",type:"String|p5.Color",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\nlet colorPicker;\nfunction setup() {\n createCanvas(100, 100);\n colorPicker = createColorPicker('#ed225d');\n colorPicker.position(0, height + 5);\n}\n\nfunction draw() {\n background(colorPicker.color());\n}\n
\nlet inp1, inp2;\nfunction setup() {\n createCanvas(100, 100);\n background('grey');\n inp1 = createColorPicker('#ff0000');\n inp1.position(0, height + 5);\n inp1.input(setShade1);\n inp2 = createColorPicker(color('yellow'));\n inp2.position(0, height + 30);\n inp2.input(setShade2);\n setMidShade();\n}\n\nfunction setMidShade() {\n // Finding a shade between the two\n let commonShade = lerpColor(inp1.color(), inp2.color(), 0.5);\n fill(commonShade);\n rect(20, 20, 60, 60);\n}\n\nfunction setShade1() {\n setMidShade();\n console.log('You are choosing shade 1 to be : ', this.value());\n}\nfunction setShade2() {\n setMidShade();\n console.log('You are choosing shade 2 to be : ', this.value());\n}\n
Creates an <input></input> element in the DOM for text input.\nUse .size() to set the display length of the box.
\n',itemtype:"method",name:"createInput",params:[{name:"value",description:"default value of the input box
\n",type:"String",optional:!0},{name:"type",description:"type of text, ie text, password etc. Defaults to text
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\nfunction setup() {\n let inp = createInput('');\n inp.input(myInputEvent);\n}\n\nfunction myInputEvent() {\n console.log('you are typing: ', this.value());\n}\n
Creates an <input></input> element in the DOM of type 'file'.\nThis allows users to select local files for use in a sketch.
\n",itemtype:"method",name:"createFileInput",params:[{name:"callback",description:"callback function for when a file loaded
\n",type:"Function",optional:!0},{name:"multiple",description:"optional to allow multiple files selected
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created DOM element',type:"p5.Element"},example:["\n\nlet input;\nlet img;\n\nfunction setup() {\n input = createFileInput(handleFile);\n input.position(0, 0);\n}\n\nfunction draw() {\n background(255);\n if (img) {\n image(img, 0, 0, width, height);\n }\n}\n\nfunction handleFile(file) {\n print(file);\n if (file.type === 'image') {\n img = createImg(file.data, '');\n img.hide();\n } else {\n img = null;\n }\n}\n
Creates an HTML5 <video> element in the DOM for simple playback\nof audio/video. Shown by default, can be hidden with .hide()\nand drawn into canvas using video(). The first parameter\ncan be either a single string path to a video file, or an array of string\npaths to different formats of the same video. This is useful for ensuring\nthat your video can play across different browsers, as each supports\ndifferent formats. See this\npage for further information about supported formats.
\n",itemtype:"method",name:"createVideo",params:[{name:"src",description:"path to a video file, or array of paths for\n supporting different browsers
\n",type:"String|String[]"},{name:"callback",description:"callback function to be called upon\n 'canplaythrough' event fire, that is, when the\n browser can play the media, and estimates that\n enough data has been loaded to play the media\n up to its end without having to stop for\n further buffering of content
\n",type:"Function",optional:!0}],return:{description:'pointer to video p5.Element',type:"p5.MediaElement"},example:["\n\nlet vid;\nfunction setup() {\n noCanvas();\n\n vid = createVideo(\n ['assets/small.mp4', 'assets/small.ogv', 'assets/small.webm'],\n vidLoad\n );\n\n vid.size(100, 100);\n}\n\n// This function is called when the video loads\nfunction vidLoad() {\n vid.loop();\n vid.volume(0);\n}\n
Creates a hidden HTML5 <audio> element in the DOM for simple audio\nplayback. The first parameter can be either a single string path to a\naudio file, or an array of string paths to different formats of the same\naudio. This is useful for ensuring that your audio can play across\ndifferent browsers, as each supports different formats.\nSee this\npage for further information about supported formats.
\n",itemtype:"method",name:"createAudio",params:[{name:"src",description:"path to an audio file, or array of paths\n for supporting different browsers
\n",type:"String|String[]",optional:!0},{name:"callback",description:"callback function to be called upon\n 'canplaythrough' event fire, that is, when the\n browser can play the media, and estimates that\n enough data has been loaded to play the media\n up to its end without having to stop for\n further buffering of content
\n",type:"Function",optional:!0}],return:{description:'pointer to audio p5.Element',type:"p5.MediaElement"},example:["\n\nlet ele;\nfunction setup() {\n ele = createAudio('assets/beat.mp3');\n\n // here we set the element to autoplay\n // The element will play as soon\n // as it is able to do so.\n ele.autoplay(true);\n}\n
Creates a new HTML5 <video> element that contains the audio/video\nfeed from a webcam. The element is separate from the canvas and is\ndisplayed by default. The element can be hidden using .hide(). The feed\ncan be drawn onto the canvas using image(). The loadedmetadata property can\nbe used to detect when the element has fully loaded (see second example).
\nMore specific properties of the feed can be passing in a Constraints object.\nSee the\n W3C\nspec for possible properties. Note that not all of these are supported\nby all browsers.
\nSecurity note: A new browser security specification requires that getUserMedia,\nwhich is behind createCapture(), only works when you're running the code locally,\nor on HTTPS. Learn more here\nand here.
",itemtype:"method",name:"createCapture",params:[{name:"type",description:"type of capture, either VIDEO or\n AUDIO if none specified, default both,\n or a Constraints object
\n",type:"String|Constant|Object"},{name:"callback",description:"function to be called once\n stream has loaded
\n",type:"Function",optional:!0}],return:{description:'capture video p5.Element',type:"p5.Element"},example:["\n\nlet capture;\n\nfunction setup() {\n createCanvas(480, 480);\n capture = createCapture(VIDEO);\n capture.hide();\n}\n\nfunction draw() {\n image(capture, 0, 0, width, width * capture.height / capture.width);\n filter(INVERT);\n}\n
\nfunction setup() {\n createCanvas(480, 120);\n let constraints = {\n video: {\n mandatory: {\n minWidth: 1280,\n minHeight: 720\n },\n optional: [{ maxFrameRate: 10 }]\n },\n audio: true\n };\n createCapture(constraints, function(stream) {\n console.log(stream);\n });\n}\n
\nlet capture;\n\nfunction setup() {\n createCanvas(640, 480);\n capture = createCapture(VIDEO);\n}\nfunction draw() {\n background(0);\n if (capture.loadedmetadata) {\n let c = capture.get(0, 0, 100, 100);\n image(c, 0, 0);\n }\n}\n"],class:"p5",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1391,description:"Creates element with given tag in the DOM with given content.
\n",itemtype:"method",name:"createElement",params:[{name:"tag",description:"tag for the new element
\n",type:"String"},{name:"content",description:"html content to be inserted into the element
\n",type:"String",optional:!0}],return:{description:'pointer to p5.Element holding created node',type:"p5.Element"},example:["\n\ncreateElement('h2', 'im an h2 p5.element!');\n
"],class:"p5",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1415,description:"Adds specified class to the element.
\n",itemtype:"method",name:"addClass",params:[{name:"class",description:"name of class to add
\n",type:"String"}],chainable:1,example:["\n \n let div = createDiv('div');\n div.addClass('myClass');\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1440,description:"Removes specified class from the element.
\n",itemtype:"method",name:"removeClass",params:[{name:"class",description:"name of class to remove
\n",type:"String"}],chainable:1,example:["\n \n // In this example, a class is set when the div is created\n // and removed when mouse is pressed. This could link up\n // with a CSS style rule to toggle style properties.\nlet div;\nfunction setup() {\n div = createDiv('div');\n div.addClass('myClass');\n }\nfunction mousePressed() {\n div.removeClass('myClass');\n }\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1471,description:"Checks if specified class already set to element
\n",itemtype:"method",name:"hasClass",return:{description:"a boolean value if element has specified class",type:"Boolean"},params:[{name:"c",description:"class name of class to check
\n",type:"String"}],example:["\n \n let div;\nfunction setup() {\n div = createDiv('div');\n div.addClass('show');\n }\nfunction mousePressed() {\n if (div.hasClass('show')) {\n div.addClass('show');\n } else {\n div.removeClass('show');\n }\n }\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1500,description:"Toggles element class
\n",itemtype:"method",name:"toggleClass",params:[{name:"c",description:"class name to toggle
\n",type:"String"}],chainable:1,example:["\n \n let div;\nfunction setup() {\n div = createDiv('div');\n div.addClass('show');\n }\nfunction mousePressed() {\n div.toggleClass('show');\n }\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1533,description:'Attaches the element as a child to the parent specified.\n Accepts either a string ID, DOM node, or p5.Element.\n If no argument is specified, an array of children DOM nodes is returned.
\n',itemtype:"method",name:"child",return:{description:"an array of child nodes",type:"Node[]"},example:["\n \n let div0 = createDiv('this is the parent');\n let div1 = createDiv('this is the child');\n div0.child(div1); // use p5.Element\n
\n \n let div0 = createDiv('this is the parent');\n let div1 = createDiv('this is the child');\n div1.id('apples');\n div0.child('apples'); // use id\n
\n \n // this example assumes there is a div already on the page\n // with id \"myChildDiv\"\n let div0 = createDiv('this is the parent');\n let elt = document.getElementById('myChildDiv');\n div0.child(elt); // use element from page\n
"],class:"p5.Element",module:"DOM",submodule:"DOM",overloads:[{line:1533,params:[],return:{description:"an array of child nodes",type:"Node[]"}},{line:1561,params:[{name:"child",description:'the ID, DOM node, or p5.Element\n to add to the current element
\n',type:"String|p5.Element",optional:!0}],chainable:1}]},{file:"src/dom/dom.js",line:1583,description:"Centers a p5 Element either vertically, horizontally,\nor both, relative to its parent or according to\nthe body if the Element has no parent. If no argument is passed\nthe Element is aligned both vertically and horizontally.
\n",itemtype:"method",name:"center",params:[{name:"align",description:"passing 'vertical', 'horizontal' aligns element accordingly
\n",type:"String",optional:!0}],chainable:1,example:["\n\nfunction setup() {\n let div = createDiv('').size(10, 10);\n div.style('background-color', 'orange');\n div.center();\n}\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1637,description:"If an argument is given, sets the inner HTML of the element,\n replacing any existing html. If true is included as a second\n argument, html is appended instead of replacing existing html.\n If no arguments are given, returns\n the inner HTML of the element.
\n",itemtype:"method",name:"html",return:{description:"the inner HTML of the element",type:"String"},example:["\n \n let div = createDiv('').size(100, 100);\n div.html('hi');\n
\n \n let div = createDiv('Hello ').size(100, 100);\n div.html('World', true);\n
"],class:"p5.Element",module:"DOM",submodule:"DOM",overloads:[{line:1637,params:[],return:{description:"the inner HTML of the element",type:"String"}},{line:1658,params:[{name:"html",description:"the HTML to be placed inside the element
\n",type:"String",optional:!0},{name:"append",description:"whether to append HTML to existing
\n",type:"Boolean",optional:!0}],chainable:1}]},{file:"src/dom/dom.js",line:1676,description:'Sets the position of the element. If no position type argument is given, the\n position will be relative to (0, 0) of the window.\n Essentially, this sets position:absolute and left and top\n properties of style. If an optional third argument specifying position type is given,\n the x and y coordinates will be interpreted based on the positioning scheme.\n If no arguments given, the function returns the x and y position of the element.
\n',itemtype:"method",name:"position",return:{description:"the x and y position of the element in an object",type:"Object"},example:["\n \n function setup() {\n let cnv = createCanvas(100, 100);\n // positions canvas 50px to the right and 100px\n // below upper left corner of the window\n cnv.position(50, 100);\n }\n
\n \n function setup() {\n let cnv = createCanvas(100, 100);\n // positions canvas 50px to the right and 100px\n // below upper left corner of the window\n cnv.position(0, 0, 'fixed');\n }\n
"],class:"p5.Element",module:"DOM",submodule:"DOM",overloads:[{line:1676,params:[],return:{description:"the x and y position of the element in an object",type:"Object"}},{line:1706,params:[{name:"x",description:"x-position relative to upper left of window (optional)
\n",type:"Number",optional:!0},{name:"y",description:"y-position relative to upper left of window (optional)
\n",type:"Number",optional:!0},{name:"positionType",description:"it can be static, fixed, relative, sticky, initial or inherit (optional)
\n",type:"String"}],chainable:1}]},{file:"src/dom/dom.js",line:1793,description:"Sets the given style (css) property (1st arg) of the element with the\ngiven value (2nd arg). If a single argument is given, .style()\nreturns the value of the given property; however, if the single argument\nis given in css syntax ('text-align:center'), .style() sets the css\nappropriately.
\n",itemtype:"method",name:"style",return:{description:"value of property",type:"String"},example:["\n\nlet myDiv = createDiv('I like pandas.');\nmyDiv.style('font-size', '18px');\nmyDiv.style('color', '#ff0000');\n
\n\nlet col = color(25, 23, 200, 50);\nlet button = createButton('button');\nbutton.style('background-color', col);\nbutton.position(10, 10);\n
\n\nlet myDiv;\nfunction setup() {\n background(200);\n myDiv = createDiv('I like gray.');\n myDiv.position(20, 20);\n}\n\nfunction draw() {\n myDiv.style('font-size', mouseX + 'px');\n}\n
"],class:"p5.Element",module:"DOM",submodule:"DOM",overloads:[{line:1793,params:[{name:"property",description:"property to be set
\n",type:"String"}],return:{description:"value of property",type:"String"}},{line:1828,params:[{name:"property",description:"",type:"String"},{name:"value",description:"value to assign to property
\n",type:"String|Number|p5.Color"}],chainable:1,return:{description:"current value of property, if no value is given as second argument",type:"String"}}]},{file:"src/dom/dom.js",line:1882,description:"Adds a new attribute or changes the value of an existing attribute\n on the specified element. If no value is specified, returns the\n value of the given attribute, or null if attribute is not set.
\n",itemtype:"method",name:"attribute",return:{description:"value of attribute",type:"String"},example:["\n \n let myDiv = createDiv('I like pandas.');\n myDiv.attribute('align', 'center');\n
"],class:"p5.Element",module:"DOM",submodule:"DOM",overloads:[{line:1882,params:[],return:{description:"value of attribute",type:"String"}},{line:1897,params:[{name:"attr",description:"attribute to set
\n",type:"String"},{name:"value",description:"value to assign to attribute
\n",type:"String"}],chainable:1}]},{file:"src/dom/dom.js",line:1926,description:"Removes an attribute on the specified element.
\n",itemtype:"method",name:"removeAttribute",params:[{name:"attr",description:"attribute to remove
\n",type:"String"}],chainable:1,example:["\n \n let button;\n let checkbox;\nfunction setup() {\n checkbox = createCheckbox('enable', true);\n checkbox.changed(enableButton);\n button = createButton('button');\n button.position(10, 10);\n }\nfunction enableButton() {\n if (this.checked()) {\n // Re-enable the button\n button.removeAttribute('disabled');\n } else {\n // Disable the button\n button.attribute('disabled', '');\n }\n }\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:1971,description:"Either returns the value of the element if no arguments\ngiven, or sets the value of the element.
\n",itemtype:"method",name:"value",return:{description:"value of the element",type:"String|Number"},example:["\n\n// gets the value\nlet inp;\nfunction setup() {\n inp = createInput('');\n}\n\nfunction mousePressed() {\n print(inp.value());\n}\n
\n\n// sets the value\nlet inp;\nfunction setup() {\n inp = createInput('myValue');\n}\n\nfunction mousePressed() {\n inp.value('myValue');\n}\n
"],class:"p5.Element",module:"DOM",submodule:"DOM",overloads:[{line:1971,params:[],return:{description:"value of the element",type:"String|Number"}},{line:2001,params:[{name:"value",description:"",type:"String|Number"}],chainable:1}]},{file:"src/dom/dom.js",line:2017,description:"Shows the current element. Essentially, setting display:block for the style.
\n",itemtype:"method",name:"show",chainable:1,example:["\n \n let div = createDiv('div');\n div.style('display', 'none');\n div.show(); // turns display to block\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2035,description:"Hides the current element. Essentially, setting display:none for the style.
\n",itemtype:"method",name:"hide",chainable:1,example:["\n\nlet div = createDiv('this is a div');\ndiv.hide();\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2051,description:"Sets the width and height of the element. AUTO can be used to\n only adjust one dimension at a time. If no arguments are given, it\n returns the width and height of the element in an object. In case of\n elements which need to be loaded, such as images, it is recommended\n to call the function after the element has finished loading.
\n",itemtype:"method",name:"size",return:{description:"the width and height of the element in an object",type:"Object"},example:["\n \n let div = createDiv('this is a div');\n div.size(100, 100);\n let img = createImg(\n 'assets/rockies.jpg',\n 'A tall mountain with a small forest and field in front of it on a sunny day',\n '',\n () => {\n img.size(10, AUTO);\n }\n );\n
"],class:"p5.Element",module:"DOM",submodule:"DOM",overloads:[{line:2051,params:[],return:{description:"the width and height of the element in an object",type:"Object"}},{line:2075,params:[{name:"w",description:"width of the element, either AUTO, or a number
\n",type:"Number|Constant"},{name:"h",description:"height of the element, either AUTO, or a number
\n",type:"Number|Constant",optional:!0}],chainable:1}]},{file:"src/dom/dom.js",line:2132,description:"Removes the element, stops all media streams, and deregisters all listeners.
\n",itemtype:"method",name:"remove",example:["\n\nlet myDiv = createDiv('this is some text');\nmyDiv.remove();\n
"],class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2166,description:'Registers a callback that gets called every time a file that is\ndropped on the element has been loaded.\np5 will load every dropped file into memory and pass it as a p5.File object to the callback.\nMultiple files dropped at the same time will result in multiple calls to the callback.
\nYou can optionally pass a second callback which will be registered to the raw\ndrop event.\nThe callback will thus be provided the original\nDragEvent.\nDropping multiple files at the same time will trigger the second callback once per drop,\nwhereas the first callback will trigger for each loaded file.
\n',itemtype:"method",name:"drop",params:[{name:"callback",description:"callback to receive loaded file, called for each file dropped.
\n",type:"Function"},{name:"fxn",description:"callback triggered once when files are dropped with the drop event.
\n",type:"Function",optional:!0}],chainable:1,example:["\n\nfunction setup() {\n let c = createCanvas(100, 100);\n background(200);\n textAlign(CENTER);\n text('drop file', width / 2, height / 2);\n c.drop(gotFile);\n}\n\nfunction gotFile(file) {\n background(200);\n text('received file:', width / 2, height / 2);\n text(file.name, width / 2, height / 2 + 50);\n}\n
\n\n\nlet img;\n\nfunction setup() {\n let c = createCanvas(100, 100);\n background(200);\n textAlign(CENTER);\n text('drop image', width / 2, height / 2);\n c.drop(gotFile);\n}\n\nfunction draw() {\n if (img) {\n image(img, 0, 0, width, height);\n }\n}\n\nfunction gotFile(file) {\n img = createImg(file.data, '').hide();\n}\n
"],alt:"Canvas turns into whatever image is dragged/dropped onto it.",class:"p5.Element",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2298,description:"Path to the media element source.
\n",itemtype:"property",name:"src",return:{description:"src",type:"String"},example:["\n\nlet ele;\n\nfunction setup() {\n background(250);\n\n //p5.MediaElement objects are usually created\n //by calling the createAudio(), createVideo(),\n //and createCapture() functions.\n\n //In this example we create\n //a new p5.MediaElement via createAudio().\n ele = createAudio('assets/beat.mp3');\n\n //We'll set up our example so that\n //when you click on the text,\n //an alert box displays the MediaElement's\n //src field.\n textAlign(CENTER);\n text('Click Me!', width / 2, height / 2);\n}\n\nfunction mouseClicked() {\n //here we test if the mouse is over the\n //canvas element when it's clicked\n if (mouseX >= 0 && mouseX <= width && mouseY >= 0 && mouseY <= height) {\n //Show our p5.MediaElement's src field\n alert(ele.src);\n }\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2363,description:"Play an HTML5 media element.
\n",itemtype:"method",name:"play",chainable:1,example:["\n\nlet ele;\n\nfunction setup() {\n //p5.MediaElement objects are usually created\n //by calling the createAudio(), createVideo(),\n //and createCapture() functions.\n\n //In this example we create\n //a new p5.MediaElement via createAudio().\n ele = createAudio('assets/beat.mp3');\n\n background(250);\n textAlign(CENTER);\n text('Click to Play!', width / 2, height / 2);\n}\n\nfunction mouseClicked() {\n //here we test if the mouse is over the\n //canvas element when it's clicked\n if (mouseX >= 0 && mouseX <= width && mouseY >= 0 && mouseY <= height) {\n //Here we call the play() function on\n //the p5.MediaElement we created above.\n //This will start the audio sample.\n ele.play();\n\n background(200);\n text('You clicked Play!', width / 2, height / 2);\n }\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2427,description:"Stops an HTML5 media element (sets current time to zero).
\n",itemtype:"method",name:"stop",chainable:1,example:["\n\n//This example both starts\n//and stops a sound sample\n//when the user clicks the canvas\n\n//We will store the p5.MediaElement\n//object in here\nlet ele;\n\n//while our audio is playing,\n//this will be set to true\nlet sampleIsPlaying = false;\n\nfunction setup() {\n //Here we create a p5.MediaElement object\n //using the createAudio() function.\n ele = createAudio('assets/beat.mp3');\n background(200);\n textAlign(CENTER);\n text('Click to play!', width / 2, height / 2);\n}\n\nfunction mouseClicked() {\n //here we test if the mouse is over the\n //canvas element when it's clicked\n if (mouseX >= 0 && mouseX <= width && mouseY >= 0 && mouseY <= height) {\n background(200);\n\n if (sampleIsPlaying) {\n //if the sample is currently playing\n //calling the stop() function on\n //our p5.MediaElement will stop\n //it and reset its current\n //time to 0 (i.e. it will start\n //at the beginning the next time\n //you play it)\n ele.stop();\n\n sampleIsPlaying = false;\n text('Click to play!', width / 2, height / 2);\n } else {\n //loop our sound element until we\n //call ele.stop() on it.\n ele.loop();\n\n sampleIsPlaying = true;\n text('Click to stop!', width / 2, height / 2);\n }\n }\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2491,description:"Pauses an HTML5 media element.
\n",itemtype:"method",name:"pause",chainable:1,example:["\n\n//This example both starts\n//and pauses a sound sample\n//when the user clicks the canvas\n\n//We will store the p5.MediaElement\n//object in here\nlet ele;\n\n//while our audio is playing,\n//this will be set to true\nlet sampleIsPlaying = false;\n\nfunction setup() {\n //Here we create a p5.MediaElement object\n //using the createAudio() function.\n ele = createAudio('assets/lucky_dragons.mp3');\n background(200);\n textAlign(CENTER);\n text('Click to play!', width / 2, height / 2);\n}\n\nfunction mouseClicked() {\n //here we test if the mouse is over the\n //canvas element when it's clicked\n if (mouseX >= 0 && mouseX <= width && mouseY >= 0 && mouseY <= height) {\n background(200);\n\n if (sampleIsPlaying) {\n //Calling pause() on our\n //p5.MediaElement will stop it\n //playing, but when we call the\n //loop() or play() functions\n //the sample will start from\n //where we paused it.\n ele.pause();\n\n sampleIsPlaying = false;\n text('Click to resume!', width / 2, height / 2);\n } else {\n //loop our sound element until we\n //call ele.pause() on it.\n ele.loop();\n\n sampleIsPlaying = true;\n text('Click to pause!', width / 2, height / 2);\n }\n }\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2553,description:"Set 'loop' to true for an HTML5 media element, and starts playing.
\n",itemtype:"method",name:"loop",chainable:1,example:["\n\n//Clicking the canvas will loop\n//the audio sample until the user\n//clicks again to stop it\n\n//We will store the p5.MediaElement\n//object in here\nlet ele;\n\n//while our audio is playing,\n//this will be set to true\nlet sampleIsLooping = false;\n\nfunction setup() {\n //Here we create a p5.MediaElement object\n //using the createAudio() function.\n ele = createAudio('assets/lucky_dragons.mp3');\n background(200);\n textAlign(CENTER);\n text('Click to loop!', width / 2, height / 2);\n}\n\nfunction mouseClicked() {\n //here we test if the mouse is over the\n //canvas element when it's clicked\n if (mouseX >= 0 && mouseX <= width && mouseY >= 0 && mouseY <= height) {\n background(200);\n\n if (!sampleIsLooping) {\n //loop our sound element until we\n //call ele.stop() on it.\n ele.loop();\n\n sampleIsLooping = true;\n text('Click to stop!', width / 2, height / 2);\n } else {\n ele.stop();\n\n sampleIsLooping = false;\n text('Click to loop!', width / 2, height / 2);\n }\n }\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2609,description:"Set 'loop' to false for an HTML5 media element. Element will stop\nwhen it reaches the end.
\n",itemtype:"method",name:"noLoop",chainable:1,example:["\n\n//This example both starts\n//and stops loop of sound sample\n//when the user clicks the canvas\n\n//We will store the p5.MediaElement\n//object in here\nlet ele;\n//while our audio is playing,\n//this will be set to true\nlet sampleIsPlaying = false;\n\nfunction setup() {\n //Here we create a p5.MediaElement object\n //using the createAudio() function.\n ele = createAudio('assets/beat.mp3');\n background(200);\n textAlign(CENTER);\n text('Click to play!', width / 2, height / 2);\n}\n\nfunction mouseClicked() {\n //here we test if the mouse is over the\n //canvas element when it's clicked\n if (mouseX >= 0 && mouseX <= width && mouseY >= 0 && mouseY <= height) {\n background(200);\n\n if (sampleIsPlaying) {\n ele.noLoop();\n text('No more Loops!', width / 2, height / 2);\n } else {\n ele.loop();\n sampleIsPlaying = true;\n text('Click to stop looping!', width / 2, height / 2);\n }\n }\n}\n
\n"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2675,description:"Set HTML5 media element to autoplay or not.
\n",itemtype:"method",name:"autoplay",params:[{name:"autoplay",description:"whether the element should autoplay
\n",type:"Boolean"}],chainable:1,class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:2704,description:"Sets volume for this HTML5 media element. If no argument is given,\nreturns the current volume.
\n",itemtype:"method",name:"volume",return:{description:"current volume",type:"Number"},example:["\n\nlet ele;\nfunction setup() {\n // p5.MediaElement objects are usually created\n // by calling the createAudio(), createVideo(),\n // and createCapture() functions.\n // In this example we create\n // a new p5.MediaElement via createAudio().\n ele = createAudio('assets/lucky_dragons.mp3');\n background(250);\n textAlign(CENTER);\n text('Click to Play!', width / 2, height / 2);\n}\nfunction mouseClicked() {\n // Here we call the volume() function\n // on the sound element to set its volume\n // Volume must be between 0.0 and 1.0\n ele.volume(0.2);\n ele.play();\n background(200);\n text('You clicked Play!', width / 2, height / 2);\n}\n
\n\nlet audio;\nlet counter = 0;\n\nfunction loaded() {\n audio.play();\n}\n\nfunction setup() {\n audio = createAudio('assets/lucky_dragons.mp3', loaded);\n textAlign(CENTER);\n}\n\nfunction draw() {\n if (counter === 0) {\n background(0, 255, 0);\n text('volume(0.9)', width / 2, height / 2);\n } else if (counter === 1) {\n background(255, 255, 0);\n text('volume(0.5)', width / 2, height / 2);\n } else if (counter === 2) {\n background(255, 0, 0);\n text('volume(0.1)', width / 2, height / 2);\n }\n}\n\nfunction mousePressed() {\n counter++;\n if (counter === 0) {\n audio.volume(0.9);\n } else if (counter === 1) {\n audio.volume(0.5);\n } else if (counter === 2) {\n audio.volume(0.1);\n } else {\n counter = 0;\n audio.volume(0.9);\n }\n}\n
\n"],class:"p5.MediaElement",module:"DOM",submodule:"DOM",overloads:[{line:2704,params:[],return:{description:"current volume",type:"Number"}},{line:2777,params:[{name:"val",description:"volume between 0.0 and 1.0
\n",type:"Number"}],chainable:1}]},{file:"src/dom/dom.js",line:2790,description:"If no arguments are given, returns the current playback speed of the\nelement. The speed parameter sets the speed where 2.0 will play the\nelement twice as fast, 0.5 will play at half the speed, and -1 will play\nthe element in normal speed in reverse.(Note that not all browsers support\nbackward playback and even if they do, playback might not be smooth.)
\n",itemtype:"method",name:"speed",return:{description:"current playback speed of the element",type:"Number"},example:["\n\n//Clicking the canvas will loop\n//the audio sample until the user\n//clicks again to stop it\n\n//We will store the p5.MediaElement\n//object in here\nlet ele;\nlet button;\n\nfunction setup() {\n createCanvas(710, 400);\n //Here we create a p5.MediaElement object\n //using the createAudio() function.\n ele = createAudio('assets/beat.mp3');\n ele.loop();\n background(200);\n\n button = createButton('2x speed');\n button.position(100, 68);\n button.mousePressed(twice_speed);\n\n button = createButton('half speed');\n button.position(200, 68);\n button.mousePressed(half_speed);\n\n button = createButton('reverse play');\n button.position(300, 68);\n button.mousePressed(reverse_speed);\n\n button = createButton('STOP');\n button.position(400, 68);\n button.mousePressed(stop_song);\n\n button = createButton('PLAY!');\n button.position(500, 68);\n button.mousePressed(play_speed);\n}\n\nfunction twice_speed() {\n ele.speed(2);\n}\n\nfunction half_speed() {\n ele.speed(0.5);\n}\n\nfunction reverse_speed() {\n ele.speed(-1);\n}\n\nfunction stop_song() {\n ele.stop();\n}\n\nfunction play_speed() {\n ele.play();\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM",overloads:[{line:2790,params:[],return:{description:"current playback speed of the element",type:"Number"}},{line:2861,params:[{name:"speed",description:"speed multiplier for element playback
\n",type:"Number"}],chainable:1}]},{file:"src/dom/dom.js",line:2878,description:"If no arguments are given, returns the current time of the element.\nIf an argument is given the current time of the element is set to it.
\n",itemtype:"method",name:"time",return:{description:"current time (in seconds)",type:"Number"},example:["\n\nlet ele;\nlet beginning = true;\nfunction setup() {\n //p5.MediaElement objects are usually created\n //by calling the createAudio(), createVideo(),\n //and createCapture() functions.\n\n //In this example we create\n //a new p5.MediaElement via createAudio().\n ele = createAudio('assets/lucky_dragons.mp3');\n background(250);\n textAlign(CENTER);\n text('start at beginning', width / 2, height / 2);\n}\n\n// this function fires with click anywhere\nfunction mousePressed() {\n if (beginning === true) {\n // here we start the sound at the beginning\n // time(0) is not necessary here\n // as this produces the same result as\n // play()\n ele.play().time(0);\n background(200);\n text('jump 2 sec in', width / 2, height / 2);\n beginning = false;\n } else {\n // here we jump 2 seconds into the sound\n ele.play().time(2);\n background(250);\n text('start at beginning', width / 2, height / 2);\n beginning = true;\n }\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM",overloads:[{line:2878,params:[],return:{description:"current time (in seconds)",type:"Number"}},{line:2923,params:[{name:"time",description:"time to jump to (in seconds)
\n",type:"Number"}],chainable:1}]},{file:"src/dom/dom.js",line:2937,description:"Returns the duration of the HTML5 media element.
\n",itemtype:"method",name:"duration",return:{description:"duration",type:"Number"},example:["\n\nlet ele;\nfunction setup() {\n //p5.MediaElement objects are usually created\n //by calling the createAudio(), createVideo(),\n //and createCapture() functions.\n //In this example we create\n //a new p5.MediaElement via createAudio().\n ele = createAudio('assets/doorbell.mp3');\n background(250);\n textAlign(CENTER);\n text('Click to know the duration!', 10, 25, 70, 80);\n}\nfunction mouseClicked() {\n ele.play();\n background(200);\n //ele.duration dislpays the duration\n text(ele.duration() + ' seconds', width / 2, height / 2);\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3059,description:"Schedule an event to be called when the audio or video\nelement reaches the end. If the element is looping,\nthis will not be called. The element is passed in\nas the argument to the onended callback.
\n",itemtype:"method",name:"onended",params:[{name:"callback",description:"function to call when the\n soundfile has ended. The\n media element will be passed\n in as the argument to the\n callback.
\n",type:"Function"}],chainable:1,example:["\n\nfunction setup() {\n let audioEl = createAudio('assets/beat.mp3');\n audioEl.showControls();\n audioEl.onended(sayDone);\n}\n\nfunction sayDone(elt) {\n alert('done playing ' + elt.src);\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3090,class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3092,description:"Send the audio output of this element to a specified audioNode or\np5.sound object. If no element is provided, connects to p5's master\noutput. That connection is established when this method is first called.\nAll connections are removed by the .disconnect() method.
\nThis method is meant to be used with the p5.sound.js addon library.
\n",itemtype:"method",name:"connect",params:[{name:"audioNode",description:"AudioNode from the Web Audio API,\nor an object from the p5.sound library
\n",type:"AudioNode|Object"}],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3141,description:"Disconnect all Web Audio routing, including to master output.\nThis is useful if you want to re-route the output through\naudio effects, for example.
\n",itemtype:"method",name:"disconnect",class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3156,class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3158,description:"Show the default MediaElement controls, as determined by the web browser.
\n",itemtype:"method",name:"showControls",example:["\n\nlet ele;\nfunction setup() {\n //p5.MediaElement objects are usually created\n //by calling the createAudio(), createVideo(),\n //and createCapture() functions.\n //In this example we create\n //a new p5.MediaElement via createAudio()\n ele = createAudio('assets/lucky_dragons.mp3');\n background(200);\n textAlign(CENTER);\n text('Click to Show Controls!', 10, 25, 70, 80);\n}\nfunction mousePressed() {\n ele.showControls();\n background(200);\n text('Controls Shown', width / 2, height / 2);\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3189,description:"Hide the default mediaElement controls.
\n",itemtype:"method",name:"hideControls",example:["\n\nlet ele;\nfunction setup() {\n //p5.MediaElement objects are usually created\n //by calling the createAudio(), createVideo(),\n //and createCapture() functions.\n //In this example we create\n //a new p5.MediaElement via createAudio()\n ele = createAudio('assets/lucky_dragons.mp3');\n ele.showControls();\n background(200);\n textAlign(CENTER);\n text('Click to hide Controls!', 10, 25, 70, 80);\n}\nfunction mousePressed() {\n ele.hideControls();\n background(200);\n text('Controls hidden', width / 2, height / 2);\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3218,class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3229,description:"Schedule events to trigger every time a MediaElement\n(audio/video) reaches a playback cue point.
\nAccepts a callback function, a time (in seconds) at which to trigger\nthe callback, and an optional parameter for the callback.
\nTime will be passed as the first parameter to the callback function,\nand param will be the second parameter.
\n",itemtype:"method",name:"addCue",params:[{name:"time",description:"Time in seconds, relative to this media\n element's playback. For example, to trigger\n an event every time playback reaches two\n seconds, pass in the number 2. This will be\n passed as the first parameter to\n the callback function.
\n",type:"Number"},{name:"callback",description:"Name of a function that will be\n called at the given time. The callback will\n receive time and (optionally) param as its\n two parameters.
\n",type:"Function"},{name:"value",description:"An object to be passed as the\n second parameter to the\n callback function.
\n",type:"Object",optional:!0}],return:{description:"id ID of this cue,\n useful for removeCue(id)",type:"Number"},example:["\n\n//\n//\nfunction setup() {\n noCanvas();\n\n let audioEl = createAudio('assets/beat.mp3');\n audioEl.showControls();\n\n // schedule three calls to changeBackground\n audioEl.addCue(0.5, changeBackground, color(255, 0, 0));\n audioEl.addCue(1.0, changeBackground, color(0, 255, 0));\n audioEl.addCue(2.5, changeBackground, color(0, 0, 255));\n audioEl.addCue(3.0, changeBackground, color(0, 255, 255));\n audioEl.addCue(4.2, changeBackground, color(255, 255, 0));\n audioEl.addCue(5.0, changeBackground, color(255, 255, 0));\n}\n\nfunction changeBackground(val) {\n background(val);\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3293,description:"Remove a callback based on its ID. The ID is returned by the\naddCue method.
\n",itemtype:"method",name:"removeCue",params:[{name:"id",description:"ID of the cue, as returned by addCue
\n",type:"Number"}],example:["\n\nlet audioEl, id1, id2;\nfunction setup() {\n background(255, 255, 255);\n audioEl = createAudio('assets/beat.mp3');\n audioEl.showControls();\n // schedule five calls to changeBackground\n id1 = audioEl.addCue(0.5, changeBackground, color(255, 0, 0));\n audioEl.addCue(1.0, changeBackground, color(0, 255, 0));\n audioEl.addCue(2.5, changeBackground, color(0, 0, 255));\n audioEl.addCue(3.0, changeBackground, color(0, 255, 255));\n id2 = audioEl.addCue(4.2, changeBackground, color(255, 255, 0));\n text('Click to remove first and last Cue!', 10, 25, 70, 80);\n}\nfunction mousePressed() {\n audioEl.removeCue(id1);\n audioEl.removeCue(id2);\n}\nfunction changeBackground(val) {\n background(val);\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3335,description:"Remove all of the callbacks that had originally been scheduled\nvia the addCue method.
\n",itemtype:"method",name:"clearCues",params:[{name:"id",description:"ID of the cue, as returned by addCue
\n",type:"Number"}],example:["\n\nlet audioEl;\nfunction setup() {\n background(255, 255, 255);\n audioEl = createAudio('assets/beat.mp3');\n //Show the default MediaElement controls, as determined by the web browser\n audioEl.showControls();\n // schedule calls to changeBackground\n background(200);\n text('Click to change Cue!', 10, 25, 70, 80);\n audioEl.addCue(0.5, changeBackground, color(255, 0, 0));\n audioEl.addCue(1.0, changeBackground, color(0, 255, 0));\n audioEl.addCue(2.5, changeBackground, color(0, 0, 255));\n audioEl.addCue(3.0, changeBackground, color(0, 255, 255));\n audioEl.addCue(4.2, changeBackground, color(255, 255, 0));\n}\nfunction mousePressed() {\n // here we clear the scheduled callbacks\n audioEl.clearCues();\n // then we add some more callbacks\n audioEl.addCue(1, changeBackground, color(2, 2, 2));\n audioEl.addCue(3, changeBackground, color(255, 255, 0));\n}\nfunction changeBackground(val) {\n background(val);\n}\n
"],class:"p5.MediaElement",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3401,description:"Underlying File object. All normal File methods can be called on this.
\n",itemtype:"property",name:"file",class:"p5.File",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3413,description:"File type (image, text, etc.)
\n",itemtype:"property",name:"type",class:"p5.File",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3419,description:"File subtype (usually the file extension jpg, png, xml, etc.)
\n",itemtype:"property",name:"subtype",class:"p5.File",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3425,description:"File name
\n",itemtype:"property",name:"name",class:"p5.File",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3431,description:"File size
\n",itemtype:"property",name:"size",class:"p5.File",module:"DOM",submodule:"DOM"},{file:"src/dom/dom.js",line:3438,description:"URL string containing image data.
\n",itemtype:"property",name:"data",class:"p5.File",module:"DOM",submodule:"DOM"},{file:"src/events/acceleration.js",line:11,description:"The system variable deviceOrientation always contains the orientation of\nthe device. The value of this variable will either be set 'landscape'\nor 'portrait'. If no data is available it will be set to 'undefined'.\neither LANDSCAPE or PORTRAIT.
\n",itemtype:"property",name:"deviceOrientation",type:"Constant",readonly:"",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:23,description:"The system variable accelerationX always contains the acceleration of the\ndevice along the x axis. Value is represented as meters per second squared.
\n",itemtype:"property",name:"accelerationX",type:"Number",readonly:"",example:["\n\n\n// Move a touchscreen device to register\n// acceleration changes.\nfunction draw() {\n background(220, 50);\n fill('magenta');\n ellipse(width / 2, height / 2, accelerationX);\n}\n
\n"],alt:"Magnitude of device acceleration is displayed as ellipse size",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:46,description:"The system variable accelerationY always contains the acceleration of the\ndevice along the y axis. Value is represented as meters per second squared.
\n",itemtype:"property",name:"accelerationY",type:"Number",readonly:"",example:["\n\n\n// Move a touchscreen device to register\n// acceleration changes.\nfunction draw() {\n background(220, 50);\n fill('magenta');\n ellipse(width / 2, height / 2, accelerationY);\n}\n
\n"],alt:"Magnitude of device acceleration is displayed as ellipse size",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:69,description:"The system variable accelerationZ always contains the acceleration of the\ndevice along the z axis. Value is represented as meters per second squared.
\n",itemtype:"property",name:"accelerationZ",type:"Number",readonly:"",example:["\n\n\n// Move a touchscreen device to register\n// acceleration changes.\nfunction draw() {\n background(220, 50);\n fill('magenta');\n ellipse(width / 2, height / 2, accelerationZ);\n}\n
\n"],alt:"Magnitude of device acceleration is displayed as ellipse size",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:94,description:"The system variable pAccelerationX always contains the acceleration of the\ndevice along the x axis in the frame previous to the current frame. Value\nis represented as meters per second squared.
\n",itemtype:"property",name:"pAccelerationX",type:"Number",readonly:"",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:104,description:"The system variable pAccelerationY always contains the acceleration of the\ndevice along the y axis in the frame previous to the current frame. Value\nis represented as meters per second squared.
\n",itemtype:"property",name:"pAccelerationY",type:"Number",readonly:"",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:114,description:"The system variable pAccelerationZ always contains the acceleration of the\ndevice along the z axis in the frame previous to the current frame. Value\nis represented as meters per second squared.
\n",itemtype:"property",name:"pAccelerationZ",type:"Number",readonly:"",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:135,description:'The system variable rotationX always contains the rotation of the\ndevice along the x axis. If the sketch \nangleMode() is set to DEGREES, the value will be -180 to 180. If\nit is set to RADIANS, the value will be -PI to PI.\n
\nNote: The order the rotations are called is important, ie. if used\ntogether, it must be called in the order Z-X-Y or there might be\nunexpected behaviour.
\n',itemtype:"property",name:"rotationX",type:"Number",readonly:"",example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n //rotateZ(radians(rotationZ));\n rotateX(radians(rotationX));\n //rotateY(radians(rotationY));\n box(200, 200, 200);\n}\n
\n"],alt:"red horizontal line right, green vertical line bottom. black background.",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:168,description:'The system variable rotationY always contains the rotation of the\ndevice along the y axis. If the sketch \nangleMode() is set to DEGREES, the value will be -90 to 90. If\nit is set to RADIANS, the value will be -PI/2 to PI/2.\n
\nNote: The order the rotations are called is important, ie. if used\ntogether, it must be called in the order Z-X-Y or there might be\nunexpected behaviour.
\n',itemtype:"property",name:"rotationY",type:"Number",readonly:"",example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n //rotateZ(radians(rotationZ));\n //rotateX(radians(rotationX));\n rotateY(radians(rotationY));\n box(200, 200, 200);\n}\n
\n"],alt:"red horizontal line right, green vertical line bottom. black background.",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:201,description:'The system variable rotationZ always contains the rotation of the\ndevice along the z axis. If the sketch \nangleMode() is set to DEGREES, the value will be 0 to 360. If\nit is set to RADIANS, the value will be 0 to 2*PI.\n
\nUnlike rotationX and rotationY, this variable is available for devices\nwith a built-in compass only.\n
\nNote: The order the rotations are called is important, ie. if used\ntogether, it must be called in the order Z-X-Y or there might be\nunexpected behaviour.
\n',example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n rotateZ(radians(rotationZ));\n //rotateX(radians(rotationX));\n //rotateY(radians(rotationY));\n box(200, 200, 200);\n}\n
\n"],itemtype:"property",name:"rotationZ",type:"Number",readonly:"",alt:"red horizontal line right, green vertical line bottom. black background.",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:239,description:'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 angleMode() is set to DEGREES,\nthe value will be -180 to 180. If it is set to RADIANS, the value will\nbe -PI to PI.\n
\npRotationX can also be used with rotationX to determine the rotate\ndirection of the device along the X-axis.
\n',example:["\n\n\n// A simple if statement looking at whether\n// rotationX - pRotationX < 0 is true or not will be\n// sufficient for determining the rotate direction\n// in most cases.\n\n// Some extra logic is needed to account for cases where\n// the angles wrap around.\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);\n
\n"],alt:"no image to display.",itemtype:"property",name:"pRotationX",type:"Number",readonly:"",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:286,description:'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 angleMode() is set to DEGREES,\nthe value will be -90 to 90. If it is set to RADIANS, the value will\nbe -PI/2 to PI/2.\n
\npRotationY can also be used with rotationY to determine the rotate\ndirection of the device along the Y-axis.
\n',example:["\n\n\n// A simple if statement looking at whether\n// rotationY - pRotationY < 0 is true or not will be\n// sufficient for determining the rotate direction\n// in most cases.\n\n// Some extra logic is needed to account for cases where\n// the angles wrap around.\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);\n
\n"],alt:"no image to display.",itemtype:"property",name:"pRotationY",type:"Number",readonly:"",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:332,description:'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 angleMode() is set to DEGREES,\nthe value will be 0 to 360. If it is set to RADIANS, the value will\nbe 0 to 2*PI.\n
\npRotationZ can also be used with rotationZ to determine the rotate\ndirection of the device along the Z-axis.
\n',example:["\n\n\n// A simple if statement looking at whether\n// rotationZ - pRotationZ < 0 is true or not will be\n// sufficient for determining the rotate direction\n// in most cases.\n\n// Some extra logic is needed to account for cases where\n// the angles wrap around.\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);\n
\n"],alt:"no image to display.",itemtype:"property",name:"pRotationZ",type:"Number",readonly:"",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:392,description:'When a device is rotated, the axis that triggers the deviceTurned()\nmethod is stored in the turnAxis variable. The turnAxis variable is only defined within\nthe scope of deviceTurned().
\n',itemtype:"property",name:"turnAxis",type:"String",readonly:"",example:["\n\n\n// Run this example on a mobile device\n// Rotate the device by 90 degrees in the\n// X-axis to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceTurned() {\n if (turnAxis === 'X') {\n if (value === 0) {\n value = 255;\n } else if (value === 255) {\n value = 0;\n }\n }\n}\n
\n"],alt:"50x50 black rect in center of canvas. turns white on mobile when device turns\n50x50 black rect in center of canvas. turns white on mobile when x-axis turns",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:431,description:'The setMoveThreshold() function is used to set the movement threshold for\nthe deviceMoved() function. The default threshold is set to 0.5.
\n',itemtype:"method",name:"setMoveThreshold",params:[{name:"value",description:"The threshold value
\n",type:"Number"}],example:['\n\n\n// Run this example on a mobile device\n// You will need to move the device incrementally further\n// the closer the square\'s color gets to white in order to change the value.\n\nlet value = 0;\nlet threshold = 0.5;\nfunction setup() {\n setMoveThreshold(threshold);\n}\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceMoved() {\n value = value + 5;\n threshold = threshold + 0.1;\n if (value > 255) {\n value = 0;\n threshold = 30;\n }\n setMoveThreshold(threshold);\n}\n
\n'],alt:"50x50 black rect in center of canvas. turns white on mobile when device moves",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:474,description:'The setShakeThreshold() function is used to set the movement threshold for\nthe deviceShaken() function. The default threshold is set to 30.
\n',itemtype:"method",name:"setShakeThreshold",params:[{name:"value",description:"The threshold value
\n",type:"Number"}],example:['\n\n\n// Run this example on a mobile device\n// You will need to shake the device more firmly\n// the closer the box\'s fill gets to white in order to change the value.\n\nlet value = 0;\nlet threshold = 30;\nfunction setup() {\n setShakeThreshold(threshold);\n}\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceMoved() {\n value = value + 5;\n threshold = threshold + 5;\n if (value > 255) {\n value = 0;\n threshold = 30;\n }\n setShakeThreshold(threshold);\n}\n
\n'],alt:"50x50 black rect in center of canvas. turns white on mobile when device\nis being shaked",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:518,description:'The deviceMoved() function is called when the device is moved by more than\nthe threshold value along X, Y or Z axis. The default threshold is set to 0.5.\nThe threshold value can be changed using setMoveThreshold().
\n',itemtype:"method",name:"deviceMoved",example:['\n\n\n// Run this example on a mobile device\n// Move the device around\n// to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n'],alt:"50x50 black rect in center of canvas. turns white on mobile when device moves",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:550,description:'The deviceTurned() function is called when the device rotates by\nmore than 90 degrees continuously.\n
\nThe axis that triggers the deviceTurned() method is stored in the turnAxis\nvariable. The deviceTurned() method can be locked to trigger on any axis:\nX, Y or Z by comparing the turnAxis variable to 'X', 'Y' or 'Z'.
\n',itemtype:"method",name:"deviceTurned",example:["\n\n\n// Run this example on a mobile device\n// Rotate the device by 90 degrees\n// to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceTurned() {\n if (value === 0) {\n value = 255;\n } else if (value === 255) {\n value = 0;\n }\n}\n
\n\n\n\n// Run this example on a mobile device\n// Rotate the device by 90 degrees in the\n// X-axis to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceTurned() {\n if (turnAxis === 'X') {\n if (value === 0) {\n value = 255;\n } else if (value === 255) {\n value = 0;\n }\n }\n}\n
\n"],alt:"50x50 black rect in center of canvas. turns white on mobile when device turns\n50x50 black rect in center of canvas. turns white on mobile when x-axis turns",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/acceleration.js",line:609,description:'The deviceShaken() function is called when the device total acceleration\nchanges of accelerationX and accelerationY values is more than\nthe threshold value. The default threshold is set to 30.\nThe threshold value can be changed using setShakeThreshold().
\n',itemtype:"method",name:"deviceShaken",example:['\n\n\n// Run this example on a mobile device\n// Shake the device to change the value.\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction deviceShaken() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n'],alt:"50x50 black rect in center of canvas. turns white on mobile when device shakes",class:"p5",module:"Events",submodule:"Acceleration"},{file:"src/events/keyboard.js",line:10,description:'The boolean system variable keyIsPressed is true if any key is pressed\nand false if no keys are pressed.
\n',itemtype:"property",name:"keyIsPressed",type:"Boolean",readonly:"",example:["\n\n\nfunction draw() {\n if (keyIsPressed === true) {\n fill(0);\n } else {\n fill(255);\n }\n rect(25, 25, 50, 50);\n}\n
\n"],alt:"50x50 white rect that turns black on keypress.",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/keyboard.js",line:37,description:'The system variable key always contains the value of the most recent\nkey on the keyboard that was typed. To get the proper capitalization, it\nis best to use it within keyTyped(). For non-ASCII keys, use the keyCode\nvariable.
\n',itemtype:"property",name:"key",type:"String",readonly:"",example:["\n\n// Click any key to display it!\n// (Not Guaranteed to be Case Sensitive)\nfunction setup() {\n fill(245, 123, 158);\n textSize(50);\n}\n\nfunction draw() {\n background(200);\n text(key, 33, 65); // Display last key pressed.\n}\n
"],alt:"canvas displays any key value that is pressed in pink font.",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/keyboard.js",line:66,description:'The variable keyCode is used to detect special keys such as BACKSPACE,\nDELETE, ENTER, RETURN, TAB, ESCAPE, SHIFT, CONTROL, OPTION, ALT, UP_ARROW,\nDOWN_ARROW, LEFT_ARROW, RIGHT_ARROW.\nYou can also check for custom keys by looking up the keyCode of any key\non a site like this: keycode.info.
\n',itemtype:"property",name:"keyCode",type:"Integer",readonly:"",example:["\n\nlet fillVal = 126;\nfunction draw() {\n fill(fillVal);\n rect(25, 25, 50, 50);\n}\n\nfunction keyPressed() {\n if (keyCode === UP_ARROW) {\n fillVal = 255;\n } else if (keyCode === DOWN_ARROW) {\n fillVal = 0;\n }\n return false; // prevent default\n}\n
\n\nfunction draw() {}\nfunction keyPressed() {\n background('yellow');\n text(`${key} ${keyCode}`, 10, 40);\n print(key, ' ', keyCode);\n return false; // prevent default\n}\n
"],alt:"Grey rect center. turns white when up arrow pressed and black when down\nDisplay key pressed and its keyCode in a yellow box",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/keyboard.js",line:107,description:'The keyPressed() function is called once every time a key is pressed. The\nkeyCode for the key that was pressed is stored in the keyCode variable.\n
\nFor non-ASCII keys, use the keyCode variable. You can check if the keyCode\nequals BACKSPACE, DELETE, ENTER, RETURN, TAB, ESCAPE, SHIFT, CONTROL,\nOPTION, ALT, UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW.\n
\nFor ASCII keys, the key that was pressed is stored in the key variable. However, it\ndoes not distinguish between uppercase and lowercase. For this reason, it\nis recommended to use keyTyped() to read the key variable, in which the\ncase of the variable will be distinguished.\n
\nBecause of how operating systems handle key repeats, holding down a key\nmay cause multiple calls to keyTyped() (and keyReleased() as well). The\nrate of repeat is set by the operating system and how each computer is\nconfigured.
\nBrowsers may have different default\nbehaviors attached to various key events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.
\n',itemtype:"method",name:"keyPressed",example:['\n\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction keyPressed() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\n\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction keyPressed() {\n if (keyCode === LEFT_ARROW) {\n value = 255;\n } else if (keyCode === RIGHT_ARROW) {\n value = 0;\n }\n}\n
\n\n\n\nfunction keyPressed() {\n // Do something\n return false; // prevent any default behaviour\n}\n
\n'],alt:"black rect center. turns white when key pressed and black when released\nblack rect center. turns white when left arrow pressed and black when right.",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/keyboard.js",line:194,description:'The keyReleased() function is called once every time a key is released.\nSee key and keyCode for more information.
\nBrowsers may have different default\nbehaviors attached to various key events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.
\n',itemtype:"method",name:"keyReleased",example:["\n\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction keyReleased() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n return false; // prevent any default behavior\n}\n
\n"],alt:"black rect center. turns white when key pressed and black when pressed again",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/keyboard.js",line:246,description:'The keyTyped() function is called once every time a key is pressed, but\naction keys such as Backspace, Delete, Ctrl, Shift, and Alt are ignored. If you are trying to detect\na keyCode for one of these keys, use the keyPressed() function instead.\nThe most recent key typed will be stored in the key variable.\n
\nBecause of how operating systems handle key repeats, holding down a key\nwill cause multiple calls to keyTyped() (and keyReleased() as well). The\nrate of repeat is set by the operating system and how each computer is\nconfigured.
\nBrowsers may have different default behaviors attached to various key\nevents. To prevent any default behavior for this event, add "return false"\nto the end of the method.
\n',itemtype:"method",name:"keyTyped",example:["\n\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction keyTyped() {\n if (key === 'a') {\n value = 255;\n } else if (key === 'b') {\n value = 0;\n }\n // uncomment to prevent any default behavior\n // return false;\n}\n
\n"],alt:"black rect center. turns white when 'a' key typed and black when 'b' pressed",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/keyboard.js",line:300,description:"The onblur function is called when the user is no longer focused\non the p5 element. Because the keyup events will not fire if the user is\nnot focused on the element we must assume all keys currently down have\nbeen released.
\n",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/keyboard.js",line:310,description:'The keyIsDown() function checks if the key is currently down, i.e. pressed.\nIt can be used if you have an object that moves, and you want several keys\nto be able to affect its behaviour simultaneously, such as moving a\nsprite diagonally. You can put in any number representing the keyCode of\nthe key, or use any of the variable keyCode names listed\nhere.
\n',itemtype:"method",name:"keyIsDown",params:[{name:"code",description:"The key to check for.
\n",type:"Number"}],return:{description:"whether key is down or not",type:"Boolean"},example:['\n\nlet x = 100;\nlet y = 100;\n\nfunction setup() {\n createCanvas(512, 512);\n fill(255, 0, 0);\n}\n\nfunction draw() {\n if (keyIsDown(LEFT_ARROW)) {\n x -= 5;\n }\n\n if (keyIsDown(RIGHT_ARROW)) {\n x += 5;\n }\n\n if (keyIsDown(UP_ARROW)) {\n y -= 5;\n }\n\n if (keyIsDown(DOWN_ARROW)) {\n y += 5;\n }\n\n clear();\n ellipse(x, y, 50, 50);\n}\n
\n\n\nlet diameter = 50;\n\nfunction setup() {\n createCanvas(512, 512);\n}\n\nfunction draw() {\n // 107 and 187 are keyCodes for "+"\n if (keyIsDown(107) || keyIsDown(187)) {\n diameter += 1;\n }\n\n // 109 and 189 are keyCodes for "-"\n if (keyIsDown(109) || keyIsDown(189)) {\n diameter -= 1;\n }\n\n clear();\n fill(255, 0, 0);\n ellipse(50, 50, diameter, diameter);\n}\n
'],alt:"50x50 red ellipse moves left, right, up and down with arrow presses.\n50x50 red ellipse gets bigger or smaller when + or - are pressed.",class:"p5",module:"Events",submodule:"Keyboard"},{file:"src/events/mouse.js",line:12,description:"The variable movedX contains the horizontal movement of the mouse since the last frame
\n",itemtype:"property",name:"movedX",type:"Number",readonly:"",example:['\n \n \n let x = 50;\n function setup() {\n rectMode(CENTER);\n }\nfunction draw() {\n if (x > 48) {\n x -= 2;\n } else if (x < 48) {\n x += 2;\n }\n x += floor(movedX / 5);\n background(237, 34, 93);\n fill(0);\n rect(x, 50, 50, 50);\n }\n
\n '],alt:"box moves left and right according to mouse movement then slowly back towards the center",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:44,description:"The variable movedY contains the vertical movement of the mouse since the last frame
\n",itemtype:"property",name:"movedY",type:"Number",readonly:"",example:['\n\n\nlet y = 50;\nfunction setup() {\n rectMode(CENTER);\n}\n\nfunction draw() {\n if (y > 48) {\n y -= 2;\n } else if (y < 48) {\n y += 2;\n }\n y += floor(movedY / 5);\n background(237, 34, 93);\n fill(0);\n rect(y, 50, 50, 50);\n}\n
\n'],alt:"box moves up and down according to mouse movement then slowly back towards the center",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:82,description:"The system variable mouseX always contains the current horizontal\nposition of the mouse, relative to (0, 0) of the canvas. The value at\nthe top-left corner is (0, 0) for 2-D and (-width/2, -height/2) for WebGL.\nIf touch is used instead of mouse input, mouseX will hold the x value\nof the most recent touch point.
\n",itemtype:"property",name:"mouseX",type:"Number",readonly:"",example:["\n\n\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(mouseX, 0, mouseX, 100);\n}\n
\n"],alt:"horizontal black line moves left and right with mouse x-position",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:109,description:"The system variable mouseY always contains the current vertical\nposition of the mouse, relative to (0, 0) of the canvas. The value at\nthe top-left corner is (0, 0) for 2-D and (-width/2, -height/2) for WebGL.\nIf touch is used instead of mouse input, mouseY will hold the y value\nof the most recent touch point.
\n",itemtype:"property",name:"mouseY",type:"Number",readonly:"",example:["\n\n\n// Move the mouse across the canvas\nfunction draw() {\n background(244, 248, 252);\n line(0, mouseY, 100, mouseY);\n}\n
\n"],alt:"vertical black line moves up and down with mouse y-position",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:136,description:"The system variable pmouseX always contains the horizontal position of\nthe mouse or finger in the frame previous to the current frame, relative to\n(0, 0) of the canvas. The value at the top-left corner is (0, 0) for 2-D and\n(-width/2, -height/2) for WebGL. Note: pmouseX will be reset to the current mouseX\nvalue at the start of each touch event.
\n",itemtype:"property",name:"pmouseX",type:"Number",readonly:"",example:["\n\n\n// Move the mouse across the canvas to leave a trail\nfunction setup() {\n //slow down the frameRate to make it more visible\n frameRate(10);\n}\n\nfunction draw() {\n background(244, 248, 252);\n line(mouseX, mouseY, pmouseX, pmouseY);\n print(pmouseX + ' -> ' + mouseX);\n}\n
\n"],alt:"line trail is created from cursor movements. faster movement make longer line.",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:169,description:"The system variable pmouseY always contains the vertical position of\nthe mouse or finger in the frame previous to the current frame, relative to\n(0, 0) of the canvas. The value at the top-left corner is (0, 0) for 2-D and\n(-width/2, -height/2) for WebGL. Note: pmouseY will be reset to the current mouseY\nvalue at the start of each touch event.
\n",itemtype:"property",name:"pmouseY",type:"Number",readonly:"",example:["\n\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n //draw a square only if the mouse is not moving\n if (mouseY === pmouseY && mouseX === pmouseX) {\n rect(20, 20, 60, 60);\n }\n\n print(pmouseY + ' -> ' + mouseY);\n}\n
\n"],alt:"60x60 black rect center, fuchsia background. rect flickers on mouse movement",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:201,description:"The system variable winMouseX always contains the current horizontal\nposition of the mouse, relative to (0, 0) of the window.
\n",itemtype:"property",name:"winMouseX",type:"Number",readonly:"",example:["\n\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n let body = document.getElementsByTagName('body')[0];\n myCanvas.parent(body);\n}\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n //move the canvas to the horizontal mouse position\n //relative to the window\n myCanvas.position(winMouseX + 1, windowHeight / 2);\n\n //the y of the square is relative to the canvas\n rect(20, mouseY, 60, 60);\n}\n
\n"],alt:"60x60 black rect y moves with mouse y and fuchsia canvas moves with mouse x",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:240,description:"The system variable winMouseY always contains the current vertical\nposition of the mouse, relative to (0, 0) of the window.
\n",itemtype:"property",name:"winMouseY",type:"Number",readonly:"",example:["\n\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n let body = document.getElementsByTagName('body')[0];\n myCanvas.parent(body);\n}\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n //move the canvas to the vertical mouse position\n //relative to the window\n myCanvas.position(windowWidth / 2, winMouseY + 1);\n\n //the x of the square is relative to the canvas\n rect(mouseX, 20, 60, 60);\n}\n
\n"],alt:"60x60 black rect x moves with mouse x and fuchsia canvas y moves with mouse y",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:279,description:"The system variable pwinMouseX always contains the horizontal position\nof the mouse in the frame previous to the current frame, relative to\n(0, 0) of the window. Note: pwinMouseX will be reset to the current winMouseX\nvalue at the start of each touch event.
\n",itemtype:"property",name:"pwinMouseX",type:"Number",readonly:"",example:["\n\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n noStroke();\n fill(237, 34, 93);\n}\n\nfunction draw() {\n clear();\n //the difference between previous and\n //current x position is the horizontal mouse speed\n let speed = abs(winMouseX - pwinMouseX);\n //change the size of the circle\n //according to the horizontal speed\n ellipse(50, 50, 10 + speed * 5, 10 + speed * 5);\n //move the canvas to the mouse position\n myCanvas.position(winMouseX + 1, winMouseY + 1);\n}\n
\n"],alt:"fuchsia ellipse moves with mouse x and y. Grows and shrinks with mouse speed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:320,description:"The system variable pwinMouseY always contains the vertical position of\nthe mouse in the frame previous to the current frame, relative to (0, 0)\nof the window. Note: pwinMouseY will be reset to the current winMouseY\nvalue at the start of each touch event.
\n",itemtype:"property",name:"pwinMouseY",type:"Number",readonly:"",example:["\n\n\nlet myCanvas;\n\nfunction setup() {\n //use a variable to store a pointer to the canvas\n myCanvas = createCanvas(100, 100);\n noStroke();\n fill(237, 34, 93);\n}\n\nfunction draw() {\n clear();\n //the difference between previous and\n //current y position is the vertical mouse speed\n let speed = abs(winMouseY - pwinMouseY);\n //change the size of the circle\n //according to the vertical speed\n ellipse(50, 50, 10 + speed * 5, 10 + speed * 5);\n //move the canvas to the mouse position\n myCanvas.position(winMouseX + 1, winMouseY + 1);\n}\n
\n"],alt:"fuchsia ellipse moves with mouse x and y. Grows and shrinks with mouse speed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:362,description:"Processing automatically tracks if the mouse button is pressed and which\nbutton is pressed. The value of the system variable mouseButton is either\nLEFT, RIGHT, or CENTER depending on which button was pressed last.\nWarning: different browsers may track mouseButton differently.
\n",itemtype:"property",name:"mouseButton",type:"Constant",readonly:"",example:["\n\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n if (mouseIsPressed) {\n if (mouseButton === LEFT) {\n ellipse(50, 50, 50, 50);\n }\n if (mouseButton === RIGHT) {\n rect(25, 25, 50, 50);\n }\n if (mouseButton === CENTER) {\n triangle(23, 75, 50, 20, 78, 75);\n }\n }\n\n print(mouseButton);\n}\n
\n"],alt:"50x50 black ellipse appears on center of fuchsia canvas on mouse click/press.",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:401,description:"The boolean system variable mouseIsPressed is true if the mouse is pressed\nand false if not.
\n",itemtype:"property",name:"mouseIsPressed",type:"Boolean",readonly:"",example:["\n\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n\n if (mouseIsPressed) {\n ellipse(50, 50, 50, 50);\n } else {\n rect(25, 25, 50, 50);\n }\n\n print(mouseIsPressed);\n}\n
\n"],alt:"black 50x50 rect becomes ellipse with mouse click/press. fuchsia background.",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:494,description:'The mouseMoved() function is called every time the mouse moves and a mouse\nbutton is not pressed.
\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.
\n',itemtype:"method",name:"mouseMoved",params:[{name:"event",description:"optional MouseEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Move the mouse across the page\n// to change its value\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mouseMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction mouseMoved() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseMoved(event) {\n console.log(event);\n}\n
\n'],alt:"black 50x50 rect becomes lighter with mouse movements until white then resets\nno image displayed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:549,description:'The mouseDragged() function is called once every time the mouse moves and\na mouse button is pressed. If no mouseDragged() function is defined, the\ntouchMoved() function will be called instead if it is defined.
\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.
\n',itemtype:"method",name:"mouseDragged",params:[{name:"event",description:"optional MouseEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Drag the mouse across the page\n// to change its value\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mouseDragged() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction mouseDragged() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseDragged(event) {\n console.log(event);\n}\n
\n'],alt:"black 50x50 rect turns lighter with mouse click and drag until white, resets\nno image displayed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:630,description:'The mousePressed() function is called once after every time a mouse button\nis pressed. The mouseButton variable (see the related reference entry)\ncan be used to determine which button has been pressed. If no\nmousePressed() function is defined, the touchStarted() function will be\ncalled instead if it is defined.
\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.
\n',itemtype:"method",name:"mousePressed",params:[{name:"event",description:"optional MouseEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Click within the image to change\n// the value of the rectangle\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mousePressed() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction mousePressed() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mousePressed(event) {\n console.log(event);\n}\n
\n'],alt:"black 50x50 rect turns white with mouse click/press.\nno image displayed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:712,description:'The mouseReleased() function is called every time a mouse button is\nreleased. If no mouseReleased() function is defined, the touchEnded()\nfunction will be called instead if it is defined.
\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.
\n',itemtype:"method",name:"mouseReleased",params:[{name:"event",description:"optional MouseEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been clicked\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction mouseReleased() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction mouseReleased() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseReleased(event) {\n console.log(event);\n}\n
\n'],alt:"black 50x50 rect turns white with mouse click/press.\nno image displayed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:790,description:'The mouseClicked() function is called once after a mouse button has been\npressed and then released.
\nBrowsers handle clicks differently, so this function is only guaranteed to be\nrun when the left mouse button is clicked. To handle other mouse buttons\nbeing pressed or released, see mousePressed() or mouseReleased().
\nBrowsers may have different default\nbehaviors attached to various mouse events. To prevent any default\nbehavior for this event, add "return false" to the end of the method.
\n',itemtype:"method",name:"mouseClicked",params:[{name:"event",description:"optional MouseEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been clicked\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\n\nfunction mouseClicked() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction mouseClicked() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a MouseEvent object\n// as a callback argument\nfunction mouseClicked(event) {\n console.log(event);\n}\n
\n'],alt:"black 50x50 rect turns white with mouse click/press.\nno image displayed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:860,description:'The doubleClicked() function is executed every time a event\nlistener has detected a dblclick event which is a part of the\nDOM L3 specification. The doubleClicked event is fired when a\npointing device button (usually a mouse's primary button)\nis clicked twice on a single element. For more info on the\ndblclick event refer to mozilla's documentation here:\nhttps://developer.mozilla.org/en-US/docs/Web/Events/dblclick
\n',itemtype:"method",name:"doubleClicked",params:[{name:"event",description:"optional MouseEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Click within the image to change\n// the value of the rectangle\n// after the mouse has been double clicked\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\n\nfunction doubleClicked() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction doubleClicked() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a MouseEvent object\n// as a callback argument\nfunction doubleClicked(event) {\n console.log(event);\n}\n
\n'],alt:"black 50x50 rect turns white with mouse doubleClick/press.\nno image displayed",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:945,description:'The function mouseWheel() is executed every time a vertical mouse wheel\nevent is detected either triggered by an actual mouse wheel or by a\ntouchpad.
\nThe event.delta property returns the amount the mouse wheel\nhave scrolled. The values can be positive or negative depending on the\nscroll direction (on OS X with "natural" scrolling enabled, the signs\nare inverted).
\nBrowsers may have different default behaviors attached to various\nmouse events. To prevent any default behavior for this event, add\n"return false" to the end of the method.
\nDue to the current support of the "wheel" event on Safari, the function\nmay only work as expected if "return false" is included while using Safari.
\n',itemtype:"method",name:"mouseWheel",params:[{name:"event",description:"optional WheelEvent callback argument.
\n",type:"Object",optional:!0}],example:["\n\n\nlet pos = 25;\n\nfunction draw() {\n background(237, 34, 93);\n fill(0);\n rect(25, pos, 50, 50);\n}\n\nfunction mouseWheel(event) {\n print(event.delta);\n //move the square according to the vertical scroll amount\n pos += event.delta;\n //uncomment to block page scrolling\n //return false;\n}\n
\n"],alt:"black 50x50 rect moves up and down with vertical scroll. fuchsia background",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:999,description:'The function requestPointerLock()\nlocks the pointer to its current position and makes it invisible.\nUse movedX and movedY to get the difference the mouse was moved since\nthe last call of draw
\nNote that not all browsers support this feature
\nThis enables you to create experiences that aren\'t limited by the mouse moving out of the screen\neven if it is repeatedly moved into one direction.
\nFor example a first person perspective experience
',itemtype:"method",name:"requestPointerLock",example:['\n\n\nlet cam;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n requestPointerLock();\n cam = createCamera();\n}\n\nfunction draw() {\n background(255);\n cam.pan(-movedX * 0.001);\n cam.tilt(movedY * 0.001);\n sphere(25);\n}\n
\n'],alt:"3D scene moves according to mouse mouse movement in a first person perspective",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/mouse.js",line:1046,description:'The function exitPointerLock()\nexits a previously triggered pointer Lock\nfor example to make ui elements usable etc',itemtype:"method",name:"exitPointerLock",example:['\n
\n\n//click the canvas to lock the pointer\n//click again to exit (otherwise escape)\nlet locked = false;\nfunction draw() {\n background(237, 34, 93);\n}\nfunction mouseClicked() {\n if (!locked) {\n locked = true;\n requestPointerLock();\n } else {\n exitPointerLock();\n locked = false;\n }\n}\n
\n'],alt:"cursor gets locked / unlocked on mouse-click",class:"p5",module:"Events",submodule:"Mouse"},{file:"src/events/touch.js",line:10,description:"The system variable touches[] contains an array of the positions of all\ncurrent touch points, relative to (0, 0) of the canvas, and IDs identifying a\nunique touch as it moves. Each element in the array is an object with x, y,\nand id properties.
\nThe touches[] array is not supported on Safari and IE on touch-based\ndesktops (laptops).
\n",itemtype:"property",name:"touches",type:"Object[]",readonly:"",example:["\n\n\n// On a touchscreen device, touch\n// the canvas using one or more fingers\n// at the same time\nfunction draw() {\n clear();\n let display = touches.length + ' touches';\n text(display, 5, 10);\n}\n
\n"],alt:"Number of touches currently registered are displayed on the canvas",class:"p5",module:"Events",submodule:"Touch"},{file:"src/events/touch.js",line:71,description:'The touchStarted() function is called once after every time a touch is\nregistered. If no touchStarted() function is defined, the mousePressed()\nfunction will be called instead if it is defined.
\nBrowsers may have different default behaviors attached to various touch\nevents. To prevent any default behavior for this event, add "return false"\nto the end of the method.
\n',itemtype:"method",name:"touchStarted",params:[{name:"event",description:"optional TouchEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Touch within the image to change\n// the value of the rectangle\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction touchStarted() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction touchStarted() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a TouchEvent object\n// as a callback argument\nfunction touchStarted(event) {\n console.log(event);\n}\n
\n'],alt:"50x50 black rect turns white with touch event.\nno image displayed",class:"p5",module:"Events",submodule:"Touch"},{file:"src/events/touch.js",line:151,description:'The touchMoved() function is called every time a touch move is registered.\nIf no touchMoved() function is defined, the mouseDragged() function will\nbe called instead if it is defined.
\nBrowsers may have different default behaviors attached to various touch\nevents. To prevent any default behavior for this event, add "return false"\nto the end of the method.
\n',itemtype:"method",name:"touchMoved",params:[{name:"event",description:"optional TouchEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Move your finger across the page\n// to change its value\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction touchMoved() {\n value = value + 5;\n if (value > 255) {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction touchMoved() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a TouchEvent object\n// as a callback argument\nfunction touchMoved(event) {\n console.log(event);\n}\n
\n'],alt:"50x50 black rect turns lighter with touch until white. resets\nno image displayed",class:"p5",module:"Events",submodule:"Touch"},{file:"src/events/touch.js",line:224,description:'The touchEnded() function is called every time a touch ends. If no\ntouchEnded() function is defined, the mouseReleased() function will be\ncalled instead if it is defined.
\nBrowsers may have different default behaviors attached to various touch\nevents. To prevent any default behavior for this event, add "return false"\nto the end of the method.
\n',itemtype:"method",name:"touchEnded",params:[{name:"event",description:"optional TouchEvent callback argument.
\n",type:"Object",optional:!0}],example:['\n\n\n// Release touch within the image to\n// change the value of the rectangle\n\nlet value = 0;\nfunction draw() {\n fill(value);\n rect(25, 25, 50, 50);\n}\nfunction touchEnded() {\n if (value === 0) {\n value = 255;\n } else {\n value = 0;\n }\n}\n
\n\n\n\n\nfunction touchEnded() {\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}\n
\n\n\n\n\n// returns a TouchEvent object\n// as a callback argument\nfunction touchEnded(event) {\n console.log(event);\n}\n
\n'],alt:"50x50 black rect turns white with touch.\nno image displayed",class:"p5",module:"Events",submodule:"Touch"},{file:"src/image/filters.js",line:3,description:'This module defines the filters for use with image buffers.
\nThis module is basically a collection of functions stored in an object\nas opposed to modules. The functions are destructive, modifying\nthe passed in canvas rather than creating a copy.
\nGenerally speaking users of this module will use the Filters.apply method\non a canvas to create an effect.
\nA number of functions are borrowed/adapted from\nhttp://www.html5rocks.com/en/tutorials/canvas/imagefilters/\nor the java processing implementation.
\n',class:"p5",module:"Events"},{file:"src/image/image.js",line:8,description:'This module defines the p5 methods for the p5.Image class\nfor drawing images to the main display canvas.
\n',class:"p5",module:"Image",submodule:"Image"},{file:"src/image/image.js",line:22,description:'Creates a new p5.Image (the datatype for storing images). This provides a\nfresh buffer of pixels to play with. Set the size of the buffer with the\nwidth and height parameters.\n
\n.pixels gives access to an array containing the values for all the pixels\nin the display window.\nThese values are numbers. This array is the size (including an appropriate\nfactor for the pixelDensity) of the display window x4,\nrepresenting the R, G, B, A values in order for each pixel, moving from\nleft to right across each row, then down each column. See .pixels for\nmore info. It may also be simpler to use set() or get().\n
\nBefore accessing the pixels of an image, the data must loaded with the\nloadPixels() function. After the array data has been modified, the\nupdatePixels() function must be run to update the changes.
\n',itemtype:"method",name:"createImage",params:[{name:"width",description:"width in pixels
\n",type:"Integer"},{name:"height",description:"height in pixels
\n",type:"Integer"}],return:{description:'the p5.Image object',type:"p5.Image"},example:["\n\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let i = 0; i < img.width; i++) {\n for (let j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n
\n\n\n\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let i = 0; i < img.width; i++) {\n for (let j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102, (i % img.width) * 2));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\nimage(img, 34, 34);\n
\n\n\n\n\nlet pink = color(255, 102, 204);\nlet img = createImage(66, 66);\nimg.loadPixels();\nlet d = pixelDensity();\nlet halfImage = 4 * (img.width * d) * (img.height / 2 * d);\nfor (let i = 0; i < halfImage; i += 4) {\n img.pixels[i] = red(pink);\n img.pixels[i + 1] = green(pink);\n img.pixels[i + 2] = blue(pink);\n img.pixels[i + 3] = alpha(pink);\n}\nimg.updatePixels();\nimage(img, 17, 17);\n
\n"],alt:"66x66 dark turquoise rect in center of canvas.\n2 gradated dark turquoise rects fade left. 1 center 1 bottom right of canvas\nno image displayed",class:"p5",module:"Image",submodule:"Image"},{file:"src/image/image.js",line:102,description:"Save the current canvas as an image. The browser will either save the\nfile immediately, or prompt the user with a dialogue window.
\n",itemtype:"method",name:"saveCanvas",example:["\n \n function setup() {\n let c = createCanvas(100, 100);\n background(255, 0, 0);\n saveCanvas(c, 'myCanvas', 'jpg');\n }\n
\n \n // note that this example has the same result as above\n // if no canvas is specified, defaults to main canvas\n function setup() {\n let c = createCanvas(100, 100);\n background(255, 0, 0);\n saveCanvas('myCanvas', 'jpg');\n\n // all of the following are valid\n saveCanvas(c, 'myCanvas', 'jpg');\n saveCanvas(c, 'myCanvas.jpg');\n saveCanvas(c, 'myCanvas');\n saveCanvas(c);\n saveCanvas('myCanvas', 'png');\n saveCanvas('myCanvas');\n saveCanvas();\n }\n
"],alt:"no image displayed\n no image displayed\n no image displayed",class:"p5",module:"Image",submodule:"Image",overloads:[{line:102,params:[{name:"selectedCanvas",description:"a variable\n representing a specific html5 canvas (optional)
\n",type:"p5.Element|HTMLCanvasElement"},{name:"filename",description:"",type:"String",optional:!0},{name:"extension",description:"'jpg' or 'png'
\n",type:"String",optional:!0}]},{line:144,params:[{name:"filename",description:"",type:"String",optional:!0},{name:"extension",description:"",type:"String",optional:!0}]}]},{file:"src/image/image.js",line:246,description:'Capture a sequence of frames that can be used to create a movie.\nAccepts a callback. For example, you may wish to send the frames\nto a server where they can be stored or converted into a movie.\nIf no callback is provided, the browser will pop up save dialogues in an\nattempt to download all of the images that have just been created. With the\ncallback provided the image data isn't saved by default but instead passed\nas an argument to the callback function as an array of objects, with the\nsize of array equal to the total number of frames.
\nNote that saveFrames() will only save the first 15 frames of an animation.\nTo export longer animations, you might look into a library like\nccapture.js.
\n',itemtype:"method",name:"saveFrames",params:[{name:"filename",description:"",type:"String"},{name:"extension",description:"'jpg' or 'png'
\n",type:"String"},{name:"duration",description:"Duration in seconds to save the frames for.
\n",type:"Number"},{name:"framerate",description:"Framerate to save the frames in.
\n",type:"Number"},{name:"callback",description:"A callback function that will be executed\n to handle the image data. This function\n should accept an array as argument. The\n array will contain the specified number of\n frames of objects. Each object has three\n properties: imageData - an\n image/octet-stream, filename and extension.
\n",type:"Function(Array)",optional:!0}],example:["\n\n function draw() {\n background(mouseX);\n }\n\n function mousePressed() {\n saveFrames('out', 'png', 1, 25, data => {\n print(data);\n });\n }\n
"],alt:"canvas background goes from light to dark with mouse x.",class:"p5",module:"Image",submodule:"Image"},{file:"src/image/loading_displaying.js",line:16,description:'Loads an image from a path and creates a p5.Image from it.\n
\nThe image may not be immediately available for rendering\nIf you want to ensure that the image is ready before doing\nanything with it, place the loadImage() call in preload().\nYou may also supply a callback function to handle the image when it's ready.\n
\nThe path to the image should be relative to the HTML file\nthat links in your sketch. Loading an image from a URL or other\nremote location may be blocked due to your browser's built-in\nsecurity.
\n',itemtype:"method",name:"loadImage",params:[{name:"path",description:"Path of the image to be loaded
\n",type:"String"},{name:"successCallback",description:'Function to be called once\n the image is loaded. Will be passed the\n p5.Image.
\n',type:"function(p5.Image)",optional:!0},{name:"failureCallback",description:"called with event error if\n the image fails to load.
\n",type:"Function(Event)",optional:!0}],return:{description:'the p5.Image object',type:"p5.Image"},example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n}\n
\n\n\n\nfunction setup() {\n // here we use a callback to display the image after loading\n loadImage('assets/laDefense.jpg', img => {\n image(img, 0, 0);\n });\n}\n
\n"],alt:"image of the underside of a white umbrella and grided ceililng above\nimage of the underside of a white umbrella and grided ceililng above",class:"p5",module:"Image",submodule:"Loading & Displaying"},{file:"src/image/loading_displaying.js",line:149,description:"Helper function for loading GIF-based images
\n",class:"p5",module:"Image",submodule:"Loading & Displaying"},{file:"src/image/loading_displaying.js",line:247,description:'Draw an image to the p5.js canvas.
\nThis function can be used with different numbers of parameters. The\nsimplest use requires only three parameters: img, x, and y—where (x, y) is\nthe position of the image. Two more parameters can optionally be added to\nspecify the width and height of the image.
\nThis function can also be used with all eight Number parameters. To\ndifferentiate between all these parameters, p5.js uses the language of\n"destination rectangle" (which corresponds to "dx", "dy", etc.) and "source\nimage" (which corresponds to "sx", "sy", etc.) below. Specifying the\n"source image" dimensions can be useful when you want to display a\nsubsection of the source image instead of the whole thing. Here's a diagram\nto explain further:\n
\n',itemtype:"method",name:"image",example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\nfunction setup() {\n // Top-left corner of the img is at (0, 0)\n // Width and height are the img's original width and height\n image(img, 0, 0);\n}\n
\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\nfunction setup() {\n background(50);\n // Top-left corner of the img is at (10, 10)\n // Width and height are 50 x 50\n image(img, 10, 10, 50, 50);\n}\n
\n\n\n\nfunction setup() {\n // Here, we use a callback to display the image after loading\n loadImage('assets/laDefense.jpg', img => {\n image(img, 0, 0);\n });\n}\n
\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/gradient.png');\n}\nfunction setup() {\n // 1. Background image\n // Top-left corner of the img is at (0, 0)\n // Width and height are the img's original width and height, 100 x 100\n image(img, 0, 0);\n // 2. Top right image\n // Top-left corner of destination rectangle is at (50, 0)\n // Destination rectangle width and height are 40 x 20\n // The next parameters are relative to the source image:\n // - Starting at position (50, 50) on the source image, capture a 50 x 50\n // subsection\n // - Draw this subsection to fill the dimensions of the destination rectangle\n image(img, 50, 0, 40, 20, 50, 50, 50, 50);\n}\n
\n"],alt:"image of the underside of a white umbrella and gridded ceiling above\nimage of the underside of a white umbrella and gridded ceiling above",class:"p5",module:"Image",submodule:"Loading & Displaying",overloads:[{line:247,params:[{name:"img",description:"the image to display
\n",type:"p5.Image|p5.Element"},{name:"x",description:"the x-coordinate of the top-left corner of the image
\n",type:"Number"},{name:"y",description:"the y-coordinate of the top-left corner of the image
\n",type:"Number"},{name:"width",description:"the width to draw the image
\n",type:"Number",optional:!0},{name:"height",description:"the height to draw the image
\n",type:"Number",optional:!0}]},{line:335,params:[{name:"img",description:"",type:"p5.Image|p5.Element"},{name:"dx",description:"the x-coordinate of the destination\n rectangle in which to draw the source image
\n",type:"Number"},{name:"dy",description:"the y-coordinate of the destination\n rectangle in which to draw the source image
\n",type:"Number"},{name:"dWidth",description:"the width of the destination rectangle
\n",type:"Number"},{name:"dHeight",description:"the height of the destination rectangle
\n",type:"Number"},{name:"sx",description:"the x-coordinate of the subsection of the source\nimage to draw into the destination rectangle
\n",type:"Number"},{name:"sy",description:"the y-coordinate of the subsection of the source\nimage to draw into the destination rectangle
\n",type:"Number"},{name:"sWidth",description:"the width of the subsection of the\n source image to draw into the destination\n rectangle
\n",type:"Number",optional:!0},{name:"sHeight",description:"the height of the subsection of the\n source image to draw into the destination rectangle
\n",type:"Number",optional:!0}]}]},{file:"src/image/loading_displaying.js",line:418,description:'Sets the fill value for displaying images. Images can be tinted to\nspecified colors or made transparent by including an alpha value.\n
\nTo apply transparency to an image without affecting its color, use\nwhite as the tint color and specify an alpha value. For instance,\ntint(255, 128) will make an image 50% transparent (assuming the default\nalpha range of 0-255, which can be changed with colorMode()).\n
\nThe value for the gray parameter must be less than or equal to the current\nmaximum value as specified by colorMode(). The default maximum value is\n255.
\n',itemtype:"method",name:"tint",example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n tint(0, 153, 204); // Tint blue\n image(img, 50, 0);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n tint(0, 153, 204, 126); // Tint blue and set transparency\n image(img, 50, 0);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n tint(255, 126); // Apply transparency without changing color\n image(img, 50, 0);\n}\n
\n"],alt:"2 side by side images of umbrella and ceiling, one image with blue tint\nImages of umbrella and ceiling, one half of image with blue tint\n2 side by side images of umbrella and ceiling, one image translucent",class:"p5",module:"Image",submodule:"Loading & Displaying",overloads:[{line:418,params:[{name:"v1",description:"red or hue value relative to\n the current color range
\n",type:"Number"},{name:"v2",description:"green or saturation value\n relative to the current color range
\n",type:"Number"},{name:"v3",description:"blue or brightness value\n relative to the current color range
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}]},{line:491,params:[{name:"value",description:"a color string
\n",type:"String"}]},{line:496,params:[{name:"gray",description:"a gray value
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}]},{line:502,params:[{name:"values",description:"an array containing the red,green,blue &\n and alpha components of the color
\n",type:"Number[]"}]},{line:508,params:[{name:"color",description:"the tint color
\n",type:"p5.Color"}]}]},{file:"src/image/loading_displaying.js",line:518,description:"Removes the current fill value for displaying images and reverts to\ndisplaying images with their original hues.
\n",itemtype:"method",name:"noTint",example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n tint(0, 153, 204); // Tint blue\n image(img, 0, 0);\n noTint(); // Disable tint\n image(img, 50, 0);\n}\n
\n"],alt:"2 side by side images of bricks, left image with blue tint",class:"p5",module:"Image",submodule:"Loading & Displaying"},{file:"src/image/loading_displaying.js",line:584,description:'Set image mode. Modifies the location from which images are drawn by\nchanging the way in which parameters given to image() are interpreted.\nThe default mode is imageMode(CORNER), which interprets the second and\nthird parameters of image() as the upper-left corner of the image. If\ntwo additional parameters are specified, they are used to set the image's\nwidth and height.\n
\nimageMode(CORNERS) interprets the second and third parameters of image()\nas the location of one corner, and the fourth and fifth parameters as the\nopposite corner.\n
\nimageMode(CENTER) interprets the second and third parameters of image()\nas the image's center point. If two additional parameters are specified,\nthey are used to set the image's width and height.
\n',itemtype:"method",name:"imageMode",params:[{name:"mode",description:"either CORNER, CORNERS, or CENTER
\n",type:"Constant"}],example:["\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n imageMode(CORNER);\n image(img, 10, 10, 50, 50);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n imageMode(CORNERS);\n image(img, 10, 10, 90, 40);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n imageMode(CENTER);\n image(img, 50, 50, 80, 80);\n}\n
\n"],alt:"small square image of bricks\nhorizontal rectangle image of bricks\nlarge square image of bricks",class:"p5",module:"Image",submodule:"Loading & Displaying"},{file:"src/image/p5.Image.js",line:9,description:'This module defines the p5.Image class and P5 methods for\ndrawing images to the main display canvas.
\n',class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:89,description:"Image width.
\n",itemtype:"property",name:"width",type:"Number",readonly:"",example:["\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100);\n image(img, 0, 0);\n for (let i = 0; i < img.width; i++) {\n let c = img.get(i, img.height / 2);\n stroke(c);\n line(i, height / 2, i, height);\n }\n}\n
"],alt:"rocky mountains in top and horizontal lines in corresponding colors in bottom.",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:116,description:"Image height.
\n",itemtype:"property",name:"height",type:"Number",readonly:"",example:["\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100);\n image(img, 0, 0);\n for (let i = 0; i < img.height; i++) {\n let c = img.get(img.width / 2, i);\n stroke(c);\n line(0, i, width / 2, i);\n }\n}\n
"],alt:"rocky mountains on right and vertical lines in corresponding colors on left.",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:153,description:'Array containing the values for all the pixels in the display window.\nThese values are numbers. This array is the size (include an appropriate\nfactor for pixelDensity) of the display window x4,\nrepresenting the R, G, B, A values in order for each pixel, moving from\nleft to right across each row, then down each column. Retina and other\nhigh density displays may have more pixels (by a factor of\npixelDensity^2).\nFor example, if the image is 100x100 pixels, there will be 40,000. With\npixelDensity = 2, there will be 160,000. The first four values\n(indices 0-3) in the array will be the R, G, B, A values of the pixel at\n(0, 0). The second four values (indices 4-7) will contain the R, G, B, A\nvalues of the pixel at (1, 0). More generally, to set values for a pixel\nat (x, y):
\nlet d = pixelDensity();\nfor (let i = 0; i < d; i++) {\n for (let j = 0; j < d; j++) {\n // loop over\n index = 4 * ((y * d + j) * width * d + (x * d + i));\n pixels[index] = r;\n pixels[index+1] = g;\n pixels[index+2] = b;\n pixels[index+3] = a;\n }\n}
\n
\nBefore accessing this array, the data must loaded with the loadPixels()\nfunction. After the array data has been modified, the updatePixels()\nfunction must be run to update the changes.
\n',itemtype:"property",name:"pixels",type:"Number[]",example:["\n\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let i = 0; i < img.width; i++) {\n for (let j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\n
\n\n\n\nlet pink = color(255, 102, 204);\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let i = 0; i < 4 * (width * height / 2); i += 4) {\n img.pixels[i] = red(pink);\n img.pixels[i + 1] = green(pink);\n img.pixels[i + 2] = blue(pink);\n img.pixels[i + 3] = alpha(pink);\n}\nimg.updatePixels();\nimage(img, 17, 17);\n
\n"],alt:"66x66 turquoise rect in center of canvas\n66x66 pink rect in center of canvas",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:223,description:"Helper function for animating GIF-based images with time
\n",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:250,description:"Helper fxn for sharing pixel methods
\n",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:259,description:"Loads the pixels data for this image into the [pixels] attribute.
\n",itemtype:"method",name:"loadPixels",example:["\n\nlet myImage;\nlet halfImage;\n\nfunction preload() {\n myImage = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n myImage.loadPixels();\n halfImage = 4 * myImage.width * myImage.height / 2;\n for (let i = 0; i < halfImage; i++) {\n myImage.pixels[i + halfImage] = myImage.pixels[i];\n }\n myImage.updatePixels();\n}\n\nfunction draw() {\n image(myImage, 0, 0, width, height);\n}\n
"],alt:"2 images of rocky mountains vertically stacked",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:295,description:"Updates the backing canvas for this image with the contents of\nthe [pixels] array.\n
\nIf this image is an animated GIF then the pixels will be updated\nin the frame that is currently displayed.
\n",itemtype:"method",name:"updatePixels",example:["\n\nlet myImage;\nlet halfImage;\n\nfunction preload() {\n myImage = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n myImage.loadPixels();\n halfImage = 4 * myImage.width * myImage.height / 2;\n for (let i = 0; i < halfImage; i++) {\n myImage.pixels[i + halfImage] = myImage.pixels[i];\n }\n myImage.updatePixels();\n}\n\nfunction draw() {\n image(myImage, 0, 0, width, height);\n}\n
"],alt:"2 images of rocky mountains vertically stacked",class:"p5.Image",module:"Image",submodule:"Image",overloads:[{line:295,params:[{name:"x",description:"x-offset of the target update area for the\n underlying canvas
\n",type:"Integer"},{name:"y",description:"y-offset of the target update area for the\n underlying canvas
\n",type:"Integer"},{name:"w",description:"height of the target update area for the\n underlying canvas
\n",type:"Integer"},{name:"h",description:"height of the target update area for the\n underlying canvas
\n",type:"Integer"}]},{line:338,params:[]}]},{file:"src/image/p5.Image.js",line:346,description:'Get a region of pixels from an image.
\nIf no params are passed, the whole image is returned.\nIf x and y are the only params passed a single pixel is extracted.\nIf all params are passed a rectangle region is extracted and a p5.Image\nis returned.
\n',itemtype:"method",name:"get",return:{description:'the rectangle p5.Image',type:"p5.Image"},example:["\n\nlet myImage;\nlet c;\n\nfunction preload() {\n myImage = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n background(myImage);\n noStroke();\n c = myImage.get(60, 90);\n fill(c);\n rect(25, 25, 50, 50);\n}\n\n//get() returns color here\n
"],alt:"image of rocky mountains with 50x50 green rect in front",class:"p5.Image",module:"Image",submodule:"Image",overloads:[{line:346,params:[{name:"x",description:"x-coordinate of the pixel
\n",type:"Number"},{name:"y",description:"y-coordinate of the pixel
\n",type:"Number"},{name:"w",description:"width
\n",type:"Number"},{name:"h",description:"height
\n",type:"Number"}],return:{description:'the rectangle p5.Image',type:"p5.Image"}},{line:384,params:[],return:{description:'the whole p5.Image',type:"p5.Image"}},{line:388,params:[{name:"x",description:"",type:"Number"},{name:"y",description:"",type:"Number"}],return:{description:"color of pixel at x,y in array format [R, G, B, A]",type:"Number[]"}}]},{file:"src/image/p5.Image.js",line:401,description:'Set the color of a single pixel or write an image into\nthis p5.Image.
\nNote that for a large number of pixels this will\nbe slower than directly manipulating the pixels array\nand then calling updatePixels().
\n',itemtype:"method",name:"set",params:[{name:"x",description:"x-coordinate of the pixel
\n",type:"Number"},{name:"y",description:"y-coordinate of the pixel
\n",type:"Number"},{name:"a",description:'grayscale value | pixel array |\n a p5.Color | image to copy
\n',type:"Number|Number[]|Object"}],example:["\n\n\nlet img = createImage(66, 66);\nimg.loadPixels();\nfor (let i = 0; i < img.width; i++) {\n for (let j = 0; j < img.height; j++) {\n img.set(i, j, color(0, 90, 102, (i % img.width) * 2));\n }\n}\nimg.updatePixels();\nimage(img, 17, 17);\nimage(img, 34, 34);\n
\n"],alt:"2 gradated dark turquoise rects fade left. 1 center 1 bottom right of canvas",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:439,description:"Resize the image to a new width and height. To make the image scale\nproportionally, use 0 as the value for the wide or high parameter.\nFor instance, to make the width of an image 150 pixels, and change\nthe height using the same proportion, use resize(150, 0).
\n",itemtype:"method",name:"resize",params:[{name:"width",description:"the resized image width
\n",type:"Number"},{name:"height",description:"the resized image height
\n",type:"Number"}],example:["\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction draw() {\n image(img, 0, 0);\n}\n\nfunction mousePressed() {\n img.resize(50, 100);\n}\n
"],alt:"image of rocky mountains. zoomed in",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:551,description:"Copies a region of pixels from one image to another. If no\nsrcImage is specified this is used as the source. If the source\nand destination regions aren't the same size, it will\nautomatically resize source pixels to fit the specified\ntarget region.
\n",itemtype:"method",name:"copy",example:["\n\nlet photo;\nlet bricks;\nlet x;\nlet y;\n\nfunction preload() {\n photo = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks.jpg');\n}\n\nfunction setup() {\n x = bricks.width / 2;\n y = bricks.height / 2;\n photo.copy(bricks, 0, 0, x, y, 0, 0, x, y);\n image(photo, 0, 0);\n}\n
"],alt:"image of rocky mountains and smaller image on top of bricks at top left",class:"p5.Image",module:"Image",submodule:"Image",overloads:[{line:551,params:[{name:"srcImage",description:"source image
\n",type:"p5.Image|p5.Element"},{name:"sx",description:"X coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sy",description:"Y coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sw",description:"source image width
\n",type:"Integer"},{name:"sh",description:"source image height
\n",type:"Integer"},{name:"dx",description:"X coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dy",description:"Y coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dw",description:"destination image width
\n",type:"Integer"},{name:"dh",description:"destination image height
\n",type:"Integer"}]},{line:592,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:607,description:"Masks part of an image from displaying by loading another\nimage and using its alpha channel as an alpha channel for\nthis image.
\n",itemtype:"method",name:"mask",params:[{name:"srcImage",description:"source image
\n",type:"p5.Image"}],example:["\n\nlet photo, maskImage;\nfunction preload() {\n photo = loadImage('assets/rockies.jpg');\n maskImage = loadImage('assets/mask2.png');\n}\n\nfunction setup() {\n createCanvas(100, 100);\n photo.mask(maskImage);\n image(photo, 0, 0);\n}\n
"],alt:"image of rocky mountains with white at right\n\n\nhttp://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:670,description:'Applies an image filter to a p5.Image
\n',itemtype:"method",name:"filter",params:[{name:"filterType",description:"either THRESHOLD, GRAY, OPAQUE, INVERT,\n POSTERIZE, BLUR, ERODE, DILATE or BLUR.\n See Filters.js for docs on\n each available filter
\n",type:"Constant"},{name:"filterParam",description:"an optional parameter unique\n to each filter, see above
\n",type:"Number",optional:!0}],example:["\n\nlet photo1;\nlet photo2;\n\nfunction preload() {\n photo1 = loadImage('assets/rockies.jpg');\n photo2 = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n photo2.filter(GRAY);\n image(photo1, 0, 0);\n image(photo2, width / 2, 0);\n}\n
"],alt:"2 images of rocky mountains left one in color, right in black and white",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:706,description:"Copies a region of pixels from one image to another, using a specified\nblend mode to do the operation.
\n",itemtype:"method",name:"blend",example:["\n\nlet mountains;\nlet bricks;\n\nfunction preload() {\n mountains = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, ADD);\n image(mountains, 0, 0);\n image(bricks, 0, 0);\n}\n
\n\nlet mountains;\nlet bricks;\n\nfunction preload() {\n mountains = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST);\n image(mountains, 0, 0);\n image(bricks, 0, 0);\n}\n
\n\nlet mountains;\nlet bricks;\n\nfunction preload() {\n mountains = loadImage('assets/rockies.jpg');\n bricks = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n mountains.blend(bricks, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST);\n image(mountains, 0, 0);\n image(bricks, 0, 0);\n}\n
"],alt:"image of rocky mountains. Brick images on left and right. Right overexposed\nimage of rockies. Brickwall images on left and right. Right mortar transparent\nimage of rockies. Brickwall images on left and right. Right translucent",class:"p5.Image",module:"Image",submodule:"Image",overloads:[{line:706,params:[{name:"srcImage",description:"source image
\n",type:"p5.Image"},{name:"sx",description:"X coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sy",description:"Y coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sw",description:"source image width
\n",type:"Integer"},{name:"sh",description:"source image height
\n",type:"Integer"},{name:"dx",description:"X coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dy",description:"Y coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dw",description:"destination image width
\n",type:"Integer"},{name:"dh",description:"destination image height
\n",type:"Integer"},{name:"blendMode",description:'the blend mode. either\n BLEND, DARKEST, LIGHTEST, DIFFERENCE,\n MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.
\nAvailable blend modes are: normal | multiply | screen | overlay |\n darken | lighten | color-dodge | color-burn | hard-light |\n soft-light | difference | exclusion | hue | saturation |\n color | luminosity
\nhttp://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/
\n',type:"Constant"}]},{line:785,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:828,description:"Saves the image to a file and force the browser to download it.\nAccepts two strings for filename and file extension\nSupports png (default), jpg, and gif\n
\nNote that the file will only be downloaded as an animated GIF\nif the p5.Image was loaded from a GIF file.
\n",itemtype:"method",name:"save",params:[{name:"filename",description:"give your file a name
\n",type:"String"},{name:"extension",description:"'png' or 'jpg'
\n",type:"String"}],example:["\n\nlet photo;\n\nfunction preload() {\n photo = loadImage('assets/rockies.jpg');\n}\n\nfunction draw() {\n image(photo, 0, 0);\n}\n\nfunction keyTyped() {\n if (key === 's') {\n photo.save('photo', 'png');\n }\n}\n
"],alt:"image of rocky mountains.",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:870,description:"Starts an animated GIF over at the beginning state.
\n",itemtype:"method",name:"reset",example:["\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-wink-loop-once.gif');\n}\n\nfunction draw() {\n background(255);\n // The GIF file that we loaded only loops once\n // so it freezes on the last frame after playing through\n image(gif, 0, 0);\n}\n\nfunction mousePressed() {\n // Click to reset the GIF and begin playback from start\n gif.reset();\n}\n
"],alt:"Animated image of a cartoon face that winks once and then freezes\nWhen you click it animates again, winks once and freezes",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:911,description:"Gets the index for the frame that is currently visible in an animated GIF.
\n",itemtype:"method",name:"getCurrentFrame",return:{description:"The index for the currently displaying frame in animated GIF",type:"Number"},example:["\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction draw() {\n let frame = gif.getCurrentFrame();\n image(gif, 0, 0);\n text(frame, 10, 90);\n}\n
"],alt:"Animated image of a cartoon eye looking around and then\nlooking outwards, in the lower-left hand corner a number counts\nup quickly to 124 and then starts back over at 0",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:943,description:"Sets the index of the frame that is currently visible in an animated GIF
\n",itemtype:"method",name:"setFrame",params:[{name:"index",description:"the index for the frame that should be displayed
\n",type:"Number"}],example:["\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\n// Move your mouse up and down over canvas to see the GIF\n// frames animate\nfunction draw() {\n gif.pause();\n image(gif, 0, 0);\n // Get the highest frame number which is the number of frames - 1\n let maxFrame = gif.numFrames() - 1;\n // Set the current frame that is mapped to be relative to mouse position\n let frameNumber = floor(map(mouseY, 0, height, 0, maxFrame, true));\n gif.setFrame(frameNumber);\n}\n
"],alt:"A still image of a cartoon eye that looks around when you move your mouse\nup and down over the canvas",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:988,description:"Returns the number of frames in an animated GIF
\n",itemtype:"method",name:"numFrames",return:{description:"",type:"Number"},example:[" The number of frames in the animated GIF\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\n// Move your mouse up and down over canvas to see the GIF\n// frames animate\nfunction draw() {\n gif.pause();\n image(gif, 0, 0);\n // Get the highest frame number which is the number of frames - 1\n let maxFrame = gif.numFrames() - 1;\n // Set the current frame that is mapped to be relative to mouse position\n let frameNumber = floor(map(mouseY, 0, height, 0, maxFrame, true));\n gif.setFrame(frameNumber);\n}\n
"],alt:"A still image of a cartoon eye that looks around when you move your mouse\nup and down over the canvas",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:1024,description:'Plays an animated GIF that was paused with\npause()
\n',itemtype:"method",name:"play",example:["\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/nancy-liang-wind-loop-forever.gif');\n}\n\nfunction draw() {\n background(255);\n image(gif, 0, 0);\n}\n\nfunction mousePressed() {\n gif.pause();\n}\n\nfunction mouseReleased() {\n gif.play();\n}\n
"],alt:"An animated GIF of a drawing of small child with\nhair blowing in the wind, when you click the image\nfreezes when you release it animates again",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:1062,description:"Pauses an animated GIF.
\n",itemtype:"method",name:"pause",example:["\n\nlet gif;\n\nfunction preload() {\n gif = loadImage('assets/nancy-liang-wind-loop-forever.gif');\n}\n\nfunction draw() {\n background(255);\n image(gif, 0, 0);\n}\n\nfunction mousePressed() {\n gif.pause();\n}\n\nfunction mouseReleased() {\n gif.play();\n}\n
"],alt:"An animated GIF of a drawing of small child with\nhair blowing in the wind, when you click the image\nfreezes when you release it animates again",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/p5.Image.js",line:1099,description:"Changes the delay between frames in an animated GIF. There is an optional second parameter that\nindicates an index for a specific frame that should have its delay modified. If no index is given, all frames\nwill have the new delay.
\n",itemtype:"method",name:"delay",params:[{name:"d",description:"the amount in milliseconds to delay between switching frames
\n",type:"Number"},{name:"index",description:"the index of the frame that should have the new delay value {optional}
\n",type:"Number",optional:!0}],example:["\n\nlet gifFast, gifSlow;\n\nfunction preload() {\n gifFast = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n gifSlow = loadImage('assets/arnott-wallace-eye-loop-forever.gif');\n}\n\nfunction setup() {\n gifFast.resize(width / 2, height / 2);\n gifSlow.resize(width / 2, height / 2);\n\n //Change the delay here\n gifFast.delay(10);\n gifSlow.delay(100);\n}\n\nfunction draw() {\n background(255);\n image(gifFast, 0, 0);\n image(gifSlow, width / 2, 0);\n}\n
"],alt:"Two animated gifs of cartoon eyes looking around\nThe gif on the left animates quickly, on the right\nthe animation is much slower",class:"p5.Image",module:"Image",submodule:"Image"},{file:"src/image/pixels.js",line:12,description:'Uint8ClampedArray\ncontaining the values for all the pixels in the display window.\nThese values are numbers. This array is the size (include an appropriate\nfactor for pixelDensity) of the display window x4,\nrepresenting the R, G, B, A values in order for each pixel, moving from\nleft to right across each row, then down each column. Retina and other\nhigh density displays will have more pixels[] (by a factor of\npixelDensity^2).\nFor example, if the image is 100x100 pixels, there will be 40,000. On a\nretina display, there will be 160,000.\n
\nThe first four values (indices 0-3) in the array will be the R, G, B, A\nvalues of the pixel at (0, 0). The second four values (indices 4-7) will\ncontain the R, G, B, A values of the pixel at (1, 0). More generally, to\nset values for a pixel at (x, y):
\nlet d = pixelDensity();\nfor (let i = 0; i < d; i++) {\n for (let j = 0; j < d; j++) {\n // loop over\n index = 4 * ((y * d + j) * width * d + (x * d + i));\n pixels[index] = r;\n pixels[index+1] = g;\n pixels[index+2] = b;\n pixels[index+3] = a;\n }\n}
\nWhile the above method is complex, it is flexible enough to work with\nany pixelDensity. Note that set() will automatically take care of\nsetting all the appropriate values in pixels[] for a given (x, y) at\nany pixelDensity, but the performance may not be as fast when lots of\nmodifications are made to the pixel array.\n
\nBefore accessing this array, the data must loaded with the loadPixels()\nfunction. After the array data has been modified, the updatePixels()\nfunction must be run to update the changes.\n
\nNote that this is not a standard javascript array. This means that\nstandard javascript functions such as slice() or\narrayCopy() do not\nwork.
',itemtype:"property",name:"pixels",type:"Number[]",example:["\n\n\nlet pink = color(255, 102, 204);\nloadPixels();\nlet d = pixelDensity();\nlet halfImage = 4 * (width * d) * (height / 2 * d);\nfor (let i = 0; i < halfImage; i += 4) {\n pixels[i] = red(pink);\n pixels[i + 1] = green(pink);\n pixels[i + 2] = blue(pink);\n pixels[i + 3] = alpha(pink);\n}\nupdatePixels();\n
\n"],alt:"top half of canvas pink, bottom grey",class:"p5",module:"Image",submodule:"Pixels"},{file:"src/image/pixels.js",line:81,description:"Copies a region of pixels from one image to another, using a specified\nblend mode to do the operation.
\n",itemtype:"method",name:"blend",example:["\n\nlet img0;\nlet img1;\n\nfunction preload() {\n img0 = loadImage('assets/rockies.jpg');\n img1 = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n background(img0);\n image(img1, 0, 0);\n blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST);\n}\n
\n\nlet img0;\nlet img1;\n\nfunction preload() {\n img0 = loadImage('assets/rockies.jpg');\n img1 = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n background(img0);\n image(img1, 0, 0);\n blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST);\n}\n
\n\nlet img0;\nlet img1;\n\nfunction preload() {\n img0 = loadImage('assets/rockies.jpg');\n img1 = loadImage('assets/bricks_third.jpg');\n}\n\nfunction setup() {\n background(img0);\n image(img1, 0, 0);\n blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, ADD);\n}\n
"],alt:"image of rocky mountains. Brick images on left and right. Right overexposed\nimage of rockies. Brickwall images on left and right. Right mortar transparent\nimage of rockies. Brickwall images on left and right. Right translucent",class:"p5",module:"Image",submodule:"Pixels",overloads:[{line:81,params:[{name:"srcImage",description:"source image
\n",type:"p5.Image"},{name:"sx",description:"X coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sy",description:"Y coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sw",description:"source image width
\n",type:"Integer"},{name:"sh",description:"source image height
\n",type:"Integer"},{name:"dx",description:"X coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dy",description:"Y coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dw",description:"destination image width
\n",type:"Integer"},{name:"dh",description:"destination image height
\n",type:"Integer"},{name:"blendMode",description:"the blend mode. either\n BLEND, DARKEST, LIGHTEST, DIFFERENCE,\n MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,\n SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.
\n",type:"Constant"}]},{line:154,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:175,description:"Copies a region of the canvas to another region of the canvas\nand copies a region of pixels from an image used as the srcImg parameter\ninto the canvas srcImage is specified this is used as the source. If\nthe source and destination regions aren't the same size, it will\nautomatically resize source pixels to fit the specified\ntarget region.
\n",itemtype:"method",name:"copy",example:["\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n background(img);\n copy(img, 7, 22, 10, 10, 35, 25, 50, 50);\n stroke(255);\n noFill();\n // Rectangle shows area being copied\n rect(7, 22, 10, 10);\n}\n
"],alt:"image of rocky mountains. Brick images on left and right. Right overexposed\nimage of rockies. Brickwall images on left and right. Right mortar transparent\nimage of rockies. Brickwall images on left and right. Right translucent",class:"p5",module:"Image",submodule:"Pixels",overloads:[{line:175,params:[{name:"srcImage",description:"source image
\n",type:"p5.Image|p5.Element"},{name:"sx",description:"X coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sy",description:"Y coordinate of the source's upper left corner
\n",type:"Integer"},{name:"sw",description:"source image width
\n",type:"Integer"},{name:"sh",description:"source image height
\n",type:"Integer"},{name:"dx",description:"X coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dy",description:"Y coordinate of the destination's upper left corner
\n",type:"Integer"},{name:"dw",description:"destination image width
\n",type:"Integer"},{name:"dh",description:"destination image height
\n",type:"Integer"}]},{line:218,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:310,description:"Applies a filter to the canvas.\n
\nThe presets options are:\n
\nTHRESHOLD\nConverts the image to black and white pixels depending if they are above or\nbelow the threshold defined by the level parameter. The parameter must be\nbetween 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is used.\n
\nGRAY\nConverts any colors in the image to grayscale equivalents. No parameter\nis used.\n
\nOPAQUE\nSets the alpha channel to entirely opaque. No parameter is used.\n
\nINVERT\nSets each pixel to its inverse value. No parameter is used.\n
\nPOSTERIZE\nLimits each channel of the image to the number of colors specified as the\nparameter. The parameter can be set to values between 2 and 255, but\nresults are most noticeable in the lower ranges.\n
\nBLUR\nExecutes a Gaussian blur with the level parameter specifying the extent\nof the blurring. If no parameter is used, the blur is equivalent to\nGaussian blur of radius 1. Larger values increase the blur.\n
\nERODE\nReduces the light areas. No parameter is used.\n
\nDILATE\nIncreases the light areas. No parameter is used.\n
\nfilter() does not work in WEBGL mode.\nA similar effect can be achieved in WEBGL mode using custom\nshaders. Adam Ferriss has written\na selection of shader examples that contains many\nof the effects present in the filter examples.
\n",itemtype:"method",name:"filter",params:[{name:"filterType",description:"either THRESHOLD, GRAY, OPAQUE, INVERT,\n POSTERIZE, BLUR, ERODE, DILATE or BLUR.\n See Filters.js for docs on\n each available filter
\n",type:"Constant"},{name:"filterParam",description:"an optional parameter unique\n to each filter, see above
\n",type:"Number",optional:!0}],example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(THRESHOLD);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(GRAY);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(OPAQUE);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(INVERT);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(POSTERIZE, 3);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(DILATE);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(BLUR, 3);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/bricks.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n filter(ERODE);\n}\n
\n"],alt:"black and white image of a brick wall.\ngreyscale image of a brickwall\nimage of a brickwall\njade colored image of a brickwall\nred and pink image of a brickwall\nimage of a brickwall\nblurry image of a brickwall\nimage of a brickwall\nimage of a brickwall with less detail",class:"p5",module:"Image",submodule:"Pixels"},{file:"src/image/pixels.js",line:497,description:'Get a region of pixels, or a single pixel, from the canvas.
\nReturns an array of [R,G,B,A] values for any pixel or grabs a section of\nan image. If no parameters are specified, the entire image is returned.\nUse the x and y parameters to get the value of one pixel. Get a section of\nthe display window by specifying additional w and h parameters. When\ngetting an image, the x and y parameters define the coordinates for the\nupper-left corner of the image, regardless of the current imageMode().\n
\nGetting the color of a single pixel with get(x, y) is easy, but not as fast\nas grabbing the data directly from pixels[]. The equivalent statement to\nget(x, y) using pixels[] with pixel density d is
\nlet x, y, d; // set these to the coordinates\nlet off = (y * width + x) * d * 4;\nlet components = [\n pixels[off],\n pixels[off + 1],\n pixels[off + 2],\n pixels[off + 3]\n];\nprint(components);
\n
\nSee the reference for pixels[] for more information.
\nIf you want to extract an array of colors or a subimage from an p5.Image object,\ntake a look at p5.Image.get()
\n',itemtype:"method",name:"get",return:{description:'the rectangle p5.Image',type:"p5.Image"},example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n let c = get();\n image(c, width / 2, 0);\n}\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\nfunction setup() {\n image(img, 0, 0);\n let c = get(50, 90);\n fill(c);\n noStroke();\n rect(25, 25, 50, 50);\n}\n
\n"],alt:"2 images of the rocky mountains, side-by-side\nImage of the rocky mountains with 50x50 green rect in center of canvas",class:"p5",module:"Image",submodule:"Pixels",overloads:[{line:497,params:[{name:"x",description:"x-coordinate of the pixel
\n",type:"Number"},{name:"y",description:"y-coordinate of the pixel
\n",type:"Number"},{name:"w",description:"width
\n",type:"Number"},{name:"h",description:"height
\n",type:"Number"}],return:{description:'the rectangle p5.Image',type:"p5.Image"}},{line:570,params:[],return:{description:'the whole p5.Image',type:"p5.Image"}},{line:574,params:[{name:"x",description:"",type:"Number"},{name:"y",description:"",type:"Number"}],return:{description:"color of pixel at x,y in array format [R, G, B, A]",type:"Number[]"}}]},{file:"src/image/pixels.js",line:585,description:'Loads the pixel data for the display window into the pixels[] array. This\nfunction must always be called before reading from or writing to pixels[].\nNote that only changes made with set() or direct manipulation of pixels[]\nwill occur.
\n',itemtype:"method",name:"loadPixels",example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0, width, height);\n let d = pixelDensity();\n let halfImage = 4 * (width * d) * (height * d / 2);\n loadPixels();\n for (let i = 0; i < halfImage; i++) {\n pixels[i + halfImage] = pixels[i];\n }\n updatePixels();\n}\n
\n"],alt:"two images of the rocky mountains. one on top, one on bottom of canvas.",class:"p5",module:"Image",submodule:"Pixels"},{file:"src/image/pixels.js",line:622,description:'Changes the color of any pixel, or writes an image directly to the\ndisplay window.
\nThe x and y parameters specify the pixel to change and the c parameter\nspecifies the color value. This can be a p5.Color object, or [R, G, B, A]\npixel array. It can also be a single grayscale value.\nWhen setting an image, the x and y parameters define the coordinates for\nthe upper-left corner of the image, regardless of the current imageMode().\n
\n\nAfter using set(), you must call updatePixels() for your changes to appear.\nThis should be called once all pixels have been set, and must be called before\ncalling .get() or drawing the image.\n
\nSetting the color of a single pixel with set(x, y) is easy, but not as\nfast as putting the data directly into pixels[]. Setting the pixels[]\nvalues directly may be complicated when working with a retina display,\nbut will perform better when lots of pixels need to be set directly on\nevery loop.
\nSee the reference for pixels[] for more information.
',itemtype:"method",name:"set",params:[{name:"x",description:"x-coordinate of the pixel
\n",type:"Number"},{name:"y",description:"y-coordinate of the pixel
\n",type:"Number"},{name:"c",description:'insert a grayscale value | a pixel array |\n a p5.Color object | a p5.Image to copy
\n',type:"Number|Number[]|Object"}],example:["\n\n\nlet black = color(0);\nset(30, 20, black);\nset(85, 20, black);\nset(85, 75, black);\nset(30, 75, black);\nupdatePixels();\n
\n\n\n\n\nfor (let i = 30; i < width - 15; i++) {\n for (let j = 20; j < height - 25; j++) {\n let c = color(204 - j, 153 - i, 0);\n set(i, j, c);\n }\n}\nupdatePixels();\n
\n\n\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n set(0, 0, img);\n updatePixels();\n line(0, 0, width, height);\n line(0, height, width, 0);\n}\n
\n"],alt:"4 black points in the shape of a square middle-right of canvas.\nsquare with orangey-brown gradient lightening at bottom right.\nimage of the rocky mountains. with lines like an 'x' through the center.",class:"p5",module:"Image",submodule:"Pixels"},{file:"src/image/pixels.js",line:696,description:'Updates the display window with the data in the pixels[] array.\nUse in conjunction with loadPixels(). If you're only reading pixels from\nthe array, there's no need to call updatePixels() — updating is only\nnecessary to apply changes. updatePixels() should be called anytime the\npixels array is manipulated or set() is called, and only changes made with\nset() or direct changes to pixels[] will occur.
\n',itemtype:"method",name:"updatePixels",params:[{name:"x",description:"x-coordinate of the upper-left corner of region\n to update
\n",type:"Number",optional:!0},{name:"y",description:"y-coordinate of the upper-left corner of region\n to update
\n",type:"Number",optional:!0},{name:"w",description:"width of region to update
\n",type:"Number",optional:!0},{name:"h",description:"height of region to update
\n",type:"Number",optional:!0}],example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies.jpg');\n}\n\nfunction setup() {\n image(img, 0, 0, width, height);\n let d = pixelDensity();\n let halfImage = 4 * (width * d) * (height * d / 2);\n loadPixels();\n for (let i = 0; i < halfImage; i++) {\n pixels[i + halfImage] = pixels[i];\n }\n updatePixels();\n}\n
\n"],alt:"two images of the rocky mountains. one on top, one on bottom of canvas.",class:"p5",module:"Image",submodule:"Pixels"},{file:"src/io/files.js",line:18,description:'Loads a JSON file from a file or a URL, and returns an Object.\nNote that even if the JSON file contains an Array, an Object will be\nreturned with index numbers as keys.
\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. JSONP is supported via a polyfill and you\ncan pass in as the second argument an object with definitions of the json\ncallback following the syntax specified here.
\nThis method is suitable for fetching files up to size of 64MB.
\n',itemtype:"method",name:"loadJSON",return:{description:"JSON data",type:"Object|Array"},example:["\n\nCalling loadJSON() inside preload() guarantees to complete the\noperation before setup() and draw() are called.
\n\n\n// Examples use USGS Earthquake API:\n// https://earthquake.usgs.gov/fdsnws/event/1/#methods\nlet earthquakes;\nfunction preload() {\n // Get the most recent earthquake in the database\n let url =\n 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/' +\n 'summary/all_day.geojson';\n earthquakes = loadJSON(url);\n}\n\nfunction setup() {\n noLoop();\n}\n\nfunction draw() {\n background(200);\n // Get the magnitude and name of the earthquake out of the loaded JSON\n let earthquakeMag = earthquakes.features[0].properties.mag;\n let earthquakeName = earthquakes.features[0].properties.place;\n ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10);\n textAlign(CENTER);\n text(earthquakeName, 0, height - 30, width, 30);\n}\n
\n\n\nOutside of preload(), you may supply a callback function to handle the\nobject:
\n\nfunction setup() {\n noLoop();\n let url =\n 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/' +\n 'summary/all_day.geojson';\n loadJSON(url, drawEarthquake);\n}\n\nfunction draw() {\n background(200);\n}\n\nfunction drawEarthquake(earthquakes) {\n // Get the magnitude and name of the earthquake out of the loaded JSON\n let earthquakeMag = earthquakes.features[0].properties.mag;\n let earthquakeName = earthquakes.features[0].properties.place;\n ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10);\n textAlign(CENTER);\n text(earthquakeName, 0, height - 30, width, 30);\n}\n
"],alt:"50x50 ellipse that changes from black to white depending on the current humidity\n50x50 ellipse that changes from black to white depending on the current humidity",class:"p5",module:"IO",submodule:"Input",overloads:[{line:18,params:[{name:"path",description:"name of the file or url to load
\n",type:"String"},{name:"jsonpOptions",description:"options object for jsonp related settings
\n",type:"Object",optional:!0},{name:"datatype",description:""json" or "jsonp"
\n",type:"String",optional:!0},{name:"callback",description:'function to be executed after\n loadJSON() completes, data is passed\n in as first argument
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if\n there is an error, response is passed\n in as first argument
\n",type:"Function",optional:!0}],return:{description:"JSON data",type:"Object|Array"}},{line:104,params:[{name:"path",description:"",type:"String"},{name:"datatype",description:"",type:"String"},{name:"callback",description:"",type:"Function",optional:!0},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Object|Array"}},{line:112,params:[{name:"path",description:"",type:"String"},{name:"callback",description:"",type:"Function"},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Object|Array"}}]},{file:"src/io/files.js",line:183,description:"Reads the contents of a file and creates a String array of its individual\nlines. If the name of the file is used as the parameter, as in the above\nexample, the file must be located in the sketch directory/folder.\n
\nAlternatively, the file maybe be loaded from anywhere on the local\ncomputer using an absolute path (something that starts with / on Unix and\nLinux, or a drive letter on Windows), or the filename parameter can be a\nURL for a file found on a network.\n
\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed.
\nThis method is suitable for fetching files up to size of 64MB.
\n",itemtype:"method",name:"loadStrings",params:[{name:"filename",description:"name of the file or url to load
\n",type:"String"},{name:"callback",description:'function to be executed after loadStrings()\n completes, Array is passed in as first\n argument
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if\n there is an error, response is passed\n in as first argument
\n",type:"Function",optional:!0}],return:{description:"Array of Strings",type:"String[]"},example:['\n\nCalling loadStrings() inside preload() guarantees to complete the\noperation before setup() and draw() are called.
\n\n\nlet result;\nfunction preload() {\n result = loadStrings(\'assets/test.txt\');\n}\n\nfunction setup() {\n background(200);\n text(random(result), 10, 10, 80, 80);\n}\n
\n\nOutside of preload(), you may supply a callback function to handle the\nobject:
\n\n\nfunction setup() {\n loadStrings(\'assets/test.txt\', pickString);\n}\n\nfunction pickString(result) {\n background(200);\n text(random(result), 10, 10, 80, 80);\n}\n
'],alt:'randomly generated text from a file, for example "i smell like butter"\nrandomly generated text from a file, for example "i have three feet"',class:"p5",module:"IO",submodule:"Input"},{file:"src/io/files.js",line:294,description:'Reads the contents of a file or URL and creates a p5.Table object with\nits values. If a file is specified, it must be located in the sketch\'s\n"data" folder. The filename parameter can also be a URL to a file found\nonline. By default, the file is assumed to be comma-separated (in CSV\nformat). Table only looks for a header row if the \'header\' option is\nincluded.
\n\nPossible options include:\n
\n- csv - parse the table as comma-separated values
\n- tsv - parse the table as tab-separated values
\n- header - this table has a header (title) row
\n
\n\n\nWhen passing in multiple options, pass them in as separate parameters,\nseperated by commas. For example:\n
\n\nloadTable(\'my_csv_file.csv\', \'csv\', \'header\');\n
\n
\n\n All files loaded and saved use UTF-8 encoding.
\n\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. Calling loadTable() inside preload()\nguarantees to complete the operation before setup() and draw() are called.\n
Outside of preload(), you may supply a callback function to handle the\nobject:
\n\n\nThis method is suitable for fetching files up to size of 64MB.
\n',itemtype:"method",name:"loadTable",return:{description:'Table object containing data',type:"Object"},example:['\n\n\n// Given the following CSV file called "mammals.csv"\n// located in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value "csv"\n //and has a header specifying the columns labels\n table = loadTable(\'assets/mammals.csv\', \'csv\', \'header\');\n //the file can be remote\n //table = loadTable("http://p5js.org/reference/assets/mammals.csv",\n // "csv", "header");\n}\n\nfunction setup() {\n //count the columns\n print(table.getRowCount() + \' total rows in table\');\n print(table.getColumnCount() + \' total columns in table\');\n\n print(table.getColumn(\'name\'));\n //["Goat", "Leopard", "Zebra"]\n\n //cycle through the table\n for (let r = 0; r < table.getRowCount(); r++)\n for (let c = 0; c < table.getColumnCount(); c++) {\n print(table.getString(r, c));\n }\n}\n
\n'],alt:'randomly generated text from a file, for example "i smell like butter"\nrandomly generated text from a file, for example "i have three feet"',class:"p5",module:"IO",submodule:"Input",overloads:[{line:294,params:[{name:"filename",description:"name of the file or URL to load
\n",type:"String"},{name:"options",description:""header" "csv" "tsv"
\n",type:"String"},{name:"callback",description:'function to be executed after\n loadTable() completes. On success, the\n Table object is passed in as the\n first argument.
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if\n there is an error, response is passed\n in as first argument
\n",type:"Function",optional:!0}],return:{description:'Table object containing data',type:"Object"}},{line:384,params:[{name:"filename",description:"",type:"String"},{name:"callback",description:"",type:"Function",optional:!0},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Object"}}]},{file:"src/io/files.js",line:604,description:'Reads the contents of a file and creates an XML object with its values.\nIf the name of the file is used as the parameter, as in the above example,\nthe file must be located in the sketch directory/folder.
\nAlternatively, the file maybe be loaded from anywhere on the local\ncomputer using an absolute path (something that starts with / on Unix and\nLinux, or a drive letter on Windows), or the filename parameter can be a\nURL for a file found on a network.
\nThis method is asynchronous, meaning it may not finish before the next\nline in your sketch is executed. Calling loadXML() inside preload()\nguarantees to complete the operation before setup() and draw() are called.
\nOutside of preload(), you may supply a callback function to handle the\nobject.
\nThis method is suitable for fetching files up to size of 64MB.
\n',itemtype:"method",name:"loadXML",params:[{name:"filename",description:"name of the file or URL to load
\n",type:"String"},{name:"callback",description:'function to be executed after loadXML()\n completes, XML object is passed in as\n first argument
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if\n there is an error, response is passed\n in as first argument
\n",type:"Function",optional:!0}],return:{description:"XML object containing data",type:"Object"},example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let children = xml.getChildren(\'animal\');\n\n for (let i = 0; i < children.length; i++) {\n let id = children[i].getNum(\'id\');\n let coloring = children[i].getString(\'species\');\n let name = children[i].getContent();\n print(id + \', \' + coloring + \', \' + name);\n }\n}\n\n// Sketch prints:\n// 0, Capra hircus, Goat\n// 1, Panthera pardus, Leopard\n// 2, Equus zebra, Zebra\n
'],alt:"no image displayed",class:"p5",module:"IO",submodule:"Input"},{file:"src/io/files.js",line:715,description:"This method is suitable for fetching files up to size of 64MB.
\n",itemtype:"method",name:"loadBytes",params:[{name:"file",description:"name of the file or URL to load
\n",type:"String"},{name:"callback",description:'function to be executed after loadBytes()\n completes
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if there\n is an error
\n",type:"Function",optional:!0}],return:{description:"an object whose 'bytes' property will be the loaded buffer",type:"Object"},example:["\n\nlet data;\n\nfunction preload() {\n data = loadBytes('assets/mammals.xml');\n}\n\nfunction setup() {\n for (let i = 0; i < 5; i++) {\n console.log(data.bytes[i].toString(16));\n }\n}\n
"],alt:"no image displayed",class:"p5",module:"IO",submodule:"Input"},{file:"src/io/files.js",line:775,description:"Method for executing an HTTP GET request. If data type is not specified,\np5 will try to guess based on the URL, defaulting to text. This is equivalent to\ncalling httpDo(path, 'GET')
. The 'binary' datatype will return\na Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer\nwhich can be used to initialize typed arrays (such as Uint8Array).
\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\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
"],class:"p5",module:"IO",submodule:"Input",overloads:[{line:775,params:[{name:"path",description:"name of the file or url to load
\n",type:"String"},{name:"datatype",description:""json", "jsonp", "binary", "arrayBuffer",\n "xml", or "text"
\n",type:"String",optional:!0},{name:"data",description:"param data passed sent with request
\n",type:"Object|Boolean",optional:!0},{name:"callback",description:'function to be executed after\n httpGet() completes, data is passed in\n as first argument
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if\n there is an error, response is passed\n in as first argument
\n",type:"Function",optional:!0}],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:829,params:[{name:"path",description:"",type:"String"},{name:"data",description:"",type:"Object|Boolean"},{name:"callback",description:"",type:"Function",optional:!0},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Promise"}},{line:837,params:[{name:"path",description:"",type:"String"},{name:"callback",description:"",type:"Function"},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Promise"}}]},{file:"src/io/files.js",line:852,description:"Method for executing an HTTP POST request. If data type is not specified,\np5 will try to guess based on the URL, defaulting to text. This is equivalent to\ncalling httpDo(path, 'POST')
.
\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\n\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 way cool.' };\n\nfunction setup() {\n createCanvas(800, 800);\n}\n\nfunction mousePressed() {\n // Pick new random color values\n let r = random(255);\n let g = random(255);\n let b = random(255);\n\n httpPost(url, 'json', postData, function(result) {\n strokeWeight(2);\n stroke(r, g, b);\n fill(r, g, b, 127);\n ellipse(mouseX, mouseY, 200, 200);\n text(result.body, mouseX, mouseY);\n });\n}\n
\n\n\n\n\nlet url = 'https://invalidURL'; // A bad URL that will cause errors\nlet postData = { title: 'p5 Clicked!', body: 'p5.js is way cool.' };\n\nfunction setup() {\n createCanvas(800, 800);\n}\n\nfunction mousePressed() {\n // Pick new random color values\n let r = random(255);\n let g = random(255);\n let b = random(255);\n\n httpPost(\n url,\n 'json',\n postData,\n function(result) {\n // ... won't be called\n },\n function(error) {\n strokeWeight(2);\n stroke(r, g, b);\n fill(r, g, b, 127);\n text(error.toString(), mouseX, mouseY);\n }\n );\n}\n
\n"],class:"p5",module:"IO",submodule:"Input",overloads:[{line:852,params:[{name:"path",description:"name of the file or url to load
\n",type:"String"},{name:"datatype",description:'"json", "jsonp", "xml", or "text".\n If omitted, httpPost() will guess.
\n',type:"String",optional:!0},{name:"data",description:"param data passed sent with request
\n",type:"Object|Boolean",optional:!0},{name:"callback",description:'function to be executed after\n httpPost() completes, data is passed in\n as first argument
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if\n there is an error, response is passed\n in as first argument
\n",type:"Function",optional:!0}],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:934,params:[{name:"path",description:"",type:"String"},{name:"data",description:"",type:"Object|Boolean"},{name:"callback",description:"",type:"Function",optional:!0},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Promise"}},{line:942,params:[{name:"path",description:"",type:"String"},{name:"callback",description:"",type:"Function"},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Promise"}}]},{file:"src/io/files.js",line:957,description:"Method for executing an HTTP request. If data type is not specified,\np5 will try to guess based on the URL, defaulting to text.
\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.
\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\n\n// Examples use USGS Earthquake API:\n// https://earthquake.usgs.gov/fdsnws/event/1/#methods\n\n// displays an animation of all USGS earthquakes\nlet earthquakes;\nlet eqFeatureIndex = 0;\n\nfunction preload() {\n let url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson';\n httpDo(\n url,\n {\n method: 'GET',\n // Other Request options, like special headers for apis\n headers: { authorization: 'Bearer secretKey' }\n },\n function(res) {\n earthquakes = res;\n }\n );\n}\n\nfunction draw() {\n // wait until the data is loaded\n if (!earthquakes || !earthquakes.features[eqFeatureIndex]) {\n return;\n }\n clear();\n\n let feature = earthquakes.features[eqFeatureIndex];\n let mag = feature.properties.mag;\n let rad = mag / 11 * ((width + height) / 2);\n fill(255, 0, 0, 100);\n ellipse(width / 2 + random(-2, 2), height / 2 + random(-2, 2), rad, rad);\n\n if (eqFeatureIndex >= earthquakes.features.length) {\n eqFeatureIndex = 0;\n } else {\n eqFeatureIndex += 1;\n }\n}\n
\n"],class:"p5",module:"IO",submodule:"Input",overloads:[{line:957,params:[{name:"path",description:"name of the file or url to load
\n",type:"String"},{name:"method",description:"either "GET", "POST", or "PUT",\n defaults to "GET"
\n",type:"String",optional:!0},{name:"datatype",description:""json", "jsonp", "xml", or "text"
\n",type:"String",optional:!0},{name:"data",description:"param data passed sent with request
\n",type:"Object",optional:!0},{name:"callback",description:'function to be executed after\n httpGet() completes, data is passed in\n as first argument
\n',type:"Function",optional:!0},{name:"errorCallback",description:"function to be executed if\n there is an error, response is passed\n in as first argument
\n",type:"Function",optional:!0}],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:1028,params:[{name:"path",description:"",type:"String"},{name:"options",description:'Request object options as documented in the\n "fetch" API\nreference
\n',type:"Object"},{name:"callback",description:"",type:"Function",optional:!0},{name:"errorCallback",description:"",type:"Function",optional:!0}],return:{description:"",type:"Promise"}}]},{file:"src/io/files.js",line:1190,itemtype:"method",name:"createWriter",params:[{name:"name",description:"name of the file to be created
\n",type:"String"},{name:"extension",description:"",type:"String",optional:!0}],return:{description:"",type:"p5.PrintWriter"},example:["\n\n\nfunction setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n}\n\nfunction mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n const writer = createWriter('squares.txt');\n for (let i = 0; i < 10; i++) {\n writer.print(i * i);\n }\n writer.close();\n writer.clear();\n }\n}\n
\n"],class:"p5",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1245,description:"Writes data to the PrintWriter stream
\n",itemtype:"method",name:"write",params:[{name:"data",description:"all data to be written by the PrintWriter
\n",type:"Array"}],example:["\n\n\n// creates a file called 'newFile.txt'\nlet writer = createWriter('newFile.txt');\n// write 'Hello world!'' to the file\nwriter.write(['Hello world!']);\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n\n\n// creates a file called 'newFile2.txt'\nlet writer = createWriter('newFile2.txt');\n// write 'apples,bananas,123' to the file\nwriter.write(['apples', 'bananas', 123]);\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n\n\n// creates a file called 'newFile3.txt'\nlet writer = createWriter('newFile3.txt');\n// write 'My name is: Teddy' to the file\nwriter.write('My name is:');\nwriter.write(' Teddy');\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n\n\nfunction setup() {\n createCanvas(100, 100);\n button = createButton('SAVE FILE');\n button.position(21, 40);\n button.mousePressed(createFile);\n}\n\nfunction createFile() {\n // creates a file called 'newFile.txt'\n let writer = createWriter('newFile.txt');\n // write 'Hello world!'' to the file\n writer.write(['Hello world!']);\n // close the PrintWriter and save the file\n writer.close();\n}\n
\n"],class:"p5.PrintWriter",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1304,description:"Writes data to the PrintWriter stream, and adds a new line at the end
\n",itemtype:"method",name:"print",params:[{name:"data",description:"all data to be printed by the PrintWriter
\n",type:"Array"}],example:["\n\n\n// creates a file called 'newFile.txt'\nlet writer = createWriter('newFile.txt');\n// creates a file containing\n// My name is:\n// Teddy\nwriter.print('My name is:');\nwriter.print('Teddy');\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n\n\nlet writer;\n\nfunction setup() {\n createCanvas(400, 400);\n // create a PrintWriter\n writer = createWriter('newFile.txt');\n}\n\nfunction draw() {\n writer.print([mouseX, mouseY]);\n}\n\nfunction mouseClicked() {\n writer.close();\n}\n
\n"],class:"p5.PrintWriter",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1345,description:"Clears the data already written to the PrintWriter object
\n",itemtype:"method",name:"clear",example:["\n\n// create writer object\nlet writer = createWriter('newFile.txt');\nwriter.write(['clear me']);\n// clear writer object here\nwriter.clear();\n// close writer\nwriter.close();\n
\n\n\nfunction setup() {\n button = createButton('CLEAR ME');\n button.position(21, 40);\n button.mousePressed(createFile);\n}\n\nfunction createFile() {\n let writer = createWriter('newFile.txt');\n writer.write(['clear me']);\n writer.clear();\n writer.close();\n}\n
\n\n"],class:"p5.PrintWriter",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1379,description:"Closes the PrintWriter
\n",itemtype:"method",name:"close",example:["\n\n\n// create a file called 'newFile.txt'\nlet writer = createWriter('newFile.txt');\n// close the PrintWriter and save the file\nwriter.close();\n
\n\n\n\n// create a file called 'newFile2.txt'\nlet writer = createWriter('newFile2.txt');\n// write some data to the file\nwriter.write([100, 101, 102]);\n// close the PrintWriter and save the file\nwriter.close();\n
\n"],class:"p5.PrintWriter",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1428,description:"Save an image, text, json, csv, wav, or html. Prompts download to\nthe client's computer. Note that it is not recommended to call save()\nwithin draw if it's looping, as the save() function will open a new save\ndialog every frame.
\nThe default behavior is to save the canvas as an image. You can\noptionally specify a filename.\nFor example:
\n \n save();\n save('myCanvas.jpg'); // save a specific canvas with a filename\n
\n\nAlternately, the first parameter can be a pointer to a canvas\np5.Element, an Array of Strings,\nan Array of JSON, a JSON object, a p5.Table, a p5.Image, or a\np5.SoundFile (requires p5.sound). The second parameter is a filename\n(including extension). The third parameter is for options specific\nto this type of object. This method will save a file that fits the\ngiven parameters. For example:
\n\n \n // Saves canvas as an image\n save('myCanvas.jpg');\n\n // Saves pImage as a png image\n let img = createImage(10, 10);\n save(img, 'my.png');\n\n // Saves canvas as an image\n let cnv = createCanvas(100, 100);\n save(cnv, 'myCanvas.jpg');\n\n // Saves p5.Renderer object as an image\n let gb = createGraphics(100, 100);\n save(gb, 'myGraphics.jpg');\n\n let myTable = new p5.Table();\n\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 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 // Saves array of strings to a text file with line breaks after each item\n let arrayOfStrings = ['a', 'b'];\n save(arrayOfStrings, 'my.txt');\n
",itemtype:"method",name:"save",params:[{name:"objectOrFilename",description:"If filename is provided, will\n save canvas as an image with\n either png or jpg extension\n depending on the filename.\n If object is provided, will\n save depending on the object\n and filename (see examples\n above).
\n",type:"Object|String",optional:!0},{name:"filename",description:"If an object is provided as the first\n parameter, then the second parameter\n indicates the filename,\n and should include an appropriate\n file extension (see examples above).
\n",type:"String",optional:!0},{name:"options",description:"Additional options depend on\n filetype. For example, when saving JSON,\n true
indicates that the\n output will be optimized for filesize,\n rather than readability.
\n",type:"Boolean|String",optional:!0}],class:"p5",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1556,description:"Writes the contents of an Array or a JSON object to a .json file.\nThe file saving process and location of the saved file will\nvary between web browsers.
\n",itemtype:"method",name:"saveJSON",params:[{name:"json",description:"",type:"Array|Object"},{name:"filename",description:"",type:"String"},{name:"optimize",description:"If true, removes line breaks\n and spaces from the output\n file to optimize filesize\n (but not readability).
\n",type:"Boolean",optional:!0}],example:['\n \n let json = {}; // new JSON Object\n\n json.id = 0;\n json.species = \'Panthera leo\';\n json.name = \'Lion\';\n\n function setup() {\n createCanvas(100, 100);\n background(200);\n text(\'click here to save\', 10, 10, 70, 80);\n }\n\n function mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n saveJSON(json, \'lion.json\');\n }\n }\n\n // saves the following to a file called "lion.json":\n // {\n // "id": 0,\n // "species": "Panthera leo",\n // "name": "Lion"\n // }\n
'],alt:"no image displayed",class:"p5",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1614,description:"Writes an array of Strings to a text file, one line per String.\nThe file saving process and location of the saved file will\nvary between web browsers.
\n",itemtype:"method",name:"saveStrings",params:[{name:"list",description:"string array to be written
\n",type:"String[]"},{name:"filename",description:"filename for output
\n",type:"String"},{name:"extension",description:"the filename's extension
\n",type:"String",optional:!0},{name:"isCRLF",description:"if true, change line-break to CRLF
\n",type:"Boolean",optional:!0}],example:["\n \n let words = 'apple bear cat dog';\n\n // .split() outputs an Array\n let list = split(words, ' ');\n\n function setup() {\n createCanvas(100, 100);\n background(200);\n text('click here to save', 10, 10, 70, 80);\n }\n\n function mousePressed() {\n if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n saveStrings(list, 'nouns.txt');\n }\n }\n\n // Saves the following to a file called 'nouns.txt':\n //\n // apple\n // bear\n // cat\n // dog\n
"],alt:"no image displayed",class:"p5",module:"IO",submodule:"Output"},{file:"src/io/files.js",line:1679,description:'Writes the contents of a Table object to a file. Defaults to a\ntext file with comma-separated-values ('csv') but can also\nuse tab separation ('tsv'), or generate an HTML table ('html').\nThe file saving process and location of the saved file will\nvary between web browsers.
\n',itemtype:"method",name:"saveTable",params:[{name:"Table",description:'the Table object to save to a file
\n',type:"p5.Table"},{name:"filename",description:"the filename to which the Table should be saved
\n",type:"String"},{name:"options",description:"can be one of "tsv", "csv", or "html"
\n",type:"String",optional:!0}],example:["\n\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\n // Saves the following to a file called 'new.csv':\n // id,species,name\n // 0,Panthera leo,Lion\n
"],alt:"no image displayed",class:"p5",module:"IO",submodule:"Output"},{file:"src/io/p5.Table.js",line:9,description:'Table Options
\nGeneric class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.
\nCSV files are\n\ncomma separated values, often with the data in quotes. TSV\nfiles use tabs as separators, and usually don\'t bother with the\nquotes.
\nFile names should end with .csv if they\'re comma separated.
\nA rough "spec" for CSV can be found\nhere.
\nTo load files, use the loadTable method.
\nTo save tables to your computer, use the save method\n or the saveTable method.
\n\nPossible options include:
\n\n- csv - parse the table as comma-separated values\n
- tsv - parse the table as tab-separated values\n
- header - this table has a header (title) row\n
',class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:43,description:"An array containing the names of the columns in the table, if the "header" the table is\nloaded with the "header" parameter.
\n",itemtype:"property",name:"columns",type:"String[]",example:["\n\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //print the column names\n for (let c = 0; c < table.getColumnCount(); c++) {\n print('column ' + c + ' is named ' + table.columns[c]);\n }\n}\n
\n"],class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:77,description:'An array containing the p5.TableRow objects that make up the\nrows of the table. The same result as calling getRows()
\n',itemtype:"property",name:"rows",type:"p5.TableRow[]",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:85,description:'Use addRow() to add a new row of data to a p5.Table object. By default,\nan empty row is created. Typically, you would store a reference to\nthe new row in a TableRow object (see newRow in the example above),\nand then set individual values using set().
\nIf a p5.TableRow object is included as a parameter, then that row is\nduplicated and added to the table.
\n',itemtype:"method",name:"addRow",params:[{name:"row",description:"row to be added to the table
\n",type:"p5.TableRow",optional:!0}],return:{description:"the row that was added",type:"p5.TableRow"},example:["\n \n \n // Given the CSV file \"mammals.csv\"\n // in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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
\n "],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:149,description:"Removes a row from the table object.
\n",itemtype:"method",name:"removeRow",params:[{name:"id",description:"ID number of the row to remove
\n",type:"Integer"}],example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\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
\n'],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:197,description:'Returns a reference to the specified p5.TableRow. The reference\ncan then be used to get and set values of the selected row.
\n',itemtype:"method",name:"getRow",params:[{name:"rowID",description:"ID number of the row to get
\n",type:"Integer"}],return:{description:'p5.TableRow object',type:"p5.TableRow"},example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\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
\n'],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:243,description:'Gets all rows from the table. Returns an array of p5.TableRows.
\n',itemtype:"method",name:"getRows",return:{description:'Array of p5.TableRows',type:"p5.TableRow[]"},example:["\n \n \n // Given the CSV file \"mammals.csv\"\n // in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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
\n "],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:292,description:"Finds the first row in the Table that contains the value\nprovided, and returns a reference to that row. Even if\nmultiple rows are possible matches, only the first matching\nrow is returned. The column to search may be specified by\neither its ID or title.
\n",itemtype:"method",name:"findRow",params:[{name:"value",description:"The value to match
\n",type:"String"},{name:"column",description:"ID number or title of the\n column to search
\n",type:"Integer|String"}],return:{description:"",type:"p5.TableRow"},example:["\n \n \n // Given the CSV file \"mammals.csv\"\n // in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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 }\n
\n "],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:357,description:"Finds the rows in the Table that contain the value\nprovided, and returns references to those rows. Returns an\nArray, so for must be used to iterate through all the rows,\nas shown in the example above. The column to search may be\nspecified by either its ID or title.
\n",itemtype:"method",name:"findRows",params:[{name:"value",description:"The value to match
\n",type:"String"},{name:"column",description:"ID number or title of the\n column to search
\n",type:"Integer|String"}],return:{description:"An Array of TableRow objects",type:"p5.TableRow[]"},example:["\n \n \n // Given the CSV file \"mammals.csv\"\n // in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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 }\n
\n "],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:426,description:"Finds the first row in the Table that matches the regular\nexpression provided, and returns a reference to that row.\nEven if multiple rows are possible matches, only the first\nmatching row is returned. The column to search may be\nspecified by either its ID or title.
\n",itemtype:"method",name:"matchRow",params:[{name:"regexp",description:"The regular expression to match
\n",type:"String|RegExp"},{name:"column",description:"The column ID (number) or\n title (string)
\n",type:"String|Integer"}],return:{description:"TableRow object",type:"p5.TableRow"},example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value "csv"\n //and has a header specifying the columns labels\n table = loadTable(\'assets/mammals.csv\', \'csv\', \'header\');\n}\n\nfunction setup() {\n //Search using specified regex on a given column, return TableRow object\n let mammal = table.matchRow(new RegExp(\'ant\'), 1);\n print(mammal.getString(1));\n //Output "Panthera pardus"\n}\n
\n\n'],class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:485,description:"Finds the rows in the Table that match the regular expression provided,\nand returns references to those rows. Returns an array, so for must be\nused to iterate through all the rows, as shown in the example. The\ncolumn to search may be specified by either its ID or title.
\n",itemtype:"method",name:"matchRows",params:[{name:"regexp",description:"The regular expression to match
\n",type:"String"},{name:"column",description:"The column ID (number) or\n title (string)
\n",type:"String|Integer",optional:!0}],return:{description:"An Array of TableRow objects",type:"p5.TableRow[]"},example:["\n\n\nlet table;\n\nfunction setup() {\n table = new p5.Table();\n\n table.addColumn('name');\n table.addColumn('type');\n\n let newRow = table.addRow();\n newRow.setString('name', 'Lion');\n newRow.setString('type', 'Mammal');\n\n newRow = table.addRow();\n newRow.setString('name', 'Snake');\n newRow.setString('type', 'Reptile');\n\n newRow = table.addRow();\n newRow.setString('name', 'Mosquito');\n newRow.setString('type', 'Insect');\n\n newRow = table.addRow();\n newRow.setString('name', 'Lizard');\n newRow.setString('type', 'Reptile');\n\n let rows = table.matchRows('R.*', 'type');\n for (let i = 0; i < rows.length; i++) {\n print(rows[i].getString('name') + ': ' + rows[i].getString('type'));\n }\n}\n// Sketch prints:\n// Snake: Reptile\n// Lizard: Reptile\n
\n"],class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:552,description:"Retrieves all values in the specified column, and returns them\nas an array. The column may be specified by either its ID or title.
\n",itemtype:"method",name:"getColumn",params:[{name:"column",description:"String or Number of the column to return
\n",type:"String|Number"}],return:{description:"Array of column values",type:"Array"},example:['\n \n \n // Given the CSV file "mammals.csv"\n // in the project\'s "assets" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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 }\n
\n '],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:605,description:"Removes all rows from a Table. While all rows are removed,\ncolumns and column titles are maintained.
\n",itemtype:"method",name:"clearRows",example:["\n \n \n // Given the CSV file \"mammals.csv\"\n // in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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 }\n
\n "],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:647,description:'Use addColumn() to add a new column to a Table object.\nTypically, you will want to specify a title, so the column\nmay be easily referenced later by name. (If no title is\nspecified, the new column's title will be null.)
\n',itemtype:"method",name:"addColumn",params:[{name:"title",description:"title of the given column
\n",type:"String",optional:!0}],example:["\n \n \n // Given the CSV file \"mammals.csv\"\n // in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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
\n "],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:698,description:"Returns the total number of columns in a Table.
\n",itemtype:"method",name:"getColumnCount",return:{description:"Number of columns in this table",type:"Integer"},example:["\n \n \n // given the cvs file \"blobs.csv\" in /assets directory\n // ID, Name, Flavor, Shape, Color\n // Blob1, Blobby, Sweet, Blob, Pink\n // Blob2, Saddy, Savory, Blob, Blue\n\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
\n "],class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:734,description:"Returns the total number of rows in a Table.
\n",itemtype:"method",name:"getRowCount",return:{description:"Number of rows in this table",type:"Integer"},example:["\n \n \n // given the cvs file \"blobs.csv\" in /assets directory\n //\n // ID, Name, Flavor, Shape, Color\n // Blob1, Blobby, Sweet, Blob, Pink\n // Blob2, Saddy, Savory, Blob, Blue\n\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
\n "],class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:770,description:'Removes any of the specified characters (or "tokens").
\n\nIf no column is specified, then the values in all columns and\nrows are processed. A specific column may be referenced by\neither its ID or title.
',itemtype:"method",name:"removeTokens",params:[{name:"chars",description:"String listing characters to be removed
\n",type:"String"},{name:"column",description:"Column ID (number)\n or name (string)
\n",type:"String|Integer",optional:!0}],example:["\n \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
"],class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:842,description:"Trims leading and trailing whitespace, such as spaces and tabs,\nfrom String table values. If no column is specified, then the\nvalues in all columns and rows are trimmed. A specific column\nmay be referenced by either its ID or title.
\n",itemtype:"method",name:"trim",params:[{name:"column",description:"Column ID (number)\n or name (string)
\n",type:"String|Integer",optional:!0}],example:["\n \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
"],class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:906,description:'Use removeColumn() to remove an existing column from a Table\nobject. The column to be removed may be identified by either\nits title (a String) or its index value (an int).\nremoveColumn(0) would remove the first column, removeColumn(1)\nwould remove the second column, and so on.
\n',itemtype:"method",name:"removeColumn",params:[{name:"column",description:"columnName (string) or ID (number)
\n",type:"String|Integer"}],example:["\n \n \n // Given the CSV file \"mammals.csv\"\n // in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\n 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 }\n
\n "],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:971,description:"Stores a value in the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified\nby either its ID or title.
\n",itemtype:"method",name:"set",params:[{name:"row",description:"row ID
\n",type:"Integer"},{name:"column",description:"column ID (Number)\n or title (String)
\n",type:"String|Integer"},{name:"value",description:"value to assign
\n",type:"String|Number"}],example:["\n\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\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
\n"],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:1021,description:"Stores a Float value in the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified\nby either its ID or title.
\n",itemtype:"method",name:"setNum",params:[{name:"row",description:"row ID
\n",type:"Integer"},{name:"column",description:"column ID (Number)\n or title (String)
\n",type:"String|Integer"},{name:"value",description:"value to assign
\n",type:"Number"}],example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\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
\n'],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:1067,description:"Stores a String value in the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified\nby either its ID or title.
\n",itemtype:"method",name:"setString",params:[{name:"row",description:"row ID
\n",type:"Integer"},{name:"column",description:"column ID (Number)\n or title (String)
\n",type:"String|Integer"},{name:"value",description:"value to assign
\n",type:"String"}],example:["\n\n// Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n //my table is comma separated value \"csv\"\n //and has a header specifying the columns labels\n table = loadTable('assets/mammals.csv', 'csv', 'header');\n}\n\nfunction setup() {\n //add a row\n let newRow = table.addRow();\n newRow.setString('id', table.getRowCount() - 1);\n newRow.setString('species', 'Canis Lupus');\n newRow.setString('name', 'Wolf');\n\n print(table.getArray());\n}\n
"],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:1112,description:"Retrieves a value from the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified by\neither its ID or title.
\n",itemtype:"method",name:"get",params:[{name:"row",description:"row ID
\n",type:"Integer"},{name:"column",description:"columnName (string) or\n ID (number)
\n",type:"String|Integer"}],return:{description:"",type:"String|Number"},example:["\n\n\n// Given the CSV file \"mammals.csv\"\n// in the project's \"assets\" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\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}\n
\n"],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:1159,description:"Retrieves a Float value from the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified by\neither its ID or title.
\n",itemtype:"method",name:"getNum",params:[{name:"row",description:"row ID
\n",type:"Integer"},{name:"column",description:"columnName (string) or\n ID (number)
\n",type:"String|Integer"}],return:{description:"",type:"Number"},example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\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}\n
\n'],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:1204,description:"Retrieves a String value from the Table's specified row and column.\nThe row is specified by its ID, while the column may be specified by\neither its ID or title.
\n",itemtype:"method",name:"getString",params:[{name:"row",description:"row ID
\n",type:"Integer"},{name:"column",description:"columnName (string) or\n ID (number)
\n",type:"String|Integer"}],return:{description:"",type:"String"},example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value "CSV"\n // and has specifiying header for column labels\n table = loadTable(\'assets/mammals.csv\', \'csv\', \'header\');\n}\n\nfunction setup() {\n print(table.getString(0, 0)); // 0\n print(table.getString(0, 1)); // Capra hircus\n print(table.getString(0, 2)); // Goat\n print(table.getString(1, 0)); // 1\n print(table.getString(1, 1)); // Panthera pardus\n print(table.getString(1, 2)); // Leopard\n print(table.getString(2, 0)); // 2\n print(table.getString(2, 1)); // Equus zebra\n print(table.getString(2, 2)); // Zebra\n}\n
\n'],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:1257,description:"Retrieves all table data and returns as an object. If a column name is\npassed in, each row object will be stored with that attribute as its\ntitle.
\n",itemtype:"method",name:"getObject",params:[{name:"headerColumn",description:"Name of the column which should be used to\n title each row object (optional)
\n",type:"String",optional:!0}],return:{description:"",type:"Object"},example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder:\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leopard\n// 2,Equus zebra,Zebra\n\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
\n'],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.Table.js",line:1321,description:"Retrieves all table data and returns it as a multidimensional array.
\n",itemtype:"method",name:"getArray",return:{description:"",type:"Array"},example:['\n\n\n// Given the CSV file "mammals.csv"\n// in the project\'s "assets" folder\n//\n// id,species,name\n// 0,Capra hircus,Goat\n// 1,Panthera pardus,Leoperd\n// 2,Equus zebra,Zebra\n\nlet table;\n\nfunction preload() {\n // table is comma separated value "CSV"\n // and has specifiying header for column labels\n table = loadTable(\'assets/mammals.csv\', \'csv\', \'header\');\n}\n\nfunction setup() {\n let tableArray = table.getArray();\n for (let i = 0; i < tableArray.length; i++) {\n print(tableArray[i]);\n }\n}\n
\n'],alt:"no image displayed",class:"p5.Table",module:"IO",submodule:"Table"},{file:"src/io/p5.TableRow.js",line:40,description:"Stores a value in the TableRow's specified column.\nThe column may be specified by either its ID or title.
\n",itemtype:"method",name:"set",params:[{name:"column",description:"Column ID (Number)\n or Title (String)
\n",type:"String|Integer"},{name:"value",description:"The value to be stored
\n",type:"String|Number"}],example:["\n \n // Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\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
"],alt:"no image displayed",class:"p5.TableRow",module:"IO",submodule:"Table"},{file:"src/io/p5.TableRow.js",line:102,description:"Stores a Float value in the TableRow's specified column.\nThe column may be specified by either its ID or title.
\n",itemtype:"method",name:"setNum",params:[{name:"column",description:"Column ID (Number)\n or Title (String)
\n",type:"String|Integer"},{name:"value",description:"The value to be stored\n as a Float
\n",type:"Number|String"}],example:["\n \n // Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\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
"],alt:"no image displayed",class:"p5.TableRow",module:"IO",submodule:"Table"},{file:"src/io/p5.TableRow.js",line:146,description:"Stores a String value in the TableRow's specified column.\nThe column may be specified by either its ID or title.
\n",itemtype:"method",name:"setString",params:[{name:"column",description:"Column ID (Number)\n or Title (String)
\n",type:"String|Integer"},{name:"value",description:"The value to be stored\n as a String
\n",type:"String|Number|Boolean|Object"}],example:["\n \n // Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\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
"],alt:"no image displayed",class:"p5.TableRow",module:"IO",submodule:"Table"},{file:"src/io/p5.TableRow.js",line:191,description:"Retrieves a value from the TableRow's specified column.\nThe column may be specified by either its ID or title.
\n",itemtype:"method",name:"get",params:[{name:"column",description:"columnName (string) or\n ID (number)
\n",type:"String|Integer"}],return:{description:"",type:"String|Number"},example:["\n \n // Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\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
"],alt:"no image displayed",class:"p5.TableRow",module:"IO",submodule:"Table"},{file:"src/io/p5.TableRow.js",line:239,description:"Retrieves a Float value from the TableRow's specified\ncolumn. The column may be specified by either its ID or\ntitle.
\n",itemtype:"method",name:"getNum",params:[{name:"column",description:"columnName (string) or\n ID (number)
\n",type:"String|Integer"}],return:{description:"Float Floating point number",type:"Number"},example:["\n \n // Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\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 }\n
"],alt:"no image displayed",class:"p5.TableRow",module:"IO",submodule:"Table"},{file:"src/io/p5.TableRow.js",line:295,description:"Retrieves an String value from the TableRow's specified\ncolumn. The column may be specified by either its ID or\ntitle.
\n",itemtype:"method",name:"getString",params:[{name:"column",description:"columnName (string) or\n ID (number)
\n",type:"String|Integer"}],return:{description:"String",type:"String"},example:["\n \n // Given the CSV file \"mammals.csv\" in the project's \"assets\" folder:\n //\n // id,species,name\n // 0,Capra hircus,Goat\n // 1,Panthera pardus,Leopard\n // 2,Equus zebra,Zebra\n\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
"],alt:"no image displayed",class:"p5.TableRow",module:"IO",submodule:"Table"},{file:"src/io/p5.XML.js",line:63,description:'Gets a copy of the element's parent. Returns the parent as another\np5.XML object.
\n',itemtype:"method",name:"getParent",return:{description:"element parent",type:"p5.XML"},example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let children = xml.getChildren(\'animal\');\n let parent = children[1].getParent();\n print(parent.getName());\n}\n\n// Sketch prints:\n// mammals\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:101,description:"Gets the element's full name, which is returned as a String.
\n",itemtype:"method",name:"getName",return:{description:"the name of the node",type:"String"},example:['<animal\n \n // The following short XML file called "mammals.xml" is parsed\n // in the code below.\n //\n //\n // <mammals>\n // <animal id="0" species="Capra hircus">Goat</animal>\n // <animal id="1" species="Panthera pardus">Leopard</animal>\n // <animal id="2" species="Equus zebra">Zebra</animal>\n // </mammals>\n\n let xml;\n\n function preload() {\n xml = loadXML(\'assets/mammals.xml\');\n }\n\n function setup() {\n print(xml.getName());\n }\n\n // Sketch prints:\n // mammals\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:136,description:"Sets the element's name, which is specified as a String.
\n",itemtype:"method",name:"setName",params:[{name:"the",description:"new name of the node
\n",type:"String"}],example:['<animal\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n print(xml.getName());\n xml.setName(\'fish\');\n print(xml.getName());\n}\n\n// Sketch prints:\n// mammals\n// fish\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:182,description:"Checks whether or not the element has any children, and returns the result\nas a boolean.
\n",itemtype:"method",name:"hasChildren",return:{description:"",type:"Boolean"},example:['<animal\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n print(xml.hasChildren());\n}\n\n// Sketch prints:\n// true\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:218,description:'Get the names of all of the element's children, and returns the names as an\narray of Strings. This is the same as looping through and calling getName()\non each child element individually.
\n',itemtype:"method",name:"listChildren",return:{description:"names of the children of the element",type:"String[]"},example:['<animal\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n print(xml.listChildren());\n}\n\n// Sketch prints:\n// ["animal", "animal", "animal"]\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:259,description:'Returns all of the element's children as an array of p5.XML objects. When\nthe name parameter is specified, then it will return all children that match\nthat name.
\n',itemtype:"method",name:"getChildren",params:[{name:"name",description:"element name
\n",type:"String",optional:!0}],return:{description:"children of the element",type:"p5.XML[]"},example:['<animal\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let animals = xml.getChildren(\'animal\');\n\n for (let i = 0; i < animals.length; i++) {\n print(animals[i].getContent());\n }\n}\n\n// Sketch prints:\n// "Goat"\n// "Leopard"\n// "Zebra"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:315,description:"Returns the first of the element's children that matches the name parameter\nor the child of the given index.It returns undefined if no matching\nchild is found.
\n",itemtype:"method",name:"getChild",params:[{name:"name",description:"element name or index
\n",type:"String|Integer"}],return:{description:"",type:"p5.XML"},example:['<animal\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.getContent());\n}\n\n// Sketch prints:\n// "Goat"\n
\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let secondChild = xml.getChild(1);\n print(secondChild.getContent());\n}\n\n// Sketch prints:\n// "Leopard"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:375,description:'Appends a new child to the element. The child can be specified with\neither a String, which will be used as the new tag's name, or as a\nreference to an existing p5.XML object.\nA reference to the newly created child is returned as an p5.XML object.
\n',itemtype:"method",name:"addChild",params:[{name:"node",description:'a p5.XML Object which will be the child to be added
\n',type:"p5.XML"}],example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let child = new p5.XML();\n child.setName(\'animal\');\n child.setAttribute(\'id\', \'3\');\n child.setAttribute(\'species\', \'Ornithorhynchus anatinus\');\n child.setContent(\'Platypus\');\n xml.addChild(child);\n\n let animals = xml.getChildren(\'animal\');\n print(animals[animals.length - 1].getContent());\n}\n\n// Sketch prints:\n// "Goat"\n// "Leopard"\n// "Zebra"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:427,description:"Removes the element specified by name or index.
\n",itemtype:"method",name:"removeChild",params:[{name:"name",description:"element name or index
\n",type:"String|Integer"}],example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n xml.removeChild(\'animal\');\n let children = xml.getChildren();\n for (let i = 0; i < children.length; i++) {\n print(children[i].getContent());\n }\n}\n\n// Sketch prints:\n// "Leopard"\n// "Zebra"\n
\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n xml.removeChild(1);\n let children = xml.getChildren();\n for (let i = 0; i < children.length; i++) {\n print(children[i].getContent());\n }\n}\n\n// Sketch prints:\n// "Goat"\n// "Zebra"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:499,description:"Counts the specified element's number of attributes, returned as an Number.
\n",itemtype:"method",name:"getAttributeCount",return:{description:"",type:"Integer"},example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.getAttributeCount());\n}\n\n// Sketch prints:\n// 2\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:535,description:"Gets all of the specified element's attributes, and returns them as an\narray of Strings.
\n",itemtype:"method",name:"listAttributes",return:{description:"an array of strings containing the names of attributes",type:"String[]"},example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.listAttributes());\n}\n\n// Sketch prints:\n// ["id", "species"]\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:578,description:"Checks whether or not an element has the specified attribute.
\n",itemtype:"method",name:"hasAttribute",params:[{name:"the",description:"attribute to be checked
\n",type:"String"}],return:{description:"true if attribute found else false",type:"Boolean"},example:['\n \n // The following short XML file called "mammals.xml" is parsed\n // in the code below.\n //\n //\n // <mammals>\n // <animal id="0" species="Capra hircus">Goat</animal>\n // <animal id="1" species="Panthera pardus">Leopard</animal>\n // <animal id="2" species="Equus zebra">Zebra</animal>\n // </mammals>\n\n let xml;\n\n function preload() {\n xml = loadXML(\'assets/mammals.xml\');\n }\n\n function setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.hasAttribute(\'species\'));\n print(firstChild.hasAttribute(\'color\'));\n }\n\n // Sketch prints:\n // true\n // false\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:623,description:"Returns an attribute value of the element as an Number. If the defaultValue\nparameter is specified and the attribute doesn't exist, then defaultValue\nis returned. If no defaultValue is specified and the attribute doesn't\nexist, the value 0 is returned.
\n",itemtype:"method",name:"getNum",params:[{name:"name",description:"the non-null full name of the attribute
\n",type:"String"},{name:"defaultValue",description:"the default value of the attribute
\n",type:"Number",optional:!0}],return:{description:"",type:"Number"},example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.getNum(\'id\'));\n}\n\n// Sketch prints:\n// 0\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:670,description:"Returns an attribute value of the element as an String. If the defaultValue\nparameter is specified and the attribute doesn't exist, then defaultValue\nis returned. If no defaultValue is specified and the attribute doesn't\nexist, null is returned.
\n",itemtype:"method",name:"getString",params:[{name:"name",description:"the non-null full name of the attribute
\n",type:"String"},{name:"defaultValue",description:"the default value of the attribute
\n",type:"Number",optional:!0}],return:{description:"",type:"String"},example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.getString(\'species\'));\n}\n\n// Sketch prints:\n// "Capra hircus"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:717,description:"Sets the content of an element's attribute. The first parameter specifies\nthe attribute name, while the second specifies the new content.
\n",itemtype:"method",name:"setAttribute",params:[{name:"name",description:"the full name of the attribute
\n",type:"String"},{name:"value",description:"the value of the attribute
\n",type:"Number|String|Boolean"}],example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.getString(\'species\'));\n firstChild.setAttribute(\'species\', \'Jamides zebra\');\n print(firstChild.getString(\'species\'));\n}\n\n// Sketch prints:\n// "Capra hircus"\n// "Jamides zebra"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:758,description:"Returns the content of an element. If there is no such content,\ndefaultValue is returned if specified, otherwise null is returned.
\n",itemtype:"method",name:"getContent",params:[{name:"defaultValue",description:"value returned if no content is found
\n",type:"String",optional:!0}],return:{description:"",type:"String"},example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.getContent());\n}\n\n// Sketch prints:\n// "Goat"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:799,description:"Sets the element's content.
\n",itemtype:"method",name:"setContent",params:[{name:"text",description:"the new content
\n",type:"String"}],example:['\n\n// The following short XML file called "mammals.xml" is parsed\n// in the code below.\n//\n//\n// <mammals>\n// <animal id="0" species="Capra hircus">Goat</animal>\n// <animal id="1" species="Panthera pardus">Leopard</animal>\n// <animal id="2" species="Equus zebra">Zebra</animal>\n// </mammals>\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n let firstChild = xml.getChild(\'animal\');\n print(firstChild.getContent());\n firstChild.setContent(\'Mountain Goat\');\n print(firstChild.getContent());\n}\n\n// Sketch prints:\n// "Goat"\n// "Mountain Goat"\n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/io/p5.XML.js",line:840,description:"Serializes the element into a string. This function is useful for preparing\nthe content to be sent over a http request or saved to file.
\n",itemtype:"method",name:"serialize",return:{description:"Serialized string of the element",type:"String"},example:['\n\nlet xml;\n\nfunction preload() {\n xml = loadXML(\'assets/mammals.xml\');\n}\n\nfunction setup() {\n print(xml.serialize());\n}\n\n// Sketch prints:\n// \n// Goat \n// Leopard \n// Zebra \n// \n
'],class:"p5.XML",module:"IO",submodule:"Input"},{file:"src/math/calculation.js",line:10,description:"Calculates the absolute value (magnitude) of a number. Maps to Math.abs().\nThe absolute value of a number is always positive.
\n",itemtype:"method",name:"abs",params:[{name:"n",description:"number to compute
\n",type:"Number"}],return:{description:"absolute value of given number",type:"Number"},example:['\n\nfunction setup() {\n let x = -3;\n let y = abs(x);\n\n print(x); // -3\n print(y); // 3\n}\n
'],alt:"no image displayed",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:34,description:"Calculates the closest int value that is greater than or equal to the\nvalue of the parameter. Maps to Math.ceil(). For example, ceil(9.03)\nreturns the value 10.
\n",itemtype:"method",name:"ceil",params:[{name:"n",description:"number to round up
\n",type:"Number"}],return:{description:"rounded up number",type:"Integer"},example:["\n\nfunction draw() {\n background(200);\n // map, mouseX between 0 and 5.\n let ax = map(mouseX, 0, 100, 0, 5);\n let ay = 66;\n\n //Get the ceiling of the mapped number.\n let bx = ceil(map(mouseX, 0, 100, 0, 5));\n let by = 33;\n\n // Multiply the mapped numbers by 20 to more easily\n // see the changes.\n stroke(0);\n fill(0);\n line(0, ay, ax * 20, ay);\n line(0, by, bx * 20, by);\n\n // Reformat the float returned by map and draw it.\n noStroke();\n text(nfc(ax, 2), ax, ay - 5);\n text(nfc(bx, 1), bx, by - 5);\n}\n
"],alt:"2 horizontal lines & number sets. increase with mouse x. bottom to 2 decimals",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:74,description:"Constrains a value between a minimum and maximum value.
\n",itemtype:"method",name:"constrain",params:[{name:"n",description:"number to constrain
\n",type:"Number"},{name:"low",description:"minimum limit
\n",type:"Number"},{name:"high",description:"maximum limit
\n",type:"Number"}],return:{description:"constrained number",type:"Number"},example:["\n\nfunction draw() {\n background(200);\n\n let leftWall = 25;\n let rightWall = 75;\n\n // xm is just the mouseX, while\n // xc is the mouseX, but constrained\n // between the leftWall and rightWall!\n let xm = mouseX;\n let xc = constrain(mouseX, leftWall, rightWall);\n\n // Draw the walls.\n stroke(150);\n line(leftWall, 0, leftWall, height);\n line(rightWall, 0, rightWall, height);\n\n // Draw xm and xc as circles.\n noStroke();\n fill(150);\n ellipse(xm, 33, 9, 9); // Not Constrained\n fill(0);\n ellipse(xc, 66, 9, 9); // Constrained\n}\n
"],alt:"2 vertical lines. 2 ellipses move with mouse X 1 does not move passed lines",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:119,description:"Calculates the distance between two points, in either two or three dimensions.
\n",itemtype:"method",name:"dist",return:{description:"distance between the two points",type:"Number"},example:["\n\n// Move your mouse inside the canvas to see the\n// change in distance between two points!\nfunction draw() {\n background(200);\n fill(0);\n\n let x1 = 10;\n let y1 = 90;\n let x2 = mouseX;\n let y2 = mouseY;\n\n line(x1, y1, x2, y2);\n ellipse(x1, y1, 7, 7);\n ellipse(x2, y2, 7, 7);\n\n // d is the length of the line\n // the distance from point 1 to point 2.\n let d = int(dist(x1, y1, x2, y2));\n\n // Let's write d along the line we are drawing!\n push();\n translate((x1 + x2) / 2, (y1 + y2) / 2);\n rotate(atan2(y2 - y1, x2 - x1));\n text(nfc(d, 1), 0, -5);\n pop();\n // Fancy!\n}\n
"],alt:"2 ellipses joined by line. 1 ellipse moves with mouse X&Y. Distance displayed.",class:"p5",module:"Math",submodule:"Calculation",overloads:[{line:119,params:[{name:"x1",description:"x-coordinate of the first point
\n",type:"Number"},{name:"y1",description:"y-coordinate of the first point
\n",type:"Number"},{name:"x2",description:"x-coordinate of the second point
\n",type:"Number"},{name:"y2",description:"y-coordinate of the second point
\n",type:"Number"}],return:{description:"distance between the two points",type:"Number"}},{line:163,params:[{name:"x1",description:"",type:"Number"},{name:"y1",description:"",type:"Number"},{name:"z1",description:"z-coordinate of the first point
\n",type:"Number"},{name:"x2",description:"",type:"Number"},{name:"y2",description:"",type:"Number"},{name:"z2",description:"z-coordinate of the second point
\n",type:"Number"}],return:{description:"distance between the two points",type:"Number"}}]},{file:"src/math/calculation.js",line:184,description:"Returns Euler's number e (2.71828...) raised to the power of the n\nparameter. Maps to Math.exp().
\n",itemtype:"method",name:"exp",params:[{name:"n",description:"exponent to raise
\n",type:"Number"}],return:{description:"e^n",type:"Number"},example:["\n\nfunction draw() {\n background(200);\n\n // Compute the exp() function with a value between 0 and 2\n let xValue = map(mouseX, 0, width, 0, 2);\n let yValue = exp(xValue);\n\n let y = map(yValue, 0, 8, height, 0);\n\n let legend = 'exp (' + nfc(xValue, 3) + ')\\n= ' + nf(yValue, 1, 4);\n stroke(150);\n line(mouseX, y, mouseX, height);\n fill(0);\n text(legend, 5, 15);\n noStroke();\n ellipse(mouseX, y, 7, 7);\n\n // Draw the exp(x) curve,\n // over the domain of x from 0 to 2\n noFill();\n stroke(0);\n beginShape();\n for (let x = 0; x < width; x++) {\n xValue = map(x, 0, width, 0, 2);\n yValue = exp(xValue);\n y = map(yValue, 0, 8, height, 0);\n vertex(x, y);\n }\n\n endShape();\n line(0, 0, 0, height);\n line(0, height - 1, width, height - 1);\n}\n
"],alt:"ellipse moves along a curve with mouse x. e^n displayed.",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:234,description:"Calculates the closest int value that is less than or equal to the\nvalue of the parameter. Maps to Math.floor().
\n",itemtype:"method",name:"floor",params:[{name:"n",description:"number to round down
\n",type:"Number"}],return:{description:"rounded down number",type:"Integer"},example:["\n\nfunction draw() {\n background(200);\n //map, mouseX between 0 and 5.\n let ax = map(mouseX, 0, 100, 0, 5);\n let ay = 66;\n\n //Get the floor of the mapped number.\n let bx = floor(map(mouseX, 0, 100, 0, 5));\n let by = 33;\n\n // Multiply the mapped numbers by 20 to more easily\n // see the changes.\n stroke(0);\n fill(0);\n line(0, ay, ax * 20, ay);\n line(0, by, bx * 20, by);\n\n // Reformat the float returned by map and draw it.\n noStroke();\n text(nfc(ax, 2), ax, ay - 5);\n text(nfc(bx, 1), bx, by - 5);\n}\n
"],alt:"2 horizontal lines & number sets. increase with mouse x. bottom to 2 decimals",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:273,description:"Calculates a number between two numbers at a specific increment. The amt\nparameter is the amount to interpolate between the two values where 0.0\nequal to the first point, 0.1 is very near the first point, 0.5 is\nhalf-way in between, and 1.0 is equal to the second point. If the\nvalue of amt is more than 1.0 or less than 0.0, the number will be\ncalculated accordingly in the ratio of the two given numbers. The lerp\nfunction is convenient for creating motion along a straight\npath and for drawing dotted lines.
\n",itemtype:"method",name:"lerp",params:[{name:"start",description:"first value
\n",type:"Number"},{name:"stop",description:"second value
\n",type:"Number"},{name:"amt",description:"number
\n",type:"Number"}],return:{description:"lerped value",type:"Number"},example:["\n\nfunction setup() {\n background(200);\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 let y = 50;\n\n strokeWeight(5);\n stroke(0); // Draw the original points in black\n point(a, y);\n point(b, y);\n\n stroke(100); // Draw the lerp points in gray\n point(c, y);\n point(d, y);\n point(e, y);\n}\n
"],alt:"5 points horizontally staggered mid-canvas. mid 3 are grey, outer black",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:321,description:"Calculates the natural logarithm (the base-e logarithm) of a number. This\nfunction expects the n parameter to be a value greater than 0.0. Maps to\nMath.log().
\n",itemtype:"method",name:"log",params:[{name:"n",description:"number greater than 0
\n",type:"Number"}],return:{description:"natural logarithm of n",type:"Number"},example:["\n\nfunction draw() {\n background(200);\n let maxX = 2.8;\n let maxY = 1.5;\n\n // Compute the natural log of a value between 0 and maxX\n let xValue = map(mouseX, 0, width, 0, maxX);\n let yValue, y;\n if (xValue > 0) {\n // Cannot take the log of a negative number.\n yValue = log(xValue);\n y = map(yValue, -maxY, maxY, height, 0);\n\n // Display the calculation occurring.\n let legend = 'log(' + nf(xValue, 1, 2) + ')\\n= ' + nf(yValue, 1, 3);\n stroke(150);\n line(mouseX, y, mouseX, height);\n fill(0);\n text(legend, 5, 15);\n noStroke();\n ellipse(mouseX, y, 7, 7);\n }\n\n // Draw the log(x) curve,\n // over the domain of x from 0 to maxX\n noFill();\n stroke(0);\n beginShape();\n for (let x = 0; x < width; x++) {\n xValue = map(x, 0, width, 0, maxX);\n yValue = log(xValue);\n y = map(yValue, -maxY, maxY, height, 0);\n vertex(x, y);\n }\n endShape();\n line(0, 0, 0, height);\n line(0, height / 2, width, height / 2);\n}\n
"],alt:"ellipse moves along a curve with mouse x. natural logarithm of n displayed.",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:377,description:'Calculates the magnitude (or length) of a vector. A vector is a direction\nin space commonly used in computer graphics and linear algebra. Because it\nhas no "start" position, the magnitude of a vector can be thought of as\nthe distance from the coordinate 0,0 to its x,y value. Therefore, mag() is\na shortcut for writing dist(0, 0, x, y).
\n',itemtype:"method",name:"mag",params:[{name:"a",description:"first value
\n",type:"Number"},{name:"b",description:"second value
\n",type:"Number"}],return:{description:"magnitude of vector from (0,0) to (a,b)",type:"Number"},example:['\n\nfunction setup() {\n let x1 = 20;\n let x2 = 80;\n let y1 = 30;\n let y2 = 70;\n\n line(0, 0, x1, y1);\n print(mag(x1, y1)); // Prints "36.05551275463989"\n line(0, 0, x2, y1);\n print(mag(x2, y1)); // Prints "85.44003745317531"\n line(0, 0, x1, y2);\n print(mag(x1, y2)); // Prints "72.80109889280519"\n line(0, 0, x2, y2);\n print(mag(x2, y2)); // Prints "106.3014581273465"\n}\n
'],alt:"4 lines of different length radiate from top left of canvas.",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:416,description:"Re-maps a number from one range to another.\n
\nIn the first example above, the number 25 is converted from a value in the\nrange of 0 to 100 into a value that ranges from the left edge of the\nwindow (0) to the right edge (width).
\n",itemtype:"method",name:"map",params:[{name:"value",description:"the incoming value to be converted
\n",type:"Number"},{name:"start1",description:"lower bound of the value's current range
\n",type:"Number"},{name:"stop1",description:"upper bound of the value's current range
\n",type:"Number"},{name:"start2",description:"lower bound of the value's target range
\n",type:"Number"},{name:"stop2",description:"upper bound of the value's target range
\n",type:"Number"},{name:"withinBounds",description:"constrain the value to the newly mapped range
\n",type:"Boolean",optional:!0}],return:{description:"remapped number",type:"Number"},example:["\n \nlet value = 25;\nlet m = map(value, 0, 100, 0, width);\nellipse(m, 50, 10, 10);\n
\n\n \nfunction setup() {\n noStroke();\n}\n\nfunction draw() {\n background(204);\n let x1 = map(mouseX, 0, width, 25, 75);\n ellipse(x1, 25, 25, 25);\n //This ellipse is constrained to the 0-100 range\n //after setting withinBounds to true\n let x2 = map(mouseX, 0, width, 0, 100, true);\n ellipse(x2, 75, 25, 25);\n}\n
"],alt:"10 by 10 white ellipse with in mid left canvas\n2 25 by 25 white ellipses move with mouse x. Bottom has more range from X",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:472,description:'Determines the largest value in a sequence of numbers, and then returns\nthat value. max() accepts any number of Number parameters, or an Array\nof any length.
\n',itemtype:"method",name:"max",return:{description:"maximum Number",type:"Number"},example:["\n\nfunction setup() {\n // Change the elements in the array and run the sketch\n // to show how max() works!\n let numArray = [2, 1, 5, 4, 8, 9];\n fill(0);\n noStroke();\n text('Array Elements', 0, 10);\n // Draw all numbers in the array\n let spacing = 15;\n let elemsY = 25;\n for (let i = 0; i < numArray.length; i++) {\n text(numArray[i], i * spacing, elemsY);\n }\n let maxX = 33;\n let maxY = 80;\n // Draw the Maximum value in the array.\n textSize(32);\n text(max(numArray), maxX, maxY);\n}\n
"],alt:"Small text at top reads: Array Elements 2 1 5 4 8 9. Large text at center: 9",class:"p5",module:"Math",submodule:"Calculation",overloads:[{line:472,params:[{name:"n0",description:"Number to compare
\n",type:"Number"},{name:"n1",description:"Number to compare
\n",type:"Number"}],return:{description:"maximum Number",type:"Number"}},{line:508,params:[{name:"nums",description:"Numbers to compare
\n",type:"Number[]"}],return:{description:"",type:"Number"}}]},{file:"src/math/calculation.js",line:522,description:'Determines the smallest value in a sequence of numbers, and then returns\nthat value. min() accepts any number of Number parameters, or an Array\nof any length.
\n',itemtype:"method",name:"min",return:{description:"minimum Number",type:"Number"},example:["\n\nfunction setup() {\n // Change the elements in the array and run the sketch\n // to show how min() works!\n let numArray = [2, 1, 5, 4, 8, 9];\n fill(0);\n noStroke();\n text('Array Elements', 0, 10);\n // Draw all numbers in the array\n let spacing = 15;\n let elemsY = 25;\n for (let i = 0; i < numArray.length; i++) {\n text(numArray[i], i * spacing, elemsY);\n }\n let maxX = 33;\n let maxY = 80;\n // Draw the Minimum value in the array.\n textSize(32);\n text(min(numArray), maxX, maxY);\n}\n
"],alt:"Small text at top reads: Array Elements 2 1 5 4 8 9. Large text at center: 1",class:"p5",module:"Math",submodule:"Calculation",overloads:[{line:522,params:[{name:"n0",description:"Number to compare
\n",type:"Number"},{name:"n1",description:"Number to compare
\n",type:"Number"}],return:{description:"minimum Number",type:"Number"}},{line:558,params:[{name:"nums",description:"Numbers to compare
\n",type:"Number[]"}],return:{description:"",type:"Number"}}]},{file:"src/math/calculation.js",line:572,description:"Normalizes a number from another range into a value between 0 and 1.\nIdentical to map(value, low, high, 0, 1).\nNumbers outside of the range are not clamped to 0 and 1, because\nout-of-range values are often intentional and useful. (See the example above.)
\n",itemtype:"method",name:"norm",params:[{name:"value",description:"incoming value to be normalized
\n",type:"Number"},{name:"start",description:"lower bound of the value's current range
\n",type:"Number"},{name:"stop",description:"upper bound of the value's current range
\n",type:"Number"}],return:{description:"normalized number",type:"Number"},example:["\n\nfunction draw() {\n background(200);\n let currentNum = mouseX;\n let lowerBound = 0;\n let upperBound = width; //100;\n let normalized = norm(currentNum, lowerBound, upperBound);\n let lineY = 70;\n stroke(3);\n line(0, lineY, width, lineY);\n //Draw an ellipse mapped to the non-normalized value.\n noStroke();\n fill(50);\n let s = 7; // ellipse size\n ellipse(currentNum, lineY, s, s);\n\n // Draw the guide\n let guideY = lineY + 15;\n text('0', 0, guideY);\n textAlign(RIGHT);\n text('100', width, guideY);\n\n // Draw the normalized value\n textAlign(LEFT);\n fill(0);\n textSize(32);\n let normalY = 40;\n let normalX = 20;\n text(normalized, normalX, normalY);\n}\n
"],alt:"ellipse moves with mouse. 0 shown left & 100 right and updating values center",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:625,description:'Facilitates exponential expressions. The pow() function is an efficient\nway of multiplying numbers by themselves (or their reciprocals) in large\nquantities. For example, pow(3, 5) is equivalent to the expression\n3 × 3 × 3 × 3 × 3 and pow(3, -5) is equivalent to 1 /\n3 × 3 × 3 × 3 × 3. Maps to\nMath.pow().
\n',itemtype:"method",name:"pow",params:[{name:"n",description:"base of the exponential expression
\n",type:"Number"},{name:"e",description:"power by which to raise the base
\n",type:"Number"}],return:{description:"n^e",type:"Number"},example:["\n\nfunction setup() {\n //Exponentially increase the size of an ellipse.\n let eSize = 3; // Original Size\n let eLoc = 10; // Original Location\n\n ellipse(eLoc, eLoc, eSize, eSize);\n\n ellipse(eLoc * 2, eLoc * 2, pow(eSize, 2), pow(eSize, 2));\n\n ellipse(eLoc * 4, eLoc * 4, pow(eSize, 3), pow(eSize, 3));\n\n ellipse(eLoc * 8, eLoc * 8, pow(eSize, 4), pow(eSize, 4));\n}\n
"],alt:"small to large ellipses radiating from top left of canvas",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:660,description:"Calculates the integer closest to the n parameter. For example,\nround(133.8) returns the value 134. Maps to Math.round().
\n",itemtype:"method",name:"round",params:[{name:"n",description:"number to round
\n",type:"Number"},{name:"decimals",description:"number of decimal places to round to, default is 0
\n",type:"Number",optional:!0}],return:{description:"rounded number",type:"Integer"},example:["\n\nlet x = round(3.7);\ntext(x, width / 2, height / 2);\n
\n\nlet x = round(12.782383, 2);\ntext(x, width / 2, height / 2);\n
\n\nfunction draw() {\n background(200);\n //map, mouseX between 0 and 5.\n let ax = map(mouseX, 0, 100, 0, 5);\n let ay = 66;\n\n // Round the mapped number.\n let bx = round(map(mouseX, 0, 100, 0, 5));\n let by = 33;\n\n // Multiply the mapped numbers by 20 to more easily\n // see the changes.\n stroke(0);\n fill(0);\n line(0, ay, ax * 20, ay);\n line(0, by, bx * 20, by);\n\n // Reformat the float returned by map and draw it.\n noStroke();\n text(nfc(ax, 2), ax, ay - 5);\n text(nfc(bx, 1), bx, by - 5);\n}\n
"],alt:'"3" written in middle of canvas\n"12.78" written in middle of canvas\nhorizontal center line squared values displayed on top and regular on bottom.',class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:715,description:"Squares a number (multiplies a number by itself). The result is always a\npositive number, as multiplying two negative numbers always yields a\npositive result. For example, -1 * -1 = 1.
\n",itemtype:"method",name:"sq",params:[{name:"n",description:"number to square
\n",type:"Number"}],return:{description:"squared number",type:"Number"},example:["\n\nfunction draw() {\n background(200);\n let eSize = 7;\n let x1 = map(mouseX, 0, width, 0, 10);\n let y1 = 80;\n let x2 = sq(x1);\n let y2 = 20;\n\n // Draw the non-squared.\n line(0, y1, width, y1);\n ellipse(x1, y1, eSize, eSize);\n\n // Draw the squared.\n line(0, y2, width, y2);\n ellipse(x2, y2, eSize, eSize);\n\n // Draw dividing line.\n stroke(100);\n line(0, height / 2, width, height / 2);\n\n // Draw text.\n let spacing = 15;\n noStroke();\n fill(0);\n text('x = ' + x1, 0, y1 + spacing);\n text('sq(x) = ' + x2, 0, y2 + spacing);\n}\n
"],alt:"horizontal center line squared values displayed on top and regular on bottom.",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:760,description:"Calculates the square root of a number. The square root of a number is\nalways positive, even though there may be a valid negative root. The\nsquare root s of number a is such that s*s = a. It is the opposite of\nsquaring. Maps to Math.sqrt().
\n",itemtype:"method",name:"sqrt",params:[{name:"n",description:"non-negative number to square root
\n",type:"Number"}],return:{description:"square root of number",type:"Number"},example:["\n\nfunction draw() {\n background(200);\n let eSize = 7;\n let x1 = mouseX;\n let y1 = 80;\n let x2 = sqrt(x1);\n let y2 = 20;\n\n // Draw the non-squared.\n line(0, y1, width, y1);\n ellipse(x1, y1, eSize, eSize);\n\n // Draw the squared.\n line(0, y2, width, y2);\n ellipse(x2, y2, eSize, eSize);\n\n // Draw dividing line.\n stroke(100);\n line(0, height / 2, width, height / 2);\n\n // Draw text.\n noStroke();\n fill(0);\n let spacing = 15;\n text('x = ' + x1, 0, y1 + spacing);\n text('sqrt(x) = ' + x2, 0, y2 + spacing);\n}\n
"],alt:"horizontal center line squareroot values displayed on top and regular on bottom.",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/calculation.js",line:848,description:"Calculates the fractional part of a number.
\n",itemtype:"method",name:"fract",params:[{name:"num",description:"Number whose fractional part needs to be found out
\n",type:"Number"}],return:{description:"fractional part of x, i.e, {x}",type:"Number"},example:["\n\n\nfunction setup() {\n createCanvas(windowWidth, windowHeight);\n fill(0);\n text(7345.73472742, 0, 50);\n text(fract(7345.73472742), 0, 100);\n text(1.4215e-15, 150, 50);\n text(fract(1.4215e-15), 150, 100);\n}\n
\n"],alt:"2 rows of numbers, the first row having 8 numbers and the second having the fractional parts of those numbers.",class:"p5",module:"Math",submodule:"Calculation"},{file:"src/math/math.js",line:10,description:'Creates a new p5.Vector (the datatype for storing vectors). This provides a\ntwo or three dimensional vector, specifically a Euclidean (also known as\ngeometric) vector. A vector is an entity that has both magnitude and\ndirection.
\n',itemtype:"method",name:"createVector",params:[{name:"x",description:"x component of the vector
\n",type:"Number",optional:!0},{name:"y",description:"y component of the vector
\n",type:"Number",optional:!0},{name:"z",description:"z component of the vector
\n",type:"Number",optional:!0}],return:{description:"",type:"p5.Vector"},example:["\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n fill(255, 102, 204);\n}\n\nfunction draw() {\n background(255);\n pointLight(color(255), createVector(sin(millis() / 1000) * 20, -40, -10));\n scale(0.75);\n sphere();\n}\n
"],alt:"a purple sphere lit by a point light oscillating horizontally",class:"p5",module:"Math",submodule:"Vector"},{file:"src/math/noise.js",line:36,description:'Returns the Perlin noise value at specified coordinates. Perlin noise is\na random sequence generator producing a more natural ordered, harmonic\nsuccession of numbers compared to the standard random() function.\nIt was invented by Ken Perlin in the 1980s and been used since in\ngraphical applications to produce procedural textures, natural motion,\nshapes, terrains etc.
The main difference to the\nrandom() function is that Perlin noise is defined in an infinite\nn-dimensional space where each pair of coordinates corresponds to a\nfixed semi-random value (fixed only for the lifespan of the program; see\nthe noiseSeed() function). p5.js can compute 1D, 2D and 3D noise,\ndepending on the number of coordinates given. The resulting value will\nalways be between 0.0 and 1.0. The noise value can be animated by moving\nthrough the noise space as demonstrated in the example above. The 2nd\nand 3rd dimension can also be interpreted as time.
The actual\nnoise is structured similar to an audio signal, in respect to the\nfunction's use of frequencies. Similar to the concept of harmonics in\nphysics, perlin noise is computed over several octaves which are added\ntogether for the final result.
Another way to adjust the\ncharacter of the resulting sequence is the scale of the input\ncoordinates. As the function works within an infinite space the value of\nthe coordinates doesn't matter as such, only the distance between\nsuccessive coordinates does (eg. when using noise() within a\nloop). As a general rule the smaller the difference between coordinates,\nthe smoother the resulting noise sequence will be. Steps of 0.005-0.03\nwork best for most applications, but this will differ depending on use.
\n',itemtype:"method",name:"noise",params:[{name:"x",description:"x-coordinate in noise space
\n",type:"Number"},{name:"y",description:"y-coordinate in noise space
\n",type:"Number",optional:!0},{name:"z",description:"z-coordinate in noise space
\n",type:"Number",optional:!0}],return:{description:"Perlin noise value (between 0 and 1) at specified\n coordinates",type:"Number"},example:["\n\n\nlet xoff = 0.0;\n\nfunction draw() {\n background(204);\n xoff = xoff + 0.01;\n let n = noise(xoff) * width;\n line(n, 0, n, height);\n}\n
\n\n\nlet noiseScale=0.02;\n\nfunction draw() {\n background(0);\n for (let x=0; x < width; x++) {\n let noiseVal = noise((mouseX+x)*noiseScale, mouseY*noiseScale);\n stroke(noiseVal*255);\n line(x, mouseY+noiseVal*80, x, height);\n }\n}\n
\n"],alt:"vertical line moves left to right with updating noise values.\nhorizontal wave pattern effected by mouse x-position & updating noise values.",class:"p5",module:"Math",submodule:"Noise"},{file:"src/math/noise.js",line:180,description:"Adjusts the character and level of detail produced by the Perlin noise\n function. Similar to harmonics in physics, noise is computed over\n several octaves. Lower octaves contribute more to the output signal and\n as such define the overall intensity of the noise, whereas higher octaves\n create finer grained details in the noise sequence.\n
\n By default, noise is computed over 4 octaves with each octave contributing\n exactly half than its predecessor, starting at 50% strength for the 1st\n octave. This falloff amount can be changed by adding an additional function\n parameter. Eg. a falloff factor of 0.75 means each octave will now have\n 75% impact (25% less) of the previous lower octave. Any value between\n 0.0 and 1.0 is valid, however note that values greater than 0.5 might\n result in greater than 1.0 values returned by noise().\n
\n By changing these parameters, the signal created by the noise()\n function can be adapted to fit very specific needs and characteristics.
\n",itemtype:"method",name:"noiseDetail",params:[{name:"lod",description:"number of octaves to be used by the noise
\n",type:"Number"},{name:"falloff",description:"falloff factor for each octave
\n",type:"Number"}],example:["\n \n \n let noiseVal;\n let noiseScale = 0.02;\nfunction setup() {\n createCanvas(100, 100);\n }\nfunction draw() {\n background(0);\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width / 2; x++) {\n noiseDetail(2, 0.2);\n noiseVal = noise((mouseX + x) * noiseScale, (mouseY + y) * noiseScale);\n stroke(noiseVal * 255);\n point(x, y);\n noiseDetail(8, 0.65);\n noiseVal = noise(\n (mouseX + x + width / 2) * noiseScale,\n (mouseY + y) * noiseScale\n );\n stroke(noiseVal * 255);\n point(x + width / 2, y);\n }\n }\n }\n
\n "],alt:"2 vertical grey smokey patterns affected my mouse x-position and noise.",class:"p5",module:"Math",submodule:"Noise"},{file:"src/math/noise.js",line:246,description:"Sets the seed value for noise(). By default, noise()\nproduces different results each time the program is run. Set the\nvalue parameter to a constant to return the same pseudo-random\nnumbers each time the software is run.
\n",itemtype:"method",name:"noiseSeed",params:[{name:"seed",description:"the seed value
\n",type:"Number"}],example:["\n\nlet xoff = 0.0;\n\nfunction setup() {\n noiseSeed(99);\n stroke(0, 10);\n}\n\nfunction draw() {\n xoff = xoff + .01;\n let n = noise(xoff) * width;\n line(n, 0, n, height);\n}\n
\n"],alt:"vertical grey lines drawing in pattern affected by noise.",class:"p5",module:"Math",submodule:"Noise"},{file:"src/math/p5.Vector.js",line:66,description:"The x component of the vector
\n",itemtype:"property",name:"x",type:"Number",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:71,description:"The y component of the vector
\n",itemtype:"property",name:"y",type:"Number",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:76,description:"The z component of the vector
\n",itemtype:"property",name:"z",type:"Number",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:83,description:"Returns a string representation of a vector v by calling String(v)\nor v.toString(). This method is useful for logging vectors in the\nconsole.
\n",itemtype:"method",name:"toString",return:{description:"",type:"String"},example:['\n\n\nfunction setup() {\n let v = createVector(20, 30);\n print(String(v)); // prints "p5.Vector Object : [20, 30, 0]"\n}\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n let v1 = createVector(mouseX, mouseY);\n drawArrow(v0, v1, \'black\');\n\n noStroke();\n text(v1.toString(), 10, 25, 90, 75);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n'],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:133,description:'Sets the x, y, and z component of the vector using two or three separate\nvariables, the data from a p5.Vector, or the values from a float array.
\n',itemtype:"method",name:"set",chainable:1,example:["\n\n\nfunction setup() {\n let v = createVector(1, 2, 3);\n v.set(4, 5, 6); // Sets vector to [4, 5, 6]\n\n let v1 = createVector(0, 0, 0);\n let arr = [1, 2, 3];\n v1.set(arr); // Sets vector to [1, 2, 3]\n}\n
\n\n\n\n\nlet v0, v1;\nfunction setup() {\n createCanvas(100, 100);\n\n v0 = createVector(0, 0);\n v1 = createVector(50, 50);\n}\n\nfunction draw() {\n background(240);\n\n drawArrow(v0, v1, 'black');\n v1.set(v1.x + random(-1, 1), v1.y + random(-1, 1));\n\n noStroke();\n text('x: ' + round(v1.x) + ' y: ' + round(v1.y), 20, 90);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:133,params:[{name:"x",description:"the x component of the vector
\n",type:"Number",optional:!0},{name:"y",description:"the y component of the vector
\n",type:"Number",optional:!0},{name:"z",description:"the z component of the vector
\n",type:"Number",optional:!0}],chainable:1},{line:192,params:[{name:"value",description:"the vector to set
\n",type:"p5.Vector|Number[]"}],chainable:1}]},{file:"src/math/p5.Vector.js",line:216,description:'Gets a copy of the vector, returns a p5.Vector object.
\n',itemtype:"method",name:"copy",return:{description:'the copy of the p5.Vector object',type:"p5.Vector"},example:['\n\n\nlet v1 = createVector(1, 2, 3);\nlet v2 = v1.copy();\nprint(v1.x === v2.x && v1.y === v2.y && v1.z === v2.z);\n// Prints "true"\n
\n'],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:239,description:'Adds x, y, and z components to a vector, adds one vector to another, or\nadds two independent vectors together. The version of the method that adds\ntwo vectors together is a static method and returns a p5.Vector, the others\nacts directly on the vector. See the examples for more context.
\n',itemtype:"method",name:"add",chainable:1,example:["\n\n\nlet v = createVector(1, 2, 3);\nv.add(4, 5, 6);\n// v's components are set to [5, 7, 9]\n
\n\n\n\n\n// Static method\nlet v1 = createVector(1, 2, 3);\nlet v2 = createVector(2, 3, 4);\n\nlet v3 = p5.Vector.add(v1, v2);\n// v3 has components [3, 5, 7]\nprint(v3);\n
\n\n\n\n\n// red vector + blue vector = purple vector\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n let v1 = createVector(mouseX, mouseY);\n drawArrow(v0, v1, 'red');\n\n let v2 = createVector(-30, 20);\n drawArrow(v1, v2, 'blue');\n\n let v3 = p5.Vector.add(v1, v2);\n drawArrow(v0, v3, 'purple');\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:239,params:[{name:"x",description:"the x component of the vector to be added
\n",type:"Number"},{name:"y",description:"the y component of the vector to be added
\n",type:"Number",optional:!0},{name:"z",description:"the z component of the vector to be added
\n",type:"Number",optional:!0}],chainable:1},{line:305,params:[{name:"value",description:"the vector to add
\n",type:"p5.Vector|Number[]"}],chainable:1},{line:1720,params:[{name:"v1",description:'a p5.Vector to add
\n',type:"p5.Vector"},{name:"v2",description:'a p5.Vector to add
\n',type:"p5.Vector"},{name:"target",description:"the vector to receive the result
\n",type:"p5.Vector"}],static:1},{line:1727,params:[{name:"v1",description:"",type:"p5.Vector"},{name:"v2",description:"",type:"p5.Vector"}],static:1,return:{description:'the resulting p5.Vector',type:"p5.Vector"}}]},{file:"src/math/p5.Vector.js",line:352,description:"Gives remainder of a vector when it is divided by another vector.\nSee examples for more context.
\n",itemtype:"method",name:"rem",chainable:1,example:["\n\n\nlet v = createVector(3, 4, 5);\nv.rem(2, 3, 4);\n// v's components are set to [1, 1, 1]\n
\n\n\n\n// Static method\nlet v1 = createVector(3, 4, 5);\nlet v2 = createVector(2, 3, 4);\n\nlet v3 = p5.Vector.rem(v1, v2);\n// v3 has components [1, 1, 1]\nprint(v3);\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:352,params:[{name:"x",description:"the x component of divisor vector
\n",type:"Number"},{name:"y",description:"the y component of divisor vector
\n",type:"Number"},{name:"z",description:"the z component of divisor vector
\n",type:"Number"}],chainable:1},{line:381,params:[{name:"value",description:"divisor vector
\n",type:"p5.Vector | Number[]"}],chainable:1},{line:1747,params:[{name:"v1",description:'dividend p5.Vector
\n',type:"p5.Vector"},{name:"v2",description:'divisor p5.Vector
\n',type:"p5.Vector"}],static:1},{line:1753,params:[{name:"v1",description:"",type:"p5.Vector"},{name:"v2",description:"",type:"p5.Vector"}],static:1,return:{description:'the resulting p5.Vector',type:"p5.Vector"}}]},{file:"src/math/p5.Vector.js",line:436,description:'Subtracts x, y, and z components from a vector, subtracts one vector from\nanother, or subtracts two independent vectors. The version of the method\nthat subtracts two vectors is a static method and returns a p5.Vector, the\nother acts directly on the vector. See the examples for more context.
\n',itemtype:"method",name:"sub",chainable:1,example:["\n\n\nlet v = createVector(4, 5, 6);\nv.sub(1, 1, 1);\n// v's components are set to [3, 4, 5]\n
\n\n\n\n\n// Static method\nlet v1 = createVector(2, 3, 4);\nlet v2 = createVector(1, 2, 3);\n\nlet v3 = p5.Vector.sub(v1, v2);\n// v3 has components [1, 1, 1]\nprint(v3);\n
\n\n\n\n\n// red vector - blue vector = purple vector\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n let v1 = createVector(70, 50);\n drawArrow(v0, v1, 'red');\n\n let v2 = createVector(mouseX, mouseY);\n drawArrow(v0, v2, 'blue');\n\n let v3 = p5.Vector.sub(v1, v2);\n drawArrow(v2, v3, 'purple');\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:436,params:[{name:"x",description:"the x component of the vector to subtract
\n",type:"Number"},{name:"y",description:"the y component of the vector to subtract
\n",type:"Number",optional:!0},{name:"z",description:"the z component of the vector to subtract
\n",type:"Number",optional:!0}],chainable:1},{line:502,params:[{name:"value",description:"the vector to subtract
\n",type:"p5.Vector|Number[]"}],chainable:1},{line:1773,params:[{name:"v1",description:'a p5.Vector to subtract from
\n',type:"p5.Vector"},{name:"v2",description:'a p5.Vector to subtract
\n',type:"p5.Vector"},{name:"target",description:"if undefined a new vector will be created
\n",type:"p5.Vector"}],static:1},{line:1780,params:[{name:"v1",description:"",type:"p5.Vector"},{name:"v2",description:"",type:"p5.Vector"}],static:1,return:{description:'the resulting p5.Vector',type:"p5.Vector"}}]},{file:"src/math/p5.Vector.js",line:526,description:'Multiply the vector by a scalar. The static version of this method\ncreates a new p5.Vector while the non static version acts on the vector\ndirectly. See the examples for more context.
\n',itemtype:"method",name:"mult",chainable:1,example:["\n\n\nlet v = createVector(1, 2, 3);\nv.mult(2);\n// v's components are set to [2, 4, 6]\n
\n\n\n\n\n// Static method\nlet v1 = createVector(1, 2, 3);\nlet v2 = p5.Vector.mult(v1, 2);\n// v2 has components [2, 4, 6]\nprint(v2);\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(25, -25);\n drawArrow(v0, v1, 'red');\n\n let num = map(mouseX, 0, width, -2, 2, true);\n let v2 = p5.Vector.mult(v1, num);\n drawArrow(v0, v2, 'blue');\n\n noStroke();\n text('multiplied by ' + num.toFixed(2), 5, 90);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:526,params:[{name:"n",description:"the number to multiply with the vector
\n",type:"Number"}],chainable:1},{line:1801,params:[{name:"v",description:"the vector to multiply
\n",type:"p5.Vector"},{name:"n",description:"",type:"Number"},{name:"target",description:"if undefined a new vector will be created
\n",type:"p5.Vector"}],static:1},{line:1808,params:[{name:"v",description:"",type:"p5.Vector"},{name:"n",description:"",type:"Number"}],static:1,return:{description:'the resulting new p5.Vector',type:"p5.Vector"}}]},{file:"src/math/p5.Vector.js",line:601,description:'Divide the vector by a scalar. The static version of this method creates a\nnew p5.Vector while the non static version acts on the vector directly.\nSee the examples for more context.
\n',itemtype:"method",name:"div",chainable:1,example:["\n\n\nlet v = createVector(6, 4, 2);\nv.div(2); //v's components are set to [3, 2, 1]\n
\n\n\n\n\n// Static method\nlet v1 = createVector(6, 4, 2);\nlet v2 = p5.Vector.div(v1, 2);\n// v2 has components [3, 2, 1]\nprint(v2);\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 100);\n let v1 = createVector(50, -50);\n drawArrow(v0, v1, 'red');\n\n let num = map(mouseX, 0, width, 10, 0.5, true);\n let v2 = p5.Vector.div(v1, num);\n drawArrow(v0, v2, 'blue');\n\n noStroke();\n text('divided by ' + num.toFixed(2), 10, 90);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:601,params:[{name:"n",description:"the number to divide the vector by
\n",type:"Number"}],chainable:1},{line:1828,params:[{name:"v",description:"the vector to divide
\n",type:"p5.Vector"},{name:"n",description:"",type:"Number"},{name:"target",description:"if undefined a new vector will be created
\n",type:"p5.Vector"}],static:1},{line:1835,params:[{name:"v",description:"",type:"p5.Vector"},{name:"n",description:"",type:"Number"}],static:1,return:{description:'the resulting new p5.Vector',type:"p5.Vector"}}]},{file:"src/math/p5.Vector.js",line:679,description:"Calculates the magnitude (length) of the vector and returns the result as\na float (this is simply the equation sqrt(x*x + y*y + z*z).)
\n",itemtype:"method",name:"mag",return:{description:"magnitude of the vector",type:"Number"},example:["\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n let v1 = createVector(mouseX, mouseY);\n drawArrow(v0, v1, 'black');\n\n noStroke();\n text('vector length: ' + v1.mag().toFixed(2), 10, 70, 90, 30);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n\n\n\nlet v = createVector(20.0, 30.0, 40.0);\nlet m = v.mag();\nprint(m); // Prints \"53.85164807134504\"\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:679,params:[],return:{description:"magnitude of the vector",type:"Number"}},{line:1925,params:[{name:"vecT",description:"the vector to return the magnitude of
\n",type:"p5.Vector"}],static:1,return:{description:"the magnitude of vecT",type:"Number"}}]},{file:"src/math/p5.Vector.js",line:727,description:"Calculates the squared magnitude of the vector and returns the result\nas a float (this is simply the equation (x*x + y*y + z*z).)\nFaster if the real length is not required in the\ncase of comparing vectors, etc.
\n",itemtype:"method",name:"magSq",return:{description:"squared magnitude of the vector",type:"Number"},example:["\n\n\n// Static method\nlet v1 = createVector(6, 4, 2);\nprint(v1.magSq()); // Prints \"56\"\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n let v1 = createVector(mouseX, mouseY);\n drawArrow(v0, v1, 'black');\n\n noStroke();\n text('vector length squared: ' + v1.magSq().toFixed(2), 10, 45, 90, 55);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:781,description:"Calculates the dot product of two vectors. The version of the method\nthat computes the dot product of two independent vectors is a static\nmethod. See the examples for more context.
\n",itemtype:"method",name:"dot",return:{description:"the dot product",type:"Number"},example:['\n\n\nlet v1 = createVector(1, 2, 3);\nlet v2 = createVector(2, 3, 4);\n\nprint(v1.dot(v2)); // Prints "20"\n
\n\n\n\n\n//Static method\nlet v1 = createVector(1, 2, 3);\nlet v2 = createVector(3, 2, 1);\nprint(p5.Vector.dot(v1, v2)); // Prints "10"\n
\n'],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:781,params:[{name:"x",description:"x component of the vector
\n",type:"Number"},{name:"y",description:"y component of the vector
\n",type:"Number",optional:!0},{name:"z",description:"z component of the vector
\n",type:"Number",optional:!0}],return:{description:"the dot product",type:"Number"}},{line:812,params:[{name:"value",description:'value component of the vector or a p5.Vector
\n',type:"p5.Vector"}],return:{description:"",type:"Number"}},{line:1855,params:[{name:"v1",description:'the first p5.Vector
\n',type:"p5.Vector"},{name:"v2",description:'the second p5.Vector
\n',type:"p5.Vector"}],static:1,return:{description:"the dot product",type:"Number"}}]},{file:"src/math/p5.Vector.js",line:824,description:'Calculates and returns a vector composed of the cross product between\ntwo vectors. Both the static and non static methods return a new p5.Vector.\nSee the examples for more context.
\n',itemtype:"method",name:"cross",return:{description:'p5.Vector composed of cross product',type:"p5.Vector"},example:['\n\n\nlet v1 = createVector(1, 2, 3);\nlet v2 = createVector(1, 2, 3);\n\nv1.cross(v2); // v\'s components are [0, 0, 0]\n
\n\n\n\n\n// Static method\nlet v1 = createVector(1, 0, 0);\nlet v2 = createVector(0, 1, 0);\n\nlet crossProduct = p5.Vector.cross(v1, v2);\n// crossProduct has components [0, 0, 1]\nprint(crossProduct);\n
\n'],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:824,params:[{name:"v",description:'p5.Vector to be crossed
\n',type:"p5.Vector"}],return:{description:'p5.Vector composed of cross product',type:"p5.Vector"}},{line:1869,params:[{name:"v1",description:'the first p5.Vector
\n',type:"p5.Vector"},{name:"v2",description:'the second p5.Vector
\n',type:"p5.Vector"}],static:1,return:{description:"the cross product",type:"Number"}}]},{file:"src/math/p5.Vector.js",line:865,description:"Calculates the Euclidean distance between two points (considering a\npoint as a vector object).
\n",itemtype:"method",name:"dist",return:{description:"the distance",type:"Number"},example:["\n\n\nlet v1 = createVector(1, 0, 0);\nlet v2 = createVector(0, 1, 0);\n\nlet distance = v1.dist(v2); // distance is 1.4142...\nprint(distance);\n
\n\n\n\n\n// Static method\nlet v1 = createVector(1, 0, 0);\nlet v2 = createVector(0, 1, 0);\n\nlet distance = p5.Vector.dist(v1, v2);\n// distance is 1.4142...\nprint(distance);\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n\n let v1 = createVector(70, 50);\n drawArrow(v0, v1, 'red');\n\n let v2 = createVector(mouseX, mouseY);\n drawArrow(v0, v2, 'blue');\n\n noStroke();\n text('distance between vectors: ' + v2.dist(v1).toFixed(2), 5, 50, 95, 50);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:865,params:[{name:"v",description:'the x, y, and z coordinates of a p5.Vector
\n',type:"p5.Vector"}],return:{description:"the distance",type:"Number"}},{line:1884,params:[{name:"v1",description:'the first p5.Vector
\n',type:"p5.Vector"},{name:"v2",description:'the second p5.Vector
\n',type:"p5.Vector"}],static:1,return:{description:"the distance",type:"Number"}}]},{file:"src/math/p5.Vector.js",line:936,description:"Normalize the vector to length 1 (make it a unit vector).
\n",itemtype:"method",name:"normalize",return:{description:'normalized p5.Vector',type:"p5.Vector"},example:["\n\n\nlet v = createVector(10, 20, 2);\n// v has components [10.0, 20.0, 2.0]\nv.normalize();\n// v's components are set to\n// [0.4454354, 0.8908708, 0.089087084]\n
\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(mouseX - 50, mouseY - 50);\n\n drawArrow(v0, v1, 'red');\n v1.normalize();\n drawArrow(v0, v1.mult(35), 'blue');\n\n noFill();\n ellipse(50, 50, 35 * 2);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:992,description:"Limit the magnitude of this vector to the value used for the max\nparameter.
\n",itemtype:"method",name:"limit",params:[{name:"max",description:"the maximum magnitude for the vector
\n",type:"Number"}],chainable:1,example:["\n\n\nlet v = createVector(10, 20, 2);\n// v has components [10.0, 20.0, 2.0]\nv.limit(5);\n// v's components are set to\n// [2.2271771, 4.4543543, 0.4454354]\n
\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(mouseX - 50, mouseY - 50);\n\n drawArrow(v0, v1, 'red');\n drawArrow(v0, v1.limit(35), 'blue');\n\n noFill();\n ellipse(50, 50, 35 * 2);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1050,description:"Set the magnitude of this vector to the value used for the len\nparameter.
\n",itemtype:"method",name:"setMag",params:[{name:"len",description:"the new length for this vector
\n",type:"Number"}],chainable:1,example:["\n\n\nlet v = createVector(10, 20, 2);\n// v has components [10.0, 20.0, 2.0]\nv.setMag(10);\n// v's components are set to [6.0, 8.0, 0.0]\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n let v1 = createVector(50, 50);\n\n drawArrow(v0, v1, 'red');\n\n let length = map(mouseX, 0, width, 0, 141, true);\n v1.setMag(length);\n drawArrow(v0, v1, 'blue');\n\n noStroke();\n text('magnitude set to: ' + length.toFixed(2), 10, 70, 90, 30);\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1106,description:"Calculate the angle of rotation for this vector (only 2D vectors)
\n",itemtype:"method",name:"heading",return:{description:"the angle of rotation",type:"Number"},example:["\n\n\nfunction setup() {\n let v1 = createVector(30, 50);\n print(v1.heading()); // 1.0303768265243125\n\n v1 = createVector(40, 50);\n print(v1.heading()); // 0.8960553845713439\n\n v1 = createVector(30, 70);\n print(v1.heading()); // 1.1659045405098132\n}\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(mouseX - 50, mouseY - 50);\n\n drawArrow(v0, v1, 'black');\n\n let myHeading = v1.heading();\n noStroke();\n text(\n 'vector heading: ' +\n myHeading.toFixed(2) +\n ' radians or ' +\n degrees(myHeading).toFixed(2) +\n ' degrees',\n 10,\n 50,\n 90,\n 50\n );\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1175,description:"Rotate the vector by an angle (only 2D vectors), magnitude remains the\nsame
\n",itemtype:"method",name:"rotate",params:[{name:"angle",description:"the angle of rotation
\n",type:"Number"}],chainable:1,example:["\n\n\nlet v = createVector(10.0, 20.0);\n// v has components [10.0, 20.0, 0.0]\nv.rotate(HALF_PI);\n// v's components are set to [-20.0, 9.999999, 0.0]\n
\n\n\n\n\nlet angle = 0;\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = createVector(50, 0);\n\n drawArrow(v0, v1.rotate(angle), 'black');\n angle += 0.01;\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1231,description:"Calculates and returns the angle (in radians) between two vectors.
\n",itemtype:"method",name:"angleBetween",params:[{name:"value",description:'the x, y, and z components of a p5.Vector
\n',type:"p5.Vector"}],return:{description:"the angle between (in radians)",type:"Number"},example:["\n\n\nlet v1 = createVector(1, 0, 0);\nlet v2 = createVector(0, 1, 0);\n\nlet angle = v1.angleBetween(v2);\n// angle is PI/2\nprint(angle);\n
\n\n\n\n\nfunction draw() {\n background(240);\n let v0 = createVector(50, 50);\n\n let v1 = createVector(50, 0);\n drawArrow(v0, v1, 'red');\n\n let v2 = createVector(mouseX - 50, mouseY - 50);\n drawArrow(v0, v2, 'blue');\n\n let angleBetween = v1.angleBetween(v2);\n noStroke();\n text(\n 'angle between: ' +\n angleBetween.toFixed(2) +\n ' radians or ' +\n degrees(angleBetween).toFixed(2) +\n ' degrees',\n 10,\n 50,\n 90,\n 50\n );\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1308,description:"Linear interpolate the vector to another vector
\n",itemtype:"method",name:"lerp",chainable:1,example:["\n\n\nlet v = createVector(1, 1, 0);\n\nv.lerp(3, 3, 0, 0.5); // v now has components [2,2,0]\n
\n\n\n\n\nlet v1 = createVector(0, 0, 0);\nlet v2 = createVector(100, 100, 0);\n\nlet v3 = p5.Vector.lerp(v1, v2, 0.5);\n// v3 has components [50,50,0]\nprint(v3);\n
\n\n\n\n\nlet step = 0.01;\nlet amount = 0;\n\nfunction draw() {\n background(240);\n let v0 = createVector(0, 0);\n\n let v1 = createVector(mouseX, mouseY);\n drawArrow(v0, v1, 'red');\n\n let v2 = createVector(90, 90);\n drawArrow(v0, v2, 'blue');\n\n if (amount > 1 || amount < 0) {\n step *= -1;\n }\n amount += step;\n let v3 = p5.Vector.lerp(v1, v2, amount);\n\n drawArrow(v0, v3, 'purple');\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:1308,params:[{name:"x",description:"the x component
\n",type:"Number"},{name:"y",description:"the y component
\n",type:"Number"},{name:"z",description:"the z component
\n",type:"Number"},{name:"amt",description:"the amount of interpolation; some value between 0.0\n (old vector) and 1.0 (new vector). 0.9 is very near\n the new vector. 0.5 is halfway in between.
\n",type:"Number"}],chainable:1},{line:1381,params:[{name:"v",description:'the p5.Vector to lerp to
\n',type:"p5.Vector"},{name:"amt",description:"",type:"Number"}],chainable:1},{line:1899,params:[{name:"v1",description:"",type:"p5.Vector"},{name:"v2",description:"",type:"p5.Vector"},{name:"amt",description:"",type:"Number"},{name:"target",description:"if undefined a new vector will be created
\n",type:"p5.Vector"}],static:1},{line:1907,params:[{name:"v1",description:"",type:"p5.Vector"},{name:"v2",description:"",type:"p5.Vector"},{name:"amt",description:"",type:"Number"}],static:1,return:{description:"the lerped value",type:"Number"}}]},{file:"src/math/p5.Vector.js",line:1397,description:"Reflect the incoming vector about a normal to a line in 2D, or about a normal to a plane in 3D\nThis method acts on the vector directly
\n",itemtype:"method",name:"reflect",params:[{name:"surfaceNormal",description:'the p5.Vector to reflect about, will be normalized by this method
\n',type:"p5.Vector"}],chainable:1,example:["\n\n\nlet v = createVector(4, 6); // incoming vector, this example vector is heading to the right and downward\nlet n = createVector(0, -1); // surface normal to a plane (this example normal points directly upwards)\nv.reflect(n); // v is reflected about the surface normal n. v's components are now set to [4, -6]\n
\n\n\n\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(0, 0);\n let v1 = createVector(mouseX, mouseY);\n drawArrow(v0, v1, 'red');\n\n let n = createVector(0, -30);\n drawArrow(v1, n, 'blue');\n\n let r = v1.copy();\n r.reflect(n);\n drawArrow(v1, r, 'purple');\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1452,description:'Return a representation of this vector as a float array. This is only\nfor temporary use. If used in any other fashion, the contents should be\ncopied by using the p5.Vector.copy() method to copy into your own\narray.
\n',itemtype:"method",name:"array",return:{description:"an Array with the 3 values",type:"Number[]"},example:['\n\n\nfunction setup() {\n let v = createVector(20, 30);\n print(v.array()); // Prints : Array [20, 30, 0]\n}\n
\n\n\n\n\nlet v = createVector(10.0, 20.0, 30.0);\nlet f = v.array();\nprint(f[0]); // Prints "10.0"\nprint(f[1]); // Prints "20.0"\nprint(f[2]); // Prints "30.0"\n
\n'],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1484,description:'Equality check against a p5.Vector
\n',itemtype:"method",name:"equals",return:{description:"whether the vectors are equals",type:"Boolean"},example:['\n\n\nlet v1 = createVector(5, 10, 20);\nlet v2 = createVector(5, 10, 20);\nlet v3 = createVector(13, 10, 19);\n\nprint(v1.equals(v2.x, v2.y, v2.z)); // true\nprint(v1.equals(v3.x, v3.y, v3.z)); // false\n
\n\n\n\n\nlet v1 = createVector(10.0, 20.0, 30.0);\nlet v2 = createVector(10.0, 20.0, 30.0);\nlet v3 = createVector(0.0, 0.0, 0.0);\nprint(v1.equals(v2)); // true\nprint(v1.equals(v3)); // false\n
\n'],class:"p5.Vector",module:"Math",submodule:"Vector",overloads:[{line:1484,params:[{name:"x",description:"the x component of the vector
\n",type:"Number",optional:!0},{name:"y",description:"the y component of the vector
\n",type:"Number",optional:!0},{name:"z",description:"the z component of the vector
\n",type:"Number",optional:!0}],return:{description:"whether the vectors are equals",type:"Boolean"}},{line:1514,params:[{name:"value",description:"the vector to compare
\n",type:"p5.Vector|Array"}],return:{description:"",type:"Boolean"}}]},{file:"src/math/p5.Vector.js",line:1539,description:"Make a new 2D vector from an angle
\n",itemtype:"method",name:"fromAngle",static:1,params:[{name:"angle",description:'the desired angle, in radians (unaffected by angleMode)
\n',type:"Number"},{name:"length",description:"the length of the new vector (defaults to 1)
\n",type:"Number",optional:!0}],return:{description:'the new p5.Vector object',type:"p5.Vector"},example:["\n\n\nfunction draw() {\n background(200);\n\n // Create a variable, proportional to the mouseX,\n // varying from 0-360, to represent an angle in degrees.\n let myDegrees = map(mouseX, 0, width, 0, 360);\n\n // Display that variable in an onscreen text.\n // (Note the nfc() function to truncate additional decimal places,\n // and the \"\\xB0\" character for the degree symbol.)\n let readout = 'angle = ' + nfc(myDegrees, 1) + '\\xB0';\n noStroke();\n fill(0);\n text(readout, 5, 15);\n\n // Create a p5.Vector using the fromAngle function,\n // and extract its x and y components.\n let v = p5.Vector.fromAngle(radians(myDegrees), 30);\n let vx = v.x;\n let vy = v.y;\n\n push();\n translate(width / 2, height / 2);\n noFill();\n stroke(150);\n line(0, 0, 30, 0);\n stroke(0);\n line(0, 0, vx, vy);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1590,description:"Make a new 3D vector from a pair of ISO spherical angles
\n",itemtype:"method",name:"fromAngles",static:1,params:[{name:"theta",description:"the polar angle, in radians (zero is up)
\n",type:"Number"},{name:"phi",description:"the azimuthal angle, in radians\n (zero is out of the screen)
\n",type:"Number"},{name:"length",description:"the length of the new vector (defaults to 1)
\n",type:"Number",optional:!0}],return:{description:'the new p5.Vector object',type:"p5.Vector"},example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n fill(255);\n noStroke();\n}\nfunction draw() {\n background(255);\n\n let t = millis() / 1000;\n\n // add three point lights\n pointLight(color('#f00'), p5.Vector.fromAngles(t * 1.0, t * 1.3, 100));\n pointLight(color('#0f0'), p5.Vector.fromAngles(t * 1.1, t * 1.2, 100));\n pointLight(color('#00f'), p5.Vector.fromAngles(t * 1.2, t * 1.1, 100));\n\n sphere(35);\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1639,description:"Make a new 2D unit vector from a random angle
\n",itemtype:"method",name:"random2D",static:1,return:{description:'the new p5.Vector object',type:"p5.Vector"},example:["\n\n\nlet v = p5.Vector.random2D();\n// May make v's attributes something like:\n// [0.61554617, -0.51195765, 0.0] or\n// [-0.4695841, -0.14366731, 0.0] or\n// [0.6091097, -0.22805278, 0.0]\nprint(v);\n
\n\n\n\n\nfunction setup() {\n frameRate(1);\n}\n\nfunction draw() {\n background(240);\n\n let v0 = createVector(50, 50);\n let v1 = p5.Vector.random2D();\n drawArrow(v0, v1.mult(50), 'black');\n}\n\n// draw an arrow for a vector at a given base position\nfunction drawArrow(base, vec, myColor) {\n push();\n stroke(myColor);\n strokeWeight(3);\n fill(myColor);\n translate(base.x, base.y);\n line(0, 0, vec.x, vec.y);\n rotate(vec.heading());\n let arrowSize = 7;\n translate(vec.mag() - arrowSize, 0);\n triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);\n pop();\n}\n
\n"],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1692,description:"Make a new random 3D unit vector.
\n",itemtype:"method",name:"random3D",static:1,return:{description:'the new p5.Vector object',type:"p5.Vector"},example:['\n\n\nlet v = p5.Vector.random3D();\n// May make v\'s attributes something like:\n// [0.61554617, -0.51195765, 0.599168] or\n// [-0.4695841, -0.14366731, -0.8711202] or\n// [0.6091097, -0.22805278, -0.7595902]\nprint(v);\n
\n'],class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1798,description:"Multiplies a vector by a scalar and returns a new vector.
\n",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1825,description:"Divides a vector by a scalar and returns a new vector.
\n",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1852,description:"Calculates the dot product of two vectors.
\n",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1866,description:"Calculates the cross product of two vectors.
\n",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1880,description:"Calculates the Euclidean distance between two points (considering a\npoint as a vector object).
\n",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/p5.Vector.js",line:1895,description:"Linear interpolate a vector to another vector and return the result as a\nnew vector.
\n",class:"p5.Vector",module:"Math",submodule:"Vector"},{file:"src/math/random.js",line:37,description:'Sets the seed value for random().
\nBy default, random() produces different results each time the program\nis run. Set the seed parameter to a constant to return the same\npseudo-random numbers each time the software is run.
\n',itemtype:"method",name:"randomSeed",params:[{name:"seed",description:"the seed value
\n",type:"Number"}],example:["\n\n\nrandomSeed(99);\nfor (let i = 0; i < 100; i++) {\n let r = random(0, 255);\n stroke(r);\n line(i, 0, i, 100);\n}\n
\n"],alt:"many vertical lines drawn in white, black or grey.",class:"p5",module:"Math",submodule:"Random"},{file:"src/math/random.js",line:67,description:"Return a random floating-point number.
\nTakes either 0, 1 or 2 arguments.
\nIf no argument is given, returns a random number from 0\nup to (but not including) 1.
\nIf one argument is given and it is a number, returns a random number from 0\nup to (but not including) the number.
\nIf one argument is given and it is an array, returns a random element from\nthat array.
\nIf two arguments are given, returns a random number from the\nfirst argument up to (but not including) the second argument.
\n",itemtype:"method",name:"random",return:{description:"the random number",type:"Number"},example:["\n\n\nfor (let i = 0; i < 100; i++) {\n let r = random(50);\n stroke(r * 5);\n line(50, i, 50 + r, i);\n}\n
\n\n\n\nfor (let i = 0; i < 100; i++) {\n let r = random(-50, 50);\n line(50, i, 50 + r, i);\n}\n
\n\n\n\n// Get a random element from an array using the random(Array) syntax\nlet words = ['apple', 'bear', 'cat', 'dog'];\nlet word = random(words); // select random word\ntext(word, 10, 50); // draw the word\n
\n"],alt:"100 horizontal lines from center canvas to right. size+fill change each time\n100 horizontal lines from center of canvas. height & side change each render\nword displayed at random. Either apple, bear, cat, or dog",class:"p5",module:"Math",submodule:"Random",overloads:[{line:67,params:[{name:"min",description:"the lower bound (inclusive)
\n",type:"Number",optional:!0},{name:"max",description:"the upper bound (exclusive)
\n",type:"Number",optional:!0}],return:{description:"the random number",type:"Number"}},{line:121,params:[{name:"choices",description:"the array to choose from
\n",type:"Array"}],return:{description:"the random element from the array",type:"*"}}]},{file:"src/math/random.js",line:155,description:'Returns a random number fitting a Gaussian, or\n normal, distribution. There is theoretically no minimum or maximum\n value that randomGaussian() might return. Rather, there is\n just a very low probability that values far from the mean will be\n returned; and a higher probability that numbers near the mean will\n be returned.\n
\n Takes either 0, 1 or 2 arguments.
\n If no args, returns a mean of 0 and standard deviation of 1.
\n If one arg, that arg is the mean (standard deviation is 1).
\n If two args, first is mean, second is standard deviation.
\n',itemtype:"method",name:"randomGaussian",params:[{name:"mean",description:"the mean
\n",type:"Number"},{name:"sd",description:"the standard deviation
\n",type:"Number"}],return:{description:"the random number",type:"Number"},example:["\n \n \n for (let y = 0; y < 100; y++) {\n let x = randomGaussian(50, 15);\n line(50, y, x, y);\n }\n
\n \n \n \n let distribution = new Array(360);\nfunction setup() {\n createCanvas(100, 100);\n for (let i = 0; i < distribution.length; i++) {\n distribution[i] = floor(randomGaussian(0, 15));\n }\n }\nfunction draw() {\n background(204);\n translate(width / 2, width / 2);\n for (let i = 0; i < distribution.length; i++) {\n rotate(TWO_PI / distribution.length);\n stroke(0);\n let dist = abs(distribution[i]);\n line(0, 0, dist, 0);\n }\n }\n
\n "],alt:"100 horizontal lines from center of canvas. height & side change each render\n black lines radiate from center of canvas. size determined each render",class:"p5",module:"Math",submodule:"Random"},{file:"src/math/trigonometry.js",line:18,description:'The inverse of cos(), returns the arc cosine of a value. This function\nexpects the values in the range of -1 to 1 and values are returned in\nthe range 0 to PI (3.1415927).
\n',itemtype:"method",name:"acos",params:[{name:"value",description:"the value whose arc cosine is to be returned
\n",type:"Number"}],return:{description:"the arc cosine of the given value",type:"Number"},example:["\n\n\nlet a = PI;\nlet c = cos(a);\nlet ac = acos(c);\n// Prints: \"3.1415927 : -1.0 : 3.1415927\"\nprint(a + ' : ' + c + ' : ' + ac);\n
\n\n\n\n\nlet a = PI + PI / 4.0;\nlet c = cos(a);\nlet ac = acos(c);\n// Prints: \"3.926991 : -0.70710665 : 2.3561943\"\nprint(a + ' : ' + c + ' : ' + ac);\n
\n"],class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:52,description:'The inverse of sin(), returns the arc sine of a value. This function\nexpects the values in the range of -1 to 1 and values are returned\nin the range -PI/2 to PI/2.
\n',itemtype:"method",name:"asin",params:[{name:"value",description:"the value whose arc sine is to be returned
\n",type:"Number"}],return:{description:"the arc sine of the given value",type:"Number"},example:["\n\n\nlet a = PI / 3.0;\nlet s = sin(a);\nlet as = asin(s);\n// Prints: \"1.0471975 : 0.86602540 : 1.0471975\"\nprint(a + ' : ' + s + ' : ' + as);\n
\n\n\n\n\nlet a = PI + PI / 3.0;\nlet s = sin(a);\nlet as = asin(s);\n// Prints: \"4.1887902 : -0.86602540 : -1.0471975\"\nprint(a + ' : ' + s + ' : ' + as);\n
\n\n"],class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:87,description:'The inverse of tan(), returns the arc tangent of a value. This function\nexpects the values in the range of -Infinity to Infinity (exclusive) and\nvalues are returned in the range -PI/2 to PI/2.
\n',itemtype:"method",name:"atan",params:[{name:"value",description:"the value whose arc tangent is to be returned
\n",type:"Number"}],return:{description:"the arc tangent of the given value",type:"Number"},example:["\n\n\nlet a = PI / 3.0;\nlet t = tan(a);\nlet at = atan(t);\n// Prints: \"1.0471975 : 1.7320508 : 1.0471975\"\nprint(a + ' : ' + t + ' : ' + at);\n
\n\n\n\n\nlet a = PI + PI / 3.0;\nlet t = tan(a);\nlet at = atan(t);\n// Prints: \"4.1887902 : 1.7320508 : 1.0471975\"\nprint(a + ' : ' + t + ' : ' + at);\n
\n\n"],class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:122,description:'Calculates the angle (in radians) from a specified point to the coordinate\norigin as measured from the positive x-axis. Values are returned as a\nfloat in the range from PI to -PI. The atan2() function is most often used\nfor orienting geometry to the position of the cursor.\n
\nNote: The y-coordinate of the point is the first parameter, and the\nx-coordinate is the second parameter, due the the structure of calculating\nthe tangent.
\n',itemtype:"method",name:"atan2",params:[{name:"y",description:"y-coordinate of the point
\n",type:"Number"},{name:"x",description:"x-coordinate of the point
\n",type:"Number"}],return:{description:"the arc tangent of the given point",type:"Number"},example:["\n\n\nfunction draw() {\n background(204);\n translate(width / 2, height / 2);\n let a = atan2(mouseY - height / 2, mouseX - width / 2);\n rotate(a);\n rect(-30, -5, 60, 10);\n}\n
\n"],alt:"60 by 10 rect at center of canvas rotates with mouse movements",class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:158,description:'Calculates the cosine of an angle. This function takes into account the\ncurrent angleMode. Values are returned in the range -1 to 1.
\n',itemtype:"method",name:"cos",params:[{name:"angle",description:"the angle
\n",type:"Number"}],return:{description:"the cosine of the angle",type:"Number"},example:["\n\n\nlet a = 0.0;\nlet inc = TWO_PI / 25.0;\nfor (let i = 0; i < 25; i++) {\n line(i * 4, 50, i * 4, 50 + cos(a) * 40.0);\n a = a + inc;\n}\n
\n"],alt:"vertical black lines form wave patterns, extend-down on left and right side",class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:186,description:'Calculates the sine of an angle. This function takes into account the\ncurrent angleMode. Values are returned in the range -1 to 1.
\n',itemtype:"method",name:"sin",params:[{name:"angle",description:"the angle
\n",type:"Number"}],return:{description:"the sine of the angle",type:"Number"},example:["\n\n\nlet a = 0.0;\nlet inc = TWO_PI / 25.0;\nfor (let i = 0; i < 25; i++) {\n line(i * 4, 50, i * 4, 50 + sin(a) * 40.0);\n a = a + inc;\n}\n
\n"],alt:"vertical black lines extend down and up from center to form wave pattern",class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:214,description:'Calculates the tangent of an angle. This function takes into account\nthe current angleMode. Values are returned in the range of all real numbers.
\n',itemtype:"method",name:"tan",params:[{name:"angle",description:"the angle
\n",type:"Number"}],return:{description:"the tangent of the angle",type:"Number"},example:["\n\n\nlet a = 0.0;\nlet inc = TWO_PI / 50.0;\nfor (let i = 0; i < 100; i = i + 2) {\n line(i, 50, i, 50 + tan(a) * 2.0);\n a = a + inc;\n}\n
"],alt:"vertical black lines end down and up from center to form spike pattern",class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:242,description:'Converts a radian measurement to its corresponding value in degrees.\nRadians and degrees are two ways of measuring the same thing. There are\n360 degrees in a circle and 2*PI radians in a circle. For example,\n90° = PI/2 = 1.5707964. This function does not take into account the\ncurrent angleMode.
\n',itemtype:"method",name:"degrees",params:[{name:"radians",description:"the radians value to convert to degrees
\n",type:"Number"}],return:{description:"the converted angle",type:"Number"},example:["\n\n\nlet rad = PI / 4;\nlet deg = degrees(rad);\nprint(rad + ' radians is ' + deg + ' degrees');\n// Prints: 0.7853981633974483 radians is 45 degrees\n
\n\n"],class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:267,description:'Converts a degree measurement to its corresponding value in radians.\nRadians and degrees are two ways of measuring the same thing. There are\n360 degrees in a circle and 2*PI radians in a circle. For example,\n90° = PI/2 = 1.5707964. This function does not take into account the\ncurrent angleMode.
\n',itemtype:"method",name:"radians",params:[{name:"degrees",description:"the degree value to convert to radians
\n",type:"Number"}],return:{description:"the converted angle",type:"Number"},example:["\n\n\nlet deg = 45.0;\nlet rad = radians(deg);\nprint(deg + ' degrees is ' + rad + ' radians');\n// Prints: 45 degrees is 0.7853981633974483 radians\n
\n"],class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/math/trigonometry.js",line:290,description:"Sets the current mode of p5 to given mode. Default mode is RADIANS.
\n",itemtype:"method",name:"angleMode",params:[{name:"mode",description:"either RADIANS or DEGREES
\n",type:"Constant"}],example:["\n\n\nfunction draw() {\n background(204);\n angleMode(DEGREES); // Change the mode to DEGREES\n let a = atan2(mouseY - height / 2, mouseX - width / 2);\n translate(width / 2, height / 2);\n push();\n rotate(a);\n rect(-20, -5, 40, 10); // Larger rectangle is rotating in degrees\n pop();\n angleMode(RADIANS); // Change the mode to RADIANS\n rotate(a); // variable a stays the same\n rect(-40, -5, 20, 10); // Smaller rectangle is rotating in radians\n}\n
\n"],alt:"40 by 10 rect in center rotates with mouse moves. 20 by 10 rect moves faster.",class:"p5",module:"Math",submodule:"Trigonometry"},{file:"src/typography/attributes.js",line:11,description:'Sets the current alignment for drawing text. Accepts two\narguments: horizAlign (LEFT, CENTER, or RIGHT) and\nvertAlign (TOP, BOTTOM, CENTER, or BASELINE).
\nThe horizAlign parameter is in reference to the x value\nof the text() function, while the vertAlign parameter is\nin reference to the y value.
\nSo if you write textAlign(LEFT), you are aligning the left\nedge of your text to the x value you give in text(). If you\nwrite textAlign(RIGHT, TOP), you are aligning the right edge\nof your text to the x value and the top of edge of the text\nto the y value.
\n',itemtype:"method",name:"textAlign",chainable:1,example:["\n\n\ntextSize(16);\ntextAlign(RIGHT);\ntext('ABCD', 50, 30);\ntextAlign(CENTER);\ntext('EFGH', 50, 50);\ntextAlign(LEFT);\ntext('IJKL', 50, 70);\n
\n\n\n\n\ntextSize(16);\nstrokeWeight(0.5);\n\nline(0, 12, width, 12);\ntextAlign(CENTER, TOP);\ntext('TOP', 0, 12, width);\n\nline(0, 37, width, 37);\ntextAlign(CENTER, CENTER);\ntext('CENTER', 0, 37, width);\n\nline(0, 62, width, 62);\ntextAlign(CENTER, BASELINE);\ntext('BASELINE', 0, 62, width);\n\nline(0, 87, width, 87);\ntextAlign(CENTER, BOTTOM);\ntext('BOTTOM', 0, 87, width);\n
\n"],alt:"Letters ABCD displayed at top right, EFGH at center and IJKL at bottom left.\nThe names of the four vertical alignments rendered each showing that alignment's placement relative to a horizontal line.",class:"p5",module:"Typography",submodule:"Attributes",overloads:[{line:11,params:[{name:"horizAlign",description:"horizontal alignment, either LEFT,\n CENTER, or RIGHT
\n",type:"Constant"},{name:"vertAlign",description:"vertical alignment, either TOP,\n BOTTOM, CENTER, or BASELINE
\n",type:"Constant",optional:!0}],chainable:1},{line:73,params:[],return:{description:"",type:"Object"}}]},{file:"src/typography/attributes.js",line:82,description:'Sets/gets the spacing, in pixels, between lines of text. This\nsetting will be used in all subsequent calls to the text() function.
\n',itemtype:"method",name:"textLeading",chainable:1,example:['\n\n\n// Text to display. The "\\n" is a "new line" character\nlet lines = \'L1\\nL2\\nL3\';\ntextSize(12);\n\ntextLeading(10); // Set leading to 10\ntext(lines, 10, 25);\n\ntextLeading(20); // Set leading to 20\ntext(lines, 40, 25);\n\ntextLeading(30); // Set leading to 30\ntext(lines, 70, 25);\n
\n'],alt:"set L1 L2 & L3 displayed vertically 3 times. spacing increases for each set",class:"p5",module:"Typography",submodule:"Attributes",overloads:[{line:82,params:[{name:"leading",description:"the size in pixels for spacing between lines
\n",type:"Number"}],chainable:1},{line:111,params:[],return:{description:"",type:"Number"}}]},{file:"src/typography/attributes.js",line:120,description:'Sets/gets the current font size. This size will be used in all subsequent\ncalls to the text() function. Font size is measured in pixels.
\n',itemtype:"method",name:"textSize",chainable:1,example:["\n\n\ntextSize(12);\ntext('Font Size 12', 10, 30);\ntextSize(14);\ntext('Font Size 14', 10, 60);\ntextSize(16);\ntext('Font Size 16', 10, 90);\n
\n"],alt:"Font Size 12 displayed small, Font Size 14 medium & Font Size 16 large",class:"p5",module:"Typography",submodule:"Attributes",overloads:[{line:120,params:[{name:"theSize",description:"the size of the letters in units of pixels
\n",type:"Number"}],chainable:1},{line:143,params:[],return:{description:"",type:"Number"}}]},{file:"src/typography/attributes.js",line:152,description:"Sets/gets the style of the text for system fonts to NORMAL, ITALIC, BOLD or BOLDITALIC.\nNote: this may be is overridden by CSS styling. For non-system fonts\n(opentype, truetype, etc.) please load styled fonts instead.
\n",itemtype:"method",name:"textStyle",chainable:1,example:["\n\n\nstrokeWeight(0);\ntextSize(12);\ntextStyle(NORMAL);\ntext('Font Style Normal', 10, 15);\ntextStyle(ITALIC);\ntext('Font Style Italic', 10, 40);\ntextStyle(BOLD);\ntext('Font Style Bold', 10, 65);\ntextStyle(BOLDITALIC);\ntext('Font Style Bold Italic', 10, 90);\n
\n"],alt:"words Font Style Normal displayed normally, Italic in italic, bold in bold and bold italic in bold italics.",class:"p5",module:"Typography",submodule:"Attributes",overloads:[{line:152,params:[{name:"theStyle",description:"styling for text, either NORMAL,\n ITALIC, BOLD or BOLDITALIC
\n",type:"Constant"}],chainable:1},{line:180,params:[],return:{description:"",type:"String"}}]},{file:"src/typography/attributes.js",line:189,description:"Calculates and returns the width of any character or text string.
\n",itemtype:"method",name:"textWidth",params:[{name:"theText",description:"the String of characters to measure
\n",type:"String"}],return:{description:"",type:"Number"},example:["\n\n\ntextSize(28);\n\nlet aChar = 'P';\nlet cWidth = textWidth(aChar);\ntext(aChar, 0, 40);\nline(cWidth, 0, cWidth, 50);\n\nlet aString = 'p5.js';\nlet sWidth = textWidth(aString);\ntext(aString, 0, 85);\nline(sWidth, 50, sWidth, 100);\n
\n"],alt:"Letter P and p5.js are displayed with vertical lines at end. P is wide",class:"p5",module:"Typography",submodule:"Attributes"},{file:"src/typography/attributes.js",line:225,description:"Returns the ascent of the current font at its current size. The ascent\nrepresents the distance, in pixels, of the tallest character above\nthe baseline.
\n",itemtype:"method",name:"textAscent",return:{description:"",type:"Number"},example:["\n\n\nlet base = height * 0.75;\nlet scalar = 0.8; // Different for each font\n\ntextSize(32); // Set initial text size\nlet asc = textAscent() * scalar; // Calc ascent\nline(0, base - asc, width, base - asc);\ntext('dp', 0, base); // Draw text on baseline\n\ntextSize(64); // Increase text size\nasc = textAscent() * scalar; // Recalc ascent\nline(40, base - asc, width, base - asc);\ntext('dp', 40, base); // Draw text on baseline\n
\n"],class:"p5",module:"Typography",submodule:"Attributes"},{file:"src/typography/attributes.js",line:254,description:"Returns the descent of the current font at its current size. The descent\nrepresents the distance, in pixels, of the character with the longest\ndescender below the baseline.
\n",itemtype:"method",name:"textDescent",return:{description:"",type:"Number"},example:["\n\n\nlet base = height * 0.75;\nlet scalar = 0.8; // Different for each font\n\ntextSize(32); // Set initial text size\nlet desc = textDescent() * scalar; // Calc ascent\nline(0, base + desc, width, base + desc);\ntext('dp', 0, base); // Draw text on baseline\n\ntextSize(64); // Increase text size\ndesc = textDescent() * scalar; // Recalc ascent\nline(40, base + desc, width, base + desc);\ntext('dp', 40, base); // Draw text on baseline\n
\n"],class:"p5",module:"Typography",submodule:"Attributes"},{file:"src/typography/attributes.js",line:283,description:"Helper function to measure ascent and descent.
\n",class:"p5",module:"Typography",submodule:"Attributes"},{file:"src/typography/loading_displaying.js",line:14,description:"Loads an opentype font file (.otf, .ttf) from a file or a URL,\nand returns a PFont Object. This method is asynchronous,\nmeaning it may not finish before the next line in your sketch\nis executed.\n
\nThe path to the font should be relative to the HTML file\nthat links in your sketch. Loading fonts from a URL or other\nremote location may be blocked due to your browser's built-in\nsecurity.
\n",itemtype:"method",name:"loadFont",params:[{name:"path",description:"name of the file or url to load
\n",type:"String"},{name:"callback",description:'function to be executed after\n loadFont() completes
\n',type:"Function",optional:!0},{name:"onError",description:"function to be executed if\n an error occurs
\n",type:"Function",optional:!0}],return:{description:'p5.Font object',type:"p5.Font"},example:["\n\nCalling loadFont() inside preload() guarantees that the load\noperation will have completed before setup() and draw() are called.
\n\n\nlet myFont;\nfunction preload() {\n myFont = loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n fill('#ED225D');\n textFont(myFont);\n textSize(36);\n text('p5*js', 10, 50);\n}\n
\n\nOutside of preload(), you may supply a callback function to handle the\nobject:\n\n\nfunction setup() {\n loadFont('assets/inconsolata.otf', drawText);\n}\n\nfunction drawText(font) {\n fill('#ED225D');\n textFont(font, 36);\n text('p5*js', 10, 50);\n}\n
\n\nYou can also use the font filename string (without the file extension) to style other HTML\nelements.
\n\n\nfunction preload() {\n loadFont('assets/inconsolata.otf');\n}\n\nfunction setup() {\n let myDiv = createDiv('hello there');\n myDiv.style('font-family', 'Inconsolata');\n}\n
"],alt:"p5*js in p5's theme dark pink\np5*js in p5's theme dark pink",class:"p5",module:"Typography",submodule:"Loading & Displaying"},{file:"src/typography/loading_displaying.js",line:138,description:'Draws text to the screen. Displays the information specified in the first\nparameter on the screen in the position specified by the additional\nparameters. A default font will be used unless a font is set with the\ntextFont() function and a default size will be used unless a font is set\nwith textSize(). Change the color of the text with the fill() function.\nChange the outline of the text with the stroke() and strokeWeight()\nfunctions.\n
\nThe text displays in relation to the textAlign() function, which gives the\noption to draw to the left, right, and center of the coordinates.\n
\nThe x2 and y2 parameters define a rectangular area to display within and\nmay only be used with string data. When these parameters are specified,\nthey are interpreted based on the current rectMode() setting. Text that\ndoes not fit completely within the rectangle specified will not be drawn\nto the screen. If x2 and y2 are not specified, the baseline alignment is the\ndefault, which means that the text will be drawn upwards from x and y.\n
\nWEBGL: Only opentype/truetype fonts are supported. You must load a font using the\nloadFont() method (see the example above).\nstroke() currently has no effect in webgl mode.
\n',itemtype:"method",name:"text",params:[{name:"str",description:"the alphanumeric\n symbols to be displayed
\n",type:"String|Object|Array|Number|Boolean"},{name:"x",description:"x-coordinate of text
\n",type:"Number"},{name:"y",description:"y-coordinate of text
\n",type:"Number"},{name:"x2",description:'by default, the width of the text box,\n see rectMode() for more info
\n',type:"Number",optional:!0},{name:"y2",description:'by default, the height of the text box,\n see rectMode() for more info
\n',type:"Number",optional:!0}],chainable:1,example:["\n\n\ntextSize(32);\ntext('word', 10, 30);\nfill(0, 102, 153);\ntext('word', 10, 60);\nfill(0, 102, 153, 51);\ntext('word', 10, 90);\n
\n\n\n\nlet s = 'The quick brown fox jumped over the lazy dog.';\nfill(50);\ntext(s, 10, 10, 70, 80); // Text wraps within text box\n
\n\n\n\n\nlet inconsolata;\nfunction preload() {\n inconsolata = loadFont('assets/inconsolata.otf');\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textFont(inconsolata);\n textSize(width / 3);\n textAlign(CENTER, CENTER);\n}\nfunction draw() {\n background(0);\n let time = millis();\n rotateX(time / 1000);\n rotateZ(time / 1234);\n text('p5.js', 0, 0);\n}\n
\n"],alt:"'word' displayed 3 times going from black, blue to translucent blue\nThe quick brown fox jumped over the lazy dog.\nthe text 'p5.js' spinning in 3d",class:"p5",module:"Typography",submodule:"Loading & Displaying"},{file:"src/typography/loading_displaying.js",line:225,description:'Sets the current font that will be drawn with the text() function.\n
\nWEBGL: Only fonts loaded via loadFont() are supported.
\n',itemtype:"method",name:"textFont",return:{description:"the current font",type:"Object"},example:["\n\n\nfill(0);\ntextSize(12);\ntextFont('Georgia');\ntext('Georgia', 12, 30);\ntextFont('Helvetica');\ntext('Helvetica', 12, 60);\n
\n\n\n\nlet fontRegular, fontItalic, fontBold;\nfunction preload() {\n fontRegular = loadFont('assets/Regular.otf');\n fontItalic = loadFont('assets/Italic.ttf');\n fontBold = loadFont('assets/Bold.ttf');\n}\nfunction setup() {\n background(210);\n fill(0)\n .strokeWeight(0)\n .textSize(10);\n textFont(fontRegular);\n text('Font Style Normal', 10, 30);\n textFont(fontItalic);\n text('Font Style Italic', 10, 50);\n textFont(fontBold);\n text('Font Style Bold', 10, 70);\n}\n
\n"],alt:"words Font Style Normal displayed normally, Italic in italic and bold in bold",class:"p5",module:"Typography",submodule:"Loading & Displaying",overloads:[{line:225,params:[],return:{description:"the current font",type:"Object"}},{line:270,params:[{name:"font",description:'a font loaded via loadFont(), or a String\nrepresenting a web safe font (a font\nthat is generally available across all systems)
\n',type:"Object|String"},{name:"size",description:"the font size to use
\n",type:"Number",optional:!0}],chainable:1}]},{file:"src/typography/p5.Font.js",line:24,description:"Underlying opentype font implementation
\n",itemtype:"property",name:"font",class:"p5.Font",module:"Typography",submodule:"Loading & Displaying"},{file:"src/typography/p5.Font.js",line:31,description:"Returns a tight bounding box for the given text string using this\nfont (currently only supports single lines)
\n",itemtype:"method",name:"textBounds",params:[{name:"line",description:"a line of text
\n",type:"String"},{name:"x",description:"x-position
\n",type:"Number"},{name:"y",description:"y-position
\n",type:"Number"},{name:"fontSize",description:"font size to use (optional) Default is 12.
\n",type:"Number",optional:!0},{name:"options",description:"opentype options (optional)\n opentype fonts contains alignment and baseline options.\n Default is 'LEFT' and 'alphabetic'
\n",type:"Object",optional:!0}],return:{description:"a rectangle object with properties: x, y, w, h",type:"Object"},example:["\n\n\nlet font;\nlet textString = 'Lorem ipsum dolor sit amet.';\nfunction preload() {\n font = loadFont('./assets/Regular.otf');\n}\nfunction setup() {\n background(210);\n\n let bbox = font.textBounds(textString, 10, 30, 12);\n fill(255);\n stroke(0);\n rect(bbox.x, bbox.y, bbox.w, bbox.h);\n fill(0);\n noStroke();\n\n textFont(font);\n textSize(12);\n text(textString, 10, 30);\n}\n
\n"],alt:"words Lorem ipsum dol go off canvas and contained by white bounding box",class:"p5.Font",module:"Typography",submodule:"Loading & Displaying"},{file:"src/typography/p5.Font.js",line:155,description:"Computes an array of points following the path for specified text
\n",itemtype:"method",name:"textToPoints",params:[{name:"txt",description:"a line of text
\n",type:"String"},{name:"x",description:"x-position
\n",type:"Number"},{name:"y",description:"y-position
\n",type:"Number"},{name:"fontSize",description:"font size to use (optional)
\n",type:"Number"},{name:"options",description:"an (optional) object that can contain:
\n
sampleFactor - the ratio of path-length to number of samples\n(default=.1); higher values yield more points and are therefore\nmore precise
\n
simplifyThreshold - if set to a non-zero value, collinear points will be\nbe removed from the polygon; the value represents the threshold angle to use\nwhen determining whether two edges are collinear
\n",type:"Object",optional:!0}],return:{description:"an array of points, each with x, y, alpha (the path angle)",type:"Array"},example:["\n\n\nlet font;\nfunction preload() {\n font = loadFont('assets/inconsolata.otf');\n}\n\nlet points;\nlet bounds;\nfunction setup() {\n createCanvas(100, 100);\n stroke(0);\n fill(255, 104, 204);\n\n points = font.textToPoints('p5', 0, 0, 10, {\n sampleFactor: 5,\n simplifyThreshold: 0\n });\n bounds = font.textBounds(' p5 ', 0, 0, 10);\n}\n\nfunction draw() {\n background(255);\n beginShape();\n translate(-bounds.x * width / bounds.w, -bounds.y * height / bounds.h);\n for (let i = 0; i < points.length; i++) {\n let p = points[i];\n vertex(\n p.x * width / bounds.w +\n sin(20 * p.y / bounds.h + millis() / 1000) * width / 30,\n p.y * height / bounds.h\n );\n }\n endShape(CLOSE);\n}\n
\n\n"],class:"p5.Font",module:"Typography",submodule:"Loading & Displaying"},{file:"src/utilities/array_functions.js",line:10,description:"Adds a value to the end of an array. Extends the length of\nthe array by one. Maps to Array.push().
\n",itemtype:"method",name:"append",deprecated:!0,deprecationMessage:'Use array.push(value) instead.',params:[{name:"array",description:"Array to append
\n",type:"Array"},{name:"value",description:"to be added to the Array
\n",type:"Any"}],return:{description:"the array that was appended to",type:"Array"},example:["\n\nfunction setup() {\n let myArray = ['Mango', 'Apple', 'Papaya'];\n print(myArray); // ['Mango', 'Apple', 'Papaya']\n\n append(myArray, 'Peach');\n print(myArray); // ['Mango', 'Apple', 'Papaya', 'Peach']\n}\n
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/array_functions.js",line:35,description:'Copies an array (or part of an array) to another array. The src array is\ncopied to the dst array, beginning at the position specified by\nsrcPosition and into the position specified by dstPosition. The number of\nelements to copy is determined by length. Note that copying values\noverwrites existing values in the destination array. To append values\ninstead of overwriting them, use concat().\n
\nThe simplified version with only two arguments, arrayCopy(src, dst),\ncopies an entire array to another of the same size. It is equivalent to\narrayCopy(src, 0, dst, 0, src.length).\n
\nUsing this function is far more efficient for copying array data than\niterating through a for() loop and copying each element individually.
\n',itemtype:"method",name:"arrayCopy",deprecated:!0,example:["\n\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
"],class:"p5",module:"Data",submodule:"Array Functions",overloads:[{line:35,params:[{name:"src",description:"the source Array
\n",type:"Array"},{name:"srcPosition",description:"starting position in the source Array
\n",type:"Integer"},{name:"dst",description:"the destination Array
\n",type:"Array"},{name:"dstPosition",description:"starting position in the destination Array
\n",type:"Integer"},{name:"length",description:"number of Array elements to be copied
\n",type:"Integer"}]},{line:73,params:[{name:"src",description:"",type:"Array"},{name:"dst",description:"",type:"Array"},{name:"length",description:"",type:"Integer",optional:!0}]}]},{file:"src/utilities/array_functions.js",line:112,description:"Concatenates two arrays, maps to Array.concat(). Does not modify the\ninput arrays.
\n",itemtype:"method",name:"concat",deprecated:!0,deprecationMessage:'Use arr1.concat(arr2) instead.',params:[{name:"a",description:"first Array to concatenate
\n",type:"Array"},{name:"b",description:"second Array to concatenate
\n",type:"Array"}],return:{description:"concatenated array",type:"Array"},example:["\n\nfunction setup() {\n 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
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/array_functions.js",line:141,description:"Reverses the order of an array, maps to Array.reverse()
\n",itemtype:"method",name:"reverse",deprecated:!0,deprecationMessage:'Use array.reverse() instead.',params:[{name:"list",description:"Array to reverse
\n",type:"Array"}],return:{description:"the reversed list",type:"Array"},example:["\n\nfunction setup() {\n let myArray = ['A', 'B', 'C'];\n print(myArray); // ['A','B','C']\n\n reverse(myArray);\n print(myArray); // ['C','B','A']\n}\n
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/array_functions.js",line:161,description:"Decreases an array by one element and returns the shortened array,\nmaps to Array.pop().
\n",itemtype:"method",name:"shorten",deprecated:!0,deprecationMessage:'Use array.pop() instead.',params:[{name:"list",description:"Array to shorten
\n",type:"Array"}],return:{description:"shortened Array",type:"Array"},example:["\n\nfunction setup() {\n let myArray = ['A', 'B', 'C'];\n print(myArray); // ['A', 'B', 'C']\n let newArray = shorten(myArray);\n print(myArray); // ['A','B','C']\n print(newArray); // ['A','B']\n}\n
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/array_functions.js",line:185,description:"Randomizes the order of the elements of an array. Implements\n\nFisher-Yates Shuffle Algorithm.
\n",itemtype:"method",name:"shuffle",params:[{name:"array",description:"Array to shuffle
\n",type:"Array"},{name:"bool",description:"modify passed array
\n",type:"Boolean",optional:!0}],return:{description:"shuffled Array",type:"Array"},example:["\n\nfunction setup() {\n let regularArr = ['ABC', 'def', createVector(), TAU, Math.E];\n print(regularArr);\n shuffle(regularArr, true); // force modifications to passed array\n print(regularArr);\n\n // By default shuffle() returns a shuffled cloned array:\n let newArr = shuffle(regularArr);\n print(regularArr);\n print(newArr);\n}\n
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/array_functions.js",line:227,description:"Sorts an array of numbers from smallest to largest, or puts an array of\nwords in alphabetical order. The original array is not modified; a\nre-ordered array is returned. The count parameter states the number of\nelements to sort. For example, if there are 12 elements in an array and\ncount is set to 5, only the first 5 elements in the array will be sorted.
\n",itemtype:"method",name:"sort",deprecated:!0,deprecationMessage:'Use array.sort() instead.',params:[{name:"list",description:"Array to sort
\n",type:"Array"},{name:"count",description:"number of elements to sort, starting from 0
\n",type:"Integer",optional:!0}],return:{description:"the sorted list",type:"Array"},example:["\n\nfunction setup() {\n let words = ['banana', 'apple', 'pear', 'lime'];\n print(words); // ['banana', 'apple', 'pear', 'lime']\n let count = 4; // length of array\n\n words = sort(words, count);\n print(words); // ['apple', 'banana', 'lime', 'pear']\n}\n
\n\nfunction setup() {\n let numbers = [2, 6, 1, 5, 14, 9, 8, 12];\n print(numbers); // [2, 6, 1, 5, 14, 9, 8, 12]\n let count = 5; // Less than the length of the array\n\n numbers = sort(numbers, count);\n print(numbers); // [1,2,5,6,14,9,8,12]\n}\n
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/array_functions.js",line:273,description:"Inserts a value or an array of values into an existing array. The first\nparameter specifies the initial array to be modified, and the second\nparameter defines the data to be inserted. The third parameter is an index\nvalue which specifies the array position from which to insert data.\n(Remember that array index numbering starts at zero, so the first position\nis 0, the second position is 1, and so on.)
\n",itemtype:"method",name:"splice",deprecated:!0,deprecationMessage:'Use array.splice() instead.',params:[{name:"list",description:"Array to splice into
\n",type:"Array"},{name:"value",description:"value to be spliced in
\n",type:"Any"},{name:"position",description:"in the array from which to insert data
\n",type:"Integer"}],return:{description:"the list",type:"Array"},example:["\n\nfunction setup() {\n let myArray = [0, 1, 2, 3, 4];\n let insArray = ['A', 'B', 'C'];\n print(myArray); // [0, 1, 2, 3, 4]\n print(insArray); // ['A','B','C']\n\n splice(myArray, insArray, 3);\n print(myArray); // [0,1,2,'A','B','C',3,4]\n}\n
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/array_functions.js",line:308,description:"Extracts an array of elements from an existing array. The list parameter\ndefines the array from which the elements will be copied, and the start\nand count parameters specify which elements to extract. If no count is\ngiven, elements will be extracted from the start to the end of the array.\nWhen specifying the start, remember that the first array element is 0.\nThis function does not change the source array.
\n",itemtype:"method",name:"subset",deprecated:!0,deprecationMessage:'Use array.slice() instead.',params:[{name:"list",description:"Array to extract from
\n",type:"Array"},{name:"start",description:"position to begin
\n",type:"Integer"},{name:"count",description:"number of values to extract
\n",type:"Integer",optional:!0}],return:{description:"Array of extracted elements",type:"Array"},example:["\n\nfunction setup() {\n let myArray = [1, 2, 3, 4, 5];\n print(myArray); // [1, 2, 3, 4, 5]\n\n let sub1 = subset(myArray, 0, 3);\n let sub2 = subset(myArray, 2, 2);\n print(sub1); // [1,2,3]\n print(sub2); // [3,4]\n}\n
"],class:"p5",module:"Data",submodule:"Array Functions"},{file:"src/utilities/conversion.js",line:10,description:"Converts a string to its floating point representation. The contents of a\nstring must resemble a number, or NaN (not a number) will be returned.\nFor example, float("1234.56") evaluates to 1234.56, but float("giraffe")\nwill return NaN.
\nWhen an array of values is passed in, then an array of floats of the same\nlength is returned.
\n",itemtype:"method",name:"float",params:[{name:"str",description:"float string to parse
\n",type:"String"}],return:{description:"floating point representation of string",type:"Number"},example:["\n\nlet str = '20';\nlet diameter = float(str);\nellipse(width / 2, height / 2, diameter, diameter);\n
\n\nprint(float('10.31')); // 10.31\nprint(float('Infinity')); // Infinity\nprint(float('-Infinity')); // -Infinity\n
"],alt:"20 by 20 white ellipse in the center of the canvas",class:"p5",module:"Data",submodule:"Conversion"},{file:"src/utilities/conversion.js",line:45,description:"Converts a boolean, string, or float to its integer representation.\nWhen an array of values is passed in, then an int array of the same length\nis returned.
\n",itemtype:"method",name:"int",return:{description:"integer representation of value",type:"Number"},example:["\n\nprint(int('10')); // 10\nprint(int(10.31)); // 10\nprint(int(-10)); // -10\nprint(int(true)); // 1\nprint(int(false)); // 0\nprint(int([false, true, '10.3', 9.8])); // [0, 1, 10, 9]\nprint(int(Infinity)); // Infinity\nprint(int('-Infinity')); // -Infinity\n
"],class:"p5",module:"Data",submodule:"Conversion",overloads:[{line:45,params:[{name:"n",description:"value to parse
\n",type:"String|Boolean|Number"},{name:"radix",description:"the radix to convert to (default: 10)
\n",type:"Integer",optional:!0}],return:{description:"integer representation of value",type:"Number"}},{line:67,params:[{name:"ns",description:"values to parse
\n",type:"Array"}],return:{description:"integer representation of values",type:"Number[]"}}]},{file:"src/utilities/conversion.js",line:88,description:"Converts a boolean, string or number to its string representation.\nWhen an array of values is passed in, then an array of strings of the same\nlength is returned.
\n",itemtype:"method",name:"str",params:[{name:"n",description:"value to parse
\n",type:"String|Boolean|Number|Array"}],return:{description:"string representation of value",type:"String"},example:['\n\nprint(str(\'10\')); // "10"\nprint(str(10.31)); // "10.31"\nprint(str(-10)); // "-10"\nprint(str(true)); // "true"\nprint(str(false)); // "false"\nprint(str([true, \'10.3\', 9.8])); // [ "true", "10.3", "9.8" ]\n
'],class:"p5",module:"Data",submodule:"Conversion"},{file:"src/utilities/conversion.js",line:114,description:"Converts a number or string to its boolean representation.\nFor a number, any non-zero value (positive or negative) evaluates to true,\nwhile zero evaluates to false. For a string, the value "true" evaluates to\ntrue, while any other value evaluates to false. When an array of number or\nstring values is passed in, then a array of booleans of the same length is\nreturned.
\n",itemtype:"method",name:"boolean",params:[{name:"n",description:"value to parse
\n",type:"String|Boolean|Number|Array"}],return:{description:"boolean representation of value",type:"Boolean"},example:["\n\nprint(boolean(0)); // false\nprint(boolean(1)); // true\nprint(boolean('true')); // true\nprint(boolean('abcd')); // false\nprint(boolean([0, 12, 'true'])); // [false, true, true]\n
"],class:"p5",module:"Data",submodule:"Conversion"},{file:"src/utilities/conversion.js",line:146,description:"Converts a number, string representation of a number, or boolean to its byte\nrepresentation. A byte can be only a whole number between -128 and 127, so\nwhen a value outside of this range is converted, it wraps around to the\ncorresponding byte representation. When an array of number, string or boolean\nvalues is passed in, then an array of bytes the same length is returned.
\n",itemtype:"method",name:"byte",return:{description:"byte representation of value",type:"Number"},example:["\n\nprint(byte(127)); // 127\nprint(byte(128)); // -128\nprint(byte(23.4)); // 23\nprint(byte('23.4')); // 23\nprint(byte('hello')); // NaN\nprint(byte(true)); // 1\nprint(byte([0, 255, '100'])); // [0, -1, 100]\n
"],class:"p5",module:"Data",submodule:"Conversion",overloads:[{line:146,params:[{name:"n",description:"value to parse
\n",type:"String|Boolean|Number"}],return:{description:"byte representation of value",type:"Number"}},{line:168,params:[{name:"ns",description:"values to parse
\n",type:"Array"}],return:{description:"array of byte representation of values",type:"Number[]"}}]},{file:"src/utilities/conversion.js",line:182,description:"Converts a number or string to its corresponding single-character\nstring representation. If a string parameter is provided, it is first\nparsed as an integer and then translated into a single-character string.\nWhen an array of number or string values is passed in, then an array of\nsingle-character strings of the same length is returned.
\n",itemtype:"method",name:"char",return:{description:"string representation of value",type:"String"},example:['\n\nprint(char(65)); // "A"\nprint(char(\'65\')); // "A"\nprint(char([65, 66, 67])); // [ "A", "B", "C" ]\nprint(join(char([65, 66, 67]), \'\')); // "ABC"\n
'],class:"p5",module:"Data",submodule:"Conversion",overloads:[{line:182,params:[{name:"n",description:"value to parse
\n",type:"String|Number"}],return:{description:"string representation of value",type:"String"}},{line:201,params:[{name:"ns",description:"values to parse
\n",type:"Array"}],return:{description:"array of string representation of values",type:"String[]"}}]},{file:"src/utilities/conversion.js",line:216,description:"Converts a single-character string to its corresponding integer\nrepresentation. When an array of single-character string values is passed\nin, then an array of integers of the same length is returned.
\n",itemtype:"method",name:"unchar",return:{description:"integer representation of value",type:"Number"},example:["\n\nprint(unchar('A')); // 65\nprint(unchar(['A', 'B', 'C'])); // [ 65, 66, 67 ]\nprint(unchar(split('ABC', ''))); // [ 65, 66, 67 ]\n
"],class:"p5",module:"Data",submodule:"Conversion",overloads:[{line:216,params:[{name:"n",description:"value to parse
\n",type:"String"}],return:{description:"integer representation of value",type:"Number"}},{line:232,params:[{name:"ns",description:"values to parse
\n",type:"Array"}],return:{description:"integer representation of values",type:"Number[]"}}]},{file:"src/utilities/conversion.js",line:245,description:"Converts a number to a string in its equivalent hexadecimal notation. If a\nsecond parameter is passed, it is used to set the number of characters to\ngenerate in the hexadecimal notation. When an array is passed in, an\narray of strings in hexadecimal notation of the same length is returned.
\n",itemtype:"method",name:"hex",return:{description:"hexadecimal string representation of value",type:"String"},example:['\n\nprint(hex(255)); // "000000FF"\nprint(hex(255, 6)); // "0000FF"\nprint(hex([0, 127, 255], 6)); // [ "000000", "00007F", "0000FF" ]\nprint(Infinity); // "FFFFFFFF"\nprint(-Infinity); // "00000000"\n
'],class:"p5",module:"Data",submodule:"Conversion",overloads:[{line:245,params:[{name:"n",description:"value to parse
\n",type:"Number"},{name:"digits",description:"",type:"Number",optional:!0}],return:{description:"hexadecimal string representation of value",type:"String"}},{line:265,params:[{name:"ns",description:"array of values to parse
\n",type:"Number[]"},{name:"digits",description:"",type:"Number",optional:!0}],return:{description:"hexadecimal string representation of values",type:"String[]"}}]},{file:"src/utilities/conversion.js",line:295,description:"Converts a string representation of a hexadecimal number to its equivalent\ninteger value. When an array of strings in hexadecimal notation is passed\nin, an array of integers of the same length is returned.
\n",itemtype:"method",name:"unhex",return:{description:"integer representation of hexadecimal value",type:"Number"},example:["\n\nprint(unhex('A')); // 10\nprint(unhex('FF')); // 255\nprint(unhex(['FF', 'AA', '00'])); // [ 255, 170, 0 ]\n
"],class:"p5",module:"Data",submodule:"Conversion",overloads:[{line:295,params:[{name:"n",description:"value to parse
\n",type:"String"}],return:{description:"integer representation of hexadecimal value",type:"Number"}},{line:311,params:[{name:"ns",description:"values to parse
\n",type:"Array"}],return:{description:"integer representations of hexadecimal value",type:"Number[]"}}]},{file:"src/utilities/string_functions.js",line:13,description:'Combines an array of Strings into one String, each separated by the\ncharacter(s) used for the separator parameter. To join arrays of ints or\nfloats, it's necessary to first convert them to Strings using nf() or\nnfs().
\n',itemtype:"method",name:"join",params:[{name:"list",description:"array of Strings to be joined
\n",type:"Array"},{name:"separator",description:"String to be placed between each item
\n",type:"String"}],return:{description:"joined String",type:"String"},example:["\n\n\nlet array = ['Hello', 'world!'];\nlet separator = ' ';\nlet message = join(array, separator);\ntext(message, 5, 50);\n
\n"],alt:'"hello world!" displayed middle left of canvas.',class:"p5",module:"Data",submodule:"String Functions"},{file:"src/utilities/string_functions.js",line:42,description:"This function is used to apply a regular expression to a piece of text,\nand return matching groups (elements found inside parentheses) as a\nString array. If there are no matches, a null value will be returned.\nIf no groups are specified in the regular expression, but the sequence\nmatches, an array of length 1 (with the matched text as the first element\nof the array) will be returned.\n
\nTo use the function, first check to see if the result is null. If the\nresult is null, then the sequence did not match at all. If the sequence\ndid match, an array is returned.\n
\nIf there are groups (specified by sets of parentheses) in the regular\nexpression, then the contents of each will be returned in the array.\nElement [0] of a regular expression match returns the entire matching\nstring, and the match groups start at element [1] (the first group is [1],\nthe second [2], and so on).
\n",itemtype:"method",name:"match",params:[{name:"str",description:"the String to be searched
\n",type:"String"},{name:"regexp",description:"the regexp to be used for matching
\n",type:"String"}],return:{description:"Array of Strings found",type:"String[]"},example:["\n\n\nlet string = 'Hello p5js*!';\nlet regexp = 'p5js\\\\*';\nlet m = match(string, regexp);\ntext(m, 5, 50);\n
\n"],alt:'"p5js*" displayed middle left of canvas.',class:"p5",module:"Data",submodule:"String Functions"},{file:"src/utilities/string_functions.js",line:83,description:"This function is used to apply a regular expression to a piece of text,\nand return a list of matching groups (elements found inside parentheses)\nas a two-dimensional String array. If there are no matches, a null value\nwill be returned. If no groups are specified in the regular expression,\nbut the sequence matches, a two dimensional array is still returned, but\nthe second dimension is only of length one.\n
\nTo use the function, first check to see if the result is null. If the\nresult is null, then the sequence did not match at all. If the sequence\ndid match, a 2D array is returned.\n
\nIf there are groups (specified by sets of parentheses) in the regular\nexpression, then the contents of each will be returned in the array.\nAssuming a loop with counter variable i, element [i][0] of a regular\nexpression match returns the entire matching string, and the match groups\nstart at element [i][1] (the first group is [i][1], the second [i][2],\nand so on).
\n",itemtype:"method",name:"matchAll",params:[{name:"str",description:"the String to be searched
\n",type:"String"},{name:"regexp",description:"the regexp to be used for matching
\n",type:"String"}],return:{description:"2d Array of Strings found",type:"String[]"},example:["\n\n\nlet string = 'Hello p5js*! Hello world!';\nlet regexp = 'Hello';\nmatchAll(string, regexp);\n
\n"],class:"p5",module:"Data",submodule:"String Functions"},{file:"src/utilities/string_functions.js",line:130,description:"Utility function for formatting numbers into strings. There are two\nversions: one for formatting floats, and one for formatting ints.\nThe values for the digits, left, and right parameters should always\nbe positive integers.\n(NOTE): Be cautious when using left and right parameters as it prepends numbers of 0's if the parameter\nif greater than the current length of the number.\nFor example if number is 123.2 and left parameter passed is 4 which is greater than length of 123\n(integer part) i.e 3 than result will be 0123.2. Same case for right parameter i.e. if right is 3 than\nthe result will be 123.200.
\n",itemtype:"method",name:"nf",return:{description:"formatted String",type:"String"},example:["\n\n\nlet myFont;\nfunction preload() {\n myFont = loadFont('assets/fonts/inconsolata.ttf');\n}\nfunction setup() {\n background(200);\n let num1 = 321;\n let num2 = -1321;\n\n noStroke();\n fill(0);\n textFont(myFont);\n textSize(22);\n\n text(nf(num1, 4, 2), 10, 30);\n text(nf(num2, 4, 2), 10, 80);\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n}\n
\n"],alt:'"0321.00" middle top, -1321.00" middle bottom canvas',class:"p5",module:"Data",submodule:"String Functions",overloads:[{line:130,params:[{name:"num",description:"the Number to format
\n",type:"Number|String"},{name:"left",description:"number of digits to the left of the\n decimal point
\n",type:"Integer|String",optional:!0},{name:"right",description:"number of digits to the right of the\n decimal point
\n",type:"Integer|String",optional:!0}],return:{description:"formatted String",type:"String"}},{line:178,params:[{name:"nums",description:"the Numbers to format
\n",type:"Array"},{name:"left",description:"",type:"Integer|String",optional:!0},{name:"right",description:"",type:"Integer|String",optional:!0}],return:{description:"formatted Strings",type:"String[]"}}]},{file:"src/utilities/string_functions.js",line:239,description:"Utility function for formatting numbers into strings and placing\nappropriate commas to mark units of 1000. There are two versions: one\nfor formatting ints, and one for formatting an array of ints. The value\nfor the right parameter should always be a positive integer.
\n",itemtype:"method",name:"nfc",return:{description:"formatted String",type:"String"},example:["\n\n\nfunction setup() {\n background(200);\n let num = 11253106.115;\n let numArr = [1, 1, 2];\n\n noStroke();\n fill(0);\n textSize(12);\n\n // Draw formatted numbers\n text(nfc(num, 4), 10, 30);\n text(nfc(numArr, 2), 10, 80);\n\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n}\n
\n"],alt:'"11,253,106.115" top middle and "1.00,1.00,2.00" displayed bottom mid',class:"p5",module:"Data",submodule:"String Functions",overloads:[{line:239,params:[{name:"num",description:"the Number to format
\n",type:"Number|String"},{name:"right",description:"number of digits to the right of the\n decimal point
\n",type:"Integer|String",optional:!0}],return:{description:"formatted String",type:"String"}},{line:277,params:[{name:"nums",description:"the Numbers to format
\n",type:"Array"},{name:"right",description:"",type:"Integer|String",optional:!0}],return:{description:"formatted Strings",type:"String[]"}}]},{file:"src/utilities/string_functions.js",line:313,description:'Utility function for formatting numbers into strings. Similar to nf() but\nputs a "+" in front of positive numbers and a "-" in front of negative\nnumbers. There are two versions: one for formatting floats, and one for\nformatting ints. The values for left, and right parameters\nshould always be positive integers.
\n',itemtype:"method",name:"nfp",return:{description:"formatted String",type:"String"},example:["\n\n\nfunction setup() {\n background(200);\n let num1 = 11253106.115;\n let num2 = -11253106.115;\n\n noStroke();\n fill(0);\n textSize(12);\n\n // Draw formatted numbers\n text(nfp(num1, 4, 2), 10, 30);\n text(nfp(num2, 4, 2), 10, 80);\n\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n}\n
\n"],alt:'"+11253106.11" top middle and "-11253106.11" displayed bottom middle',class:"p5",module:"Data",submodule:"String Functions",overloads:[{line:313,params:[{name:"num",description:"the Number to format
\n",type:"Number"},{name:"left",description:"number of digits to the left of the decimal\n point
\n",type:"Integer",optional:!0},{name:"right",description:"number of digits to the right of the\n decimal point
\n",type:"Integer",optional:!0}],return:{description:"formatted String",type:"String"}},{line:354,params:[{name:"nums",description:"the Numbers to format
\n",type:"Number[]"},{name:"left",description:"",type:"Integer",optional:!0},{name:"right",description:"",type:"Integer",optional:!0}],return:{description:"formatted Strings",type:"String[]"}}]},{file:"src/utilities/string_functions.js",line:375,description:'Utility function for formatting numbers into strings. Similar to nf() but\nputs an additional "_" (space) in front of positive numbers just in case to align it with negative\nnumbers which includes "-" (minus) sign.\nThe main usecase of nfs() can be seen when one wants to align the digits (place values) of a non-negative\nnumber with some negative number (See the example to get a clear picture).\nThere are two versions: one for formatting float, and one for formatting int.\nThe values for the digits, left, and right parameters should always be positive integers.\n(IMP): The result on the canvas basically the expected alignment can vary based on the typeface you are using.\n(NOTE): Be cautious when using left and right parameters as it prepends numbers of 0's if the parameter\nif greater than the current length of the number.\nFor example if number is 123.2 and left parameter passed is 4 which is greater than length of 123\n(integer part) i.e 3 than result will be 0123.2. Same case for right parameter i.e. if right is 3 than\nthe result will be 123.200.
\n',itemtype:"method",name:"nfs",return:{description:"formatted String",type:"String"},example:["\n\n\nlet myFont;\nfunction preload() {\n myFont = loadFont('assets/fonts/inconsolata.ttf');\n}\nfunction setup() {\n background(200);\n let num1 = 321;\n let num2 = -1321;\n\n noStroke();\n fill(0);\n textFont(myFont);\n textSize(22);\n\n // nfs() aligns num1 (positive number) with num2 (negative number) by\n // adding a blank space in front of the num1 (positive number)\n // [left = 4] in num1 add one 0 in front, to align the digits with num2\n // [right = 2] in num1 and num2 adds two 0's after both numbers\n // To see the differences check the example of nf() too.\n text(nfs(num1, 4, 2), 10, 30);\n text(nfs(num2, 4, 2), 10, 80);\n // Draw dividing line\n stroke(120);\n line(0, 50, width, 50);\n}\n
\n"],alt:'"0321.00" top middle and "-1321.00" displayed bottom middle',class:"p5",module:"Data",submodule:"String Functions",overloads:[{line:375,params:[{name:"num",description:"the Number to format
\n",type:"Number"},{name:"left",description:"number of digits to the left of the decimal\n point
\n",type:"Integer",optional:!0},{name:"right",description:"number of digits to the right of the\n decimal point
\n",type:"Integer",optional:!0}],return:{description:"formatted String",type:"String"}},{line:432,params:[{name:"nums",description:"the Numbers to format
\n",type:"Array"},{name:"left",description:"",type:"Integer",optional:!0},{name:"right",description:"",type:"Integer",optional:!0}],return:{description:"formatted Strings",type:"String[]"}}]},{file:"src/utilities/string_functions.js",line:453,description:'The split() function maps to String.split(), it breaks a String into\npieces using a character or string as the delimiter. The delim parameter\nspecifies the character or characters that mark the boundaries between\neach piece. A String[] array is returned that contains each of the pieces.
\nThe splitTokens() function works in a similar fashion, except that it\nsplits using a range of characters instead of a specific character or\nsequence.
\n',itemtype:"method",name:"split",params:[{name:"value",description:"the String to be split
\n",type:"String"},{name:"delim",description:"the String used to separate the data
\n",type:"String"}],return:{description:"Array of Strings",type:"String[]"},example:["\n\n\nlet names = 'Pat,Xio,Alex';\nlet splitString = split(names, ',');\ntext(splitString[0], 5, 30);\ntext(splitString[1], 5, 50);\ntext(splitString[2], 5, 70);\n
\n"],alt:'"pat" top left, "Xio" mid left and "Alex" displayed bottom left',class:"p5",module:"Data",submodule:"String Functions"},{file:"src/utilities/string_functions.js",line:487,description:'The splitTokens() function splits a String at one or many character\ndelimiters or "tokens." The delim parameter specifies the character or\ncharacters to be used as a boundary.\n
\nIf no delim characters are specified, any whitespace character is used to\nsplit. Whitespace characters include tab (\\t), line feed (\\n), carriage\nreturn (\\r), form feed (\\f), and space.
\n',itemtype:"method",name:"splitTokens",params:[{name:"value",description:"the String to be split
\n",type:"String"},{name:"delim",description:"list of individual Strings that will be used as\n separators
\n",type:"String",optional:!0}],return:{description:"Array of Strings",type:"String[]"},example:['\n\n\nfunction setup() {\n let myStr = \'Mango, Banana, Lime\';\n let myStrArr = splitTokens(myStr, \',\');\n\n print(myStrArr); // prints : ["Mango"," Banana"," Lime"]\n}\n
\n'],class:"p5",module:"Data",submodule:"String Functions"},{file:"src/utilities/string_functions.js",line:540,description:"Removes whitespace characters from the beginning and end of a String. In\naddition to standard whitespace characters such as space, carriage return,\nand tab, this function also removes the Unicode "nbsp" character.
\n",itemtype:"method",name:"trim",return:{description:"a trimmed String",type:"String"},example:["\n\n\nlet string = trim(' No new lines\\n ');\ntext(string + ' here', 2, 50);\n
\n"],alt:'"No new lines here" displayed center canvas',class:"p5",module:"Data",submodule:"String Functions",overloads:[{line:540,params:[{name:"str",description:"a String to be trimmed
\n",type:"String"}],return:{description:"a trimmed String",type:"String"}},{line:560,params:[{name:"strs",description:"an Array of Strings to be trimmed
\n",type:"Array"}],return:{description:"an Array of trimmed Strings",type:"String[]"}}]},{file:"src/utilities/time_date.js",line:10,description:'p5.js communicates with the clock on your computer. The day() function\nreturns the current day as a value from 1 - 31.
\n',itemtype:"method",name:"day",return:{description:"the current day",type:"Integer"},example:["\n\n\nlet d = day();\ntext('Current day: \\n' + d, 5, 50);\n
\n"],alt:"Current day is displayed",class:"p5",module:"IO",submodule:"Time & Date"},{file:"src/utilities/time_date.js",line:32,description:'p5.js communicates with the clock on your computer. The hour() function\nreturns the current hour as a value from 0 - 23.
\n',itemtype:"method",name:"hour",return:{description:"the current hour",type:"Integer"},example:["\n\n\nlet h = hour();\ntext('Current hour:\\n' + h, 5, 50);\n
\n"],alt:"Current hour is displayed",class:"p5",module:"IO",submodule:"Time & Date"},{file:"src/utilities/time_date.js",line:54,description:'p5.js communicates with the clock on your computer. The minute() function\nreturns the current minute as a value from 0 - 59.
\n',itemtype:"method",name:"minute",return:{description:"the current minute",type:"Integer"},example:["\n\n\nlet m = minute();\ntext('Current minute: \\n' + m, 5, 50);\n
\n"],alt:"Current minute is displayed",class:"p5",module:"IO",submodule:"Time & Date"},{file:"src/utilities/time_date.js",line:76,description:"Returns the number of milliseconds (thousandths of a second) since\nstarting the sketch (when setup()
is called). This information is often\nused for timing events and animation sequences.
\n",itemtype:"method",name:"millis",return:{description:"the number of milliseconds since starting the sketch",type:"Number"},example:["\n\n\nlet millisecond = millis();\ntext('Milliseconds \\nrunning: \\n' + millisecond, 5, 40);\n
\n"],alt:"number of milliseconds since sketch has started displayed",class:"p5",module:"IO",submodule:"Time & Date"},{file:"src/utilities/time_date.js",line:104,description:'p5.js communicates with the clock on your computer. The month() function\nreturns the current month as a value from 1 - 12.
\n',itemtype:"method",name:"month",return:{description:"the current month",type:"Integer"},example:["\n\n\nlet m = month();\ntext('Current month: \\n' + m, 5, 50);\n
\n"],alt:"Current month is displayed",class:"p5",module:"IO",submodule:"Time & Date"},{file:"src/utilities/time_date.js",line:127,description:'p5.js communicates with the clock on your computer. The second() function\nreturns the current second as a value from 0 - 59.
\n',itemtype:"method",name:"second",return:{description:"the current second",type:"Integer"},example:["\n\n\nlet s = second();\ntext('Current second: \\n' + s, 5, 50);\n
\n"],alt:"Current second is displayed",class:"p5",module:"IO",submodule:"Time & Date"},{file:"src/utilities/time_date.js",line:149,description:'p5.js communicates with the clock on your computer. The year() function\nreturns the current year as an integer (2014, 2015, 2016, etc).
\n',itemtype:"method",name:"year",return:{description:"the current year",type:"Integer"},example:["\n\n\nlet y = year();\ntext('Current year: \\n' + y, 5, 50);\n
\n"],alt:"Current year is displayed",class:"p5",module:"IO",submodule:"Time & Date"},{file:"src/webgl/3d_primitives.js",line:13,description:"Draw a plane with given a width and height
\n",itemtype:"method",name:"plane",params:[{name:"width",description:"width of the plane
\n",type:"Number",optional:!0},{name:"height",description:"height of the plane
\n",type:"Number",optional:!0},{name:"detailX",description:"Optional number of triangle\n subdivisions in x-dimension
\n",type:"Integer",optional:!0},{name:"detailY",description:"Optional number of triangle\n subdivisions in y-dimension
\n",type:"Integer",optional:!0}],chainable:1,example:["\n\n\n// draw a plane\n// with width 50 and height 50\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n plane(50, 50);\n}\n
\n"],alt:"Nothing displayed on canvas\nRotating interior view of a box with sides that change color.\n3d red and green gradient.\nRotating interior view of a cylinder with sides that change color.\nRotating view of a cylinder with sides that change color.\n3d red and green gradient.\nrotating view of a multi-colored cylinder with concave sides.",class:"p5",module:"Shape",submodule:"3D Primitives"},{file:"src/webgl/3d_primitives.js",line:97,description:"Draw a box with given width, height and depth
\n",itemtype:"method",name:"box",params:[{name:"width",description:"width of the box
\n",type:"Number",optional:!0},{name:"Height",description:"height of the box
\n",type:"Number",optional:!0},{name:"depth",description:"depth of the box
\n",type:"Number",optional:!0},{name:"detailX",description:"Optional number of triangle\n subdivisions in x-dimension
\n",type:"Integer",optional:!0},{name:"detailY",description:"Optional number of triangle\n subdivisions in y-dimension
\n",type:"Integer",optional:!0}],chainable:1,example:["\n\n\n// draw a spinning box\n// with width, height and depth of 50\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n box(50);\n}\n
\n"],class:"p5",module:"Shape",submodule:"3D Primitives"},{file:"src/webgl/3d_primitives.js",line:215,description:"Draw a sphere with given radius.
\nDetailX and detailY determines the number of subdivisions in the x-dimension\nand the y-dimension of a sphere. More subdivisions make the sphere seem\nsmoother. The recommended maximum values are both 24. Using a value greater\nthan 24 may cause a warning or slow down the browser.
\n",itemtype:"method",name:"sphere",params:[{name:"radius",description:"radius of circle
\n",type:"Number",optional:!0},{name:"detailX",description:"optional number of subdivisions in x-dimension
\n",type:"Integer",optional:!0},{name:"detailY",description:"optional number of subdivisions in y-dimension
\n",type:"Integer",optional:!0}],chainable:1,example:["\n\n\n// draw a sphere with radius 40\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(205, 102, 94);\n sphere(40);\n}\n
\n","\n\n\nlet detailX;\n// slide to see how detailX works\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(3, 24, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n sphere(40, detailX.value(), 16);\n}\n
\n","\n\n\nlet detailY;\n// slide to see how detailY works\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(3, 16, 3);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n sphere(40, 16, detailY.value());\n}\n
\n"],class:"p5",module:"Shape",submodule:"3D Primitives"},{file:"src/webgl/3d_primitives.js",line:419,description:"Draw a cylinder with given radius and height
\nDetailX and detailY determines the number of subdivisions in the x-dimension\nand the y-dimension of a cylinder. More subdivisions make the cylinder seem smoother.\nThe recommended maximum value for detailX is 24. Using a value greater than 24\nmay cause a warning or slow down the browser.
\n",itemtype:"method",name:"cylinder",params:[{name:"radius",description:"radius of the surface
\n",type:"Number",optional:!0},{name:"height",description:"height of the cylinder
\n",type:"Number",optional:!0},{name:"detailX",description:"number of subdivisions in x-dimension;\n default is 24
\n",type:"Integer",optional:!0},{name:"detailY",description:"number of subdivisions in y-dimension;\n default is 1
\n",type:"Integer",optional:!0},{name:"bottomCap",description:"whether to draw the bottom of the cylinder
\n",type:"Boolean",optional:!0},{name:"topCap",description:"whether to draw the top of the cylinder
\n",type:"Boolean",optional:!0}],chainable:1,example:["\n\n\n// draw a spinning cylinder\n// with radius 20 and height 50\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n cylinder(20, 50);\n}\n
\n","\n\n\n// slide to see how detailX works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(3, 24, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n cylinder(20, 75, detailX.value(), 1);\n}\n
\n","\n\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(1, 16, 1);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n cylinder(20, 75, 16, detailY.value());\n}\n
\n"],class:"p5",module:"Shape",submodule:"3D Primitives"},{file:"src/webgl/3d_primitives.js",line:554,description:"Draw a cone with given radius and height
\nDetailX and detailY determine the number of subdivisions in the x-dimension and\nthe y-dimension of a cone. More subdivisions make the cone seem smoother. The\nrecommended maximum value for detailX is 24. Using a value greater than 24\nmay cause a warning or slow down the browser.
\n",itemtype:"method",name:"cone",params:[{name:"radius",description:"radius of the bottom surface
\n",type:"Number",optional:!0},{name:"height",description:"height of the cone
\n",type:"Number",optional:!0},{name:"detailX",description:"number of segments,\n the more segments the smoother geometry\n default is 24
\n",type:"Integer",optional:!0},{name:"detailY",description:"number of segments,\n the more segments the smoother geometry\n default is 1
\n",type:"Integer",optional:!0},{name:"cap",description:"whether to draw the base of the cone
\n",type:"Boolean",optional:!0}],chainable:1,example:["\n\n\n// draw a spinning cone\n// with radius 40 and height 70\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateZ(frameCount * 0.01);\n cone(40, 70);\n}\n
\n","\n\n\n// slide to see how detailx works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(3, 16, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n cone(30, 65, detailX.value(), 16);\n}\n
\n","\n\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(3, 16, 3);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n cone(30, 65, 16, detailY.value());\n}\n
\n"],class:"p5",module:"Shape",submodule:"3D Primitives"},{file:"src/webgl/3d_primitives.js",line:669,description:"Draw an ellipsoid with given radius
\nDetailX and detailY determine the number of subdivisions in the x-dimension and\nthe y-dimension of a cone. More subdivisions make the ellipsoid appear to be smoother.\nAvoid detail number above 150, it may crash the browser.
\n",itemtype:"method",name:"ellipsoid",params:[{name:"radiusx",description:"x-radius of ellipsoid
\n",type:"Number",optional:!0},{name:"radiusy",description:"y-radius of ellipsoid
\n",type:"Number",optional:!0},{name:"radiusz",description:"z-radius of ellipsoid
\n",type:"Number",optional:!0},{name:"detailX",description:"number of segments,\n the more segments the smoother geometry\n default is 24. Avoid detail number above\n 150, it may crash the browser.
\n",type:"Integer",optional:!0},{name:"detailY",description:"number of segments,\n the more segments the smoother geometry\n default is 16. Avoid detail number above\n 150, it may crash the browser.
\n",type:"Integer",optional:!0}],chainable:1,example:["\n\n\n// draw an ellipsoid\n// with radius 30, 40 and 40.\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(205, 105, 94);\n ellipsoid(30, 40, 40);\n}\n
\n","\n\n\n// slide to see how detailX works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(2, 24, 12);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 105, 94);\n rotateY(millis() / 1000);\n ellipsoid(30, 40, 40, detailX.value(), 8);\n}\n
\n","\n\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(2, 24, 6);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 105, 9);\n rotateY(millis() / 1000);\n ellipsoid(30, 40, 40, 12, detailY.value());\n}\n
\n\n"],class:"p5",module:"Shape",submodule:"3D Primitives"},{file:"src/webgl/3d_primitives.js",line:805,description:"Draw a torus with given radius and tube radius
\nDetailX and detailY determine the number of subdivisions in the x-dimension and\nthe y-dimension of a torus. More subdivisions make the torus appear to be smoother.\nThe default and maximum values for detailX and detailY are 24 and 16, respectively.\nSetting them to relatively small values like 4 and 6 allows you to create new\nshapes other than a torus.
\n",itemtype:"method",name:"torus",params:[{name:"radius",description:"radius of the whole ring
\n",type:"Number",optional:!0},{name:"tubeRadius",description:"radius of the tube
\n",type:"Number",optional:!0},{name:"detailX",description:"number of segments in x-dimension,\n the more segments the smoother geometry\n default is 24
\n",type:"Integer",optional:!0},{name:"detailY",description:"number of segments in y-dimension,\n the more segments the smoother geometry\n default is 16
\n",type:"Integer",optional:!0}],chainable:1,example:["\n\n\n// draw a spinning torus\n// with ring radius 30 and tube radius 15\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n torus(30, 15);\n}\n
\n","\n\n\n// slide to see how detailX works\nlet detailX;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailX = createSlider(3, 24, 3);\n detailX.position(10, height + 5);\n detailX.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n torus(30, 15, detailX.value(), 12);\n}\n
\n","\n\n\n// slide to see how detailY works\nlet detailY;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n detailY = createSlider(3, 16, 3);\n detailY.position(10, height + 5);\n detailY.style('width', '80px');\n}\n\nfunction draw() {\n background(205, 102, 94);\n rotateY(millis() / 1000);\n torus(30, 15, 16, detailY.value());\n}\n
\n"],class:"p5",module:"Shape",submodule:"3D Primitives"},{file:"src/webgl/interaction.js",line:11,description:"Allows movement around a 3D sketch using a mouse or trackpad. Left-clicking\nand dragging will rotate the camera position about the center of the sketch,\nright-clicking and dragging will pan the camera position without rotation,\nand using the mouse wheel (scrolling) will move the camera closer or further\nfrom the center of the sketch. This function can be called with parameters\ndictating sensitivity to mouse movement along the X and Y axes. Calling\nthis function without parameters is equivalent to calling orbitControl(1,1).\nTo reverse direction of movement in either axis, enter a negative number\nfor sensitivity.
\n",itemtype:"method",name:"orbitControl",params:[{name:"sensitivityX",description:"sensitivity to mouse movement along X axis
\n",type:"Number",optional:!0},{name:"sensitivityY",description:"sensitivity to mouse movement along Y axis
\n",type:"Number",optional:!0},{name:"sensitivityZ",description:"sensitivity to scroll movement along Z axis
\n",type:"Number",optional:!0}],chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n}\nfunction draw() {\n background(200);\n orbitControl();\n rotateY(0.5);\n box(30, 50);\n}\n
\n"],alt:"Camera orbits around a box when mouse is hold-clicked & then moved.",class:"p5",module:"Lights, Camera",submodule:"Interaction"},{file:"src/webgl/interaction.js",line:145,description:"debugMode() helps visualize 3D space by adding a grid to indicate where the\n‘ground’ is in a sketch and an axes icon which indicates the +X, +Y, and +Z\ndirections. This function can be called without parameters to create a\ndefault grid and axes icon, or it can be called according to the examples\nabove to customize the size and position of the grid and/or axes icon. The\ngrid is drawn using the most recently set stroke color and weight. To\nspecify these parameters, add a call to stroke() and strokeWeight()\njust before the end of the draw() loop.
\nBy default, the grid will run through the origin (0,0,0) of the sketch\nalong the XZ plane\nand the axes icon will be offset from the origin. Both the grid and axes\nicon will be sized according to the current canvas size. Note that because the\ngrid runs parallel to the default camera view, it is often helpful to use\ndebugMode along with orbitControl to allow full view of the grid.
\n",itemtype:"method",name:"debugMode",example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n normalMaterial();\n debugMode();\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n // Press the spacebar to turn debugMode off!\n if (keyIsDown(32)) {\n noDebugMode();\n }\n}\n
\n","\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n normalMaterial();\n debugMode(GRID);\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n}\n
\n","\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n normalMaterial();\n debugMode(AXES);\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n}\n
\n","\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n normalMaterial();\n debugMode(GRID, 100, 10, 0, 0, 0);\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n}\n
\n","\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n normalMaterial();\n debugMode(100, 10, 0, 0, 0, 20, 0, -40, 0);\n}\n\nfunction draw() {\n noStroke();\n background(200);\n orbitControl();\n box(15, 30);\n // set the stroke color and weight for the grid!\n stroke(255, 0, 150);\n strokeWeight(0.8);\n}\n
\n"],alt:"a 3D box is centered on a grid in a 3D sketch. an icon\nindicates the direction of each axis: a red line points +X,\na green line +Y, and a blue line +Z.",class:"p5",module:"Lights, Camera",submodule:"Interaction",overloads:[{line:145,params:[]},{line:278,params:[{name:"mode",description:"either GRID or AXES
\n",type:"Constant"}]},{line:283,params:[{name:"mode",description:"",type:"Constant"},{name:"gridSize",description:"size of one side of the grid
\n",type:"Number",optional:!0},{name:"gridDivisions",description:"number of divisions in the grid
\n",type:"Number",optional:!0},{name:"xOff",description:"X axis offset from origin (0,0,0)
\n",type:"Number",optional:!0},{name:"yOff",description:"Y axis offset from origin (0,0,0)
\n",type:"Number",optional:!0},{name:"zOff",description:"Z axis offset from origin (0,0,0)
\n",type:"Number",optional:!0}]},{line:293,params:[{name:"mode",description:"",type:"Constant"},{name:"axesSize",description:"size of axes icon
\n",type:"Number",optional:!0},{name:"xOff",description:"",type:"Number",optional:!0},{name:"yOff",description:"",type:"Number",optional:!0},{name:"zOff",description:"",type:"Number",optional:!0}]},{line:302,params:[{name:"gridSize",description:"",type:"Number",optional:!0},{name:"gridDivisions",description:"",type:"Number",optional:!0},{name:"gridXOff",description:"",type:"Number",optional:!0},{name:"gridYOff",description:"",type:"Number",optional:!0},{name:"gridZOff",description:"",type:"Number",optional:!0},{name:"axesSize",description:"",type:"Number",optional:!0},{name:"axesXOff",description:"",type:"Number",optional:!0},{name:"axesYOff",description:"",type:"Number",optional:!0},{name:"axesZOff",description:"",type:"Number",optional:!0}]}]},{file:"src/webgl/interaction.js",line:353,description:"Turns off debugMode() in a 3D sketch.
\n",itemtype:"method",name:"noDebugMode",example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n camera(0, -30, 100, 0, 0, 0, 0, 1, 0);\n normalMaterial();\n debugMode();\n}\n\nfunction draw() {\n background(200);\n orbitControl();\n box(15, 30);\n // Press the spacebar to turn debugMode off!\n if (keyIsDown(32)) {\n noDebugMode();\n }\n}\n
\n"],alt:"a 3D box is centered on a grid in a 3D sketch. an icon\nindicates the direction of each axis: a red line points +X,\na green line +Y, and a blue line +Z. the grid and icon disappear when the\nspacebar is pressed.",class:"p5",module:"Lights, Camera",submodule:"Interaction"},{file:"src/webgl/light.js",line:10,description:"Creates an ambient light with a color. Ambient light is light that comes from everywhere on the canvas.\nIt has no particular source.
\n",itemtype:"method",name:"ambientLight",chainable:1,example:["\n\n\ncreateCanvas(100, 100, WEBGL);\nambientLight(0);\nambientMaterial(250);\nsphere(40);\n
\n\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(51);\n ambientLight(100); // white light\n ambientMaterial(255, 102, 94); // magenta material\n box(30);\n}\n
\n"],alt:"evenly distributed light across a sphere\nevenly distributed light across a rotating sphere",class:"p5",module:"Lights, Camera",submodule:"Lights",overloads:[{line:10,params:[{name:"v1",description:"red or hue value relative to\n the current color range
\n",type:"Number"},{name:"v2",description:"green or saturation value\n relative to the current color range
\n",type:"Number"},{name:"v3",description:"blue or brightness value\n relative to the current color range
\n",type:"Number"},{name:"alpha",description:"the alpha value
\n",type:"Number",optional:!0}],chainable:1},{line:51,params:[{name:"value",description:"a color string
\n",type:"String"}],chainable:1},{line:57,params:[{name:"gray",description:"a gray value
\n",type:"Number"},{name:"alpha",description:"",type:"Number",optional:!0}],chainable:1},{line:64,params:[{name:"values",description:"an array containing the red,green,blue &\n and alpha components of the color
\n",type:"Number[]"}],chainable:1},{line:71,params:[{name:"color",description:"the ambient light color
\n",type:"p5.Color"}],chainable:1}]},{file:"src/webgl/light.js",line:92,description:'Set's the color of the specular highlight when using a specular material and\nspecular light.
\nThis method can be combined with specularMaterial() and shininess()\nfunctions to set specular highlights. The default color is white, ie\n(255, 255, 255), which is used if this method is not called before\nspecularMaterial(). If this method is called without specularMaterial(),\nThere will be no effect.
\nNote: specularColor is equivalent to the processing function\nlightSpecular.
\n',itemtype:"method",name:"specularColor",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n}\n\nfunction draw() {\n background(0);\n shininess(20);\n ambientLight(50);\n specularColor(255, 0, 0);\n pointLight(255, 0, 0, 0, -50, 50);\n specularColor(0, 255, 0);\n pointLight(0, 255, 0, 0, 50, 50);\n specularMaterial(255);\n sphere(40);\n}\n
\n"],alt:"different specular light sources from top and bottom of canvas",class:"p5",module:"Lights, Camera",submodule:"Lights",overloads:[{line:92,params:[{name:"v1",description:"red or hue value relative to\n the current color range
\n",type:"Number"},{name:"v2",description:"green or saturation value\n relative to the current color range
\n",type:"Number"},{name:"v3",description:"blue or brightness value\n relative to the current color range
\n",type:"Number"}],chainable:1},{line:139,params:[{name:"value",description:"a color string
\n",type:"String"}],chainable:1},{line:145,params:[{name:"gray",description:"a gray value
\n",type:"Number"}],chainable:1},{line:151,params:[{name:"values",description:"an array containing the red,green,blue &\n and alpha components of the color
\n",type:"Number[]"}],chainable:1},{line:158,params:[{name:"color",description:"the ambient light color
\n",type:"p5.Color"}],chainable:1}]},{file:"src/webgl/light.js",line:177,description:"Creates a directional light with a color and a direction
\nA maximum of 5 directionalLight can be active at one time
\n",itemtype:"method",name:"directionalLight",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n //move your mouse to change light direction\n let dirX = (mouseX / width - 0.5) * 2;\n let dirY = (mouseY / height - 0.5) * 2;\n directionalLight(250, 250, 250, -dirX, -dirY, -1);\n noStroke();\n sphere(40);\n}\n
\n"],alt:"light source on canvas changeable with mouse position",class:"p5",module:"Lights, Camera",submodule:"Lights",overloads:[{line:177,params:[{name:"v1",description:"red or hue value (depending on the current\ncolor mode),
\n",type:"Number"},{name:"v2",description:"green or saturation value
\n",type:"Number"},{name:"v3",description:"blue or brightness value
\n",type:"Number"},{name:"position",description:"the direction of the light
\n",type:"p5.Vector"}],chainable:1},{line:211,params:[{name:"color",description:'color Array, CSS color string,\n or p5.Color value
\n',type:"Number[]|String|p5.Color"},{name:"x",description:"x axis direction
\n",type:"Number"},{name:"y",description:"y axis direction
\n",type:"Number"},{name:"z",description:"z axis direction
\n",type:"Number"}],chainable:1},{line:221,params:[{name:"color",description:"",type:"Number[]|String|p5.Color"},{name:"position",description:"",type:"p5.Vector"}],chainable:1},{line:228,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"}],chainable:1}]},{file:"src/webgl/light.js",line:281,description:"Creates a point light with a color and a light position
\nA maximum of 5 pointLight can be active at one time
\n",itemtype:"method",name:"pointLight",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n //move your mouse to change light position\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n // to set the light position,\n // think of the world's coordinate as:\n // -width/2,-height/2 -------- width/2,-height/2\n // | |\n // | 0,0 |\n // | |\n // -width/2,height/2--------width/2,height/2\n pointLight(250, 250, 250, locX, locY, 50);\n noStroke();\n sphere(40);\n}\n
\n"],alt:"spot light on canvas changes position with mouse",class:"p5",module:"Lights, Camera",submodule:"Lights",overloads:[{line:281,params:[{name:"v1",description:"red or hue value (depending on the current\ncolor mode),
\n",type:"Number"},{name:"v2",description:"green or saturation value
\n",type:"Number"},{name:"v3",description:"blue or brightness value
\n",type:"Number"},{name:"x",description:"x axis position
\n",type:"Number"},{name:"y",description:"y axis position
\n",type:"Number"},{name:"z",description:"z axis position
\n",type:"Number"}],chainable:1},{line:324,params:[{name:"v1",description:"",type:"Number"},{name:"v2",description:"",type:"Number"},{name:"v3",description:"",type:"Number"},{name:"position",description:"the position of the light
\n",type:"p5.Vector"}],chainable:1},{line:333,params:[{name:"color",description:'color Array, CSS color string,\nor p5.Color value
\n',type:"Number[]|String|p5.Color"},{name:"x",description:"",type:"Number"},{name:"y",description:"",type:"Number"},{name:"z",description:"",type:"Number"}],chainable:1},{line:343,params:[{name:"color",description:"",type:"Number[]|String|p5.Color"},{name:"position",description:"",type:"p5.Vector"}],chainable:1}]},{file:"src/webgl/light.js",line:389,description:'Sets the default ambient and directional light. The defaults are ambientLight(128, 128, 128) and directionalLight(128, 128, 128, 0, 0, -1). Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop.
\n',itemtype:"method",name:"lights",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n lights();\n rotateX(millis() / 1000);\n rotateY(millis() / 1000);\n rotateZ(millis() / 1000);\n box();\n}\n
\n"],alt:"the light is partially ambient and partially directional",class:"p5",module:"Lights, Camera",submodule:"Lights"},{file:"src/webgl/light.js",line:420,description:"Sets the falloff rates for point lights. It affects only the elements which are created after it in the code.\nThe default value is lightFalloff(1.0, 0.0, 0.0), and the parameters are used to calculate the falloff with the following equation:
\nd = distance from light position to vertex position
\nfalloff = 1 / (CONSTANT + d * LINEAR + ( d * d ) * QUADRATIC)
\n",itemtype:"method",name:"lightFalloff",params:[{name:"constant",description:"constant value for determining falloff
\n",type:"Number"},{name:"linear",description:"linear value for determining falloff
\n",type:"Number"},{name:"quadratic",description:"quadratic value for determining falloff
\n",type:"Number"}],chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n}\nfunction draw() {\n background(0);\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n translate(-25, 0, 0);\n lightFalloff(1, 0, 0);\n pointLight(250, 250, 250, locX, locY, 50);\n sphere(20);\n translate(50, 0, 0);\n lightFalloff(0.9, 0.01, 0);\n pointLight(250, 250, 250, locX, locY, 50);\n sphere(20);\n}\n
\n"],alt:"Two spheres with different falloff values show different intensity of light",class:"p5",module:"Lights, Camera",submodule:"Lights"},{file:"src/webgl/light.js",line:506,description:"Creates a spotlight with a given color, position, direction of light,\nangle and concentration. Here, angle refers to the opening or aperture\nof the cone of the spotlight, and concentration is used to focus the\nlight towards the center. Both angle and concentration are optional, but if\nyou want to provide concentration, you will also have to specify the angle.
\nA maximum of 5 spotLight can be active at one time
\n",itemtype:"method",name:"spotLight",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n //move your mouse to change light position\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n // to set the light position,\n // think of the world's coordinate as:\n // -width/2,-height/2 -------- width/2,-height/2\n // | |\n // | 0,0 |\n // | |\n // -width/2,height/2--------width/2,height/2\n ambientLight(50);\n spotLight(0, 250, 0, locX, locY, 100, 0, 0, -1, Math.PI / 16);\n noStroke();\n sphere(40);\n}\n
\n"],alt:"Spot light on a sphere which changes position with mouse",class:"p5",module:"Lights, Camera",submodule:"Lights",overloads:[{line:506,params:[{name:"v1",description:"red or hue value (depending on the current\ncolor mode),
\n",type:"Number"},{name:"v2",description:"green or saturation value
\n",type:"Number"},{name:"v3",description:"blue or brightness value
\n",type:"Number"},{name:"x",description:"x axis position
\n",type:"Number"},{name:"y",description:"y axis position
\n",type:"Number"},{name:"z",description:"z axis position
\n",type:"Number"},{name:"rx",description:"x axis direction of light
\n",type:"Number"},{name:"ry",description:"y axis direction of light
\n",type:"Number"},{name:"rz",description:"z axis direction of light
\n",type:"Number"},{name:"angle",description:"optional parameter for angle. Defaults to PI/3
\n",type:"Number",optional:!0},{name:"conc",description:"optional parameter for concentration. Defaults to 100
\n",type:"Number",optional:!0}],chainable:1},{line:558,params:[{name:"color",description:'color Array, CSS color string,\nor p5.Color value
\n',type:"Number[]|String|p5.Color"},{name:"position",description:"the position of the light
\n",type:"p5.Vector"},{name:"direction",description:"the direction of the light
\n",type:"p5.Vector"},{name:"angle",description:"",type:"Number",optional:!0},{name:"conc",description:"",type:"Number",optional:!0}]},{line:567,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:!0},{name:"conc",description:"",type:"Number",optional:!0}]},{line:577,params:[{name:"color",description:"",type:"Number[]|String|p5.Color"},{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:!0},{name:"conc",description:"",type:"Number",optional:!0}]},{line:587,params:[{name:"color",description:"",type:"Number[]|String|p5.Color"},{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:!0},{name:"conc",description:"",type:"Number",optional:!0}]},{line:597,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:!0},{name:"conc",description:"",type:"Number",optional:!0}]},{line:609,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:!0},{name:"conc",description:"",type:"Number",optional:!0}]},{line:621,params:[{name:"color",description:"",type:"Number[]|String|p5.Color"},{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:!0},{name:"conc",description:"",type:"Number",optional:!0}]}]},{file:"src/webgl/light.js",line:846,description:"This function will remove all the lights from the sketch for the\nsubsequent materials rendered. It affects all the subsequent methods.\nCalls to lighting methods made after noLights() will re-enable lights\nin the sketch.
\n",itemtype:"method",name:"noLights",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n noStroke();\n\n ambientLight(150, 0, 0);\n translate(-25, 0, 0);\n ambientMaterial(250);\n sphere(20);\n\n noLights();\n ambientLight(0, 150, 0);\n translate(50, 0, 0);\n ambientMaterial(250);\n sphere(20);\n}\n
\n"],alt:"Two spheres showing different colors",class:"p5",module:"Lights, Camera",submodule:"Lights"},{file:"src/webgl/loading.js",line:12,description:'Load a 3d model from an OBJ or STL file.\n
\nloadModel() should be placed inside of preload().\nThis allows the model to load fully before the rest of your code is run.\n
\nOne of the limitations of the OBJ and STL format is that it doesn't have a built-in\nsense of scale. This means that models exported from different programs might\nbe very different sizes. If your model isn't displaying, try calling\nloadModel() with the normalized parameter set to true. This will resize the\nmodel to a scale appropriate for p5. You can also make additional changes to\nthe final size of your model with the scale() function.
\nAlso, the support for colored STL files is not present. STL files with color will be\nrendered without color properties.
\n',itemtype:"method",name:"loadModel",return:{description:'the p5.Geometry object',type:"p5.Geometry"},example:["\n\n\n//draw a spinning octahedron\nlet octahedron;\n\nfunction preload() {\n octahedron = loadModel('assets/octahedron.obj');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n model(octahedron);\n}\n
\n","\n\n\n//draw a spinning teapot\nlet teapot;\n\nfunction preload() {\n // Load model with normalise parameter set to true\n teapot = loadModel('assets/teapot.obj', true);\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n scale(0.4); // Scaled to make model fit into canvas\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n normalMaterial(); // For effect\n model(teapot);\n}\n
\n"],alt:"Vertically rotating 3-d teapot with red, green and blue gradient.",class:"p5",module:"Shape",submodule:"3D Models",overloads:[{line:12,params:[{name:"path",description:"Path of the model to be loaded
\n",type:"String"},{name:"normalize",description:"If true, scale the model to a\n standardized size when loading
\n",type:"Boolean"},{name:"successCallback",description:"Function to be called\n once the model is loaded. Will be passed\n the 3D model object.
\n",type:"function(p5.Geometry)",optional:!0},{name:"failureCallback",description:"called with event error if\n the model fails to load.
\n",type:"Function(Event)",optional:!0}],return:{description:'the p5.Geometry object',type:"p5.Geometry"}},{line:94,params:[{name:"path",description:"",type:"String"},{name:"successCallback",description:"",type:"function(p5.Geometry)",optional:!0},{name:"failureCallback",description:"",type:"Function(Event)",optional:!0}],return:{description:'the p5.Geometry object',type:"p5.Geometry"}}]},{file:"src/webgl/loading.js",line:170,description:"Parse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:
\nv -0.5 -0.5 0.5\nv -0.5 -0.5 -0.5\nv -0.5 0.5 -0.5\nv -0.5 0.5 0.5
\nf 4 3 2 1
\n",class:"p5",module:"Shape",submodule:"3D Models"},{file:"src/webgl/loading.js",line:279,description:"STL files can be of two types, ASCII and Binary,
\nWe need to convert the arrayBuffer to an array of strings,\nto parse it as an ASCII file.
\n",class:"p5",module:"Shape",submodule:"3D Models"},{file:"src/webgl/loading.js",line:306,description:'This function checks if the file is in ASCII format or in Binary format
\nIt is done by searching keyword solid
at the start of the file.
\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
.
\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.
\n',class:"p5",module:"Shape",submodule:"3D Models"},{file:"src/webgl/loading.js",line:333,description:"This function matches the query
at the provided offset
\n",class:"p5",module:"Shape",submodule:"3D Models"},{file:"src/webgl/loading.js",line:345,description:'This function parses the Binary STL files.\nhttps://en.wikipedia.org/wiki/STL_%28file_format%29#Binary_STL
\nCurrently there is no support for the colors provided in STL files.
\n',class:"p5",module:"Shape",submodule:"3D Models"},{file:"src/webgl/loading.js",line:435,description:"ASCII 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
\n",class:"p5",module:"Shape",submodule:"3D Models"},{file:"src/webgl/loading.js",line:579,description:"Render a 3d model to the screen.
\n",itemtype:"method",name:"model",params:[{name:"model",description:"Loaded 3d model to be rendered
\n",type:"p5.Geometry"}],example:["\n\n\n//draw a spinning octahedron\nlet octahedron;\n\nfunction preload() {\n octahedron = loadModel('assets/octahedron.obj');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n model(octahedron);\n}\n
\n"],alt:"Vertically rotating 3-d octahedron.",class:"p5",module:"Shape",submodule:"3D Models"},{file:"src/webgl/material.js",line:12,description:'Loads a custom shader from the provided vertex and fragment\nshader paths. The shader files are loaded asynchronously in the\nbackground, so this method should be used in preload().
\nFor now, there are three main types of shaders. p5 will automatically\nsupply appropriate vertices, normals, colors, and lighting attributes\nif the parameters defined in the shader match the names.
\n',itemtype:"method",name:"loadShader",params:[{name:"vertFilename",description:"path to file containing vertex shader\nsource code
\n",type:"String"},{name:"fragFilename",description:"path to file containing fragment shader\nsource code
\n",type:"String"},{name:"callback",description:"callback to be executed after loadShader\ncompletes. On success, the Shader object is passed as the first argument.
\n",type:"Function",optional:!0},{name:"errorCallback",description:"callback to be executed when an error\noccurs inside loadShader. On error, the error is passed as the first\nargument.
\n",type:"Function",optional:!0}],return:{description:"a shader object created from the provided\nvertex and fragment shader files.",type:"p5.Shader"},example:["\n\n\nlet mandel;\nfunction preload() {\n // load the shader definitions from files\n mandel = loadShader('assets/shader.vert', 'assets/shader.frag');\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n // use the shader\n shader(mandel);\n noStroke();\n mandel.setUniform('p', [-0.74364388703, 0.13182590421]);\n}\n\nfunction draw() {\n mandel.setUniform('r', 1.5 * exp(-6.5 * (1 + sin(millis() / 2000))));\n quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n
\n"],alt:"zooming Mandelbrot set. a colorful, infinitely detailed fractal.",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:111,itemtype:"method",name:"createShader",params:[{name:"vertSrc",description:"source code for the vertex shader
\n",type:"String"},{name:"fragSrc",description:"source code for the fragment shader
\n",type:"String"}],return:{description:"a shader object created from the provided\nvertex and fragment shaders.",type:"p5.Shader"},example:["\n\n\n// the 'varying's are shared between both vertex & fragment shaders\nlet varying = 'precision highp float; varying vec2 vPos;';\n\n// the vertex shader is called for each vertex\nlet vs =\n varying +\n 'attribute vec3 aPosition;' +\n 'void main() { vPos = (gl_Position = vec4(aPosition,1.0)).xy; }';\n\n// the fragment shader is called for each pixel\nlet fs =\n varying +\n 'uniform vec2 p;' +\n 'uniform float r;' +\n 'const int I = 500;' +\n 'void main() {' +\n ' vec2 c = p + vPos * r, z = c;' +\n ' float n = 0.0;' +\n ' for (int i = I; i > 0; i --) {' +\n ' if(z.x*z.x+z.y*z.y > 4.0) {' +\n ' n = float(i)/float(I);' +\n ' break;' +\n ' }' +\n ' z = vec2(z.x*z.x-z.y*z.y, 2.0*z.x*z.y) + c;' +\n ' }' +\n ' gl_FragColor = vec4(0.5-cos(n*17.0)/2.0,0.5-cos(n*13.0)/2.0,0.5-cos(n*23.0)/2.0,1.0);' +\n '}';\n\nlet mandel;\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n // create and initialize the shader\n mandel = createShader(vs, fs);\n shader(mandel);\n noStroke();\n\n // 'p' is the center point of the Mandelbrot image\n mandel.setUniform('p', [-0.74364388703, 0.13182590421]);\n}\n\nfunction draw() {\n // 'r' is the size of the image in Mandelbrot-space\n mandel.setUniform('r', 1.5 * exp(-6.5 * (1 + sin(millis() / 2000))));\n quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n
\n"],alt:"zooming Mandelbrot set. a colorful, infinitely detailed fractal.",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:179,description:'The shader() function lets the user provide a custom shader\nto fill in shapes in WEBGL mode. Users can create their\nown shaders by loading vertex and fragment shaders with\nloadShader().
\n',itemtype:"method",name:"shader",chainable:1,params:[{name:"s",description:'the desired p5.Shader to use for rendering\nshapes.
\n',type:"p5.Shader",optional:!0}],example:["\n\n\n// Click within the image to toggle\n// the shader used by the quad shape\n// Note: for an alternative approach to the same example,\n// involving changing uniforms please refer to:\n// https://p5js.org/reference/#/p5.Shader/setUniform\n\nlet redGreen;\nlet orangeBlue;\nlet showRedGreen = false;\n\nfunction preload() {\n // note that we are using two instances\n // of the same vertex and fragment shaders\n redGreen = loadShader('assets/shader.vert', 'assets/shader-gradient.frag');\n orangeBlue = loadShader('assets/shader.vert', 'assets/shader-gradient.frag');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n // initialize the colors for redGreen shader\n shader(redGreen);\n redGreen.setUniform('colorCenter', [1.0, 0.0, 0.0]);\n redGreen.setUniform('colorBackground', [0.0, 1.0, 0.0]);\n\n // initialize the colors for orangeBlue shader\n shader(orangeBlue);\n orangeBlue.setUniform('colorCenter', [1.0, 0.5, 0.0]);\n orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]);\n\n noStroke();\n}\n\nfunction draw() {\n // update the offset values for each shader,\n // moving orangeBlue in vertical and redGreen\n // in horizontal direction\n orangeBlue.setUniform('offset', [0, sin(millis() / 2000) + 1]);\n redGreen.setUniform('offset', [sin(millis() / 2000), 1]);\n\n if (showRedGreen === true) {\n shader(redGreen);\n } else {\n shader(orangeBlue);\n }\n quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n\nfunction mouseClicked() {\n showRedGreen = !showRedGreen;\n}\n
\n"],alt:"canvas toggles between a circular gradient of orange and blue vertically. and a circular gradient of red and green moving horizontally when mouse is clicked/pressed.",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:270,description:'This function restores the default shaders in WEBGL mode. Code that runs\nafter resetShader() will not be affected by previously defined\nshaders. Should be run after shader().
\n',itemtype:"method",name:"resetShader",chainable:1,class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:283,description:'Normal material for geometry is a material that is not affected by light.\nIt is not reflective and is a placeholder material often used for debugging.\nSurfaces facing the X-axis, become red, those facing the Y-axis, become green and those facing the Z-axis, become blue.\nYou can view all possible materials in this\nexample.
\n',itemtype:"method",name:"normalMaterial",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(200);\n normalMaterial();\n sphere(40);\n}\n
\n"],alt:"Red, green and blue gradient.",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:322,description:'Texture for geometry. You can view other possible materials in this\nexample.
\n',itemtype:"method",name:"texture",params:[{name:"tex",description:"2-dimensional graphics\n to render as texture
\n",type:"p5.Image|p5.MediaElement|p5.Graphics"}],chainable:1,example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(0);\n rotateZ(frameCount * 0.01);\n rotateX(frameCount * 0.01);\n rotateY(frameCount * 0.01);\n //pass image as texture\n texture(img);\n box(200, 200, 200);\n}\n
\n\n\n\n\nlet pg;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n pg = createGraphics(200, 200);\n pg.textSize(75);\n}\n\nfunction draw() {\n background(0);\n pg.background(255);\n pg.text('hello!', 0, 100);\n //pass image as texture\n texture(pg);\n rotateX(0.5);\n noStroke();\n plane(50);\n}\n
\n\n\n\n\nlet vid;\nfunction preload() {\n vid = createVideo('assets/fingers.mov');\n vid.hide();\n}\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(0);\n //pass video frame as texture\n texture(vid);\n rect(-40, -40, 80, 80);\n}\n\nfunction mousePressed() {\n vid.loop();\n}\n
\n"],alt:"Rotating view of many images umbrella and grid roof on a 3d plane\nblack canvas\nblack canvas",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:423,description:"Sets the coordinate space for texture mapping. The default mode is IMAGE\nwhich refers to the actual coordinates of the image.\nNORMAL refers to a normalized space of values ranging from 0 to 1.\nThis function only works in WEBGL mode.
\nWith IMAGE, if an image is 100 x 200 pixels, mapping the image onto the entire\nsize of a quad would require the points (0,0) (100, 0) (100,200) (0,200).\nThe same mapping in NORMAL is (0,0) (1,0) (1,1) (0,1).
\n",itemtype:"method",name:"textureMode",params:[{name:"mode",description:"either IMAGE or NORMAL
\n",type:"Constant"}],example:["\n\n\nlet img;\n\nfunction preload() {\n img = loadImage('assets/laDefense.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n texture(img);\n textureMode(NORMAL);\n beginShape();\n vertex(-50, -50, 0, 0);\n vertex(50, -50, 1, 0);\n vertex(50, 50, 1, 1);\n vertex(-50, 50, 0, 1);\n endShape();\n}\n
\n"],alt:"the underside of a white umbrella and gridded ceiling above",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:502,description:"Sets the global texture wrapping mode. This controls how textures behave\nwhen their uv's go outside of the 0 - 1 range. There are three options:\nCLAMP, REPEAT, and MIRROR.
\nCLAMP causes the pixels at the edge of the texture to extend to the bounds\nREPEAT causes the texture to tile repeatedly until reaching the bounds\nMIRROR works similarly to REPEAT but it flips the texture with every new tile
\nREPEAT & MIRROR are only available if the texture\nis a power of two size (128, 256, 512, 1024, etc.).
\nThis method will affect all textures in your sketch until a subsequent\ntextureWrap call is made.
\nIf only one argument is provided, it will be applied to both the\nhorizontal and vertical axes.
\n",itemtype:"method",name:"textureWrap",params:[{name:"wrapX",description:"either CLAMP, REPEAT, or MIRROR
\n",type:"Constant"},{name:"wrapY",description:"either CLAMP, REPEAT, or MIRROR
\n",type:"Constant",optional:!0}],example:["\n\n\nlet img;\nfunction preload() {\n img = loadImage('assets/rockies128.jpg');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textureWrap(MIRROR);\n}\n\nfunction draw() {\n background(0);\n\n let dX = mouseX;\n let dY = mouseY;\n\n let u = lerp(1.0, 2.0, dX);\n let v = lerp(1.0, 2.0, dY);\n\n scale(width / 2);\n\n texture(img);\n\n beginShape(TRIANGLES);\n vertex(-1, -1, 0, 0, 0);\n vertex(1, -1, 0, u, 0);\n vertex(1, 1, 0, u, v);\n\n vertex(1, 1, 0, u, v);\n vertex(-1, 1, 0, 0, v);\n vertex(-1, -1, 0, 0, 0);\n endShape();\n}\n
\n"],alt:"an image of the rocky mountains repeated in mirrored tiles",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/material.js",line:575,description:'Ambient material for geometry with a given color. Ambient material defines the color the object reflects under any lighting.\nFor example, if the ambient material of an object is pure red, but the ambient lighting only contains green, the object will not reflect any light.\nHere's an example containing all possible materials.
\n',itemtype:"method",name:"ambientMaterial",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n noStroke();\n ambientLight(200);\n ambientMaterial(70, 130, 230);\n sphere(40);\n}\n
\n\n\n\n// ambientLight is both red and blue (magenta),\n// so object only reflects it's red and blue components\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(70);\n ambientLight(100); // white light\n ambientMaterial(255, 0, 255); // pink material\n box(30);\n}\n
\n\n\n\n// ambientLight is green. Since object does not contain\n// green, it does not reflect any light\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(70);\n ambientLight(0, 255, 0); // green light\n ambientMaterial(255, 0, 255); // pink material\n box(30);\n}\n
\n"],alt:"radiating light source from top right of canvas\nbox reflecting only red and blue light\nbox reflecting no light",class:"p5",module:"Lights, Camera",submodule:"Material",overloads:[{line:575,params:[{name:"v1",description:"gray value, red or hue value\n (depending on the current color mode),
\n",type:"Number"},{name:"v2",description:"green or saturation value
\n",type:"Number",optional:!0},{name:"v3",description:"blue or brightness value
\n",type:"Number",optional:!0}],chainable:1},{line:635,params:[{name:"color",description:"color, color Array, or CSS color string
\n",type:"Number[]|String|p5.Color"}],chainable:1}]},{file:"src/webgl/material.js",line:655,description:"Sets the emissive color of the material used for geometry drawn to\nthe screen. This is a misnomer in the sense that the material does not\nactually emit light that effects surrounding polygons. Instead,\nit gives the appearance that the object is glowing. An emissive material\nwill display at full strength even if there is no light for it to reflect.
\n",itemtype:"method",name:"emissiveMaterial",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n noStroke();\n ambientLight(0);\n emissiveMaterial(130, 230, 0);\n sphere(40);\n}\n
\n"],alt:"radiating light source from top right of canvas",class:"p5",module:"Lights, Camera",submodule:"Material",overloads:[{line:655,params:[{name:"v1",description:"gray value, red or hue value\n (depending on the current color mode),
\n",type:"Number"},{name:"v2",description:"green or saturation value
\n",type:"Number",optional:!0},{name:"v3",description:"blue or brightness value
\n",type:"Number",optional:!0},{name:"a",description:"opacity
\n",type:"Number",optional:!0}],chainable:1},{line:687,params:[{name:"color",description:"color, color Array, or CSS color string
\n",type:"Number[]|String|p5.Color"}],chainable:1}]},{file:"src/webgl/material.js",line:707,description:'Specular material for geometry with a given color. Specular material is a shiny reflective material.\nLike ambient material it also defines the color the object reflects under ambient lighting.\nFor example, if the specular material of an object is pure red, but the ambient lighting only contains green, the object will not reflect any light.\nFor all other types of light like point and directional light, a specular material will reflect the color of the light source to the viewer.\nHere's an example containing all possible materials.
\n',itemtype:"method",name:"specularMaterial",chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n ambientLight(50);\n pointLight(250, 250, 250, 100, 100, 30);\n specularMaterial(250);\n sphere(40);\n}\n
\n"],alt:"diffused radiating light source from top right of canvas",class:"p5",module:"Lights, Camera",submodule:"Material",overloads:[{line:707,params:[{name:"v1",description:"gray value, red or hue value\n (depending on the current color mode),
\n",type:"Number"},{name:"v2",description:"green or saturation value
\n",type:"Number",optional:!0},{name:"v3",description:"blue or brightness value
\n",type:"Number",optional:!0}],chainable:1},{line:737,params:[{name:"color",description:"color Array, or CSS color string
\n",type:"Number[]|String|p5.Color"}],chainable:1}]},{file:"src/webgl/material.js",line:757,description:"Sets the amount of gloss in the surface of shapes.\nUsed in combination with specularMaterial() in setting\nthe material properties of shapes. The default and minimum value is 1.
\n",itemtype:"method",name:"shininess",params:[{name:"shine",description:"Degree of Shininess.\n Defaults to 1.
\n",type:"Number"}],chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(0);\n noStroke();\n let locX = mouseX - width / 2;\n let locY = mouseY - height / 2;\n ambientLight(60, 60, 60);\n pointLight(255, 255, 255, locX, locY, 50);\n specularMaterial(250);\n translate(-25, 0, 0);\n shininess(1);\n sphere(20);\n translate(50, 0, 0);\n shininess(20);\n sphere(20);\n}\n
\n"],alt:"Shininess on Camera changes position with mouse",class:"p5",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/p5.Camera.js",line:13,description:'Sets the camera position for a 3D sketch. Parameters for this function define\nthe position for the camera, the center of the sketch (where the camera is\npointing), and an up direction (the orientation of the camera).
\nThis function simulates the movements of the camera, allowing objects to be\nviewed from various angles. Remember, it does not move the objects themselves\nbut the camera instead. For example when centerX value is positive, the camera\nis rotating to the right side of the sketch, so the object would seem like\nmoving to the left.
\nSee this example to view the position of your camera.
\nWhen called with no arguments, this function creates a default camera\nequivalent to\ncamera(0, 0, (height/2.0) / tan(PI*30.0 / 180.0), 0, 0, 0, 0, 1, 0);
\n',itemtype:"method",name:"camera",is_constructor:1,params:[{name:"x",description:"camera position value on x axis
\n",type:"Number",optional:!0},{name:"y",description:"camera position value on y axis
\n",type:"Number",optional:!0},{name:"z",description:"camera position value on z axis
\n",type:"Number",optional:!0},{name:"centerX",description:"x coordinate representing center of the sketch
\n",type:"Number",optional:!0},{name:"centerY",description:"y coordinate representing center of the sketch
\n",type:"Number",optional:!0},{name:"centerZ",description:"z coordinate representing center of the sketch
\n",type:"Number",optional:!0},{name:"upX",description:"x component of direction 'up' from camera
\n",type:"Number",optional:!0},{name:"upY",description:"y component of direction 'up' from camera
\n",type:"Number",optional:!0},{name:"upZ",description:"z component of direction 'up' from camera
\n",type:"Number",optional:!0}],chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\nfunction draw() {\n background(204);\n //move the camera away from the plane by a sin wave\n camera(0, 0, 20 + sin(frameCount * 0.01) * 10, 0, 0, 0, 0, 1, 0);\n plane(10, 10);\n}\n
\n","\n\n\n//move slider to see changes!\n//sliders control the first 6 parameters of camera()\nlet sliderGroup = [];\nlet X;\nlet Y;\nlet Z;\nlet centerX;\nlet centerY;\nlet centerZ;\nlet h = 20;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n //create sliders\n for (var i = 0; i < 6; i++) {\n if (i === 2) {\n sliderGroup[i] = createSlider(10, 400, 200);\n } else {\n sliderGroup[i] = createSlider(-400, 400, 0);\n }\n h = map(i, 0, 6, 5, 85);\n sliderGroup[i].position(10, height + h);\n sliderGroup[i].style('width', '80px');\n }\n}\n\nfunction draw() {\n background(60);\n // assigning sliders' value to each parameters\n X = sliderGroup[0].value();\n Y = sliderGroup[1].value();\n Z = sliderGroup[2].value();\n centerX = sliderGroup[3].value();\n centerY = sliderGroup[4].value();\n centerZ = sliderGroup[5].value();\n camera(X, Y, Z, centerX, centerY, centerZ, 0, 1, 0);\n stroke(255);\n fill(255, 102, 94);\n box(85);\n}\n
\n"],alt:"White square repeatedly grows to fill canvas and then shrinks.",class:"p5",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:113,description:"Sets a perspective projection for the camera in a 3D sketch. This projection\nrepresents depth through foreshortening: objects that are close to the camera\nappear their actual size while those that are further away from the camera\nappear smaller. The parameters to this function define the viewing frustum\n(the truncated pyramid within which objects are seen by the camera) through\nvertical field of view, aspect ratio (usually width/height), and near and far\nclipping planes.
\nWhen called with no arguments, the defaults\nprovided are equivalent to\nperspective(PI/3.0, width/height, eyeZ/10.0, eyeZ10.0), where eyeZ\nis equal to ((height/2.0) / tan(PI60.0/360.0));
\n",itemtype:"method",name:"perspective",params:[{name:"fovy",description:'camera frustum vertical field of view,\n from bottom to top of view, in angleMode units
\n',type:"Number",optional:!0},{name:"aspect",description:"camera frustum aspect ratio
\n",type:"Number",optional:!0},{name:"near",description:"frustum near plane length
\n",type:"Number",optional:!0},{name:"far",description:"frustum far plane length
\n",type:"Number",optional:!0}],chainable:1,example:["\n\n\n//drag the mouse to look around!\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n perspective(PI / 3.0, width / height, 0.1, 500);\n}\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateX(-0.3);\n rotateY(-0.2);\n translate(0, 0, -50);\n\n push();\n translate(-15, 0, sin(frameCount / 30) * 95);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 95);\n box(30);\n pop();\n}\n
\n"],alt:"two colored 3D boxes move back and forth, rotating as mouse is dragged.",class:"p5",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:174,description:"Sets an orthographic projection for the camera in a 3D sketch and defines a\nbox-shaped viewing frustum within which objects are seen. In this projection,\nall objects with the same dimension appear the same size, regardless of\nwhether they are near or far from the camera. The parameters to this\nfunction specify the viewing frustum where left and right are the minimum and\nmaximum x values, top and bottom are the minimum and maximum y values, and near\nand far are the minimum and maximum z values. If no parameters are given, the\ndefault is used: ortho(-width/2, width/2, -height/2, height/2).
\n",itemtype:"method",name:"ortho",params:[{name:"left",description:"camera frustum left plane
\n",type:"Number",optional:!0},{name:"right",description:"camera frustum right plane
\n",type:"Number",optional:!0},{name:"bottom",description:"camera frustum bottom plane
\n",type:"Number",optional:!0},{name:"top",description:"camera frustum top plane
\n",type:"Number",optional:!0},{name:"near",description:"camera frustum near plane
\n",type:"Number",optional:!0},{name:"far",description:"camera frustum far plane
\n",type:"Number",optional:!0}],chainable:1,example:["\n\n\n//drag the mouse to look around!\n//there's no vanishing point\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n ortho(-width / 2, width / 2, height / 2, -height / 2, 0, 500);\n}\nfunction draw() {\n background(200);\n orbitControl();\n normalMaterial();\n\n rotateX(0.2);\n rotateY(-0.2);\n push();\n translate(-15, 0, sin(frameCount / 30) * 65);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 65);\n box(30);\n pop();\n}\n
\n"],alt:"two 3D boxes move back and forth along same plane, rotating as mouse is dragged.",class:"p5",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:231,description:'Sets a perspective matrix as defined by the parameters.
\nA frustum is a geometric form: a pyramid with its top\ncut off. With the viewer's eye at the imaginary top of\nthe pyramid, the six planes of the frustum act as clipping\nplanes when rendering a 3D view. Thus, any form inside the\nclipping planes is visible; anything outside\nthose planes is not visible.
\nSetting the frustum changes the perspective of the scene being rendered.\nThis can be achieved more simply in many cases by using\nperspective().
\n',itemtype:"method",name:"frustum",params:[{name:"left",description:"camera frustum left plane
\n",type:"Number",optional:!0},{name:"right",description:"camera frustum right plane
\n",type:"Number",optional:!0},{name:"bottom",description:"camera frustum bottom plane
\n",type:"Number",optional:!0},{name:"top",description:"camera frustum top plane
\n",type:"Number",optional:!0},{name:"near",description:"camera frustum near plane
\n",type:"Number",optional:!0},{name:"far",description:"camera frustum far plane
\n",type:"Number",optional:!0}],chainable:1,example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n setAttributes('antialias', true);\n frustum(-0.1, 0.1, -0.1, 0.1, 0.1, 200);\n}\nfunction draw() {\n background(200);\n orbitControl();\n strokeWeight(10);\n stroke(0, 0, 255);\n noFill();\n\n rotateY(-0.2);\n rotateX(-0.3);\n push();\n translate(-15, 0, sin(frameCount / 30) * 25);\n box(30);\n pop();\n push();\n translate(15, 0, sin(frameCount / 30 + PI) * 25);\n box(30);\n pop();\n}\n
\n"],alt:"two 3D boxes move back and forth along same plane, rotating as mouse is dragged.",class:"p5",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:298,description:'Creates a new p5.Camera object and tells the\nrenderer to use that camera.\nReturns the p5.Camera object.
\n',itemtype:"method",name:"createCamera",return:{description:"The newly created camera object.",type:"p5.Camera"},class:"p5",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:409,description:'Sets a perspective projection for a p5.Camera object and sets parameters\nfor that projection according to perspective()\nsyntax.
\n',itemtype:"method",name:"perspective",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:489,description:'Sets an orthographic projection for a p5.Camera object and sets parameters\nfor that projection according to ortho() syntax.
\n',itemtype:"method",name:"ortho",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:548,itemtype:"method",name:"frustum",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:653,description:"Panning rotates the camera view to the left and right.
\n",itemtype:"method",name:"pan",params:[{name:"angle",description:'amount to rotate camera in current\nangleMode units.\nGreater than 0 values rotate counterclockwise (to the left).
\n',type:"Number"}],example:["\n\n\nlet cam;\nlet delta = 0.01;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n // set initial pan angle\n cam.pan(-0.8);\n}\n\nfunction draw() {\n background(200);\n\n // pan camera according to angle 'delta'\n cam.pan(delta);\n\n // every 160 frames, switch direction\n if (frameCount % 160 === 0) {\n delta *= -1;\n }\n\n rotateX(frameCount * 0.01);\n translate(-100, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n}\n
\n"],alt:"camera view pans left and right across a series of rotating 3D boxes.",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:712,description:"Tilting rotates the camera view up and down.
\n",itemtype:"method",name:"tilt",params:[{name:"angle",description:'amount to rotate camera in current\nangleMode units.\nGreater than 0 values rotate counterclockwise (to the left).
\n',type:"Number"}],example:["\n\n\nlet cam;\nlet delta = 0.01;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n // set initial tilt\n cam.tilt(-0.8);\n}\n\nfunction draw() {\n background(200);\n\n // pan camera according to angle 'delta'\n cam.tilt(delta);\n\n // every 160 frames, switch direction\n if (frameCount % 160 === 0) {\n delta *= -1;\n }\n\n rotateY(frameCount * 0.01);\n translate(0, -100, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n translate(0, 35, 0);\n box(20);\n}\n
\n"],alt:"camera view tilts up and down across a series of rotating 3D boxes.",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:770,description:"Reorients the camera to look at a position in world space.
\n",itemtype:"method",name:"lookAt",params:[{name:"x",description:"x position of a point in world space
\n",type:"Number"},{name:"y",description:"y position of a point in world space
\n",type:"Number"},{name:"z",description:"z position of a point in world space
\n",type:"Number"}],example:["\n\n\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n}\n\nfunction draw() {\n background(200);\n\n // look at a new random point every 60 frames\n if (frameCount % 60 === 0) {\n cam.lookAt(random(-100, 100), random(-50, 50), 0);\n }\n\n rotateX(frameCount * 0.01);\n translate(-100, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n}\n
\n"],alt:"camera view of rotating 3D cubes changes to look at a new random\npoint every second .",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:837,description:'Sets a camera's position and orientation. This is equivalent to calling\ncamera() on a p5.Camera object.
\n',itemtype:"method",name:"camera",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:918,description:"Move camera along its local axes while maintaining current camera orientation.
\n",itemtype:"method",name:"move",params:[{name:"x",description:"amount to move along camera's left-right axis
\n",type:"Number"},{name:"y",description:"amount to move along camera's up-down axis
\n",type:"Number"},{name:"z",description:"amount to move along camera's forward-backward axis
\n",type:"Number"}],example:["\n\n\n// see the camera move along its own axes while maintaining its orientation\nlet cam;\nlet delta = 0.5;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n}\n\nfunction draw() {\n background(200);\n\n // move the camera along its local axes\n cam.move(delta, delta, 0);\n\n // every 100 frames, switch direction\n if (frameCount % 150 === 0) {\n delta *= -1;\n }\n\n translate(-10, -10, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n translate(15, 15, 0);\n box(50, 8, 50);\n}\n
\n"],alt:"camera view moves along a series of 3D boxes, maintaining the same\norientation throughout the move",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:990,description:"Set camera position in world-space while maintaining current camera\norientation.
\n",itemtype:"method",name:"setPosition",params:[{name:"x",description:"x position of a point in world space
\n",type:"Number"},{name:"y",description:"y position of a point in world space
\n",type:"Number"},{name:"z",description:"z position of a point in world space
\n",type:"Number"}],example:["\n\n\n// press '1' '2' or '3' keys to set camera position\n\nlet cam;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n cam = createCamera();\n}\n\nfunction draw() {\n background(200);\n\n // '1' key\n if (keyIsDown(49)) {\n cam.setPosition(30, 0, 80);\n }\n // '2' key\n if (keyIsDown(50)) {\n cam.setPosition(0, 0, 80);\n }\n // '3' key\n if (keyIsDown(51)) {\n cam.setPosition(-30, 0, 80);\n }\n\n box(20);\n}\n
\n"],alt:"camera position changes as the user presses keys, altering view of a 3D box",class:"p5.Camera",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Camera.js",line:1255,description:"Sets rendererGL's current camera to a p5.Camera object. Allows switching\nbetween multiple cameras.
\n",itemtype:"method",name:"setCamera",params:[{name:"cam",description:"p5.Camera object
\n",type:"p5.Camera"}],example:["\n\n\nlet cam1, cam2;\nlet currentCamera;\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n normalMaterial();\n\n cam1 = createCamera();\n cam2 = createCamera();\n cam2.setPosition(30, 0, 50);\n cam2.lookAt(0, 0, 0);\n cam2.ortho();\n\n // set variable for previously active camera:\n currentCamera = 1;\n}\n\nfunction draw() {\n background(200);\n\n // camera 1:\n cam1.lookAt(0, 0, 0);\n cam1.setPosition(sin(frameCount / 60) * 200, 0, 100);\n\n // every 100 frames, switch between the two cameras\n if (frameCount % 100 === 0) {\n if (currentCamera === 1) {\n setCamera(cam1);\n currentCamera = 0;\n } else {\n setCamera(cam2);\n currentCamera = 1;\n }\n }\n\n drawBoxes();\n}\n\nfunction drawBoxes() {\n rotateX(frameCount * 0.01);\n translate(-100, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n translate(35, 0, 0);\n box(20);\n}\n
\n"],alt:"Canvas switches between two camera views, each showing a series of spinning\n3D boxes.",class:"p5",module:"Lights, Camera",submodule:"Camera"},{file:"src/webgl/p5.Geometry.js",line:72,itemtype:"method",name:"computeFaces",chainable:1,class:"p5.Geometry",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/p5.Geometry.js",line:114,description:"computes smooth normals per vertex as an average of each\nface.
\n",itemtype:"method",name:"computeNormals",chainable:1,class:"p5.Geometry",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/p5.Geometry.js",line:153,description:"Averages the vertex normals. Used in curved\nsurfaces
\n",itemtype:"method",name:"averageNormals",chainable:1,class:"p5.Geometry",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/p5.Geometry.js",line:174,description:"Averages pole normals. Used in spherical primitives
\n",itemtype:"method",name:"averagePoleNormals",chainable:1,class:"p5.Geometry",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/p5.Geometry.js",line:267,description:"Modifies all vertices to be centered within the range -100 to 100.
\n",itemtype:"method",name:"normalize",chainable:1,class:"p5.Geometry",module:"Lights, Camera",submodule:"Material"},{file:"src/webgl/p5.RendererGL.js",line:331,description:"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.\n
\nNote that this will reinitialize the drawing context\nif called after the WebGL canvas is made.\n
\nIf an object is passed as the parameter, all attributes\nnot declared in the object will be set to defaults.\n
\nThe available attributes are:\n
\nalpha - indicates if the canvas contains an alpha buffer\ndefault is true\n
\ndepth - indicates whether the drawing buffer has a depth buffer\nof at least 16 bits - default is true\n
\nstencil - indicates whether the drawing buffer has a stencil buffer\nof at least 8 bits\n
\nantialias - indicates whether or not to perform anti-aliasing\ndefault is false (true in Safari)\n
\npremultipliedAlpha - indicates that the page compositor will assume\nthe drawing buffer contains colors with pre-multiplied alpha\ndefault is false\n
\npreserveDrawingBuffer - if true the buffers will not be cleared and\nand will preserve their values until cleared or overwritten by author\n(note that p5 clears automatically on draw loop)\ndefault is true\n
\nperPixelLighting - if true, per-pixel lighting will be used in the\nlighting shader otherwise per-vertex lighting is used.\ndefault is true.\n
\n",itemtype:"method",name:"setAttributes",example:["\n\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(255);\n push();\n rotateZ(frameCount * 0.02);\n rotateX(frameCount * 0.02);\n rotateY(frameCount * 0.02);\n fill(0, 0, 0);\n box(50);\n pop();\n}\n
\n\n
\nNow with the antialias attribute set to true.\n
\n\n\nfunction setup() {\n setAttributes('antialias', true);\n createCanvas(100, 100, WEBGL);\n}\n\nfunction draw() {\n background(255);\n push();\n rotateZ(frameCount * 0.02);\n rotateX(frameCount * 0.02);\n rotateY(frameCount * 0.02);\n fill(0, 0, 0);\n box(50);\n pop();\n}\n
\n\n\n\n\n// press the mouse button to disable perPixelLighting\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n noStroke();\n fill(255);\n}\n\nlet lights = [\n { c: '#f00', t: 1.12, p: 1.91, r: 0.2 },\n { c: '#0f0', t: 1.21, p: 1.31, r: 0.2 },\n { c: '#00f', t: 1.37, p: 1.57, r: 0.2 },\n { c: '#ff0', t: 1.12, p: 1.91, r: 0.7 },\n { c: '#0ff', t: 1.21, p: 1.31, r: 0.7 },\n { c: '#f0f', t: 1.37, p: 1.57, r: 0.7 }\n];\n\nfunction draw() {\n let t = millis() / 1000 + 1000;\n background(0);\n directionalLight(color('#222'), 1, 1, 1);\n\n for (let i = 0; i < lights.length; i++) {\n let light = lights[i];\n pointLight(\n color(light.c),\n p5.Vector.fromAngles(t * light.t, t * light.p, width * light.r)\n );\n }\n\n specularMaterial(255);\n sphere(width * 0.1);\n\n rotateX(t * 0.77);\n rotateY(t * 0.83);\n rotateZ(t * 0.91);\n torus(width * 0.3, width * 0.07, 24, 10);\n}\n\nfunction mousePressed() {\n setAttributes('perPixelLighting', false);\n noStroke();\n fill(255);\n}\nfunction mouseReleased() {\n setAttributes('perPixelLighting', true);\n noStroke();\n fill(255);\n}\n
\n"],alt:"a rotating cube with smoother edges",class:"p5",module:"Rendering",submodule:"Rendering",overloads:[{line:331,params:[{name:"key",description:"Name of attribute
\n",type:"String"},{name:"value",description:"New value of named attribute
\n",type:"Boolean"}]},{line:470,params:[{name:"obj",description:"object with key-value pairs
\n",type:"Object"}]}]},{file:"src/webgl/p5.Shader.js",line:293,description:"Wrapper around gl.uniform functions.\nAs we store uniform info in the shader we can use that\nto do type checking on the supplied data and call\nthe appropriate function.
\n",itemtype:"method",name:"setUniform",chainable:1,params:[{name:"uniformName",description:"the name of the uniform in the\nshader program
\n",type:"String"},{name:"data",description:"the data to be associated\nwith that uniform; type varies (could be a single numerical value, array,\nmatrix, or texture / sampler reference)
\n",type:"Object|Number|Boolean|Number[]"}],example:["\n\n\n// Click within the image to toggle the value of uniforms\n// Note: for an alternative approach to the same example,\n// involving toggling between shaders please refer to:\n// https://p5js.org/reference/#/p5/shader\n\nlet grad;\nlet showRedGreen = false;\n\nfunction preload() {\n // note that we are using two instances\n // of the same vertex and fragment shaders\n grad = loadShader('assets/shader.vert', 'assets/shader-gradient.frag');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n shader(grad);\n noStroke();\n}\n\nfunction draw() {\n // update the offset values for each scenario,\n // moving the \"grad\" shader in either vertical or\n // horizontal direction each with differing colors\n\n if (showRedGreen === true) {\n grad.setUniform('colorCenter', [1, 0, 0]);\n grad.setUniform('colorBackground', [0, 1, 0]);\n grad.setUniform('offset', [sin(millis() / 2000), 1]);\n } else {\n grad.setUniform('colorCenter', [1, 0.5, 0]);\n grad.setUniform('colorBackground', [0.226, 0, 0.615]);\n grad.setUniform('offset', [0, sin(millis() / 2000) + 1]);\n }\n quad(-1, -1, 1, -1, 1, 1, -1, 1);\n}\n\nfunction mouseClicked() {\n showRedGreen = !showRedGreen;\n}\n
\n"],alt:"canvas toggles between a circular gradient of orange and blue vertically. and a circular gradient of red and green moving horizontally when mouse is clicked/pressed.",class:"p5.Shader",module:"Lights, Camera",submodule:"Material"},{file:"lib/addons/p5.sound.js",line:1,class:"p5.sound",module:"Lights, Camera"},{file:"lib/addons/p5.sound.js",line:52,description:'p5.sound \nhttps://p5js.org/reference/#/libraries/p5.sound
\nFrom the Processing Foundation and contributors\nhttps://github.com/processing/p5.js-sound/graphs/contributors
\nMIT License (MIT)\nhttps://github.com/processing/p5.js-sound/blob/master/LICENSE
\nSome of the many audio libraries & resources that inspire p5.sound:
\n\nTONE.js (c) Yotam Mann. Licensed under The MIT License (MIT). https://github.com/TONEnoTONE/Tone.js
\n \nbuzz.js (c) Jay Salvat. Licensed under The MIT License (MIT). http://buzz.jaysalvat.com/
\n \nBoris Smus Web Audio API book, 2013. Licensed under the Apache License http://www.apache.org/licenses/LICENSE-2.0
\n \nwavesurfer.js https://github.com/katspaugh/wavesurfer.js
\n \nWeb Audio Components by Jordan Santell https://github.com/web-audio-components
\n \nWilm Thoben's Sound library for Processing https://github.com/processing/processing/tree/master/java/libraries/sound
\nWeb Audio API: http://w3.org/TR/webaudio/
\n \n
\n',class:"p5.sound",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:166,description:"Returns a number representing the master amplitude (volume) for sound\nin this sketch.
\n",itemtype:"method",name:"getMasterVolume",return:{description:"Master amplitude (volume) for sound in this sketch.\n Should be between 0.0 (silence) and 1.0.",type:"Number"},class:"p5.sound",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:178,description:"Scale the output of all sound in this sketch
\nScaled between 0.0 (silence) and 1.0 (full volume).\n1.0 is the maximum amplitude of a digital sound, so multiplying\nby greater than 1.0 may cause digital distortion. To\nfade, provide a rampTime
parameter. For more\ncomplex fades, see the Envelope class.\n\nAlternately, you can pass in a signal source such as an\noscillator to modulate the amplitude with an audio signal.
\nHow This Works: When you load the p5.sound module, it\ncreates a single instance of p5sound. All sound objects in this\nmodule output to p5sound before reaching your computer's output.\nSo if you change the amplitude of p5sound, it impacts all of the\nsound in this module.
\n\nIf no value is provided, returns a Web Audio API Gain Node
",itemtype:"method",name:"masterVolume",params:[{name:"volume",description:"Volume (amplitude) between 0.0\n and 1.0 or modulating signal/oscillator
\n",type:"Number|Object"},{name:"rampTime",description:"Fade for t seconds
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"Schedule this event to happen at\n t seconds in the future
\n",type:"Number",optional:!0}],class:"p5.sound",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:221,description:"p5.soundOut
is the p5.sound master output. It sends output to\nthe destination of this window's web audio context. It contains\nWeb Audio API nodes including a dyanmicsCompressor (.limiter
),\nand Gain Nodes for .input
and .output
.
\n",itemtype:"property",name:"soundOut",type:"Object",class:"p5.sound",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:300,description:"In classes that extend\np5.Effect, connect effect nodes\nto the wet parameter
\n",class:"p5.Effect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:316,description:"Set the output volume of the filter.
\n",itemtype:"method",name:"amp",params:[{name:"vol",description:"amplitude between 0 and 1.0
\n",type:"Number",optional:!0},{name:"rampTime",description:"create a fade that lasts until rampTime
\n",type:"Number",optional:!0},{name:"tFromNow",description:"schedule this event to happen in tFromNow seconds
\n",type:"Number",optional:!0}],class:"p5.Effect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:336,description:"Link effects together in a chain\nExample usage: filter.chain(reverb, delay, panner);\nMay be used with an open-ended number of arguments
\n",itemtype:"method",name:"chain",params:[{name:"arguments",description:"Chain together multiple sound objects
\n",type:"Object",optional:!0}],class:"p5.Effect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:358,description:"Adjust the dry/wet value.
\n",itemtype:"method",name:"drywet",params:[{name:"fade",description:"The desired drywet value (0 - 1.0)
\n",type:"Number",optional:!0}],class:"p5.Effect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:374,description:"Send output to a p5.js-sound, Web Audio Node, or use signal to\ncontrol an AudioParam
\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:388,description:"Disconnect all output.
\n",itemtype:"method",name:"disconnect",class:"p5.Effect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:451,class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:455,description:"Returns a number representing the sample rate, in samples per second,\nof all sound objects in this audio context. It is determined by the\nsampling rate of your operating system's sound card, and it is not\ncurrently possile to change.\nIt is often 44100, or twice the range of human hearing.
\n",itemtype:"method",name:"sampleRate",return:{description:"samplerate samples per second",type:"Number"},class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:470,description:"Returns the closest MIDI note value for\na given frequency.
\n",itemtype:"method",name:"freqToMidi",params:[{name:"frequency",description:"A freqeuncy, for example, the "A"\n above Middle C is 440Hz
\n",type:"Number"}],return:{description:"MIDI note value",type:"Number"},class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:486,description:"Returns the frequency value of a MIDI note value.\nGeneral MIDI treats notes as integers where middle C\nis 60, C# is 61, D is 62 etc. Useful for generating\nmusical frequencies with oscillators.
\n",itemtype:"method",name:"midiToFreq",params:[{name:"midiNote",description:"The number of a MIDI note
\n",type:"Number"}],return:{description:"Frequency value of the given MIDI note",type:"Number"},example:["\n\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
"],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:570,description:'List the SoundFile formats that you will include. LoadSound\nwill search your directory for these extensions, and will pick\na format that is compatable with the client's web browser.\nHere is a free online file\nconverter.
\n',itemtype:"method",name:"soundFormats",params:[{name:"formats",description:"i.e. 'mp3', 'wav', 'ogg'
\n",type:"String",optional:!0,multiple:!0}],example:["\n\nfunction preload() {\n // set the global sound formats\n soundFormats('mp3', 'ogg');\n\n // load either beatbox.mp3, or .ogg, depending on browser\n mySound = loadSound('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
"],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:688,description:"Used by Osc and Envelope to chain signal math
\n",class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:967,description:'The p5.Filter is built with a\n\nWeb Audio BiquadFilter Node.
\n',itemtype:"property",name:"biquadFilter",type:"DelayNode",class:"p5.Filter",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:989,description:"Filter an audio signal according to a set\nof filter parameters.
\n",itemtype:"method",name:"process",params:[{name:"Signal",description:"An object that outputs audio
\n",type:"Object"},{name:"freq",description:"Frequency in Hz, from 10 to 22050
\n",type:"Number",optional:!0},{name:"res",description:"Resonance/Width of the filter frequency\n from 0.001 to 1000
\n",type:"Number",optional:!0}],class:"p5.Filter",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1004,description:"Set the frequency and the resonance of the filter.
\n",itemtype:"method",name:"set",params:[{name:"freq",description:"Frequency in Hz, from 10 to 22050
\n",type:"Number",optional:!0},{name:"res",description:"Resonance (Q) from 0.001 to 1000
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],class:"p5.Filter",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1024,description:"Set the filter frequency, in Hz, from 10 to 22050 (the range of\nhuman hearing, although in reality most people hear in a narrower\nrange).
\n",itemtype:"method",name:"freq",params:[{name:"freq",description:"Filter Frequency
\n",type:"Number"},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],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:1053,description:"Controls either width of a bandpass frequency,\nor the resonance of a low/highpass cutoff frequency.
\n",itemtype:"method",name:"res",params:[{name:"res",description:"Resonance/Width of filter freq\n from 0.001 to 1000
\n",type:"Number"},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],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:1079,description:"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.
\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:1104,description:"Toggle function. Switches between the specified type and allpass
\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:1123,description:"Set the type of a p5.Filter. Possible types include:\n"lowpass" (default), "highpass", "bandpass",\n"lowshelf", "highshelf", "peaking", "notch",\n"allpass".
\n",itemtype:"method",name:"setType",params:[{name:"t",description:"",type:"String"}],class:"p5.Filter",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1218,description:"Returns the Audio Context for this sketch. Useful for users\nwho would like to dig deeper into the Web Audio API\n.
\n\nSome browsers require users to startAudioContext\nwith a user gesture, such as touchStarted in the example below.
",itemtype:"method",name:"getAudioContext",return:{description:"AudioContext for this sketch",type:"Object"},example:["\n\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
"],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1257,description:'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\nGoogle Chrome, which create the Web Audio API\'s\nAudio Context\nin a suspended state.
\n\nIn these browser-specific policies, sound will not play until a user\ninteraction event (i.e. mousePressed()
) explicitly resumes\nthe AudioContext, or starts an audio node. This can be accomplished by\ncalling start()
on a p5.Oscillator
,\n play()
on a p5.SoundFile
, or simply\nuserStartAudio()
.
\n\nuserStartAudio()
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 mousePressed()
as in the\nexample below. This method utilizes\nStartAudioContext\n, a library by Yotam Mann (MIT Licence, 2016).
',params:[{name:"element(s)",description:"This argument can be an Element,\n Selector String, NodeList, p5.Element,\n jQuery Element, or an Array of any of those.
\n",type:"Element|Array",optional:!0},{name:"callback",description:"Callback to invoke when the AudioContext\n has started
\n",type:"Function",optional:!0}],return:{description:"Returns a Promise that resolves when\n the AudioContext state is 'running'",type:"Promise"},itemtype:"method",name:"userStartAudio",example:["\n\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
"],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1477,description:"Start an oscillator.
\nStarting 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: userStartAudio()
.
\n",itemtype:"method",name:"start",params:[{name:"time",description:"startTime in seconds from now.
\n",type:"Number",optional:!0},{name:"frequency",description:"frequency in Hz.
\n",type:"Number",optional:!0}],class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1525,description:"Stop an oscillator. Accepts an optional parameter\nto determine how long (in seconds from now) until the\noscillator stops.
\n",itemtype:"method",name:"stop",params:[{name:"secondsFromNow",description:"Time, in seconds from now.
\n",type:"Number"}],class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1544,description:"Set the amplitude between 0 and 1.0. Or, pass in an object\nsuch as an oscillator to modulate amplitude with an audio signal.
\n",itemtype:"method",name:"amp",params:[{name:"vol",description:"between 0 and 1.0\n or a modulating signal/oscillator
\n",type:"Number|Object"},{name:"rampTime",description:"create a fade that lasts rampTime
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],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:1584,description:"Set frequency of an oscillator to a value. Or, pass in an object\nsuch as an oscillator to modulate the frequency with an audio signal.
\n",itemtype:"method",name:"freq",params:[{name:"Frequency",description:"Frequency in Hz\n or modulating signal/oscillator
\n",type:"Number|Object"},{name:"rampTime",description:"Ramp time (in seconds)
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"Schedule this event to happen\n at x seconds from now
\n",type:"Number",optional:!0}],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\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
"],class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1662,description:"Set type to 'sine', 'triangle', 'sawtooth' or 'square'.
\n",itemtype:"method",name:"setType",params:[{name:"type",description:"'sine', 'triangle', 'sawtooth' or 'square'.
\n",type:"String"}],class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1678,description:"Connect to a p5.sound / Web Audio object.
\n",itemtype:"method",name:"connect",params:[{name:"unit",description:"A p5.sound or Web Audio object
\n",type:"Object"}],class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1698,description:"Disconnect all outputs
\n",itemtype:"method",name:"disconnect",class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1721,description:"Pan between Left (-1) and Right (1)
\n",itemtype:"method",name:"pan",params:[{name:"panning",description:"Number between -1 and 1
\n",type:"Number"},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number"}],class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1759,description:"Set the phase of an oscillator between 0.0 and 1.0.\nIn this implementation, phase is a delay time\nbased on the oscillator's current frequency.
\n",itemtype:"method",name:"phase",params:[{name:"phase",description:"float between 0.0 and 1.0
\n",type:"Number"}],class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1818,description:"Add a value to the p5.Oscillator's output amplitude,\nand return the oscillator. Calling this method again\nwill override the initial add() with a new value.
\n",itemtype:"method",name:"add",params:[{name:"number",description:"Constant number to add
\n",type:"Number"}],return:{description:"Oscillator Returns this oscillator\n with scaled output",type:"p5.Oscillator"},class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1838,description:"Multiply the p5.Oscillator's output amplitude\nby a fixed value (i.e. turn it up!). Calling this method\nagain will override the initial mult() with a new value.
\n",itemtype:"method",name:"mult",params:[{name:"number",description:"Constant number to multiply
\n",type:"Number"}],return:{description:"Oscillator Returns this oscillator\n with multiplied output",type:"p5.Oscillator"},class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:1857,description:"Scale this oscillator's amplitude values to a given\nrange, and return the oscillator. Calling this method\nagain will override the initial scale() with new values.
\n",itemtype:"method",name:"scale",params:[{name:"inMin",description:"input range minumum
\n",type:"Number"},{name:"inMax",description:"input range maximum
\n",type:"Number"},{name:"outMin",description:"input range minumum
\n",type:"Number"},{name:"outMax",description:"input range maximum
\n",type:"Number"}],return:{description:"Oscillator Returns this oscillator\n with scaled output",type:"p5.Oscillator"},class:"p5.Oscillator",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2067,description:"Play tells the MonoSynth to start playing a note. This method schedules\nthe calling of .triggerAttack and .triggerRelease.
\n",itemtype:"method",name:"play",params:[{name:"note",description:'the note you want to play, specified as a\n frequency in Hertz (Number) or as a midi\n value in Note/Octave format ("C4", "Eb3"...etc")\n See \n Tone. Defaults to 440 hz.
\n',type:"String | Number"},{name:"velocity",description:"velocity of the note to play (ranging from 0 to 1)
\n",type:"Number",optional:!0},{name:"secondsFromNow",description:"time from now (in seconds) at which to play
\n",type:"Number",optional:!0},{name:"sustainTime",description:"time to sustain before releasing the envelope. Defaults to 0.15 seconds.
\n",type:"Number",optional:!0}],example:["\n\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
\n"],class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2116,description:"Trigger the Attack, and Decay portion of the Envelope.\nSimilar to holding down a key on a piano, but it will\nhold the sustain level until you let go.
\n",params:[{name:"note",description:'the note you want to play, specified as a\n frequency in Hertz (Number) or as a midi\n value in Note/Octave format ("C4", "Eb3"...etc")\n See \n Tone. Defaults to 440 hz
\n',type:"String | Number"},{name:"velocity",description:"velocity of the note to play (ranging from 0 to 1)
\n",type:"Number",optional:!0},{name:"secondsFromNow",description:"time from now (in seconds) at which to play
\n",type:"Number",optional:!0}],itemtype:"method",name:"triggerAttack",example:["\n\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
"],class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2162,description:"Trigger the release of the Envelope. This is similar to releasing\nthe key on a piano and letting the sound fade according to the\nrelease level and release time.
\n",params:[{name:"secondsFromNow",description:"time to trigger the release
\n",type:"Number"}],itemtype:"method",name:"triggerRelease",example:["\n\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
"],class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2199,description:'Set values like a traditional\n\nADSR envelope\n.
\n',itemtype:"method",name:"setADSR",params:[{name:"attackTime",description:"Time (in seconds before envelope\n reaches Attack Level
\n",type:"Number"},{name:"decayTime",description:"Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n",type:"Number",optional:!0},{name:"susRatio",description:"Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
\n",type:"Number",optional:!0},{name:"releaseTime",description:"Time in seconds from now (defaults to 0)
\n",type:"Number",optional:!0}],class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2226,description:"Getters and Setters
\n",itemtype:"property",name:"attack",type:"Number",class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2232,itemtype:"property",name:"decay",type:"Number",class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2237,itemtype:"property",name:"sustain",type:"Number",class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2242,itemtype:"property",name:"release",type:"Number",class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2282,description:"MonoSynth amp
\n",itemtype:"method",name:"amp",params:[{name:"vol",description:"desired volume
\n",type:"Number"},{name:"rampTime",description:"Time to reach new volume
\n",type:"Number",optional:!0}],return:{description:"new volume value",type:"Number"},class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2300,description:"Connect to a p5.sound / Web Audio object.
\n",itemtype:"method",name:"connect",params:[{name:"unit",description:"A p5.sound or Web Audio object
\n",type:"Object"}],class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2313,description:"Disconnect all outputs
\n",itemtype:"method",name:"disconnect",class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2326,description:"Get rid of the MonoSynth and free up its resources / memory.
\n",itemtype:"method",name:"dispose",class:"p5.MonoSynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2380,description:"Connect to p5 objects or Web Audio Nodes
\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:2392,description:"Disconnect from soundOut
\n",itemtype:"method",name:"disconnect",class:"p5.AudioVoice",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2474,description:"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.
\n",itemtype:"property",name:"notes",class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2487,description:"A PolySynth must have at least 1 voice, defaults to 8
\n",itemtype:"property",name:"polyvalue",class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2493,description:"Monosynth that generates the sound for each note that is triggered. The\np5.PolySynth defaults to using the p5.MonoSynth as its voice.
\n",itemtype:"property",name:"AudioVoice",class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2530,description:"Play a note by triggering noteAttack and noteRelease with sustain time
\n",itemtype:"method",name:"play",params:[{name:"note",description:"midi note to play (ranging from 0 to 127 - 60 being a middle C)
\n",type:"Number",optional:!0},{name:"velocity",description:"velocity of the note to play (ranging from 0 to 1)
\n",type:"Number",optional:!0},{name:"secondsFromNow",description:"time from now (in seconds) at which to play
\n",type:"Number",optional:!0},{name:"sustainTime",description:"time to sustain before releasing the envelope
\n",type:"Number",optional:!0}],example:["\n\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
"],class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2578,description:"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.
\n",itemtype:"method",name:"noteADSR",params:[{name:"note",description:"Midi note on which ADSR should be set.
\n",type:"Number",optional:!0},{name:"attackTime",description:"Time (in seconds before envelope\n reaches Attack Level
\n",type:"Number",optional:!0},{name:"decayTime",description:"Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n",type:"Number",optional:!0},{name:"susRatio",description:"Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
\n",type:"Number",optional:!0},{name:"releaseTime",description:"Time in seconds from now (defaults to 0)
\n",type:"Number",optional:!0}],class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2609,description:"Set the PolySynths global envelope. This method modifies the envelopes of each\nmonosynth so that all notes are played with this envelope.
\n",itemtype:"method",name:"setADSR",params:[{name:"attackTime",description:"Time (in seconds before envelope\n reaches Attack Level
\n",type:"Number",optional:!0},{name:"decayTime",description:"Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n",type:"Number",optional:!0},{name:"susRatio",description:"Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
\n",type:"Number",optional:!0},{name:"releaseTime",description:"Time in seconds from now (defaults to 0)
\n",type:"Number",optional:!0}],class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2636,description:"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.
\n",itemtype:"method",name:"noteAttack",params:[{name:"note",description:"midi note on which attack should be triggered.
\n",type:"Number",optional:!0},{name:"velocity",description:"velocity of the note to play (ranging from 0 to 1)/
\n",type:"Number",optional:!0},{name:"secondsFromNow",description:"time from now (in seconds)
\n",type:"Number",optional:!0}],example:["\n\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
"],class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2746,description:"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.
\n",itemtype:"method",name:"noteRelease",params:[{name:"note",description:"midi note on which attack should be triggered.\n If no value is provided, all notes will be released.
\n",type:"Number",optional:!0},{name:"secondsFromNow",description:"time to trigger the release
\n",type:"Number",optional:!0}],example:["\n\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
\n"],class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2829,description:"Connect to a p5.sound / Web Audio object.
\n",itemtype:"method",name:"connect",params:[{name:"unit",description:"A p5.sound or Web Audio object
\n",type:"Object"}],class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2842,description:"Disconnect all outputs
\n",itemtype:"method",name:"disconnect",class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2855,description:"Get rid of the MonoSynth and free up its resources / memory.
\n",itemtype:"method",name:"dispose",class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:2969,description:"This module has shims
\n",class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3105,description:"Determine which filetypes are supported (inspired by buzz.js)\nThe audio element (el) will only be used to test browser support for various audio formats
\n",class:"p5.PolySynth",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3492,description:'loadSound() returns a new p5.SoundFile from a specified\npath. If called during preload(), the p5.SoundFile will be ready\nto play in time for setup() and draw(). If called outside of\npreload, the p5.SoundFile will not be ready immediately, so\nloadSound accepts a callback as the second parameter. Using a\n\nlocal server is recommended when loading external files.
\n',itemtype:"method",name:"loadSound",params:[{name:"path",description:"Path to the sound file, or an array with\n paths to soundfiles in multiple formats\n i.e. ['sound.ogg', 'sound.mp3'].\n Alternately, accepts an object: either\n from the HTML5 File API, or a p5.File.
\n",type:"String|Array"},{name:"successCallback",description:"Name of a function to call once file loads
\n",type:"Function",optional:!0},{name:"errorCallback",description:"Name of a function to call if there is\n an error loading the file.
\n",type:"Function",optional:!0},{name:"whileLoading",description:"Name of a function to call while file is loading.\n This function will receive the percentage loaded\n so far, from 0.0 to 1.0.
\n",type:"Function",optional:!0}],return:{description:"Returns a p5.SoundFile",type:"SoundFile"},example:["\n\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
"],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3672,description:"Returns true if the sound file finished loading successfully.
\n",itemtype:"method",name:"isLoaded",return:{description:"",type:"Boolean"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3688,description:"Play the p5.SoundFile
\n",itemtype:"method",name:"play",params:[{name:"startTime",description:"(optional) schedule playback to start (in seconds from now).
\n",type:"Number",optional:!0},{name:"rate",description:"(optional) playback rate
\n",type:"Number",optional:!0},{name:"amp",description:"(optional) amplitude (volume)\n of playback
\n",type:"Number",optional:!0},{name:"cueStart",description:"(optional) cue start time in seconds
\n",type:"Number",optional:!0},{name:"duration",description:"(optional) duration of playback in seconds
\n",type:"Number",optional:!0}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3795,description:"p5.SoundFile has two play modes: restart
and\nsustain
. Play Mode determines what happens to a\np5.SoundFile if it is triggered while in the middle of playback.\nIn sustain mode, playback will continue simultaneous to the\nnew playback. In restart mode, play() will stop playback\nand start over. With untilDone, a sound will play only if it's\nnot already playing. Sustain is the default mode.
\n",itemtype:"method",name:"playMode",params:[{name:"str",description:"'restart' or 'sustain' or 'untilDone'
\n",type:"String"}],example:["\n\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
"],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3854,description:"Pauses a file that is currently playing. If the file is not\nplaying, then nothing will happen.
\nAfter pausing, .play() will resume from the paused\nposition.\nIf p5.SoundFile had been set to loop before it was paused,\nit will continue to loop after it is unpaused with .play().
\n",itemtype:"method",name:"pause",params:[{name:"startTime",description:"(optional) schedule event to occur\n seconds from now
\n",type:"Number",optional:!0}],example:["\n\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
\n"],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3911,description:"Loop the p5.SoundFile. Accepts optional parameters to set the\nplayback rate, playback volume, loopStart, loopEnd.
\n",itemtype:"method",name:"loop",params:[{name:"startTime",description:"(optional) schedule event to occur\n seconds from now
\n",type:"Number",optional:!0},{name:"rate",description:"(optional) playback rate
\n",type:"Number",optional:!0},{name:"amp",description:"(optional) playback volume
\n",type:"Number",optional:!0},{name:"cueLoopStart",description:"(optional) startTime in seconds
\n",type:"Number",optional:!0},{name:"duration",description:"(optional) loop duration in seconds
\n",type:"Number",optional:!0}],example:["\n \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
\n "],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3955,description:"Set a p5.SoundFile's looping flag to true or false. If the sound\nis currently playing, this change will take effect when it\nreaches the end of the current playback.
\n",itemtype:"method",name:"setLoop",params:[{name:"Boolean",description:"set looping to true or false
\n",type:"Boolean"}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:3980,description:"Returns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.
\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:4e3,description:"Returns true if a p5.SoundFile is playing, false if not (i.e.\npaused or stopped).
\n",itemtype:"method",name:"isPlaying",return:{description:"",type:"Boolean"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4013,description:"Returns true if a p5.SoundFile is paused, false if not (i.e.\nplaying or stopped).
\n",itemtype:"method",name:"isPaused",return:{description:"",type:"Boolean"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4026,description:"Stop soundfile playback.
\n",itemtype:"method",name:"stop",params:[{name:"startTime",description:"(optional) schedule event to occur\n in seconds from now
\n",type:"Number",optional:!0}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4083,description:"Multiply the output volume (amplitude) of a sound file\nbetween 0.0 (silence) and 1.0 (full volume).\n1.0 is the maximum amplitude of a digital sound, so multiplying\nby greater than 1.0 may cause digital distortion. To\nfade, provide a rampTime
parameter. For more\ncomplex fades, see the Envelope class.
\nAlternately, you can pass in a signal source such as an\noscillator to modulate the amplitude with an audio signal.
\n",itemtype:"method",name:"setVolume",params:[{name:"volume",description:"Volume (amplitude) between 0.0\n and 1.0 or modulating signal/oscillator
\n",type:"Number|Object"},{name:"rampTime",description:"Fade for t seconds
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"Schedule this event to happen at\n t seconds in the future
\n",type:"Number",optional:!0}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4128,description:"Set the stereo panning of a p5.sound object to\na floating point number between -1.0 (left) and 1.0 (right).\nDefault is 0.0 (center).
\n",itemtype:"method",name:"pan",params:[{name:"panValue",description:"Set the stereo panner
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],example:["\n\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
"],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4171,description:"Returns the current stereo pan position (-1.0 to 1.0)
\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:4185,description:"Set the playback rate of a sound file. Will change the speed and the pitch.\nValues less than zero will reverse the audio buffer.
\n",itemtype:"method",name:"rate",params:[{name:"playbackRate",description:"Set the playback rate. 1.0 is normal,\n .5 is half-speed, 2.0 is twice as fast.\n Values less than zero play backwards.
\n",type:"Number",optional:!0}],example:["\n\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
\n \n"],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4275,description:"Returns the duration of a sound file in seconds.
\n",itemtype:"method",name:"duration",return:{description:"The duration of the soundFile in seconds.",type:"Number"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4291,description:"Return the current position of the p5.SoundFile playhead, in seconds.\nTime is relative to the normal buffer direction, so if reverseBuffer
\nhas been called, currentTime will count backwards.
\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:4305,description:"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 play
or loop
methods.
\n",itemtype:"method",name:"jump",params:[{name:"cueTime",description:"cueTime of the soundFile in seconds.
\n",type:"Number"},{name:"duration",description:"duration in seconds.
\n",type:"Number"}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4336,description:"Return the number of channels in a sound file.\nFor example, Mono = 1, Stereo = 2.
\n",itemtype:"method",name:"channels",return:{description:"[channels]",type:"Number"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4349,description:"Return the sample rate of the sound file.
\n",itemtype:"method",name:"sampleRate",return:{description:"[sampleRate]",type:"Number"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4361,description:"Return the number of samples in a sound file.\nEqual to sampleRate * duration.
\n",itemtype:"method",name:"frames",return:{description:"[sampleCount]",type:"Number"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4374,description:"Returns an array of amplitude peaks in a p5.SoundFile that can be\nused to draw a static waveform. Scans through the p5.SoundFile's\naudio buffer to find the greatest amplitudes. Accepts one\nparameter, 'length', which determines size of the array.\nLarger arrays result in more precise waveform visualizations.
\nInspired by Wavesurfer.js.
\n",itemtype:"method",name:"getPeaks",params:[{name:"length",description:"length is the size of the returned array.\n Larger length results in more precision.\n Defaults to 5*width of the browser window.
\n",type:"Number",optional:!0}],return:{description:"Array of peaks.",type:"Float32Array"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4435,description:"Reverses the p5.SoundFile's buffer source.\nPlayback must be handled separately (see example).
\n",itemtype:"method",name:"reverseBuffer",example:["\n\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
\n "],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4488,description:"Schedule an event to be called when the soundfile\nreaches the end of a buffer. If the soundfile is\nplaying through once, this will be called when it\nends. If it is looping, it will be called when\nstop is called.
\n",itemtype:"method",name:"onended",params:[{name:"callback",description:"function to call when the\n soundfile has ended.
\n",type:"Function"}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4553,description:"Connects the output of a p5sound object to input of another\np5.sound object. For example, you may connect a p5.SoundFile to an\nFFT or an Effect. If no parameter is given, it will connect to\nthe master output. Most p5sound objects connect to the master\noutput when they are created.
\n",itemtype:"method",name:"connect",params:[{name:"object",description:"Audio object that accepts an input
\n",type:"Object",optional:!0}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4577,description:"Disconnects the output of this p5sound object.
\n",itemtype:"method",name:"disconnect",class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4590,class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4597,description:"Reset the source for this SoundFile to a\nnew path (URL).
\n",itemtype:"method",name:"setPath",params:[{name:"path",description:"path to audio file
\n",type:"String"},{name:"callback",description:"Callback
\n",type:"Function"}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4614,description:"Replace the current Audio Buffer with a new Buffer.
\n",itemtype:"method",name:"setBuffer",params:[{name:"buf",description:"Array of Float32 Array(s). 2 Float32 Arrays\n will create a stereo source. 1 will create\n a mono source.
\n",type:"Array"}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4708,description:"processPeaks returns an array of timestamps where it thinks there is a beat.
\nThis is an asynchronous function that processes the soundfile in an offline audio context,\nand sends the results to your callback function.
\nThe process involves running the soundfile through a lowpass filter, and finding all of the\npeaks above the initial threshold. If the total number of peaks are below the minimum number of peaks,\nit decreases the threshold and re-runs the analysis until either minPeaks or minThreshold are reached.
\n",itemtype:"method",name:"processPeaks",params:[{name:"callback",description:"a function to call once this data is returned
\n",type:"Function"},{name:"initThreshold",description:"initial threshold defaults to 0.9
\n",type:"Number",optional:!0},{name:"minThreshold",description:"minimum threshold defaults to 0.22
\n",type:"Number",optional:!0},{name:"minPeaks",description:"minimum number of peaks defaults to 200
\n",type:"Number",optional:!0}],return:{description:"Array of timestamped peaks",type:"Array"},class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4929,description:"Schedule events to trigger every time a MediaElement\n(audio/video) reaches a playback cue point.
\nAccepts a callback function, a time (in seconds) at which to trigger\nthe callback, and an optional parameter for the callback.
\nTime will be passed as the first parameter to the callback function,\nand param will be the second parameter.
\n",itemtype:"method",name:"addCue",params:[{name:"time",description:"Time in seconds, relative to this media\n element's playback. For example, to trigger\n an event every time playback reaches two\n seconds, pass in the number 2. This will be\n passed as the first parameter to\n the callback function.
\n",type:"Number"},{name:"callback",description:"Name of a function that will be\n called at the given time. The callback will\n receive time and (optionally) param as its\n two parameters.
\n",type:"Function"},{name:"value",description:"An object to be passed as the\n second parameter to the\n callback function.
\n",type:"Object",optional:!0}],return:{description:"id ID of this cue,\n useful for removeCue(id)",type:"Number"},example:['\n\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
'],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:4999,description:"Remove a callback based on its ID. The ID is returned by the\naddCue method.
\n",itemtype:"method",name:"removeCue",params:[{name:"id",description:"ID of the cue, as returned by addCue
\n",type:"Number"}],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5025,description:"Remove all of the callbacks that had originally been scheduled\nvia the addCue method.
\n",itemtype:"method",name:"clearCues",class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5054,description:'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\ngetBlob
\n',itemtype:"method",name:"save",params:[{name:"fileName",description:"name of the resulting .wav file.
\n",type:"String",optional:!0}],example:["\n \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
"],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5085,description:'This method is useful for sending a SoundFile to a server. It returns the\n.wav-encoded audio data as a "Blob".\nA Blob is a file-like data object that can be uploaded to a server\nwith an http request. We'll\nuse the httpDo
options object to send a POST request with some\nspecific options: we encode the request as multipart/form-data
,\nand attach the blob as one of the form values using FormData
.
\n',itemtype:"method",name:"getBlob",return:{description:"A file-like data object",type:"Blob"},example:["\n \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 `
"],class:"p5.SoundFile",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5276,description:"Connects to the p5sound instance (master output) by default.\nOptionally, you can pass in a specific source (i.e. a soundfile).
\n",itemtype:"method",name:"setInput",params:[{name:"snd",description:"set the sound source\n (optional, defaults to\n master output)
\n",type:"SoundObject|undefined",optional:!0},{name:"smoothing",description:"a range between 0.0 and 1.0\n to smooth amplitude readings
\n",type:"Number|undefined",optional:!0}],example:["\n\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
"],class:"p5.Amplitude",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5367,description:"Returns a single Amplitude reading at the moment it is called.\nFor continuous readings, run in the draw loop.
\n",itemtype:"method",name:"getLevel",params:[{name:"channel",description:"Optionally return only channel 0 (left) or 1 (right)
\n",type:"Number",optional:!0}],return:{description:"Amplitude as a number between 0.0 and 1.0",type:"Number"},example:["\n\nfunction preload(){\n sound = loadSound('assets/beat.mp3');\n}\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
"],class:"p5.Amplitude",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5421,description:"Determines whether the results of Amplitude.process() will be\nNormalized. To normalize, Amplitude finds the difference the\nloudest reading it has processed and the maximum amplitude of\n1.0. Amplitude adds this difference to all values to produce\nresults that will reliably map between 0.0 and 1.0. However,\nif a louder moment occurs, the amount that Normalize adds to\nall the values will change. Accepts an optional boolean parameter\n(true or false). Normalizing is off by default.
\n",itemtype:"method",name:"toggleNormalize",params:[{name:"boolean",description:"set normalize to true (1) or false (0)
\n",type:"Boolean",optional:!0}],class:"p5.Amplitude",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5449,description:"Smooth Amplitude analysis by averaging with the last analysis\nframe. Off by default.
\n",itemtype:"method",name:"smooth",params:[{name:"set",description:"smoothing from 0.0 <= 1
\n",type:"Number"}],class:"p5.Amplitude",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5625,description:"Set the input source for the FFT analysis. If no source is\nprovided, FFT will analyze all sound in the sketch.
\n",itemtype:"method",name:"setInput",params:[{name:"source",description:"p5.sound object (or web audio API source node)
\n",type:"Object",optional:!0}],class:"p5.FFT",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5648,description:"Returns an array of amplitude values (between -1.0 and +1.0) that represent\na snapshot of amplitude readings in a single buffer. Length will be\nequal to bins (defaults to 1024). Can be used to draw the waveform\nof a sound.
\n",itemtype:"method",name:"waveform",params:[{name:"bins",description:"Must be a power of two between\n 16 and 1024. Defaults to 1024.
\n",type:"Number",optional:!0},{name:"precision",description:"If any value is provided, will return results\n in a Float32 Array which is more precise\n than a regular array.
\n",type:"String",optional:!0}],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:5699,description:"Returns an array of amplitude values (between 0 and 255)\nacross the frequency spectrum. Length is equal to FFT bins\n(1024 by default). The array indices correspond to frequencies\n(i.e. pitches), from the lowest to the highest that humans can\nhear. Each value represents amplitude at that slice of the\nfrequency spectrum. Must be called prior to using\ngetEnergy()
.
\n",itemtype:"method",name:"analyze",params:[{name:"bins",description:"Must be a power of two between\n 16 and 1024. Defaults to 1024.
\n",type:"Number",optional:!0},{name:"scale",description:"If "dB," returns decibel\n float measurements between\n -140 and 0 (max).\n Otherwise returns integers from 0-255.
\n",type:"Number",optional:!0}],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\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
\n\n"],class:"p5.FFT",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5795,description:'Returns the amount of energy (volume) at a specific\n\nfrequency, or the average amount of energy between two\nfrequencies. Accepts Number(s) corresponding\nto frequency (in Hz), or a String corresponding to predefined\nfrequency ranges ("bass", "lowMid", "mid", "highMid", "treble").\nReturns a range between 0 (no energy/volume at that frequency) and\n255 (maximum energy).\nNOTE: analyze() must be called prior to getEnergy(). Analyze()\ntells the FFT to analyze frequency data, and getEnergy() uses\nthe results determine the value at a specific frequency or\nrange of frequencies.
\n',itemtype:"method",name:"getEnergy",params:[{name:"frequency1",description:"Will return a value representing\n energy at this frequency. Alternately,\n the strings "bass", "lowMid" "mid",\n "highMid", and "treble" will return\n predefined frequency ranges.
\n",type:"Number|String"},{name:"frequency2",description:"If a second frequency is given,\n will return average amount of\n energy that exists between the\n two frequencies.
\n",type:"Number",optional:!0}],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:5882,description:'Returns the\n\nspectral centroid of the input signal.\nNOTE: analyze() must be called prior to getCentroid(). Analyze()\ntells the FFT to analyze frequency data, and getCentroid() uses\nthe results determine the spectral centroid.
\n',itemtype:"method",name:"getCentroid",return:{description:"Spectral Centroid Frequency Frequency of the spectral centroid in Hz.",type:"Number"},example:["\n\n 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
"],class:"p5.FFT",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5968,description:"Smooth FFT analysis by averaging with the last analysis frame.
\n",itemtype:"method",name:"smooth",params:[{name:"smoothing",description:"0.0 < smoothing < 1.0.\n Defaults to 0.8.
\n",type:"Number"}],class:"p5.FFT",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:5994,description:"Returns an array of average amplitude values for a given number\nof frequency bands split equally. N defaults to 16.\nNOTE: 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.
\n",itemtype:"method",name:"linAverages",params:[{name:"N",description:"Number of returned frequency groups
\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:6028,description:'Returns an array of average amplitude values of the spectrum, for a given\nset of \nOctave Bands\nNOTE: 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.
\n',itemtype:"method",name:"logAverages",params:[{name:"octaveBands",description:"Array of Octave Bands objects for grouping
\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:6063,description:'Calculates and Returns the 1/N\nOctave Bands\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.
\n',itemtype:"method",name:"getOctaveBands",params:[{name:"N",description:"Specifies the 1/N type of generated octave bands
\n",type:"Number"},{name:"fCtr0",description:"Minimum central frequency for the lowest band
\n",type:"Number"}],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:6209,description:"Fade to value, for smooth transitions
\n",itemtype:"method",name:"fade",params:[{name:"value",description:"Value to set this signal
\n",type:"Number"},{name:"secondsFromNow",description:"Length of fade, in seconds from now
\n",type:"Number",optional:!0}],class:"p5.Signal",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6223,description:"Connect a p5.sound object or Web Audio node to this\np5.Signal so that its amplitude values can be scaled.
\n",itemtype:"method",name:"setInput",params:[{name:"input",description:"",type:"Object"}],class:"p5.Signal",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6240,description:"Add a constant value to this audio signal,\nand return the resulting audio signal. Does\nnot change the value of the original signal,\ninstead it returns a new p5.SignalAdd.
\n",itemtype:"method",name:"add",params:[{name:"number",description:"",type:"Number"}],return:{description:"object",type:"p5.Signal"},class:"p5.Signal",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6262,description:"Multiply this signal by a constant value,\nand return the resulting audio signal. Does\nnot change the value of the original signal,\ninstead it returns a new p5.SignalMult.
\n",itemtype:"method",name:"mult",params:[{name:"number",description:"to multiply
\n",type:"Number"}],return:{description:"object",type:"p5.Signal"},class:"p5.Signal",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6284,description:"Scale this signal value to a given range,\nand return the result as an audio signal. Does\nnot change the value of the original signal,\ninstead it returns a new p5.SignalScale.
\n",itemtype:"method",name:"scale",params:[{name:"number",description:"to multiply
\n",type:"Number"},{name:"inMin",description:"input range minumum
\n",type:"Number"},{name:"inMax",description:"input range maximum
\n",type:"Number"},{name:"outMin",description:"input range minumum
\n",type:"Number"},{name:"outMax",description:"input range maximum
\n",type:"Number"}],return:{description:"object",type:"p5.Signal"},class:"p5.Signal",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6397,description:"Time until envelope reaches attackLevel
\n",itemtype:"property",name:"attackTime",class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6402,description:"Level once attack is complete.
\n",itemtype:"property",name:"attackLevel",class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6408,description:"Time until envelope reaches decayLevel.
\n",itemtype:"property",name:"decayTime",class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6414,description:"Level after decay. The envelope will sustain here until it is released.
\n",itemtype:"property",name:"decayLevel",class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6420,description:"Duration of the release portion of the envelope.
\n",itemtype:"property",name:"releaseTime",class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6426,description:"Level at the end of the release.
\n",itemtype:"property",name:"releaseLevel",class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6463,description:"Reset the envelope with a series of time/value pairs.
\n",itemtype:"method",name:"set",params:[{name:"attackTime",description:"Time (in seconds) before level\n reaches attackLevel
\n",type:"Number"},{name:"attackLevel",description:"Typically an amplitude between\n 0.0 and 1.0
\n",type:"Number"},{name:"decayTime",description:"Time
\n",type:"Number"},{name:"decayLevel",description:"Amplitude (In a standard ADSR envelope,\n decayLevel = sustainLevel)
\n",type:"Number"},{name:"releaseTime",description:"Release Time (in seconds)
\n",type:"Number"},{name:"releaseLevel",description:"Amplitude
\n",type:"Number"}],example:["\n\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
\n"],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6525,description:'Set values like a traditional\n\nADSR envelope\n.
\n',itemtype:"method",name:"setADSR",params:[{name:"attackTime",description:"Time (in seconds before envelope\n reaches Attack Level
\n",type:"Number"},{name:"decayTime",description:"Time (in seconds) before envelope\n reaches Decay/Sustain Level
\n",type:"Number",optional:!0},{name:"susRatio",description:"Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n where 1.0 = attackLevel, 0.0 = releaseLevel.\n The susRatio determines the decayLevel and the level at which the\n sustain portion of the envelope will sustain.\n For example, if attackLevel is 0.4, releaseLevel is 0,\n and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n increased to 1.0 (using setRange
),\n then decayLevel would increase proportionally, to become 0.5.
\n",type:"Number",optional:!0},{name:"releaseTime",description:"Time in seconds from now (defaults to 0)
\n",type:"Number",optional:!0}],example:["\n\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
"],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6594,description:"Set max (attackLevel) and min (releaseLevel) of envelope.
\n",itemtype:"method",name:"setRange",params:[{name:"aLevel",description:"attack level (defaults to 1)
\n",type:"Number"},{name:"rLevel",description:"release level (defaults to 0)
\n",type:"Number"}],example:["\n\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
"],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6667,description:"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.
\n",itemtype:"method",name:"setInput",params:[{name:"inputs",description:"A p5.sound object or\n Web Audio Param.
\n",type:"Object",optional:!0,multiple:!0}],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6685,description:"Set whether the envelope ramp is linear (default) or exponential.\nExponential ramps can be useful because we perceive amplitude\nand frequency logarithmically.
\n",itemtype:"method",name:"setExp",params:[{name:"isExp",description:"true is exponential, false is linear
\n",type:"Boolean"}],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6708,description:'Play tells the envelope to start acting on a given input.\nIf the input is a p5.sound object (i.e. AudioIn, Oscillator,\nSoundFile), then Envelope will control its output volume.\nEnvelopes can also be used to control any \nWeb Audio Audio Param.
',itemtype:"method",name:"play",params:[{name:"unit",description:"A p5.sound object or\n Web Audio Param.
\n",type:"Object"},{name:"startTime",description:"time from now (in seconds) at which to play
\n",type:"Number",optional:!0},{name:"sustainTime",description:"time to sustain before releasing the envelope
\n",type:"Number",optional:!0}],example:["\n\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
"],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6779,description:'Trigger the Attack, and Decay portion of the Envelope.\nSimilar to holding down a key on a piano, but it will\nhold the sustain level until you let go. Input can be\nany p5.sound object, or a \nWeb Audio Param.
\n',itemtype:"method",name:"triggerAttack",params:[{name:"unit",description:"p5.sound Object or Web Audio Param
\n",type:"Object"},{name:"secondsFromNow",description:"time from now (in seconds)
\n",type:"Number"}],example:["\n\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
"],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6887,description:"Trigger the Release of the Envelope. This is similar to releasing\nthe key on a piano and letting the sound fade according to the\nrelease level and release time.
\n",itemtype:"method",name:"triggerRelease",params:[{name:"unit",description:"p5.sound Object or Web Audio Param
\n",type:"Object"},{name:"secondsFromNow",description:"time to trigger the release
\n",type:"Number"}],example:["\n\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
"],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:6981,description:'Exponentially ramp to a value using the first two\nvalues from setADSR(attackTime, decayTime)
\nas \ntime constants for simple exponential ramps.\nIf the value is higher than current value, it uses attackTime,\nwhile a decrease uses decayTime.
\n',itemtype:"method",name:"ramp",params:[{name:"unit",description:"p5.sound Object or Web Audio Param
\n",type:"Object"},{name:"secondsFromNow",description:"When to trigger the ramp
\n",type:"Number"},{name:"v",description:"Target value
\n",type:"Number"},{name:"v2",description:"Second target value (optional)
\n",type:"Number",optional:!0}],example:["\n\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
"],class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7095,description:"Add a value to the p5.Oscillator's output amplitude,\nand return the oscillator. Calling this method\nagain will override the initial add() with new values.
\n",itemtype:"method",name:"add",params:[{name:"number",description:"Constant number to add
\n",type:"Number"}],return:{description:"Envelope Returns this envelope\n with scaled output",type:"p5.Envelope"},class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7114,description:"Multiply the p5.Envelope's output amplitude\nby a fixed value. Calling this method\nagain will override the initial mult() with new values.
\n",itemtype:"method",name:"mult",params:[{name:"number",description:"Constant number to multiply
\n",type:"Number"}],return:{description:"Envelope Returns this envelope\n with scaled output",type:"p5.Envelope"},class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7133,description:"Scale this envelope's amplitude values to a given\nrange, and return the envelope. Calling this method\nagain will override the initial scale() with new values.
\n",itemtype:"method",name:"scale",params:[{name:"inMin",description:"input range minumum
\n",type:"Number"},{name:"inMax",description:"input range maximum
\n",type:"Number"},{name:"outMin",description:"input range minumum
\n",type:"Number"},{name:"outMax",description:"input range maximum
\n",type:"Number"}],return:{description:"Envelope Returns this envelope\n with scaled output",type:"p5.Envelope"},class:"p5.Envelope",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7268,description:"Set the width of a Pulse object (an oscillator that implements\nPulse Width Modulation).
\n",itemtype:"method",name:"width",params:[{name:"width",description:"Width between the pulses (0 to 1.0,\n defaults to 0)
\n",type:"Number",optional:!0}],class:"p5.Pulse",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7484,description:"Set type of noise to 'white', 'pink' or 'brown'.\nWhite is the default.
\n",itemtype:"method",name:"setType",params:[{name:"type",description:"'white', 'pink' or 'brown'
\n",type:"String",optional:!0}],class:"p5.Noise",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7630,itemtype:"property",name:"input",type:"GainNode",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7634,itemtype:"property",name:"output",type:"GainNode",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7639,itemtype:"property",name:"stream",type:"MediaStream|null",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7644,itemtype:"property",name:"mediaStream",type:"MediaStreamAudioSourceNode|null",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7649,itemtype:"property",name:"currentSource",type:"Number|null",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7654,description:"Client must allow browser to access their microphone / audioin source.\nDefault: false. Will become true when the client enables access.
\n",itemtype:"property",name:"enabled",type:"Boolean",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7662,description:"Input amplitude, connect to it by default but not to master out
\n",itemtype:"property",name:"amplitude",type:"p5.Amplitude",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7678,description:"Start processing audio input. This enables the use of other\nAudioIn methods like getLevel(). Note that by default, AudioIn\nis not connected to p5.sound's output. So you won't hear\nanything unless you use the connect() method.
\nCertain 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—a function that is called in case\nthe browser won't provide mic access.
\n",itemtype:"method",name:"start",params:[{name:"successCallback",description:"Name of a function to call on\n success.
\n",type:"Function",optional:!0},{name:"errorCallback",description:"Name of a function to call if\n there was an error. For example,\n some browsers do not support\n getUserMedia.
\n",type:"Function",optional:!0}],class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7733,description:"Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\nIf re-starting, the user may be prompted for permission access.
\n",itemtype:"method",name:"stop",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7752,description:"Connect to an audio unit. If no parameter is provided, will\nconnect to the master output (i.e. your speakers).
\n",itemtype:"method",name:"connect",params:[{name:"unit",description:"An object that accepts audio input,\n such as an FFT
\n",type:"Object",optional:!0}],class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7776,description:"Disconnect the AudioIn from all audio units. For example, if\nconnect() had been called, disconnect() will stop sending\nsignal to your speakers.
\n",itemtype:"method",name:"disconnect",class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7793,description:"Read the Amplitude (volume level) of an AudioIn. The AudioIn\nclass contains its own instance of the Amplitude class to help\nmake it easy to get a microphone's volume level. Accepts an\noptional smoothing value (0.0 < 1.0). NOTE: AudioIn must\n.start() before using .getLevel().
\n",itemtype:"method",name:"getLevel",params:[{name:"smoothing",description:"Smoothing is 0.0 by default.\n Smooths values based on previous values.
\n",type:"Number",optional:!0}],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:7815,description:"Set amplitude (volume) of a mic input between 0 and 1.0.
\n",itemtype:"method",name:"amp",params:[{name:"vol",description:"between 0 and 1.0
\n",type:"Number"},{name:"time",description:"ramp time (optional)
\n",type:"Number",optional:!0}],class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7837,description:'Returns a list of available input sources. This is a wrapper\nfor <a title="MediaDevices.enumerateDevices() - Web APIs | MDN" target="_blank" href=\n "https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices"
\n\nand it returns a Promise.
\n
\n',itemtype:"method",name:"getSources",params:[{name:"successCallback",description:"This callback function handles the sources when they\n have been enumerated. The callback function\n receives the deviceList array as its only argument
\n",type:"Function",optional:!0},{name:"errorCallback",description:"This optional callback receives the error\n message as its argument.
\n",type:"Function",optional:!0}],return:{description:"Returns a Promise that can be used in place of the callbacks, similar\n to the enumerateDevices() method",type:"Promise"},example:["\n \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
"],class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:7896,description:'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 title="MediaDevices.enumerateDevices() - Web APIs | MDN" target="_blank" href=\n"https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices"
\n\nnavigator.mediaDevices.enumerateDevices().
\n
\n',itemtype:"method",name:"setSource",params:[{name:"num",description:"position of input source in the array
\n",type:"Number"}],example:["\n\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
"],class:"p5.AudioIn",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8107,description:'The p5.EQ is built with abstracted p5.Filter objects.\nTo modify any bands, use methods of the \np5.Filter API, especially gain
and freq
.\nBands are stored in an array, with indices 0 - 3, or 0 - 7
\n',itemtype:"property",name:"bands",type:"Array",class:"p5.EQ",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8148,description:"Process an input by connecting it to the EQ
\n",itemtype:"method",name:"process",params:[{name:"src",description:"Audio source
\n",type:"Object"}],class:"p5.EQ",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8321,description:'\nWeb Audio Spatial Panner Node
\nProperties include
\n\n- <a title="w3 spec for Panning Model"\nhref="https://www.w3.org/TR/webaudio/#idl-def-PanningModelType"
\npanningModel: "equal power" or "HRTF"
\n
\n \n- <a title="w3 spec for Distance Model"\nhref="https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType"
\ndistanceModel: "linear", "inverse", or "exponential"
\n
\n \n
\n',itemtype:"property",name:"panner",type:"AudioNode",class:"p5.Panner3D",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8346,description:"Connect an audio sorce
\n",itemtype:"method",name:"process",params:[{name:"src",description:"Input source
\n",type:"Object"}],class:"p5.Panner3D",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8357,description:"Set the X,Y,Z position of the Panner
\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:8375,description:"Getter and setter methods for position coordinates
\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:8382,description:"Getter and setter methods for position coordinates
\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:8389,description:"Getter and setter methods for position coordinates
\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:8438,description:"Set the X,Y,Z position of the Panner
\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:8456,description:"Getter and setter methods for orient coordinates
\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:8463,description:"Getter and setter methods for orient coordinates
\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:8470,description:"Getter and setter methods for orient coordinates
\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:8519,description:"Set the rolloff factor and max distance
\n",itemtype:"method",name:"setFalloff",params:[{name:"maxDistance",description:"",type:"Number",optional:!0},{name:"rolloffFactor",description:"",type:"Number",optional:!0}],class:"p5.Panner3D",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8532,description:"Maxium distance between the source and the listener
\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:8548,description:"How quickly the volume is reduced as the source moves away from the listener
\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:8885,description:'The p5.Delay is built with two\n\nWeb Audio Delay Nodes, one for each stereo channel.
\n',itemtype:"property",name:"leftDelay",type:"DelayNode",class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8895,description:'The p5.Delay is built with two\n\nWeb Audio Delay Nodes, one for each stereo channel.
\n',itemtype:"property",name:"rightDelay",type:"DelayNode",class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8942,description:"Add delay to an audio signal according to a set\nof delay parameters.
\n",itemtype:"method",name:"process",params:[{name:"Signal",description:"An object that outputs audio
\n",type:"Object"},{name:"delayTime",description:"Time (in seconds) of the delay/echo.\n Some browsers limit delayTime to\n 1 second.
\n",type:"Number",optional:!0},{name:"feedback",description:"sends the delay back through itself\n in a loop that decreases in volume\n each time.
\n",type:"Number",optional:!0},{name:"lowPass",description:"Cutoff frequency. Only frequencies\n below the lowPass will be part of the\n delay.
\n",type:"Number",optional:!0}],class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:8984,description:"Set the delay (echo) time, in seconds. Usually this value will be\na floating point number between 0.0 and 1.0.
\n",itemtype:"method",name:"delayTime",params:[{name:"delayTime",description:"Time (in seconds) of the delay
\n",type:"Number"}],class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9005,description:"Feedback occurs when Delay sends its signal back through its input\nin a loop. The feedback amount determines how much signal to send each\ntime through the loop. A feedback greater than 1.0 is not desirable because\nit will increase the overall output each time through the loop,\ncreating an infinite feedback loop. The default value is 0.5
\n",itemtype:"method",name:"feedback",params:[{name:"feedback",description:"0.0 to 1.0, or an object such as an\n Oscillator that can be used to\n modulate this param
\n",type:"Number|Object"}],return:{description:"Feedback value",type:"Number"},class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9036,description:"Set a lowpass filter frequency for the delay. A lowpass filter\nwill cut off any frequencies higher than the filter frequency.
\n",itemtype:"method",name:"filter",params:[{name:"cutoffFreq",description:"A lowpass filter will cut off any\n frequencies higher than the filter frequency.
\n",type:"Number|Object"},{name:"res",description:"Resonance of the filter frequency\n cutoff, or an object (i.e. a p5.Oscillator)\n that can be used to modulate this parameter.\n High numbers (i.e. 15) will produce a resonance,\n low numbers (i.e. .2) will produce a slope.
\n",type:"Number|Object"}],class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9057,description:"Choose a preset type of delay. 'pingPong' bounces the signal\nfrom the left to the right channel to produce a stereo effect.\nAny other parameter will revert to the default delay setting.
\n",itemtype:"method",name:"setType",params:[{name:"type",description:"'pingPong' (1) or 'default' (0)
\n",type:"String|Number"}],class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9109,description:"Set the output level of the delay effect.
\n",itemtype:"method",name:"amp",params:[{name:"volume",description:"amplitude between 0 and 1.0
\n",type:"Number"},{name:"rampTime",description:"create a fade that lasts rampTime
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9120,description:"Send output to a p5.sound or web audio object
\n",itemtype:"method",name:"connect",params:[{name:"unit",description:"",type:"Object"}],class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9128,description:"Disconnect all output.
\n",itemtype:"method",name:"disconnect",class:"p5.Delay",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9265,description:"Connect a source to the reverb, and assign reverb parameters.
\n",itemtype:"method",name:"process",params:[{name:"src",description:"p5.sound / Web Audio object with a sound\n output.
\n",type:"Object"},{name:"seconds",description:"Duration of the reverb, in seconds.\n Min: 0, Max: 10. Defaults to 3.
\n",type:"Number",optional:!0},{name:"decayRate",description:"Percentage of decay with each echo.\n Min: 0, Max: 100. Defaults to 2.
\n",type:"Number",optional:!0},{name:"reverse",description:"Play the reverb backwards or forwards.
\n",type:"Boolean",optional:!0}],class:"p5.Reverb",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9301,description:"Set the reverb settings. Similar to .process(), but without\nassigning a new input.
\n",itemtype:"method",name:"set",params:[{name:"seconds",description:"Duration of the reverb, in seconds.\n Min: 0, Max: 10. Defaults to 3.
\n",type:"Number",optional:!0},{name:"decayRate",description:"Percentage of decay with each echo.\n Min: 0, Max: 100. Defaults to 2.
\n",type:"Number",optional:!0},{name:"reverse",description:"Play the reverb backwards or forwards.
\n",type:"Boolean",optional:!0}],class:"p5.Reverb",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9336,description:"Set the output level of the reverb effect.
\n",itemtype:"method",name:"amp",params:[{name:"volume",description:"amplitude between 0 and 1.0
\n",type:"Number"},{name:"rampTime",description:"create a fade that lasts rampTime
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],class:"p5.Reverb",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9347,description:"Send output to a p5.sound or web audio object
\n",itemtype:"method",name:"connect",params:[{name:"unit",description:"",type:"Object"}],class:"p5.Reverb",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9355,description:"Disconnect all output.
\n",itemtype:"method",name:"disconnect",class:"p5.Reverb",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9461,description:'Internally, the p5.Convolver uses the a\n\nWeb Audio Convolver Node.
\n',itemtype:"property",name:"convolverNode",type:"ConvolverNode",class:"p5.Convolver",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9489,description:"Create a p5.Convolver. Accepts a path to a soundfile\nthat will be used to generate an impulse response.
\n",itemtype:"method",name:"createConvolver",params:[{name:"path",description:"path to a sound file
\n",type:"String"},{name:"callback",description:"function to call if loading is successful.\n The object will be passed in as the argument\n to the callback function.
\n",type:"Function",optional:!0},{name:"errorCallback",description:"function to call if loading is not successful.\n A custom error will be passed in as the argument\n to the callback function.
\n",type:"Function",optional:!0}],return:{description:"",type:"p5.Convolver"},example:["\n\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 master output...\n sound.disconnect();\n\n // ...and process with cVerb\n // so that we only hear the convolution\n cVerb.process(sound);\n}\n\nfunction playSound() {\n sound.play();\n}\n
"],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9635,description:"Connect a source to the convolver.
\n",itemtype:"method",name:"process",params:[{name:"src",description:"p5.sound / Web Audio object with a sound\n output.
\n",type:"Object"}],example:["\n\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 master output...\n sound.disconnect();\n\n // ...and process with cVerb\n // so that we only hear the convolution\n cVerb.process(sound);\n}\n\nfunction playSound() {\n sound.play();\n}\n\n
"],class:"p5.Convolver",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9682,description:"If you load multiple impulse files using the .addImpulse method,\nthey will be stored as Objects in this Array. Toggle between them\nwith the toggleImpulse(id)
method.
\n",itemtype:"property",name:"impulses",type:"Array",class:"p5.Convolver",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9693,description:"Load and assign a new Impulse Response to the p5.Convolver.\nThe impulse is added to the .impulses
array. Previous\nimpulses can be accessed with the .toggleImpulse(id)
\nmethod.
\n",itemtype:"method",name:"addImpulse",params:[{name:"path",description:"path to a sound file
\n",type:"String"},{name:"callback",description:"function (optional)
\n",type:"Function"},{name:"errorCallback",description:"function (optional)
\n",type:"Function"}],class:"p5.Convolver",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9713,description:"Similar to .addImpulse, except that the .impulses
\nArray is reset to save memory. A new .impulses
\narray is created with this impulse as the only item.
\n",itemtype:"method",name:"resetImpulse",params:[{name:"path",description:"path to a sound file
\n",type:"String"},{name:"callback",description:"function (optional)
\n",type:"Function"},{name:"errorCallback",description:"function (optional)
\n",type:"Function"}],class:"p5.Convolver",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9735,description:'If you have used .addImpulse()
to add multiple impulses\nto a p5.Convolver, then you can use this method to toggle between\nthe items in the .impulses
Array. Accepts a parameter\nto identify which impulse you wish to use, identified either by its\noriginal filename (String) or by its position in the .impulses\n
Array (Number).
\nYou can access the objects in the .impulses Array directly. Each\nObject has two attributes: an .audioBuffer
(type:\nWeb Audio \nAudioBuffer) and a .name
, a String that corresponds\nwith the original filename.
\n',itemtype:"method",name:"toggleImpulse",params:[{name:"id",description:"Identify the impulse by its original filename\n (String), or by its position in the\n .impulses
Array (Number).
\n",type:"String|Number"}],class:"p5.Convolver",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9903,description:"Set the global tempo, in beats per minute, for all\np5.Parts. This method will impact all active p5.Parts.
\n",itemtype:"method",name:"setBPM",params:[{name:"BPM",description:"Beats Per Minute
\n",type:"Number"},{name:"rampTime",description:"Seconds from now
\n",type:"Number"}],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:9990,description:"Array of values to pass into the callback\nat each step of the phrase. Depending on the callback\nfunction's requirements, these values may be numbers,\nstrings, or an object with multiple parameters.\nZero (0) indicates a rest.
\n",itemtype:"property",name:"sequence",type:"Array",class:"p5.Phrase",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10076,description:"Set the tempo of this part, in Beats Per Minute.
\n",itemtype:"method",name:"setBPM",params:[{name:"BPM",description:"Beats Per Minute
\n",type:"Number"},{name:"rampTime",description:"Seconds from now
\n",type:"Number",optional:!0}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10089,description:"Returns the tempo, in Beats Per Minute, of this part.
\n",itemtype:"method",name:"getBPM",return:{description:"",type:"Number"},class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10101,description:"Start playback of this part. It will play\nthrough all of its phrases at a speed\ndetermined by setBPM.
\n",itemtype:"method",name:"start",params:[{name:"time",description:"seconds from now
\n",type:"Number",optional:!0}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10120,description:"Loop playback of this part. It will begin\nlooping through all of its phrases at a speed\ndetermined by setBPM.
\n",itemtype:"method",name:"loop",params:[{name:"time",description:"seconds from now
\n",type:"Number",optional:!0}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10141,description:"Tell the part to stop looping.
\n",itemtype:"method",name:"noLoop",class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10156,description:"Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.
\n",itemtype:"method",name:"stop",params:[{name:"time",description:"seconds from now
\n",type:"Number",optional:!0}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10169,description:"Pause the part. Playback will resume\nfrom the current step.
\n",itemtype:"method",name:"pause",params:[{name:"time",description:"seconds from now
\n",type:"Number"}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10184,description:"Add a p5.Phrase to this Part.
\n",itemtype:"method",name:"addPhrase",params:[{name:"phrase",description:"reference to a p5.Phrase
\n",type:"p5.Phrase"}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10210,description:"Remove a phrase from this part, based on the name it was\ngiven when it was created.
\n",itemtype:"method",name:"removePhrase",params:[{name:"phraseName",description:"",type:"String"}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10227,description:"Get a phrase from this part, based on the name it was\ngiven when it was created. Now you can modify its array.
\n",itemtype:"method",name:"getPhrase",params:[{name:"phraseName",description:"",type:"String"}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10244,description:"Find all sequences with the specified name, and replace their patterns with the specified array.
\n",itemtype:"method",name:"replaceSequence",params:[{name:"phraseName",description:"",type:"String"},{name:"sequence",description:"Array of values to pass into the callback\n at each step of the phrase.
\n",type:"Array"}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10273,description:"Set the function that will be called at every step. This will clear the previous function.
\n",itemtype:"method",name:"onStep",params:[{name:"callback",description:"The name of the callback\n you want to fire\n on every beat/tatum.
\n",type:"Function"}],class:"p5.Part",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10332,description:"Start playback of the score.
\n",itemtype:"method",name:"start",class:"p5.Score",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10344,description:"Stop playback of the score.
\n",itemtype:"method",name:"stop",class:"p5.Score",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10357,description:"Pause playback of the score.
\n",itemtype:"method",name:"pause",class:"p5.Score",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10368,description:"Loop playback of the score.
\n",itemtype:"method",name:"loop",class:"p5.Score",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10380,description:"Stop looping playback of the score. If it\nis currently playing, this will go into effect\nafter the current round of playback completes.
\n",itemtype:"method",name:"noLoop",class:"p5.Score",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10411,description:"Set the tempo for all parts in the score
\n",itemtype:"method",name:"setBPM",params:[{name:"BPM",description:"Beats Per Minute
\n",type:"Number"},{name:"rampTime",description:"Seconds from now
\n",type:"Number"}],class:"p5.Score",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10508,description:'musicalTimeMode uses Tone.Time convention\ntrue if string, false if number
\n',itemtype:"property",name:"musicalTimeMode",type:"Boolean",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10516,description:"musicalTimeMode variables\nmodify these only when the interval is specified in musicalTime format as a string
\n",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10524,description:"Set a limit to the number of loops to play. defaults to Infinity
\n",itemtype:"property",name:"maxIterations",type:"Number",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10534,description:"Do not initiate the callback if timeFromNow is < 0\nThis ususually occurs for a few milliseconds when the page\nis not fully loaded
\nThe callback should only be called until maxIterations is reached
\n",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10549,description:"Start the loop
\n",itemtype:"method",name:"start",params:[{name:"timeFromNow",description:"schedule a starting time
\n",type:"Number",optional:!0}],class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10566,description:"Stop the loop
\n",itemtype:"method",name:"stop",params:[{name:"timeFromNow",description:"schedule a stopping time
\n",type:"Number",optional:!0}],class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10583,description:"Pause the loop
\n",itemtype:"method",name:"pause",params:[{name:"timeFromNow",description:"schedule a pausing time
\n",type:"Number",optional:!0}],class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10600,description:"Synchronize loops. Use this method to start two more 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)
\n",itemtype:"method",name:"syncedStart",params:[{name:"otherLoop",description:"a p5.SoundLoop to sync with
\n",type:"Object"},{name:"timeFromNow",description:"Start the loops in sync after timeFromNow seconds
\n",type:"Number",optional:!0}],class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10705,description:"Getters and Setters, setting any paramter will result in a change in the clock's\nfrequency, that will be reflected after the next callback\nbeats per minute (defaults to 60)
\n",itemtype:"property",name:"bpm",type:"Number",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10728,description:"number of quarter notes in a measure (defaults to 4)
\n",itemtype:"property",name:"timeSignature",type:"Number",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10748,description:"length of the loops interval
\n",itemtype:"property",name:"interval",type:"Number|String",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10765,description:"how many times the callback has been called so far
\n",itemtype:"property",name:"iterations",type:"Number",readonly:"",class:"p5.SoundLoop",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10817,description:'The p5.Compressor is built with a Web Audio Dynamics Compressor Node\n
\n',itemtype:"property",name:"compressor",type:"AudioNode",class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10830,description:"Performs the same function as .connect, but also accepts\noptional parameters to set compressor's audioParams
\n",itemtype:"method",name:"process",params:[{name:"src",description:"Sound source to be connected
\n",type:"Object"},{name:"attack",description:"The amount of time (in seconds) to reduce the gain by 10dB,\n default = .003, range 0 - 1
\n",type:"Number",optional:!0},{name:"knee",description:"A decibel value representing the range above the\n threshold where the curve smoothly transitions to the "ratio" portion.\n default = 30, range 0 - 40
\n",type:"Number",optional:!0},{name:"ratio",description:"The amount of dB change in input for a 1 dB change in output\n default = 12, range 1 - 20
\n",type:"Number",optional:!0},{name:"threshold",description:"The decibel value above which the compression will start taking effect\n default = -24, range -100 - 0
\n",type:"Number",optional:!0},{name:"release",description:"The amount of time (in seconds) to increase the gain by 10dB\n default = .25, range 0 - 1
\n",type:"Number",optional:!0}],class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10855,description:"Set the paramters of a compressor.
\n",itemtype:"method",name:"set",params:[{name:"attack",description:"The amount of time (in seconds) to reduce the gain by 10dB,\n default = .003, range 0 - 1
\n",type:"Number"},{name:"knee",description:"A decibel value representing the range above the\n threshold where the curve smoothly transitions to the "ratio" portion.\n default = 30, range 0 - 40
\n",type:"Number"},{name:"ratio",description:"The amount of dB change in input for a 1 dB change in output\n default = 12, range 1 - 20
\n",type:"Number"},{name:"threshold",description:"The decibel value above which the compression will start taking effect\n default = -24, range -100 - 0
\n",type:"Number"},{name:"release",description:"The amount of time (in seconds) to increase the gain by 10dB\n default = .25, range 0 - 1
\n",type:"Number"}],class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10894,description:"Get current attack or set value w/ time ramp
\n",itemtype:"method",name:"attack",params:[{name:"attack",description:"Attack is the amount of time (in seconds) to reduce the gain by 10dB,\n default = .003, range 0 - 1
\n",type:"Number",optional:!0},{name:"time",description:"Assign time value to schedule the change in value
\n",type:"Number",optional:!0}],class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10919,description:"Get current knee or set value w/ time ramp
\n",itemtype:"method",name:"knee",params:[{name:"knee",description:"A decibel value representing the range above the\n threshold where the curve smoothly transitions to the "ratio" portion.\n default = 30, range 0 - 40
\n",type:"Number",optional:!0},{name:"time",description:"Assign time value to schedule the change in value
\n",type:"Number",optional:!0}],class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10944,description:"Get current ratio or set value w/ time ramp
\n",itemtype:"method",name:"ratio",params:[{name:"ratio",description:"The amount of dB change in input for a 1 dB change in output\n default = 12, range 1 - 20
\n",type:"Number",optional:!0},{name:"time",description:"Assign time value to schedule the change in value
\n",type:"Number",optional:!0}],class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10967,description:"Get current threshold or set value w/ time ramp
\n",itemtype:"method",name:"threshold",params:[{name:"threshold",description:"The decibel value above which the compression will start taking effect\n default = -24, range -100 - 0
\n",type:"Number"},{name:"time",description:"Assign time value to schedule the change in value
\n",type:"Number",optional:!0}],class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:10990,description:"Get current release or set value w/ time ramp
\n",itemtype:"method",name:"release",params:[{name:"release",description:"The amount of time (in seconds) to increase the gain by 10dB\n default = .25, range 0 - 1
\n",type:"Number"},{name:"time",description:"Assign time value to schedule the change in value
\n",type:"Number",optional:!0}],class:"p5.Compressor",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11014,description:"Return the current reduction value
\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:11169,description:"Connect a specific device to the p5.SoundRecorder.\nIf no parameter is given, p5.SoundRecorer will record\nall audible p5.sound from your sketch.
\n",itemtype:"method",name:"setInput",params:[{name:"unit",description:"p5.sound object or a web audio unit\n that outputs sound
\n",type:"Object",optional:!0}],class:"p5.SoundRecorder",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11194,description:"Start recording. To access the recording, provide\na p5.SoundFile as the first parameter. The p5.SoundRecorder\nwill send its recording to that p5.SoundFile for playback once\nrecording is complete. Optional parameters include duration\n(in seconds) of the recording, and a callback function that\nwill be called once the complete recording has been\ntransfered to the p5.SoundFile.
\n",itemtype:"method",name:"record",params:[{name:"soundFile",description:"p5.SoundFile
\n",type:"p5.SoundFile"},{name:"duration",description:"Time (in seconds)
\n",type:"Number",optional:!0},{name:"callback",description:"The name of a function that will be\n called once the recording completes
\n",type:"Function",optional:!0}],class:"p5.SoundRecorder",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11229,description:"Stop the recording. Once the recording is stopped,\nthe results will be sent to the p5.SoundFile that\nwas given on .record(), and if a callback function\nwas provided on record, that function will be called.
\n",itemtype:"method",name:"stop",class:"p5.SoundRecorder",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11259,description:'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\np5.SoundFile.saveBlob
.
\n',itemtype:"method",name:"saveSound",params:[{name:"soundFile",description:"p5.SoundFile that you wish to save
\n",type:"p5.SoundFile"},{name:"fileName",description:"name of the resulting .wav file.
\n",type:"String"}],class:"p5",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11389,description:"isDetected is set to true when a peak is detected.
\n",itemtype:"attribute",name:"isDetected",type:"Boolean",default:"false",class:"p5.PeakDetect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11402,description:"The update method is run in the draw loop.
\nAccepts an FFT object. You must call .analyze()\non the FFT object prior to updating the peakDetect\nbecause it relies on a completed FFT analysis.
\n",itemtype:"method",name:"update",params:[{name:"fftObject",description:"A p5.FFT object
\n",type:"p5.FFT"}],class:"p5.PeakDetect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11438,description:"onPeak accepts two arguments: a function to call when\na peak is detected. The value of the peak,\nbetween 0.0 and 1.0, is passed to the callback.
\n",itemtype:"method",name:"onPeak",params:[{name:"callback",description:"Name of a function that will\n be called when a peak is\n detected.
\n",type:"Function"},{name:"val",description:"Optional value to pass\n into the function when\n a peak is detected.
\n",type:"Object",optional:!0}],example:["\n\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
"],class:"p5.PeakDetect",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11600,description:"Connect a source to the gain node.
\n",itemtype:"method",name:"setInput",params:[{name:"src",description:"p5.sound / Web Audio object with a sound\n output.
\n",type:"Object"}],class:"p5.Gain",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11613,description:"Send output to a p5.sound or web audio object
\n",itemtype:"method",name:"connect",params:[{name:"unit",description:"",type:"Object"}],class:"p5.Gain",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11626,description:"Disconnect all output.
\n",itemtype:"method",name:"disconnect",class:"p5.Gain",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11639,description:"Set the output level of the gain node.
\n",itemtype:"method",name:"amp",params:[{name:"volume",description:"amplitude between 0 and 1.0
\n",type:"Number"},{name:"rampTime",description:"create a fade that lasts rampTime
\n",type:"Number",optional:!0},{name:"timeFromNow",description:"schedule this event to happen\n seconds from now
\n",type:"Number",optional:!0}],class:"p5.Gain",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11743,description:'The p5.Distortion is built with a\n\nWeb Audio WaveShaper Node.
\n',itemtype:"property",name:"WaveShaperNode",type:"AudioNode",class:"p5.Distortion",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11760,description:"Process a sound source, optionally specify amount and oversample values.
\n",itemtype:"method",name:"process",params:[{name:"amount",description:"Unbounded distortion amount.\n Normal values range from 0-1.
\n",type:"Number",optional:!0,optdefault:"0.25"},{name:"oversample",description:"'none', '2x', or '4x'.
\n",type:"String",optional:!0,optdefault:"'none'"}],class:"p5.Distortion",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11774,description:"Set the amount and oversample of the waveshaper distortion.
\n",itemtype:"method",name:"set",params:[{name:"amount",description:"Unbounded distortion amount.\n Normal values range from 0-1.
\n",type:"Number",optional:!0,optdefault:"0.25"},{name:"oversample",description:"'none', '2x', or '4x'.
\n",type:"String",optional:!0,optdefault:"'none'"}],class:"p5.Distortion",module:"p5.sound",submodule:"p5.sound"},{file:"lib/addons/p5.sound.js",line:11796,description:"Return the distortion amount, typically between 0-1.
\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:11809,description:"Return the oversampling.
\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"}],warnings:[{message:"unknown tag: alt",line:" src/color/creating_reading.js:14"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:59"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:89"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:132"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:330"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:361"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:398"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:489"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:519"},{message:"unknown tag: alt",line:" src/color/creating_reading.js:559"},{message:"unknown tag: alt",line:" src/color/p5.Color.js:51"},{message:"unknown tag: alt",line:" src/color/p5.Color.js:252"},{message:"unknown tag: alt",line:" src/color/p5.Color.js:281"},{message:"unknown tag: alt",line:" src/color/p5.Color.js:310"},{message:"unknown tag: alt",line:" src/color/p5.Color.js:339"},{message:"unknown tag: alt",line:" src/color/p5.Color.js:776"},{message:"unknown tag: alt",line:" src/color/setting.js:13"},{message:"unknown tag: alt",line:" src/color/setting.js:179"},{message:"unknown tag: alt",line:" src/color/setting.js:218"},{message:"unknown tag: alt",line:" src/color/setting.js:339"},{message:"unknown tag: alt",line:" src/color/setting.js:496"},{message:"unknown tag: alt",line:" src/color/setting.js:537"},{message:"unknown tag: alt",line:" src/color/setting.js:577"},{message:"unknown tag: alt",line:" src/color/setting.js:749"},{message:"unknown tag: alt",line:" src/color/setting.js:829"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:100"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:211"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:249"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:306"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:362"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:437"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:504"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:569"},{message:"unknown tag: alt",line:" src/core/shape/2d_primitives.js:652"},{message:"unknown tag: alt",line:" src/core/shape/attributes.js:12"},{message:"unknown tag: alt",line:" src/core/shape/attributes.js:82"},{message:"unknown tag: alt",line:" src/core/shape/attributes.js:117"},{message:"unknown tag: alt",line:" src/core/shape/attributes.js:186"},{message:"unknown tag: alt",line:" src/core/shape/attributes.js:222"},{message:"unknown tag: alt",line:" src/core/shape/attributes.js:259"},{message:"unknown tag: alt",line:" src/core/shape/attributes.js:326"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:11"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:94"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:137"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:192"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:271"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:362"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:404"},{message:"unknown tag: alt",line:" src/core/shape/curves.js:500"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:20"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:68"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:268"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:268"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:268"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:396"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:441"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:506"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:566"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:652"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:718"},{message:"unknown tag: alt",line:" src/core/shape/vertex.js:811"},{message:"unknown tag: alt",line:" src/core/constants.js:58"},{message:"unknown tag: alt",line:" src/core/constants.js:77"},{message:"unknown tag: alt",line:" src/core/constants.js:96"},{message:"unknown tag: alt",line:" src/core/constants.js:115"},{message:"unknown tag: alt",line:" src/core/constants.js:134"},{message:"unknown tag: alt",line:" src/core/environment.js:20"},{message:"unknown tag: alt",line:" src/core/environment.js:51"},{message:"unknown tag: alt",line:" src/core/environment.js:78"},{message:"unknown tag: alt",line:" src/core/environment.js:129"},{message:"unknown tag: alt",line:" src/core/environment.js:161"},{message:"unknown tag: alt",line:" src/core/environment.js:230"},{message:"unknown tag: alt",line:" src/core/environment.js:333"},{message:"unknown tag: alt",line:" src/core/environment.js:358"},{message:"unknown tag: alt",line:" src/core/environment.js:377"},{message:"unknown tag: alt",line:" src/core/environment.js:396"},{message:"unknown tag: alt",line:" src/core/environment.js:412"},{message:"unknown tag: alt",line:" src/core/environment.js:428"},{message:"unknown tag: alt",line:" src/core/environment.js:506"},{message:"unknown tag: alt",line:" src/core/environment.js:557"},{message:"replacing incorrect tag: returns with return",line:" src/core/environment.js:592"},{message:"replacing incorrect tag: returns with return",line:" src/core/environment.js:611"},{message:"unknown tag: alt",line:" src/core/environment.js:611"},{message:"unknown tag: alt",line:" src/core/environment.js:666"},{message:"unknown tag: alt",line:" src/core/environment.js:695"},{message:"unknown tag: alt",line:" src/core/environment.js:715"},{message:"replacing incorrect tag: function with method",line:" src/core/internationalization.js:5"},{message:"replacing incorrect tag: returns with return",line:" src/core/internationalization.js:5"},{message:"unknown tag: alt",line:" src/core/main.js:41"},{message:"unknown tag: alt",line:" src/core/main.js:82"},{message:"unknown tag: alt",line:" src/core/main.js:113"},{message:"unknown tag: alt",line:" src/core/main.js:410"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:47"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:112"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:152"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:187"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:248"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:297"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:363"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:417"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:473"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:531"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:574"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:616"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:664"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:704"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:753"},{message:"unknown tag: alt",line:" src/core/p5.Element.js:791"},{message:"unknown tag: alt",line:" src/core/p5.Graphics.js:64"},{message:"unknown tag: alt",line:" src/core/p5.Graphics.js:116"},{message:"unknown tag: alt",line:" src/core/rendering.js:15"},{message:"unknown tag: alt",line:" src/core/rendering.js:115"},{message:"unknown tag: alt",line:" src/core/rendering.js:170"},{message:"unknown tag: alt",line:" src/core/rendering.js:193"},{message:"unknown tag: alt",line:" src/core/rendering.js:232"},{message:"unknown tag: alt",line:" src/core/rendering.js:315"},{message:"unknown tag: alt",line:" src/core/structure.js:10"},{message:"unknown tag: alt",line:" src/core/structure.js:72"},{message:"unknown tag: alt",line:" src/core/structure.js:120"},{message:"unknown tag: alt",line:" src/core/structure.js:211"},{message:"unknown tag: alt",line:" src/core/structure.js:303"},{message:"unknown tag: alt",line:" src/core/structure.js:404"},{message:"unknown tag: alt",line:" src/core/transform.js:11"},{message:"unknown tag: alt",line:" src/core/transform.js:148"},{message:"unknown tag: alt",line:" src/core/transform.js:174"},{message:"unknown tag: alt",line:" src/core/transform.js:214"},{message:"unknown tag: alt",line:" src/core/transform.js:244"},{message:"unknown tag: alt",line:" src/core/transform.js:274"},{message:"unknown tag: alt",line:" src/core/transform.js:304"},{message:"unknown tag: alt",line:" src/core/transform.js:379"},{message:"unknown tag: alt",line:" src/core/transform.js:419"},{message:"unknown tag: alt",line:" src/core/transform.js:459"},{message:"unknown tag: alt",line:" src/data/local_storage.js:10"},{message:"unknown tag: alt",line:" src/data/local_storage.js:91"},{message:"unknown tag: alt",line:" src/dom/dom.js:226"},{message:"unknown tag: alt",line:" src/dom/dom.js:294"},{message:"replacing incorrect tag: returns with return",line:" src/dom/dom.js:1471"},{message:"replacing incorrect tag: returns with return",line:" src/dom/dom.js:1533"},{message:"replacing incorrect tag: returns with return",line:" src/dom/dom.js:1637"},{message:"replacing incorrect tag: returns with return",line:" src/dom/dom.js:1676"},{message:"replacing incorrect tag: returns with return",line:" src/dom/dom.js:1793"},{message:"unknown tag: alt",line:" src/dom/dom.js:2166"},{message:"unknown tag: alt",line:" src/events/acceleration.js:23"},{message:"unknown tag: alt",line:" src/events/acceleration.js:46"},{message:"unknown tag: alt",line:" src/events/acceleration.js:69"},{message:"unknown tag: alt",line:" src/events/acceleration.js:135"},{message:"unknown tag: alt",line:" src/events/acceleration.js:168"},{message:"unknown tag: alt",line:" src/events/acceleration.js:201"},{message:"unknown tag: alt",line:" src/events/acceleration.js:239"},{message:"unknown tag: alt",line:" src/events/acceleration.js:286"},{message:"unknown tag: alt",line:" src/events/acceleration.js:332"},{message:"unknown tag: alt",line:" src/events/acceleration.js:392"},{message:"unknown tag: alt",line:" src/events/acceleration.js:431"},{message:"unknown tag: alt",line:" src/events/acceleration.js:474"},{message:"unknown tag: alt",line:" src/events/acceleration.js:518"},{message:"unknown tag: alt",line:" src/events/acceleration.js:550"},{message:"unknown tag: alt",line:" src/events/acceleration.js:609"},{message:"unknown tag: alt",line:" src/events/keyboard.js:10"},{message:"unknown tag: alt",line:" src/events/keyboard.js:37"},{message:"unknown tag: alt",line:" src/events/keyboard.js:66"},{message:"unknown tag: alt",line:" src/events/keyboard.js:107"},{message:"unknown tag: alt",line:" src/events/keyboard.js:194"},{message:"unknown tag: alt",line:" src/events/keyboard.js:246"},{message:"unknown tag: alt",line:" src/events/keyboard.js:310"},{message:"unknown tag: alt",line:" src/events/mouse.js:12"},{message:"unknown tag: alt",line:" src/events/mouse.js:44"},{message:"unknown tag: alt",line:" src/events/mouse.js:82"},{message:"unknown tag: alt",line:" src/events/mouse.js:109"},{message:"unknown tag: alt",line:" src/events/mouse.js:136"},{message:"unknown tag: alt",line:" src/events/mouse.js:169"},{message:"unknown tag: alt",line:" src/events/mouse.js:201"},{message:"unknown tag: alt",line:" src/events/mouse.js:240"},{message:"unknown tag: alt",line:" src/events/mouse.js:279"},{message:"unknown tag: alt",line:" src/events/mouse.js:320"},{message:"unknown tag: alt",line:" src/events/mouse.js:362"},{message:"unknown tag: alt",line:" src/events/mouse.js:401"},{message:"unknown tag: alt",line:" src/events/mouse.js:494"},{message:"unknown tag: alt",line:" src/events/mouse.js:549"},{message:"unknown tag: alt",line:" src/events/mouse.js:630"},{message:"unknown tag: alt",line:" src/events/mouse.js:712"},{message:"unknown tag: alt",line:" src/events/mouse.js:790"},{message:"unknown tag: alt",line:" src/events/mouse.js:860"},{message:"unknown tag: alt",line:" src/events/mouse.js:945"},{message:"unknown tag: alt",line:" src/events/mouse.js:999"},{message:"unknown tag: alt",line:" src/events/mouse.js:1046"},{message:"unknown tag: alt",line:" src/events/touch.js:10"},{message:"unknown tag: alt",line:" src/events/touch.js:71"},{message:"unknown tag: alt",line:" src/events/touch.js:151"},{message:"unknown tag: alt",line:" src/events/touch.js:224"},{message:"unknown tag: alt",line:" src/image/image.js:22"},{message:"unknown tag: alt",line:" src/image/image.js:102"},{message:"unknown tag: alt",line:" src/image/image.js:246"},{message:"unknown tag: alt",line:" src/image/loading_displaying.js:16"},{message:"replacing incorrect tag: returns with return",line:" src/image/loading_displaying.js:230"},{message:"unknown tag: alt",line:" src/image/loading_displaying.js:247"},{message:"unknown tag: alt",line:" src/image/loading_displaying.js:418"},{message:"unknown tag: alt",line:" src/image/loading_displaying.js:518"},{message:"unknown tag: alt",line:" src/image/loading_displaying.js:584"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:89"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:116"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:153"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:259"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:295"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:346"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:401"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:439"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:551"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:607"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:670"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:706"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:828"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:870"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:911"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:943"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:988"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:1024"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:1062"},{message:"unknown tag: alt",line:" src/image/p5.Image.js:1099"},{message:"unknown tag: alt",line:" src/image/pixels.js:12"},{message:"unknown tag: alt",line:" src/image/pixels.js:81"},{message:"unknown tag: alt",line:" src/image/pixels.js:175"},{message:"unknown tag: alt",line:" src/image/pixels.js:310"},{message:"unknown tag: alt",line:" src/image/pixels.js:497"},{message:"unknown tag: alt",line:" src/image/pixels.js:585"},{message:"unknown tag: alt",line:" src/image/pixels.js:622"},{message:"unknown tag: alt",line:" src/image/pixels.js:696"},{message:"unknown tag: alt",line:" src/io/files.js:18"},{message:"unknown tag: alt",line:" src/io/files.js:183"},{message:"unknown tag: alt",line:" src/io/files.js:294"},{message:"unknown tag: alt",line:" src/io/files.js:604"},{message:"replacing incorrect tag: returns with return",line:" src/io/files.js:715"},{message:"unknown tag: alt",line:" src/io/files.js:715"},{message:"unknown tag: alt",line:" src/io/files.js:1556"},{message:"unknown tag: alt",line:" src/io/files.js:1614"},{message:"unknown tag: alt",line:" src/io/files.js:1679"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:85"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:149"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:197"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:243"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:292"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:357"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:552"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:605"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:647"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:906"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:971"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:1021"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:1067"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:1112"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:1159"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:1204"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:1257"},{message:"unknown tag: alt",line:" src/io/p5.Table.js:1321"},{message:"unknown tag: alt",line:" src/io/p5.TableRow.js:40"},{message:"unknown tag: alt",line:" src/io/p5.TableRow.js:102"},{message:"unknown tag: alt",line:" src/io/p5.TableRow.js:146"},{message:"unknown tag: alt",line:" src/io/p5.TableRow.js:191"},{message:"unknown tag: alt",line:" src/io/p5.TableRow.js:239"},{message:"unknown tag: alt",line:" src/io/p5.TableRow.js:295"},{message:"unknown tag: alt",line:" src/io/p5.XML.js:9"},{message:"unknown tag: alt",line:" src/math/calculation.js:10"},{message:"unknown tag: alt",line:" src/math/calculation.js:34"},{message:"unknown tag: alt",line:" src/math/calculation.js:74"},{message:"unknown tag: alt",line:" src/math/calculation.js:119"},{message:"unknown tag: alt",line:" src/math/calculation.js:184"},{message:"unknown tag: alt",line:" src/math/calculation.js:234"},{message:"unknown tag: alt",line:" src/math/calculation.js:273"},{message:"unknown tag: alt",line:" src/math/calculation.js:321"},{message:"unknown tag: alt",line:" src/math/calculation.js:377"},{message:"unknown tag: alt",line:" src/math/calculation.js:416"},{message:"unknown tag: alt",line:" src/math/calculation.js:472"},{message:"unknown tag: alt",line:" src/math/calculation.js:522"},{message:"unknown tag: alt",line:" src/math/calculation.js:572"},{message:"unknown tag: alt",line:" src/math/calculation.js:625"},{message:"unknown tag: alt",line:" src/math/calculation.js:660"},{message:"unknown tag: alt",line:" src/math/calculation.js:715"},{message:"unknown tag: alt",line:" src/math/calculation.js:760"},{message:"replacing incorrect tag: returns with return",line:" src/math/calculation.js:848"},{message:"unknown tag: alt",line:" src/math/calculation.js:848"},{message:"unknown tag: alt",line:" src/math/math.js:10"},{message:"unknown tag: alt",line:" src/math/noise.js:36"},{message:"unknown tag: alt",line:" src/math/noise.js:180"},{message:"unknown tag: alt",line:" src/math/noise.js:246"},{message:"unknown tag: alt",line:" src/math/p5.Vector.js:10"},{message:"unknown tag: alt",line:" src/math/random.js:37"},{message:"unknown tag: alt",line:" src/math/random.js:67"},{message:"unknown tag: alt",line:" src/math/random.js:155"},{message:"unknown tag: alt",line:" src/math/trigonometry.js:122"},{message:"unknown tag: alt",line:" src/math/trigonometry.js:158"},{message:"unknown tag: alt",line:" src/math/trigonometry.js:186"},{message:"unknown tag: alt",line:" src/math/trigonometry.js:214"},{message:"unknown tag: alt",line:" src/math/trigonometry.js:290"},{message:"replacing incorrect tag: returns with return",line:" src/math/trigonometry.js:326"},{message:"replacing incorrect tag: returns with return",line:" src/math/trigonometry.js:341"},{message:"replacing incorrect tag: returns with return",line:" src/math/trigonometry.js:356"},{message:"unknown tag: alt",line:" src/typography/attributes.js:11"},{message:"unknown tag: alt",line:" src/typography/attributes.js:82"},{message:"unknown tag: alt",line:" src/typography/attributes.js:120"},{message:"unknown tag: alt",line:" src/typography/attributes.js:152"},{message:"unknown tag: alt",line:" src/typography/attributes.js:189"},{message:"unknown tag: alt",line:" src/typography/loading_displaying.js:14"},{message:"unknown tag: alt",line:" src/typography/loading_displaying.js:138"},{message:"unknown tag: alt",line:" src/typography/loading_displaying.js:225"},{message:"unknown tag: alt",line:" src/typography/p5.Font.js:31"},{message:"unknown tag: alt",line:" src/utilities/conversion.js:10"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:13"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:42"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:130"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:239"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:313"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:375"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:453"},{message:"unknown tag: alt",line:" src/utilities/string_functions.js:540"},{message:"unknown tag: alt",line:" src/utilities/time_date.js:10"},{message:"unknown tag: alt",line:" src/utilities/time_date.js:32"},{message:"unknown tag: alt",line:" src/utilities/time_date.js:54"},{message:"unknown tag: alt",line:" src/utilities/time_date.js:76"},{message:"unknown tag: alt",line:" src/utilities/time_date.js:104"},{message:"unknown tag: alt",line:" src/utilities/time_date.js:127"},{message:"unknown tag: alt",line:" src/utilities/time_date.js:149"},{message:"unknown tag: alt",line:" src/webgl/3d_primitives.js:13"},{message:"unknown tag: alt",line:" src/webgl/interaction.js:11"},{message:"unknown tag: alt",line:" src/webgl/interaction.js:145"},{message:"unknown tag: alt",line:" src/webgl/interaction.js:145"},{message:"unknown tag: alt",line:" src/webgl/interaction.js:145"},{message:"unknown tag: alt",line:" src/webgl/interaction.js:145"},{message:"unknown tag: alt",line:" src/webgl/interaction.js:145"},{message:"unknown tag: alt",line:" src/webgl/interaction.js:353"},{message:"unknown tag: alt",line:" src/webgl/light.js:10"},{message:"unknown tag: alt",line:" src/webgl/light.js:92"},{message:"unknown tag: alt",line:" src/webgl/light.js:177"},{message:"unknown tag: alt",line:" src/webgl/light.js:281"},{message:"unknown tag: alt",line:" src/webgl/light.js:389"},{message:"unknown tag: alt",line:" src/webgl/light.js:420"},{message:"unknown tag: alt",line:" src/webgl/light.js:506"},{message:"unknown tag: alt",line:" src/webgl/light.js:846"},{message:"unknown tag: alt",line:" src/webgl/loading.js:12"},{message:"unknown tag: alt",line:" src/webgl/loading.js:12"},{message:"unknown tag: alt",line:" src/webgl/loading.js:579"},{message:"unknown tag: alt",line:" src/webgl/material.js:12"},{message:"replacing incorrect tag: returns with return",line:" src/webgl/material.js:111"},{message:"unknown tag: alt",line:" src/webgl/material.js:111"},{message:"unknown tag: alt",line:" src/webgl/material.js:179"},{message:"unknown tag: alt",line:" src/webgl/material.js:283"},{message:"unknown tag: alt",line:" src/webgl/material.js:322"},{message:"unknown tag: alt",line:" src/webgl/material.js:423"},{message:"unknown tag: alt",line:" src/webgl/material.js:423"},{message:"unknown tag: alt",line:" src/webgl/material.js:502"},{message:"unknown tag: alt",line:" src/webgl/material.js:575"},{message:"unknown tag: alt",line:" src/webgl/material.js:655"},{message:"unknown tag: alt",line:" src/webgl/material.js:707"},{message:"unknown tag: alt",line:" src/webgl/material.js:757"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:13"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:113"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:174"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:231"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:320"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:653"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:712"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:770"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:918"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:990"},{message:"unknown tag: alt",line:" src/webgl/p5.Camera.js:1255"},{message:"replacing incorrect tag: returns with return",line:" src/webgl/p5.RendererGL.Immediate.js:178"},{message:"unknown tag: parem",line:" src/webgl/p5.RendererGL.Immediate.js:299"},{message:"replacing incorrect tag: returns with return",line:" src/webgl/p5.RendererGL.Retained.js:8"},{message:"unknown tag: alt",line:" src/webgl/p5.RendererGL.js:331"},{message:"unknown tag: alt",line:" src/webgl/p5.RendererGL.js:600"},{message:"unknown tag: alt",line:" src/webgl/p5.RendererGL.js:642"},{message:"unknown tag: alt",line:" src/webgl/p5.RendererGL.js:751"},{message:"unknown tag: alt",line:" src/webgl/p5.Shader.js:293"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:115"},{message:"replacing incorrect tag: returns with return",line:" src/webgl/text.js:158"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:191"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:203"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:236"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:250"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:388"},{message:"replacing incorrect tag: returns with return",line:" src/webgl/text.js:388"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:456"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:471"},{message:"replacing incorrect tag: function with method",line:" src/webgl/text.js:556"},{message:"replacing incorrect tag: params with param",line:" lib/addons/p5.sound.js:4374"},{message:"replacing incorrect tag: returns with return",line:" lib/addons/p5.sound.js:4374"},{message:"replacing incorrect tag: returns with return",line:" lib/addons/p5.sound.js:5085"},{message:"replacing incorrect tag: returns with return",line:" lib/addons/p5.sound.js:7837"},{message:"replacing incorrect tag: returns with return",line:" lib/addons/p5.sound.js:9005"},{message:"Missing item type\nConversions adapted from .\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:19"},{message:"Missing item type\nConvert an HSBA array to RGBA.",line:" src/color/color_conversion.js:45"},{message:"Missing item type\nConvert an HSLA array to HSBA.",line:" src/color/color_conversion.js:100"},{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:123"},{message:"Missing item type\nConvert an RGBA array to HSBA.",line:" src/color/color_conversion.js:187"},{message:"Missing item type\nConvert an RGBA array to HSLA.",line:" src/color/color_conversion.js:226"},{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:422"},{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:453"},{message:"Missing item type\nCSS named colors.",line:" src/color/p5.Color.js:472"},{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:626"},{message:"Missing item type\nFull color string patterns. The capture groups are necessary.",line:" src/color/p5.Color.js:639"},{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:776"},{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:988"},{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:14"},{message:"Missing item type\nReturns the current framerate.",line:" src/core/environment.js:307"},{message:'Missing item type\nSpecifies the number of frames to be displayed every second. For example,\nthe function call frameRate(30) will attempt to refresh 30 times a second.\nIf the processor is not fast enough to maintain the specified rate, the\nframe rate will not be achieved. Setting the frame rate within setup() is\nrecommended. The default rate is 60 frames per second.\n\nCalling frameRate() with no arguments returns the current framerate.',line:" src/core/environment.js:317"},{message:"Missing item type",line:" src/core/error_helpers.js:1"},{message:'Missing item type\nValidates parameters\nparam {String} func the name of the function\nparam {Array} args user input arguments\n\nexample:\n const a;\n ellipse(10,10,a,5);\nconsole ouput:\n "It looks like ellipse received an empty variable in spot #2."\n\nexample:\n ellipse(10,"foo",5,5);\nconsole output:\n "ellipse was expecting a number for parameter #1,\n received "foo" instead."',line:" src/core/error_helpers.js:630"},{message:"Missing item type\nPrints out all the colors in the color pallete with white text.\nFor color blindness testing.",line:" src/core/error_helpers.js:691"},{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\nSet up our translation function, with loaded languages",line:" src/core/internationalization.js:22"},{message:"Missing item type",line:" src/core/legacy.js:1"},{message:"Missing item type\nHelper fxn for sharing pixel methods",line:" src/core/p5.Element.js:855"},{message:"Missing item type\nResize our canvas element.",line:" src/core/p5.Renderer.js:95"},{message:"Missing item type\nHelper fxn to check font type (system or otf)",line:" src/core/p5.Renderer.js:334"},{message:"Missing item type\nHelper fxn to measure ascent and descent.\nAdapted from http://stackoverflow.com/a/25355178",line:" src/core/p5.Renderer.js:386"},{message:"Missing item type\np5.Renderer2D\nThe 2D graphics canvas renderer class.\nextends p5.Renderer",line:" src/core/p5.Renderer2D.js:7"},{message:"Missing item type\nGenerate a cubic Bezier representing an arc on the unit circle of total\nangle `size` radians, beginning `start` radians above the x-axis. Up to\nfour of these curves are combined to make a full arc.\n\nSee www.joecridge.me/bezier.pdf for an explanation of the method.",line:" src/core/p5.Renderer2D.js:385"},{message:"Missing item type\nshim for Uint8ClampedArray.slice\n(allows arrayCopy to work with pixels[])\nwith thanks to http://halfpapstudios.com/blog/tag/html5-canvas/\nEnumerable set to false to protect for...in from\nUint8ClampedArray.prototype pollution.",line:" src/core/shim.js:18"},{message:"Missing item type\nthis is implementation of Object.assign() which is unavailable in\nIE11 and (non-Chrome) Android browsers.\nThe assign() method is used to copy the values of all enumerable\nown properties from one or more source objects to a target object.\nIt will return the target object.\nModified from https://github.com/ljharb/object.assign",line:" src/core/shim.js:39"},{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:202"},{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:393"},{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:433"},{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:548"},{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:615"},{message:"Missing item type\nHelper function for select and selectAll",line:" src/dom/dom.js:149"},{message:"Missing item type\nHelper function for getElement and getElements.",line:" src/dom/dom.js:165"},{message:"Missing item type\nHelpers for create methods.",line:" src/dom/dom.js:329"},{message:"Missing item type",line:" src/dom/dom.js:455"},{message:"Missing item type",line:" src/dom/dom.js:1081"},{message:"Missing item type",line:" src/dom/dom.js:1169"},{message:"Missing item type",line:" src/dom/dom.js:1208"},{message:"Missing item type",line:" src/dom/dom.js:3090"},{message:"Missing item type",line:" src/dom/dom.js:3156"},{message:"Missing item type",line:" src/dom/dom.js:3218"},{message:"Missing item type\n_updatePAccelerations updates the pAcceleration values",line:" src/events/acceleration.js:124"},{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:300"},{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:387"},{message:"Missing item type\nThis module defines the filters for use with image buffers.\n\nThis module is basically a collection of functions stored in an object\nas opposed to modules. The functions are destructive, modifying\nthe passed in canvas rather than creating a copy.\n\nGenerally speaking users of this module will use the Filters.apply method\non a canvas to create an effect.\n\nA number of functions are borrowed/adapted from\nhttp://www.html5rocks.com/en/tutorials/canvas/imagefilters/\nor the java processing implementation.",line:" src/image/filters.js:3"},{message:"Missing item type\nReturns the pixel buffer for a canvas",line:" src/image/filters.js:24"},{message:"Missing item type\nReturns a 32 bit number containing ARGB data at ith pixel in the\n1D array containing pixels data.",line:" src/image/filters.js:44"},{message:"Missing item type\nModifies pixels RGBA values to values contained in the data object.",line:" src/image/filters.js:65"},{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:85"},{message:"Missing item type\nReturns a blank ImageData object.",line:" src/image/filters.js:105"},{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:120"},{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:173"},{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:207"},{message:"Missing item type\nSets the alpha channel to entirely opaque. No parameter is used.",line:" src/image/filters.js:230"},{message:"Missing item type\nSets each pixel to its inverse value. No parameter is used.",line:" src/image/filters.js:246"},{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:261"},{message:"Missing item type\nreduces the bright areas in an image",line:" src/image/filters.js:293"},{message:"Missing item type\nincreases the bright areas in an image",line:" src/image/filters.js:381"},{message:'Missing item type\nThis module defines the p5 methods for the p5.Image class\nfor drawing images to the main display canvas.',line:" src/image/image.js:8"},{message:"Missing item type\nHelper function for loading GIF-based images",line:" src/image/loading_displaying.js:149"},{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:230"},{message:"Missing item type\nApply the current tint color to the input image, return the resulting\ncanvas.",line:" src/image/loading_displaying.js:547"},{message:'Missing item type\nThis module defines the p5.Image class and P5 methods for\ndrawing images to the main display canvas.',line:" src/image/p5.Image.js:9"},{message:"Missing item type\nHelper function for animating GIF-based images with time",line:" src/image/p5.Image.js:223"},{message:"Missing item type\nHelper fxn for sharing pixel methods",line:" src/image/p5.Image.js:250"},{message:'Missing item type\nGenerate a blob of file data as a url to prepare for download.\nAccepts an array of data, a filename, and an extension (optional).\nThis is a private function because it does not do any formatting,\nbut it is used by saveStrings, saveJSON, saveTable etc.',line:" src/io/files.js:1805"},{message:"Missing item type\nReturns a file extension, or another string\nif the provided parameter has no extension.",line:" src/io/files.js:1873"},{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:1906"},{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:1918"},{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\ncomma separated values, 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\nhere.
\nTo load files, use the loadTable method.
\nTo save tables to your computer, use the save method\n or the saveTable method.
\n\nPossible options include:\n\n- csv - parse the table as comma-separated values\n
- tsv - parse the table as tab-separated values\n
- header - this table has a header (title) row\n
',line:" src/io/p5.Table.js:9"},{message:"Missing item type\nMultiplies a vector by a scalar and returns a new vector.",line:" src/math/p5.Vector.js:1798"},{message:"Missing item type\nDivides a vector by a scalar and returns a new vector.",line:" src/math/p5.Vector.js:1825"},{message:"Missing item type\nCalculates the dot product of two vectors.",line:" src/math/p5.Vector.js:1852"},{message:"Missing item type\nCalculates the cross product of two vectors.",line:" src/math/p5.Vector.js:1866"},{message:"Missing item type\nCalculates the Euclidean distance between two points (considering a\npoint as a vector object).",line:" src/math/p5.Vector.js:1880"},{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:1895"},{message:"Missing item type\nHelper function to measure ascent and descent.",line:" src/typography/attributes.js:283"},{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:254"},{message:"Missing item type\nReturns an opentype path for the supplied string and position.",line:" src/typography/p5.Font.js:269"},{message:"Missing item type",line:" src/webgl/3d_primitives.js:301"},{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:956"},{message:"Missing item type\nDraw a line given two points",line:" src/webgl/3d_primitives.js:1356"},{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:170"},{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:279"},{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:306"},{message:"Missing item type\nThis function matches the `query` at the provided `offset`",line:" src/webgl/loading.js:333"},{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:345"},{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:435"},{message:"Missing item type",line:" src/webgl/material.js:802"},{message:"Missing item type",line:" src/webgl/material.js:833"},{message:"Missing item type\nCreate a 2D array for establishing stroke connections",line:" src/webgl/p5.Geometry.js:212"},{message:"Missing item type\nCreate 4 vertices for each stroke line, two at the beginning position\nand two at the end position. These vertices are displaced relative to\nthat line's normal on the GPU",line:" src/webgl/p5.Geometry.js:233"},{message:"Missing item type",line:" src/webgl/p5.Matrix.js:1"},{message:"Missing item type\nPRIVATE",line:" src/webgl/p5.Matrix.js:722"},{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:12"},{message:'Missing item type\nWelcome to RendererGL Immediate Mode.\nImmediate mode is used for drawing custom shapes\nfrom a set of vertices. Immediate Mode is activated\nwhen you call beginShape() & de-activated when you call endShape().\nImmediate mode is a style of programming borrowed\nfrom OpenGL\'s (now-deprecated) immediate mode.\nIt differs from p5.js\' default, Retained Mode, which caches\ngeometries and buffers on the CPU to reduce the number of webgl\ndraw calls. Retained mode is more efficient & performative,\nhowever, Immediate Mode is useful for sketching quick\ngeometric ideas.',line:" src/webgl/p5.RendererGL.Immediate.js:1"},{message:"Missing item type\nEnd shape drawing and render vertices to screen.",line:" src/webgl/p5.RendererGL.Immediate.js:106"},{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:144"},{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:178"},{message:"Missing item type\nCalled from _processVertices() when applicable. This function tesselates immediateMode.geometry.",line:" src/webgl/p5.RendererGL.Immediate.js:223"},{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:243"},{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:278"},{message:"Missing item type\nCalled from _drawImmediateFill(). Currently adds default normals which\nonly work for flat shapes.",line:" src/webgl/p5.RendererGL.Immediate.js:299"},{message:"Missing item type\ninitializes buffer defaults. runs each time a new geometry is\nregistered",line:" src/webgl/p5.RendererGL.Retained.js:8"},{message:"Missing item type\ncreates a buffers object that holds the WebGL render buffers\nfor a geometry.",line:" src/webgl/p5.RendererGL.Retained.js:59"},{message:"Missing item type\nDraws buffers given a geometry key ID",line:" src/webgl/p5.RendererGL.Retained.js:97"},{message:"Missing item type\nmodel view, projection, & normal\nmatrices",line:" src/webgl/p5.RendererGL.js:117"},{message:"Missing item type\n[background description]",line:" src/webgl/p5.RendererGL.js:583"},{message:"Missing item type\n[resize description]",line:" src/webgl/p5.RendererGL.js:864"},{message:"Missing item type\nclears color and depth buffers\nwith r,g,b,a",line:" src/webgl/p5.RendererGL.js:894"},{message:"Missing item type\n[translate description]",line:" src/webgl/p5.RendererGL.js:926"},{message:"Missing item type\nScales the Model View Matrix by a vector",line:" src/webgl/p5.RendererGL.js:945"},{message:"Missing item type\nturn a two dimensional array into one dimensional array",line:" src/webgl/p5.RendererGL.js:1363"},{message:"Missing item type\nturn a p5.Vector Array into a one dimensional number array",line:" src/webgl/p5.RendererGL.js:1400"},{message:"Missing item type\nensures that p5 is using a 3d renderer. throws an error if not.",line:" src/webgl/p5.RendererGL.js:1418"},{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\nThe p5.Effect class is built\n \tusing Tone.js CrossFade",line:" lib/addons/p5.sound.js:293"},{message:"Missing item type\nIn classes that extend\np5.Effect, connect effect nodes\nto the wet parameter",line:" lib/addons/p5.sound.js:300"},{message:"Missing item type",line:" lib/addons/p5.sound.js:451"},{message:"Missing item type\nUsed by Osc and Envelope to chain signal math",line:" lib/addons/p5.sound.js:688"},{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:2721"},{message:"Missing item type\nThis module has shims",line:" lib/addons/p5.sound.js:2969"},{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:3105"},{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:3555"},{message:"Missing item type\nStop playback on all of this soundfile's sources.",line:" lib/addons/p5.sound.js:4056"},{message:"Missing item type",line:" lib/addons/p5.sound.js:4590"},{message:"Missing item type\nEQFilter extends p5.Filter with constraints\nnecessary for the p5.EQ",line:" lib/addons/p5.sound.js:8235"},{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:9362"},{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:9557"},{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:10516"},{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:10534"},{message:"Missing item type\ncallback invoked when the recording is over",line:" lib/addons/p5.sound.js:11153"},{message:"Missing item type",line:" lib/addons/p5.sound.min.js:1"}],consts:{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"],SQUARE:["p5.strokeCap"],PROJECT:["p5.strokeCap"],ROUND:["p5.strokeCap","p5.strokeJoin"],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"],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"],VIDEO:["p5.createCapture"],AUDIO:["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"],BLUR:["p5.Image.filter","p5.filter"],ERODE:["p5.Image.filter","p5.filter"],DILATE:["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"],IMAGE:["p5.textureMode"],CLAMP:["p5.textureWrap"],REPEAT:["p5.textureWrap"],MIRROR:["p5.textureWrap"]}}},{}],2:[function(e,t,n){t.exports=function(e){if(Array.isArray(e))return e}},{}],3:[function(e,t,n){t.exports=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t0?i-4:i;for(n=0;n>16&255,c[d++]=t>>8&255,c[d++]=255&t;2===s&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[d++]=255&t);1===s&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[d++]=t>>8&255,c[d++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,o=n%3,r=[],i=16383,s=0,l=n-o;sl?l:s+i));1===o?r.push(a[(t=e[n-1])>>2]+a[t<<4&63]+"=="):2===o&&r.push(a[(t=(e[n-2]<<8)+e[n-1])>>10]+a[t>>4&63]+a[t<<2&63]+"=");return r.join("")};for(var a=[],o=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)a[s]=i[s],o[i.charCodeAt(s)]=s;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e,t,n){for(var o,r=[],i=t;i>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return r.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],21:[function(e,t,n){},{}],22:[function(e,t,n){(function(t){"use strict";var a=e("base64-js"),o=e("ieee754"),r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=t,n.SlowBuffer=function(e){+e!=e&&(e=0);return t.alloc(+e)},n.INSPECT_MAX_BYTES=50;var i=2147483647;function s(e){if(e>i)throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=new Uint8Array(e);return Object.setPrototypeOf(n,t.prototype),n}function t(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,n)}function l(e,n,a){if("string"==typeof e)return function(e,n){"string"==typeof n&&""!==n||(n="utf8");if(!t.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var a=0|h(e,n),o=s(a),r=o.write(e,n);r!==a&&(o=o.slice(0,r));return o}(e,n);if(ArrayBuffer.isView(e))return p(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(G(e,ArrayBuffer)||e&&G(e.buffer,ArrayBuffer))return function(e,n,a){if(n<0||e.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function h(e,n){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||G(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var a=e.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===a)return 0;for(var r=!1;;)switch(n){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return O(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a;case"hex":return a>>>1;case"base64":return F(e).length;default:if(r)return o?-1:O(e).length;n=(""+n).toLowerCase(),r=!0}}function m(e,t,n){var a=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return M(this,t,n);case"latin1":case"binary":return E(this,t,n);case"base64":return _(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(a)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}function f(e,t,n){var a=e[t];e[t]=e[n],e[n]=a}function g(e,n,a,o,r){if(0===e.length)return-1;if("string"==typeof a?(o=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),U(a=+a)&&(a=r?0:e.length-1),a<0&&(a=e.length+a),a>=e.length){if(r)return-1;a=e.length-1}else if(a<0){if(!r)return-1;a=0}if("string"==typeof n&&(n=t.from(n,o)),t.isBuffer(n))return 0===n.length?-1:b(e,n,a,o,r);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,n,a):Uint8Array.prototype.lastIndexOf.call(e,n,a):b(e,[n],a,o,r);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,a,o){var r,i=1,s=e.length,l=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return-1;i=2,s/=2,l/=2,n/=2}function c(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o){var d=-1;for(r=n;rs&&(n=s-l),r=n;r>=0;r--){for(var p=!0,u=0;uo&&(a=o):a=o;var r=t.length;a>r/2&&(a=r/2);for(var i=0;i>8,o.push(n%256),o.push(a);return o}(t,e.length-n),e,n,a)}function _(e,t,n){return a.fromByteArray(0===t&&n===e.length?e:e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var a=[],o=t;o239?4:c>223?3:c>191?2:1;if(o+p<=n)switch(p){case 1:c<128&&(d=c);break;case 2:128==(192&(r=e[o+1]))&&(l=(31&c)<<6|63&r)>127&&(d=l);break;case 3:i=e[o+2],128==(192&(r=e[o+1]))&&128==(192&i)&&(l=(15&c)<<12|(63&r)<<6|63&i)>2047&&(l<55296||l>57343)&&(d=l);break;case 4:i=e[o+2],s=e[o+3],128==(192&(r=e[o+1]))&&128==(192&i)&&128==(192&s)&&(l=(15&c)<<18|(63&r)<<12|(63&i)<<6|63&s)>65535&&l<1114112&&(d=l)}null===d?(d=65533,p=1):d>65535&&(a.push((d-=65536)>>>10&1023|55296),d=56320|1023&d),a.push(d),o+=p}return function(e){var t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);var n="",a=0;for(;at&&(e+=" ... "),""},r&&(t.prototype[r]=t.prototype.inspect),t.prototype.compare=function(e,n,a,o,r){if(G(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=0),void 0===a&&(a=e?e.length:0),void 0===o&&(o=0),void 0===r&&(r=this.length),n<0||a>e.length||o<0||r>this.length)throw new RangeError("out of range index");if(o>=r&&n>=a)return 0;if(o>=r)return-1;if(n>=a)return 1;if(this===e)return 0;for(var i=(r>>>=0)-(o>>>=0),s=(a>>>=0)-(n>>>=0),l=Math.min(i,s),c=this.slice(o,r),d=e.slice(n,a),p=0;p>>=0,isFinite(n)?(n>>>=0,void 0===a&&(a="utf8")):(a=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var r=!1;;)switch(a){case"hex":return y(this,e,t,n);case"utf8":case"utf-8":return v(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,n);default:if(r)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),r=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function M(e,t,n){var a="";n=Math.min(e.length,n);for(var o=t;oa)&&(n=a);for(var o="",r=t;rn)throw new RangeError("Trying to access beyond buffer length")}function D(e,n,a,o,r,i){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>r||ne.length)throw new RangeError("Index out of range")}function N(e,t,n,a,o,r){if(n+a>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function A(e,t,n,a,r){return t=+t,n>>>=0,r||N(e,0,n,4),o.write(e,t,n,a,23,4),n+4}function P(e,t,n,a,r){return t=+t,n>>>=0,r||N(e,0,n,8),o.write(e,t,n,a,52,8),n+8}t.prototype.slice=function(e,n){var a=this.length;(e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(n=void 0===n?a:~~n)<0?(n+=a)<0&&(n=0):n>a&&(n=a),n>>=0,t>>>=0,n||R(e,t,this.length);for(var a=this[e],o=1,r=0;++r>>=0,t>>>=0,n||R(e,t,this.length);for(var a=this[e+--t],o=1;t>0&&(o*=256);)a+=this[e+--t]*o;return a},t.prototype.readUInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||R(e,t,this.length);for(var a=this[e],o=1,r=0;++r=(o*=128)&&(a-=Math.pow(2,8*t)),a},t.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||R(e,t,this.length);for(var a=t,o=1,r=this[e+--a];a>0&&(o*=256);)r+=this[e+--a]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},t.prototype.readInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(e,t){e>>>=0,t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||R(e,4,this.length),o.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||R(e,4,this.length),o.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||R(e,8,this.length),o.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||R(e,8,this.length),o.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,n,a){(e=+e,t>>>=0,n>>>=0,a)||D(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,r=0;for(this[t]=255&e;++r>>=0,n>>>=0,a)||D(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,r=1;for(this[t+o]=255&e;--o>=0&&(r*=256);)this[t+o]=e/r&255;return t+n},t.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},t.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeIntLE=function(e,t,n,a){if(e=+e,t>>>=0,!a){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var r=0,i=1,s=0;for(this[t]=255&e;++r>>=0,!a){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var r=n-1,i=1,s=0;for(this[t+r]=255&e;--r>=0&&(i*=256);)e<0&&0===s&&0!==this[t+r+1]&&(s=1),this[t+r]=(e/i|0)-s&255;return t+n},t.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},t.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeFloatLE=function(e,t,n){return A(this,e,t,!0,n)},t.prototype.writeFloatBE=function(e,t,n){return A(this,e,t,!1,n)},t.prototype.writeDoubleLE=function(e,t,n){return P(this,e,t,!0,n)},t.prototype.writeDoubleBE=function(e,t,n){return P(this,e,t,!1,n)},t.prototype.copy=function(e,n,a,o){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(a||(a=0),o||0===o||(o=this.length),n>=e.length&&(n=e.length),n||(n=0),o>0&&o=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-n=0;--i)e[i+n]=this[i+a];else Uint8Array.prototype.set.call(e,this.subarray(a,o),n);return r},t.prototype.fill=function(e,n,a,o){if("string"==typeof e){if("string"==typeof n?(o=n,n=0,a=this.length):"string"==typeof a&&(o=a,a=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!t.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===e.length){var r=e.charCodeAt(0);("utf8"===o&&r<128||"latin1"===o)&&(e=r)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(n<0||this.length>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(i=n;i55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&r.push(239,191,189);continue}if(i+1===a){(t-=3)>-1&&r.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&r.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&r.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;r.push(n)}else if(n<2048){if((t-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;r.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function F(e){return a.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(e,t,n,a){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function G(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function U(e){return e!=e}var z=function(){for(var e="0123456789abcdef",t=new Array(256),n=0;n<16;++n)for(var a=16*n,o=0;o<16;++o)t[a+o]=e[n]+e[o];return t}()}).call(this,e("buffer").Buffer)},{"base64-js":20,buffer:22,ieee754:31}],23:[function(e,t,n){"use strict";t.exports=e("./").polyfill()},{"./":24}],24:[function(e,t,n){(function(a,o){!function(e,a){"object"==typeof n&&void 0!==t?t.exports=a():e.ES6Promise=a()}(this,(function(){"use strict";function t(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=0,i=void 0,s=void 0,l=function(e,t){f[r]=e,f[r+1]=t,2===(r+=2)&&(s?s(g):x())};var c="undefined"!=typeof window?window:void 0,d=c||{},p=d.MutationObserver||d.WebKitMutationObserver,u="undefined"==typeof self&&void 0!==a&&"[object process]"==={}.toString.call(a),h="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function m(){var e=setTimeout;return function(){return e(g,1)}}var f=new Array(1e3);function g(){for(var e=0;e0)n[a].substring(0,o)===e.lookupQuerystring&&(t=n[a].substring(o+1))}return t}};try{c="undefined"!==window&&null!==window.localStorage;var m="i18next.translate.boo";window.localStorage.setItem(m,"foo"),window.localStorage.removeItem(m)}catch(e){c=!1}var f={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&c){var n=window.localStorage.getItem(e.lookupLocalStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&c&&window.localStorage.setItem(t.lookupLocalStorage,e)}},g={name:"navigator",lookup:function(e){var t=[];if("undefined"!=typeof navigator){if(navigator.languages)for(var n=0;n0?t:void 0}},b={name:"htmlTag",lookup:function(e){var t,n=e.htmlTag||("undefined"!=typeof document?document.documentElement:null);return n&&"function"==typeof n.getAttribute&&(t=n.getAttribute("lang")),t}},y={name:"path",lookup:function(e){var t;if("undefined"!=typeof window){var n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(n instanceof Array)if("number"==typeof e.lookupFromPathIndex){if("string"!=typeof n[e.lookupFromPathIndex])return;t=n[e.lookupFromPathIndex].replace("/","")}else t=n[0].replace("/","")}return t}},v={name:"subdomain",lookup:function(e){var t;if("undefined"!=typeof window){var n=window.location.href.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/gi);n instanceof Array&&(t="number"==typeof e.lookupFromSubdomainIndex?n[e.lookupFromSubdomainIndex].replace("http://","").replace("https://","").replace(".",""):n[0].replace("http://","").replace("https://","").replace(".",""))}return t}};var w=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return r(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e,this.options=function(e){return s.call(l.call(arguments,1),(function(t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n])})),e}(t,this.options||{},{order:["querystring","cookie","localStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],checkWhitelist:!0}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(u),this.addDetector(h),this.addDetector(f),this.addDetector(g),this.addDetector(b),this.addDetector(y),this.addDetector(v)}},{key:"addDetector",value:function(e){this.detectors[e.name]=e}},{key:"detect",value:function(e){var t=this;e||(e=this.options.order);var n,a=[];if(e.forEach((function(e){if(t.detectors[e]){var n=t.detectors[e].lookup(t.options);n&&"string"==typeof n&&(n=[n]),n&&(a=a.concat(n))}})),a.forEach((function(e){if(!n){var a=t.services.languageUtils.formatLanguageCode(e);t.options.checkWhitelist&&!t.services.languageUtils.isWhitelisted(a)||(n=a)}})),!n){var o=this.i18nOptions.fallbackLng;"string"==typeof o&&(o=[o]),o||(o=[]),n="[object Array]"===Object.prototype.toString.apply(o)?o[0]:o[0]||o.default&&o.default[0]}return n}},{key:"cacheUserLanguage",value:function(e,t){var n=this;t||(t=this.options.caches),t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach((function(t){n.detectors[t]&&n.detectors[t].cacheUserLanguage(e,n.options)})))}}]),e}();w.type="languageDetector",t.exports=w},{"@babel/runtime/helpers/classCallCheck":28,"@babel/runtime/helpers/createClass":29}],28:[function(e,t,n){arguments[4][5][0].apply(n,arguments)},{dup:5}],29:[function(e,t,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],30:[function(e,t,n){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o=a(e("@babel/runtime/helpers/typeof")),r=a(e("@babel/runtime/helpers/objectSpread")),i=a(e("@babel/runtime/helpers/classCallCheck")),s=a(e("@babel/runtime/helpers/createClass")),l=a(e("@babel/runtime/helpers/possibleConstructorReturn")),c=a(e("@babel/runtime/helpers/getPrototypeOf")),d=a(e("@babel/runtime/helpers/assertThisInitialized")),p=a(e("@babel/runtime/helpers/inherits")),u=a(e("@babel/runtime/helpers/toConsumableArray")),h=a(e("@babel/runtime/helpers/slicedToArray")),m={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){var n;console&&console[e]&&(n=console)[e].apply(n,u(t))}},f=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,e),this.init(t,n)}return s(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||m,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1?t-1:0),a=1;a-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}for(var r="string"!=typeof t?[].concat(t):t.split(".");r.length>1;){if(o())return{};var i=a(r.shift());!e[i]&&n&&(e[i]=new n),e=e[i]}return o()?{}:{obj:e,k:a(r.shift())}}function x(e,t,n){var a=w(e,t,Object);a.obj[a.k]=n}function S(e,t){var n=w(e,t),a=n.obj;if(a)return a[n.k]}function k(e,t,n){var a=S(e,n);return void 0!==a?a:S(t,n)}function _(e,t,n){for(var a in t)a in e?"string"==typeof e[a]||e[a]instanceof String||"string"==typeof t[a]||t[a]instanceof String?n&&(e[a]=t[a]):_(e[a],t[a],n):e[a]=t[a];return e}function T(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var C={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function M(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return C[e]})):e}var E=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return i(this,t),n=l(this,c(t).call(this)),b.call(d(n)),n.data=e||{},n.options=a,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n}return p(t,e),s(t,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,r=[e,t];return n&&"string"!=typeof n&&(r=r.concat(n)),n&&"string"==typeof n&&(r=r.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(r=e.split(".")),S(this.data,r)}},{key:"addResource",value:function(e,t,n,a){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},r=this.options.keySeparator;void 0===r&&(r=".");var i=[e,t];n&&(i=i.concat(r?n.split(r):n)),e.indexOf(".")>-1&&(a=t,t=(i=e.split("."))[1]),this.addNamespaces(t),x(this.data,i,a),o.silent||this.emit("added",e,t,n,a)}},{key:"addResources",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var o in n)"string"!=typeof n[o]&&"[object Array]"!==Object.prototype.toString.apply(n[o])||this.addResource(e,t,o,n[o],{silent:!0});a.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,a,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},s=[e,t];e.indexOf(".")>-1&&(a=n,n=t,t=(s=e.split("."))[1]),this.addNamespaces(t);var l=S(this.data,s)||{};a?_(l,n,o):l=r({},l,n),x(this.data,s,l),i.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?r({},{},this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"toJSON",value:function(){return this.data}}]),t}(b),j={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,a,o){var r=this;return e.forEach((function(e){r.processors[e]&&(t=r.processors[e].process(t,n,a,o))})),t}},I={},R=function(e){function t(e){var n,a,o,r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i(this,t),n=l(this,c(t).call(this)),b.call(d(n)),a=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],o=e,r=d(n),a.forEach((function(e){o[e]&&(r[e]=o[e])})),n.options=s,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=g.create("translator"),n}return p(t,e),s(t,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=this.resolve(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}});return t&&void 0!==t.res}},{key:"extractFromKey",value:function(e,t){var n=t.nsSeparator||this.options.nsSeparator;void 0===n&&(n=":");var a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS;if(n&&e.indexOf(n)>-1){var r=e.split(n);(n!==a||n===a&&this.options.ns.indexOf(r[0])>-1)&&(o=r.shift()),e=r.join(a)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}},{key:"translate",value:function(e,t){var n=this;if("object"!==o(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=this.extractFromKey(e[e.length-1],t),s=i.key,l=i.namespaces,c=l[l.length-1],d=t.lng||this.language,p=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase())return p?c+(t.nsSeparator||this.options.nsSeparator)+s:s;var u=this.resolve(e,t),h=u&&u.res,m=u&&u.usedKey||s,f=u&&u.exactUsedKey||s,g=Object.prototype.toString.apply(h),b=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject;if(y&&h&&("string"!=typeof h&&"boolean"!=typeof h&&"number"!=typeof h)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(g)<0&&("string"!=typeof b||"[object Array]"!==g)){if(!t.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,h,t):"key '".concat(s," (").concat(this.language,")' returned an object instead of string.");if(a){var v="[object Array]"===g,w=v?[]:{},x=v?f:m;for(var S in h)if(Object.prototype.hasOwnProperty.call(h,S)){var k="".concat(x).concat(a).concat(S);w[S]=this.translate(k,r({},t,{joinArrays:!1,ns:l})),w[S]===k&&(w[S]=h[S])}h=w}}else if(y&&"string"==typeof b&&"[object Array]"===g)(h=h.join(b))&&(h=this.extendTranslation(h,e,t));else{var _=!1,T=!1;if(!this.isValidLookup(h)&&void 0!==t.defaultValue){if(_=!0,void 0!==t.count){var C=this.pluralResolver.getSuffix(d,t.count);h=t["defaultValue".concat(C)]}h||(h=t.defaultValue)}this.isValidLookup(h)||(T=!0,h=s);var M=t.defaultValue&&t.defaultValue!==h&&this.options.updateMissing;if(T||_||M){this.logger.log(M?"updateKey":"missingKey",d,c,s,M?t.defaultValue:h);var E=[],j=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&j&&j[0])for(var I=0;I1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!i.isValidLookup(t)){var l=i.extractFromKey(e,s),c=l.key;n=c;var d=l.namespaces;i.options.fallbackNS&&(d=d.concat(i.options.fallbackNS));var p=void 0!==s.count&&"string"!=typeof s.count,u=void 0!==s.context&&"string"==typeof s.context&&""!==s.context,h=s.lngs?s.lngs:i.languageUtils.toResolveHierarchy(s.lng||i.language,s.fallbackLng);d.forEach((function(e){i.isValidLookup(t)||(r=e,!I["".concat(h[0],"-").concat(e)]&&i.utils&&i.utils.hasLoadedNamespace&&!i.utils.hasLoadedNamespace(r)&&(I["".concat(h[0],"-").concat(e)]=!0,i.logger.warn('key "'.concat(n,'" for namespace "').concat(r,'" for languages "').concat(h.join(", "),"\" won't get resolved as namespace was not yet loaded"),"This means something IS WRONG in your application setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach((function(n){if(!i.isValidLookup(t)){o=n;var r,l,d=c,h=[d];if(i.i18nFormat&&i.i18nFormat.addLookupKeys)i.i18nFormat.addLookupKeys(h,c,n,e,s);else p&&(r=i.pluralResolver.getSuffix(n,s.count)),p&&u&&h.push(d+r),u&&h.push(d+="".concat(i.options.contextSeparator).concat(s.context)),p&&h.push(d+=r);for(;l=h.pop();)i.isValidLookup(t)||(a=l,t=i.getResource(n,e,l,s))}})))}))}})),{res:t,usedKey:n,exactUsedKey:a,usedLng:o,usedNS:r}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,a):this.resourceStore.getResource(e,t,n,a)}}]),t}(b);function D(e){return e.charAt(0).toUpperCase()+e.slice(1)}var N=function(){function e(t){i(this,e),this.options=t,this.whitelist=this.options.whitelist||!1,this.logger=g.create("languageUtils")}return s(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=D(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=D(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=D(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isWhitelisted",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitWhitelist)&&(e=this.getLanguagePartFromCode(e)),!this.whitelist||!this.whitelist.length||this.whitelist.indexOf(e)>-1}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,a=this.getFallbackCodes(t||this.options.fallbackLng||[],e),o=[],r=function(e){e&&(n.isWhitelisted(e)?o.push(e):n.logger.warn("rejecting non-whitelisted language code: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):"string"==typeof e&&r(this.formatLanguageCode(e)),a.forEach((function(e){o.indexOf(e)<0&&r(n.formatLanguageCode(e))})),o}}]),e}(),A=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he"],nr:[1,2,20,21],fc:22}],P={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0===e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1===e?0:2===e?1:(e<0||e>10)&&e%10==0?2:3)}};var L=function(){function e(t){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,e),this.languageUtils=t,this.options=a,this.logger=g.create("pluralResolver"),this.rules=(n={},A.forEach((function(e){e.lngs.forEach((function(t){n[t]={numbers:e.nr,plurals:P[e.fc]}}))})),n)}return s(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=this.getRule(e);return t&&t.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=this,a=[],o=this.getRule(e);return o?(o.numbers.forEach((function(o){var r=n.getSuffix(e,o);a.push("".concat(t).concat(r))})),a):a}},{key:"getSuffix",value:function(e,t){var n=this,a=this.getRule(e);if(a){var o=a.plurals(a.noAbs?t:Math.abs(t)),r=a.numbers[o];this.options.simplifyPluralSuffix&&2===a.numbers.length&&1===a.numbers[0]&&(2===r?r="plural":1===r&&(r=""));var i=function(){return n.options.prepend&&r.toString()?n.options.prepend+r.toString():r.toString()};return"v1"===this.options.compatibilityJSON?1===r?"":"number"==typeof r?"_plural_".concat(r.toString()):i():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===a.numbers.length&&1===a.numbers[0]?i():this.options.prepend&&o.toString()?this.options.prepend+o.toString():o.toString()}return this.logger.warn("no plural rule found for: ".concat(e)),""}}]),e}(),O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this.logger=g.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return s(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:M,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?T(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?T(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?T(t.nestingPrefix):t.nestingPrefixEscaped||T("$t("),this.nestingSuffix=t.nestingSuffix?T(t.nestingSuffix):t.nestingSuffixEscaped||T(")"),this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,a){var o,r,i,s=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var d=function(e){if(e.indexOf(s.formatSeparator)<0)return k(t,l,e);var a=e.split(s.formatSeparator),o=a.shift().trim(),r=a.join(s.formatSeparator).trim();return s.format(k(t,l,o),r,n)};this.resetRegExp();var p=a&&a.missingInterpolationHandler||this.options.missingInterpolationHandler;for(i=0;o=this.regexpUnescape.exec(e);){if(void 0===(r=d(o[1].trim())))if("function"==typeof p){var u=p(e,o,a);r="string"==typeof u?u:""}else this.logger.warn("missed to pass in variable ".concat(o[1]," for interpolating ").concat(e)),r="";else"string"==typeof r||this.useRawValueToEscape||(r=v(r));if(e=e.replace(o[0],c(r)),this.regexpUnescape.lastIndex=0,++i>=this.maxReplaces)break}for(i=0;o=this.regexp.exec(e);){if(void 0===(r=d(o[1].trim())))if("function"==typeof p){var h=p(e,o,a);r="string"==typeof h?h:""}else this.logger.warn("missed to pass in variable ".concat(o[1]," for interpolating ").concat(e)),r="";else"string"==typeof r||this.useRawValueToEscape||(r=v(r));if(r=c(this.escapeValue?this.escape(r):r),e=e.replace(o[0],r),this.regexp.lastIndex=0,++i>=this.maxReplaces)break}return e}},{key:"nest",value:function(e,t){var n,a,o=r({},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{});function i(e,t){if(e.indexOf(",")<0)return e;var n=e.split(",");e=n.shift();var a=n.join(",");a=(a=this.interpolate(a,o)).replace(/'/g,'"');try{o=JSON.parse(a),t&&(o=r({},t,o))}catch(t){this.logger.error("failed parsing options string in nesting for key ".concat(e),t)}return delete o.defaultValue,e}for(o.applyPostProcessor=!1,delete o.defaultValue;n=this.nestingRegexp.exec(e);){if((a=t(i.call(this,n[1].trim(),o),o))&&n[0]===e&&"string"!=typeof a)return a;"string"!=typeof a&&(a=v(a)),a||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),a=""),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}]),e}();var F=function(e){function t(e,n,a){var o,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return i(this,t),o=l(this,c(t).call(this)),b.call(d(o)),o.backend=e,o.store=n,o.services=a,o.languageUtils=a.languageUtils,o.options=r,o.logger=g.create("backendConnector"),o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(a,r.backend,r),o}return p(t,e),s(t,[{key:"queueLoad",value:function(e,t,n,a){var o=this,r=[],i=[],s=[],l=[];return e.forEach((function(e){var a=!0;t.forEach((function(t){var s="".concat(e,"|").concat(t);!n.reload&&o.store.hasResourceBundle(e,t)?o.state[s]=2:o.state[s]<0||(1===o.state[s]?i.indexOf(s)<0&&i.push(s):(o.state[s]=1,a=!1,i.indexOf(s)<0&&i.push(s),r.indexOf(s)<0&&r.push(s),l.indexOf(t)<0&&l.push(t)))})),a||s.push(e)})),(r.length||i.length)&&this.queue.push({pending:i,loaded:{},errors:[],callback:a}),{toLoad:r,pending:i,toLoadLanguages:s,toLoadNamespaces:l}}},{key:"loaded",value:function(e,t,n){var a=e.split("|"),o=h(a,2),r=o[0],i=o[1];t&&this.emit("failedLoading",r,i,t),n&&this.store.addResourceBundle(r,i,n),this.state[e]=t?-1:2;var s={};this.queue.forEach((function(n){var a,o,l,c,d;a=i,l=w(n.loaded,[r],Object),(c=l.obj)[d=l.k]=c[d]||[],o&&(c[d]=c[d].concat(a)),o||c[d].push(a),function(e,t){for(var n=e.indexOf(t);-1!==n;)e.splice(n,1),n=e.indexOf(t)}(n.pending,e),t&&n.errors.push(t),0!==n.pending.length||n.done||(Object.keys(n.loaded).forEach((function(e){s[e]||(s[e]=[]),n.loaded[e].length&&n.loaded[e].forEach((function(t){s[e].indexOf(t)<0&&s[e].push(t)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",s),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var a=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:250,i=arguments.length>5?arguments[5]:void 0;return e.length?this.backend[n](e,t,(function(s,l){s&&l&&o<5?setTimeout((function(){a.read.call(a,e,t,n,o+1,2*r,i)}),r):i(s,l)})):i(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var r=this.queueLoad(e,t,a,o);if(!r.toLoad.length)return r.pending.length||o(),null;r.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",a=e.split("|"),o=h(a,2),r=o[0],i=o[1];this.read(r,i,"read",null,null,(function(a,o){a&&t.logger.warn("".concat(n,"loading namespace ").concat(i," for language ").concat(r," failed"),a),!a&&o&&t.logger.log("".concat(n,"loaded namespace ").concat(i," for language ").concat(r),o),t.loaded(e,a,o)}))}},{key:"saveMissing",value:function(e,t,n,a,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" for namespace "').concat(t,'" as the namespace was not yet loaded'),"This means something IS WRONG in your application setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null!=n&&""!==n&&(this.backend&&this.backend.create&&this.backend.create(e,t,n,a,null,r({},i,{isUpdate:o})),e&&e[0]&&this.store.addResource(e[0],t,n,a))}}]),t}(b);function B(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&e.whitelist.indexOf("cimode")<0&&(e.whitelist=e.whitelist.concat(["cimode"])),e}function G(){}var U=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;if(i(this,t),e=l(this,c(t).call(this)),b.call(d(e)),e.options=B(n),e.services={},e.logger=g,e.modules={external:[]},a&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,a),l(e,d(e));setTimeout((function(){e.init(n,a)}),0)}return e}return p(t,e),s(t,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;function a(e){return e?"function"==typeof e?new e:e:null}if("function"==typeof t&&(n=t,t={}),this.options=r({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===o(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===o(e[2])||"object"===o(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",maxReplaces:1e3}},this.options,B(t)),this.format=this.options.interpolation.format,n||(n=G),!this.options.isClone){g.init(this.modules.logger?a(this.modules.logger):null,this.options);var i=new N(this.options);this.store=new E(this.options.resources,this.options);var s=this.services;s.logger=g,s.resourceStore=this.store,s.languageUtils=i,s.pluralResolver=new L(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),s.interpolator=new O(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new F(a(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(function(t){for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:G,a="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(a&&"cimode"===a.toLowerCase())return n();var o=[],r=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){o.indexOf(e)<0&&o.push(e)}))};if(a)r(a);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return r(e)}));this.options.preload&&this.options.preload.forEach((function(e){return r(e)})),this.services.backendConnector.load(o,this.options.ns,n)}else n(null)}},{key:"reloadResources",value:function(e,t,n){var a=y();return e||(e=this.languages),t||(t=this.options.ns),n||(n=G),this.services.backendConnector.reload(e,t,(function(e){a.resolve(),n(e)})),a}},{key:"use",value:function(e){return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&j.addPostProcessor(e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var a=y();this.emit("languageChanging",e);var o=function(e){e&&(n.language||(n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e)),n.translator.language||n.translator.changeLanguage(e),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(e)),n.loadResources(e,(function(o){!function(e,o){o?(n.language=o,n.languages=n.services.languageUtils.toResolveHierarchy(o),n.translator.changeLanguage(o),n.isLanguageChangingTo=void 0,n.emit("languageChanged",o),n.logger.log("languageChanged",o)):n.isLanguageChangingTo=void 0,a.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(o,e)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),a}},{key:"getFixedT",value:function(e,t){var n=this,a=function e(t,a){var i;if("object"!==o(a)){for(var s=arguments.length,l=new Array(s>2?s-2:0),c=2;c0?this.languages[0]:this.language),!e)return"rtl";return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>=0?"rtl":"ltr"}},{key:"createInstance",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}},{key:"cloneInstance",value:function(){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G,a=r({},this.options,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{isClone:!0}),o=new t(a);return["store","services","language"].forEach((function(t){o[t]=e[t]})),o.translator=new R(o.services,o.options),o.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a>1,d=-7,p=n?o-1:0,u=n?-1:1,h=e[t+p];for(p+=u,r=h&(1<<-d)-1,h>>=-d,d+=s;d>0;r=256*r+e[t+p],p+=u,d-=8);for(i=r&(1<<-d)-1,r>>=-d,d+=a;d>0;i=256*i+e[t+p],p+=u,d-=8);if(0===r)r=1-c;else{if(r===l)return i?NaN:Infinity*(h?-1:1);i+=Math.pow(2,a),r-=c}return(h?-1:1)*i*Math.pow(2,r-a)},n.write=function(e,t,n,a,o,r){var i,s,l,c=8*r-o-1,d=(1<>1,u=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=a?0:r-1,m=a?1:-1,f=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(s=isNaN(t)?1:0,i=d):(i=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-i))<1&&(i--,l*=2),(t+=i+p>=1?u/l:u*Math.pow(2,1-p))*l>=2&&(i++,l/=2),i+p>=d?(s=0,i=d):i+p>=1?(s=(t*l-1)*Math.pow(2,o),i+=p):(s=t*Math.pow(2,p-1)*Math.pow(2,o),i=0));o>=8;e[n+h]=255&s,h+=m,s/=256,o-=8);for(i=i<0;e[n+h]=255&i,h+=m,i/=256,c-=8);e[n+h-m]|=128*f}},{}],32:[function(e,t,n){"use strict";var a;function o(e,t){return e.b===t.b&&e.a===t.a}function r(e,t){return e.be?0:e)<=(n=0>n?0:n)?0===n?(t+a)/2:t+e/(e+n)*(a-t):a+n/(e+n)*(t-a)}function m(e){var t=v(e.b);return x(t,e.c),x(t.b,e.c),S(t,e.a),t}function f(e,t){var n=!1,a=!1;e!==t&&(t.a!==e.a&&(a=!0,_(t.a,e.a)),t.d!==e.d&&(n=!0,T(t.d,e.d)),w(t,e),a||(x(t,e.a),e.a.c=e),n||(S(t,e.d),e.d.a=e))}function g(e){var t=e.b,n=!1;e.d!==e.b.d&&(n=!0,T(e.d,e.b.d)),e.c===e?_(e.a,null):(e.b.d.a=te(e),e.a.c=e.c,w(e,te(e)),n||S(e,e.d)),t.c===t?(_(t.a,null),T(t.d,null)):(e.d.a=te(t),t.a.c=t.c,w(t,te(t))),k(e)}function b(e){var t=v(e),n=t.b;return w(t,e.e),t.a=e.b.a,x(n,t.a),t.d=n.d=e.d,t=t.b,w(e.b,te(e.b)),w(e.b,t),e.b.a=t.a,t.b.a.c=t.b,t.b.d=e.b.d,t.f=e.f,t.b.f=e.b.f,t}function y(e,t){var n=!1,a=v(e),o=a.b;return t.d!==e.d&&(n=!0,T(t.d,e.d)),w(a,e.e),w(o,t),a.a=e.b.a,o.a=t.a,a.d=o.d=e.d,e.d.a=o,n||S(a,e.d),a}function v(e){var t=new ee,n=new ee,a=e.b.h;return n.h=a,a.b.h=t,t.h=e,e.b.h=n,t.b=n,t.c=t,t.e=n,n.b=t,n.c=n,n.e=t}function w(e,t){var n=e.c,a=t.c;n.b.e=t,a.b.e=e,e.c=a,t.c=n}function x(e,t){var n=t.f,a=new ae(t,n);n.e=a,t.f=a,n=a.c=e;do{n.a=a,n=n.c}while(n!==e)}function S(e,t){var n=t.d,a=new $(t,n);n.b=a,t.d=a,a.a=e,a.c=t.c,n=e;do{n.d=a,n=n.e}while(n!==e)}function k(e){var t=e.h;t.b.h=e=e.b.h,e.b.h=t}function _(e,t){var n=e.c,a=n;do{a.a=t,a=a.c}while(a!==n);(a=e.e).f=n=e.f,n.e=a}function T(e,t){var n=e.a,a=n;do{a.d=t,a=a.e}while(a!==n);(a=e.b).d=n=e.d,n.b=a}function C(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t}var M=4e150;function E(e,t){e.f+=t.f,e.b.f+=t.b.f}function j(e,t,n){return n=n.a,(t=t.a).b.a===(e=e.a)?n.b.a===e?r(t.a,n.a)?0>=s(n.b.a,t.a,n.a):0<=s(t.b.a,n.a,t.a):0>=s(n.b.a,e,n.a):n.b.a===e?0<=s(t.b.a,e,t.a):(t=i(t.b.a,e,t.a))>=(e=i(n.b.a,e,n.a))}function I(e){e.a.i=null;var t=e.e;t.a.c=t.c,t.c.a=t.a,e.e=null}function R(e,t){g(e.a),e.c=!1,e.a=t,t.i=e}function D(e){var t=e.a.a;do{e=fe(e)}while(e.a.a===t);return e.c&&(R(e,t=y(me(e).a.b,e.a.e)),e=fe(e)),e}function N(e,t,n){var a=new he;return a.a=n,a.e=X(e.f,t.e,a),n.i=a}function A(e,t){switch(e.s){case 100130:return!!(1&t);case 100131:return 0!==t;case 100132:return 0t;case 100134:return 2<=t||-2>=t}return!1}function P(e){var t=e.a,n=t.d;n.c=e.d,n.a=t,I(e)}function L(e,t,n){for(e=t,t=t.a;e!==n;){e.c=!1;var a=me(e),o=a.a;if(o.a!==t.a){if(!a.c){P(e);break}R(a,o=y(t.c.b,o.b))}t.c!==o&&(f(te(o),o),f(t,o)),P(e),t=a.a,e=a}return t}function O(e,t,n,a,o,r){var i=!0;do{N(e,t,n.b),n=n.c}while(n!==a);for(null===o&&(o=me(t).a.b.c);(n=(a=me(t)).a.b).a===o.a;)n.c!==o&&(f(te(n),n),f(te(o),n)),a.f=t.f-n.f,a.d=A(e,a.f),t.b=!0,!i&&U(e,t)&&(E(n,o),I(t),g(o)),i=!1,t=a,o=n;t.b=!0,r&&V(e,t)}function F(e,t,n,a,o){var r=[t.g[0],t.g[1],t.g[2]];t.d=null,t.d=e.o&&e.o(r,n,a,e.c)||null,null===t.d&&(o?e.n||(K(e,100156),e.n=!0):t.d=n[0])}function B(e,t,n){var a=[null,null,null,null];a[0]=t.a.d,a[1]=n.a.d,F(e,t.a,a,[.5,.5,0,0],!1),f(t,n)}function G(e,t,n,a,o){var r=Math.abs(t.b-e.b)+Math.abs(t.a-e.a),i=Math.abs(n.b-e.b)+Math.abs(n.a-e.a),s=o+1;a[o]=.5*i/(r+i),a[s]=.5*r/(r+i),e.g[0]+=a[o]*t.g[0]+a[s]*n.g[0],e.g[1]+=a[o]*t.g[1]+a[s]*n.g[1],e.g[2]+=a[o]*t.g[2]+a[s]*n.g[2]}function U(e,t){var n=me(t),a=t.a,i=n.a;if(r(a.a,i.a)){if(0=u||r(d[c[u>>1]],d[c[u]])?pe(n,u):ue(n,u)),d[l]=null,p[l]=n.b,n.b=l}else for(n.c[-(l+1)]=null;0s(a.b.a,i.a,a.a))return!1;fe(t).b=t.b=!0,b(a.b),f(te(i),a)}return!0}function z(e,t){var n=me(t),a=t.a,p=n.a,u=a.a,m=p.a,g=a.b.a,y=p.b.a,v=new ae;if(s(g,e.a,u),s(y,e.a,m),u===m||Math.min(u.a,g.a)>Math.max(m.a,y.a))return!1;if(r(u,m)){if(0s(g,m,u))return!1;var w,x,S=g,k=u,_=y,T=m;if(r(S,k)||(w=S,S=k,k=w),r(_,T)||(w=_,_=T,T=w),r(S,_)||(w=S,S=_,_=w,w=k,k=T,T=w),r(_,k)?r(k,T)?(0>(w=i(S,_,k))+(x=i(_,k,T))&&(w=-w,x=-x),v.b=h(w,_.b,x,k.b)):(0>(w=s(S,_,k))+(x=-s(S,T,k))&&(w=-w,x=-x),v.b=h(w,_.b,x,T.b)):v.b=(_.b+k.b)/2,l(S,k)||(w=S,S=k,k=w),l(_,T)||(w=_,_=T,T=w),l(S,_)||(w=S,S=_,_=w,w=k,k=T,T=w),l(_,k)?l(k,T)?(0>(w=c(S,_,k))+(x=c(_,k,T))&&(w=-w,x=-x),v.a=h(w,_.a,x,k.a)):(0>(w=d(S,_,k))+(x=-d(S,T,k))&&(w=-w,x=-x),v.a=h(w,_.a,x,T.a)):v.a=(_.a+k.a)/2,r(v,e.a)&&(v.b=e.a.b,v.a=e.a.a),S=r(u,m)?u:m,r(S,v)&&(v.b=S.b,v.a=S.a),o(v,u)||o(v,m))return U(e,t),!1;if(!o(g,e.a)&&0<=s(g,e.a,v)||!o(y,e.a)&&0>=s(y,e.a,v)){if(y===e.a)return b(a.b),f(p.b,a),a=me(t=D(t)).a,L(e,me(t),n),O(e,t,te(a),a,a,!0),!0;if(g===e.a){b(p.b),f(a.e,te(p)),m=(u=n=t).a.b.a;do{u=fe(u)}while(u.a.b.a===m);return u=me(t=u).a.b.c,n.a=te(p),O(e,t,(p=L(e,n,null)).c,a.b.c,u,!0),!0}return 0<=s(g,e.a,v)&&(fe(t).b=t.b=!0,b(a.b),a.a.b=e.a.b,a.a.a=e.a.a),0>=s(y,e.a,v)&&(t.b=n.b=!0,b(p.b),p.a.b=e.a.b,p.a.a=e.a.a),!1}return b(a.b),b(p.b),f(te(p),a),a.a.b=v.b,a.a.a=v.a,a.a.h=re(e.e,a.a),p=[0,0,0,0],v=[u.d,g.d,m.d,y.d],(a=a.a).g[0]=a.g[1]=a.g[2]=0,G(a,u,g,p,0),G(a,m,y,p,2),F(e,a,v,p,!0),fe(t).b=t.b=n.b=!0,!1}function V(e,t){for(var n=me(t);;){for(;n.b;)t=n,n=me(n);if(!t.b&&(n=t,null===(t=fe(t))||!t.b))break;t.b=!1;var a,o=t.a,i=n.a;if(a=o.b.a!==i.b.a)e:{var l=me(a=t),c=a.a,d=l.a,p=void 0;if(r(c.b.a,d.b.a)){if(0>s(c.b.a,d.b.a,c.a)){a=!1;break e}fe(a).b=a.b=!0,p=b(c),f(d.b,p),p.d.c=a.d}else{if(0a.f&&(a.f*=2,a.c=le(a.c,a.f+1)),0===a.b?n=o:(n=a.b,a.b=a.c[a.b]),a.e[n]=t,a.c[n]=o,a.d[o]=n,a.h&&ue(a,o),n}return a=e.a++,e.c[a]=t,-(a+1)}function ie(e){if(0===e.a)return de(e.b);var t=e.c[e.d[e.a-1]];if(0!==e.b.a&&r(ce(e.b),t))return de(e.b);do{--e.a}while(0e.a||r(a[s],a[c])){n[i]=s,o[s]=i;break}n[i]=c,o[c]=i,i=l}}function ue(e,t){for(var n=e.d,a=e.e,o=e.c,i=t,s=n[i];;){var l=i>>1,c=n[l];if(0===l||r(a[c],a[s])){n[i]=s,o[s]=i;break}n[i]=c,o[c]=i,i=l}}function he(){this.e=this.a=null,this.f=0,this.c=this.b=this.h=this.d=!1}function me(e){return e.e.c.b}function fe(e){return e.e.a.b}(a=Z.prototype).x=function(){Q(this,J)},a.B=function(e,t){switch(e){case 100142:return;case 100140:switch(t){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=t)}break;case 100141:return void(this.m=!!t);default:return void K(this,100900)}K(this,100901)},a.y=function(e){switch(e){case 100142:return 0;case 100140:return this.s;case 100141:return this.m;default:K(this,100900)}return!1},a.A=function(e,t,n){this.j[0]=e,this.j[1]=t,this.j[2]=n},a.z=function(e,t){var n=t||null;switch(e){case 100100:case 100106:this.h=n;break;case 100104:case 100110:this.l=n;break;case 100101:case 100107:this.k=n;break;case 100102:case 100108:this.i=n;break;case 100103:case 100109:this.p=n;break;case 100105:case 100111:this.o=n;break;case 100112:this.r=n;break;default:K(this,100900)}},a.C=function(e,t){var n=!1,a=[0,0,0];Q(this,2);for(var o=0;3>o;++o){var r=e[o];-1e150>r&&(r=-1e150,n=!0),1e150d;++d){var h=c.g[d];hn[d]&&(n[d]=h,i[d]=c)}if(c=0,n[1]-a[1]>n[0]-a[0]&&(c=1),n[2]-a[2]>n[c]-a[c]&&(c=2),a[c]>=n[c])t[0]=0,t[1]=0,t[2]=1;else{for(n=0,a=l[c],l=[0,0,0],a=[a.g[0]-(i=i[c]).g[0],a.g[1]-i.g[1],a.g[2]-i.g[2]],d=[0,0,0],c=e.e;c!==e;c=c.e)d[0]=c.g[0]-i.g[0],d[1]=c.g[1]-i.g[1],d[2]=c.g[2]-i.g[2],l[0]=a[1]*d[2]-a[2]*d[1],l[1]=a[2]*d[0]-a[0]*d[2],l[2]=a[0]*d[1]-a[1]*d[0],(h=l[0]*l[0]+l[1]*l[1]+l[2]*l[2])>n&&(n=h,t[0]=l[0],t[1]=l[1],t[2]=l[2]);0>=n&&(t[0]=t[1]=t[2]=0,t[C(a)]=1)}e=!0}for(n=((l=C(t))+1)%3,i=(l+2)%3,l=0=(n=c.a).f))do{t+=(n.a.b-n.b.a.b)*(n.a.a+n.b.a.a),n=n.e}while(n!==c.a);if(0>t)for(e=(t=this.b.c).e;e!==t;e=e.e)e.a=-e.a}for(this.n=!1,c=(t=this.b.b).h;c!==t;c=e)e=c.h,n=c.e,o(c.a,c.b.a)&&c.e.e!==c&&(B(this,n,c),g(c),n=(c=n).e),n.e===c&&(n!==c&&(n!==e&&n!==e.b||(e=e.h),g(n)),c!==e&&c!==e.b||(e=e.h),g(c));for(this.e=t=new oe,c=(e=this.b.c).e;c!==e;c=c.e)c.h=re(t,c);for(function(e){e.d=[];for(var t=0;t=s(n.a,n.b.a,n.e.b.a));)n=(i=y(n.e,n)).b;n=n.c.b}else{for(;n.e!==c&&(u(c.c.b)||0<=s(c.b.a,c.a,c.c.b.a));)c=(i=y(c,c.c.b)).b;c=c.e}for(;n.e.e!==c;)n=(i=y(n.e,n)).b}if(this.h||this.i||this.k||this.l)if(this.m){for(e=(t=this.b).a.b;e!==t.a;e=e.b)if(e.c){this.h&&this.h(2,this.c),c=e.a;do{this.k&&this.k(c.a.d,this.c),c=c.e}while(c!==e.a);this.i&&this.i(this.c)}}else{for(e=!!this.l,c=!1,n=-1,i=(t=this.b).a.d;i!==t.a;i=i.d)if(i.c){c||(this.h&&this.h(4,this.c),c=!0),l=i.a;do{e&&(n!==(a=l.b.d.c?0:1)&&(n=a,this.l&&this.l(!!n,this.c))),this.k&&this.k(l.a.d,this.c),l=l.e}while(l!==i.a)}c&&this.i&&this.i(this.c)}if(this.r){for(c=(t=this.b).a.b;c!==t.a;c=e)if(e=c.b,!c.c){i=(n=c.a).e,l=void 0;do{i=(l=i).e,l.d=null,null===l.b.d&&(l.c===l?_(l.a,null):(l.a.c=l.c,w(l,te(l))),(a=l.b).c===a?_(a.a,null):(a.a.c=a.c,w(a,te(a))),k(l))}while(l!==n);n=c.d,(c=c.b).d=n,n.b=c}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},this.libtess={GluTesselator:Z,windingRule:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},errorType:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},gluEnum:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},Z.prototype.gluDeleteTess=Z.prototype.x,Z.prototype.gluTessProperty=Z.prototype.B,Z.prototype.gluGetTessProperty=Z.prototype.y,Z.prototype.gluTessNormal=Z.prototype.A,Z.prototype.gluTessCallback=Z.prototype.z,Z.prototype.gluTessVertex=Z.prototype.C,Z.prototype.gluTessBeginPolygon=Z.prototype.u,Z.prototype.gluTessBeginContour=Z.prototype.t,Z.prototype.gluTessEndContour=Z.prototype.v,Z.prototype.gluTessEndPolygon=Z.prototype.w,void 0!==t&&(t.exports=this.libtess)},{}],33:[function(e,t,n){"use strict";function a(e,t,n,a){for(var o=e[t++],r=1<>=l,d-=l,g!==r){if(g===i)break;for(var b=gr;)v=m[v]>>8,++y;var w=v;if(u+y+(b!==g?1:0)>a)return void console.log("Warning, gif stream longer than expected.");n[u++]=w;var x=u+=y;for(b!==g&&(n[u++]=w),v=b;y--;)n[--x]=255&(v=m[v]),v>>=8;null!==f&&s<4096&&(m[s++]=f<<8|w,s>=c+1&&l<12&&(++l,c=c<<1|1)),f=g}else s=i+1,c=(1<<(l=o+1))-1,f=null}return u!==a&&console.log("Warning, gif stream shorter than expected."),n}try{n.GifWriter=function(e,t,n,a){var o=0,r=void 0===(a=void 0===a?{}:a).loop?null:a.loop,i=void 0===a.palette?null:a.palette;if(t<=0||n<=0||t>65535||n>65535)throw new Error("Width/Height invalid.");function s(e){var t=e.length;if(t<2||t>256||t&t-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return t}e[o++]=71,e[o++]=73,e[o++]=70,e[o++]=56,e[o++]=57,e[o++]=97;var l=0,c=0;if(null!==i){for(var d=s(i);d>>=1;)++l;if(d=1<=d)throw new Error("Background index out of range.");if(0===c)throw new Error("Background index explicitly passed as 0.")}}if(e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&n,e[o++]=n>>8&255,e[o++]=(null!==i?128:0)|l,e[o++]=c,e[o++]=0,null!==i)for(var p=0,u=i.length;p>16&255,e[o++]=h>>8&255,e[o++]=255&h}if(null!==r){if(r<0||r>65535)throw new Error("Loop count invalid.");e[o++]=33,e[o++]=255,e[o++]=11,e[o++]=78,e[o++]=69,e[o++]=84,e[o++]=83,e[o++]=67,e[o++]=65,e[o++]=80,e[o++]=69,e[o++]=50,e[o++]=46,e[o++]=48,e[o++]=3,e[o++]=1,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=0}var m=!1;this.addFrame=function(t,n,a,r,l,c){if(!0===m&&(--o,m=!1),c=void 0===c?{}:c,t<0||n<0||t>65535||n>65535)throw new Error("x/y invalid.");if(a<=0||r<=0||a>65535||r>65535)throw new Error("Width/Height invalid.");if(l.length>=1;)++h;u=1<3)throw new Error("Disposal out of range.");var b=!1,y=0;if(null!=c.transparent&&(b=!0,(y=c.transparent)<0||y>=u))throw new Error("Transparent color index.");if((0!==g||b||0!==f)&&(e[o++]=33,e[o++]=249,e[o++]=4,e[o++]=g<<2|(!0===b?1:0),e[o++]=255&f,e[o++]=f>>8&255,e[o++]=y,e[o++]=0),e[o++]=44,e[o++]=255&t,e[o++]=t>>8&255,e[o++]=255&n,e[o++]=n>>8&255,e[o++]=255&a,e[o++]=a>>8&255,e[o++]=255&r,e[o++]=r>>8&255,e[o++]=!0===d?128|h-1:0,!0===d)for(var v=0,w=p.length;v>16&255,e[o++]=x>>8&255,e[o++]=255&x}return o=function(e,t,n,a){e[t++]=n;var o=t++,r=1<=n;)e[t++]=255&p,p>>=8,d-=8,t===o+256&&(e[o]=255,o=t++)}function h(e){p|=e<=8;)e[t++]=255&p,p>>=8,d-=8,t===o+256&&(e[o]=255,o=t++);4096===l?(h(r),l=s+1,c=n+1,f={}):(l>=1<>7&&(s=t,l=i,t+=3*i);var c=!0,d=[],p=0,u=null,h=0,m=null;for(this.width=n,this.height=o;c&&t=0))throw Error("Invalid block size");if(0===M)break;t+=M}break;case 249:if(4!==e[t++]||0!==e[t+4])throw new Error("Invalid graphics extension block.");var f=e[t++];p=e[t++]|e[t++]<<8,u=e[t++],1&f||(u=null),h=f>>2&7,t++;break;case 254:for(;;){if(!((M=e[t++])>=0))throw Error("Invalid block size");if(0===M)break;t+=M}break;default:throw new Error("Unknown graphic control label: 0x"+e[t-1].toString(16))}break;case 44:var g=e[t++]|e[t++]<<8,b=e[t++]|e[t++]<<8,y=e[t++]|e[t++]<<8,v=e[t++]|e[t++]<<8,w=e[t++],x=w>>6&1,S=1<<1+(7&w),k=s,_=l,T=!1;w>>7&&(T=!0,k=t,_=S,t+=3*S);var C=t;for(t++;;){var M;if(!((M=e[t++])>=0))throw Error("Invalid block size");if(0===M)break;t+=M}d.push({x:g,y:b,width:y,height:v,has_local_palette:T,palette_offset:k,palette_size:_,data_offset:C,data_length:t-C,transparent_index:u,interlaced:!!x,delay:p,disposal:h});break;case 59:c=!1;break;default:throw new Error("Unknown gif block: 0x"+e[t-1].toString(16))}this.numFrames=function(){return d.length},this.loopCount=function(){return m},this.frameInfo=function(e){if(e<0||e>=d.length)throw new Error("Frame index out of range.");return d[e]},this.decodeAndBlitFrameBGRA=function(t,o){var r=this.frameInfo(t),i=r.width*r.height,s=new Uint8Array(i);a(e,r.data_offset,s,i);var l=r.palette_offset,c=r.transparent_index;null===c&&(c=256);var d=r.width,p=n-d,u=d,h=4*(r.y*n+r.x),m=4*((r.y+r.height)*n+r.x),f=h,g=4*p;!0===r.interlaced&&(g+=4*n*7);for(var b=8,y=0,v=s.length;y=m&&(g=4*p+4*n*(b-1),f=h+(d+p)*(b<<1),b>>=1)),w===c)f+=4;else{var x=e[l+3*w],S=e[l+3*w+1];o[f++]=e[l+3*w+2],o[f++]=S,o[f++]=x,o[f++]=255}--u}},this.decodeAndBlitFrameRGBA=function(t,o){var r=this.frameInfo(t),i=r.width*r.height,s=new Uint8Array(i);a(e,r.data_offset,s,i);var l=r.palette_offset,c=r.transparent_index;null===c&&(c=256);var d=r.width,p=n-d,u=d,h=4*(r.y*n+r.x),m=4*((r.y+r.height)*n+r.x),f=h,g=4*p;!0===r.interlaced&&(g+=4*n*7);for(var b=8,y=0,v=s.length;y=m&&(g=4*p+4*n*(b-1),f=h+(d+p)*(b<<1),b>>=1)),w===c)f+=4;else{var x=e[l+3*w+1],S=e[l+3*w+2];o[f++]=e[l+3*w],o[f++]=x,o[f++]=S,o[f++]=255}--u}}}}catch(e){}},{}],34:[function(e,t,n){(function(a){!function(e,a){a("object"==typeof n&&void 0!==t?n:e.opentype={})}(this,(function(t){"use strict";var n,o;String.prototype.codePointAt||(n=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}(),o=function(e){if(null==this)throw TypeError();var t=String(this),n=t.length,a=e?Number(e):0;if(a!=a&&(a=0),!(a<0||a>=n)){var o,r=t.charCodeAt(a);return r>=55296&&r<=56319&&n>a+1&&(o=t.charCodeAt(a+1))>=56320&&o<=57343?1024*(r-55296)+o-56320+65536:r}},n?n(String.prototype,"codePointAt",{value:o,configurable:!0,writable:!0}):String.prototype.codePointAt=o);var r=0,i=-3;function s(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function l(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new s,this.dtree=new s}var c=new s,d=new s,p=new Uint8Array(30),u=new Uint16Array(30),h=new Uint8Array(30),m=new Uint16Array(30),f=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),g=new s,b=new Uint8Array(320);function y(e,t,n,a){var o,r;for(o=0;o>>=1,t}function S(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,a+n}function k(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++o,n+=t.table[o],a-=t.table[o]}while(a>=0);return e.tag=r,e.bitcount-=o,t.trans[n+a]}function _(e,t,n){var a,o,r,i,s,l;for(a=S(e,5,257),o=S(e,5,1),r=S(e,4,4),i=0;i<19;++i)b[i]=0;for(i=0;i8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return i;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,r}!function(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}(c,d),y(p,u,4,3),y(h,m,2,1),p[28]=0,u[28]=258;var M=function(e,t){var n,a,o=new l(e,t);do{switch(n=x(o),S(o,2,0)){case 0:a=C(o);break;case 1:a=T(o,c,d);break;case 2:_(o,o.ltree,o.dtree),a=T(o,o.ltree,o.dtree);break;default:a=i}if(a!==r)throw new Error("Data error")}while(!n);return o.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},j.prototype.addX=function(e){this.addPoint(e,null)},j.prototype.addY=function(e){this.addPoint(null,e)},j.prototype.addBezier=function(e,t,n,a,o,r,i,s){var l=this,c=[e,t],d=[n,a],p=[o,r],u=[i,s];this.addPoint(e,t),this.addPoint(i,s);for(var h=0;h<=1;h++){var m=6*c[h]-12*d[h]+6*p[h],f=-3*c[h]+9*d[h]-9*p[h]+3*u[h],g=3*d[h]-3*c[h];if(0!==f){var b=Math.pow(m,2)-4*g*f;if(!(b<0)){var y=(-m+Math.sqrt(b))/(2*f);0=0&&a>0&&(n+=" "),n+=t(o)}return n}e=void 0!==e?e:2;for(var a="",o=0;o "},I.prototype.toDOMElement=function(e){var t=this.toPathData(e),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t),n};var N={fail:R,argument:D,assert:D},A=2147483648,P={},L={},O={};function F(e){return function(){return e}}L.BYTE=function(e){return N.argument(e>=0&&e<=255,"Byte value should be between 0 and 255."),[e]},O.BYTE=F(1),L.CHAR=function(e){return[e.charCodeAt(0)]},O.CHAR=F(1),L.CHARARRAY=function(e){for(var t=[],n=0;n>8&255,255&e]},O.USHORT=F(2),L.SHORT=function(e){return e>=32768&&(e=-(65536-e)),[e>>8&255,255&e]},O.SHORT=F(2),L.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},O.UINT24=F(3),L.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},O.ULONG=F(4),L.LONG=function(e){return e>=A&&(e=-(2*A-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},O.LONG=F(4),L.FIXED=L.ULONG,O.FIXED=O.ULONG,L.FWORD=L.SHORT,O.FWORD=O.SHORT,L.UFWORD=L.USHORT,O.UFWORD=O.USHORT,L.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},O.LONGDATETIME=F(8),L.TAG=function(e){return N.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},O.TAG=F(4),L.Card8=L.BYTE,O.Card8=O.BYTE,L.Card16=L.USHORT,O.Card16=O.USHORT,L.OffSize=L.BYTE,O.OffSize=O.BYTE,L.SID=L.USHORT,O.SID=O.USHORT,L.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?L.NUMBER16(e):L.NUMBER32(e)},O.NUMBER=function(e){return L.NUMBER(e).length},L.NUMBER16=function(e){return[28,e>>8&255,255&e]},O.NUMBER16=F(3),L.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},O.NUMBER32=F(5),L.REAL=function(e){var t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){var a=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*a)/a).toString()}for(var o="",r=0,i=t.length;r>8&255,t[t.length]=255&a}return t},O.UTF16=function(e){return 2*e.length};var B={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};P.MACSTRING=function(e,t,n,a){var o=B[a];if(void 0!==o){for(var r="",i=0;i=-128&&e<=127}function V(e,t,n){for(var a=0,o=e.length;t>8&255,l+256&255)}return r}L.MACSTRING=function(e,t){var n=function(e){if(!G)for(var t in G={},B)G[t]=new String(t);var n=G[e];if(void 0!==n){if(U){var a=U.get(n);if(void 0!==a)return a}var o=B[e];if(void 0!==o){for(var r={},i=0;i=128&&void 0===(r=n[r]))return;a[o]=r}return a}},O.MACSTRING=function(e,t){var n=L.MACSTRING(e,t);return void 0!==n?n.length:0},L.VARDELTAS=function(e){for(var t=0,n=[];t=-128&&a<=127?q(e,t,n):W(e,t,n)}return n},L.INDEX=function(e){for(var t=1,n=[t],a=[],o=0;o>8,t[p+1]=255&u,t=t.concat(a[d])}return t},O.TABLE=function(e){for(var t=0,n=e.fields.length,a=0;a0)return new se(this.data,this.offset+t).parseStruct(e)},se.prototype.parsePointer32=function(e){var t=this.parseOffset32();if(t>0)return new se(this.data,this.offset+t).parseStruct(e)},se.prototype.parseListOfLists=function(e){for(var t=this,n=this.parseOffset16List(),a=n.length,o=this.relativeOffset,r=new Array(a),i=0;i=0;o-=1){var r=ce.getUShort(e,t+4+8*o),i=ce.getUShort(e,t+4+8*o+2);if(3===r&&(0===i||1===i||10===i)||0===r&&(0===i||1===i||2===i||3===i||4===i)){a=ce.getULong(e,t+4+8*o+4);break}}if(-1===a)throw new Error("No valid cmap sub-tables found.");var s=new ce.Parser(e,t+a);if(n.format=s.parseUShort(),12===n.format)!function(e,t){var n;t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong(),e.groupCount=n=t.parseULong(),e.glyphIndexMap={};for(var a=0;a>1,t.skip("uShort",3),e.glyphIndexMap={};for(var i=new ce.Parser(n,a+o+14),s=new ce.Parser(n,a+o+16+2*r),l=new ce.Parser(n,a+o+16+4*r),c=new ce.Parser(n,a+o+16+6*r),d=a+o+16+8*r,p=0;p0;t-=1){if(e.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),n=!1;break}}var a=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:n?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:n?12:20}];n||(a=a.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),a=a.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var o=new te.Table("cmap",a);for(o.segments=[],t=0;t>4,r=15&a;if(15===o)break;if(t+=n[o],15===r)break;t+=n[r]}return parseFloat(t)}(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return 256*(t-247)+e.parseByte()+108;if(t>=251&&t<=254)return 256*-(t-251)-e.parseByte()-108;throw new Error("Invalid b0 "+t)}function je(e,t,n){var a=new ce.Parser(e,t=void 0!==t?t:0),o=[],r=[];for(n=void 0!==n?n:e.length;a.relativeOffset>1,u.length=0,m=!0}return function n(c){for(var y,S,k,_,T,C,M,E,j,I,R,D,N=0;N1&&!m&&(v=u.shift()+d,m=!0),b+=u.pop(),w(g,b);break;case 5:for(;u.length>0;)g+=u.shift(),b+=u.shift(),p.lineTo(g,b);break;case 6:for(;u.length>0&&(g+=u.shift(),p.lineTo(g,b),0!==u.length);)b+=u.shift(),p.lineTo(g,b);break;case 7:for(;u.length>0&&(b+=u.shift(),p.lineTo(g,b),0!==u.length);)g+=u.shift(),p.lineTo(g,b);break;case 8:for(;u.length>0;)a=g+u.shift(),o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),g=r+u.shift(),b=i+u.shift(),p.curveTo(a,o,r,i,g,b);break;case 10:T=u.pop()+l,(C=s[T])&&n(C);break;case 11:return;case 12:switch(A=c[N],N+=1,A){case 35:a=g+u.shift(),o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),M=r+u.shift(),E=i+u.shift(),j=M+u.shift(),I=E+u.shift(),R=j+u.shift(),D=I+u.shift(),g=R+u.shift(),b=D+u.shift(),u.shift(),p.curveTo(a,o,r,i,M,E),p.curveTo(j,I,R,D,g,b);break;case 34:a=g+u.shift(),o=b,r=a+u.shift(),i=o+u.shift(),M=r+u.shift(),E=i,j=M+u.shift(),I=i,R=j+u.shift(),D=b,g=R+u.shift(),p.curveTo(a,o,r,i,M,E),p.curveTo(j,I,R,D,g,b);break;case 36:a=g+u.shift(),o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),M=r+u.shift(),E=i,j=M+u.shift(),I=i,R=j+u.shift(),D=I+u.shift(),g=R+u.shift(),p.curveTo(a,o,r,i,M,E),p.curveTo(j,I,R,D,g,b);break;case 37:a=g+u.shift(),o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),M=r+u.shift(),E=i+u.shift(),j=M+u.shift(),I=E+u.shift(),R=j+u.shift(),D=I+u.shift(),Math.abs(R-g)>Math.abs(D-b)?g=R+u.shift():b=D+u.shift(),p.curveTo(a,o,r,i,M,E),p.curveTo(j,I,R,D,g,b);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+A),u.length=0}break;case 14:u.length>0&&!m&&(v=u.shift()+d,m=!0),f&&(p.closePath(),f=!1);break;case 19:case 20:x(),N+=h+7>>3;break;case 21:u.length>2&&!m&&(v=u.shift()+d,m=!0),b+=u.pop(),w(g+=u.pop(),b);break;case 22:u.length>1&&!m&&(v=u.shift()+d,m=!0),w(g+=u.pop(),b);break;case 24:for(;u.length>2;)a=g+u.shift(),o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),g=r+u.shift(),b=i+u.shift(),p.curveTo(a,o,r,i,g,b);g+=u.shift(),b+=u.shift(),p.lineTo(g,b);break;case 25:for(;u.length>6;)g+=u.shift(),b+=u.shift(),p.lineTo(g,b);a=g+u.shift(),o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),g=r+u.shift(),b=i+u.shift(),p.curveTo(a,o,r,i,g,b);break;case 26:for(u.length%2&&(g+=u.shift());u.length>0;)a=g,o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),g=r,b=i+u.shift(),p.curveTo(a,o,r,i,g,b);break;case 27:for(u.length%2&&(b+=u.shift());u.length>0;)a=g+u.shift(),o=b,r=a+u.shift(),i=o+u.shift(),g=r+u.shift(),p.curveTo(a,o,r,i,g,b=i);break;case 28:u.push(((y=c[N])<<24|(S=c[N+1])<<16)>>16),N+=2;break;case 29:T=u.pop()+e.gsubrsBias,(C=e.gsubrs[T])&&n(C);break;case 30:for(;u.length>0&&(a=g,o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),g=r+u.shift(),b=i+(1===u.length?u.shift():0),p.curveTo(a,o,r,i,g,b),0!==u.length);)a=g+u.shift(),o=b,r=a+u.shift(),i=o+u.shift(),b=i+u.shift(),g=r+(1===u.length?u.shift():0),p.curveTo(a,o,r,i,g,b);break;case 31:for(;u.length>0&&(a=g+u.shift(),o=b,r=a+u.shift(),i=o+u.shift(),b=i+u.shift(),g=r+(1===u.length?u.shift():0),p.curveTo(a,o,r,i,g,b),0!==u.length);)a=g,o=b+u.shift(),r=a+u.shift(),i=o+u.shift(),g=r+u.shift(),b=i+(1===u.length?u.shift():0),p.curveTo(a,o,r,i,g,b);break;default:A<32?console.log("Glyph "+t.index+": unknown operator "+A):A<247?u.push(A-139):A<251?(y=c[N],N+=1,u.push(256*(A-247)+y+108)):A<255?(y=c[N],N+=1,u.push(256*-(A-251)-y-108)):(y=c[N],S=c[N+1],k=c[N+2],_=c[N+3],N+=4,u.push((y<<24|S<<16|k<<8|_)/65536))}}}(n),t.advanceWidth=v,p}function Fe(e,t){var n,a=ue.indexOf(e);return a>=0&&(n=a),(a=t.indexOf(e))>=0?n=a+ue.length:(n=ue.length+t.length,t.push(e)),n}function Be(e,t,n){for(var a={},o=0;o=a)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+a+")");r.push(o)}else{if(3!==s)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+s);var c,d=i.parseCard16(),p=i.parseCard16();if(0!==p)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+p);for(var u=0;u=a)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+a+")");if(c>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+c);for(;p=1&&(n.ulCodePageRange1=a.parseULong(),n.ulCodePageRange2=a.parseULong()),n.version>=2&&(n.sxHeight=a.parseShort(),n.sCapHeight=a.parseShort(),n.usDefaultChar=a.parseUShort(),n.usBreakChar=a.parseUShort(),n.usMaxContent=a.parseUShort()),n},make:function(e){return new te.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)},unicodeRanges:lt,getUnicodeRange:function(e){for(var t=0;t=n.begin&&e=fe.length){var i=a.parseChar();n.names.push(a.parseString(i))}break;case 2.5:n.numberOfGlyphs=a.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var s=0;st.value.tag?1:-1})),t.fields=t.fields.concat(a),t.fields=t.fields.concat(o),t}function wt(e,t,n){for(var a=0;a0)return e.glyphs.get(o).getMetrics()}return n}function xt(e){for(var t=0,n=0;ng||void 0===t)&&g>0&&(t=g),c 123 are reserved for internal usage");h|=1<0?Xe.make(D):void 0,P=dt.make(),L=Ve.make(e.glyphs,{version:e.getEnglishName("version"),fullName:E,familyName:C,weightName:M,postScriptName:j,unitsPerEm:e.unitsPerEm,fontBBox:[0,v.yMin,v.ascender,v.advanceWidthMax]}),O=e.metas&&Object.keys(e.metas).length>0?ft.make(e.metas):void 0,F=[w,x,S,k,N,T,P,L,_];A&&F.push(A),e.tables.gsub&&F.push(mt.make(e.tables.gsub)),O&&F.push(O);for(var B=vt(F),G=bt(B.encode()),U=B.fields,z=!1,V=0;V>>1,r=e[o].tag;if(r===t)return o;r>>1,r=e[o];if(r===t)return o;r>>1,i=(n=e[r]).start;if(i===t)return n;i0)return t>(n=e[a-1]).end?0:n}function Ct(e,t){this.font=e,this.tableName=t}function Mt(e){Ct.call(this,e,"gpos")}function Et(e){Ct.call(this,e,"gsub")}function jt(e,t){var n=e.length;if(n!==t.length)return!1;for(var a=0;a0?(r=e.parseByte(),t&o||(r=-r),r=n+r):r=(t&o)>0?n:n+e.parseShort(),r}function At(e,t,n){var a,o,r=new ce.Parser(t,n);if(e.numberOfContours=r.parseShort(),e._xMin=r.parseShort(),e._yMin=r.parseShort(),e._xMax=r.parseShort(),e._yMax=r.parseShort(),e.numberOfContours>0){for(var i=e.endPointIndices=[],s=0;s0)for(var p=r.parseByte(),u=0;u0){var h,m=[];if(c>0){for(var f=0;f=0,m.push(h);for(var g=0,b=0;b0?(2&a)>0?(x.dx=r.parseShort(),x.dy=r.parseShort()):x.matchedPoints=[r.parseUShort(),r.parseUShort()]:(2&a)>0?(x.dx=r.parseChar(),x.dy=r.parseChar()):x.matchedPoints=[r.parseByte(),r.parseByte()],(8&a)>0?x.xScale=x.yScale=r.parseF2Dot14():(64&a)>0?(x.xScale=r.parseF2Dot14(),x.yScale=r.parseF2Dot14()):(128&a)>0&&(x.xScale=r.parseF2Dot14(),x.scale01=r.parseF2Dot14(),x.scale10=r.parseF2Dot14(),x.yScale=r.parseF2Dot14()),e.components.push(x),w=!!(32&a)}if(256&a){e.instructionLength=r.parseUShort(),e.instructions=[];for(var S=0;St.points.length-1||a.matchedPoints[1]>o.points.length-1)throw Error("Matched points out of range in "+t.name);var i=t.points[a.matchedPoints[0]],s=o.points[a.matchedPoints[1]],l={xScale:a.xScale,scale01:a.scale01,scale10:a.scale10,yScale:a.yScale,dx:0,dy:0};s=Pt([s],l)[0],l.dx=i.x-s.x,l.dy=i.y-s.y,r=Pt(o.points,l)}t.points=t.points.concat(r)}}return Lt(t.points)}Ct.prototype={searchTag:kt,binSearch:_t,getTable:function(e){var t=this.font.tables[this.tableName];return!t&&e&&(t=this.font.tables[this.tableName]=this.createDefaultTable()),t},getScriptNames:function(){var e=this.getTable();return e?e.scripts.map((function(e){return e.tag})):[]},getDefaultScriptName:function(){var e=this.getTable();if(e){for(var t=!1,n=0;n=0)return a[o].script;if(t){var r={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return a.splice(-1-o,0,r),r.script}}},getLangSysTable:function(e,t,n){var a=this.getScriptTable(e,n);if(a){if(!t||"dflt"===t||"DFLT"===t)return a.defaultLangSys;var o=kt(a.langSysRecords,t);if(o>=0)return a.langSysRecords[o].langSys;if(n){var r={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return a.langSysRecords.splice(-1-o,0,r),r.langSys}}},getFeatureTable:function(e,t,n,a){var o=this.getLangSysTable(e,t,a);if(o){for(var r,i=o.featureIndexes,s=this.font.tables[this.tableName].features,l=0;l=s[c-1].tag,"Features must be added in alphabetical order."),s.push(r={tag:n,feature:{params:0,lookupListIndexes:[]}}),i.push(c),r.feature}}},getLookupTables:function(e,t,n,a,o){var r=this.getFeatureTable(e,t,n,o),i=[];if(r){for(var s,l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups,d=0;d=0?n:-1;case 2:var a=Tt(e.ranges,t);return a?a.index+t-a.start:-1}},expandCoverage:function(e){if(1===e.format)return e.glyphs;for(var t=[],n=e.ranges,a=0;a=0){for(var d=r.ligatureSets[c],p=0;p=176&&n<=183)o+=n-176+1;else if(n>=184&&n<=191)o+=2*(n-184+1);else if(t&&1===r&&27===n)break}while(r>0);e.ip=o}function ln(e,n){t.DEBUG&&console.log(n.step,"SVTCA["+e.axis+"]"),n.fv=n.pv=n.dpv=e}function cn(e,n){t.DEBUG&&console.log(n.step,"SPVTCA["+e.axis+"]"),n.pv=n.dpv=e}function dn(e,n){t.DEBUG&&console.log(n.step,"SFVTCA["+e.axis+"]"),n.fv=e}function pn(e,n){var a,o,r=n.stack,i=r.pop(),s=r.pop(),l=n.z2[i],c=n.z1[s];t.DEBUG&&console.log("SPVTL["+e+"]",i,s),e?(a=l.y-c.y,o=c.x-l.x):(a=c.x-l.x,o=c.y-l.y),n.pv=n.dpv=en(a,o)}function un(e,n){var a,o,r=n.stack,i=r.pop(),s=r.pop(),l=n.z2[i],c=n.z1[s];t.DEBUG&&console.log("SFVTL["+e+"]",i,s),e?(a=l.y-c.y,o=c.x-l.x):(a=c.x-l.x,o=c.y-l.y),n.fv=en(a,o)}function hn(e){t.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function mn(e,n){var a=n.stack.pop(),o=n.z0[a],r=n.fv,i=n.pv;t.DEBUG&&console.log(n.step,"MDAP["+e+"]",a);var s=i.distance(o,nn);e&&(s=n.round(s)),r.setRelative(o,nn,s,i),r.touch(o),n.rp0=n.rp1=a}function fn(e,n){var a,o,r,i=n.z2,s=i.length-2;t.DEBUG&&console.log(n.step,"IUP["+e.axis+"]");for(var l=0;l1?"loop "+(n.loop-s)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",c)}n.loop=1}function bn(e,n){var a=(e?n.z0:n.z1)[e?n.rp1:n.rp2],o=n.fv,r=n.pv,i=n.stack.pop(),s=n.z2[n.contours[i]],l=s;t.DEBUG&&console.log(n.step,"SHC["+e+"]",i);var c=r.distance(a,a,!1,!0);do{l!==a&&o.setRelative(l,l,c,r),l=l.nextPointOnContour}while(l!==s)}function yn(e,n){var a,o,r=(e?n.z0:n.z1)[e?n.rp1:n.rp2],i=n.fv,s=n.pv,l=n.stack.pop();switch(t.DEBUG&&console.log(n.step,"SHZ["+e+"]",l),l){case 0:a=n.tZone;break;case 1:a=n.gZone;break;default:throw new Error("Invalid zone")}for(var c=s.distance(r,r,!1,!0),d=a.length-2,p=0;p",i),n.stack.push(Math.round(64*i))}function kn(e,n){var a=n.stack,o=a.pop(),r=n.fv,i=n.pv,s=n.ppem,l=n.deltaBase+16*(e-1),c=n.deltaShift,d=n.z0;t.DEBUG&&console.log(n.step,"DELTAP["+e+"]",o,a);for(var p=0;p>4)===s){var m=(15&h)-8;m>=0&&m++,t.DEBUG&&console.log(n.step,"DELTAPFIX",u,"by",m*c);var f=d[u];r.setRelative(f,f,m*c,i)}}}function _n(e,n){var a=n.stack,o=a.pop();t.DEBUG&&console.log(n.step,"ROUND[]"),a.push(64*n.round(o/64))}function Tn(e,n){var a=n.stack,o=a.pop(),r=n.ppem,i=n.deltaBase+16*(e-1),s=n.deltaShift;t.DEBUG&&console.log(n.step,"DELTAC["+e+"]",o,a);for(var l=0;l>4)===r){var p=(15&d)-8;p>=0&&p++;var u=p*s;t.DEBUG&&console.log(n.step,"DELTACFIX",c,"by",u),n.cvt[c]+=u}}}function Cn(e,n){var a,o,r=n.stack,i=r.pop(),s=r.pop(),l=n.z2[i],c=n.z1[s];t.DEBUG&&console.log(n.step,"SDPVTL["+e+"]",i,s),e?(a=l.y-c.y,o=c.x-l.x):(a=c.x-l.x,o=c.y-l.y),n.dpv=en(a,o)}function Mn(e,n){var a=n.stack,o=n.prog,r=n.ip;t.DEBUG&&console.log(n.step,"PUSHB["+e+"]");for(var i=0;i=0?1:-1,l=Math.abs(l),e&&(d=i.cvt[u],o&&Math.abs(l-d)":"_")+(o?"R":"_")+(0===r?"Gr":1===r?"Bl":2===r?"Wh":"")+"]",e?u+"("+i.cvt[u]+","+d+")":"",h,"(d =",s,"->",c*l,")"),i.rp1=i.rp0,i.rp2=h,n&&(i.rp0=h)}Vt.prototype.exec=function(e,n){if("number"!=typeof n)throw new Error("Point size is not a number!");if(!(this._errorState>2)){var a=this.font,o=this._prepState;if(!o||o.ppem!==n){var r=this._fpgmState;if(!r){on.prototype=an,(r=this._fpgmState=new on("fpgm",a.tables.fpgm)).funcs=[],r.font=a,t.DEBUG&&(console.log("---EXEC FPGM---"),r.step=-1);try{Bt(r)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}on.prototype=r,(o=this._prepState=new on("prep",a.tables.prep)).ppem=n;var i=a.tables.cvt;if(i)for(var s=o.cvt=new Array(i.length),l=n/a.unitsPerEm,c=0;c1))try{return Gt(e,o)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}}},Gt=function(e,n){var a,o,r,i=n.ppem/n.font.unitsPerEm,s=i,l=e.components;if(on.prototype=n,l){var c=n.font;o=[],a=[];for(var d=0;d1?"loop "+(e.loop-a)+": ":"")+"SHPIX[]",s,r),o.setRelative(l,l,r),o.touch(l)}e.loop=1},function(e){for(var n=e.stack,a=e.rp1,o=e.rp2,r=e.loop,i=e.z0[a],s=e.z1[o],l=e.fv,c=e.dpv,d=e.z2;r--;){var p=n.pop(),u=d[p];t.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"IP[]",p,a,"<->",o),l.interpolate(u,i,s,c),l.touch(u)}e.loop=1},vn.bind(void 0,0),vn.bind(void 0,1),function(e){for(var n=e.stack,a=e.z0[e.rp0],o=e.loop,r=e.fv,i=e.pv,s=e.z1;o--;){var l=n.pop(),c=s[l];t.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"ALIGNRP[]",l),r.setRelative(c,a,0,i),r.touch(c)}e.loop=1},function(e){t.DEBUG&&console.log(e.step,"RTDG[]"),e.round=Ht},wn.bind(void 0,0),wn.bind(void 0,1),function(e){var n=e.prog,a=e.ip,o=e.stack,r=n[++a];t.DEBUG&&console.log(e.step,"NPUSHB[]",r);for(var i=0;ia?1:0)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"GTEQ[]",a,o),n.push(o>=a?1:0)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"EQ[]",a,o),n.push(a===o?1:0)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"NEQ[]",a,o),n.push(a!==o?1:0)},function(e){var n=e.stack,a=n.pop();t.DEBUG&&console.log(e.step,"ODD[]",a),n.push(Math.trunc(a)%2?1:0)},function(e){var n=e.stack,a=n.pop();t.DEBUG&&console.log(e.step,"EVEN[]",a),n.push(Math.trunc(a)%2?0:1)},function(e){var n=e.stack.pop();t.DEBUG&&console.log(e.step,"IF[]",n),n||(sn(e,!0),t.DEBUG&&console.log(e.step,"EIF[]"))},function(e){t.DEBUG&&console.log(e.step,"EIF[]")},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"AND[]",a,o),n.push(a&&o?1:0)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"OR[]",a,o),n.push(a||o?1:0)},function(e){var n=e.stack,a=n.pop();t.DEBUG&&console.log(e.step,"NOT[]",a),n.push(a?0:1)},kn.bind(void 0,1),function(e){var n=e.stack.pop();t.DEBUG&&console.log(e.step,"SDB[]",n),e.deltaBase=n},function(e){var n=e.stack.pop();t.DEBUG&&console.log(e.step,"SDS[]",n),e.deltaShift=Math.pow(.5,n)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"ADD[]",a,o),n.push(o+a)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"SUB[]",a,o),n.push(o-a)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"DIV[]",a,o),n.push(64*o/a)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"MUL[]",a,o),n.push(o*a/64)},function(e){var n=e.stack,a=n.pop();t.DEBUG&&console.log(e.step,"ABS[]",a),n.push(Math.abs(a))},function(e){var n=e.stack,a=n.pop();t.DEBUG&&console.log(e.step,"NEG[]",a),n.push(-a)},function(e){var n=e.stack,a=n.pop();t.DEBUG&&console.log(e.step,"FLOOR[]",a),n.push(64*Math.floor(a/64))},function(e){var n=e.stack,a=n.pop();t.DEBUG&&console.log(e.step,"CEILING[]",a),n.push(64*Math.ceil(a/64))},_n.bind(void 0,0),_n.bind(void 0,1),_n.bind(void 0,2),_n.bind(void 0,3),void 0,void 0,void 0,void 0,function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"WCVTF[]",a,o),e.cvt[o]=a*e.ppem/e.font.unitsPerEm},kn.bind(void 0,2),kn.bind(void 0,3),Tn.bind(void 0,1),Tn.bind(void 0,2),Tn.bind(void 0,3),function(e){var n,a=e.stack.pop();switch(t.DEBUG&&console.log(e.step,"SROUND[]",a),e.round=Jt,192&a){case 0:n=.5;break;case 64:n=1;break;case 128:n=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=n,48&a){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*n;break;case 32:e.srPhase=.5*n;break;case 48:e.srPhase=.75*n;break;default:throw new Error("invalid SROUND value")}e.srThreshold=0===(a&=15)?0:(a/8-.5)*n},function(e){var n,a=e.stack.pop();switch(t.DEBUG&&console.log(e.step,"S45ROUND[]",a),e.round=Jt,192&a){case 0:n=Math.sqrt(2)/2;break;case 64:n=Math.sqrt(2);break;case 128:n=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=n,48&a){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*n;break;case 32:e.srPhase=.5*n;break;case 48:e.srPhase=.75*n;break;default:throw new Error("invalid S45ROUND value")}e.srThreshold=0===(a&=15)?0:(a/8-.5)*n},void 0,void 0,function(e){t.DEBUG&&console.log(e.step,"ROFF[]"),e.round=qt},void 0,function(e){t.DEBUG&&console.log(e.step,"RUTG[]"),e.round=Yt},function(e){t.DEBUG&&console.log(e.step,"RDTG[]"),e.round=Zt},hn,hn,void 0,void 0,void 0,void 0,void 0,function(e){var n=e.stack.pop();t.DEBUG&&console.log(e.step,"SCANCTRL[]",n)},Cn.bind(void 0,0),Cn.bind(void 0,1),function(e){var n=e.stack,a=n.pop(),o=0;t.DEBUG&&console.log(e.step,"GETINFO[]",a),1&a&&(o=35),32&a&&(o|=4096),n.push(o)},void 0,function(e){var n=e.stack,a=n.pop(),o=n.pop(),r=n.pop();t.DEBUG&&console.log(e.step,"ROLL[]"),n.push(o),n.push(a),n.push(r)},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"MAX[]",a,o),n.push(Math.max(o,a))},function(e){var n=e.stack,a=n.pop(),o=n.pop();t.DEBUG&&console.log(e.step,"MIN[]",a,o),n.push(Math.min(o,a))},function(e){var n=e.stack.pop();t.DEBUG&&console.log(e.step,"SCANTYPE[]",n)},function(e){var n=e.stack.pop(),a=e.stack.pop();switch(t.DEBUG&&console.log(e.step,"INSTCTRL[]",n,a),n){case 1:return void(e.inhibitGridFit=!!a);case 2:return void(e.ignoreCvt=!!a);default:throw new Error("invalid INSTCTRL[] selector")}},void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,Mn.bind(void 0,1),Mn.bind(void 0,2),Mn.bind(void 0,3),Mn.bind(void 0,4),Mn.bind(void 0,5),Mn.bind(void 0,6),Mn.bind(void 0,7),Mn.bind(void 0,8),En.bind(void 0,1),En.bind(void 0,2),En.bind(void 0,3),En.bind(void 0,4),En.bind(void 0,5),En.bind(void 0,6),En.bind(void 0,7),En.bind(void 0,8),jn.bind(void 0,0,0,0,0,0),jn.bind(void 0,0,0,0,0,1),jn.bind(void 0,0,0,0,0,2),jn.bind(void 0,0,0,0,0,3),jn.bind(void 0,0,0,0,1,0),jn.bind(void 0,0,0,0,1,1),jn.bind(void 0,0,0,0,1,2),jn.bind(void 0,0,0,0,1,3),jn.bind(void 0,0,0,1,0,0),jn.bind(void 0,0,0,1,0,1),jn.bind(void 0,0,0,1,0,2),jn.bind(void 0,0,0,1,0,3),jn.bind(void 0,0,0,1,1,0),jn.bind(void 0,0,0,1,1,1),jn.bind(void 0,0,0,1,1,2),jn.bind(void 0,0,0,1,1,3),jn.bind(void 0,0,1,0,0,0),jn.bind(void 0,0,1,0,0,1),jn.bind(void 0,0,1,0,0,2),jn.bind(void 0,0,1,0,0,3),jn.bind(void 0,0,1,0,1,0),jn.bind(void 0,0,1,0,1,1),jn.bind(void 0,0,1,0,1,2),jn.bind(void 0,0,1,0,1,3),jn.bind(void 0,0,1,1,0,0),jn.bind(void 0,0,1,1,0,1),jn.bind(void 0,0,1,1,0,2),jn.bind(void 0,0,1,1,0,3),jn.bind(void 0,0,1,1,1,0),jn.bind(void 0,0,1,1,1,1),jn.bind(void 0,0,1,1,1,2),jn.bind(void 0,0,1,1,1,3),jn.bind(void 0,1,0,0,0,0),jn.bind(void 0,1,0,0,0,1),jn.bind(void 0,1,0,0,0,2),jn.bind(void 0,1,0,0,0,3),jn.bind(void 0,1,0,0,1,0),jn.bind(void 0,1,0,0,1,1),jn.bind(void 0,1,0,0,1,2),jn.bind(void 0,1,0,0,1,3),jn.bind(void 0,1,0,1,0,0),jn.bind(void 0,1,0,1,0,1),jn.bind(void 0,1,0,1,0,2),jn.bind(void 0,1,0,1,0,3),jn.bind(void 0,1,0,1,1,0),jn.bind(void 0,1,0,1,1,1),jn.bind(void 0,1,0,1,1,2),jn.bind(void 0,1,0,1,1,3),jn.bind(void 0,1,1,0,0,0),jn.bind(void 0,1,1,0,0,1),jn.bind(void 0,1,1,0,0,2),jn.bind(void 0,1,1,0,0,3),jn.bind(void 0,1,1,0,1,0),jn.bind(void 0,1,1,0,1,1),jn.bind(void 0,1,1,0,1,2),jn.bind(void 0,1,1,0,1,3),jn.bind(void 0,1,1,1,0,0),jn.bind(void 0,1,1,1,0,1),jn.bind(void 0,1,1,1,0,2),jn.bind(void 0,1,1,1,0,3),jn.bind(void 0,1,1,1,1,0),jn.bind(void 0,1,1,1,1,1),jn.bind(void 0,1,1,1,1,2),jn.bind(void 0,1,1,1,1,3)];var In=Array.from||function(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g)||[]};function Rn(e){(e=e||{}).empty||(Dt(e.familyName,"When creating a new Font object, familyName is required."),Dt(e.styleName,"When creating a new Font object, styleName is required."),Dt(e.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),Dt(e.ascender,"When creating a new Font object, ascender is required."),Dt(e.descender,"When creating a new Font object, descender is required."),Dt(e.descender<0,"Descender should be negative (e.g. -512)."),this.names={fontFamily:{en:e.familyName||" "},fontSubfamily:{en:e.styleName||" "},fullName:{en:e.fullName||e.familyName+" "+e.styleName},postScriptName:{en:e.postScriptName||(e.familyName+e.styleName).replace(/\s/g,"")},designer:{en:e.designer||" "},designerURL:{en:e.designerURL||" "},manufacturer:{en:e.manufacturer||" "},manufacturerURL:{en:e.manufacturerURL||" "},license:{en:e.license||" "},licenseURL:{en:e.licenseURL||" "},version:{en:e.version||"Version 0.1"},description:{en:e.description||" "},copyright:{en:e.copyright||" "},trademark:{en:e.trademark||" "}},this.unitsPerEm=e.unitsPerEm||1e3,this.ascender=e.ascender,this.descender=e.descender,this.createdTimestamp=e.createdTimestamp,this.tables={os2:{usWeightClass:e.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:e.widthClass||this.usWidthClasses.MEDIUM,fsSelection:e.fsSelection||this.fsSelectionValues.REGULAR}}),this.supported=!0,this.glyphs=new _e.GlyphSet(this,e.glyphs||[]),this.encoding=new ge(this),this.position=new Mt(this),this.substitution=new Et(this),this.tables=this.tables||{},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:"truetype"===this.outlinesFormat?this._hinting=new Vt(this):void 0}})}function Dn(e,t){var n=JSON.stringify(e),a=256;for(var o in t){var r=parseInt(o);if(r&&!(r<256)){if(JSON.stringify(t[o])===n)return r;a<=r&&(a=r+1)}}return t[a]=e,a}function Nn(e,t,n){var a=Dn(t.name,n);return[{name:"tag_"+e,type:"TAG",value:t.tag},{name:"minValue_"+e,type:"FIXED",value:t.minValue<<16},{name:"defaultValue_"+e,type:"FIXED",value:t.defaultValue<<16},{name:"maxValue_"+e,type:"FIXED",value:t.maxValue<<16},{name:"flags_"+e,type:"USHORT",value:0},{name:"nameID_"+e,type:"USHORT",value:a}]}function An(e,t,n){var a={},o=new ce.Parser(e,t);return a.tag=o.parseTag(),a.minValue=o.parseFixed(),a.defaultValue=o.parseFixed(),a.maxValue=o.parseFixed(),o.skip("uShort",1),a.name=n[o.parseUShort()]||{},a}function Pn(e,t,n,a){for(var o=[{name:"nameID_"+e,type:"USHORT",value:Dn(t.name,a)},{name:"flags_"+e,type:"USHORT",value:0}],r=0;r1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");var n=255&e.parseUShort();if(e.skip("uShort"),0===n){var a=e.parseUShort();e.skip("uShort",3);for(var o=0;o=0;a--){var o=e[a];"."===o?e.splice(a,1):".."===o?(e.splice(a,1),n++):n&&(e.splice(a,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function a(e,t){if(e.filter)return e.filter(t);for(var n=[],a=0;a=-1&&!o;r--){var i=r>=0?arguments[r]:e.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");i&&(n=i+"/"+n,o="/"===i.charAt(0))}return(o?"/":"")+(n=t(a(n.split("/"),(function(e){return!!e})),!o).join("/"))||"."},n.normalize=function(e){var r=n.isAbsolute(e),i="/"===o(e,-1);return(e=t(a(e.split("/"),(function(e){return!!e})),!r).join("/"))||r||(e="."),e&&i&&(e+="/"),(r?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(a(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},n.relative=function(e,t){function a(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=a(e.split("/")),r=a(t.split("/")),i=Math.min(o.length,r.length),s=i,l=0;l=1;--r)if(47===(t=e.charCodeAt(r))){if(!o){a=r;break}}else o=!1;return-1===a?n?"/":".":n&&1===a?"/":e.slice(0,a)},n.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,a=-1,o=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!o){n=t+1;break}}else-1===a&&(o=!1,a=t+1);return-1===a?"":e.slice(n,a)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,a=-1,o=!0,r=0,i=e.length-1;i>=0;--i){var s=e.charCodeAt(i);if(47!==s)-1===a&&(o=!1,a=i+1),46===s?-1===t?t=i:1!==r&&(r=1):-1!==t&&(r=-1);else if(!o){n=i+1;break}}return-1===t||-1===a||0===r||1===r&&t===a-1&&t===n+1?"":e.slice(t,a)};var o="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:36}],36:[function(e,t,n){var a,o,r=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function l(e){if(a===setTimeout)return setTimeout(e,0);if((a===i||!a)&&setTimeout)return a=setTimeout,setTimeout(e,0);try{return a(e,0)}catch(t){try{return a.call(null,e,0)}catch(t){return a.call(this,e,0)}}}!function(){try{a="function"==typeof setTimeout?setTimeout:i}catch(e){a=i}try{o="function"==typeof clearTimeout?clearTimeout:s}catch(e){o=s}}();var c,d=[],p=!1,u=-1;function h(){p&&c&&(p=!1,c.length?d=c.concat(d):u=-1,d.length&&m())}function m(){if(!p){var e=l(h);p=!0;for(var t=d.length;t;){for(c=d,d=[];++u1)for(var n=1;n-1};m.prototype.append=function(e,t){e=p(e),t=u(t);var n=this.map[e];this.map[e]=n?n+","+t:t},m.prototype.delete=function(e){delete this.map[p(e)]},m.prototype.get=function(e){return e=p(e),this.has(e)?this.map[e]:null},m.prototype.has=function(e){return this.map.hasOwnProperty(p(e))},m.prototype.set=function(e,t){this.map[p(e)]=u(t)},m.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},m.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),h(e)},m.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},m.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),h(e)},n&&(m.prototype[Symbol.iterator]=m.prototype.entries);var c=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},v.call(w.prototype),v.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new m(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:0,statusText:""});return e.type="error",e};var d=[301,302,303,307,308];S.redirect=function(e,t){if(-1===d.indexOf(t))throw new RangeError("Invalid status code");return new S(null,{status:t,headers:{location:e}})},e.Headers=m,e.Request=w,e.Response=S,e.fetch=function(e,t){return new Promise((function(n,o){var r=new w(e,t),i=new XMLHttpRequest;i.onload=function(){var e,t,a={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new m,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var n=e.split(":"),a=n.shift().trim();if(a){var o=n.join(":").trim();t.append(a,o)}})),t)};a.url="responseURL"in i?i.responseURL:a.headers.get("X-Request-URL"),n(new S("response"in i?i.response:i.responseText,a))},i.onerror=function(){o(new TypeError("Network request failed"))},i.ontimeout=function(){o(new TypeError("Network request failed"))},i.open(r.method,r.url,!0),"include"===r.credentials?i.withCredentials=!0:"omit"===r.credentials&&(i.withCredentials=!1),"responseType"in i&&a&&(i.responseType="blob"),r.headers.forEach((function(e,t){i.setRequestHeader(t,e)})),i.send(void 0===r._bodyInit?null:r._bodyInit)}))},e.fetch.polyfill=!0}function p(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function m(e){this.map={},e instanceof m?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function g(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function b(e){var t=new FileReader,n=g(t);return t.readAsArrayBuffer(e),n}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(a&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(o&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(r&&a&&s(e))this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!r||!ArrayBuffer.prototype.isPrototypeOf(e)&&!l(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(b)}),this.text=function(){var e,t,n,a=f(this);if(a)return a;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=g(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),a=0;a-1?a:n),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function x(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),a=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(a),decodeURIComponent(o))}})),t}function S(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new m(t.headers),this.url=t.url||"",this._initBody(e)}}("undefined"!=typeof self?self:this)},{}],38:[function(e,t,n){"use strict";var a,o=(a=e("./core/main"))&&a.__esModule?a:{default:a};e("./core/constants"),e("./core/environment"),e("./core/error_helpers"),e("./core/helpers"),e("./core/legacy"),e("./core/preload"),e("./core/p5.Element"),e("./core/p5.Graphics"),e("./core/p5.Renderer"),e("./core/p5.Renderer2D"),e("./core/rendering"),e("./core/shim"),e("./core/structure"),e("./core/transform"),e("./core/shape/2d_primitives"),e("./core/shape/attributes"),e("./core/shape/curves"),e("./core/shape/vertex"),e("./color/color_conversion"),e("./color/creating_reading"),e("./color/p5.Color"),e("./color/setting"),e("./data/p5.TypedDict"),e("./data/local_storage.js"),e("./dom/dom"),e("./events/acceleration"),e("./events/keyboard"),e("./events/mouse"),e("./events/touch"),e("./image/filters"),e("./image/image"),e("./image/loading_displaying"),e("./image/p5.Image"),e("./image/pixels"),e("./io/files"),e("./io/p5.Table"),e("./io/p5.TableRow"),e("./io/p5.XML"),e("./math/calculation"),e("./math/math"),e("./math/noise"),e("./math/p5.Vector"),e("./math/random"),e("./math/trigonometry"),e("./typography/attributes"),e("./typography/loading_displaying"),e("./typography/p5.Font"),e("./utilities/array_functions"),e("./utilities/conversion"),e("./utilities/string_functions"),e("./utilities/time_date"),e("./webgl/3d_primitives"),e("./webgl/interaction"),e("./webgl/light"),e("./webgl/loading"),e("./webgl/material"),e("./webgl/p5.Camera"),e("./webgl/p5.Geometry"),e("./webgl/p5.Matrix"),e("./webgl/p5.RendererGL.Immediate"),e("./webgl/p5.RendererGL"),e("./webgl/p5.RendererGL.Retained"),e("./webgl/p5.Shader"),e("./webgl/p5.RenderBuffer"),e("./webgl/p5.Texture"),e("./webgl/text"),e("./core/init"),t.exports=o.default},{"./color/color_conversion":39,"./color/creating_reading":40,"./color/p5.Color":41,"./color/setting":42,"./core/constants":43,"./core/environment":44,"./core/error_helpers":45,"./core/helpers":46,"./core/init":47,"./core/legacy":49,"./core/main":50,"./core/p5.Element":51,"./core/p5.Graphics":52,"./core/p5.Renderer":53,"./core/p5.Renderer2D":54,"./core/preload":55,"./core/rendering":56,"./core/shape/2d_primitives":57,"./core/shape/attributes":58,"./core/shape/curves":59,"./core/shape/vertex":60,"./core/shim":61,"./core/structure":62,"./core/transform":63,"./data/local_storage.js":64,"./data/p5.TypedDict":65,"./dom/dom":66,"./events/acceleration":67,"./events/keyboard":68,"./events/mouse":69,"./events/touch":70,"./image/filters":71,"./image/image":72,"./image/loading_displaying":73,"./image/p5.Image":74,"./image/pixels":75,"./io/files":76,"./io/p5.Table":77,"./io/p5.TableRow":78,"./io/p5.XML":79,"./math/calculation":80,"./math/math":81,"./math/noise":82,"./math/p5.Vector":83,"./math/random":84,"./math/trigonometry":85,"./typography/attributes":86,"./typography/loading_displaying":87,"./typography/p5.Font":88,"./utilities/array_functions":89,"./utilities/conversion":90,"./utilities/string_functions":91,"./utilities/time_date":92,"./webgl/3d_primitives":93,"./webgl/interaction":94,"./webgl/light":95,"./webgl/loading":96,"./webgl/material":97,"./webgl/p5.Camera":98,"./webgl/p5.Geometry":99,"./webgl/p5.Matrix":100,"./webgl/p5.RenderBuffer":101,"./webgl/p5.RendererGL":104,"./webgl/p5.RendererGL.Immediate":102,"./webgl/p5.RendererGL.Retained":103,"./webgl/p5.Shader":105,"./webgl/p5.Texture":106,"./webgl/text":107}],39:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a,o=(a=e("../core/main"))&&a.__esModule?a:{default:a};o.default.ColorConversion={},o.default.ColorConversion._hsbaToHSLA=function(e){var t=e[1],n=e[2],a=(2-t)*n/2;return 0!==a&&(1===a?t=0:a<.5?t/=2-t:t=t*n/(2-2*a)),[e[0],t,a,e[3]]},o.default.ColorConversion._hsbaToRGBA=function(e){var t=6*e[0],n=e[1],a=e[2],o=[];if(0===n)o=[a,a,a,e[3]];else{var r,i,s,l=Math.floor(t),c=a*(1-n),d=a*(1-n*(t-l)),p=a*(1-n*(1+l-t));1===l?(r=d,i=a,s=c):2===l?(r=c,i=a,s=p):3===l?(r=c,i=d,s=a):4===l?(r=p,i=c,s=a):5===l?(r=a,i=c,s=d):(r=a,i=p,s=c),o=[r,i,s,e[3]]}return o},o.default.ColorConversion._hslaToHSBA=function(e){var t,n=e[1],a=e[2];return[e[0],n=2*((t=a<.5?(1+n)*a:a+n-a*n)-a)/t,t,e[3]]},o.default.ColorConversion._hslaToRGBA=function(e){var t=6*e[0],n=e[1],a=e[2],o=[];if(0===n)o=[a,a,a,e[3]];else{var r,i=2*a-(r=a<.5?(1+n)*a:a+n-a*n),s=function(e,t,n){return e<0?e+=6:e>=6&&(e-=6),e<1?t+(n-t)*e:e<3?n:e<4?t+(n-t)*(4-e):t};o=[s(t+2,i,r),s(t,i,r),s(t-2,i,r),e[3]]}return o},o.default.ColorConversion._rgbaToHSBA=function(e){var t,n,a=e[0],o=e[1],r=e[2],i=Math.max(a,o,r),s=i-Math.min(a,o,r);return 0===s?(t=0,n=0):(n=s/i,a===i?t=(o-r)/s:o===i?t=2+(r-a)/s:r===i&&(t=4+(a-o)/s),t<0?t+=6:t>=6&&(t-=6)),[t/6,n,i,e[3]]},o.default.ColorConversion._rgbaToHSLA=function(e){var t,n,a=e[0],o=e[1],r=e[2],i=Math.max(a,o,r),s=Math.min(a,o,r),l=i+s,c=i-s;return 0===c?(t=0,n=0):(n=l<1?c/l:c/(2-l),a===i?t=(o-r)/c:o===i?t=2+(r-a)/c:r===i&&(t=4+(a-o)/c),t<0?t+=6:t>=6&&(t-=6)),[t/6,n,l/2,e[3]]},n.default=o.default.ColorConversion},{"../core/main":50}],40:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,r=(o=e("../core/main"))&&o.__esModule?o:{default:o},i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("../core/constants"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}e("./p5.Color"),e("../core/error_helpers"),r.default.prototype.alpha=function(e){return r.default._validateParameters("alpha",arguments),this.color(e)._getAlpha()},r.default.prototype.blue=function(e){return r.default._validateParameters("blue",arguments),this.color(e)._getBlue()},r.default.prototype.brightness=function(e){return r.default._validateParameters("brightness",arguments),this.color(e)._getBrightness()},r.default.prototype.color=function(){return r.default._validateParameters("color",arguments),arguments[0]instanceof r.default.Color?arguments[0]:new r.default.Color(this,arguments[0]instanceof Array?arguments[0]:arguments)},r.default.prototype.green=function(e){return r.default._validateParameters("green",arguments),this.color(e)._getGreen()},r.default.prototype.hue=function(e){return r.default._validateParameters("hue",arguments),this.color(e)._getHue()},r.default.prototype.lerpColor=function(e,t,n){r.default._validateParameters("lerpColor",arguments);var a,o,s,l,c,d,p=this._colorMode,u=this._colorMaxes;if(p===i.RGB)c=e.levels.map((function(e){return e/255})),d=t.levels.map((function(e){return e/255}));else if(p===i.HSB)e._getBrightness(),t._getBrightness(),c=e.hsba,d=t.hsba;else{if(p!==i.HSL)throw new Error("".concat(p,"cannot be used for interpolation."));e._getLightness(),t._getLightness(),c=e.hsla,d=t.hsla}return n=Math.max(Math.min(n,1),0),void 0===this.lerp&&(this.lerp=function(e,t,n){return n*(t-e)+e}),a=this.lerp(c[0],d[0],n),o=this.lerp(c[1],d[1],n),s=this.lerp(c[2],d[2],n),l=this.lerp(c[3],d[3],n),this.color(a*=u[p][0],o*=u[p][1],s*=u[p][2],l*=u[p][3])},r.default.prototype.lightness=function(e){return r.default._validateParameters("lightness",arguments),this.color(e)._getLightness()},r.default.prototype.red=function(e){return r.default._validateParameters("red",arguments),this.color(e)._getRed()},r.default.prototype.saturation=function(e){return r.default._validateParameters("saturation",arguments),this.color(e)._getSaturation()},n.default=r.default},{"../core/constants":43,"../core/error_helpers":45,"../core/main":50,"./p5.Color":41}],41:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o=l(e("../core/main")),r=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("../core/constants")),i=l(e("./color_conversion"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function l(e){return e&&e.__esModule?e:{default:e}}o.default.Color=function(e,t){if(this._storeModeAndMaxes(e._colorMode,e._colorMaxes),this.mode!==r.RGB&&this.mode!==r.HSL&&this.mode!==r.HSB)throw new Error("".concat(this.mode," is an invalid colorMode."));return this._array=o.default.Color._parseInputs.apply(this,t),this._calculateLevels(),this},o.default.Color.prototype.toString=function(e){var t=this.levels,n=this._array,a=n[3];switch(e){case"#rrggbb":return"#".concat(t[0]<16?"0".concat(t[0].toString(16)):t[0].toString(16),t[1]<16?"0".concat(t[1].toString(16)):t[1].toString(16),t[2]<16?"0".concat(t[2].toString(16)):t[2].toString(16));case"#rrggbbaa":return"#".concat(t[0]<16?"0".concat(t[0].toString(16)):t[0].toString(16),t[1]<16?"0".concat(t[1].toString(16)):t[1].toString(16),t[2]<16?"0".concat(t[2].toString(16)):t[2].toString(16),t[3]<16?"0".concat(t[2].toString(16)):t[3].toString(16));case"#rgb":return"#".concat(Math.round(15*n[0]).toString(16),Math.round(15*n[1]).toString(16),Math.round(15*n[2]).toString(16));case"#rgba":return"#".concat(Math.round(15*n[0]).toString(16),Math.round(15*n[1]).toString(16),Math.round(15*n[2]).toString(16),Math.round(15*n[3]).toString(16));case"rgb":return"rgb(".concat(t[0],", ",t[1],", ",t[2],")");case"rgb%":return"rgb(".concat((100*n[0]).toPrecision(3),"%, ",(100*n[1]).toPrecision(3),"%, ",(100*n[2]).toPrecision(3),"%)");case"rgba%":return"rgba(".concat((100*n[0]).toPrecision(3),"%, ",(100*n[1]).toPrecision(3),"%, ",(100*n[2]).toPrecision(3),"%, ",(100*n[3]).toPrecision(3),"%)");case"hsb":case"hsv":return this.hsba||(this.hsba=i.default._rgbaToHSBA(this._array)),"hsb(".concat(this.hsba[0]*this.maxes[r.HSB][0],", ",this.hsba[1]*this.maxes[r.HSB][1],", ",this.hsba[2]*this.maxes[r.HSB][2],")");case"hsb%":case"hsv%":return this.hsba||(this.hsba=i.default._rgbaToHSBA(this._array)),"hsb(".concat((100*this.hsba[0]).toPrecision(3),"%, ",(100*this.hsba[1]).toPrecision(3),"%, ",(100*this.hsba[2]).toPrecision(3),"%)");case"hsba":case"hsva":return this.hsba||(this.hsba=i.default._rgbaToHSBA(this._array)),"hsba(".concat(this.hsba[0]*this.maxes[r.HSB][0],", ",this.hsba[1]*this.maxes[r.HSB][1],", ",this.hsba[2]*this.maxes[r.HSB][2],", ",a,")");case"hsba%":case"hsva%":return this.hsba||(this.hsba=i.default._rgbaToHSBA(this._array)),"hsba(".concat((100*this.hsba[0]).toPrecision(3),"%, ",(100*this.hsba[1]).toPrecision(3),"%, ",(100*this.hsba[2]).toPrecision(3),"%, ",(100*a).toPrecision(3),"%)");case"hsl":return this.hsla||(this.hsla=i.default._rgbaToHSLA(this._array)),"hsl(".concat(this.hsla[0]*this.maxes[r.HSL][0],", ",this.hsla[1]*this.maxes[r.HSL][1],", ",this.hsla[2]*this.maxes[r.HSL][2],")");case"hsl%":return this.hsla||(this.hsla=i.default._rgbaToHSLA(this._array)),"hsl(".concat((100*this.hsla[0]).toPrecision(3),"%, ",(100*this.hsla[1]).toPrecision(3),"%, ",(100*this.hsla[2]).toPrecision(3),"%)");case"hsla":return this.hsla||(this.hsla=i.default._rgbaToHSLA(this._array)),"hsla(".concat(this.hsla[0]*this.maxes[r.HSL][0],", ",this.hsla[1]*this.maxes[r.HSL][1],", ",this.hsla[2]*this.maxes[r.HSL][2],", ",a,")");case"hsla%":return this.hsla||(this.hsla=i.default._rgbaToHSLA(this._array)),"hsl(".concat((100*this.hsla[0]).toPrecision(3),"%, ",(100*this.hsla[1]).toPrecision(3),"%, ",(100*this.hsla[2]).toPrecision(3),"%, ",(100*a).toPrecision(3),"%)");default:return"rgba(".concat(t[0],",",t[1],",",t[2],",",a,")")}},o.default.Color.prototype.setRed=function(e){this._array[0]=e/this.maxes[r.RGB][0],this._calculateLevels()},o.default.Color.prototype.setGreen=function(e){this._array[1]=e/this.maxes[r.RGB][1],this._calculateLevels()},o.default.Color.prototype.setBlue=function(e){this._array[2]=e/this.maxes[r.RGB][2],this._calculateLevels()},o.default.Color.prototype.setAlpha=function(e){this._array[3]=e/this.maxes[this.mode][3],this._calculateLevels()},o.default.Color.prototype._calculateLevels=function(){for(var e=this._array,t=this.levels=new Array(e.length),n=e.length-1;n>=0;--n)t[n]=Math.round(255*e[n])},o.default.Color.prototype._getAlpha=function(){return this._array[3]*this.maxes[this.mode][3]},o.default.Color.prototype._storeModeAndMaxes=function(e,t){this.mode=e,this.maxes=t},o.default.Color.prototype._getMode=function(){return this.mode},o.default.Color.prototype._getMaxes=function(){return this.maxes},o.default.Color.prototype._getBlue=function(){return this._array[2]*this.maxes[r.RGB][2]},o.default.Color.prototype._getBrightness=function(){return this.hsba||(this.hsba=i.default._rgbaToHSBA(this._array)),this.hsba[2]*this.maxes[r.HSB][2]},o.default.Color.prototype._getGreen=function(){return this._array[1]*this.maxes[r.RGB][1]},o.default.Color.prototype._getHue=function(){return this.mode===r.HSB?(this.hsba||(this.hsba=i.default._rgbaToHSBA(this._array)),this.hsba[0]*this.maxes[r.HSB][0]):(this.hsla||(this.hsla=i.default._rgbaToHSLA(this._array)),this.hsla[0]*this.maxes[r.HSL][0])},o.default.Color.prototype._getLightness=function(){return this.hsla||(this.hsla=i.default._rgbaToHSLA(this._array)),this.hsla[2]*this.maxes[r.HSL][2]},o.default.Color.prototype._getRed=function(){return this._array[0]*this.maxes[r.RGB][0]},o.default.Color.prototype._getSaturation=function(){return this.mode===r.HSB?(this.hsba||(this.hsba=i.default._rgbaToHSBA(this._array)),this.hsba[1]*this.maxes[r.HSB][1]):(this.hsla||(this.hsla=i.default._rgbaToHSLA(this._array)),this.hsla[1]*this.maxes[r.HSL][1])};var c={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},d=/\s*/,p=/(\d{1,3})/,u=/((?:\d+(?:\.\d+)?)|(?:\.\d+))/,h=new RegExp("".concat(u.source,"%")),m={HEX3:/^#([a-f0-9])([a-f0-9])([a-f0-9])$/i,HEX4:/^#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])$/i,HEX6:/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i,HEX8:/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i,RGB:new RegExp(["^rgb\\(",p.source,",",p.source,",",p.source,"\\)$"].join(d.source),"i"),RGB_PERCENT:new RegExp(["^rgb\\(",h.source,",",h.source,",",h.source,"\\)$"].join(d.source),"i"),RGBA:new RegExp(["^rgba\\(",p.source,",",p.source,",",p.source,",",u.source,"\\)$"].join(d.source),"i"),RGBA_PERCENT:new RegExp(["^rgba\\(",h.source,",",h.source,",",h.source,",",u.source,"\\)$"].join(d.source),"i"),HSL:new RegExp(["^hsl\\(",p.source,",",h.source,",",h.source,"\\)$"].join(d.source),"i"),HSLA:new RegExp(["^hsla\\(",p.source,",",h.source,",",h.source,",",u.source,"\\)$"].join(d.source),"i"),HSB:new RegExp(["^hsb\\(",p.source,",",h.source,",",h.source,"\\)$"].join(d.source),"i"),HSBA:new RegExp(["^hsba\\(",p.source,",",h.source,",",h.source,",",u.source,"\\)$"].join(d.source),"i")};o.default.Color._parseInputs=function(e,t,n,a){var s,l=arguments.length,d=this.mode,p=this.maxes[d],u=[];if(l>=3){for(u[0]=e/p[0],u[1]=t/p[1],u[2]=n/p[2],u[3]="number"==typeof a?a/p[3]:1,s=u.length-1;s>=0;--s){var h=u[s];h<0?u[s]=0:h>1&&(u[s]=1)}return d===r.HSL?i.default._hslaToRGBA(u):d===r.HSB?i.default._hsbaToRGBA(u):u}if(1===l&&"string"==typeof e){var f=e.trim().toLowerCase();if(c[f])return o.default.Color._parseInputs.call(this,c[f]);if(m.HEX3.test(f))return(u=m.HEX3.exec(f).slice(1).map((function(e){return parseInt(e+e,16)/255})))[3]=1,u;if(m.HEX6.test(f))return(u=m.HEX6.exec(f).slice(1).map((function(e){return parseInt(e,16)/255})))[3]=1,u;if(m.HEX4.test(f))return u=m.HEX4.exec(f).slice(1).map((function(e){return parseInt(e+e,16)/255}));if(m.HEX8.test(f))return u=m.HEX8.exec(f).slice(1).map((function(e){return parseInt(e,16)/255}));if(m.RGB.test(f))return(u=m.RGB.exec(f).slice(1).map((function(e){return e/255})))[3]=1,u;if(m.RGB_PERCENT.test(f))return(u=m.RGB_PERCENT.exec(f).slice(1).map((function(e){return parseFloat(e)/100})))[3]=1,u;if(m.RGBA.test(f))return u=m.RGBA.exec(f).slice(1).map((function(e,t){return 3===t?parseFloat(e):e/255}));if(m.RGBA_PERCENT.test(f))return u=m.RGBA_PERCENT.exec(f).slice(1).map((function(e,t){return 3===t?parseFloat(e):parseFloat(e)/100}));if(m.HSL.test(f)?(u=m.HSL.exec(f).slice(1).map((function(e,t){return 0===t?parseInt(e,10)/360:parseInt(e,10)/100})))[3]=1:m.HSLA.test(f)&&(u=m.HSLA.exec(f).slice(1).map((function(e,t){return 0===t?parseInt(e,10)/360:3===t?parseFloat(e):parseInt(e,10)/100}))),(u=u.map((function(e){return Math.max(Math.min(e,1),0)}))).length)return i.default._hslaToRGBA(u);if(m.HSB.test(f)?(u=m.HSB.exec(f).slice(1).map((function(e,t){return 0===t?parseInt(e,10)/360:parseInt(e,10)/100})))[3]=1:m.HSBA.test(f)&&(u=m.HSBA.exec(f).slice(1).map((function(e,t){return 0===t?parseInt(e,10)/360:3===t?parseFloat(e):parseInt(e,10)/100}))),u.length){for(s=u.length-1;s>=0;--s)u[s]=Math.max(Math.min(u[s],1),0);return i.default._hsbaToRGBA(u)}u=[1,1,1,1]}else{if(1!==l&&2!==l||"number"!=typeof e)throw new Error("".concat(arguments,"is not a valid color representation."));u[0]=e/p[2],u[1]=e/p[2],u[2]=e/p[2],u[3]="number"==typeof t?t/p[3]:1,u=u.map((function(e){return Math.max(Math.min(e,1),0)}))}return u},n.default=o.default.Color},{"../core/constants":43,"../core/main":50,"./color_conversion":39}],42:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,r=(o=e("../core/main"))&&o.__esModule?o:{default:o},i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("../core/constants"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}e("./p5.Color"),r.default.prototype.background=function(){var e;return(e=this._renderer).background.apply(e,arguments),this},r.default.prototype.clear=function(){return this._renderer.clear(),this},r.default.prototype.colorMode=function(e,t,n,a,o){if(r.default._validateParameters("colorMode",arguments),e===i.RGB||e===i.HSB||e===i.HSL){this._colorMode=e;var s=this._colorMaxes[e];2===arguments.length?(s[0]=t,s[1]=t,s[2]=t,s[3]=t):4===arguments.length?(s[0]=t,s[1]=n,s[2]=a):5===arguments.length&&(s[0]=t,s[1]=n,s[2]=a,s[3]=o)}return this},r.default.prototype.fill=function(){var e;return this._renderer._setProperty("_fillSet",!0),this._renderer._setProperty("_doFill",!0),(e=this._renderer).fill.apply(e,arguments),this},r.default.prototype.noFill=function(){return this._renderer._setProperty("_doFill",!1),this},r.default.prototype.noStroke=function(){return this._renderer._setProperty("_doStroke",!1),this},r.default.prototype.stroke=function(){var e;return this._renderer._setProperty("_strokeSet",!0),this._renderer._setProperty("_doStroke",!0),(e=this._renderer).stroke.apply(e,arguments),this},r.default.prototype.erase=function(){return this._renderer.erase(arguments.length>0&&void 0!==arguments[0]?arguments[0]:255,arguments.length>1&&void 0!==arguments[1]?arguments[1]:255),this},r.default.prototype.noErase=function(){return this._renderer.noErase(),this},n.default=r.default},{"../core/constants":43,"../core/main":50,"./p5.Color":41}],43:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.FILL=n.STROKE=n.CURVE=n.BEZIER=n.QUADRATIC=n.LINEAR=n._CTX_MIDDLE=n._DEFAULT_LEADMULT=n._DEFAULT_TEXT_FILL=n.BOLDITALIC=n.BOLD=n.ITALIC=n.NORMAL=n.BLUR=n.ERODE=n.DILATE=n.POSTERIZE=n.INVERT=n.OPAQUE=n.GRAY=n.THRESHOLD=n.BURN=n.DODGE=n.SOFT_LIGHT=n.HARD_LIGHT=n.OVERLAY=n.REPLACE=n.SCREEN=n.MULTIPLY=n.EXCLUSION=n.SUBTRACT=n.DIFFERENCE=n.LIGHTEST=n.DARKEST=n.ADD=n.REMOVE=n.BLEND=n.UP_ARROW=n.TAB=n.SHIFT=n.RIGHT_ARROW=n.RETURN=n.OPTION=n.LEFT_ARROW=n.ESCAPE=n.ENTER=n.DOWN_ARROW=n.DELETE=n.CONTROL=n.BACKSPACE=n.ALT=n.AUTO=n.HSL=n.HSB=n.RGB=n.MITER=n.BEVEL=n.ROUND=n.SQUARE=n.PROJECT=n.PIE=n.CHORD=n.OPEN=n.CLOSE=n.TESS=n.QUAD_STRIP=n.QUADS=n.TRIANGLE_STRIP=n.TRIANGLE_FAN=n.TRIANGLES=n.LINE_LOOP=n.LINE_STRIP=n.LINES=n.POINTS=n.BASELINE=n.BOTTOM=n.TOP=n.CENTER=n.LEFT=n.RIGHT=n.RADIUS=n.CORNERS=n.CORNER=n.RAD_TO_DEG=n.DEG_TO_RAD=n.RADIANS=n.DEGREES=n.TWO_PI=n.TAU=n.QUARTER_PI=n.PI=n.HALF_PI=n.WAIT=n.TEXT=n.MOVE=n.HAND=n.CROSS=n.ARROW=n.WEBGL=n.P2D=void 0,n.AXES=n.GRID=n._DEFAULT_FILL=n._DEFAULT_STROKE=n.PORTRAIT=n.LANDSCAPE=n.MIRROR=n.CLAMP=n.REPEAT=n.NEAREST=n.IMAGE=n.IMMEDIATE=n.TEXTURE=void 0;var a=Math.PI;n.P2D="p2d";n.WEBGL="webgl";n.ARROW="default";n.CROSS="crosshair";n.HAND="pointer";n.MOVE="move";n.TEXT="text";n.WAIT="wait",n.HALF_PI=a/2,n.PI=a,n.QUARTER_PI=a/4,n.TAU=2*a,n.TWO_PI=2*a;n.DEGREES="degrees";n.RADIANS="radians",n.DEG_TO_RAD=a/180,n.RAD_TO_DEG=180/a;n.CORNER="corner";n.CORNERS="corners";n.RADIUS="radius";n.RIGHT="right";n.LEFT="left";n.CENTER="center";n.TOP="top";n.BOTTOM="bottom";n.BASELINE="alphabetic";n.POINTS=0;n.LINES=1;n.LINE_STRIP=3;n.LINE_LOOP=2;n.TRIANGLES=4;n.TRIANGLE_FAN=6;n.TRIANGLE_STRIP=5;n.QUADS="quads";n.QUAD_STRIP="quad_strip";n.TESS="tess";n.CLOSE="close";n.OPEN="open";n.CHORD="chord";n.PIE="pie";n.PROJECT="square";n.SQUARE="butt";n.ROUND="round";n.BEVEL="bevel";n.MITER="miter";n.RGB="rgb";n.HSB="hsb";n.HSL="hsl";n.AUTO="auto";n.ALT=18;n.BACKSPACE=8;n.CONTROL=17;n.DELETE=46;n.DOWN_ARROW=40;n.ENTER=13;n.ESCAPE=27;n.LEFT_ARROW=37;n.OPTION=18;n.RETURN=13;n.RIGHT_ARROW=39;n.SHIFT=16;n.TAB=9;n.UP_ARROW=38;n.BLEND="source-over";n.REMOVE="destination-out";n.ADD="lighter";n.DARKEST="darken";n.LIGHTEST="lighten";n.DIFFERENCE="difference";n.SUBTRACT="subtract";n.EXCLUSION="exclusion";n.MULTIPLY="multiply";n.SCREEN="screen";n.REPLACE="copy";n.OVERLAY="overlay";n.HARD_LIGHT="hard-light";n.SOFT_LIGHT="soft-light";n.DODGE="color-dodge";n.BURN="color-burn";n.THRESHOLD="threshold";n.GRAY="gray";n.OPAQUE="opaque";n.INVERT="invert";n.POSTERIZE="posterize";n.DILATE="dilate";n.ERODE="erode";n.BLUR="blur";n.NORMAL="normal";n.ITALIC="italic";n.BOLD="bold";n.BOLDITALIC="bold italic";n._DEFAULT_TEXT_FILL="#000000";n._DEFAULT_LEADMULT=1.25;n._CTX_MIDDLE="middle";n.LINEAR="linear";n.QUADRATIC="quadratic";n.BEZIER="bezier";n.CURVE="curve";n.STROKE="stroke";n.FILL="fill";n.TEXTURE="texture";n.IMMEDIATE="immediate";n.IMAGE="image";n.NEAREST="nearest";n.REPEAT="repeat";n.CLAMP="clamp";n.MIRROR="mirror";n.LANDSCAPE="landscape";n.PORTRAIT="portrait";n._DEFAULT_STROKE="#000000";n._DEFAULT_FILL="#FFFFFF";n.GRID="grid";n.AXES="axes"},{}],44:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,r=(o=e("./main"))&&o.__esModule?o:{default:o},i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("./constants"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}var l=[i.ARROW,i.CROSS,i.HAND,i.MOVE,i.TEXT,i.WAIT];r.default.prototype._frameRate=0,r.default.prototype._lastFrameTime=window.performance.now(),r.default.prototype._targetFrameRate=60;var c=window.print;function d(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth||0}function p(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight||0}r.default.prototype.print=function(){var e;arguments.length?(e=console).log.apply(e,arguments):c()},r.default.prototype.frameCount=0,r.default.prototype.deltaTime=0,r.default.prototype.focused=document.hasFocus(),r.default.prototype.cursor=function(e,t,n){var a="auto",o=this._curElement.elt;if(l.includes(e))a=e;else if("string"==typeof e){var r="";t&&n&&"number"==typeof t&&"number"==typeof n&&(r="".concat(t," ").concat(n)),a="http://"===e.substring(0,7)||"https://"===e.substring(0,8)||/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(e)?"url(".concat(e,") ").concat(r,", auto"):e}o.style.cursor=a},r.default.prototype.frameRate=function(e){return r.default._validateParameters("frameRate",arguments),"number"!=typeof e||e<0?this._frameRate:(this._setProperty("_targetFrameRate",e),0===e&&this._setProperty("_frameRate",e),this)},r.default.prototype.getFrameRate=function(){return this.frameRate()},r.default.prototype.setFrameRate=function(e){return this.frameRate(e)},r.default.prototype.noCursor=function(){this._curElement.elt.style.cursor="none"},r.default.prototype.displayWidth=screen.width,r.default.prototype.displayHeight=screen.height,r.default.prototype.windowWidth=d(),r.default.prototype.windowHeight=p(),r.default.prototype._onresize=function(e){this._setProperty("windowWidth",d()),this._setProperty("windowHeight",p());var t,n=this._isGlobal?window:this;"function"==typeof n.windowResized&&(void 0===(t=n.windowResized(e))||t||e.preventDefault())},r.default.prototype.width=0,r.default.prototype.height=0,r.default.prototype.fullscreen=function(e){if(r.default._validateParameters("fullscreen",arguments),void 0===e)return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;e?function(e){if(!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled))throw new Error("Fullscreen not enabled in this browser.");e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()}(document.documentElement):document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()},r.default.prototype.pixelDensity=function(e){var t;return r.default._validateParameters("pixelDensity",arguments),"number"==typeof e?(e!==this._pixelDensity&&(this._pixelDensity=e),t=this,this.resizeCanvas(this.width,this.height,!0)):t=this._pixelDensity,t},r.default.prototype.displayDensity=function(){return window.devicePixelRatio},r.default.prototype.getURL=function(){return location.href},r.default.prototype.getURLPath=function(){return location.pathname.split("/").filter((function(e){return""!==e}))},r.default.prototype.getURLParams=function(){for(var e,t=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim,n={};null!=(e=t.exec(location.search));)e.index===t.lastIndex&&t.lastIndex++,n[e[1]]=e[2];return n},n.default=r.default},{"./constants":43,"./main":50}],45:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a,o=(a=e("./main"))&&a.__esModule?a:{default:a},r=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==h(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r=a?Object.getOwnPropertyDescriptor(e,o):null;r&&(r.get||r.set)?Object.defineProperty(n,o,r):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(e("./constants")),i=e("./internationalization");function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e){var t="function"==typeof Map?new Map:void 0;return c=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return d(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,e)},c(e)}function d(e,t,n){return d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var a=[null];a.push.apply(a,t);var o=new(Function.bind.apply(e,a));return n&&p(o,n.prototype),o},d.apply(null,arguments)}function p(e,t){return p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},p(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function h(e){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(e)}var m,f=["#2D7BB6","#EE9900","#4DB200","#C83C00"];if("undefined"!=typeof IS_MINIFIED)o.default._validateParameters=o.default._friendlyFileLoadError=o.default._friendlyError=function(){};else{for(var g=!1,b=e("../../docs/reference/data.json"),y=JSON.parse(JSON.stringify(b)),v={},w=v.toString,x=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error"],S=0;S0&&ao&&(n=o)}return n},I=function(e,t,n,a){var o=0,r=n.formats,i=n.minParams;tr.length&&(o=2*(t-r.length));for(var s=0;o<=a&&s0&&n[a-1].optional;)a--;t.minParams=a,n.forEach((function(t){t.types=t.type.split("|").map((function n(a){if("[]"===a.substr(a.length-2,2))return{name:a,array:n(a.substr(0,a.length-2))};var i=a.toLowerCase();if("constant"===i){var s;if(g.hasOwnProperty(t.name))s=g[t.name];else{var l={},c=[];s=g[t.name]={values:l,names:c};var d=/either\s+(?:[A-Z0-9_]+\s*,?\s*(?:or)?\s*)+/g.exec(t.description);if("endShape"===e&&"mode"===t.name)l[r.CLOSE]=!0,c.push("CLOSE");else for(var p,u=d[0],h=/[A-Z0-9_]+/g;null!==(p=h.exec(u));){var m=p[0];r.hasOwnProperty(m)&&(l[r[m]]=!0,c.push(m))}}return{name:a,builtin:i,names:s.names,values:s.values}}if("function"===i.substr(0,8)&&(i="function"),C.includes(i))return{name:a,builtin:i};var f=window,b=a.split(".");return"p5"===b[0]&&(f=o.default,b.shift()),b.forEach((function(e){f=f&&f[e]})),f?{name:a,prototype:f}:{name:a,type:i}}))}))})),{overloads:m,maxParams:b}}(e)),a=n.overloads,i=t.length;i>0&&null==t[i-1];)i--;for(var s,l=99999,c=0;cd&&(l=d,s=c)}if(l>0)for(var p=function(e,t,n){var a=n.formats,o=n.minParams;if(ta.length)return[{type:"TOO_MANY_ARGUMENTS",argCount:t,maxParams:a.length}];for(var r=[],i=0;i0&&r.push({type:"WRONG_TYPE",position:i,format:l,arg:s})}return r}(t,i,a[s]),u=0;u=1e3/o._targetFrameRate-5)&&(o.redraw(),o._frameRate=1e3/(e-o._lastFrameTime),o.deltaTime=e-o._lastFrameTime,o._setProperty("deltaTime",o.deltaTime),o._lastFrameTime=e,void 0!==o._updateMouseCoords&&(o._updateMouseCoords(),o._setProperty("movedX",0),o._setProperty("movedY",0))),o._loop&&(o._requestAnimId=window.requestAnimationFrame(o._draw))},this._setProperty=function(e,t){o[e]=t,o._isGlobal&&(window[e]=t)},this.remove=function(){var t=document.getElementById(o._loadingScreenId);if(t&&(t.parentNode.removeChild(t),o._incrementPreload()),o._curElement){for(var n in o._loop=!1,o._requestAnimId&&window.cancelAnimationFrame(o._requestAnimId),o._events)window.removeEventListener(n,o._events[n]);var a=!0,r=!1,i=void 0;try{for(var s,l=o._elements[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var c=s.value;for(var d in c.elt&&c.elt.parentNode&&c.elt.parentNode.removeChild(c.elt),c._events)c.elt.removeEventListener(d,c._events[d])}}catch(e){r=!0,i=e}finally{try{a||null==l.return||l.return()}finally{if(r)throw i}}var p=o;o._registeredMethods.remove.forEach((function(e){void 0!==e&&e.call(p)}))}if(o._isGlobal){for(var u in e.prototype)try{delete window[u]}catch(e){window[u]=void 0}for(var h in o)if(o.hasOwnProperty(h))try{delete window[h]}catch(e){window[h]=void 0}e.instance=null}},this._registeredMethods.init.forEach((function(e){void 0!==e&&e.call(this)}),this),this._setupPromisePreloads();var u=this._createFriendlyGlobalFunctionBinder();if(t)t(this);else{for(var h in this._isGlobal=!0,e.instance=this,e.prototype)if("function"==typeof e.prototype[h]){var m=h.substring(2);this._events.hasOwnProperty(m)||(Math.hasOwnProperty(h)&&Math[h]===e.prototype[h]?u(h,e.prototype[h]):u(h,e.prototype[h].bind(this)))}else u(h,e.prototype[h]);for(var f in this)this.hasOwnProperty(f)&&u(f,this[f])}for(var g in this._events){var b=this["_on".concat(g)];if(b){var y=b.bind(this);window.addEventListener(g,y,{passive:!1}),this._events[g]=y}}var v=function(){o._setProperty("focused",!0)},w=function(){o._setProperty("focused",!1)};window.addEventListener("focus",v),window.addEventListener("blur",w),this.registerMethod("remove",(function(){window.removeEventListener("focus",v),window.removeEventListener("blur",w)})),"complete"===document.readyState?this._start():window.addEventListener("load",this._start.bind(this),!1)}var t,n,a;return t=e,n=[{key:"_initializeInstanceVariables",value:function(){this._styles=[],this._bezierDetail=20,this._curveDetail=20,this._colorMode=o.RGB,this._colorMaxes={rgb:[255,255,255,255],hsb:[360,100,100,1],hsl:[360,100,100,1]},this._downKeys={}}},{key:"registerPreloadMethod",value:function(t,n){e.prototype._preloadMethods.hasOwnProperty(t)||(e.prototype._preloadMethods[t]=n)}},{key:"registerMethod",value:function(t,n){var a=this||e.prototype;a._registeredMethods.hasOwnProperty(t)||(a._registeredMethods[t]=[]),a._registeredMethods[t].push(n)}},{key:"_createFriendlyGlobalFunctionBinder",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.globalObject||window,a=t.log||console.log.bind(console),o={print:!0};return function(t,r){if(e.disableFriendlyErrors||"undefined"!=typeof IS_MINIFIED||"function"!=typeof r||t in e.prototype._preloadMethods)n[t]=r;else try{if(t in n&&!(t in o))throw new Error('global "'.concat(t,'" already exists'));Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){return r},set:function(e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}),a('You just changed the value of "'.concat(t,"\", which was a p5 function. This could cause problems later if you're not careful."))}})}catch(e){a('p5 had problems creating the global function "'.concat(t,'", possibly because your code is already using that name as a variable. You may want to rename your variable to something else.')),n[t]=r}}}}],n&&i(t.prototype,n),a&&i(t,a),e}();for(var l in s.instance=null,s.disableFriendlyErrors=!1,o)s.prototype[l]=o[l];s.prototype._preloadMethods={loadJSON:s.prototype,loadImage:s.prototype,loadStrings:s.prototype,loadXML:s.prototype,loadBytes:s.prototype,loadTable:s.prototype,loadFont:s.prototype,loadModel:s.prototype,loadShader:s.prototype},s.prototype._registeredMethods={init:[],pre:[],post:[],remove:[]},s.prototype._registeredPreloadMethods={},n.default=s},{"./constants":43,"./shim":61}],51:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a,o=(a=e("./main"))&&a.__esModule?a:{default:a};o.default.Element=function(e,t){this.elt=e,this._pInst=this._pixelsState=t,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight},o.default.Element.prototype.parent=function(e){return void 0===e?this.elt.parentNode:("string"==typeof e?("#"===e[0]&&(e=e.substring(1)),e=document.getElementById(e)):e instanceof o.default.Element&&(e=e.elt),e.appendChild(this.elt),this)},o.default.Element.prototype.id=function(e){return void 0===e?this.elt.id:(this.elt.id=e,this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight,this)},o.default.Element.prototype.class=function(e){return void 0===e?this.elt.className:(this.elt.className=e,this)},o.default.Element.prototype.mousePressed=function(e){return o.default.Element._adjustListener("mousedown",(function(t){return this._pInst._setProperty("mouseIsPressed",!0),this._pInst._setMouseButton(t),e.call(this)}),this),this},o.default.Element.prototype.doubleClicked=function(e){return o.default.Element._adjustListener("dblclick",e,this),this},o.default.Element.prototype.mouseWheel=function(e){return o.default.Element._adjustListener("wheel",e,this),this},o.default.Element.prototype.mouseReleased=function(e){return o.default.Element._adjustListener("mouseup",e,this),this},o.default.Element.prototype.mouseClicked=function(e){return o.default.Element._adjustListener("click",e,this),this},o.default.Element.prototype.mouseMoved=function(e){return o.default.Element._adjustListener("mousemove",e,this),this},o.default.Element.prototype.mouseOver=function(e){return o.default.Element._adjustListener("mouseover",e,this),this},o.default.Element.prototype.mouseOut=function(e){return o.default.Element._adjustListener("mouseout",e,this),this},o.default.Element.prototype.touchStarted=function(e){return o.default.Element._adjustListener("touchstart",e,this),this},o.default.Element.prototype.touchMoved=function(e){return o.default.Element._adjustListener("touchmove",e,this),this},o.default.Element.prototype.touchEnded=function(e){return o.default.Element._adjustListener("touchend",e,this),this},o.default.Element.prototype.dragOver=function(e){return o.default.Element._adjustListener("dragover",e,this),this},o.default.Element.prototype.dragLeave=function(e){return o.default.Element._adjustListener("dragleave",e,this),this},o.default.Element._adjustListener=function(e,t,n){return!1===t?o.default.Element._detachListener(e,n):o.default.Element._attachListener(e,t,n),this},o.default.Element._attachListener=function(e,t,n){n._events[e]&&o.default.Element._detachListener(e,n);var a=t.bind(n);n.elt.addEventListener(e,a,!1),n._events[e]=a},o.default.Element._detachListener=function(e,t){t.elt.removeEventListener(e,t._events[e],!1),t._events[e]=null},o.default.Element.prototype._setProperty=function(e,t){this[e]=t},n.default=o.default.Element},{"./main":50}],52:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,r=(o=e("./main"))&&o.__esModule?o:{default:o},i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("./constants"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}r.default.Graphics=function(e,t,n,a){var o=n||i.P2D;this.canvas=document.createElement("canvas");var s=a._userNode||document.body;for(var l in s.appendChild(this.canvas),r.default.Element.call(this,this.canvas,a),r.default.prototype)this[l]||(this[l]="function"==typeof r.default.prototype[l]?r.default.prototype[l].bind(this):r.default.prototype[l]);return r.default.prototype._initializeInstanceVariables.apply(this),this.width=e,this.height=t,this._pixelDensity=a._pixelDensity,this._renderer=o===i.WEBGL?new r.default.RendererGL(this.canvas,this,!1):new r.default.Renderer2D(this.canvas,this,!1),a._elements.push(this),this._renderer.resize(e,t),this._renderer._applyDefaults(),this},r.default.Graphics.prototype=Object.create(r.default.Element.prototype),r.default.Graphics.prototype.reset=function(){this._renderer.resetMatrix(),this._renderer.isP3D&&this._renderer._update()},r.default.Graphics.prototype.remove=function(){this.elt.parentNode&&this.elt.parentNode.removeChild(this.elt);var e=this._pInst._elements.indexOf(this);for(var t in-1!==e&&this._pInst._elements.splice(e,1),this._events)this.elt.removeEventListener(t,this._events[t])},n.default=r.default.Graphics},{"./constants":43,"./main":50}],53:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a,o=(a=e("./main"))&&a.__esModule?a:{default:a},r=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==s(e)&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r=a?Object.getOwnPropertyDescriptor(e,o):null;r&&(r.get||r.set)?Object.defineProperty(n,o,r):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(e("../core/constants"));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function l(e){var t=0,n=0;if(e.offsetParent)do{t+=e.offsetLeft,n+=e.offsetTop}while(e=e.offsetParent);else t+=e.offsetLeft,n+=e.offsetTop;return[t,n]}o.default.Renderer=function(e,t,n){o.default.Element.call(this,e,t),this.canvas=e,this._pixelsState=t,n?(this._isMainCanvas=!0,this._pInst._setProperty("_curElement",this),this._pInst._setProperty("canvas",this.canvas),this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height)):(this.canvas.style.display="none",this._styles=[]),this._textSize=12,this._textLeading=15,this._textFont="sans-serif",this._textStyle=r.NORMAL,this._textAscent=null,this._textDescent=null,this._textAlign=r.LEFT,this._textBaseline=r.BASELINE,this._rectMode=r.CORNER,this._ellipseMode=r.CENTER,this._curveTightness=0,this._imageMode=r.CORNER,this._tint=null,this._doStroke=!0,this._doFill=!0,this._strokeSet=!1,this._fillSet=!1},o.default.Renderer.prototype=Object.create(o.default.Element.prototype),o.default.Renderer.prototype.push=function(){return{properties:{_doStroke:this._doStroke,_strokeSet:this._strokeSet,_doFill:this._doFill,_fillSet:this._fillSet,_tint:this._tint,_imageMode:this._imageMode,_rectMode:this._rectMode,_ellipseMode:this._ellipseMode,_textFont:this._textFont,_textLeading:this._textLeading,_textSize:this._textSize,_textAlign:this._textAlign,_textBaseline:this._textBaseline,_textStyle:this._textStyle}}},o.default.Renderer.prototype.pop=function(e){e.properties&&Object.assign(this,e.properties)},o.default.Renderer.prototype.resize=function(e,t){this.width=e,this.height=t,this.elt.width=e*this._pInst._pixelDensity,this.elt.height=t*this._pInst._pixelDensity,this.elt.style.width="".concat(e,"px"),this.elt.style.height="".concat(t,"px"),this._isMainCanvas&&(this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height))},o.default.Renderer.prototype.get=function(e,t,n,a){var r=this._pixelsState,i=r._pixelDensity,s=this.canvas;if(void 0===e&&void 0===t)e=t=0,n=r.width,a=r.height;else if(e*=i,t*=i,void 0===n&&void 0===a)return e<0||t<0||e>=s.width||t>=s.height?[0,0,0,0]:this._getPixel(e,t);var l=new o.default.Image(n,a);return l.canvas.getContext("2d").drawImage(s,e,t,n*i,a*i,0,0,n,a),l},o.default.Renderer.prototype.textLeading=function(e){return"number"==typeof e?(this._setProperty("_textLeading",e),this._pInst):this._textLeading},o.default.Renderer.prototype.textSize=function(e){return"number"==typeof e?(this._setProperty("_textSize",e),this._setProperty("_textLeading",e*r._DEFAULT_LEADMULT),this._applyTextProperties()):this._textSize},o.default.Renderer.prototype.textStyle=function(e){return e?(e!==r.NORMAL&&e!==r.ITALIC&&e!==r.BOLD&&e!==r.BOLDITALIC||this._setProperty("_textStyle",e),this._applyTextProperties()):this._textStyle},o.default.Renderer.prototype.textAscent=function(){return null===this._textAscent&&this._updateTextMetrics(),this._textAscent},o.default.Renderer.prototype.textDescent=function(){return null===this._textDescent&&this._updateTextMetrics(),this._textDescent},o.default.Renderer.prototype.textAlign=function(e,t){return void 0!==e?(this._setProperty("_textAlign",e),void 0!==t&&this._setProperty("_textBaseline",t),this._applyTextProperties()):{horizontal:this._textAlign,vertical:this._textBaseline}},o.default.Renderer.prototype.text=function(e,t,n,a,o){var i,s,l,c,d,p,u,h,m=this._pInst,f=Number.MAX_VALUE;if((this._doFill||this._doStroke)&&void 0!==e){if("string"!=typeof e&&(e=e.toString()),i=(e=e.replace(/(\t)/g," ")).split("\n"),void 0!==a){for(h=0,l=0;la?(d="".concat(u[s]," "),h+=m.textLeading()):d=p;switch(this._rectMode===r.CENTER&&(t-=a/2,n-=o/2),this._textAlign){case r.CENTER:t+=a/2;break;case r.RIGHT:t+=a}var g=!1;if(void 0!==o){switch(this._textBaseline){case r.BOTTOM:n+=o-h;break;case r.CENTER:n+=(o-h)/2;break;case r.BASELINE:g=!0,this._textBaseline=r.TOP}f=n+o-m.textAscent()}for(l=0;la&&d.length>0?(this._renderText(m,d,t,n,f),d="".concat(u[s]," "),n+=m.textLeading()):d=p;this._renderText(m,d,t,n,f),n+=m.textLeading(),g&&(this._textBaseline=r.BASELINE)}}else{var b=0,y=m.textAlign().vertical;for(y===r.CENTER?b=(i.length-1)*m.textLeading()/2:y===r.BOTTOM&&(b=(i.length-1)*m.textLeading()),c=0;c0&&void 0!==arguments[0]?arguments[0]:this._textFont;return"object"===s(e)&&e.font&&e.font.supported},o.default.Renderer.prototype._updateTextMetrics=function(){if(this._isOpenType())return this._setProperty("_textAscent",this._textFont._textAscent()),this._setProperty("_textDescent",this._textFont._textDescent()),this;var e=document.createElement("span");e.style.fontFamily=this._textFont,e.style.fontSize="".concat(this._textSize,"px"),e.innerHTML="ABCjgq|";var t=document.createElement("div");t.style.display="inline-block",t.style.width="1px",t.style.height="0px";var n=document.createElement("div");n.appendChild(e),n.appendChild(t),n.style.height="0px",n.style.overflow="hidden",document.body.appendChild(n),t.style.verticalAlign="baseline";var a=l(t),o=l(e),r=a[1]-o[1];t.style.verticalAlign="bottom",a=l(t),o=l(e);var i=a[1]-o[1]-r;return document.body.removeChild(n),this._setProperty("_textAscent",r),this._setProperty("_textDescent",i),this},n.default=o.default.Renderer},{"../core/constants":43,"./main":50}],54:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o=l(e("./main")),r=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("./constants")),i=l(e("../image/filters"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function l(e){return e&&e.__esModule?e:{default:e}}e("./p5.Renderer");var c="rgba(0,0,0,0)";o.default.Renderer2D=function(e,t,n){return o.default.Renderer.call(this,e,t,n),this.drawingContext=this.canvas.getContext("2d"),this._pInst._setProperty("drawingContext",this.drawingContext),this},o.default.Renderer2D.prototype=Object.create(o.default.Renderer.prototype),o.default.Renderer2D.prototype._applyDefaults=function(){this._cachedFillStyle=this._cachedStrokeStyle=void 0,this._cachedBlendMode=r.BLEND,this._setFill(r._DEFAULT_FILL),this._setStroke(r._DEFAULT_STROKE),this.drawingContext.lineCap=r.ROUND,this.drawingContext.font="normal 12px sans-serif"},o.default.Renderer2D.prototype.resize=function(e,t){o.default.Renderer.prototype.resize.call(this,e,t),this.drawingContext.scale(this._pInst._pixelDensity,this._pInst._pixelDensity)},o.default.Renderer2D.prototype.background=function(){if(this.drawingContext.save(),this.resetMatrix(),(arguments.length<=0?void 0:arguments[0])instanceof o.default.Image)this._pInst.image(arguments.length<=0?void 0:arguments[0],0,0,this.width,this.height);else{var e,t=this._getFill(),n=(e=this._pInst).color.apply(e,arguments).toString();this._setFill(n),this._isErasing&&this.blendMode(this._cachedBlendMode),this.drawingContext.fillRect(0,0,this.width,this.height),this._setFill(t),this._isErasing&&this._pInst.erase()}this.drawingContext.restore()},o.default.Renderer2D.prototype.clear=function(){this.drawingContext.save(),this.resetMatrix(),this.drawingContext.clearRect(0,0,this.width,this.height),this.drawingContext.restore()},o.default.Renderer2D.prototype.fill=function(){var e,t=(e=this._pInst).color.apply(e,arguments);this._setFill(t.toString())},o.default.Renderer2D.prototype.stroke=function(){var e,t=(e=this._pInst).color.apply(e,arguments);this._setStroke(t.toString())},o.default.Renderer2D.prototype.erase=function(e,t){if(!this._isErasing){this._cachedFillStyle=this.drawingContext.fillStyle;var n=this._pInst.color(255,e).toString();this.drawingContext.fillStyle=n,this._cachedStrokeStyle=this.drawingContext.strokeStyle;var a=this._pInst.color(255,t).toString();this.drawingContext.strokeStyle=a;var o=this._cachedBlendMode;this.blendMode(r.REMOVE),this._cachedBlendMode=o,this._isErasing=!0}},o.default.Renderer2D.prototype.noErase=function(){this._isErasing&&(this.drawingContext.fillStyle=this._cachedFillStyle,this.drawingContext.strokeStyle=this._cachedStrokeStyle,this.blendMode(this._cachedBlendMode),this._isErasing=!1)},o.default.Renderer2D.prototype.image=function(e,t,n,a,r,i,s,l,c){var d;e.gifProperties&&e._animateGif(this._pInst);try{this._tint&&(o.default.MediaElement&&e instanceof o.default.MediaElement&&e.loadPixels(),e.canvas&&(d=this._getTintedImageCanvas(e))),d||(d=e.canvas||e.elt);var p=1;e.width&&e.width>0&&(p=d.width/e.width),this._isErasing&&this.blendMode(this._cachedBlendMode),this.drawingContext.drawImage(d,p*t,p*n,p*a,p*r,i,s,l,c),this._isErasing&&this._pInst.erase()}catch(e){if("NS_ERROR_NOT_AVAILABLE"!==e.name)throw e}},o.default.Renderer2D.prototype._getTintedImageCanvas=function(e){if(!e.canvas)return e;var t=i.default._toPixels(e.canvas),n=document.createElement("canvas");n.width=e.canvas.width,n.height=e.canvas.height;for(var a=n.getContext("2d"),o=a.createImageData(e.canvas.width,e.canvas.height),r=o.data,s=0;s=1e-5;)p=Math.min(i-o,r.HALF_PI),u.push(this._acuteArcToBezier(o,p)),o+=p;return this._doFill&&(l.beginPath(),u.forEach((function(n,a){0===a&&l.moveTo(e+n.ax*c,t+n.ay*d),l.bezierCurveTo(e+n.bx*c,t+n.by*d,e+n.cx*c,t+n.cy*d,e+n.dx*c,t+n.dy*d)})),s!==r.PIE&&null!=s||l.lineTo(e,t),l.closePath(),l.fill()),this._doStroke&&(l.beginPath(),u.forEach((function(n,a){0===a&&l.moveTo(e+n.ax*c,t+n.ay*d),l.bezierCurveTo(e+n.bx*c,t+n.by*d,e+n.cx*c,t+n.cy*d,e+n.dx*c,t+n.dy*d)})),s===r.PIE?(l.lineTo(e,t),l.closePath()):s===r.CHORD&&l.closePath(),l.stroke()),this},o.default.Renderer2D.prototype.ellipse=function(e){var t=this.drawingContext,n=this._doFill,a=this._doStroke,o=parseFloat(e[0]),r=parseFloat(e[1]),i=parseFloat(e[2]),s=parseFloat(e[3]);if(n&&!a){if(this._getFill()===c)return this}else if(!n&&a&&this._getStroke()===c)return this;var l=.5522847498,d=i/2*l,p=s/2*l,u=o+i,h=r+s,m=o+i/2,f=r+s/2;t.beginPath(),t.moveTo(o,f),t.bezierCurveTo(o,f-p,m-d,r,m,r),t.bezierCurveTo(m+d,r,u,f-p,u,f),t.bezierCurveTo(u,f+p,m+d,h,m,h),t.bezierCurveTo(m-d,h,o,f+p,o,f),t.closePath(),n&&t.fill(),a&&t.stroke()},o.default.Renderer2D.prototype.line=function(e,t,n,a){var o=this.drawingContext;return this._doStroke?(this._getStroke()===c||(o.beginPath(),o.moveTo(e,t),o.lineTo(n,a),o.stroke()),this):this},o.default.Renderer2D.prototype.point=function(e,t){var n=this.drawingContext;if(!this._doStroke)return this;if(this._getStroke()===c)return this;var a=this._getStroke(),o=this._getFill();e=Math.round(e),t=Math.round(t),this._setFill(a),n.lineWidth>1?(n.beginPath(),n.arc(e,t,n.lineWidth/2,0,r.TWO_PI,!1),n.fill()):n.fillRect(e,t,1,1),this._setFill(o)},o.default.Renderer2D.prototype.quad=function(e,t,n,a,o,r,i,s){var l=this.drawingContext,d=this._doFill,p=this._doStroke;if(d&&!p){if(this._getFill()===c)return this}else if(!d&&p&&this._getStroke()===c)return this;return l.beginPath(),l.moveTo(e,t),l.lineTo(n,a),l.lineTo(o,r),l.lineTo(i,s),l.closePath(),d&&l.fill(),p&&l.stroke(),this},o.default.Renderer2D.prototype.rect=function(e){var t=e[0],n=e[1],a=e[2],o=e[3],r=e[4],i=e[5],s=e[6],l=e[7],d=this.drawingContext,p=this._doFill,u=this._doStroke;if(p&&!u){if(this._getFill()===c)return this}else if(!p&&u&&this._getStroke()===c)return this;if(d.beginPath(),void 0===r)d.rect(t,n,a,o);else{void 0===i&&(i=r),void 0===s&&(s=i),void 0===l&&(l=s);var h=Math.abs(a),m=Math.abs(o),f=h/2,g=m/2;h<2*r&&(r=f),m<2*r&&(r=g),h<2*i&&(i=f),m<2*i&&(i=g),h<2*s&&(s=f),m<2*s&&(s=g),h<2*l&&(l=f),m<2*l&&(l=g),d.beginPath(),d.moveTo(t+r,n),d.arcTo(t+a,n,t+a,n+o,i),d.arcTo(t+a,n+o,t,n+o,s),d.arcTo(t,n+o,t,n,l),d.arcTo(t,n,t+a,n,r),d.closePath()}return this._doFill&&d.fill(),this._doStroke&&d.stroke(),this},o.default.Renderer2D.prototype.triangle=function(e){var t=this.drawingContext,n=this._doFill,a=this._doStroke,o=e[0],r=e[1],i=e[2],s=e[3],l=e[4],d=e[5];if(n&&!a){if(this._getFill()===c)return this}else if(!n&&a&&this._getStroke()===c)return this;t.beginPath(),t.moveTo(o,r),t.lineTo(i,s),t.lineTo(l,d),t.closePath(),n&&t.fill(),a&&t.stroke()},o.default.Renderer2D.prototype.endShape=function(e,t,n,a,o,i,s){if(0===t.length)return this;if(!this._doStroke&&!this._doFill)return this;var l,c,d,p=e===r.CLOSE;p&&!i&&t.push(t[0]);var u=t.length;if(!n||s!==r.POLYGON&&null!==s)if(!a||s!==r.POLYGON&&null!==s)if(!o||s!==r.POLYGON&&null!==s)if(s===r.POINTS)for(c=0;c2){for(this.drawingContext.beginPath(),c=2;c3)for(c=0;c+13){var h=[],m=1-this._curveTightness;for(this.drawingContext.beginPath(),this.drawingContext.moveTo(t[1][0],t[1][1]),c=1;c+2=o))return e.push(),this._isOpenType()?this._textFont._renderPath(t,n,a,{renderer:this}):(this._doStroke&&this._strokeSet&&this.drawingContext.strokeText(t,n,a),this._doFill&&(this._fillSet||this._setFill(r._DEFAULT_TEXT_FILL),this.drawingContext.fillText(t,n,a))),e.pop(),e},o.default.Renderer2D.prototype.textWidth=function(e){return this._isOpenType()?this._textFont._textWidth(e,this._textSize):this.drawingContext.measureText(e).width},o.default.Renderer2D.prototype._applyTextProperties=function(){var e,t=this._pInst;return this._setProperty("_textAscent",null),this._setProperty("_textDescent",null),e=this._textFont,this._isOpenType()&&(e=this._textFont.font.familyName,this._setProperty("_textStyle",this._textFont.font.styleName)),this.drawingContext.font="".concat(this._textStyle||"normal"," ").concat(this._textSize||12,"px ").concat(e||"sans-serif"),this.drawingContext.textAlign=this._textAlign,this.drawingContext.textBaseline=this._textBaseline===r.CENTER?r._CTX_MIDDLE:this._textBaseline,t},o.default.Renderer2D.prototype.push=function(){return this.drawingContext.save(),o.default.Renderer.prototype.push.apply(this)},o.default.Renderer2D.prototype.pop=function(e){this.drawingContext.restore(),this._cachedFillStyle=this.drawingContext.fillStyle,this._cachedStrokeStyle=this.drawingContext.strokeStyle,o.default.Renderer.prototype.pop.call(this,e)},n.default=o.default.Renderer2D},{"../image/filters":71,"./constants":43,"./main":50,"./p5.Renderer":53}],55:[function(e,t,n){"use strict";var a,o=(a=e("./main"))&&a.__esModule?a:{default:a};o.default.prototype._promisePreloads=[],o.default.prototype.registerPromisePreload=function(e){o.default.prototype._promisePreloads.push(e)};var r=!1;o.default.prototype._setupPromisePreloads=function(){var e=!0,t=!1,n=void 0;try{for(var a,i=this._promisePreloads[Symbol.iterator]();!(e=(a=i.next()).done);e=!0){var s=a.value,l=this,c=s.method,d=s.addCallbacks,p=s.legacyPreloadSetup,u=s.target||this,h=u[c].bind(u);if(u===o.default.prototype){if(r)continue;l=null,h=u[c]}if(u[c]=this._wrapPromisePreload(l,h,d),p)u[p.method]=this._legacyPreloadGenerator(l,p,u[c])}}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}r=!0},o.default.prototype._wrapPromisePreload=function(e,t,n){var a=function(){var e=this;this._incrementPreload();for(var a=null,o=null,r=arguments.length,i=new Array(r),s=0;s=0&&!o&&"function"==typeof i[l];l--)o=a,a=i.pop();var c=Promise.resolve(t.apply(this,i));return a&&c.then(a),o&&c.catch(o),c.then((function(){return e._decrementPreload()})),c};return e&&(a=a.bind(e)),a};var i=function(){return{}};o.default.prototype._legacyPreloadGenerator=function(e,t,n){var a=t.createBaseObject||i,o=function(){var e=this;this._incrementPreload();var t=a.apply(this,arguments);return n.apply(this,arguments).then((function(n){Object.assign(t,n),e._decrementPreload()})),t};return e&&(o=o.bind(e)),o}},{"./main":50}],56:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a,o=(a=e("./main"))&&a.__esModule?a:{default:a},r=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==s(e)&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r=a?Object.getOwnPropertyDescriptor(e,o):null;r&&(r.get||r.set)?Object.defineProperty(n,o,r):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(e("./constants"));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}e("./p5.Graphics"),e("./p5.Renderer2D"),e("../webgl/p5.RendererGL");var l="defaultCanvas0",c="p5Canvas";o.default.prototype.createCanvas=function(e,t,n){o.default._validateParameters("createCanvas",arguments);var a,i=n||r.P2D;if(i===r.WEBGL){if(a=document.getElementById(l)){a.parentNode.removeChild(a);var s=this._renderer;this._elements=this._elements.filter((function(e){return e!==s}))}(a=document.createElement("canvas")).id=l,a.classList.add(c)}else if(this._defaultGraphicsCreated)a=this.canvas;else{a=document.createElement("canvas");for(var d=0;document.getElementById("defaultCanvas".concat(d));)d++;l="defaultCanvas".concat(d),a.id=l,a.classList.add(c)}return this._setupDone||(a.dataset.hidden=!0,a.style.visibility="hidden"),this._userNode?this._userNode.appendChild(a):document.body.appendChild(a),i===r.WEBGL?(this._setProperty("_renderer",new o.default.RendererGL(a,this,!0)),this._elements.push(this._renderer)):this._defaultGraphicsCreated||(this._setProperty("_renderer",new o.default.Renderer2D(a,this,!0)),this._defaultGraphicsCreated=!0,this._elements.push(this._renderer)),this._renderer.resize(e,t),this._renderer._applyDefaults(),this._renderer},o.default.prototype.resizeCanvas=function(e,t,n){if(o.default._validateParameters("resizeCanvas",arguments),this._renderer){var a={};for(var r in this.drawingContext){var i=this.drawingContext[r];"object"!==s(i)&&"function"!=typeof i&&(a[r]=i)}for(var l in this._renderer.resize(e,t),this.width=e,this.height=t,a)try{this.drawingContext[l]=a[l]}catch(e){}n||this.redraw()}},o.default.prototype.noCanvas=function(){this.canvas&&this.canvas.parentNode.removeChild(this.canvas)},o.default.prototype.createGraphics=function(e,t,n){return o.default._validateParameters("createGraphics",arguments),new o.default.Graphics(e,t,n,this)},o.default.prototype.blendMode=function(e){o.default._validateParameters("blendMode",arguments),e===r.NORMAL&&(console.warn("NORMAL has been deprecated for use in blendMode. defaulting to BLEND instead."),e=r.BLEND),this._renderer.blendMode(e)},n.default=o.default},{"../webgl/p5.RendererGL":104,"./constants":43,"./main":50,"./p5.Graphics":52,"./p5.Renderer2D":54}],57:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o=l(e("../main")),r=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("../constants")),i=l(e("../helpers"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function l(e){return e&&e.__esModule?e:{default:e}}e("../error_helpers"),o.default.prototype._normalizeArcAngles=function(e,t,n,a,o){var i;return e-=r.TWO_PI*Math.floor(e/r.TWO_PI),t-=r.TWO_PI*Math.floor(t/r.TWO_PI),i=Math.min(Math.abs(e-t),r.TWO_PI-Math.abs(e-t)),o&&(e=e<=r.HALF_PI?Math.atan(n/a*Math.tan(e)):e>r.HALF_PI&&e<=3*r.HALF_PI?Math.atan(n/a*Math.tan(e))+r.PI:Math.atan(n/a*Math.tan(e))+r.TWO_PI,t=t<=r.HALF_PI?Math.atan(n/a*Math.tan(t)):t>r.HALF_PI&&t<=3*r.HALF_PI?Math.atan(n/a*Math.tan(t))+r.PI:Math.atan(n/a*Math.tan(t))+r.TWO_PI),e>t&&(t+=r.TWO_PI),{start:e,stop:t,correspondToSamePoint:i<1e-5}},o.default.prototype.arc=function(e,t,n,a,r,s,l,c){if(o.default._validateParameters("arc",arguments),!this._renderer._doStroke&&!this._renderer._doFill)return this;r=this._toRadians(r),s=this._toRadians(s),n=Math.abs(n),a=Math.abs(a);var d=i.default.modeAdjust(e,t,n,a,this._renderer._ellipseMode),p=this._normalizeArcAngles(r,s,d.w,d.h,!0);return p.correspondToSamePoint?this._renderer.ellipse([d.x,d.y,d.w,d.h,c]):this._renderer.arc(d.x,d.y,d.w,d.h,p.start,p.stop,l,c),this},o.default.prototype.ellipse=function(e,t,n,a,r){return o.default._validateParameters("ellipse",arguments),this._renderEllipse.apply(this,arguments)},o.default.prototype.circle=function(){o.default._validateParameters("circle",arguments);var e=Array.prototype.slice.call(arguments,0,2);return e.push(arguments[2]),e.push(arguments[2]),this._renderEllipse.apply(this,e)},o.default.prototype._renderEllipse=function(e,t,n,a,o){if(!this._renderer._doStroke&&!this._renderer._doFill)return this;n<0&&(n=Math.abs(n)),void 0===a?a=n:a<0&&(a=Math.abs(a));var r=i.default.modeAdjust(e,t,n,a,this._renderer._ellipseMode);return this._renderer.ellipse([r.x,r.y,r.w,r.h,o]),this},o.default.prototype.line=function(){for(var e=arguments.length,t=new Array(e),n=0;n0){h=!0;for(var s=[],l=0;l0&&t.every((function(e){return"INPUT"===e.tagName||"LABEL"===e.tagName}))?this.createRadio(new o.default.Element(e,this)):new o.default.Element(e,this)},o.default.prototype.removeElements=function(e){o.default._validateParameters("removeElements",arguments);for(var t=0;t1&&"string"==typeof n[1]&&(t.alt=n[1]),n.length>2&&"string"==typeof n[2]&&(t.crossOrigin=n[2]),t.src=n[0],e=s(t,this),t.addEventListener("load",(function(){e.width=t.offsetWidth||t.width,e.height=t.offsetHeight||t.height;var a=n[n.length-1];"function"==typeof a&&a(e)})),e},o.default.prototype.createA=function(e,t,n){o.default._validateParameters("createA",arguments);var a=document.createElement("a");return a.href=e,a.innerHTML=t,n&&(a.target=n),s(a,this)},o.default.prototype.createSlider=function(e,t,n,a){o.default._validateParameters("createSlider",arguments);var r=document.createElement("input");return r.type="range",r.min=e,r.max=t,0===a?r.step=1e-18:a&&(r.step=a),"number"==typeof n&&(r.value=n),s(r,this)},o.default.prototype.createButton=function(e,t){o.default._validateParameters("createButton",arguments);var n=document.createElement("button");return n.innerHTML=e,t&&(n.value=t),s(n,this)},o.default.prototype.createCheckbox=function(){o.default._validateParameters("createCheckbox",arguments);var e=document.createElement("div"),t=document.createElement("input");t.type="checkbox",e.appendChild(t);var n=s(e,this);if(n.checked=function(){var e=n.elt.getElementsByTagName("input")[0];if(e){if(0===arguments.length)return e.checked;e.checked=!!arguments[0]}return n},this.value=function(e){return n.value=e,this},arguments[0]){var a=Math.random().toString(36).slice(2),r=document.createElement("label");t.setAttribute("id",a),r.htmlFor=a,n.value(arguments[0]),r.appendChild(document.createTextNode(arguments[0])),e.appendChild(r)}return arguments[1]&&(t.checked=!0),n},o.default.prototype.createSelect=function(){var e,t;o.default._validateParameters("createSelect",arguments);var n=arguments[0];return"object"===r(n)&&"SELECT"===n.elt.nodeName?(t=n,e=this.elt=n.elt):(e=document.createElement("select"),n&&"boolean"==typeof n&&e.setAttribute("multiple","true"),t=s(e,this)),t.option=function(t,n){for(var a,o=0;o1?n:t,e.appendChild(r),this._pInst._elements.push(r)}},t.selected=function(e){var t,n=[];if(arguments.length>0){for(t=0;t1){var l=a.length,c=a[0].name,d=a[1].name;i=1;for(var p=1;p2&&(this.elt.style.transform="translate3d("+arguments[0]+"px,"+arguments[1]+"px,"+arguments[2]+"px)",this.elt.parentElement.style.perspective=3===arguments.length?"1000px":arguments[3]+"px"),this.elt.style.transform+=e,this},o.default.Element.prototype._rotate=function(){var e="";return this.elt.style.transform&&(e=(e=this.elt.style.transform.replace(/rotate3d\(.*\)/g,"")).replace(/rotate[X-Z]?\(.*\)/g,"")),1===arguments.length?this.elt.style.transform="rotate("+arguments[0]+"deg)":2===arguments.length?this.elt.style.transform="rotate("+arguments[0]+"deg, "+arguments[1]+"deg)":3===arguments.length&&(this.elt.style.transform="rotateX("+arguments[0]+"deg)",this.elt.style.transform+="rotateY("+arguments[1]+"deg)",this.elt.style.transform+="rotateZ("+arguments[2]+"deg)"),this.elt.style.transform+=e,this},o.default.Element.prototype.style=function(e,t){if(t instanceof o.default.Color&&(t="rgba("+t.levels[0]+","+t.levels[1]+","+t.levels[2]+","+t.levels[3]/255+")"),void 0===t){if(-1===e.indexOf(":"))return window.getComputedStyle(this.elt).getPropertyValue(e);for(var n=e.split(";"),a=0;a0?(this.elt.value=arguments[0],this):"range"===this.elt.type?parseFloat(this.elt.value):this.elt.value},o.default.Element.prototype.show=function(){return this.elt.style.display="block",this},o.default.Element.prototype.hide=function(){return this.elt.style.display="none",this},o.default.Element.prototype.size=function(e,t){if(0===arguments.length)return{width:this.elt.offsetWidth,height:this.elt.offsetHeight};var n=e,a=t,r=o.default.prototype.AUTO;if(n!==r||a!==r){if(n===r?n=t*this.width/this.height:a===r&&(a=e*this.height/this.width),this.elt instanceof HTMLCanvasElement){var i,s={},l=this.elt.getContext("2d");for(i in l)s[i]=l[i];for(i in this.elt.setAttribute("width",n*this._pInst._pixelDensity),this.elt.setAttribute("height",a*this._pInst._pixelDensity),this.elt.style.width=n+"px",this.elt.style.height=a+"px",this._pInst.scale(this._pInst._pixelDensity,this._pInst._pixelDensity),s)this.elt.getContext("2d")[i]=s[i]}else this.elt.style.width=n+"px",this.elt.style.height=a+"px",this.elt.width=n,this.elt.height=a;this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight,this._pInst&&this._pInst._curElement&&this._pInst._curElement.elt===this.elt&&(this._pInst._setProperty("width",this.elt.offsetWidth),this._pInst._setProperty("height",this.elt.offsetHeight))}return this},o.default.Element.prototype.remove=function(){this instanceof o.default.MediaElement&&this.elt.srcObject.getTracks().forEach((function(e){e.stop()}));var e=this._pInst._elements.indexOf(this);for(var t in-1!==e&&this._pInst._elements.splice(e,1),this._events)this.elt.removeEventListener(t,this._events[t]);this.elt&&this.elt.parentNode&&this.elt.parentNode.removeChild(this.elt)},o.default.Element.prototype.drop=function(e,t){if(window.File&&window.FileReader&&window.FileList&&window.Blob){if(!this._dragDisabled){this._dragDisabled=!0;var n=function(e){e.preventDefault()};this.elt.addEventListener("dragover",n),this.elt.addEventListener("dragleave",n)}o.default.Element._attachListener("drop",(function(n){n.preventDefault(),"function"==typeof t&&t.call(this,n);for(var a=n.dataTransfer.files,r=0;r1||this.elt.load(),(e=this.elt.play())&&e.catch&&e.catch((function(e){"NotAllowedError"===e.name?o.default._friendlyAutoplayError(this.src):console.error("Media play method encountered an unexpected error",e)})),this},o.default.MediaElement.prototype.stop=function(){return this.elt.pause(),this.elt.currentTime=0,this},o.default.MediaElement.prototype.pause=function(){return this.elt.pause(),this},o.default.MediaElement.prototype.loop=function(){return this.elt.setAttribute("loop",!0),this.play(),this},o.default.MediaElement.prototype.noLoop=function(){return this.elt.setAttribute("loop",!1),this},o.default.MediaElement.prototype._setupAutoplayFailDetection=function(){var e=this,t=setTimeout((function(){return o.default._friendlyAutoplayError(e.src)}),500);this.elt.addEventListener("play",(function(){return clearTimeout(t)}),{passive:!0,once:!0})},o.default.MediaElement.prototype.autoplay=function(e){var t=this,n=this.elt.getAttribute("autoplay");if(this.elt.setAttribute("autoplay",e),e&&!n){var a=function(){return t._setupAutoplayFailDetection()};4===this.elt.readyState?a():this.elt.addEventListener("canplay",a,{passive:!0,once:!0})}return this},o.default.MediaElement.prototype.volume=function(e){if(void 0===e)return this.elt.volume;this.elt.volume=e},o.default.MediaElement.prototype.speed=function(e){if(void 0===e)return this.presetPlaybackRate||this.elt.playbackRate;this.loadedmetadata?this.elt.playbackRate=e:this.presetPlaybackRate=e},o.default.MediaElement.prototype.time=function(e){return void 0===e?this.elt.currentTime:(this.elt.currentTime=e,this)},o.default.MediaElement.prototype.duration=function(){return this.elt.duration},o.default.MediaElement.prototype.pixels=[],o.default.MediaElement.prototype._ensureCanvas=function(){this.canvas||(this.canvas=document.createElement("canvas"),this.drawingContext=this.canvas.getContext("2d"),this.setModified(!0)),this.loadedmetadata&&(this.canvas.width!==this.elt.width&&(this.canvas.width=this.elt.width,this.canvas.height=this.elt.height,this.width=this.canvas.width,this.height=this.canvas.height),this.drawingContext.drawImage(this.elt,0,0,this.canvas.width,this.canvas.height),this.setModified(!0))},o.default.MediaElement.prototype.loadPixels=function(){return this._ensureCanvas(),o.default.Renderer2D.prototype.loadPixels.apply(this,arguments)},o.default.MediaElement.prototype.updatePixels=function(e,t,n,a){return this.loadedmetadata&&(this._ensureCanvas(),o.default.Renderer2D.prototype.updatePixels.call(this,e,t,n,a)),this.setModified(!0),this},o.default.MediaElement.prototype.get=function(){return this._ensureCanvas(),o.default.Renderer2D.prototype.get.apply(this,arguments)},o.default.MediaElement.prototype._getPixel=function(){return this.loadPixels(),o.default.Renderer2D.prototype._getPixel.apply(this,arguments)},o.default.MediaElement.prototype.set=function(e,t,n){this.loadedmetadata&&(this._ensureCanvas(),o.default.Renderer2D.prototype.set.call(this,e,t,n),this.setModified(!0))},o.default.MediaElement.prototype.copy=function(){this._ensureCanvas(),o.default.prototype.copy.apply(this,arguments)},o.default.MediaElement.prototype.mask=function(){this.loadPixels(),this.setModified(!0),o.default.Image.prototype.mask.apply(this,arguments)},o.default.MediaElement.prototype.isModified=function(){return this._modified},o.default.MediaElement.prototype.setModified=function(e){this._modified=e},o.default.MediaElement.prototype.onended=function(e){return this._onended=e,this},o.default.MediaElement.prototype.connect=function(e){var t,n;if("function"==typeof o.default.prototype.getAudioContext)t=o.default.prototype.getAudioContext(),n=o.default.soundOut.input;else try{n=(t=e.context).destination}catch(e){throw"connect() is meant to be used with Web Audio API or p5.sound.js"}this.audioSourceNode||(this.audioSourceNode=t.createMediaElementSource(this.elt),this.audioSourceNode.connect(n)),this.audioSourceNode.connect(e?e.input?e.input:e:n)},o.default.MediaElement.prototype.disconnect=function(){if(!this.audioSourceNode)throw"nothing to disconnect";this.audioSourceNode.disconnect()},o.default.MediaElement.prototype.showControls=function(){this.elt.style["text-align"]="inherit",this.elt.controls=!0},o.default.MediaElement.prototype.hideControls=function(){this.elt.controls=!1};var c=function(e,t,n,a){this.callback=e,this.time=t,this.id=n,this.val=a};o.default.MediaElement.prototype.addCue=function(e,t,n){var a=this._cueIDCounter++,o=new c(t,e,a,n);return this._cues.push(o),this.elt.ontimeupdate||(this.elt.ontimeupdate=this._onTimeUpdate.bind(this)),a},o.default.MediaElement.prototype.removeCue=function(e){for(var t=0;t1?"landscape":"portrait",r.default.prototype.accelerationX=0,r.default.prototype.accelerationY=0,r.default.prototype.accelerationZ=0,r.default.prototype.pAccelerationX=0,r.default.prototype.pAccelerationY=0,r.default.prototype.pAccelerationZ=0,r.default.prototype._updatePAccelerations=function(){this._setProperty("pAccelerationX",this.accelerationX),this._setProperty("pAccelerationY",this.accelerationY),this._setProperty("pAccelerationZ",this.accelerationZ)},r.default.prototype.rotationX=0,r.default.prototype.rotationY=0,r.default.prototype.rotationZ=0,r.default.prototype.pRotationX=0,r.default.prototype.pRotationY=0,r.default.prototype.pRotationZ=0;var l=0,c=0,d=0,p="clockwise",u="clockwise",h="clockwise";r.default.prototype.pRotateDirectionX=void 0,r.default.prototype.pRotateDirectionY=void 0,r.default.prototype.pRotateDirectionZ=void 0,r.default.prototype._updatePRotations=function(){this._setProperty("pRotationX",this.rotationX),this._setProperty("pRotationY",this.rotationY),this._setProperty("pRotationZ",this.rotationZ)},r.default.prototype.turnAxis=void 0;var m=.5,f=30;r.default.prototype.setMoveThreshold=function(e){r.default._validateParameters("setMoveThreshold",arguments),m=e},r.default.prototype.setShakeThreshold=function(e){r.default._validateParameters("setShakeThreshold",arguments),f=e},r.default.prototype._ondeviceorientation=function(e){this._updatePRotations(),this._angleMode===i.radians&&(e.beta=e.beta*(_PI/180),e.gamma=e.gamma*(_PI/180),e.alpha=e.alpha*(_PI/180)),this._setProperty("rotationX",e.beta),this._setProperty("rotationY",e.gamma),this._setProperty("rotationZ",e.alpha),this._handleMotion()},r.default.prototype._ondevicemotion=function(e){this._updatePAccelerations(),this._setProperty("accelerationX",2*e.acceleration.x),this._setProperty("accelerationY",2*e.acceleration.y),this._setProperty("accelerationZ",2*e.acceleration.z),this._handleMotion()},r.default.prototype._handleMotion=function(){90===window.orientation||-90===window.orientation?this._setProperty("deviceOrientation","landscape"):0===window.orientation?this._setProperty("deviceOrientation","portrait"):void 0===window.orientation&&this._setProperty("deviceOrientation","undefined");var e=this.deviceMoved||window.deviceMoved;"function"==typeof e&&(Math.abs(this.accelerationX-this.pAccelerationX)>m||Math.abs(this.accelerationY-this.pAccelerationY)>m||Math.abs(this.accelerationZ-this.pAccelerationZ)>m)&&e();var t=this.deviceTurned||window.deviceTurned;if("function"==typeof t){var n=this.rotationX+180,a=this.pRotationX+180,o=l+180;n-a>0&&n-a<270||n-a<-270?p="clockwise":(n-a<0||n-a>270)&&(p="counter-clockwise"),p!==this.pRotateDirectionX&&(o=n),Math.abs(n-o)>90&&Math.abs(n-o)<270&&(o=n,this._setProperty("turnAxis","X"),t()),this.pRotateDirectionX=p,l=o-180;var r=this.rotationY+180,i=this.pRotationY+180,s=c+180;r-i>0&&r-i<270||r-i<-270?u="clockwise":(r-i<0||r-this.pRotationY>270)&&(u="counter-clockwise"),u!==this.pRotateDirectionY&&(s=r),Math.abs(r-s)>90&&Math.abs(r-s)<270&&(s=r,this._setProperty("turnAxis","Y"),t()),this.pRotateDirectionY=u,c=s-180,this.rotationZ-this.pRotationZ>0&&this.rotationZ-this.pRotationZ<270||this.rotationZ-this.pRotationZ<-270?h="clockwise":(this.rotationZ-this.pRotationZ<0||this.rotationZ-this.pRotationZ>270)&&(h="counter-clockwise"),h!==this.pRotateDirectionZ&&(d=this.rotationZ),Math.abs(this.rotationZ-d)>90&&Math.abs(this.rotationZ-d)<270&&(d=this.rotationZ,this._setProperty("turnAxis","Z"),t()),this.pRotateDirectionZ=h,this._setProperty("turnAxis",void 0)}var g,b,y=this.deviceShaken||window.deviceShaken;"function"==typeof y&&(null!==this.pAccelerationX&&(g=Math.abs(this.accelerationX-this.pAccelerationX),b=Math.abs(this.accelerationY-this.pAccelerationY)),g+b>f&&y())},n.default=r.default},{"../core/constants":43,"../core/main":50}],68:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a,o=(a=e("../core/main"))&&a.__esModule?a:{default:a};o.default.prototype.isKeyPressed=!1,o.default.prototype.keyIsPressed=!1,o.default.prototype.key="",o.default.prototype.keyCode=0,o.default.prototype._onkeydown=function(e){if(!this._downKeys[e.which]){this._setProperty("isKeyPressed",!0),this._setProperty("keyIsPressed",!0),this._setProperty("keyCode",e.which),this._downKeys[e.which]=!0,this._setProperty("key",e.key||String.fromCharCode(e.which)||e.which);var t=this.keyPressed||window.keyPressed;if("function"==typeof t&&!e.charCode)!1===t(e)&&e.preventDefault()}},o.default.prototype._onkeyup=function(e){var t=this.keyReleased||window.keyReleased;(this._downKeys[e.which]=!1,this._areDownKeys()||(this._setProperty("isKeyPressed",!1),this._setProperty("keyIsPressed",!1)),this._setProperty("_lastKeyCodeTyped",null),this._setProperty("key",e.key||String.fromCharCode(e.which)||e.which),this._setProperty("keyCode",e.which),"function"==typeof t)&&(!1===t(e)&&e.preventDefault())},o.default.prototype._onkeypress=function(e){if(e.which!==this._lastKeyCodeTyped){this._setProperty("_lastKeyCodeTyped",e.which),this._setProperty("key",String.fromCharCode(e.which));var t=this.keyTyped||window.keyTyped;if("function"==typeof t)!1===t(e)&&e.preventDefault()}},o.default.prototype._onblur=function(e){this._downKeys={}},o.default.prototype.keyIsDown=function(e){return o.default._validateParameters("keyIsDown",arguments),this._downKeys[e]||!1},o.default.prototype._areDownKeys=function(){for(var e in this._downKeys)if(this._downKeys.hasOwnProperty(e)&&!0===this._downKeys[e])return!0;return!1},n.default=o.default},{"../core/main":50}],69:[function(e,t,n){"use strict";function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,r=(o=e("../core/main"))&&o.__esModule?o:{default:o},i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(e("../core/constants"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}r.default.prototype.movedX=0,r.default.prototype.movedY=0,r.default.prototype._hasMouseInteracted=!1,r.default.prototype.mouseX=0,r.default.prototype.mouseY=0,r.default.prototype.pmouseX=0,r.default.prototype.pmouseY=0,r.default.prototype.winMouseX=0,r.default.prototype.winMouseY=0,r.default.prototype.pwinMouseX=0,r.default.prototype.pwinMouseY=0,r.default.prototype.mouseButton=0,r.default.prototype.mouseIsPressed=!1,r.default.prototype._updateNextMouseCoords=function(e){if(null!==this._curElement&&(!e.touches||e.touches.length>0)){var t=function(e,t,n,a){a&&!a.clientX&&(a.touches?a=a.touches[0]:a.changedTouches&&(a=a.changedTouches[0]));var o=e.getBoundingClientRect();return{x:(a.clientX-o.left)/(e.scrollWidth/t||1),y:(a.clientY-o.top)/(e.scrollHeight/n||1),winX:a.clientX,winY:a.clientY,id:a.identifier}}(this._curElement.elt,this.width,this.height,e);this._setProperty("movedX",e.movementX),this._setProperty("movedY",e.movementY),this._setProperty("mouseX",t.x),this._setProperty("mouseY",t.y),this._setProperty("winMouseX",t.winX),this._setProperty("winMouseY",t.winY)}this._hasMouseInteracted||(this._updateMouseCoords(),this._setProperty("_hasMouseInteracted",!0))},r.default.prototype._updateMouseCoords=function(){this._setProperty("pmouseX",this.mouseX),this._setProperty("pmouseY",this.mouseY),this._setProperty("pwinMouseX",this.winMouseX),this._setProperty("pwinMouseY",this.winMouseY),this._setProperty("_pmouseWheelDeltaY",this._mouseWheelDeltaY)},r.default.prototype._setMouseButton=function(e){this._setProperty("mouseButton",1===e.button?i.CENTER:2===e.button?i.RIGHT:i.LEFT)},r.default.prototype._onmousemove=function(e){var t=this._isGlobal?window:this;this._updateNextMouseCoords(e),this.mouseIsPressed?"function"==typeof t.mouseDragged?!1===t.mouseDragged(e)&&e.preventDefault():"function"==typeof t.touchMoved&&!1===t.touchMoved(e)&&e.preventDefault():"function"==typeof t.mouseMoved&&!1===t.mouseMoved(e)&&e.preventDefault()},r.default.prototype._onmousedown=function(e){var t=this._isGlobal?window:this;this._setProperty("mouseIsPressed",!0),this._setMouseButton(e),this._updateNextMouseCoords(e),"function"==typeof t.mousePressed?!1===t.mousePressed(e)&&e.preventDefault():navigator.userAgent.toLowerCase().includes("safari")&&"function"==typeof t.touchStarted&&!1===t.touchStarted(e)&&e.preventDefault()},r.default.prototype._onmouseup=function(e){var t=this._isGlobal?window:this;this._setProperty("mouseIsPressed",!1),"function"==typeof t.mouseReleased?!1===t.mouseReleased(e)&&e.preventDefault():"function"==typeof t.touchEnded&&!1===t.touchEnded(e)&&e.preventDefault()},r.default.prototype._ondragend=r.default.prototype._onmouseup,r.default.prototype._ondragover=r.default.prototype._onmousemove,r.default.prototype._onclick=function(e){var t=this._isGlobal?window:this;"function"==typeof t.mouseClicked&&(!1===t.mouseClicked(e)&&e.preventDefault())},r.default.prototype._ondblclick=function(e){var t=this._isGlobal?window:this;"function"==typeof t.doubleClicked&&(!1===t.doubleClicked(e)&&e.preventDefault())},r.default.prototype._mouseWheelDeltaY=0,r.default.prototype._pmouseWheelDeltaY=0,r.default.prototype._onwheel=function(e){var t=this._isGlobal?window:this;(this._setProperty("_mouseWheelDeltaY",e.deltaY),"function"==typeof t.mouseWheel)&&(e.delta=e.deltaY,!1===t.mouseWheel(e)&&e.preventDefault())},r.default.prototype.requestPointerLock=function(){var e=this._curElement.elt;return e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock,e.requestPointerLock?(e.requestPointerLock(),!0):(console.log("requestPointerLock is not implemented in this browser"),!1)},r.default.prototype.exitPointerLock=function(){document.exitPointerLock()},n.default=r.default},{"../core/constants":43,"../core/main":50}],70:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a,o=(a=e("../core/main"))&&a.__esModule?a:{default:a};function r(e,t,n,a){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=e.getBoundingClientRect(),i=a.touches[o]||a.changedTouches[o];return{x:(i.clientX-r.left)/(e.scrollWidth/t||1),y:(i.clientY-r.top)/(e.scrollHeight/n||1),winX:i.clientX,winY:i.clientY,id:i.identifier}}o.default.prototype.touches=[],o.default.prototype._updateTouchCoords=function(e){if(null!==this._curElement){for(var t=[],n=0;n=y)break;g=0}for(T=g;T=y);T++){var D=x[u+R];p+=(C=i[T])[(-16777216&D)>>>24],l+=C[(16711680&D)>>16],c+=C[(65280&D)>>8],d+=C[255&D],n+=r[T],u++}M[h=R+k]=p/n,E[h]=l/n,j[h]=c/n,I[h]=d/n}R+=y}for(R=0,f=(m=-a)*y,_=0;_=v)break;g=0,h=m,u=k+f}for(T=g;T=v);T++)p+=(C=i[T])[M[u]],l+=C[E[u]],c+=C[j[u]],d+=C[I[u]],n+=r[T],h++,u+=y;x[k+R]=p/n<<24|l/n<<16|c/n<<8|d/n}R+=y,f+=y,m++}s._setPixels(b,x)}s._toPixels=function(e){return e instanceof ImageData?e.data:e.getContext("2d").getImageData(0,0,e.width,e.height).data},s._getARGB=function(e,t){var n=4*t;return e[n+3]<<24&4278190080|e[n]<<16&16711680|e[n+1]<<8&65280|255&e[n+2]},s._setPixels=function(e,t){for(var n=0,a=0,o=e.length;a>>16,e[n+1]=(65280&t[a])>>>8,e[n+2]=255&t[a],e[n+3]=(4278190080&t[a])>>>24},s._toImageData=function(e){return e instanceof ImageData?e:e.getContext("2d").getImageData(0,0,e.width,e.height)},s._createImageData=function(e,t){return s._tmpCanvas=document.createElement("canvas"),s._tmpCtx=s._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(e,t)},s.apply=function(e,t,n){var a=e.getContext("2d"),o=a.getImageData(0,0,e.width,e.height),r=t(o,n);r instanceof ImageData?a.putImageData(r,0,0,0,0,e.width,e.height):a.putImageData(o,0,0,0,0,e.width,e.height)},s.threshold=function(e,t){var n=s._toPixels(e);void 0===t&&(t=.5);for(var a=Math.floor(255*t),o=0;o=a?255:0}},s.gray=function(e){for(var t=s._toPixels(e),n=0;n255)throw new Error("Level must be greater than 2 and less than 255 for posterize");for(var a=t-1,o=0;o>8)/a,n[o+1]=255*(r*t>>8)/a,n[o+2]=255*(i*t>>8)/a}},s.dilate=function(e){for(var t,n,a,o,r,i,l,c,d,p,u,h,m,f,g,b,y,v=s._toPixels(e),w=0,x=v.length?v.length/4:0,S=new Int32Array(x);w=n&&(i=w),(c=w-e.width)<0&&(c=0),(d=w+e.width)>=x&&(d=w),h=s._getARGB(v,c),u=s._getARGB(v,l),m=s._getARGB(v,d),(g=77*(u>>16&255)+151*(u>>8&255)+28*(255&u))>(r=77*(a>>16&255)+151*(a>>8&255)+28*(255&a))&&(o=u,r=g),(f=77*((p=s._getARGB(v,i))>>16&255)+151*(p>>8&255)+28*(255&p))>r&&(o=p,r=f),(b=77*(h>>16&255)+151*(h>>8&255)+28*(255&h))>r&&(o=h,r=b),(y=77*(m>>16&255)+151*(m>>8&255)+28*(255&m))>r&&(o=m,r=y),S[w++]=o;s._setPixels(v,S)},s.erode=function(e){for(var t,n,a,o,r,i,l,c,d,p,u,h,m,f,g,b,y,v=s._toPixels(e),w=0,x=v.length?v.length/4:0,S=new Int32Array(x);w=n&&(i=w),(c=w-e.width)<0&&(c=0),(d=w+e.width)>=x&&(d=w),h=s._getARGB(v,c),u=s._getARGB(v,l),m=s._getARGB(v,d),(g=77*(u>>16&255)+151*(u>>8&255)+28*(255&u))<(r=77*(a>>16&255)+151*(a>>8&255)+28*(255&a))&&(o=u,r=g),(f=77*((p=s._getARGB(v,i))>>16&255)+151*(p>>8&255)+28*(255&p))>16&255)+151*(h>>8&255)+28*(255&h))>16&255)+151*(m>>8&255)+28*(255&m))=1&&(t=r[0]),r.length>=2&&(n=r[1]),n=n||a.default.prototype._checkFileExtension(t,n)[1]||"png"){default:o="image/png";break;case"jpeg":case"jpg":o="image/jpeg"}e.toBlob((function(e){a.default.prototype.downloadFile(e,t,n)}),o)},a.default.prototype.saveGif=function(e,t){var n=e.gifProperties,r=n.loopLimit;1===r?r=null:null===r&&(r=0);for(var i={loop:r},s=new Uint8Array(e.width*e.height*n.numFrames),l=new o.default.GifWriter(s,e.width,e.height,i),c=[],d=0;d0&&e1){for(var p=function(e,n){try{n.decodeAndBlitFrameRGBA(e,d)}catch(e){o.default._friendlyFileLoadError(8,t.src),"function"==typeof a?a(e):console.error(e)}},u=0;u0?t.drawingContext.putImageData(s[u-1].image,0,0):(t.drawingContext.clearRect(0,0,t.width,t.height),d=new Uint8ClampedArray(t.width*t.height*4)),p(u,i);var m=new ImageData(d,t.width,t.height);t.drawingContext.putImageData(m,0,0),s.push({image:t.drawingContext.getImageData(0,0,t.width,t.height),delay:10*h.delay})}var f=i.loopCount();null===f?f=1:0===f&&(f=null),t.gifProperties={displayIndex:0,loopLimit:f,loopCount:0,frames:s,numFrames:c,playing:!0,timeDisplayed:0}}"function"==typeof n&&n(t);r()}(new Uint8Array(e),a,t,n,function(e){r._decrementPreload()}.bind(r))}),(function(e){"function"==typeof n?n(e):console.error(e)}));else{var c=new Image;c.onload=function(){a.width=a.canvas.width=c.width,a.height=a.canvas.height=c.height,a.drawingContext.drawImage(c,0,0),a.modified=!0,"function"==typeof t&&t(a),r._decrementPreload()},c.onerror=function(e){o.default._friendlyFileLoadError(0,c.src),"function"==typeof n?n(e):console.error(e)},0!==e.indexOf("data:image/")&&(c.crossOrigin="Anonymous"),c.src=e}a.modified=!0})),a},o.default.prototype.image=function(e,t,n,a,r,s,l,c,d){o.default._validateParameters("image",arguments);var u=e.width,h=e.height;e.elt&&e.elt.videoWidth&&!e.canvas&&(u=e.elt.videoWidth,h=e.elt.videoHeight);var m=t,f=n,g=a||u,b=r||h,y=s||0,v=l||0,w=c||u,x=d||h;w=p(w,u),x=p(x,h);var S=1;e.elt&&!e.canvas&&e.elt.style.width&&(S=e.elt.videoWidth&&!a?e.elt.videoWidth:e.elt.width,S/=parseInt(e.elt.style.width,10)),y*=S,v*=S,x*=S,w*=S;var k=i.default.modeAdjust(m,f,g,b,this._renderer._imageMode);this._renderer.image(e,y,v,w,x,k.x,k.y,k.w,k.h)},o.default.prototype.tint=function(){for(var e=arguments.length,t=new Array(e),n=0;n=n){var a=Math.floor(t.timeDisplayed/n);if(t.timeDisplayed=0,t.displayIndex+=a,t.loopCount=Math.floor(t.displayIndex/t.numFrames),null!==t.loopLimit&&t.loopCount>=t.loopLimit)t.playing=!1;else{var o=t.displayIndex%t.numFrames;this.drawingContext.putImageData(t.frames[o].image,0,0),t.displayIndex=o,this.setModified(!0)}}}},a.default.Image.prototype._setProperty=function(e,t){this[e]=t,this.setModified(!0)},a.default.Image.prototype.loadPixels=function(){a.default.Renderer2D.prototype.loadPixels.call(this),this.setModified(!0)},a.default.Image.prototype.updatePixels=function(e,t,n,o){a.default.Renderer2D.prototype.updatePixels.call(this,e,t,n,o),this.setModified(!0)},a.default.Image.prototype.get=function(e,t,n,o){return a.default._validateParameters("p5.Image.get",arguments),a.default.Renderer2D.prototype.get.apply(this,arguments)},a.default.Image.prototype._getPixel=a.default.Renderer2D.prototype._getPixel,a.default.Image.prototype.set=function(e,t,n){a.default.Renderer2D.prototype.set.call(this,e,t,n),this.setModified(!0)},a.default.Image.prototype.resize=function(e,t){0===e&&0===t?(e=this.canvas.width,t=this.canvas.height):0===e?e=this.canvas.width*t/this.canvas.height:0===t&&(t=this.canvas.height*e/this.canvas.width),e=Math.floor(e),t=Math.floor(t);var n=document.createElement("canvas");if(n.width=e,n.height=t,this.gifProperties)for(var a=this.gifProperties,o=function(e,t){for(var n=0,a=0;a0&&this.loadPixels(),this.setModified(!0)},a.default.Image.prototype.copy=function(){for(var e=arguments.length,t=new Array(e),n=0;n=0?(t.timeDisplayed=0,t.displayIndex=e,this.drawingContext.putImageData(t.frames[e].image,0,0)):console.log("Cannot set GIF to a frame number that is higher than total number of frames or below zero.")}},a.default.Image.prototype.numFrames=function(){if(this.gifProperties)return this.gifProperties.numFrames},a.default.Image.prototype.play=function(){this.gifProperties&&(this.gifProperties.playing=!0)},a.default.Image.prototype.pause=function(){this.gifProperties&&(this.gifProperties.playing=!1)},a.default.Image.prototype.delay=function(e,t){if(this.gifProperties){var n=this.gifProperties;if(t=0)n.frames[t].delay=e;else{var a=!0,o=!1,r=void 0;try{for(var i,s=n.frames[Symbol.iterator]();!(a=(i=s.next()).done);a=!0){i.value.delay=e}}catch(e){o=!0,r=e}finally{try{a||null==s.return||s.return()}finally{if(o)throw r}}}}},n.default=a.default.Image},{"../core/main":50,"./filters":71}],75:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a=r(e("../core/main")),o=r(e("./filters"));function r(e){return e&&e.__esModule?e:{default:e}}e("../color/p5.Color"),a.default.prototype.pixels=[],a.default.prototype.blend=function(){for(var e=arguments.length,t=new Array(e),n=0;n /g,">").replace(/"/g,""").replace(/'/g,"'")}function d(e,t){t&&!0!==t&&"true"!==t||(t=""),e||(e="untitled");var n="";return e&&e.includes(".")&&(n=e.split(".").pop()),t&&n!==t&&(n=t,e="".concat(e,".").concat(n)),[e,n]}e("../core/error_helpers"),a.default.prototype.loadJSON=function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&"function"==typeof(p<0||arguments.length<=p?void 0:arguments[p]);p--)c++;var u=arguments.length<=0?void 0:arguments[0];if(2===arguments.length-c&&"string"==typeof u&&"object"===s(arguments.length<=1?void 0:arguments[1]))r=new Request(u,arguments.length<=1?void 0:arguments[1]),t=arguments.length<=2?void 0:arguments[2],n=arguments.length<=3?void 0:arguments[3];else{for(var h,m="GET",f=1;f64e6&&a.default._friendlyFileLoadError(7,u),e){case"json":case"jsonp":return t.json();case"binary":return t.blob();case"arrayBuffer":return t.arrayBuffer();case"xml":return t.text().then((function(e){var t=(new DOMParser).parseFromString(e,"text/xml");return new a.default.XML(t.documentElement)}));default:return t.text()}}))).then(t||function(){}),i.catch(n||console.error),i},window.URL=window.URL||window.webkitURL,a.default.prototype._pWriters=[],a.default.prototype.createWriter=function(e,t){var n;for(var o in a.default.prototype._pWriters)if(a.default.prototype._pWriters[o].name===e)return n=new a.default.PrintWriter(e+this.millis(),t),a.default.prototype._pWriters.push(n),n;return n=new a.default.PrintWriter(e,t),a.default.prototype._pWriters.push(n),n},a.default.PrintWriter=function(e,t){var n=this;this.name=e,this.content="",this.write=function(e){this.content+=e},this.print=function(e){this.content+="".concat(e,"\n")},this.clear=function(){this.content=""},this.close=function(){var o=[];for(var r in o.push(this.content),a.default.prototype.writeFile(o,e,t),a.default.prototype._pWriters)a.default.prototype._pWriters[r].name===this.name&&a.default.prototype._pWriters.splice(r,1);n.clear(),n={}}},a.default.prototype.save=function(e,t,n){var o=arguments,r=this._curElement?this._curElement.elt:this.elt;if(0!==o.length)if(o[0]instanceof a.default.Renderer||o[0]instanceof a.default.Graphics)a.default.prototype.saveCanvas(o[0].elt,o[1],o[2]);else if(1===o.length&&"string"==typeof o[0])a.default.prototype.saveCanvas(r,o[0]);else switch(d(o[1],o[2])[1]){case"json":return void a.default.prototype.saveJSON(o[0],o[1],o[2]);case"txt":return void a.default.prototype.saveStrings(o[0],o[1],o[2]);default:o[0]instanceof Array?a.default.prototype.saveStrings(o[0],o[1],o[2]):o[0]instanceof a.default.Table?a.default.prototype.saveTable(o[0],o[1],o[2]):o[0]instanceof a.default.Image?a.default.prototype.saveCanvas(o[0].canvas,o[1]):o[0]instanceof a.default.SoundFile&&a.default.prototype.saveSound(o[0],o[1],o[2],o[3])}else a.default.prototype.saveCanvas(r)},a.default.prototype.saveJSON=function(e,t,n){var o;a.default._validateParameters("saveJSON",arguments),o=n?JSON.stringify(e):JSON.stringify(e,void 0,2),this.saveStrings(o.split("\n"),t,"json")},a.default.prototype.saveJSONObject=a.default.prototype.saveJSON,a.default.prototype.saveJSONArray=a.default.prototype.saveJSON,a.default.prototype.saveStrings=function(e,t,n,o){a.default._validateParameters("saveStrings",arguments);for(var r=this.createWriter(t,n||"txt"),i=0;i"),r.print("");if(r.print(' '),r.print(""),r.print(""),r.print(" "),"0"!==i[0]){r.print(" ");for(var u=0;u".concat(h)),r.print(" ")}r.print(" ")}for(var m=0;m");for(var f=0;f".concat(g)),r.print(" ")}r.print(" ")}r.print("
"),r.print(""),r.print("