Skip to content

Commit e91f5b2

Browse files
author
lauren mccarthy
committed
adding doc for vid and audio file arrays for issue #346
1 parent d805eeb commit e91f5b2

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

lib/addons/p5.dom.js

+28-4
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,18 @@ var p5DOM = (function(){
7474
* Removes all elements created by p5, except any canvas / graphics
7575
* elements created by createCanvas or createGraphics.
7676
* Event handlers are removed, and element is removed from the DOM.
77-
*
7877
* @method removeElements
78+
* <div class='norender'><code>
79+
* function setup() {
80+
* createCanvas(100, 100);
81+
* createDiv('this is some text');
82+
* createP('this is a paragraph');
83+
* }
84+
* function mousePressed() {
85+
* removeElements(); // this will remove the div and p, not canvas
86+
* }
87+
* </code></div>
88+
*
7989
*/
8090
p5.prototype.removeElements = function (e) {
8191
for (var i=0; i<this._elements.length; i++) {
@@ -280,7 +290,12 @@ var p5DOM = (function(){
280290
* Creates an HTML5 &lt;video&gt; element in the DOM for simple playback
281291
* of audio/video. Shown by default, can be hidden with .hide()
282292
* and drawn into canvas using video(). Appends to the container
283-
* node if one is specified, otherwise appends to body.
293+
* node if one is specified, otherwise appends to body. The first parameter
294+
* can be either a single string path to a video file, or an array of string
295+
* paths to different formats of the same video. This is useful for ensuring
296+
* that your video can play across different browsers, as each supports
297+
* different formats. See <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats">this
298+
* page for further information about supported formats.
284299
*
285300
* @method createVideo
286301
* @param {String|Array} src path to a video file, or array of paths for
@@ -302,7 +317,12 @@ var p5DOM = (function(){
302317
/**
303318
* Creates a hidden HTML5 &lt;audio&gt; element in the DOM for simple audio
304319
* playback. Appends to the container node if one is specified,
305-
* otherwise appends to body.
320+
* otherwise appends to body. The first parameter
321+
* can be either a single string path to a audio file, or an array of string
322+
* paths to different formats of the same audio. This is useful for ensuring
323+
* that your audio can play across different browsers, as each supports
324+
* different formats. See <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats">this
325+
* page for further information about supported formats.
306326
*
307327
* @method createAudio
308328
* @param {String|Array} src path to an audio file, or array of paths for
@@ -657,8 +677,12 @@ var p5DOM = (function(){
657677

658678
/**
659679
* Removes the element and deregisters all listeners.
660-
*
661680
* @method remove
681+
* @example
682+
* <div class='norender'><code>
683+
* var myDiv = createDiv('this is some text');
684+
* myDiv.remove();
685+
* </code></div>
662686
*/
663687
p5.Element.prototype.remove = function() {
664688
// deregister events

lib/p5.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! p5.js v0.3.5 September 05, 2014 */
1+
/*! p5.js v0.3.5 September 06, 2014 */
22
var shim = function (require) {
33
window.requestDraw = function () {
44
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {

lib/p5.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/core.js

+19
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,26 @@ define(function (require) {
298298
}.bind(this);
299299

300300
/**
301+
* Removes the entire p5 sketch. This will remove the canvas and any
302+
* elements created by p5.js. It will also stop the draw loop and unbind
303+
* any properties or methods from the window global scope. It will
304+
* leave a variable p5 in case you wanted to create a new p5 sketch.
305+
* If you like, you can set p5 = null to erase it.
301306
* @method remove
307+
* @example
308+
* <div class='norender'><code>
309+
* function setup() {
310+
* createCanvas(200, 200);
311+
* }
312+
*
313+
* function draw() {
314+
* ellipse(width/2, height/2, 0, 0);
315+
* }
316+
*
317+
* function mousePressed() {
318+
* remove(); // remove whole sketch on mouse press
319+
* }
320+
* </code></div>
302321
*/
303322
this.remove = function() {
304323
if (this._curElement) {

0 commit comments

Comments
 (0)