Unlock custom brushes, natural fill effects and intuitive hatching in p5.js
Fixed beginShape() bugs when angleMode was set to RADIANS
Alejandrod28d977394db
diff --git a/p5.brush.js b/p5.brush.jsindex eef3650..0402d13 100644--- a/p5.brush.js+++ b/p5.brush.js@@ -1994,7 +1994,7 @@_a = (_degrees) ? (_a % 360 + 360) % 360 : R.toDegrees(_a);// Replace the last angle with the final anglethis.angles.splice(-1)- this.angles.push(R.toDegrees(_a));+ this.angles.push(_a);// Store the final pressurethis.pres.push(_pres);}@@ -2178,8 +2178,8 @@* @param {number} [curvature] - From 0 to 1. Defines the curvature for the vertices being recorded (optional).* EXPORTED*/- function _beginShape(curvature) {- _strokeOption = curvature; // Set the curvature option for the shape+ function _beginShape(curvature = 0) {+ _strokeOption = R.constrain(curvature,0,1); // Set the curvature option for the shape_strokeArray = []; // Initialize the array to store vertices}@@ -2201,8 +2201,9 @@function _endShape(a) {if (a === CLOSE) {_strokeArray.push(_strokeArray[0]); // Close the shape by connecting the last vertex to the first+ _strokeArray.push(_strokeArray[1]);}- let plot = _createSpline(_strokeArray, _strokeOption); // Create a new Plot with the recorded vertices and curvature option+ let plot = _createSpline(_strokeArray, _strokeOption, a === CLOSE ? true : false); // Create a new Plot with the recorded vertices and curvature optionif (F.isActive || H.isActive) {plot.fill(); // Fill the shape if the fill state is activeplot.hatch(); // Hatch the shape if the hatch state is active@@ -2252,7 +2253,7 @@* @param {Array<Array<number>>} array_points - An array of points defining the spline curve.* @param {number} [curvature=0.5] - The curvature of the spline curve, beterrn 0 and 1. A curvature of 0 will create a series of straight segments.*/- function _createSpline (array_points, curvature = 0.5) {+ function _createSpline (array_points, curvature = 0.5, _close = false) {// Initialize the plot type based on curvaturelet plotType = (curvature === 0) ? "segments" : "curve";@@ -2260,11 +2261,9 @@// Proceed only if there are points providedif (array_points && array_points.length > 0) {- // Set the origin point from the first point in the array- p.origin = array_points[0];-// Add each segment to the plotlet done = 0;+ let pep, tep, pep2;for (let i = 0; i < array_points.length - 1; i++) {if (curvature > 0 && i < array_points.length - 2) {// Get the current and next points@@ -2277,8 +2276,12 @@let s1 = d1 - dd, s2 = d2 - dd;// If the angles are approximately the same, create a straight segmentif (Math.floor(a1) === Math.floor(a2)) {- p.addSegment(a1,s1,p1[2],true)- p.addSegment(a2,d2,p2[2],true)+ let temp = _close ? (i === 0 ? 0 : d1 - done) : d1 - done;+ let temp2 = _close ? (i === 0 ? 0 : d2 - pep2) : d2;+ p.addSegment(a1,temp,p1[2],true)+ if (i === array_points.length - 3) p.addSegment(a2,temp2,p2[2],true);+ done = 0;+ if (i === 0) pep = d1, pep2 = dd, tep = array_points[1], done = 0;} else {// If the angles are not the same, create curves, etc (this is a too complex...)let point1 = {x: p2[0] - dd * R.cos(-a1), y: p2[1] - dd * R.sin(-a1)}@@ -2288,18 +2291,22 @@let int = _intersectLines(point1,point2,point3,point4,true)let radius = dist(point1.x,point1.y,int.x,int.y)let disti = dist(point1.x,point1.y,point3.x,point3.y)/2- let a3 = 2*asin(disti/radius)+ let a3 = 2 * Math.asin( disti/radius ) * (180 / Math.PI);let s3 = 2 * Math.PI * radius * a3 / 360;- p.addSegment(a1,s1-done, p1[2],true)+ let temp = _close ? (i === 0 ? 0 : s1-done) : s1-done;+ let temp2 = (i === array_points.length - 3) ? (_close ? pep - dd : s2) : 0;+ p.addSegment(a1,temp, p1[2],true)p.addSegment(a1,s3, p1[2],true)- p.addSegment(a2,i === array_points.length - 3 ? s2 : 0, p2[2],true)+ p.addSegment(a2,temp2, p2[2],true)done = dd;+ if (i === 0) pep = s1, pep2 = dd, tep = [point1.x,point1.y];}if (i == array_points.length - 3) {p.endPlot(a2,p2[2],true)}} else if (curvature === 0) {// If curvature is 0, simply create segments+ if (i === 0 && _close) array_points.pop()let p1 = array_points[i], p2 = array_points[i+1]let d = dist(p1[0],p1[1],p2[0],p2[1]);let a = _calculateAngle(p1[0],p1[1],p2[0],p2[1]);@@ -2309,8 +2316,11 @@}}}+ // Set the origin point from the first point in the array+ p.origin = (_close && curvature !== 0) ? tep : array_points[0]}return p;+}/**diff --git a/p5.brush.min.js b/p5.brush.min.jsindex 28bfc69..171e468 100644--- a/p5.brush.min.js+++ b/p5.brush.min.js@@ -1,2 +1,56 @@/* p5.brush.js v1.0.4 - Alejandro Campos - MIT License */-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(1h(m,K){"6I"===3m 4f&&"4g"!==3m 6J?K(4f):"1h"===3m 4h&&4h.6K?4h(["4f"],K):(m=m||5t,K(m.4i={}))})(j,1h(m){1h K(a=!1){X=!0;l=a?a:6L.5t;u.3n();r.5u();Y(l.1A/5v)}1h B(){X||K()}1h Z(a,b,c,d,e=!1){1a h=a.x;a=a.y;1s k=b.x,n=b.y;b=c.x;c=c.y;1s p=d.x,q=d.y;1n(h===k&&a===n||b===p&&c===q)1c!1;d=k-h;k=n-a;n=p-b;q-=c;p=q*d-n*k;1n(0===p)1c!1;n=(n*(a-c)-q*(h-b))/p;b=(d*(a-c)-k*(h-b))/p;1c!e&&(0>b||1<b)?!1:{x:h+n*d,y:a+n*k}}1h Q(a,b,c,d){1c(2j/1k.2s*1k.6M(-(d-b),c-a)%1u+1u)%1u}1h aa(){v.2t.1g=r.1g;v.2t.2k=r.2k;v.1M.1g=g.1g;v.1M.4i=g.2F;v.1M.1O=g.c;v.1M.1Z=g.w;v.1M.3o=g.cr;v.1B.1g=z.1g;v.1B.2n=z.2n;v.1B.2a=z.2a;v.1o.1g=w.1g;v.1o.1O=w.1O;v.1o.2l=w.2l;v.1o.2o=w.2o;v.1o.2G=w.2G;v.1o.2I=w.2I;v.4j.1I=x.2Z}1h ba(){r.1g=v.2t.1g;r.2k=v.2t.2k;g.1g=v.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q*n/1u;c.1N(p,k-C,d[2],!0);c.1N(p,n,d[2],!0);c.1N(h,y===a.1l-3?F:0,e[2],!0);C=t}y==a.1l-3&&c.3p(h,e[2],!0)}2u 0===b&&(e=a[y],p=a[y+1],d=39(e[0],e[1],p[0],p[1]),e=Q(e[0],e[1],p[0],p[1]),c.1N(e,d,1,!0),y==a.1l-2&&c.3p(e,1,!0))}1c c}1h 4s(a,b,c,d){w.2l=4>3a.1l?3>3a.1l?b:1:d;w.1O=3>3a.1l?1O(a):1O(a,b,c);w.1g=!0}1h 4t(a,b="2c"){w.2o=f.2p(a,0,.6);w.5y=b}1h 4u(a=.4,b=.4){w.2G=f.2p(a,0,1);w.2I=f.2p(b,0,1)}1a l,X=!1;2d.2N.3q("4v",()=>B());1y f={2v:()=>1i(),1i(a=0,b=1){1c 1===3a.1l?j.1J(j.2v(),0,1,0,a):j.1J(j.2v(),0,1,a,b)},1E(a,b){1c 1k.1S(j.1i(a,b))},6O(a){1a b,c,d=[];1j(b 6P a)1j(c=0;c<10*a[b];c++)d.1t(b);1c d[1k.1S(j.2v()*d.1l)]},1J(a,b,c,d,e,h=!1){a=d+(a-b)/(c-b)*(e-d);1c h?d<e?j.2p(a,d,e):j.2p(a,e,d):a},2p(a,b,c){1c 1k.1f(1k.1D(a,c),b)},1x(a){1c j.c[1k.1S((a%1u+1u)%1u*4)]},1w(a){1c j.s[1k.1S((a%1u+1u)%1u*4)]},4w:!1,5z(){1n(!j.4w){1s a=2*1k.2s/3D;j.c=1v 4x(3D);j.s=1v 4x(3D);1j(1a b=0;3D>b;b++){1y c=b*a;f.c[b]=1k.1x(c);f.s[b]=1k.1w(c)}j.4w=!0}},6Q:a=>!6R(a),2w:a=>(("4y"===3b()?2j*a/1k.2s:a)%1u+1u)%1u};f.5z();1y v={2t:{},1M:{},1B:{},1o:{},4j:{}},x={2x:[0,0],2Z:0,1I(a=0){x.2Z=f.2w(a)},1z(){1c j.2x=[l.4z.5A.4A[12],l.4z.5A.4A[13]]}};1s V=1;1s 5B=a=>V*=a;1y u={4B:!1,3c:!1,4C:!0,2f:1v 3E(3),3n(){j.1d=4D(l.1A,l.1G);j.1d.3d(l.3d());j.1d.2O();j.1d.5C();j.1d.3b(4E);m.1d=j.1d;u.4B||(j.3F=j.3F.6S(\'#5D "5E.3G"\',j.3G()));j.2y=l.6T(j.5F,j.3F);u.4B=!0;j.1T=4D(l.1A,l.1G);j.1T.3d(l.3d());j.1T.5C();j.1T.2O();j.1T.3b(4E);j.3e=4D(l.1A,l.1G,6U);j.3e.3d(l.3d());j.3e.2O();j.3e.3b(4E)},3H(a){a=a.6V;1a b=1v 3E(3);b[0]=a[0]/1U;b[1]=a[1]/1U;b[2]=a[2]/1U;1c b},4F(){l.1t();l.2P(-x.1z()[0],-x.1z()[1]);l.1K(u.1T,-l.1A/2,-l.1G/2);u.1T.2O();l.2Q()},4G(){aa();g.2b("2R","6W",1);g.2S(-10,-10,-5,-5);ba()},3I:1v 3E(3),3J:1v 3E(3),3K:!1,3L:!1,1H(a=!1,b=!1,c=!1,d=!1){j.3c=c?j.3K:j.3L;j.2f=c?j.3I:j.3J;1n(!j.3c)1n(a)j.2f=j.3H(a),c?(j.3K=!0,j.3I=j.2f):(j.3L=!0,j.3J=j.2f);2u{l.1t();l.2P(-x.1z()[0],-x.1z()[1]);l.1K(j.1T,-l.1A/2,-l.1G/2);j.1T.2O();l.2Q();1c}1n((a?j.3H(a):j.2f).5G()!==j.2f.5G()||b||!j.4C)l.1t(),l.2P(-x.1z()[0],-x.1z()[1]),l.1K(j.1T,-l.1A/2,-l.1G/2),j.1T.2O(),l.2y(j.2y),j.2y.3r("3M",j.2f),j.2y.3r("2v",l.4z),j.2y.3r("4H",d),j.2y.3r("1i",[f.1i(),f.1i(),f.1i()]),d=c?j.3e:j.1d,j.2y.3r("1d",d),l.1o(0,0,0,0),l.3s(),l.3N(-l.1A/2,-l.1G/2,l.1A,l.1G),l.2Q(),d.2O(),b||(j.2f=j.3H(a),c?j.3I=j.2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U(r));}1L 3Q(1L s,1L e,1m z){1c 1L(3Q(s.2T,e.2T,z),5R(s.w,e.w,z));}"}};2d.2N.3q("4v",()=>u.1H(!1,!0));2d.2N.3q("4v",()=>u.1H(!1,!0,!0));2d.2N.3q("5Z",()=>u.1H(!1,!0));2d.2N.3q("5Z",()=>u.1H(!1,!0,!0));1y r={1g:!1,1P:1v 4P,2k:"",60(){1c 1k.1D(l.1A,l.1G)/cV},5u(){j.R=.4M*l.1A;j.61=-1*l.1A;j.62=-1*l.1G;j.2q=1k.2z(2*l.1A/j.R);j.2A=1k.2z(2*l.1G/j.R);j.63()},64(){1c j.1P.2J(j.2k).2t},4k(a=0){j.1P.2J(j.2k).2t=j.1P.2J(j.2k).5w(a,j.66())},66(){1a a=3V(j.2q);1j(1a b=0;b<j.2q;b++)a[b]=1v 4x(j.2A);1c a},63(){L("cW",1h(a,b){1a c=f.1E(-25,-15);0==f.1E(0,4Q)%2&&(c*=-1);1j(1a e=0;e<r.2q;e++)1j(1a h=0;h<r.2A;h++){1s d=67(.3W*e+.3P*a,.3W*h+.3P*a);d=f.1J(d,0,1,-c,c);b[e][h]=3*d}1c b});L("cX",1h(a,b){a=f.1E(-25,-15)+5*f.1w(a);0==f.1E(0,4Q)%2&&(a*=-1);1a c=f.1E(5,10);1j(1a e=0;e<r.2q;e++)1j(1a h=0;h<r.2A;h++){1s d=67(.3W*e,.3W*h);d=1k.2z(f.1J(d,0,1,-a,a)/c)*c;b[e][h]=4*d}1c b});L("cY",1h(a,b){a=f.1E(-30,-15)+1k.4R(44*f.1w(a));0==f.1E(0,4Q)%2&&(a*=-1);1a c=0;1j(1a d=0;d<r.2q;d++){1j(1a e=0;e<r.2A;e++)b[d][e]=c,c+=a,a*=-1;c+=a;a*=-1}1c b});L("cZ",1h(a,b){1a c=f.1E(10,15)+5*f.1w(a);a=f.1E(3,6)+3*f.1x(a);1a d=f.1E(20,35);1j(1a e=0;e<r.2q;e++)1j(1a h=0;h<r.2A;h++){1a k=f.1w(c*e)*d*f.1x(h*a)+f.1E(-3,3);b[e][h]=k}1c b});L("d0",1h(a,b){1a c=f.1i(.4,.8),d=f.1E(18,26);1j(1a h=0;h<r.2q;h++)1j(1a k=0;k<r.2A;k++){1s e=f.1E(15,20);e=d*f.1w(c*k*h+e);b[h][k]=1.1*e*f.1x(a)}1c b})}};3X S{3Y(a,b){j.3Z(a,b);j.1X=0}3Z(a,b){j.x=a;j.y=b;r.1g&&(j.68=j.x-r.61+x.1z()[0],j.69=j.y-r.62+x.1z()[1],j.41=1k.2z(j.68/r.R),j.42=1k.2z(j.69/r.R))}d1(){j.1X=0}43(){1c r.1g?0<=j.41&&0<=j.42&&j.41<r.2q&&j.42<r.2A:j.6a()}6a(){1a a=l.1A,b=l.1G;1c j.x>=-a-x.1z()[0]&&j.x<=a-x.1z()[0]&&j.y>=-b-x.1z()[1]&&j.y<=b-x.1z()[1]}2U(){1c j.43()&&r.1g?r.64()[j.41][j.42]:0}6b(a,b,c=r.60(),d=!0){1n(j.43()){1a h;1n(!d){h=f.1x(-b);1s e=f.1w(-b)}1j(1a k=0;k<a/c;k++){d&&(e=j.2U(),h=f.1x(e-b),e=f.1w(e-b));1a n=c*h,p=c*e;j.1X+=c;j.3Z(j.x+n,j.y+p)}}2u j.1X+=c}4S(a,b,c,d){1n(j.43()){d=1/d;1j(1a h=0;h<b/c;h++){1s e=j.2U();1a k=a.2U(j.1X),n=c*f.1x(e-k);e=c*f.1w(e-k);j.1X+=c*d;j.3Z(j.x+n,j.y+e)}}2u j.1X+=c/3v}}1a da=1;1y g={1g:!0,1P:1v 4P,c:"#d2",w:1,cr:3f,2F:"6c",2V:(a,b)=>{1y c="2R"===b.1q||"2C"===b.1q||"1K"===b.1q;c||"3g"===b.1q||(b.1q="46");"1K"===b.1q&&(T.2V(b.1K.6d),b.3h=()=>g.1d.1K(T.3w.2J(g.p.1K.6d),-g.p.1Z/2,-g.p.1Z/2,g.p.1Z,g.p.1Z));b.1H=c&&!1!==b.1H||b.1H?!0:!1;g.1P.2b(a,{3C:b,d3:[],d4:[]})},2b(a,b,c=1){g.4T(a);g.c=b;g.w=c;g.1g=!0},4T(a){g.2F=a},6e(a,b,c){0<3a.1l&&(g.c=2>3a.1l?a:[a,b,c]);g.1g=!0},6f(a){g.w=a},3o(a){g.cr=a},4U(){g.cr=3f},2S(a,b,c,d){B();1a e=39(a,b,c,d);0!=e&&(g.47(a,b,e,!1,!1),a=Q(a,b,c,d),g.1R(a,!1))},4V(a,b,c,d){B();g.47(a,b,c,!0,!1);g.1R(f.2w(d),!1)},4W(a,b,c,d){B();g.47(b,c,a.1l,!0,a);g.1R(d,!0)},2L(){j.p=j.1P.2J(j.2F).3C;1c"46"===j.p.1q||"3g"===j.p.1q?j.p.2L/j.w:j.p.2L},47(a,b,c,d,e){j.1r=1v S(a,b);j.1l=c;j.4X=d;(j.2W=e)&&e.3i(0)},1R(a,b){b||(j.2r=a);j.4Y();1y c=j.2L(),d=b?1k.2z(j.1l*a/c):1k.2z(j.1l/c);1j(1a e=0;e<d;e++)j.3h(),b?j.1r.4S(j.2W,c,c,a):j.1r.6b(c,a,c,j.4X);j.4Z()},6g(a){j.4Y(!0);j.3h(a);j.4Z(!0)},4Y(a=!1){j.p=j.1P.2J(j.2F).3C;1n(!a){j.a="2C"!==j.p.2h.1q?f.1i(-1,1):0;j.b="2C"!==j.p.2h.1q?f.1i(1,1.5):0;j.cp="2C"!==j.p.2h.1q?f.1i(3,3.5):f.1i(-.2,.2);1y[b,c]=j.p.2h.1Y;j.1D=b;j.1f=c}j.c=l.1O(j.c);j.1d=j.p.1H?"1K"===j.p.1q?u.3e:u.1d:u.1T;x.1z();j.1d.1t();j.1d.3s();"1K"===j.p.1q?j.1d.2P(x.2x[0],x.2x[1]):j.1d.2P(x.2x[0]+l.1A/2,x.2x[1]+l.1G/2);j.1d.1I(-x.2Z);j.1d.3v(V);j.p.1H&&("1K"!==j.p.1q?u.1H(j.c):u.1H(j.c,!1,!0),a||j.50())},4Z(a=!1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t();1a d=c?j.w*j.p.2K:0,e=c?d*f.1i(-1,1):0;c=c?d*f.1i(-1,1):0;j.1d.2P(j.1r.x+e,j.1r.y+c);j.6k(j.w*a,b);j.p.3h(j.1d);j.1d.2Q()},6j(a){1a b=j.w*j.p.2K*(j.p.5d+(1-j.p.5d)*2D()*j.5b(.5,.9,5,.2,1.2)/a);.4<f.1i(0,j.p.5c)&&j.1d.3x(j.1r.x+.7*b*f.1i(-1,1),j.1r.y+b*f.1i(-1,1),a*j.p.1Z*f.1i(.85,1.15))},6k(a,b){j.1d.3v(a);"1K"===j.p.1q&&(j.p.1H?j.1d.6l(1U,0,0,b/2):j.1d.6l(j.1d.d7(j.c),j.1d.d8(j.c),j.1d.d9(j.c),b));"1i"===j.p.1I?j.1d.1I(f.1E(0,1u)):"6m"===j.p.1I&&(a=(j.2W?-j.2W.2U(j.1r.1X):-j.2r)+(j.4X?j.1r.2U():0),j.1d.1I(a))},50(){1n(j.54()){1a b=j.52();1s a=j.53(b);j.1d.1o(1U,0,0,a/1.5);1n("2R"===g.p.1q)1j(a=1;5>a;a++)j.57(b*a/5,!1);2u 1n("2C"===g.p.1q||"1K"===g.p.1q)1j(1a c=1;5>c;c++)j.59(b*c/5,a,!1)}}},T={3w:1v 4P,2V(a){j.3w.2b(a,!1)},6n(a){a.db();1j(1a b=0;b<4*a.1A*a.1G;b+=4){1a c=(a.2X[b]+a.2X[b+1]+a.2X[b+2])/3;a.2X[b]=a.2X[b+1]=a.2X[b+2]=1U;a.2X[b+3]=1U-c}a.dc()},3n(){1j(1a a 1Q j.3w.5e()){1a b=dd(a,()=>T.6n(b));j.3w.2b(a,b)}}},z={1g:!1,2n:[5,45,{}],2a:!1,1B(a){1a b=z.2n[0],c=z.2n[1],d=z.2n[2],e=g.c,h=g.2F,k=g.w,n=g.1g;z.2a&&g.2b(z.2a[0],z.2a[1],z.2a[2]);c=f.2w(c)%2j;1a p=49,q=-49,C=49,y=-49;1s t=G=>{1j(1a D 1Q G.a)p=D[0]<p?D[0]:p,q=D[0]>q?D[0]:q,C=D[1]<C?D[1]:C,y=D[1]>y?D[1]:y};3V.de(a)||(a=[a]);1j(1s F 1Q a)t(F);F=1v M([[p,C],[q,C],[q,y],[p,y]]);1a H=90>=c&&0<=c?C:y;1s A=d.4n?1J(d.4n,0,1,1,1.1,!0):1;t=[];1a U=0,P=b,5f=G=>({3y:{x:p+P*G*f.1x(-c+90),y:H+P*G*f.1w(-c+90)},3z:{x:p+P*G*f.1x(-c+90)+f.1x(-c),y:H+P*G*f.1w(-c+90)+f.1w(-c)}});1j(;0<F.4a(5f(U)).1l;){1a G=[];1j(1s I 1Q a)G.1t(I.4a(5f(U)));t[U]=G.df().dg((D,W)=>D.x===W.x?D.y-W.y:D.x-W.x);P*=A;U++}a=[];1j(1s J 1Q t)"4g"!==3m J[0]&&a.1t(J);J=d.4m?d.4m:0;1j(I=0;I<a.1l;I++)1j(t=a[I],F=0<I&&d.5x,A=0;A<t.1l-1;A+=2)0!==J&&(t[A].x+=J*b*f.1i(-10,10),t[A].y+=J*b*f.1i(-10,10),t[A+1].x+=J*b*f.1i(-10,10),t[A+1].y+=J*b*f.1i(-10,10)),g.2S(t[A].x,t[A].y,t[A+1].x,t[A+1].y),F&&g.2S(a[I-1][1].x,a[I-1][1].y,t[A].x,t[A].y);g.2b(h,e,k);g.1g=n}};3X M{3Y(a,b=!1){j.a=a;j.5g=a.1J(c=>({x:c[0],y:c[1]}));b&&(j.5g=a);j.5h=j.5g.1J((c,d,e)=>[c,e[(d+1)%e.1l]])}4a(a){1a b=`${a.3y.x},${a.3y.y}-${a.3z.x},${a.3z.y}`;1n(j.3j&&j.3j[b])1c j.3j[b];1a c=[];1j(1a d 1Q j.5h){1a e=Z(a.3y,a.3z,d[0],d[1]);!1!==e&&c.1t(e)}j.3j||(j.3j={});1c j.3j[b]=c}1R(a=!1,b,c){1a d=g.1g;a&&g.2b(a,b,c);1n(g.1g){B();1j(1a e 1Q j.5h)g.2S(e[0].x,e[0].y,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(t-.5)},n="4y"===3b()?1k.2s/2j:1;1j(1a y=0;y<h;y++){1s p=j.v[y],q=j.v[(y+1)%h];1a t=.1===a?.1>=w.2o?.25:.75:j.m[y];b&&(t*=-.5);c.1t(p);d.1t(k(t));1a F=2d.4c.dm(p,q,2p(2D(.5,.2),.1,.9));p=2d.4c.5p(q,p);q=p.6s().dn();1a H=j.2r[y];1s C="2c"==w.5y?90:-90;C=(H?C:-C)+45*2D(0,.4);q.1I(C*n);q.do(2D(.5,.2)*1i(.6,1.4)*p.6r()*t);F.2V(q);c.1t(F);d.1t(k(t));e.1t(H,H)}1c 1v 5o(c,d,j.3A,e)}1o(a,b,c){1y d=b/5+c*b/6,e=b/4+c*b/3,h=b/7+c*b/3;b/=5;c*=3;x.1z();u.1H(a,!1,!1,!0);u.1d.1t();u.1d.3s();u.1d.2P(x.2x[0]+l.1A/2,x.2x[1]+l.1G/2);u.1d.1I(x.2Z);u.1d.3v(V);a=j.1F();1a k=a.1F().1F(.9),n=k.1F(.75),p=j.1F(.85);1j(1a q=0;24>q;q++){1n(6===q||12===q||18===q)a=a.1F(),k=k.1F(.75),n=n.1F(.75),p=p.1F(.1,!0);a.1F().3B(q,b);p.1F(.1,!0).1F(.1).3B(q,h,!1);k.1F(.1).1F(.1).3B(q,e,!1);n.1F(.8).1F(.1).3B(q,d,!1);0!==c&&a.4d(c)}u.1d.2Q()}3B(a,b,c=!0){u.1d.1o(1U,0,0,b);c?(u.1d.1M(1U,0,0,.5+1.5*w.2I),u.1d.6t(f.1J(a,0,24,6,.5))):u.1d.3s();u.1d.6u();1j(1a d 1Q j.v)u.1d.6v(d.x,d.y);u.1d.6w(4q)}4d(a){1y b=f.1i(80,6x),c=j.4b/2,d=.dp*j.4b,e=.19*j.4b;u.1d.4d(3.5*a,0);1j(a=0;a<b;a++){1y h=j.3A.x+2D(0,c),k=j.3A.y+2D(0,c),n=f.1i(d,e);u.1d.3x(h,k,n)}u.1d.6y()}}2d.6z.2N.4d=1h(a,b){j.4e||(j.5q=j.6A,j.4e=!0,j.6B("dq-2c"),j.6C=j.5r.3l(),j.5r=[1,1,1,a/1U],j.6D=j.5s.3l(),j.5s=[1,1,1,b/1U])};2d.6z.2N.6y=1h(){1n(j.4e){j.5r=j.6C.3l();j.5s=j.6D.3l();1a a=j.6A;j.6B(j.5q);j.5q=a;j.4e=!1;j.dr()}};1y 6E="1Z 2K 5d 5c 2l 2L 2h 1q 3h 1I".ds(" "),ca=[["dt",[.35,.12,.5,8,du,.3,{1C:[.15,.2],1Y:[1.3,1]}]],["dv",[.2,.5l,1,3,5v,.15,{1C:[.5l,.2],1Y:[1.2,.95]}]],["2B",[.35,.5,.1,8,2j,.2,{1C:[.15,.2],1Y:[1.3,1]}]],["6c",[.3,.5,.4,4,2j,.25,{1C:[.15,.2],1Y:[1.2,.9]}]],["2H",[.2,.4,.3,2,6F,.2,{1C:[.15,.2],1Y:[1.2,.9]}]],["dw",[.4,.6,.8,7,6G,.15,{1C:[.15,.2],1Y:[.95,1.15]}]],["dx",[.5,2,.8,dy,6x,.dz,{1C:[.15,.2],1Y:[1.15,.85]}]],["dA",[.2,.4,.3,2,6F,.15,{1C:[.5,.7],1Y:[1,1.5]}]],["3g",[.3,12,15,40,6G,.65,{1C:[0,.1],1Y:[.15,1.2]},"3g"]],["2R",[2.5,.12,3f,3f,30,.4,{1C:[.35,.25],1Y:[1.35,1]},"2R"]],["dB",[2.5,.12,3f,3f,25,.35,{1C:[.35,.25],1Y:[1.15,.95]},"2C",1h(a){1a b=da;a.3N(-1.5*b,-1.5*b,3*b,3*b);a.3N(1*b,1*b,1*b,1*b)},"6m"]]];1j(1a a 1Q ca){1a b={};1j(1a c=0;c<a[1].1l;c++)b[6E[c]]=a[1][c];g.2V(a[0],b)}m.dC=1h(a={}){a.R&&(f.2v=a.R)};m.3n=K;m.dD=1h(){T.3n()};m.dE=1h(a=!0){u.4C=a};m.dF=Y;m.1t=aa;m.2Q=ba;m.4F=u.4F;m.4G=u.4G;m.1I=x.1I;m.3v=5B;m.dG=L;m.2t=1h(a){B();r.1g=!0;r.2k=a};m.dH=1h(){r.1g=!1};m.dI=1h(a){r.4k(a)};m.dJ=1h(){1c 3V.6H(r.1P.5e())};m.2V=g.2V;m.dK=1h(){1c 3V.6H(g.1P.5e())};m.2b=g.2b;m.dL=g.4T;m.3o=g.3o;m.4U=g.4U;m.dM=1h(a,b,c){B();g.1r=1v S(a,b);g.6g(c)};m.1M=g.6e;m.6t=g.6f;m.3s=1h(){g.1g=!1};m.1o=4s;m.dN=4t;m.dO=4u;m.dP=1h(){w.1g=!1};m.dQ=1h(a){w.5m=a};m.2S=g.2S;m.4V=g.4V;m.2W=g.4W;m.3N=1h(a,b,c,d,e=dR){e==dS&&(a-=c/2,b-=d/2);r.1g?(4o(0),O(a,b),O(a+c,b),O(a+c,b+d),O(a,b+d),4p(4q)):(a=1v M([[a,b],[a+c,b],[a+c,b+d],[a,b+d]]),a.1o(),a.1B(),a.1R())};m.3x=1h(a,b,c,d=!1){1a e=1v R("1C");1s h=1k.2s*c/2;1a k=1i(0,1u);e.1N(0+k+(d?f.1i(-1,1):0),h+(d?f.1i(-1,1):0),1,!0);e.1N(-90+k+(d?f.1i(-1,1):0),h+(d?f.1i(-1,1):0),1,!0);e.1N(-2j+k+(d?f.1i(-1,1):0),h+(d?f.1i(-1,1):0),1,!0);e.1N(-dT+k+(d?f.1i(-1,1):0),h+(d?f.1i(-1,1):0),1,!0);h=d?f.1E(-5,5):0;d&&e.1N(0+k,1k.2s/2j*h*c,!0);e.3p(h+k,1,!0);e.1o(a-c*f.1w(k),b-c*f.1x(-k),1);e.1B(a-c*f.1w(k),b-c*f.1x(-k),1);e.1R(a-c*f.1w(k),b-c*f.1x(-k),1)};m.5n=1h(a){a=1v M(a);a.1o();a.1B();a.1R()};m.dU=1h(a,b=.5){4r(a,b).1R()};m.6u=4o;m.6v=O;m.6w=4p;m.dV=1h(a,b,c){N=[b,c];E=1v R(a)};m.dW=1h(a,b,c){E.1N(a,b,c)};m.dX=1h(a,b){E.3p(a,b);E.1R(N[0],N[1],1);E=!1};m.dY=z.1B;m.1B=4l;m.dZ=1h(a,b="e0",c=1){z.2a=[a,b,c]};m.e1=1h(){z.1g=!1;z.2a=!1};m.e2=M;m.e3=R;m.e4=S});',62,873,'|||||||||||||||||||this|||||||||||||||||||||||||||||||||||||||||||||||||||||let|vec3|return|mask||max|isActive|function|random|for|Math|length|float|if|fill|vec2|type|position|var|push|360|new|sin|cos|const|trans|width|hatch|curve|min|randInt|grow|height|blend|rotate|map|image|vec4|stroke|addSegment|color|list|of|draw|floor|noBlend|255|vVertTexCoord|dot|plotted|min_max|weight|||||||||||hatchingBrush|set|out|p5||currentColor|pow|pressure|angles|180|current|opacity|origin|hatchingParams|bleed_strength|constrain|num_columns|dir|PI|field|else|source|toDegrees|translation|shader|round|num_rows||custom|randomGaussian|pol|name|texture_strength||border_strength|get|vibration|spacing|segments|prototype|clear|translate|pop|marker|line|xyz|angle|add|plot|pixels|index|rotation||||||||||dist|arguments|angleMode|isBlending|pixelDensity|mask2|null|spray|tip|calcIndex|_intersectionCache|pres|slice|typeof|load|clip|endPlot|registerMethod|setUniform|noStroke|uniform|mod|scale|tips|circle|point1|point2|midP|layer|param|1440|Float32Array|frag|glsl|getPigment|color1|color2|blending1|blending2|addColor|rect|void|03|spectral_mix|spectral_uncompand|055|spectral_compand|spectral_reflectance_to_xyz|Array|02|class|constructor|update||column_index|row_index|isIn|||default|initializeDrawingState|case|Infinity|intersect|size|Vector|erase|_isErasing|exports|undefined|define|brush|others|refresh|ea|rand|gradient|fa|ha|CLOSE|ia|ja|ka|la|afterSetup|isPrecalculationDone|Float64Array|radians|_renderer|mat4|loaded|isCaching|createGraphics|DEGREES|reDraw|reBlend|active|289|9898|233|5453|01|spectral_srgb_to_linear|spectral_linear_to_reflectance|Map|100|abs|plotTo|setBrush|noClip|flowLine|flowShape|flow|pushState|popState|markerTip||calculatePressure|calculateAlpha|isInsideClippingArea||break|drawMarker||drawCustomOrImage|simPressure|gauss|quality|definition|keys|ma|vertices|sides|curving|suma|genPol|05|isAnimated|polygon|na|sub|_cachedBlendMode|curFillColor|curStrokeColor|self|create|250|gen|continuous|direction|preCalculation|uMVMatrix|oa|noSmooth|include|spectral|vert|toString|precision|highp|attribute|aPosition|aTexCoord|uModelViewMatrix|uProjectionMatrix|varying|main|fract|mix|texture2D|spectral_linear_to_srgb|spectral_upsampling|spectral_xyz_to_srgb|spectral_linear_to_concentration|int|sqrt|post|step_length|left_x|top_y|addStandard|flow_field||genField|noise|x_offset|y_offset|isInCanvas|moveTo|HB|src|setColor|setWeight|drawTip|applyColor|drawSpray|drawDefault|adjustSizeAndRotation|tint|natural|imageToWhite|splice|createVector|calcCenter|mag|copy|strokeWeight|beginShape|vertex|endShape|110|noErase|RendererGL|curBlendMode|blendMode|_cachedFillStyle|_cachedStrokeStyle|pa|150|120|from|object|module|amd|window|atan2|asin|weightedRand|in|isNumber|isNaN|replace|createShader|WEBGL|levels|white|gl_Position|sampler2D|bool|step|any|greaterThan|07482|299||587|114||43358|43213|33358|gl_FragColor|04045|0031308|clamp|inout|96853629|51567122|02055257|03147571|49108579|97901834|96855103|5401552|02059936|03146636|46944057|97901649|96859338|62645502|02062723|03140624|4016578|97901118|96877345|75595012|02073387|03119611|2449042|97892146|96942204|92826996|02114202|03053888|0682688|97858555|97143709|97223624|02233154|02856855|02732883|97743705|97541862|98616174|02556857|02459485|013606|97428075|98074186|98955255|03330189||0192952|01000187|96663223|98580992||98676237|05185294|01423112|01284127|94822893|98971194|97312575|10087639|01033111|02636635|89937713|99238027|91944277|24000413|00765876|07058713|76070164|99409844|32564851|53589066|00593693|70421692|4642044|995172|13820628|79874659|00485616|85473994|20123039|99576545|05015143|91186529|00426186|95081565|08808402|99593552|02912336|95399623|00409039|9717037|04592894|99564041|02421691|97137099|00438375|97651888|02860373|99464769|02660696|97939505|00537525|97429245|02060067|99229579|03407586|98345207||00772962||97012917|01656701||98638762|04835936|98553736|0136612|9425863|01451549|96829712|0001172|98648905|03181352|99989207|01357964|89228016|554e|98674535|10791525|99989891|01331243|53740239|85267882|98657555|46249516|13823139|01347661|15360445|93188793|98611877|84604333|06968113|01387181|05705719|94810268|98559942|94275572|05628787|01435472|03126539|94200977|98507063|96860996|06111561|01479836|02205445|91478045|98460039|97783966|08987709|0151525|01802271|87065445|98425301|98187757|13656016|01540513|0161346|78827548|98403909|98377315|22169624|01557233|01520947|65738359|98388535|98470202|32176956|0156571||01475977|59909403|98376116|98515481|36157329|01571025|01454263|56817268|98368246|98537114|4836192|01571916|01444459|54031997|98365023|98546685|46488579|01572133|01439897|52110241|98361309|98550011|47440306|01572502|0143762|51041094|98357259|98551031|4857699|01571717|01436343|50526577|98353856|98550741|49267971|01571905|01435687|5025508|98351247|98551323|49625685|01571059|0143537|50126452|98350101|98551563|49807754|01569728|01435408|50083021|98350852|98551547|49889859|0157002|mat3|24306333|53837619|49893282|96896309|87542451|04154303||05568392|20417438|05799454|469e|84e|00030502|00021941|21e|00103681|00112057|101e|00531314|00376661|00010475|01795439|01188055|00035364|05707758|02328644|00095147|11365162|03455942|00228226|17335873|03722379|00420733|19620658|03241838|0066888|18608237|02123321|0098884|13995048|01049099|01524945|08917453|00329584|02141831|04789621|00050704|03342293|02814563|00094867|05131001|01613766|00627372|07040208|0077591|01686462|08783871|00429615|02868965|09424905|00200551|04267481|09795667|00086147|05625475|09415219|00036904|0694704||08678102|00019143|08305315|07885653|00014956|0861261|0635267|231e|09046614|05374142|813e|08500387|04264606|883e||07090667||03161735|577e|05062889|02088521|94e|03547396|01386011|58e|02146821|00810264|01251646|0046301|00680458|00249138|00346457|0012593|00149761|00054165|0007697|00027795|00040737|00014711|00016901|103e|522e|439e|903e|771e|22e|1E3|curved|truncated|zigzag|waves|seabed|reset|000000|colors|buffers|switch|setAlpha|red|green|blue||loadPixels|updatePixels|loadImage|isArray|flat|sort|reduce|9999|002185|07|155|lerp|normalize|mult|025|destination|_applyBlendMode|split|pen|200|rotring|cpencil|charcoal|300|06|hatch_brush|marker2|config|preload|colorCache|scaleBrushes|addField|noField|refreshField|listFields|box|pick|point|bleed|fillTexture|noFill|fillAnimatedMode|CORNER|CENTER|270|spline|beginStroke|segment|endStroke|hatchArray|setHatch|black|noHatch|Polygon|Plot|Position'.split('|'),0,{}))\ No newline at end of file+(function(m,N){"object"===typeof exports&&"undefined"!==typeof module?N(exports):"function"===typeof define&&define.amd?define(["exports"],N):(m=m||self,N(m.brush={}))})(this,function(m){function N(a=!1){Y=!0;l=a?a:window.self;t.load();r.create();Z(l.width/250)}function E(){Y||N()}function aa(a,b,c,d,e=!1){let g=a.x;a=a.y;var k=b.x,p=b.y;b=c.x;c=c.y;var n=d.x,q=d.y;if(g===k&&a===p||b===n&&c===q)return!1;d=k-g;k=p-a;p=n-b;q-=c;n=q*d-p*k;if(0===n)return!1;p=(p*(a-c)-q*(g-b))/n;b=(d*(a-c)-k*(g-b))/n;+return!e&&(0>b||1<b)?!1:{x:g+p*d,y:a+p*k}}function S(a,b,c,d){return(180/Math.PI*Math.atan2(-(d-b),c-a)%360+360)%360}function ba(){u.field.isActive=r.isActive;u.field.current=r.current;u.stroke.isActive=h.isActive;u.stroke.brush=h.name;u.stroke.color=h.c;u.stroke.weight=h.w;u.stroke.clip=h.cr;u.hatch.isActive=y.isActive;u.hatch.hatchingParams=y.hatchingParams;u.hatch.hatchingBrush=y.hatchingBrush;u.fill.isActive=v.isActive;u.fill.color=v.color;u.fill.opacity=v.opacity;u.fill.bleed_strength=v.bleed_strength;+u.fill.texture_strength=v.texture_strength;u.fill.border_strength=v.border_strength;u.others.rotate=x.rotation}function ca(){r.isActive=u.field.isActive;r.current=u.field.current;h.isActive=u.stroke.isActive;h.name=u.stroke.brush;h.c=u.stroke.color;h.w=u.stroke.weight;h.cr=u.stroke.clip;y.isActive=u.hatch.isActive;y.hatchingParams=u.hatch.hatchingParams;y.hatchingBrush=u.hatch.hatchingBrush;v.isActive=u.fill.isActive;v.color=u.fill.color;v.opacity=u.fill.opacity;v.bleed_strength=u.fill.bleed_strength;+v.texture_strength=u.fill.texture_strength;v.border_strength=u.fill.border_strength;x.rotation=u.others.rotate}function O(a,b){E();r.list.set(a,{gen:b});r.current=a;r.refresh()}function Z(a){for(let b of da){let c=h.list.get(b[0]).param;c.weight*=a;c.vibration*=a;c.spacing*=a}ea=a}function fa(a=5,b=45,c={rand:!1,continuous:!1,gradient:!1}){y.isActive=!0;y.hatchingParams=[a,b,c]}function ha(a=0){Q=f.constrain(a,0,1);F=[]}function R(a,b,c){F.push([a,b,c])}function ia(a){a===CLOSE&&(F.push(F[0]),F.push(F[1]));+a=ja(F,Q,a===CLOSE?!0:!1);if(v.isActive||y.isActive)a.fill(),a.hatch();h.isActive&&a.draw();F=!1}function ja(a,b=.5,c=!1){let d=new T(0===b?"segments":"curve");if(a&&0<a.length){let D=0,I,B,L;for(let z=0;z<a.length-1;z++)if(0<b&&z<a.length-2){var e=a[z],g=a[z+1],k=a[z+2],p=dist(e[0],e[1],g[0],g[1]),n=dist(g[0],g[1],k[0],k[1]),q=S(e[0],e[1],g[0],g[1]);k=S(g[0],g[1],k[0],k[1]);let G=b*Math.min(Math.min(p,n),.5*Math.min(p,n));var A=Math.max(p,n),C=p-G,w=n-G;if(Math.floor(q)===Math.floor(k))C=c?0===z?+0:n-L:n,d.addSegment(q,c?0===z?0:p-D:p-D,e[2],!0),z===a.length-3&&d.addSegment(k,C,g[2],!0),D=0,0===z&&(I=p,L=G,B=a[1],D=0);else{p={x:g[0]-G*f.cos(-q),y:g[1]-G*f.sin(-q)};let J={x:p.x+A*f.cos(-q+90),y:p.y+A*f.sin(-q+90)};n={x:g[0]+G*f.cos(-k),y:g[1]+G*f.sin(-k)};A={x:n.x+A*f.cos(-k+90),y:n.y+A*f.sin(-k+90)};A=aa(p,J,n,A,!0);A=dist(p.x,p.y,A.x,A.y);n=dist(p.x,p.y,n.x,n.y)/2;n=180/Math.PI*Math.PI*A*2*Math.asin(n/A)*2/360;w=z===a.length-3?c?I-G:w:0;d.addSegment(q,c?0===z?0:C-D:C-D,e[2],!0);d.addSegment(q,+n,e[2],!0);d.addSegment(k,w,g[2],!0);D=G;0===z&&(I=C,L=G,B=[p.x,p.y])}z==a.length-3&&d.endPlot(k,g[2],!0)}else 0===b&&(0===z&&c&&a.pop(),g=a[z],q=a[z+1],e=dist(g[0],g[1],q[0],q[1]),g=S(g[0],g[1],q[0],q[1]),d.addSegment(g,e,1,!0),z==a.length-2&&d.endPlot(g,1,!0));d.origin=c&&0!==b?B:a[0]}return d}function ka(a,b,c,d){v.opacity=4>arguments.length?3>arguments.length?b:1:d;v.color=3>arguments.length?color(a):color(a,b,c);v.isActive=!0}function la(a,b="out"){v.bleed_strength=f.constrain(a,0,.6);v.direction=+b}function ma(a=.4,b=.4){v.texture_strength=f.constrain(a,0,1);v.border_strength=f.constrain(b,0,1)}let l,Y=!1;p5.prototype.registerMethod("afterSetup",()=>E());const f={source:()=>random(),random(a=0,b=1){return 1===arguments.length?this.map(this.source(),0,1,0,a):this.map(this.source(),0,1,a,b)},randInt(a,b){return Math.floor(this.random(a,b))},weightedRand(a){let b,c,d=[];for(b in a)for(c=0;c<10*a[b];c++)d.push(b);return d[Math.floor(this.source()*d.length)]},map(a,b,c,d,e,g=!1){a=d+(a-b)/(c-b)*+(e-d);return g?d<e?this.constrain(a,d,e):this.constrain(a,e,d):a},constrain(a,b,c){return Math.max(Math.min(a,c),b)},cos(a){return this.c[Math.floor((a%360+360)%360*4)]},sin(a){return this.s[Math.floor((a%360+360)%360*4)]},isPrecalculationDone:!1,preCalculation(){if(!this.isPrecalculationDone){var a=2*Math.PI/1440;this.c=new Float64Array(1440);this.s=new Float64Array(1440);for(let b=0;1440>b;b++){const c=b*a;f.c[b]=Math.cos(c);f.s[b]=Math.sin(c)}this.isPrecalculationDone=!0}},isNumber:a=>!isNaN(a),+toDegrees:a=>(("radians"===angleMode()?180*a/Math.PI:a)%360+360)%360};f.preCalculation();const u={field:{},stroke:{},hatch:{},fill:{},others:{}},x={translation:[0,0],rotation:0,rotate(a=0){x.rotation=f.toDegrees(a)},trans(){return this.translation=[l._renderer.uMVMatrix.mat4[12],l._renderer.uMVMatrix.mat4[13]]}};var W=1;var oa=a=>W*=a;const t={loaded:!1,isBlending:!1,isCaching:!0,currentColor:new Float32Array(3),load(){this.mask=createGraphics(l.width,l.height);this.mask.pixelDensity(l.pixelDensity());+this.mask.clear();this.mask.noSmooth();this.mask.angleMode(DEGREES);m.mask=this.mask;t.loaded||(this.frag=this.frag.replace('#include "spectral.glsl"',this.glsl()));this.shader=l.createShader(this.vert,this.frag);t.loaded=!0;this.noBlend=createGraphics(l.width,l.height);this.noBlend.pixelDensity(l.pixelDensity());this.noBlend.noSmooth();this.noBlend.clear();this.noBlend.angleMode(DEGREES);this.mask2=createGraphics(l.width,l.height,WEBGL);this.mask2.pixelDensity(l.pixelDensity());this.mask2.clear();+this.mask2.angleMode(DEGREES)},getPigment(a){a=a.levels;let b=new Float32Array(3);b[0]=a[0]/255;b[1]=a[1]/255;b[2]=a[2]/255;return b},reDraw(){l.push();l.translate(-x.trans()[0],-x.trans()[1]);l.image(t.noBlend,-l.width/2,-l.height/2);t.noBlend.clear();l.pop()},reBlend(){ba();h.set("marker","white",1);h.line(-10,-10,-5,-5);ca()},color1:new Float32Array(3),color2:new Float32Array(3),blending1:!1,blending2:!1,blend(a=!1,b=!1,c=!1,d=!1){this.isBlending=c?this.blending1:this.blending2;this.currentColor=+c?this.color1:this.color2;if(!this.isBlending)if(a)this.currentColor=this.getPigment(a),c?(this.blending1=!0,this.color1=this.currentColor):(this.blending2=!0,this.color2=this.currentColor);else{l.push();l.translate(-x.trans()[0],-x.trans()[1]);l.image(this.noBlend,-l.width/2,-l.height/2);this.noBlend.clear();l.pop();return}if((a?this.getPigment(a):this.currentColor).toString()!==this.currentColor.toString()||b||!this.isCaching)l.push(),l.translate(-x.trans()[0],-x.trans()[1]),l.image(this.noBlend,+-l.width/2,-l.height/2),this.noBlend.clear(),l.shader(this.shader),this.shader.setUniform("addColor",this.currentColor),this.shader.setUniform("source",l._renderer),this.shader.setUniform("active",d),this.shader.setUniform("random",[f.random(),f.random(),f.random()]),d=c?this.mask2:this.mask,this.shader.setUniform("mask",d),l.fill(0,0,0,0),l.noStroke(),l.rect(-l.width/2,-l.height/2,l.width,l.height),l.pop(),d.clear(),b||(this.currentColor=this.getPigment(a),c?this.color1=this.currentColor:this.color2=+this.currentColor);b&&(this.isBlending=!1,c?this.blending1=this.isBlending:this.blending2=this.isBlending)},vert:"precision highp float;attribute vec3 aPosition;attribute vec2 aTexCoord;uniform mat4 uModelViewMatrix,uProjectionMatrix;varying vec2 vVertTexCoord;void main(){gl_Position=uProjectionMatrix*uModelViewMatrix*vec4(aPosition,1);vVertTexCoord=aTexCoord;}",frag:'precision highp float;varying vec2 vVertTexCoord;uniform sampler2D source,mask;uniform vec4 addColor;uniform vec3 random;uniform bool active;\n #include "spectral.glsl"\n float v(vec2 v,vec2 x,float y,out vec2 i){vec2 a=vec2(v.x+v.y*.5,v.y),m=floor(a),d=fract(a);float z=step(d.y,d.x);vec2 r=vec2(z,1.-z),f=m+r,e=m+1.,s=vec2(m.x-m.y*.5,m.y),k=vec2(s.x+r.x-r.y*.5,s.y+r.y),l=vec2(s.x+.5,s.y+1.),g=v-s,o=v-k,t=v-l;vec3 u,c,C,D;if(any(greaterThan(x,vec2(0)))){C=vec3(s.x,k.x,l);D=vec3(s.y,k.y,l.y);if(x.x>0.)C=mod(vec3(s.x,k.x,l),x.x);if(x.y>0.)D=mod(vec3(s.y,k.y,l.y),x.y);u=floor(C+.5*D+.5);c=floor(D+.5);}else u=vec3(m.x,f.x,e),c=vec3(m.y,f.y,e.y);vec3 b=mod(u,289.);b=mod((b*51.+2.)*b+c,289.);b=mod((b*34.+10.)*b,289.);vec3 h=b*.07482+y,E=cos(h),w=sin(h);vec2 A=vec2(E.x,w),B=vec2(E.y,w.y),F=vec2(E.z,w.z);vec3 G=.8-vec3(dot(g,g),dot(o,o),dot(t,t));G=max(G,0.);vec3 H=G*G,I=H*H,J=vec3(dot(A,g),dot(B,o),dot(F,t)),K=H*G,L=-8.*K*J;i=10.9*(I.x*A+L.x*g+(I.y*B+L.y*o)+(I.z*F+L.z*t));return 10.9*dot(I,J);}vec4 v(vec3 v,float f){return vec4(mix(v,vec3(dot(vec3(.299,.587,.114),v)),f),1);}float f(vec2 v,float x,float y,float f){return fract(sin(dot(v,vec2(x,y)))*f);}void main(){vec4 s=texture2D(mask,vVertTexCoord);if(s.x>0.){vec2 m=vec2(12.9898,78.233),k=vec2(7.9898,58.233),d=vec2(17.9898,3.233);float x=f(vVertTexCoord,m.x,m.y,43358.5453)*2.-1.,y=f(vVertTexCoord,k.x,k.y,43213.5453)*2.-1.,l=f(vVertTexCoord,d.x,d.y,33358.5453)*2.-1.;const vec2 z=vec2(0);vec2 o;vec4 b;if(active){float a=v(vVertTexCoord*5.,z,10.*random.x,o),c=v(vVertTexCoord*5.,z,10.*random.y,o),t=v(vVertTexCoord*5.,z,10.*random.z,o),w=.25+.25*v(vVertTexCoord*4.,z,3.*random.x,o);b=vec4(v(addColor.xyz,w).xyz+vec3(a,c,t)*.03,1);}else b=vec4(addColor.xyz,1);if(s.w>.7){float r=.5*(s.w-.7);b=b*(1.-r)-vec4(.5)*r;}vec3 a=spectral_mix(texture2D(source,vVertTexCoord).xyz,b.xyz,.9*s.w);gl_FragColor=vec4(a+.01*vec3(x,y,l),1);}}',+glsl(){return"float spectral_uncompand(float s){return s<.04045?s/12.92:pow((s+.055)/1.055,2.4);}float spectral_compand(float s){return s<.0031308?s*12.92:1.055*pow(s,1./2.4)-.055;}vec3 spectral_srgb_to_linear(vec3 s){return vec3(spectral_uncompand(s[0]),spectral_uncompand(s[1]),spectral_uncompand(s[2]));}vec3 spectral_linear_to_srgb(vec3 s){return clamp(vec3(spectral_compand(s[0]),spectral_compand(s[1]),spectral_compand(s[2])),0.,1.);}void spectral_upsampling(vec3 e,out float m,out float s,out float f,out float r,out float x,out float v,out float z){m=min(e.x,min(e.y,e.z));e-=m;s=min(e.y,e.z);f=min(e.x,e.z);r=min(e.x,e.y);x=min(max(0.,e.x-e.z),max(0.,e.x-e.y));v=min(max(0.,e.y-e.z),max(0.,e.y-e.x));z=min(max(0.,e.z-e.y),max(0.,e.z-e.x));}void spectral_linear_to_reflectance(vec3 s,inout float f[38]){float e,o,m,x,v,w,z;spectral_upsampling(s,e,o,m,x,v,w,z);f[0]=max(1e-4,e+o*.96853629+m*.51567122+x*.02055257+v*.03147571+w*.49108579+z*.97901834);f[1]=max(1e-4,e+o*.96855103+m*.5401552+x*.02059936+v*.03146636+w*.46944057+z*.97901649);f[2]=max(1e-4,e+o*.96859338+m*.62645502+x*.02062723+v*.03140624+w*.4016578+z*.97901118);f[3]=max(1e-4,e+o*.96877345+m*.75595012+x*.02073387+v*.03119611+w*.2449042+z*.97892146);f[4]=max(1e-4,e+o*.96942204+m*.92826996+x*.02114202+v*.03053888+w*.0682688+z*.97858555);f[5]=max(1e-4,e+o*.97143709+m*.97223624+x*.02233154+v*.02856855+w*.02732883+z*.97743705);f[6]=max(1e-4,e+o*.97541862+m*.98616174+x*.02556857+v*.02459485+w*.013606+z*.97428075);f[7]=max(1e-4,e+o*.98074186+m*.98955255+x*.03330189+v*.0192952+w*.01000187+z*.96663223);f[8]=max(1e-4,e+o*.98580992+m*.98676237+x*.05185294+v*.01423112+w*.01284127+z*.94822893);f[9]=max(1e-4,e+o*.98971194+m*.97312575+x*.10087639+v*.01033111+w*.02636635+z*.89937713);f[10]=max(1e-4,e+o*.99238027+m*.91944277+x*.24000413+v*.00765876+w*.07058713+z*.76070164);f[11]=max(1e-4,e+o*.99409844+m*.32564851+x*.53589066+v*.00593693+w*.70421692+z*.4642044);f[12]=max(1e-4,e+o*.995172+m*.13820628+x*.79874659+v*.00485616+w*.85473994+z*.20123039);f[13]=max(1e-4,e+o*.99576545+m*.05015143+x*.91186529+v*.00426186+w*.95081565+z*.08808402);f[14]=max(1e-4,e+o*.99593552+m*.02912336+x*.95399623+v*.00409039+w*.9717037+z*.04592894);f[15]=max(1e-4,e+o*.99564041+m*.02421691+x*.97137099+v*.00438375+w*.97651888+z*.02860373);f[16]=max(1e-4,e+o*.99464769+m*.02660696+x*.97939505+v*.00537525+w*.97429245+z*.02060067);f[17]=max(1e-4,e+o*.99229579+m*.03407586+x*.98345207+v*.00772962+w*.97012917+z*.01656701);f[18]=max(1e-4,e+o*.98638762+m*.04835936+x*.98553736+v*.0136612+w*.9425863+z*.01451549);f[19]=max(1e-4,e+o*.96829712+m*.0001172+x*.98648905+v*.03181352+w*.99989207+z*.01357964);f[20]=max(1e-4,e+o*.89228016+m*8.554e-5+x*.98674535+v*.10791525+w*.99989891+z*.01331243);f[21]=max(1e-4,e+o*.53740239+m*.85267882+x*.98657555+v*.46249516+w*.13823139+z*.01347661);f[22]=max(1e-4,e+o*.15360445+m*.93188793+x*.98611877+v*.84604333+w*.06968113+z*.01387181);f[23]=max(1e-4,e+o*.05705719+m*.94810268+x*.98559942+v*.94275572+w*.05628787+z*.01435472);f[24]=max(1e-4,e+o*.03126539+m*.94200977+x*.98507063+v*.96860996+w*.06111561+z*.01479836);f[25]=max(1e-4,e+o*.02205445+m*.91478045+x*.98460039+v*.97783966+w*.08987709+z*.0151525);f[26]=max(1e-4,e+o*.01802271+m*.87065445+x*.98425301+v*.98187757+w*.13656016+z*.01540513);f[27]=max(1e-4,e+o*.0161346+m*.78827548+x*.98403909+v*.98377315+w*.22169624+z*.01557233);f[28]=max(1e-4,e+o*.01520947+m*.65738359+x*.98388535+v*.98470202+w*.32176956+z*.0156571);f[29]=max(1e-4,e+o*.01475977+m*.59909403+x*.98376116+v*.98515481+w*.36157329+z*.01571025);f[30]=max(1e-4,e+o*.01454263+m*.56817268+x*.98368246+v*.98537114+w*.4836192+z*.01571916);f[31]=max(1e-4,e+o*.01444459+m*.54031997+x*.98365023+v*.98546685+w*.46488579+z*.01572133);f[32]=max(1e-4,e+o*.01439897+m*.52110241+x*.98361309+v*.98550011+w*.47440306+z*.01572502);f[33]=max(1e-4,e+o*.0143762+m*.51041094+x*.98357259+v*.98551031+w*.4857699+z*.01571717);f[34]=max(1e-4,e+o*.01436343+m*.50526577+x*.98353856+v*.98550741+w*.49267971+z*.01571905);f[35]=max(1e-4,e+o*.01435687+m*.5025508+x*.98351247+v*.98551323+w*.49625685+z*.01571059);f[36]=max(1e-4,e+o*.0143537+m*.50126452+x*.98350101+v*.98551563+w*.49807754+z*.01569728);f[37]=max(1e-4,e+o*.01435408+m*.50083021+x*.98350852+v*.98551547+w*.49889859+z*.0157002);}vec3 spectral_xyz_to_srgb(vec3 e){mat3 f;f[0]=vec3(3.24306333,-1.53837619,-.49893282);f[1]=vec3(-.96896309,1.87542451,.04154303);f[2]=vec3(.05568392,-.20417438,1.05799454);float s=dot(f[0],e),m=dot(f[1],e),z=dot(f[2],e);return spectral_linear_to_srgb(vec3(s,m,z));}vec3 spectral_reflectance_to_xyz(float f[38]){vec3 e=vec3(0);e+=f[0]*vec3(6.469e-5,1.84e-6,.00030502);e+=f[1]*vec3(.00021941,6.21e-6,.00103681);e+=f[2]*vec3(.00112057,3.101e-5,.00531314);e+=f[3]*vec3(.00376661,.00010475,.01795439);e+=f[4]*vec3(.01188055,.00035364,.05707758);e+=f[5]*vec3(.02328644,.00095147,.11365162);e+=f[6]*vec3(.03455942,.00228226,.17335873);e+=f[7]*vec3(.03722379,.00420733,.19620658);e+=f[8]*vec3(.03241838,.0066888,.18608237);e+=f[9]*vec3(.02123321,.0098884,.13995048);e+=f[10]*vec3(.01049099,.01524945,.08917453);e+=f[11]*vec3(.00329584,.02141831,.04789621);e+=f[12]*vec3(.00050704,.03342293,.02814563);e+=f[13]*vec3(.00094867,.05131001,.01613766);e+=f[14]*vec3(.00627372,.07040208,.0077591);e+=f[15]*vec3(.01686462,.08783871,.00429615);e+=f[16]*vec3(.02868965,.09424905,.00200551);e+=f[17]*vec3(.04267481,.09795667,.00086147);e+=f[18]*vec3(.05625475,.09415219,.00036904);e+=f[19]*vec3(.0694704,.08678102,.00019143);e+=f[20]*vec3(.08305315,.07885653,.00014956);e+=f[21]*vec3(.0861261,.0635267,9.231e-5);e+=f[22]*vec3(.09046614,.05374142,6.813e-5);e+=f[23]*vec3(.08500387,.04264606,2.883e-5);e+=f[24]*vec3(.07090667,.03161735,1.577e-5);e+=f[25]*vec3(.05062889,.02088521,3.94e-6);e+=f[26]*vec3(.03547396,.01386011,1.58e-6);e+=f[27]*vec3(.02146821,.00810264,0);e+=f[28]*vec3(.01251646,.0046301,0);e+=f[29]*vec3(.00680458,.00249138,0);e+=f[30]*vec3(.00346457,.0012593,0);e+=f[31]*vec3(.00149761,.00054165,0);e+=f[32]*vec3(.0007697,.00027795,0);e+=f[33]*vec3(.00040737,.00014711,0);e+=f[34]*vec3(.00016901,6.103e-5,0);e+=f[35]*vec3(9.522e-5,3.439e-5,0);e+=f[36]*vec3(4.903e-5,1.771e-5,0);e+=f[37]*vec3(2e-5,7.22e-6,0);return e;}float spectral_linear_to_concentration(float v,float m,float s){float z=m*pow(s,2.);return z/(v*pow(1.-s,2.)+z);}vec3 spectral_mix(vec3 s,vec3 f,float e){vec3 v=spectral_srgb_to_linear(s),m=spectral_srgb_to_linear(f);float z[38],o[38];spectral_linear_to_reflectance(v,z);spectral_linear_to_reflectance(m,o);float x=spectral_reflectance_to_xyz(z)[1],w=spectral_reflectance_to_xyz(o)[1];e=spectral_linear_to_concentration(x,w,e);float r[38];for(int c=0;c<38;c++){float y=(1.-e)*(pow(1.-z[c],2.)/(2.*z[c]))+e*(pow(1.-o[c],2.)/(2.*o[c]));r[c]=1.+y-sqrt(pow(y,2.)+2.*y);}return spectral_xyz_to_srgb(spectral_reflectance_to_xyz(r));}vec4 spectral_mix(vec4 s,vec4 e,float z){return vec4(spectral_mix(s.xyz,e.xyz,z),mix(s.w,e.w,z));}"}};+p5.prototype.registerMethod("afterSetup",()=>t.blend(!1,!0));p5.prototype.registerMethod("afterSetup",()=>t.blend(!1,!0,!0));p5.prototype.registerMethod("post",()=>t.blend(!1,!0));p5.prototype.registerMethod("post",()=>t.blend(!1,!0,!0));const r={isActive:!1,list:new Map,current:"",step_length(){return Math.min(l.width,l.height)/1E3},create(){this.R=.01*l.width;this.left_x=-1*l.width;this.top_y=-1*l.height;this.num_columns=Math.round(2*l.width/this.R);this.num_rows=Math.round(2*l.height/this.R);this.addStandard()},+flow_field(){return this.list.get(this.current).field},refresh(a=0){this.list.get(this.current).field=this.list.get(this.current).gen(a,this.genField())},genField(){let a=Array(this.num_columns);for(let b=0;b<this.num_columns;b++)a[b]=new Float64Array(this.num_rows);return a},addStandard(){O("curved",function(a,b){let c=f.randInt(-25,-15);0==f.randInt(0,100)%2&&(c*=-1);for(let e=0;e<r.num_columns;e++)for(let g=0;g<r.num_rows;g++){var d=noise(.02*e+.03*a,.02*g+.03*a);d=f.map(d,0,1,-c,c);b[e][g]=3*+d}return b});O("truncated",function(a,b){a=f.randInt(-25,-15)+5*f.sin(a);0==f.randInt(0,100)%2&&(a*=-1);let c=f.randInt(5,10);for(let e=0;e<r.num_columns;e++)for(let g=0;g<r.num_rows;g++){var d=noise(.02*e,.02*g);d=Math.round(f.map(d,0,1,-a,a)/c)*c;b[e][g]=4*d}return b});O("zigzag",function(a,b){a=f.randInt(-30,-15)+Math.abs(44*f.sin(a));0==f.randInt(0,100)%2&&(a*=-1);let c=0;for(let d=0;d<r.num_columns;d++){for(let e=0;e<r.num_rows;e++)b[d][e]=c,c+=a,a*=-1;c+=a;a*=-1}return b});O("waves",function(a,+b){let c=f.randInt(10,15)+5*f.sin(a);a=f.randInt(3,6)+3*f.cos(a);let d=f.randInt(20,35);for(let e=0;e<r.num_columns;e++)for(let g=0;g<r.num_rows;g++){let k=f.sin(c*e)*d*f.cos(g*a)+f.randInt(-3,3);b[e][g]=k}return b});O("seabed",function(a,b){let c=f.random(.4,.8),d=f.randInt(18,26);for(let g=0;g<r.num_columns;g++)for(let k=0;k<r.num_rows;k++){var e=f.randInt(15,20);e=d*f.sin(c*k*g+e);b[g][k]=1.1*e*f.cos(a)}return b})}};class U{constructor(a,b){this.update(a,b);this.plotted=0}update(a,b){this.x=a;+this.y=b;r.isActive&&(this.x_offset=this.x-r.left_x+x.trans()[0],this.y_offset=this.y-r.top_y+x.trans()[1],this.column_index=Math.round(this.x_offset/r.R),this.row_index=Math.round(this.y_offset/r.R))}reset(){this.plotted=0}isIn(){return r.isActive?0<=this.column_index&&0<=this.row_index&&this.column_index<r.num_columns&&this.row_index<r.num_rows:this.isInCanvas()}isInCanvas(){let a=l.width,b=l.height;return this.x>=-a-x.trans()[0]&&this.x<=a-x.trans()[0]&&this.y>=-b-x.trans()[1]&&this.y<=b-x.trans()[1]}angle(){return this.isIn()&&+r.isActive?r.flow_field()[this.column_index][this.row_index]:0}moveTo(a,b,c=r.step_length(),d=!0){if(this.isIn()){let g;if(!d){g=f.cos(-b);var e=f.sin(-b)}for(let k=0;k<a/c;k++){d&&(e=this.angle(),g=f.cos(e-b),e=f.sin(e-b));let p=c*g,n=c*e;this.plotted+=c;this.update(this.x+p,this.y+n)}}else this.plotted+=c}plotTo(a,b,c,d){if(this.isIn()){d=1/d;for(let g=0;g<b/c;g++){var e=this.angle();let k=a.angle(this.plotted),p=c*f.cos(e-k);e=c*f.sin(e-k);this.plotted+=c*d;this.update(this.x+p,this.y+e)}}else this.plotted+=+c/scale}}let ea=1;const h={isActive:!0,list:new Map,c:"#000000",w:1,cr:null,name:"HB",add:(a,b)=>{const c="marker"===b.type||"custom"===b.type||"image"===b.type;c||"spray"===b.type||(b.type="default");"image"===b.type&&(V.add(b.image.src),b.tip=()=>h.mask.image(V.tips.get(h.p.image.src),-h.p.weight/2,-h.p.weight/2,h.p.weight,h.p.weight));b.blend=c&&!1!==b.blend||b.blend?!0:!1;h.list.set(a,{param:b,colors:[],buffers:[]})},set(a,b,c=1){h.setBrush(a);h.c=b;h.w=c;h.isActive=!0},setBrush(a){h.name=a},+setColor(a,b,c){0<arguments.length&&(h.c=2>arguments.length?a:[a,b,c]);h.isActive=!0},setWeight(a){h.w=a},clip(a){h.cr=a},noClip(){h.cr=null},line(a,b,c,d){E();let e=dist(a,b,c,d);0!=e&&(h.initializeDrawingState(a,b,e,!1,!1),a=S(a,b,c,d),h.draw(a,!1))},flowLine(a,b,c,d){E();h.initializeDrawingState(a,b,c,!0,!1);h.draw(f.toDegrees(d),!1)},flowShape(a,b,c,d){E();h.initializeDrawingState(b,c,a.length,!0,a);h.draw(d,!0)},spacing(){this.p=this.list.get(this.name).param;return"default"===this.p.type||"spray"===+this.p.type?this.p.spacing/this.w:this.p.spacing},initializeDrawingState(a,b,c,d,e){this.position=new U(a,b);this.length=c;this.flow=d;(this.plot=e)&&e.calcIndex(0)},draw(a,b){b||(this.dir=a);this.pushState();const c=this.spacing(),d=b?Math.round(this.length*a/c):Math.round(this.length/c);for(let e=0;e<d;e++)this.tip(),b?this.position.plotTo(this.plot,c,c,a):this.position.moveTo(c,a,c,this.flow);this.popState()},drawTip(a){this.pushState(!0);this.tip(a);this.popState(!0)},pushState(a=!1){this.p=this.list.get(this.name).param;+if(!a){this.a="custom"!==this.p.pressure.type?f.random(-1,1):0;this.b="custom"!==this.p.pressure.type?f.random(1,1.5):0;this.cp="custom"!==this.p.pressure.type?f.random(3,3.5):f.random(-.2,.2);const [b,c]=this.p.pressure.min_max;this.min=b;this.max=c}this.c=l.color(this.c);this.mask=this.p.blend?"image"===this.p.type?t.mask2:t.mask:t.noBlend;x.trans();this.mask.push();this.mask.noStroke();"image"===this.p.type?this.mask.translate(x.translation[0],x.translation[1]):this.mask.translate(x.translation[0]++l.width/2,x.translation[1]+l.height/2);this.mask.rotate(-x.rotation);this.mask.scale(W);this.p.blend&&("image"!==this.p.type?t.blend(this.c):t.blend(this.c,!1,!0),a||this.markerTip())},popState(a=!1){this.p.blend&&!a&&this.markerTip();this.mask.pop()},tip(a=!1){a=a?a:this.calculatePressure();let b=this.calculateAlpha(a);this.applyColor(b);if(this.isInsideClippingArea())switch(this.p.type){case "spray":this.drawSpray(a);break;case "marker":this.drawMarker(a);break;case "custom":case "image":this.drawCustomOrImage(a,+b);break;default:this.drawDefault(a)}},calculatePressure(){return this.plot?this.simPressure()*this.plot.pressure(this.position.plotted):this.simPressure()},simPressure(){return"custom"===this.p.pressure.type?f.map(this.p.pressure.curve(this.position.plotted/this.length)+this.cp,0,1,this.min,this.max,!0):this.gauss()},gauss(a=.5+h.p.pressure.curve[0]*h.a,b=1-h.p.pressure.curve[1]*h.b,c=h.cp,d=h.min,e=h.max){return f.map(1/(1+Math.pow(Math.abs((this.position.plotted-a*this.length)/(b*this.length/2)),+2*c)),0,1,d,e)},calculateAlpha(a){return Math.floor(("default"!==this.p.type&&"spray"!==this.p.type?this.p.opacity/this.w:this.p.opacity)*Math.pow(a,"marker"===this.p.type?.7:1.5))},applyColor(a){this.p.blend?this.mask.fill(255,0,0,a/2):(this.c.setAlpha(a),this.mask.fill(this.c))},isInsideClippingArea(){if(h.cr)return this.position.x>=h.cr[0]&&this.position.x<=h.cr[2]&&this.position.y>=h.cr[1]&&this.position.y<=h.cr[3];let a=.55*l.width,b=.55*l.height;return this.position.x>=-a-x.trans()[0]&&this.position.x<=+a-x.trans()[0]&&this.position.y>=-b-x.trans()[1]&&this.position.y<=b-x.trans()[1]},drawSpray(a){let b=this.w*this.p.vibration*a+this.w*randomGaussian()*this.p.vibration/3,c=this.p.weight*f.random(.9,1.1);a=this.p.quality/a;for(let d=0;d<a;d++){let e=f.random(.9,1.1),g=e*b*f.random(-1,1),k=f.random(-1,1);this.mask.circle(this.position.x+g,this.position.y+k*Math.sqrt(Math.pow(e*b,2)-Math.pow(g,2)),c)}},drawMarker(a,b=!0){let c=b?this.w*this.p.vibration:0,d=b?c*f.random(-1,1):0;b=b?c*f.random(-1,1):+0;this.mask.circle(this.position.x+d,this.position.y+b,this.w*this.p.weight*a)},drawCustomOrImage(a,b,c=!0){this.mask.push();let d=c?this.w*this.p.vibration:0,e=c?d*f.random(-1,1):0;c=c?d*f.random(-1,1):0;this.mask.translate(this.position.x+e,this.position.y+c);this.adjustSizeAndRotation(this.w*a,b);this.p.tip(this.mask);this.mask.pop()},drawDefault(a){let b=this.w*this.p.vibration*(this.p.definition+(1-this.p.definition)*randomGaussian()*this.gauss(.5,.9,5,.2,1.2)/a);.4<f.random(0,this.p.quality)&&+this.mask.circle(this.position.x+.7*b*f.random(-1,1),this.position.y+b*f.random(-1,1),a*this.p.weight*f.random(.85,1.15))},adjustSizeAndRotation(a,b){this.mask.scale(a);"image"===this.p.type&&(this.p.blend?this.mask.tint(255,0,0,b/2):this.mask.tint(this.mask.red(this.c),this.mask.green(this.c),this.mask.blue(this.c),b));"random"===this.p.rotate?this.mask.rotate(f.randInt(0,360)):"natural"===this.p.rotate&&(a=(this.plot?-this.plot.angle(this.position.plotted):-this.dir)+(this.flow?this.position.angle():+0),this.mask.rotate(a))},markerTip(){if(this.isInsideClippingArea()){let b=this.calculatePressure();var a=this.calculateAlpha(b);this.mask.fill(255,0,0,a/1.5);if("marker"===h.p.type)for(a=1;5>a;a++)this.drawMarker(b*a/5,!1);else if("custom"===h.p.type||"image"===h.p.type)for(let c=1;5>c;c++)this.drawCustomOrImage(b*c/5,a,!1)}}},V={tips:new Map,add(a){this.tips.set(a,!1)},imageToWhite(a){a.loadPixels();for(let b=0;b<4*a.width*a.height;b+=4){let c=(a.pixels[b]+a.pixels[b+1]+a.pixels[b+2])/3;a.pixels[b]=+a.pixels[b+1]=a.pixels[b+2]=255;a.pixels[b+3]=255-c}a.updatePixels()},load(){for(let a of this.tips.keys()){let b=loadImage(a,()=>V.imageToWhite(b));this.tips.set(a,b)}}},y={isActive:!1,hatchingParams:[5,45,{}],hatchingBrush:!1,hatch(a){let b=y.hatchingParams[0],c=y.hatchingParams[1],d=y.hatchingParams[2],e=h.c,g=h.name,k=h.w,p=h.isActive;y.hatchingBrush&&h.set(y.hatchingBrush[0],y.hatchingBrush[1],y.hatchingBrush[2]);c=f.toDegrees(c)%180;let n=Infinity,q=-Infinity,A=Infinity,C=-Infinity;var w=K=>+{for(let H of K.a)n=H[0]<n?H[0]:n,q=H[0]>q?H[0]:q,A=H[1]<A?H[1]:A,C=H[1]>C?H[1]:C};Array.isArray(a)||(a=[a]);for(var D of a)w(D);D=new P([[n,A],[q,A],[q,C],[n,C]]);let I=90>=c&&0<=c?A:C;var B=d.gradient?map(d.gradient,0,1,1,1.1,!0):1;w=[];let L=0,z=b,G=K=>({point1:{x:n+z*K*f.cos(-c+90),y:I+z*K*f.sin(-c+90)},point2:{x:n+z*K*f.cos(-c+90)+f.cos(-c),y:I+z*K*f.sin(-c+90)+f.sin(-c)}});for(;0<D.intersect(G(L)).length;){let K=[];for(var J of a)K.push(J.intersect(G(L)));w[L]=K.flat().sort((H,X)=>H.x===X.x?+H.y-X.y:H.x-X.x);z*=B;L++}a=[];for(var M of w)"undefined"!==typeof M[0]&&a.push(M);M=d.rand?d.rand:0;for(J=0;J<a.length;J++)for(w=a[J],D=0<J&&d.continuous,B=0;B<w.length-1;B+=2)0!==M&&(w[B].x+=M*b*f.random(-10,10),w[B].y+=M*b*f.random(-10,10),w[B+1].x+=M*b*f.random(-10,10),w[B+1].y+=M*b*f.random(-10,10)),h.line(w[B].x,w[B].y,w[B+1].x,w[B+1].y),D&&h.line(a[J-1][1].x,a[J-1][1].y,w[B].x,w[B].y);h.set(g,e,k);h.isActive=p}};class P{constructor(a,b=!1){this.a=a;this.vertices=a.map(c=>({x:c[0],y:c[1]}));+b&&(this.vertices=a);this.sides=this.vertices.map((c,d,e)=>[c,e[(d+1)%e.length]])}intersect(a){let b=`${a.point1.x},${a.point1.y}-${a.point2.x},${a.point2.y}`;if(this._intersectionCache&&this._intersectionCache[b])return this._intersectionCache[b];let c=[];for(let d of this.sides){let e=aa(a.point1,a.point2,d[0],d[1]);!1!==e&&c.push(e)}this._intersectionCache||(this._intersectionCache={});return this._intersectionCache[b]=c}draw(a=!1,b,c){let d=h.isActive;a&&h.set(a,b,c);if(h.isActive){E();for(let e of this.sides)h.line(e[0].x,+e[0].y,e[1].x,e[1].y)}h.isActive=d}fill(a=!1,b,c,d,e,g){let k=v.isActive;a&&(ka(a,b),la(c,g),ma(d,e));v.isActive&&(E(),v.fill(this));v.isActive=k}hatch(a=!1,b,c){let d=y.isActive;a&&fa(a,b,c);y.isActive&&(E(),y.hatch(this));y.isActive=d}}class T{constructor(a){this.segments=[];this.angles=[];this.pres=[];this.type=a;this.dir=0;this.calcIndex(0);this.pol=!1}addSegment(a=0,b=0,c=1,d=!1){0<this.angles.length&&this.angles.splice(-1);a=d?(a%360+360)%360:f.toDegrees(a);this.angles.push(a);this.pres.push(c);+this.segments.push(b);this.length=this.segments.reduce((e,g)=>e+g,0);this.angles.push(a)}endPlot(a=0,b=1,c=!1){a=c?(a%360+360)%360:f.toDegrees(a);this.angles.splice(-1);this.angles.push(a);this.pres.push(b)}rotate(a){this.dir=f.toDegrees(a)}pressure(a){return a>this.length?this.pres[this.pres.length-1]:this.curving(this.pres,a)}angle(a){if(a>this.length)return this.angles[this.angles.length-1];this.calcIndex(a);return"curve"===this.type?this.curving(this.angles,a)+this.dir:this.angles[this.index]++this.dir}curving(a,b){let c=a[this.index];a=a[this.index+1];"undefined"==typeof a&&(a=c);180<Math.abs(a-c)&&(a>c?a=-(360-a):c=-(360-c));return f.map(b-this.suma,0,this.segments[this.index],c,a,!0)}calcIndex(a){this.index=-1;let b=this.suma=0;for(;b<=a;)this.suma=b,b+=this.segments[this.index+1],this.index++}genPol(a,b,c=1,d=!1){E();var e=0;let g=9999;for(var k of this.segments)k*=c,0!==k&&(e=Math.max(e,k),g=Math.min(g,k));c=h.spacing();k=[];let p=f.constrain(v.bleed_strength,.05,1);d=(e+g)*(d?.03:+v.isAnimated?.25:p);this.calcIndex(0);a=new U(a,b);b=Math.round(this.length/c);for(e=0;e<b;e++)a.x&&(k[Math.floor(a.plotted/d)]=[a.x,a.y]),a.plotTo(this,c,c,1);this.calcIndex(0);return new P(k)}draw(a,b,c){h.isActive&&(E(),this.origin&&(a=this.origin[0],b=this.origin[1],c=1),h.flowShape(this,a,b,c))}fill(a,b,c){v.isActive&&(E(),this.origin&&(a=this.origin[0],b=this.origin[1],c=1),this.pol||(this.pol=this.genPol(a,b,c)),this.pol.fill())}hatch(a,b,c){y.isActive&&(E(),this.origin&&(a=this.origin[0],+b=this.origin[1],c=1),this.pol||(this.pol=this.genPol(a,b,c,!0)),this.pol.hatch())}}let F=!1,Q;const v={isActive:!1,isAnimated:!1,color:"#002185",opacity:80,bleed_strength:.07,texture_strength:.4,border_strength:.4,fill(a){this.polygon=a;this.v=a.a.map(c=>createVector(c[0],c[1]));const b=this.v.length*f.random(.4);v.m=this.v.map((c,d)=>{c=f.random(.8,1.2)*this.bleed_strength;return d<b?constrain(2*c,0,.9):c});a=f.randInt(0,this.v.length);this.v=[...this.v.slice(a),...this.v.slice(0,a)];(new na(this.v,+this.m,this.calcCenter(),[],!0)).fill(this.color,int(map(this.opacity,0,155,0,20,!0)),this.texture_strength)},calcCenter(){let a=0,b=0;for(let c=0;c<this.v.length;++c)a+=this.v[c].x,b+=this.v[c].y;a/=this.v.length;b/=this.v.length;return createVector(a,b)}};class na{constructor(a,b,c,d,e=!1){this.pol=new P(a,!0);this.v=a;this.dir=d;this.m=b;this.midP=c;this.size=p5.Vector.sub(this.midP,this.v[0]).mag();if(e)for(a="radians"===angleMode()?Math.PI/180:1,b=0;b<this.v.length;b++){c=this.v[b];d=this.v[(b++1)%this.v.length];e=p5.Vector.sub(d,c);var g=e.copy();g.rotate(90*a);e={point1:{x:c.x+e.x/2,y:c.y+e.y/2},point2:{x:c.x+e.x/2+g.x,y:c.y+e.y/2+g.y}};g=0;for(let k of v.polygon.intersect(e)).01<(d.x-c.x)*(k.y-c.y)-(d.y-c.y)*(k.x-c.x)&&g++;this.dir[b]=0===g%2?!0:!1}}grow(a,b=!1){const c=[],d=[],e=[];let g=.2<=a&&10<=this.v.length?Math.floor(a*this.v.length):this.v.length;const k=C=>{const w=randomGaussian(.5,.1);return C+.1*(w-.5)},p="radians"===angleMode()?Math.PI/180:1;for(let C=0;C<g;C++){var n=this.v[C],+q=this.v[(C+1)%g];let w=.1===a?.1>=v.bleed_strength?.25:.75:this.m[C];b&&(w*=-.5);c.push(n);d.push(k(w));let D=p5.Vector.lerp(n,q,constrain(randomGaussian(.5,.2),.1,.9));n=p5.Vector.sub(q,n);q=n.copy().normalize();let I=this.dir[C];var A="out"==v.direction?90:-90;A=(I?A:-A)+45*randomGaussian(0,.4);q.rotate(A*p);q.mult(randomGaussian(.5,.2)*random(.6,1.4)*n.mag()*w);D.add(q);c.push(D);d.push(k(w));e.push(I,I)}return new na(c,d,this.midP,e)}fill(a,b,c){const d=b/5+c*b/6,e=b/4+c*b/3,g=b/7+c*b/3;b/=5;+c*=3;x.trans();t.blend(a,!1,!1,!0);t.mask.push();t.mask.noStroke();t.mask.translate(x.translation[0]+l.width/2,x.translation[1]+l.height/2);t.mask.rotate(x.rotation);t.mask.scale(W);a=this.grow();let k=a.grow().grow(.9),p=k.grow(.75),n=this.grow(.85);for(let q=0;24>q;q++){if(6===q||12===q||18===q)a=a.grow(),k=k.grow(.75),p=p.grow(.75),n=n.grow(.1,!0);a.grow().layer(q,b);n.grow(.1,!0).grow(.1).layer(q,g,!1);k.grow(.1).grow(.1).layer(q,e,!1);p.grow(.8).grow(.1).layer(q,d,!1);0!==c&&a.erase(c)}t.mask.pop()}layer(a,+b,c=!0){t.mask.fill(255,0,0,b);c?(t.mask.stroke(255,0,0,.5+1.5*v.border_strength),t.mask.strokeWeight(f.map(a,0,24,6,.5))):t.mask.noStroke();t.mask.beginShape();for(let d of this.v)t.mask.vertex(d.x,d.y);t.mask.endShape(CLOSE)}erase(a){const b=f.random(80,110),c=this.size/2,d=.025*this.size,e=.19*this.size;t.mask.erase(3.5*a,0);for(a=0;a<b;a++){const g=this.midP.x+randomGaussian(0,c),k=this.midP.y+randomGaussian(0,c),p=f.random(d,e);t.mask.circle(g,k,p)}t.mask.noErase()}}p5.RendererGL.prototype.erase=+function(a,b){this._isErasing||(this._cachedBlendMode=this.curBlendMode,this._isErasing=!0,this.blendMode("destination-out"),this._cachedFillStyle=this.curFillColor.slice(),this.curFillColor=[1,1,1,a/255],this._cachedStrokeStyle=this.curStrokeColor.slice(),this.curStrokeColor=[1,1,1,b/255])};p5.RendererGL.prototype.noErase=function(){if(this._isErasing){this.curFillColor=this._cachedFillStyle.slice();this.curStrokeColor=this._cachedStrokeStyle.slice();let a=this.curBlendMode;this.blendMode(this._cachedBlendMode);+this._cachedBlendMode=a;this._isErasing=!1;this._applyBlendMode()}};const pa="weight vibration definition quality opacity spacing pressure type tip rotate".split(" "),da=[["pen",[.35,.12,.5,8,200,.3,{curve:[.15,.2],min_max:[1.3,1]}]],["rotring",[.2,.05,1,3,250,.15,{curve:[.05,.2],min_max:[1.2,.95]}]],["2B",[.35,.5,.1,8,180,.2,{curve:[.15,.2],min_max:[1.3,1]}]],["HB",[.3,.5,.4,4,180,.25,{curve:[.15,.2],min_max:[1.2,.9]}]],["2H",[.2,.4,.3,2,150,.2,{curve:[.15,.2],min_max:[1.2,.9]}]],["cpencil",[.4,+.6,.8,7,120,.15,{curve:[.15,.2],min_max:[.95,1.15]}]],["charcoal",[.5,2,.8,300,110,.06,{curve:[.15,.2],min_max:[1.15,.85]}]],["hatch_brush",[.2,.4,.3,2,150,.15,{curve:[.5,.7],min_max:[1,1.5]}]],["spray",[.3,12,15,40,120,.65,{curve:[0,.1],min_max:[.15,1.2]},"spray"]],["marker",[2.5,.12,null,null,30,.4,{curve:[.35,.25],min_max:[1.35,1]},"marker"]],["marker2",[2.5,.12,null,null,25,.35,{curve:[.35,.25],min_max:[1.15,.95]},"custom",function(a){let b=ea;a.rect(-1.5*b,-1.5*b,3*b,3*b);a.rect(1*b,1*b,1*b,+1*b)},"natural"]]];for(let a of da){let b={};for(let c=0;c<a[1].length;c++)b[pa[c]]=a[1][c];h.add(a[0],b)}m.config=function(a={}){a.R&&(f.source=a.R)};m.load=N;m.preload=function(){V.load()};m.colorCache=function(a=!0){t.isCaching=a};m.scaleBrushes=Z;m.push=ba;m.pop=ca;m.reDraw=t.reDraw;m.reBlend=t.reBlend;m.rotate=x.rotate;m.scale=oa;m.addField=O;m.field=function(a){E();r.isActive=!0;r.current=a};m.noField=function(){r.isActive=!1};m.refreshField=function(a){r.refresh(a)};m.listFields=function(){return Array.from(r.list.keys())};+m.add=h.add;m.box=function(){return Array.from(h.list.keys())};m.set=h.set;m.pick=h.setBrush;m.clip=h.clip;m.noClip=h.noClip;m.point=function(a,b,c){E();h.position=new U(a,b);h.drawTip(c)};m.stroke=h.setColor;m.strokeWeight=h.setWeight;m.noStroke=function(){h.isActive=!1};m.fill=ka;m.bleed=la;m.fillTexture=ma;m.noFill=function(){v.isActive=!1};m.fillAnimatedMode=function(a){v.isAnimated=a};m.line=h.line;m.flowLine=h.flowLine;m.plot=h.flowShape;m.rect=function(a,b,c,d,e=CORNER){e==CENTER&&(a-=c/2,+b-=d/2);r.isActive?(ha(0),R(a,b),R(a+c,b),R(a+c,b+d),R(a,b+d),ia(CLOSE)):(a=new P([[a,b],[a+c,b],[a+c,b+d],[a,b+d]]),a.fill(),a.hatch(),a.draw())};m.circle=function(a,b,c,d=!1){let e=new T("curve");var g=Math.PI*c/2;let k=random(0,360);e.addSegment(0+k+(d?f.random(-1,1):0),g+(d?f.random(-1,1):0),1,!0);e.addSegment(-90+k+(d?f.random(-1,1):0),g+(d?f.random(-1,1):0),1,!0);e.addSegment(-180+k+(d?f.random(-1,1):0),g+(d?f.random(-1,1):0),1,!0);e.addSegment(-270+k+(d?f.random(-1,1):0),g+(d?f.random(-1,1):+0),1,!0);g=d?f.randInt(-5,5):0;d&&e.addSegment(0+k,Math.PI/180*g*c,!0);e.endPlot(g+k,1,!0);e.fill(a-c*f.sin(k),b-c*f.cos(-k),1);e.hatch(a-c*f.sin(k),b-c*f.cos(-k),1);e.draw(a-c*f.sin(k),b-c*f.cos(-k),1)};m.polygon=function(a){a=new P(a);a.fill();a.hatch();a.draw()};m.spline=function(a,b=.5){ja(a,b).draw()};m.beginShape=ha;m.vertex=R;m.endShape=ia;m.beginStroke=function(a,b,c){Q=[b,c];F=new T(a)};m.segment=function(a,b,c){F.addSegment(a,b,c)};m.endStroke=function(a,b){F.endPlot(a,b);F.draw(Q[0],Q[1],+1);F=!1};m.hatchArray=y.hatch;m.hatch=fa;m.setHatch=function(a,b="black",c=1){y.hatchingBrush=[a,b,c]};m.noHatch=function(){y.isActive=!1;y.hatchingBrush=!1};m.Polygon=P;m.Plot=T;m.Position=U});\ No newline at end of filediff --git a/sketch.js b/sketch.jsindex 19b6344..62a021a 100644--- a/sketch.js+++ b/sketch.js@@ -65,19 +65,25 @@ function preload() {brush.preload();}-let palette = ["#002185", "#fcd300", "#ff2702", "#6b9404"]+let palette = ["#002185", "#fcd300", "#ff2702", "#6b9404", "#000000"]+let x_values = []+let y_values = []function setup () {C.createCanvas()background("#e2e7dc")- angleMode(DEGREES)+ angleMode(RADIANS)translate(-width/2,-height/2)++ for (let i = 0; i < 5; i++) {+ x_values[i] = random(width)+ y_values[i] = random(width)+ }- //randomNumber = random() * 1213213-+ /*brush.field("seabed")// STANDARD PALETTE TESTlet i = 0@@ -86,26 +92,31 @@ function setup () {brush.flowLine(30,60+i*10,195,0)i++}+ */}function draw() {- /*+background("#e2e7dc")- brush.noStroke()translate(-width/2,-height/2)- randomSeed(randomNumber)- brush.fillAnimatedMode(true)+ strokeWeight(2)+ brush.fill("#ff2702",70)+ brush.bleed(0.2)+ brush.beginShape(0 + frameCount * 0.01)+ for (let i = 0; i < 5; i++) {+ stroke(palette[i])+ point(x_values[i],y_values[i])+ brush.vertex(x_values[i],y_values[i])+ }+ randomSeed(12133)+ brush.endShape(CLOSE)- frameRate(20)+ noLoop()+}- for (let i = 0; i < frameCount * 0.02; i++ ) {- if (i < 3) {- brush.fill(palette[i%palette.length], 40)- brush.bleed(0.1 + frameCount * 0.01 - i * 0.4,"out")- brush.fillTexture(0.6)- brush.circle(width * random(0.25,0.75),width * random(0.25,0.75),random(30,40))- brush.reBlend()- }- }- */+function mouseDragged() {+ loop()+ frameRate(10)+ x_values[0] = mouseX+ y_values[0] = mouseY}\ No newline at end of file