1- /*! p5.js v0.4.1 February 13 , 2015 */
1+ /*! p5.js v0.4.2 February 16 , 2015 */
22( function ( root , factory ) {
33 if ( typeof define === 'function' && define . amd )
44 define ( 'p5' , [ ] , function ( ) { return ( root . returnExportsGlobal = factory ( ) ) ; } ) ;
@@ -349,85 +349,10 @@ amdclean['core'] = function (require, shim, constants) {
349349 } . bind ( this ) ;
350350 return p5 ;
351351} ( { } , amdclean [ 'shim' ] , amdclean [ 'constants' ] ) ;
352- amdclean [ 'p5Color ' ] = function ( require , core , constants ) {
352+ amdclean [ 'utilscolor_utils ' ] = function ( require , core ) {
353353 var p5 = core ;
354- var constants = constants ;
355- p5 . Color = function ( pInst , vals ) {
356- this . color_array = p5 . Color . _getFormattedColor . apply ( pInst , vals ) ;
357- this . _normalizeColorArray ( pInst ) ;
358- if ( pInst . _colorMode === constants . HSB ) {
359- this . hsba = this . color_array ;
360- this . rgba = p5 . ColorUtils . _hsbToRGB ( this . color_array ) ;
361- } else {
362- this . rgba = this . color_array ;
363- this . hsba = p5 . ColorUtils . _rgbaToHSBA ( this . color_array ) ;
364- }
365- return this ;
366- } ;
367- p5 . Color . prototype . _normalizeColorArray = function ( pInst ) {
368- var isRGB = pInst . _colorMode === constants . RGB ;
369- var maxArr = isRGB ? pInst . _maxRGB : pInst . _maxHSB ;
370- var arr = this . color_array ;
371- arr [ 0 ] *= 255 / maxArr [ 0 ] ;
372- arr [ 1 ] *= 255 / maxArr [ 1 ] ;
373- arr [ 2 ] *= 255 / maxArr [ 2 ] ;
374- arr [ 3 ] *= 255 / maxArr [ 3 ] ;
375- return arr ;
376- } ;
377- p5 . Color . prototype . getHue = function ( ) {
378- return this . hsba [ 0 ] ;
379- } ;
380- p5 . Color . prototype . getSaturation = function ( ) {
381- return this . hsba [ 1 ] ;
382- } ;
383- p5 . Color . prototype . getBrightness = function ( ) {
384- return this . hsba [ 2 ] ;
385- } ;
386- p5 . Color . prototype . getRed = function ( ) {
387- return this . rgba [ 0 ] ;
388- } ;
389- p5 . Color . prototype . getGreen = function ( ) {
390- return this . rgba [ 1 ] ;
391- } ;
392- p5 . Color . prototype . getBlue = function ( ) {
393- return this . rgba [ 2 ] ;
394- } ;
395- p5 . Color . prototype . getAlpha = function ( ) {
396- return this . rgba [ 3 ] ;
397- } ;
398- p5 . Color . prototype . toString = function ( ) {
399- var a = this . rgba ;
400- for ( var i = 0 ; i < 3 ; i ++ ) {
401- a [ i ] = Math . floor ( a [ i ] ) ;
402- }
403- var alpha = typeof a [ 3 ] !== 'undefined' ? a [ 3 ] / 255 : 1 ;
404- return 'rgba(' + a [ 0 ] + ',' + a [ 1 ] + ',' + a [ 2 ] + ',' + alpha + ')' ;
405- } ;
406- p5 . Color . _getFormattedColor = function ( ) {
407- var r , g , b , a ;
408- if ( arguments . length >= 3 ) {
409- r = arguments [ 0 ] ;
410- g = arguments [ 1 ] ;
411- b = arguments [ 2 ] ;
412- a = typeof arguments [ 3 ] === 'number' ? arguments [ 3 ] : 255 ;
413- } else {
414- if ( this . _colorMode === constants . RGB ) {
415- r = g = b = arguments [ 0 ] ;
416- } else {
417- r = b = arguments [ 0 ] ;
418- g = 0 ;
419- }
420- a = typeof arguments [ 1 ] === 'number' ? arguments [ 1 ] : 255 ;
421- }
422- return [
423- r ,
424- g ,
425- b ,
426- a
427- ] ;
428- } ;
429354 p5 . ColorUtils = { } ;
430- p5 . ColorUtils . _hsbToRGB = function ( hsba ) {
355+ p5 . ColorUtils . hsbaToRGBA = function ( hsba ) {
431356 var h = hsba [ 0 ] ;
432357 var s = hsba [ 1 ] ;
433358 var v = hsba [ 2 ] ;
@@ -488,7 +413,7 @@ amdclean['p5Color'] = function (require, core, constants) {
488413 }
489414 return RGBA ;
490415 } ;
491- p5 . ColorUtils . _rgbaToHSBA = function ( rgba ) {
416+ p5 . ColorUtils . rgbaToHSBA = function ( rgba ) {
492417 var var_R = rgba [ 0 ] / 255 ;
493418 var var_G = rgba [ 1 ] / 255 ;
494419 var var_B = rgba [ 2 ] / 255 ;
@@ -527,8 +452,88 @@ amdclean['p5Color'] = function (require, core, constants) {
527452 rgba [ 3 ]
528453 ] ;
529454 } ;
455+ return p5 . ColorUtils ;
456+ } ( { } , amdclean [ 'core' ] ) ;
457+ amdclean [ 'p5Color' ] = function ( require , core , utilscolor_utils , constants ) {
458+ var p5 = core ;
459+ var color_utils = utilscolor_utils ;
460+ var constants = constants ;
461+ p5 . Color = function ( pInst , vals ) {
462+ this . color_array = p5 . Color . _getFormattedColor . apply ( pInst , vals ) ;
463+ this . _normalizeColorArray ( pInst ) ;
464+ if ( pInst . _colorMode === constants . HSB ) {
465+ this . hsba = this . color_array ;
466+ this . rgba = color_utils . hsbaToRGBA ( this . hsba ) ;
467+ } else {
468+ this . rgba = this . color_array ;
469+ this . hsba = color_utils . rgbaToHSBA ( this . rgba ) ;
470+ }
471+ return this ;
472+ } ;
473+ p5 . Color . prototype . _normalizeColorArray = function ( pInst ) {
474+ var isRGB = pInst . _colorMode === constants . RGB ;
475+ var maxArr = isRGB ? pInst . _maxRGB : pInst . _maxHSB ;
476+ var arr = this . color_array ;
477+ arr [ 0 ] *= 255 / maxArr [ 0 ] ;
478+ arr [ 1 ] *= 255 / maxArr [ 1 ] ;
479+ arr [ 2 ] *= 255 / maxArr [ 2 ] ;
480+ arr [ 3 ] *= 255 / maxArr [ 3 ] ;
481+ return arr ;
482+ } ;
483+ p5 . Color . prototype . getHue = function ( ) {
484+ return this . hsba [ 0 ] ;
485+ } ;
486+ p5 . Color . prototype . getSaturation = function ( ) {
487+ return this . hsba [ 1 ] ;
488+ } ;
489+ p5 . Color . prototype . getBrightness = function ( ) {
490+ return this . hsba [ 2 ] ;
491+ } ;
492+ p5 . Color . prototype . getRed = function ( ) {
493+ return this . rgba [ 0 ] ;
494+ } ;
495+ p5 . Color . prototype . getGreen = function ( ) {
496+ return this . rgba [ 1 ] ;
497+ } ;
498+ p5 . Color . prototype . getBlue = function ( ) {
499+ return this . rgba [ 2 ] ;
500+ } ;
501+ p5 . Color . prototype . getAlpha = function ( ) {
502+ return this . rgba [ 3 ] ;
503+ } ;
504+ p5 . Color . prototype . toString = function ( ) {
505+ var a = this . rgba ;
506+ for ( var i = 0 ; i < 3 ; i ++ ) {
507+ a [ i ] = Math . floor ( a [ i ] ) ;
508+ }
509+ var alpha = typeof a [ 3 ] !== 'undefined' ? a [ 3 ] / 255 : 1 ;
510+ return 'rgba(' + a [ 0 ] + ',' + a [ 1 ] + ',' + a [ 2 ] + ',' + alpha + ')' ;
511+ } ;
512+ p5 . Color . _getFormattedColor = function ( ) {
513+ var r , g , b , a ;
514+ if ( arguments . length >= 3 ) {
515+ r = arguments [ 0 ] ;
516+ g = arguments [ 1 ] ;
517+ b = arguments [ 2 ] ;
518+ a = typeof arguments [ 3 ] === 'number' ? arguments [ 3 ] : 255 ;
519+ } else {
520+ if ( this . _colorMode === constants . RGB ) {
521+ r = g = b = arguments [ 0 ] ;
522+ } else {
523+ r = b = arguments [ 0 ] ;
524+ g = 0 ;
525+ }
526+ a = typeof arguments [ 1 ] === 'number' ? arguments [ 1 ] : 255 ;
527+ }
528+ return [
529+ r ,
530+ g ,
531+ b ,
532+ a
533+ ] ;
534+ } ;
530535 return p5 . Color ;
531- } ( { } , amdclean [ 'core' ] , amdclean [ 'constants' ] ) ;
536+ } ( { } , amdclean [ 'core' ] , amdclean [ 'utilscolor_utils' ] , amdclean [ ' constants'] ) ;
532537amdclean [ 'p5Element' ] = function ( require , core ) {
533538 var p5 = core ;
534539 p5 . Element = function ( elt , pInst ) {
@@ -1762,18 +1767,14 @@ amdclean['colorcreating_reading'] = function (require, core, p5Color) {
17621767 'use strict' ;
17631768 var p5 = core ;
17641769 p5 . prototype . alpha = function ( c ) {
1765- if ( c instanceof p5 . Color ) {
1766- return c . getAlpha ( ) ;
1767- } else if ( c instanceof Array ) {
1770+ if ( c instanceof p5 . Color || c instanceof Array ) {
17681771 return this . color ( c ) . getAlpha ( ) ;
17691772 } else {
17701773 throw new Error ( 'Needs p5.Color or pixel array as argument.' ) ;
17711774 }
17721775 } ;
17731776 p5 . prototype . blue = function ( c ) {
1774- if ( c instanceof p5 . Color ) {
1775- return c . getBlue ( ) ;
1776- } else if ( c instanceof Array ) {
1777+ if ( c instanceof p5 . Color || c instanceof Array ) {
17771778 return this . color ( c ) . getBlue ( ) ;
17781779 } else {
17791780 throw new Error ( 'Needs p5.Color or pixel array as argument.' ) ;
@@ -1788,15 +1789,15 @@ amdclean['colorcreating_reading'] = function (require, core, p5Color) {
17881789 p5 . prototype . color = function ( ) {
17891790 if ( arguments [ 0 ] instanceof p5 . Color ) {
17901791 return arguments [ 0 ] ;
1792+ } else if ( arguments [ 0 ] instanceof Array ) {
1793+ return new p5 . Color ( this , arguments [ 0 ] ) ;
17911794 } else {
17921795 var args = Array . prototype . slice . call ( arguments ) ;
17931796 return new p5 . Color ( this , args ) ;
17941797 }
17951798 } ;
17961799 p5 . prototype . green = function ( c ) {
1797- if ( c instanceof p5 . Color ) {
1798- return c . getGreen ( ) ;
1799- } else if ( c instanceof Array ) {
1800+ if ( c instanceof p5 . Color || c instanceof Array ) {
18001801 return this . color ( c ) . getGreen ( ) ;
18011802 } else {
18021803 throw new Error ( 'Needs p5.Color or pixel array as argument.' ) ;
@@ -1826,9 +1827,7 @@ amdclean['colorcreating_reading'] = function (require, core, p5Color) {
18261827 }
18271828 } ;
18281829 p5 . prototype . red = function ( c ) {
1829- if ( c instanceof p5 . Color ) {
1830- return c . getRed ( ) ;
1831- } else if ( c instanceof Array ) {
1830+ if ( c instanceof p5 . Color || c instanceof Array ) {
18321831 return this . color ( c ) . getRed ( ) ;
18331832 } else {
18341833 throw new Error ( 'Needs p5.Color or pixel array as argument.' ) ;
@@ -1889,6 +1888,7 @@ amdclean['colorsetting'] = function (require, core, constants, p5Color) {
18891888 maxArr [ 0 ] = arguments [ 1 ] ;
18901889 maxArr [ 1 ] = arguments [ 1 ] ;
18911890 maxArr [ 2 ] = arguments [ 1 ] ;
1891+ maxArr [ 3 ] = arguments [ 1 ] ;
18921892 } else if ( arguments . length > 2 ) {
18931893 maxArr [ 0 ] = arguments [ 1 ] ;
18941894 maxArr [ 1 ] = arguments [ 2 ] ;
@@ -3018,7 +3018,7 @@ amdclean['inputfiles'] = function (require, core, reqwest) {
30183018 var path = arguments [ 0 ] ;
30193019 var callback = arguments [ 1 ] ;
30203020 var ret = [ ] ;
3021- var t = path . indexOf ( 'http' ) === - 1 ? ' json' : 'jsonp ';
3021+ var t = ' json';
30223022 if ( typeof arguments [ 2 ] === 'string' ) {
30233023 if ( arguments [ 2 ] === 'jsonp' || arguments [ 2 ] === 'json' ) {
30243024 t = arguments [ 2 ] ;
0 commit comments