var meta={p:"genify",op:"deploy",name:"Island Mist",max:"600",desc:'Flying over the sea, a group of islands appears on the horizon, shrouded in the mist ...\n\n"Island Mist" presents a tranquil aerial perspective of islands adrift in a calm sea. Soft clouds imbue the scene with tranquility, while the touch of light illuminates the seascape below.\n\nThis fully generative image is rendered using a painting simulation algorithm, drawing inspiration from the styles of pointillism and impressionism. Through the blending of thousands of brush strokes, vibrant colors reminiscent of fauvist works emerge, introducing an element of surrealism with their unnatural yet captivating hues. \n\nCombining a calm, dream-like atmosphere with a dynamic, painterly technique, "Island Mist" asks viewers to imagine a world where reality and imagination intertwine.\n\nPress S to save the rendered image.',artist:"Nudoru",lib:"p5@1.9",res:"1024x1250",sats:15e4,psats:15e4};document.addEventListener("p5Loaded",(()=>{const{PI:e,round:o,abs:t,sin:r,cos:l,atan2:s,sqrt:n,floor:a,min:i,max:u}=Math,d=2*e,c=(e,o)=>{if(o<e){let t=e;e=o,o=t}return t(randomValue())*(o-e)+e},h=(e,t)=>{if(t<e){let o=e;e=t,t=o}return o(randomValue()*(t-e)+e)},f=(e=.5)=>randomValue()<e,p=(e,o)=>n(randomValue())*(o-e)+e,b=e=>e[h(0,e.length-1)],m=(e,o,t,r,l)=>{let s,n=t*(1-(s=((e=0,o=1,t)=>i(o,u(e,t)))(0,1,(l-e)/(o-e))))+r*s;return isNaN(n)&&(n=0),n},g=(e,o,t,s,n)=>{let a=l(n),i=r(n);return[a*(t-e)+i*(s-o)+e,a*(s-o)-i*(t-e)+o]},C=e=>{let{r:o,g:t,b:r,a:l}=e,s=i(o,t,r),n=i(255-o,255-t,255-r),a=o-s,d=t-s,c=r-s,h=i(a,d),f=a-h,p=(d+h)/2,b=(c+d-h)/2,m=u(f,p,b)/u(a,d,c),g=isNaN(m)||m===1/0||m<=0?1:m;return{r:f/g+n,y:p/g+n,b:b/g+n,a:l}},w=e=>i(100,u(0,e)),y=e=>u(0,i(255,e)),x=e=>class t{constructor(...o){o[0]instanceof t?this._color=o[0].c():this._color=e.color(...o)}static mixClrs(o,t,r=50){return e.lerpColor(o,t,.01*r)}static mixClrsRYB(e,o,r=50){let l=C(e.toRGB()),s=C(o.toRGB()),n=.01*r,a=(e=>{let{r:o,y:t,b:r,a:l}=e,s=i(o,t,r),n=i(255-o,255-t,255-r),a=o-s,d=t-s,c=r-s,h=i(d,c),f=a+d-h,p=d+h,b=2*(c-h),m=u(f,p,b)/u(a,d,c),g=isNaN(m)||m===1/0||m<=0?1:m;return{r:f/g+n,g:p/g+n,b:b/g+n,a:l}})({r:(s.r-l.r)*n+l.r,y:(s.y-l.y)*n+l.y,b:(s.b-l.b)*n+l.b});return new t(a.r,a.g,a.b,l.a)}c(){return this._color}clone(){return new t(this._color)}toRGB(){return{r:e.red(this._color),g:e.green(this._color),b:e.blue(this._color),a:e.alpha(this._color)}}toHSB(){return{h:e.hue(this._color),s:e.saturation(this._color),b:e.brightness(this._color),a:e.alpha(this._color)}}hsbToP(o){let t=((e,o,t)=>{o/=120,t/=100;let r=o=>(o+e/60)%6,l=e=>t*(1-o*u(0,i(r(e),4-r(e),1)));return{r:255*l(5),g:255*l(3),b:255*l(1)}})(o.h,o.s,o.b);return e.color(t.r,t.g,t.b,o.a)}spin(e=0){let o=this.toHSB(),t=(o.h+e)%360;return o.h=t<0?360+t:t,this._color=this.hsbToP(o),this}getBrightness(){let e=this.toRGB();return(299*e.r+587*e.g+114*e.b)/1e3}setAlpha(o){let t=this.toRGB();return this._color=e.color(t.r,t.g,t.b,o),this}brighten(t=0){let r=this.toRGB();return r.r-=o(-t/100*255),r.g-=o(-t/100*255),r.b-=o(-t/100*255),this._color=e.color(y(r.r),y(r.g),y(r.b),r.a),this}lighten(e=0){let o=this.toHSB();return o.b=w(o.b+e),this._color=this.hsbToP(o),this}darken(e=0){let o=this.toHSB();return o.b=w(o.b-e),this._color=this.hsbToP(o),this}saturate(e=0){let o=this.toHSB();return o.s=w(o.s+e),this._color=this.hsbToP(o),this}},S=(e,o,t)=>{let r=100/t,l=[];for(let t=0;t<=100;t+=r)l.push(pColorCls.mixClrsRYB(e,o,t));return l};class M{constructor(e,o,t=50){this.colors=e.map((e=>pColor(e))),o&&(this.colors=this.colors.map((e=>pColorCls.mixClrsRYB(e,o,t))))}get brightest(){return(e=this.colors).reduce(((e,o)=>(o.getBrightness()>e.getBrightness()&&(e=o),e)),e[0]);var e}get darkest(){return(e=this.colors).reduce(((e,o)=>(o.getBrightness()<e.getBrightness()&&(e=o),e)),e[0]);var e}getAtIndex(e){let r=t(o(e))%this.colors.length;return this.colors[r].clone()}oneOf(e=0){let o=this.getAtIndex(h(0,this.colors.length-1));return e>0&&o.spin(c(-1*e,e)),o}getFromNoiseValue(e){return this.getAtIndex(e*this.colors.length)}}const k=["#cdc785","#e7c8a6","#b1e1c7","#f5e8d1","#cce3aa","#f1e0c4","#d2c2c4","#b5c3c4","#fafad2","#faebd7","#fff8dc","#fffff0","#f5fffa","#ffefd5","#fff5ee"],B=["#634b4d","#383d74","#53526b","#6d7287","#2b3e8f","#506db9","#5d2f29","#2f441f","#323e77","#3c3d59","#2e3b2f","#191970","#483d8b","#4b0082","#800000","#4682b4"],N=[{name:"Blue Sunset ",colors:["#373af3","#eb7e38","#1618aa","#7677fa","#fadf53"]},{name:"Topical Sunset",colors:["#ffbe0b","#fb5607","#ff006e","#8338ec","#3a86ff"]},{name:"Warm Cool",colors:["#3d348b","#7678ed","#f7b801","#f18701","#f35b04"]},{name:"Muted",colors:["#264653","#2a9d8f","#e9c46a","#f4a261","#e76f51"]},{name:"Cezanne",colors:["#9aa390","#52656f","#b39115","#6e9042","#3b88c2","#a24b04"]},{name:"Comfort Green",colors:["#406639","#909a53","#153024","#96a6bf","#bcc2be"]},{name:"Warm Burgundy",colors:["#d81159","#8f2d56","#218380","#fbb13c","#73d2de"]},{name:"Alma",colors:["#c33120","#0588a3","#e99216","#9ab4a2","#5b8842","#f1ce27"]},{name:"Waterloo",colors:["#7f90a2","#b47677","#fb7f4a","#913004","#165291","#75978e","#4a789e"]},{name:"June Wheat",colors:["#a27741","#7688a2","#384b91","#dfbd90","#ff925e","#ffd266"]},{name:"Poplars",colors:["#76b4f0","#a3b4a3","#dfbd77","#40a1a5","#b22f0c","#f06520"]},{name:"Lavender Sunset",colors:["#655388","#9065a3","#ce9199","#a294ef","#b46192","#4a5f9e"]},{name:"Cartagena",colors:["#f9914b","#fcce6d","#e06530","#cf0427","#0076bd","#5380a2"]},{name:"Cool Copper",colors:["#a2b3bd","#496779","#415d71","#ce886e","#f29942","#ce4b41","#d06c02"]},{name:"Iridescent",colors:["#fbb301","#03a2b3","#015ca3","#fe7e06","#ac5ce3","#d42a4b","#0fdfde"]},{name:"Deep Citrus",colors:["#fb7f03","#a24201","#c5a230","#a27703","#8e3455","#6fab88","#5a8e68"]},{name:"Walkway",colors:["#aab65a","#fcc601","#0190a3","#a3011d","#fc4a01"]},{name:"Plumage",colors:["#1d88a3","#a28830","#e04230","#77a29a","#eac630","#6d9b26","#429a77"]},{name:"Yarn",colors:["#3077ce","#915cc5","#ee0a4c","#99bb53","#e8a437"]},{name:"Bright Night",colors:["#01596f","#9b7776","#0498bc","#fb0302","#0bcee0","#fa88c6","#f3d1ac","#fe08b3","#049589","#edc725"]},{name:"Klimt Forest",colors:["#905c4b","#865a02","#e9b054","#7180a1","#99190e","#c67a1a"]},{name:"Beach Walk",colors:["#fb9003","#f0df4b","#a32f64","#fb2f76","#95c0f5","#b856ce"]},{name:"Polis",colors:["#fa4c0b","#3092f0","#fad90c","#0d7f26","#2f5b9a","#fba6fd"]},{name:"Hot Ice",colors:["#fc02ce","#0241fb","#4a3164","#0094f5","#fde659","#fd818f"]},{name:"Mitchell Warm",colors:["#f1a303","#cf6402","#537799","#8f4ba3","#c5915b","#355986","#9db8c9","#e3c604","#ad90bf"]},{name:"Mitchell Green",colors:["#042f77","#6e88b3","#bc6503","#995b99","#085e30","#d8efa6"]},{name:"Mitchell Piano",colors:["#bd762f","#907791","#b4a3a3","#5c886d","#777530","#948f0d","#e4c751","#7db299"]}];class F{constructor(e,t,r=0){let l=o(e),s=o(t);this.fullBounds=_(0,0,l,s),this.bounds=_(r,r,l-2*r,s-2*r),this.cells=[this.bounds]}}const A=(e,o)=>((e,o)=>({x:e.x*o,y:e.y*o,z:e.z*o}))(e,o/(e=>n(((e,o)=>e.x*o.x+e.y*o.y+e.z*o.z)(e,e)))(e)),P=(o,t)=>(s(t[1]-o[1],t[0]-o[0])-e/2)%d,T=(o,t,r)=>r-((o,t)=>{let r=(o-(t>0?t:t+d)+e)%d-e;return r<-e?r+d:r})(r,P(o,t)),V=(e,o,t)=>({x:e,y:o,radius:t,type:"circle"}),v=(e,o)=>(o.length&&(o={x:o[0],y:o[1]}),$(o,e)<e.radius/2),L=(e,o=0,t=0)=>G(((e,o=0,t=50)=>e.map((e=>{let s=c(o,t),n=c(0,d);return[e[0]+s*l(n),e[1]+s*r(n)]})))(e,o,t),1),Y=(e,o,t=.1,s=0,n=20,a=10,i=0,u=0)=>{let d=((e=0,o=1)=>A({x:l(e),y:r(e),z:0},o))(s?t+c(-s,s):t,n);return((e,o,t,r,l=10,s=0,n=0)=>{let a=[],i=(t-e)/l,u=(r-o)/l,d=e,c=o,h=0;for(;h++<=l;)a.push([d,c]),d+=i,c+=u;return n?L(a,s,n):a})(e,o,e+d.x,o+d.y,a,i,u)},z=(o,t,s,n=20,a=0,i=!1)=>{let u=e/n,c=[];for(let e=0;e<=d;e+=u){let n=l(e+a)*s+o,i=r(e+a)*s+t;c.push([n,i])}return i&&c.push(c[0]),c},W=e=>H(e.x,e.y,e.radius,e.radius,1)[0],H=(o,t,s,n,a=1)=>{let i=[];for(let u=0;u<a;u++){let a=p(0,s),u=p(0,n),d=c(0,2*e),h=a*l(d)+o,f=u*r(d)+t;i.push([h,f])}return i},_=(e,o,t,r)=>({x:e,y:o,w:t,h:r,x2:e+t,y2:o+r,mx:e+t/2,my:o+r/2,type:"rectangle"}),q=(e,o)=>(o.length&&(o={x:o[0],y:o[1]}),o.x>=e.x&&o.x<=e.x2&&o.y>=e.y&&o.y<=e.y2),O=e=>[h(0,e.w)+e.x,h(0,e.h)+e.y],I=e=>{let o=e.drawingContext;return{fromPoints:(n,a={},i=1)=>{let{bristleDensity:u=30,thickness:h=30*i,height:f,color:b=null,colorVariance:C=10,minBristle:w=.25*i,maxBristle:y=1*i,minLoad:x=0,maxLoad:S=1,startScale:M=1,endScale:k=1,startSpread:B=1,endSpread:N=1,bristleAlpha:F=.75,bristleTwist:A=.1}=a;if(n.length<2)return;let V=n.length,R=A/V,v=((e,o,t=3,r=30,l=30,s="red",n=0,a=0,i=1)=>{let u=[];for(let h=0;h<t;h++){let t=p(0,r),h=s.clone();u.push({lastx:0,lasty:0,radiusWidth:t,radiusHeight:p(0,l),angle:c(0,d),color:0===n?h:h.clone().spin(c(-n,n)),size:c(e,o),load:c(a,i),fromCenter:m(0,r,0,1,t),colorMixPct:m(0,r,0,75,t)})}return u})(w,y,u,h,f||h,b,C,x,S),L=P(n[0],n[1]);return n.forEach(((a,i)=>{let u=i<V-1?n[i+1]:null;if(u){let n=t(m(0,V-1,0,1,i)-1),c=a[0],h=a[1],f=u[0],p=u[1],b=(e=>s(r(e),l(e)))(T(a,u,L)),C=m(0,V,M,k,i),w=m(0,V,B,N,i);v.forEach((t=>{let s=r(t.angle),i=l(t.angle),d=t.radiusWidth*w*i+c,m=t.radiusHeight*w*s+h,y=t.radiusWidth*w*i+f,x=t.radiusHeight*w*s+p,S=[g(a[0],a[1],d,m,-L),g(u[0],u[1],y,x,-b)],M=t.size*C*n*t.load;e.noFill(),e.strokeWeight(M);let k=t.lastx||S[0][0],B=t.lasty||S[0][1],N=t.color;e.stroke(N.setAlpha(F).c()),D(o,k,B,S[1][0],S[1][1]),t.lastx=S[1][0],t.lasty=S[1][1],t.angle+=R})),L=b%d}})),v}}},D=(e,o,t,r,l)=>{e.beginPath(),e.moveTo(o,t),e.lineTo(r,l),e.stroke(),e.closePath()},E=(e,o,t=!1,r=!0,l=!0,s=null)=>{e.beginPath(),o.forEach(((o,t)=>{s&&s(o,t),0===t?e.moveTo(o[0],o[1]):e.lineTo(o[0],o[1])})),t&&e.lineTo(o[0][0],o[0][1]),r&&e.stroke(),t&&l&&e.fill(),e.closePath()},G=(e,o=1)=>{if(0===o)return e;let t=((e,o=[])=>{let t=(e,o)=>(e[0]=o[0],e[1]=o[1],e);e.length>0&&o.push(t([0,0],e[0]));for(let t=0;t<e.length-1;t++){let r=e[t],l=e[t+1],s=r[0],n=r[1],a=l[0],i=l[1],u=[.75*s+.25*a,.75*n+.25*i],d=[.25*s+.75*a,.25*n+.75*i];o.push(u),o.push(d)}return e.length>1&&o.push(t([0,0],e[e.length-1])),o})(e);return 1===o?t:G(t,o-1)},X=(e,o)=>{let t=e[0]-o[0],r=e[1]-o[1];return n(t*t+r*r)},$=(e,o)=>{let t=e.x-o.x,r=e.y-o.y;return n(t*t+r*r)},j=(e,o,t)=>[2*o[0]-(e[0]+t[0])/2,2*o[1]-(e[1]+t[1])/2],J=(e,o,t,r)=>[(1-r)**2*e[0]+2*(1-r)*r*o[0]+r*r*t[0],(1-r)**2*e[1]+2*(1-r)*r*o[1]+r*r*t[1]],K=(e,o,t=.1,s=0,n=20,a=.1,i=20,u=0,d=0,c=0)=>{let h=Y(e,o,t,s,n,2),f=h[0],p=h[h.length-1],b=((e,o=100,t=0)=>[e[0]+o*l(t),e[1]+o*r(t)])(((e,o)=>[(o[0]-e[0])/2+e[0],(o[1]-e[1])/2+e[1]])(f,p),i,u),m=((e,o,t,r=.05,l=!1)=>{let s=[];for(let n=0;n<=1.0001;n+=r)l&&(o=j(e,o,t)),s.push(J(e,o,t,n));return s})(f,b,p,a);return c&&(m=L(m,d,c)),m},Q=e=>{let o=window.location.search.substring(1).split("&");for(let t=0;t<o.length;t++){let r=o[t].split("=");if(r[0]===e)return r[1]}return!1};document.getElementById("gcss").innerHTML+="canvas {max-width: 100%;max-height: 100%;position: absolute;top:0;left:0;object-fit: contain;}",new p5((n=>{let i,d,p,g,C,w,y,A,P,T,Y,H;n.disableFriendlyErrors=!0;let D="true"===Q("debug"),$="true"===Q("hiq"),j="true"===Q("nomargin"),J=parseFloat(Q("ar")),U=parseFloat(Q("scale")),Z=parseFloat(Q("pscale")),ee=((e,o)=>{tokenHash||tokenHash.length?console.log(`Token ${tokenHash}`):(console.warn("No token hash!"),o=o||~~(123456789*Math.random()));let t=o||~~(123456789*R.random_dec());return console.log(`Seed ${t}`),e.randomSeed(t),e.noiseSeed(t),tokenHash.length?window.randomValue=()=>R.random_dec():window.randomValue=()=>e.random(),window.noise2d=(o,t=1)=>(r,l)=>e.noise(r*o,l*o)*t*2-1,t})(n);(e=>{e.colorMode(e.RGB,255,255,255,1),window.pColorCls=x(e),window.pColor=(...e)=>new pColorCls(...e)})(n),n.pixelDensity(1);let oe=!isNaN(J)&&J<=1?J:8.5/11,te=!isNaN(U)&&U?U:3,re=1e3*te,le=a(re*oe);console.log(`Scale ${te} at ratio ${oe} = ${le} x ${re}`);let se=f(.1),ne=b([0,1,1,2,3]),ae=0===ne,ie={title:"island-mist",seed:ee,width:le,height:re,ratio:oe,paletteIndex:h(0,N.length-1),pointillismScale:c(2,2.7),margin:h(5,20)*te,darkMode:!!se,drawStyle:b([0,1]),isSpring:ae,isSummer:1===ne,isFall:2===ne,isWinter:3===ne,isNight:se,horizonM:c(.33,.66),maxCBMult:f(.7)?h(7,30):h(20,50),minStrokeLoad:c(.2,1),maxStrokeLoad:c(1,3),strokeColorVariance:f()?0:h(10,30),strokeAngVar:c(.05,.2),paintPointYOffsetMax:h(10,150)*te,compositionFlowAmpTop:re*c(.07,.22)*(f()?-1:1),compositionFlowAmpBottom:re*c(0,.05),compositionFlowXOffsTop:c(-2,2),compositionFlowXOffsBottom:c(-2,2),noiseFallOff:c(.4,.6),heightNoiseXM:c(.25,1),heightNoiseFreq:c(.01,.04)/te,cloudNoiseFreq:c(.01,.02)/te,cloudEdgeFuzz:c(.01,.2),cloudEdgeNoiseM:c(5,20),lowCloudNoiseFreq:c(.01,.02)/te,lowCloudHeight:c(7,14)*te,lowCloudForeM:c(1,3),lowCloudAlpha:c(.1,.3),cloudTxXMult:c(.1,1),cloudColorNMult:c(.5,2),cloudLight:c(50,100),cloudShadow:-1*c(20,50),cloudyLightMix:h(20,80),rowColorNoiseFreq:c(.005,.05)/te,mtnMax:100*c(1,2)*te,horizonPersp:c(.5,1),edgePersp:c(.1,.25),flipPerspective:f(),horizonYM:c(.15,.33),bottomYM:1,mtnColorMode:b([0,1]),colorVary:h(5,20),skyWaterColorSpin:f()?0:c(5,20),skyBottomColorSkyMix:h(10,100),skyBottomColorWaterMix:f()?h(10,20):h(20,50),distMtnShadingMBot:c(.2,1),waterNoiseCutoff:0,waterWaveChance:c(.2,.5),waterRippleCenterX:c(0,le),waterWaveTipBracket:c(.25,.5),waterWaveShadeStr:c(5,20),waterRippleBracket:c(.01,.09),atmosLightness:c(20,80),atmosDarkness:-1*c(10,100),fogAmount:f(.75)?10:c(10,100),flowerSlope:c(.2,.4),flowerCircleChance:f()?.005:c(.05,.3),treeSlope:c(.3,.5),treeChance:c(.05,.25),treeType:b([0,1,2]),treeTopLightValue:c(1,30),treeBottomLightValue:c(-50,-25),treeSizeMax:c(5,14),treeSizeMin:c(1,3),treeMinHeightValue:c(0,.33),treeSourceTint:f()?0:h(10,90),hasSun:f(.4),crescentSun:!1,sunRadius:h(30,100)*te,sunBrightness:h(30,80),sunProxMaxBrighten:h(20,80),sunGlowSizeMult:c(.5,1),sunInsideColor:f(),isCloudy:f(.33),isSunset:f(.33),hasCliff:f(),hasLowClouds:f(),lowCloudPaletteColorPal:f(),hasShore:f(),hasWaterRipple:f(),hasFlowers:!0,hasTrees:!0,starChance:c(.005,.03),duoTone:!ae&&f(.15),colorFullBg:!!se||f(),palMixColorAmount:f()?h(5,15):h(20,50)};if(j&&(ie.margin=0),Z&&(ie.pointillismScale=Z),ie.hasSun&&(ie.isCloudy=!1),ie.strokeColorVariance&&(ie.fogAmount*=.2,ie.atmosLightness*=.2),(ie.duoTone||ie.isNight)&&(ie.isCloudy=!1,ie.hasSun=!0,ie.sunBrightness=h(60,100),ie.crescentSun=f(.3),ie.strokeColorVariance=30),ie.isCloudy&&(ie.hasShore=!0,ie.hasWaterRipple=!0,ie.colorFullBg=!0,ie.maxCBMult*=.25,ie.cloudColorNMult*=.33),ie.isSunset&&!ie.hasSun&&(ie.hasSun=f(.75)),ie.flipPerspective){let e=ie.horizonPersp;ie.horizonPersp=ie.edgePersp,ie.edgePersp=e}let ue=ie.darkMode?pColor("#27241d"):pColor("#dfddd6"),de=b(B),ce=b(k),he=ie.isNight?pColor(de).darken(30).saturate(20):pColor(de),fe=ie.isNight?pColor(de).brighten(10).saturate(50):pColor(ce),pe=new M((e=>{for(let o=e.length-1;o>0;o--){let t=a(randomValue()*(o+1)),r=e[o];e[o]=e[t],e[t]=r}return e})(N[ie.paletteIndex].colors)),be=pe.oneOf();ie.isNight?(pe=new M(S(he,fe,5)),ie.palMixColorAmount=h(70,90),be=he):ie.duoTone&&(f(.66)?(he=pColor(de).darken(20).saturate(h(0,20)),fe=pColor(ce)):(he=pe.darkest.darken(20),fe=pe.brightest.brighten(20).saturate(h(0,20))),pe=new M(S(he,fe,5)));let me=((e,o,r=0)=>(l,s=0)=>(s+=r)<0?pColorCls.mixClrsRYB(l,e,t(s)):pColorCls.mixClrsRYB(l,o,s))(he,fe),ge=new M(S(he,fe,5),be,ie.palMixColorAmount),Ce=new M(S(pColor("#4b680c"),pColor("#899630"),5),be,ie.palMixColorAmount),we=new M(S(pColor("#102018"),pColor("#404508"),5),be,ie.palMixColorAmount),ye=new M(S(pColor("#3a4f22"),pColor("#6b845e"),5),be,ie.palMixColorAmount),xe=new M(["#bca835","#ffe519","#fda01b","#fc6b3c","#f63a38","#c1a830","#df2335"],be,ie.palMixColorAmount),Se=new M(["#dc191a","#88151d","#831c27","#9e5473","#a23446"],be,ie.palMixColorAmount),Me=new M(["#fde61f","#fad30b","#edb709","#c79703","#c69031","#f1dd9c"],be,ie.palMixColorAmount),ke=new M(S(pColor("#4b281d"),pColor("#795b4d"),10),be,ie.palMixColorAmount),Be=new M(S(pColor("#f5f1d8"),pColor("#c2b8a6"),10),be,ie.palMixColorAmount),Ne=new M(S(pColor("#d5e8cb"),pColor("#f0f6ef"),5),be,ie.palMixColorAmount),Fe=new M(S(pColor("#f2c1bf"),pColor("#c76a7f"),5),be,ie.palMixColorAmount),Ae=new M(S(pColor("#95dae1"),pColor("#98dbe4"),5),be,ie.palMixColorAmount),Pe=new M(S(pColor("#ddbb33"),pColor("#ffdd33"),5),be,ie.palMixColorAmount),Te=new M(S(pColor("#8f79c0"),pColor("#483570"),5),be,ie.palMixColorAmount),Ve=b([Ce,we,ye]),Re=b([Ce,we,ye]),ve=[Ne,Fe,Ae,Pe,Te],Le=b(ve),Ye=new M(S(pColor("#b5c9e0"),pColor("#98a0ca"),5),be,ie.palMixColorAmount),ze=new M(S(pColor("#faf3d8"),pColor("#fcd6b3"),5),be,ie.palMixColorAmount),We=new M(S(pColor("#27241d"),pColor("#1f2933"),5),be,ie.palMixColorAmount),He=[[pColor("#b5c9e0"),pColor("#98a0ca")],[pColor("#b5c9e0"),pColor("#98a0ca")],[pColor("#b5c9e0"),pColor("#98a0ca")],[pColor("lightcyan"),pColor("powderblue")],[pColor("skyblue"),pColor("deepskyblue")],[pColor("#fd8732"),pColor("#284a64")],[pColor("#fbc466"),pColor("#b3b8b8")],[pe.brightest,pe.darkest]],_e=h(0,He.length-1),qe=He[_e][1],Oe=f(.66)?He[_e][0]:pColor(b(["red","orange","rebeccapurple","blue","oldlace","aquamarine","gold","orchid"])),Ie=ie.lowCloudPaletteColorPal?new M(S(Oe.clone().brighten(50),pColor("#faf3d8"),5),fe,50):ze,De=pColorCls.mixClrsRYB(fe,pColor(b(["white","red","orange","yellow","cornsilk",",lightyellow","gold"])),ie.sunBrightness),Ee=ie.sunInsideColor?De.clone().brighten(h(5,30)):De,Ge=De.clone();ie.isSpring&&(ie.flowerSlope*=2),ie.isFall&&(Ve=b([Se,xe,Me]),Le=ke),ie.isWinter&&(Ve=b([Se,Be,Me]),Le=Be,ie.flowerSlope*=2),ie.isSunset&&(Oe=pColor("orange"),De=pColor("yellow"),Ee=pColor("red"),Ge=pColor("orange"),ie.sunGlowSizeMult=1),(ie.duoTone||ie.isNight)&&(qe=pe.darkest,Oe=pe.brightest),ie.duoTone&&(Ve=ge,Re=ge,Le=ge,Ye=ge,ze=ge,Ie=ge,We=ge,pe=ge);let Xe=0,$e=!1,je=$?.2:.4,Je=$?3:2,Ke=1*te,Qe=1*te,Ue=ie.width/(($?5:10)/ie.pointillismScale),Ze=Math.round(1e3*oe),eo=Ze/le,oo=1e3/re,to=noise2d(ie.heightNoiseFreq),ro=noise2d(3*ie.heightNoiseFreq),lo=noise2d(ie.cloudNoiseFreq),so=noise2d(ie.cloudNoiseFreq*ie.cloudEdgeNoiseM),no=noise2d(ie.lowCloudNoiseFreq),ao=noise2d(ie.cloudNoiseFreq*ie.cloudColorNMult),io=noise2d(.33*ie.cloudNoiseFreq),uo=noise2d(ie.rowColorNoiseFreq),co=noise2d(.25*ie.rowColorNoiseFreq),ho=ie.sunRadius,fo=0;D&&console.table(ie),R.set_features({Palette:N[ie.paletteIndex].name,"Palette Mix":o(.1*ie.maxCBMult),"Draw Style":0===ie.drawStyle?"Random":"Rows","Pointillism Scale":o(10*(ie.pointillismScale-2)),Warp:o(.01*ie.compositionFlowAmpTop),Duotone:ie.duoTone?"Yes":"No","Color background":ie.colorFullBg?"Yes":"No",Night:ie.isNight?"Yes":"No","Crescent Moon":ie.crescentSun?"Yes":"No",Season:["Spring","Summer","Fall","Winter"][ne],Horizon:ie.horizonM<.5?"High":"Low",Fog:ie.fogAmount>10?"Yes":"No",Trees:["Hardwood","Evergreen","Mixed"][ie.treeType],Sunset:ie.isSunset?"Yes":"No",Sun:ie.hasSun?"Yes":"No",Cloudy:ie.isCloudy?"Yes":"No","Low Clouds":ie.hasLowClouds?"Yes":"No","Atmos Lightness":o(.1*ie.atmosLightness),"Atmos Darkness":o(-.1*ie.atmosDarkness)}),console.table(window.$genFeatures),n.setup=()=>{g=performance.now(),n.createCanvas(ie.width,ie.height).id("mainCanvas"),document.querySelector("#mainCanvas"),i=n.drawingContext,P=(d=new F(ie.width,ie.height,ie.margin)).bounds.y+d.bounds.h*ie.horizonM,_(d.bounds.x,d.bounds.y,d.bounds.w,P),_(d.bounds.x,P,d.bounds.w,d.bounds.h-P),T=[d.bounds.mx+h(-ie.width/3,ie.width/3),d.bounds.y+P/2],ie.isSunset&&(T[1]=P-ho*c(.25,1.5)),Y=V(T[0],T[1],ho);let e=ho*c(.1,.75)*(f()?1:-1),o=ho*c(0,.2)*(f()?1:-1);H=V(T[0]+e,T[1]+o,ho),p=I(n),C=w=d.bounds.y-t(ie.compositionFlowAmpTop),y=d.bounds.y2+t(ie.compositionFlowAmpBottom)+ie.mtnMax,A=n.createGraphics(Ze,1e3),n.noiseDetail(8,ie.noiseFallOff),n.strokeCap(n.SQUARE),n.noStroke(),n.fill(ue.c()),n.rect(0,0,ie.width,ie.height)};let po=(o,t,r,l)=>{if(!q(d.bounds,o[0])||!q(d.bounds,o[o.length-1]))return;l=l||c(.4,.8);let s=pColorCls.mixClrsRYB(t,pe.oneOf(ie.colorVary),h(5,ie.maxCBMult));if(D){let e=c(.1,4)*te,t=c(.1,2)*te;return i.setLineDash([e,t]),n.strokeWeight(2*r),n.stroke(s.setAlpha(l).c()),void E(i,o)}p.fromPoints(o,{thickness:r,height:r*c(.3,1),color:s,colorVariance:ie.strokeColorVariance,bristleAlpha:l,minBristle:.5*te,maxBristle:te,minLoad:ie.minStrokeLoad,maxLoad:ie.maxStrokeLoad,bristleDensity:r*Je/ie.pointillismScale,bristleTwist:e*c(.2,2),startScale:c(1,1.2),startSpread:c(1,1.25),endScale:c(.5,.8),endSpread:c(.6,1)},te)},bo=(e,o)=>{let t,r=ie.edgePersp,l=ie.horizonPersp;return e*(t=o<P?m(d.bounds.y,P,r,l,o):m(P,d.bounds.y2,l,r,o))+d.bounds.w*(1-t)/2},mo=(e,o)=>{let t=1*m(d.bounds.x,d.bounds.x2,-1,1,e),r=m(d.bounds.y,d.bounds.y2,ie.compositionFlowAmpTop,ie.compositionFlowAmpBottom,o);return l(t+m(d.bounds.y,d.bounds.y2,ie.compositionFlowXOffsTop,ie.compositionFlowXOffsBottom,o))*r},go=(e,t)=>{t=t<=P?t:m(P,d.bounds.y2,P,d.bounds.y,t);let r=o(e*eo),l=o(t*oo),s=A.get(r,l);return pColor(s[0],s[1],s[2])},Co=(e,o)=>{let t=lo(bo(e*=ie.cloudTxXMult,o=o<=P?o:m(P,d.bounds.y2,P,d.bounds.y,o)),o);return t+(t>0&&t<.1?so(bo(e,o),o):0)+c(-ie.cloudEdgeFuzz,ie.cloudEdgeFuzz)},wo=(e,o)=>Co(e,o)>0,yo=(e,o)=>{o=m(w,y,0,ie.height,o);let t=m(-1,1,0,255,to(e*ie.heightNoiseXM,o));return m(0,255,-1,1,t)},xo=e=>e<=ie.waterNoiseCutoff,So=e=>{let[o,t]=e;if(t<=P)return[o,t,0,0,0];let r=-1*yo(bo(o,t),t),l=xo(r);if(l)return[o,t,0,0,0];let s=m(ie.waterNoiseCutoff,1,0,-ie.mtnMax,r),n=l?0:s;return[o,t+n,n,r,s]},Mo=e=>{let[o,r]=e,l=So(e),n=So([o+3*te,r]),a=((e,o)=>s(o[1]-e[1],o[0]-e[0]))(l,n);return[l,n,a,t((l[1]-n[1])/(l[0]-n[0]))]},ko=(r,l,s=!0)=>{let n,[a,i,u,p]=l,[b,g,C,w,y]=a,x=m(P,d.bounds.y2,ie.atmosLightness,ie.atmosDarkness,r[1]),S=m(-1,0,0,ie.fogAmount,w),M=m(-e,e,100,-100,u),k=r[1]<=P,B=((e,o)=>!!ie.isCloudy||wo(e,o))(r[0],r[1]),N=Co(r[0],r[1]),F=!k&&xo(w),A=!k&&!F,V=!1,R=!1,L=!1,z=!1,W=ao(r[0]*ie.cloudTxXMult,r[1])+c(-.25,.25),_=m(d.bounds.y,P,0,1,r[1]),q=m(P,d.bounds.y2,1,0,r[1]);if(k){let e=v(Y,r);if(e&&ie.crescentSun&&(e=!v(H,r)),B){if(n=ze.getFromNoiseValue(W),M=m(-1,1,ie.cloudShadow,ie.cloudLight,W),ie.isCloudy&&!wo(r[0],r[1])){let e=ze.getFromNoiseValue(io(r[0]*ie.cloudTxXMult,r[1])+c(-.25,.25));n=pColorCls.mixClrsRYB(e,fe,ie.cloudyLightMix*_)}ie.isSunset&&(M+=m(1,0,100,-80,_))}else n=pColorCls.mixClrsRYB(qe,Oe,_*ie.skyBottomColorSkyMix).spin(h(0,ie.skyWaterColorSpin)),M=0,ie.isNight&&f(ie.starChance)&&(L=!0,n=De);if(ie.hasSun)if(e&&s){let e=X(r,T),o=m(0,Y.radius,100,0,e);n=pColorCls.mixClrsRYB(De,Ee,o)}else{let e=X(r,T);if(e<d.bounds.w*ie.sunGlowSizeMult){let o=m(0,d.bounds.w/2,ie.sunProxMaxBrighten,0,e);n=N<.1?pColorCls.mixClrsRYB(n,fe,2*o):pColorCls.mixClrsRYB(n,Ge,o)}}x=m(d.bounds.y,P,.25*ie.atmosDarkness,ie.atmosLightness,r[1]),S=m(d.bounds.y,P,0,ie.fogAmount,r[1])}else if(F){if(n=go(r[0],r[1]),ie.hasSun&&!B){let e=ie.isCloudy?.25:m(P,d.bounds.y2,.8,.3,r[1]),o=m(P,d.bounds.y2,0,100,r[1]),t=r[0]+c(-o,o)*te;f(e)&&t>Y.x-Y.radius/2&&t<Y.x+Y.radius/2&&(z=!0,n=f(.33)?De:go(t,T[1]))}let e=Ye.oneOf(ie.skyWaterColorSpin);n=pColorCls.mixClrsRYB(n,e,q*ie.skyBottomColorWaterMix),M*=.5}else{let e=m(P,d.bounds.y2,2,.1,r[1]);n=0===ie.mtnColorMode?pe.getFromNoiseValue(uo(0,r[1])*e+c(-.1,.1)):pe.getFromNoiseValue(to(r[0],r[1])+c(-.1,.1))}if(ie.hasShore&&A&&w<=ie.waterNoiseCutoff+.06&&f()&&(n=fe,V=!0),ie.hasCliff&&A&&p>.9&&(n=We.oneOf(ie.colorVary)),ie.hasFlowers&&A&&p<ie.flowerSlope){if(ie.isSpring){let e=co(bo(r[0],r[1]),r[1])+c(-.1,.1);n=ve[t(o(e*ve.length))%ve.length].getFromNoiseValue(e)}else n=Le.oneOf(ie.colorVary);R=!0}let O=M*(k?1:m(P,d.bounds.y2,.1,ie.distMtnShadingMBot,r[1]))+x+S;return[me(n,O),n,O,A,F,k,B,V,R,L,z]},Bo=(t,r,l,s,n=0,a)=>{let i=m(5,15,20,50,ie.treeSizeMax),u=f(),d=c(.5,1.5),p=m(0,1,ie.treeSizeMin*d,ie.treeSizeMax*d,s)*te,g=l-p*c(1.5,2),C=V(r,g,p),w=o(m(0,1,8,i,s)),y=1===t?Re.oneOf(ie.colorVary):Ve.oneOf(ie.colorVary);ie.isSpring&&!ie.duoTone&&(y=b(ve).oneOf(ie.colorVary)),y=pColorCls.mixClrsRYB(y,a,ie.treeSourceTint);let x=g-p,S=g+p,M=me(ke.oneOf(ie.colorVary),n),k=m(0,1,1,2,s)*te,B=2*p;po(K(r,l-B,e/2,.1,B,je,B*c(0,.3),c(.1*e,e)).reverse(),M,k,.3);for(let o=0;o<w;o++){let o=W(C),l=me(y,m(x,S,ie.treeTopLightValue,ie.treeBottomLightValue,o[1])+h(-20,50)+n),a=m(0,1,.75,1.75,s)*te,i=m(0,1,2,4,s)*te,d=o[0],f=o[1]-i/2,b=u?0:e/2,g=c(.1,1);1===t&&(d=r-(i=m(x,S,te,p,o[1])*c(.5,1.5))/2,f=o[1],b=0,g=c(.1,.3)),po(K(d,f,b,g,i,je,.5*i,c(e,2*e)).reverse(),l,a,.4)}},No=o=>{let t,l=m(d.bounds.y,P,.1,1,o[1]),s=o[1]>P?m(P,d.bounds.y2,.1,1,o[1]):1,n=Mo(o),[a,i,h,p]=n,[g,C,w,y,x]=a,[S,M,k,B,N,F,A,T,V,R,v]=ko(o,n),L=mo(a[0],a[1]),Y=B?m(P,d.bounds.y2,ie.horizonYM,ie.bottomYM,o[1]):1,W=o[1]+L+w*Y,H=y>=ie.treeMinHeightValue;H&&y<=ie.treeMinHeightValue+.2&&(H=f());let _=ie.hasTrees&&B&&H&&!T&&p<ie.treeSlope&&f(ie.treeChance),q=no(bo(o[0],o[1]),o[1])+c(-.25,.25),O=m(P,d.bounds.y2,.1,ie.lowCloudForeM,o[1]),I=o[1]+L-ie.lowCloudHeight+m(0,1,10,-50,q)*te*O,D=!F&&q>0&&I<W&&ie.hasLowClouds,E=h,G=S,X=c(2,16)*te/ie.pointillismScale,$=c(3,6)*te/ie.pointillismScale*u(s,.25);if(F&&!A&&(E=Xe%2==0?0:e/2,t=.2),A&&!N&&!ie.isCloudy){let r=Co(o[0],o[1]);$*=m(0,1,1,2,r),X*=c(1,2),t=m(0,1,.1,.3,r),E=((o,t)=>t>P?0:m(-1,1,-e,e,Co(o,t)))(o[0],o[1])*c(.25,1)}if(N){if(X*=c(1,2),E=0,f(ie.waterWaveChance)){let e=((e,o)=>{let t=m(P,d.bounds.y2,-ie.waterRippleCenterX,-ie.waterRippleCenterX,o),l=m(P,d.bounds.y2,.3,.05,o),s=m(P,d.bounds.y2,.1,1,o)*te,n=r((e+t)*l);return[n*s,n]})(o[0],o[1])[1]*s;E=e*c(.25,.75),G=me(G,e<0?c(0,ie.waterWaveShadeStr)*s:c(-ie.waterWaveShadeStr,0)*s)}if(ie.hasWaterRipple){let e=ro(bo(o[0],o[1]),o[1])+c(-.1,.1),t=ie.waterRippleBracket;e<ie.waterNoiseCutoff&&e>ie.waterNoiseCutoff-t&&(G=me(G,80*u(s,.25)))}}let j=a[0],J=W+2*c(-te,te);if(f(.15)&&B){let t=W-o[1];W-t>=J&&(t*=2,po(K(o[0],W-t,e/2,ie.strokeAngVar,t,.05,t/c(6,10),c(.5*e,2*e)).reverse(),G,$*c(1,3),.1))}let Q=K(j,J,E,ie.strokeAngVar,X,je,.2*X,c(.1*e,2*e));if(N&&(Q=K(j,J,E,ie.strokeAngVar,X,je/2,X*c(.1,.4),.5*e)),R&&(Q=z(j,J,c(.1,.3)*te*l,4)),V&&f(ie.flowerCircleChance)&&(Q=z(j,J,c(.1,.2)*te*s,4)),v&&f(.2)&&(Q=z(j,J,c(.1,.3)*te*s,4)),po(Q,G,$,t),_){let e=m(P,d.bounds.y2,.1,1,o[1]),t=ie.treeType;2===t&&(t=b([0,1])),Bo(t,a[0],W,e,k,S)}if(D){X*=c(.5,1.5),E=m(-1,1,-e,e,q)*c(.1,.75);let o=me(Ie.getFromNoiseValue(q),m(0,1,-30,80,q));po(Q=K(j,I,E,ie.strokeAngVar,X,je,.2*X,c(.1*e,2*e)),o,$,.1)}Xe++};n.draw=()=>{if(0===fo){A.noStroke();let e=2*te,o=2*te;for(let{y:t}=d.bounds;t<=P;t+=e)for(let{x:r}=d.bounds;r<=d.bounds.x2;r+=o){let l=ko([r,t],Mo([r,t]),!1)[0];A.fill(l.c()),A.rect(r*eo,t*oo,o,e)}A.loadPixels(),n.noStroke();for(let e=0;e<2e3;e++){let e=O(d.bounds),[o]=ko(e,Mo(e)),t=ie.colorFullBg?o:e[1]<P?fe:he;n.fill(t.clone().setAlpha(1*c(.01,.1)).c());let r=z(e[0],e[1],c(10,200)*te,30);r=G(r=L(r,5*te,20*te),1),E(i,r,!0,!1,!0)}let t=d.bounds.w/50,r=(d.bounds.y2-P)/100;n.fill(he.clone().setAlpha(.75/r).c());for(let e=P;e<=d.bounds.y2;e+=r){let o=[],r=0;for(let{x:l}=d.bounds;l<=d.bounds.x2;l+=t){let t=[l,e],[s]=Mo(t);(r=t[1]+mo(s[0],s[1])+s[1]*m(P,d.bounds.y2,ie.horizonYM,ie.bottomYM,t[1]))>d.bounds.y2&&(r=d.bounds.y2),o.push([l,r])}o.push([d.bounds.x2,r]),(o=G(o=L(o,0,10*te),1)).push([d.bounds.x2,d.bounds.y2]),o.push([d.bounds.x,d.bounds.y2]),o.push(o[0]),E(i,o,!0,!1,!0)}fo=1}if(1===fo){let e=D?5:1;for(let o=0;o<e;o++){if(0===ie.drawStyle)for(let e=0;e<Ue;e++)No([h(d.bounds.x,d.bounds.x2),C+c(-ie.paintPointYOffsetMax,ie.paintPointYOffsetMax)]);else for(let{x:e}=d.bounds;e<d.bounds.x2;e+=Qe)No([e,C]);C+=Ke}C>y&&(fo=2)}else 2===fo?fo=3:3===fo&&Fo()};let Fo=()=>{let e=performance.now()-g;console.log(`Sketch done in ${e}ms`),n.noLoop(),R.render_done()};n.keyPressed=()=>{let e=n.key.toLowerCase();"s"===e?(({title:e,seed:o})=>{console.log(`saving as sketch-${e}-${o}.png`),n.save(`sketch-${e}-${o}.png`)})(ie):"p"===e&&($e?console.log("Resuming. Press 'p' to pause."):console.log("Pausing. Press 'p' to resume."),$e=!$e)}})),console.log("Press 's' to save the image."),console.log(`Copyright (c) ${(new Date).getFullYear()} by Matt Perkins (@nudoru). Contact - hello@mattperkins.me, https://mattperkins.me`),console.log("Licensed under CC BY-NC-SA 4.0")}))