Skip to content

Commit

Permalink
Merge pull request #3 from processing/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
hackertron authored Dec 30, 2017
2 parents c642613 + e457148 commit 0034271
Show file tree
Hide file tree
Showing 52 changed files with 1,364 additions and 1,119 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"no-caller": 2,
"no-undef": 2,
"no-unused-vars": ["error", { "args": "none" }],
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-console": "off"
}
}
13 changes: 9 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ module.exports = function(grunt) {
},
dist: {
files: {
'lib/p5.min.js': 'lib/p5.js',
'lib/p5.min.js': 'lib/p5.pre-min.js',
'lib/addons/p5.dom.min.js': 'lib/addons/p5.dom.js'
}
}
Expand All @@ -314,8 +314,8 @@ module.exports = function(grunt) {
middleware: function(connect, options, middlewares) {
middlewares.unshift(
require('connect-modrewrite')([
'^/assets/js/p5\\.min\\.js(.*) /lib/p5.min.js$1 [L]',
'^/assets/js/p5\\.(dom|sound)\\.min\\.js(.*) /lib/addons/p5.$1.min.js$2 [L]'
'^/assets/js/p5(\\.min)?\\.js(.*) /lib/p5$1.js$2 [L]',
'^/assets/js/p5\\.(dom|sound)(\\.min)?\\.js(.*) /lib/addons/p5.$1$2.js$3 [L]'
]),
function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
Expand Down Expand Up @@ -403,7 +403,12 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-karma');

// Create the multitasks.
grunt.registerTask('build', ['browserify', 'uglify', 'requirejs']);
grunt.registerTask('build', [
'browserify',
'browserify:min',
'uglify',
'requirejs'
]);
grunt.registerTask('lint-no-fix', [
'yui', // required for eslint-samples
'eslint:build',
Expand Down
12 changes: 7 additions & 5 deletions docs/yuidoc-p5-theme-src/scripts/tpl/item.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ <h4>Description</h4>
if (name.substr(0, 3) === 'p5.') {
name = name.substr(3);
}
if (i == refs.length - 1) {
%> and <%
} else if (i !== 0) {
%>, <%
if (i !== 0) {
if (i == refs.length - 1) {
%> and <%
} else {
%>, <%
}
}
%><a href="./#/<%= ref.replace('.', '/') %>"><%= name %>()</a><%
}
Expand Down Expand Up @@ -168,4 +170,4 @@ <h4>Returns</h4>
<p class='returns'><span class="param-type label label-info"><%=item.return.type%></span>: <%= item.return.description %></p>
<% } %>
</div>
<% } %>
<% } %>
119 changes: 114 additions & 5 deletions lib/addons/p5.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
*
*/
p5.prototype.select = function(e, p) {
p5._validateParameters('select', arguments);
var res = null;
var container = getContainer(p);
if (e[0] === '.') {
Expand Down Expand Up @@ -139,6 +140,7 @@
*
*/
p5.prototype.selectAll = function(e, p) {
p5._validateParameters('selectAll', arguments);
var arr = [];
var res;
var container = getContainer(p);
Expand Down Expand Up @@ -218,6 +220,7 @@
*
*/
p5.prototype.removeElements = function(e) {
p5._validateParameters('removeElements', arguments);
for (var i = 0; i < this._elements.length; i++) {
if (!(this._elements[i].elt instanceof HTMLCanvasElement)) {
this._elements[i].remove();
Expand Down Expand Up @@ -305,6 +308,7 @@
* </code></div>
*/
p5.prototype.createImg = function() {
p5._validateParameters('createImg', arguments);
var elt = document.createElement('img');
var args = arguments;
var self;
Expand Down Expand Up @@ -347,6 +351,7 @@
* </code></div>
*/
p5.prototype.createA = function(href, html, target) {
p5._validateParameters('createA', arguments);
var elt = document.createElement('a');
elt.href = href;
elt.innerHTML = html;
Expand Down Expand Up @@ -399,6 +404,7 @@
* </code></div>
*/
p5.prototype.createSlider = function(min, max, value, step) {
p5._validateParameters('createSlider', arguments);
var elt = document.createElement('input');
elt.type = 'range';
elt.min = min;
Expand Down Expand Up @@ -441,6 +447,7 @@
* </code></div>
*/
p5.prototype.createButton = function(label, value) {
p5._validateParameters('createButton', arguments);
var elt = document.createElement('button');
elt.innerHTML = label;
if (value) elt.value = value;
Expand Down Expand Up @@ -474,6 +481,7 @@
* </code></div>
*/
p5.prototype.createCheckbox = function() {
p5._validateParameters('createCheckbox', arguments);
var elt = document.createElement('div');
var checkbox = document.createElement('input');
checkbox.type = 'checkbox';
Expand Down Expand Up @@ -549,6 +557,7 @@
*/

p5.prototype.createSelect = function() {
p5._validateParameters('createSelect', arguments);
var elt, self;
var arg = arguments[0];
if (typeof arg === 'object' && arg.elt.nodeName === 'SELECT') {
Expand Down Expand Up @@ -667,6 +676,7 @@
* </code></div>
*/
p5.prototype.createRadio = function() {
p5._validateParameters('createRadio', arguments);
var radios = document.querySelectorAll('input[type=radio]');
var count = 0;
if (radios.length > 1) {
Expand Down Expand Up @@ -764,6 +774,7 @@
* </code></div>
*/
p5.prototype.createInput = function(value, type) {
p5._validateParameters('createInput', arguments);
var elt = document.createElement('input');
elt.type = type ? type : 'text';
if (value) elt.value = value;
Expand Down Expand Up @@ -802,6 +813,7 @@
* }
*/
p5.prototype.createFileInput = function(callback, multiple) {
p5._validateParameters('createFileInput', arguments);
// Function to handle when a file is selected
// We're simplifying life and assuming that we always
// want to load every selected file
Expand Down Expand Up @@ -832,7 +844,6 @@
}
}
}

// Is the file stuff supported?
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Yup, we're ok and make an input file selector
Expand Down Expand Up @@ -916,6 +927,7 @@
* @return {p5.MediaElement|p5.Element} pointer to video p5.Element
*/
p5.prototype.createVideo = function(src, callback) {
p5._validateParameters('createVideo', arguments);
return createMedia(this, 'video', src, callback);
};

Expand Down Expand Up @@ -955,6 +967,7 @@
* </code></div>
*/
p5.prototype.createAudio = function(src, callback) {
p5._validateParameters('createAudio', arguments);
return createMedia(this, 'audio', src, callback);
};

Expand Down Expand Up @@ -1047,6 +1060,7 @@
* </code></div>
*/
p5.prototype.createCapture = function() {
p5._validateParameters('createCapture', arguments);
var useVideo = true;
var useAudio = true;
var constraints;
Expand Down Expand Up @@ -1123,6 +1137,7 @@
* </code></div>
*/
p5.prototype.createElement = function(tag, content) {
p5._validateParameters('createElement', arguments);
var elt = document.createElement(tag);
if (typeof content !== 'undefined') {
elt.innerHTML = content;
Expand Down Expand Up @@ -2161,6 +2176,30 @@
* @param {Number} [val] volume between 0.0 and 1.0
* @return {Number|p5.MediaElement} current volume or p5.MediaElement
* @method volume
*
* @example
* <div><code>
* var ele;
* function setup(){
* //p5.MediaElement objects are usually created
* //by calling the createAudio(), createVideo(),
* //and createCapture() functions.
* //In this example we create
* //a new p5.MediaElement via createAudio().
* ele = createAudio('assets/lucky_dragons_-_power_melody.mp3');
* background(250);
* textAlign(CENTER);
* text("Click to Play!", width/2, height/2);
* }
* function mouseClicked() {
* //Here we call the volume() function
* //on the sound element to set its volume
* //Volume must be between 0.0 and 1.0
* ele.volume(0.2)
* ele.play();
* background(200);
* text("You clicked Play!", width/2, height/2);
* }
*/
p5.MediaElement.prototype.volume = function(val) {
if (typeof val === 'undefined') {
Expand Down Expand Up @@ -2550,8 +2589,28 @@

/**
* Hide the default mediaElement controls.
*
* @method hideControls
* @example
* <div><code>
* var ele;
* function setup() {
* //p5.MediaElement objects are usually created
* //by calling the createAudio(), createVideo(),
* //and createCapture() functions.
* //In this example we create
* //a new p5.MediaElement via createAudio()
* ele = createAudio('assets/lucky_dragons_-_power_melody.mp3');
* ele.showControls();
* background(200);
* textAlign(CENTER);
* text('Click to hide Controls!', 10, 25, 70, 80);
* }
* function mousePressed() {
* ele.hideControls();
* background(200);
* text('Controls hidden', width / 2, height / 2);
* }
* </code></div>
*/
p5.MediaElement.prototype.hideControls = function() {
this.elt.controls = false;
Expand Down Expand Up @@ -2633,13 +2692,35 @@
/**
* Remove a callback based on its ID. The ID is returned by the
* addCue method.
*
* @method removeCue
* @param {Number} id ID of the cue, as returned by addCue
* @example
* <div><code>
* var audioEl, id1, id2;
* function setup() {
* background(255, 255, 255);
* audioEl = createAudio('assets/beat.mp3');
* audioEl.showControls();
* // schedule five calls to changeBackground
* id1 = audioEl.addCue(0.5, changeBackground, color(255, 0, 0));
* audioEl.addCue(1.0, changeBackground, color(0, 255, 0));
* audioEl.addCue(2.5, changeBackground, color(0, 0, 255));
* audioEl.addCue(3.0, changeBackground, color(0, 255, 255));
* id2 = audioEl.addCue(4.2, changeBackground, color(255, 255, 0));
* text('Click to remove first and last Cue!', 10, 25, 70, 80);
* }
* function mousePressed() {
* audioEl.removeCue(id1);
* audioEl.removeCue(id2);
* }
* function changeBackground(val) {
* background(val);
* }
* </code></div>
*/
p5.MediaElement.prototype.removeCue = function(id) {
for (var i = 0; i < this._cues.length; i++) {
if (this._cues[i] === id) {
if (this._cues[i].id === id) {
console.log(id);
this._cues.splice(i, 1);
}
Expand All @@ -2653,8 +2734,36 @@
/**
* Remove all of the callbacks that had originally been scheduled
* via the addCue method.
*
* @method clearCues
* @param {Number} id ID of the cue, as returned by addCue
* @example
* <div><code>
* var audioEl;
* function setup() {
* background(255, 255, 255);
* audioEl = createAudio('assets/beat.mp3');
* //Show the default MediaElement controls, as determined by the web browser
* audioEl.showControls();
* // schedule calls to changeBackground
* background(200);
* text('Click to change Cue!', 10, 25, 70, 80);
* audioEl.addCue(0.5, changeBackground, color(255, 0, 0));
* audioEl.addCue(1.0, changeBackground, color(0, 255, 0));
* audioEl.addCue(2.5, changeBackground, color(0, 0, 255));
* audioEl.addCue(3.0, changeBackground, color(0, 255, 255));
* audioEl.addCue(4.2, changeBackground, color(255, 255, 0));
* }
* function mousePressed() {
* // here we clear the scheduled callbacks
* audioEl.clearCues();
* // then we add some more callbacks
* audioEl.addCue(1, changeBackground, color(2, 2, 2));
* audioEl.addCue(3, changeBackground, color(255, 255, 0));
* }
* function changeBackground(val) {
* background(val);
* }
* </code></div>
*/
p5.MediaElement.prototype.clearCues = function() {
this._cues = [];
Expand Down
Loading

0 comments on commit 0034271

Please sign in to comment.