Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
9 changes: 7 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,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 Down Expand Up @@ -398,7 +398,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
17 changes: 16 additions & 1 deletion 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
28 changes: 18 additions & 10 deletions src/color/creating_reading.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ require('../core/error_helpers');
* Extracts the alpha value from a color or pixel array.
*
* @method alpha
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the alpha value
* @example
* <div>
Expand Down Expand Up @@ -61,7 +62,8 @@ p5.prototype.alpha = function(c) {
* Extracts the blue value from a color or pixel array.
*
* @method blue
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the blue value
* @example
* <div>
Expand Down Expand Up @@ -90,7 +92,8 @@ p5.prototype.blue = function(c) {
* Extracts the HSB brightness value from a color or pixel array.
*
* @method brightness
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the brightness value
* @example
* <div>
Expand Down Expand Up @@ -294,7 +297,7 @@ p5.prototype.brightness = function(c) {
*/
/**
* @method color
* @param {Array} values an array containing the red,green,blue &
* @param {Number[]} values an array containing the red,green,blue &
* and alpha components of the color
* @return {p5.Color}
*/
Expand All @@ -305,6 +308,7 @@ p5.prototype.brightness = function(c) {
*/

p5.prototype.color = function() {
p5._validateParameters('color', arguments);
if (arguments[0] instanceof p5.Color) {
return arguments[0]; // Do nothing if argument is already a color object.
} else if (arguments[0] instanceof Array) {
Expand All @@ -314,7 +318,6 @@ p5.prototype.color = function() {
return new p5.Color(this._renderer, arguments[0]);
}
} else {
p5._validateParameters('color', arguments);
if (this instanceof p5.Renderer) {
return new p5.Color(this, arguments);
} else {
Expand All @@ -327,7 +330,8 @@ p5.prototype.color = function() {
* Extracts the green value from a color or pixel array.
*
* @method green
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the green value
* @example
* <div>
Expand Down Expand Up @@ -363,7 +367,8 @@ p5.prototype.green = function(c) {
* maximum hue setting for each system is different.)
*
* @method hue
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the hue
* @example
* <div>
Expand Down Expand Up @@ -490,7 +495,8 @@ p5.prototype.lerpColor = function(c1, c2, amt) {
* Extracts the HSL lightness value from a color or pixel array.
*
* @method lightness
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the lightness
* @example
* <div>
Expand Down Expand Up @@ -519,7 +525,8 @@ p5.prototype.lightness = function(c) {
* Extracts the red value from a color or pixel array.
*
* @method red
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the red value
* @example
* <div>
Expand Down Expand Up @@ -563,7 +570,8 @@ p5.prototype.red = function(c) {
* HSL saturation otherwise.
*
* @method saturation
* @param {p5.Color|Array} color p5.Color object or pixel array
* @param {p5.Color|Number[]|String} color p5.Color object, color components,
* or CSS color
* @return {Number} the saturation value
* @example
* <div>
Expand Down
1 change: 1 addition & 0 deletions src/color/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ p5.prototype.clear = function() {
* @chainable
*/
p5.prototype.colorMode = function() {
p5._validateParameters('colorMode', arguments);
if (
arguments[0] === constants.RGB ||
arguments[0] === constants.HSB ||
Expand Down
17 changes: 16 additions & 1 deletion src/core/2d_primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require('./error_helpers');
* @param {Number} start angle to start the arc, specified in radians
* @param {Number} stop angle to stop the arc, specified in radians
* @param {Constant} [mode] optional parameter to determine the way of drawing
* the arc. Parameter options are OPEN, CHORD or PIE
* the arc. either CHORD, PIE or OPEN
* @chainable
* @example
* <div>
Expand Down Expand Up @@ -232,6 +232,16 @@ p5.prototype.ellipse = function() {
*3 lines of various stroke sizes. Form top, bottom and right sides of a square.
*
*/
/**
* @method line
* @param {Number} x1
* @param {Number} y1
* @param {Number} z1 the z-coordinate of the first point
* @param {Number} x2
* @param {Number} y2
* @param {Number} z2 the z-coordinate of the second point
* @chainable
*/
p5.prototype.line = function() {
if (!this._renderer._doStroke) {
return this;
Expand Down Expand Up @@ -260,6 +270,7 @@ p5.prototype.line = function() {
* @method point
* @param {Number} x the x-coordinate
* @param {Number} y the y-coordinate
* @param {Number} [z] the z-coordinate
* @chainable
* @example
* <div>
Expand Down Expand Up @@ -326,12 +337,16 @@ p5.prototype.point = function() {
* @method quad
* @param {Number} x1
* @param {Number} y1
* @param {Number} z1
* @param {Number} x2
* @param {Number} y2
* @param {Number} z2
* @param {Number} x3
* @param {Number} y3
* @param {Number} z3
* @param {Number} x4
* @param {Number} y4
* @param {Number} z4
* @chainable
*/
p5.prototype.quad = function() {
Expand Down
5 changes: 5 additions & 0 deletions src/core/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var constants = require('./constants');
*
*/
p5.prototype.ellipseMode = function(m) {
p5._validateParameters('ellipseMode', arguments);
if (
m === constants.CORNER ||
m === constants.CORNERS ||
Expand Down Expand Up @@ -164,6 +165,7 @@ p5.prototype.noSmooth = function() {
*
*/
p5.prototype.rectMode = function(m) {
p5._validateParameters('rectMode', arguments);
if (
m === constants.CORNER ||
m === constants.CORNERS ||
Expand Down Expand Up @@ -230,6 +232,7 @@ p5.prototype.smooth = function() {
*
*/
p5.prototype.strokeCap = function(cap) {
p5._validateParameters('strokeCap', arguments);
if (
cap === constants.ROUND ||
cap === constants.SQUARE ||
Expand Down Expand Up @@ -296,6 +299,7 @@ p5.prototype.strokeCap = function(cap) {
*
*/
p5.prototype.strokeJoin = function(join) {
p5._validateParameters('strokeJoin', arguments);
if (
join === constants.ROUND ||
join === constants.BEVEL ||
Expand Down Expand Up @@ -330,6 +334,7 @@ p5.prototype.strokeJoin = function(join) {
*
*/
p5.prototype.strokeWeight = function(w) {
p5._validateParameters('strokeWeight', arguments);
this._renderer.strokeWeight(w);
return this;
};
Expand Down
3 changes: 1 addition & 2 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ var p5 = function(sketch, node, sync) {
this.createCanvas(
this._defaultCanvasSize.width,
this._defaultCanvasSize.height,
'p2d',
true
'p2d'
);

// return preload functions to their normal vals if switched by preload
Expand Down
Loading