0x316042d3…fbe8sent to0x99a9b7c1…b069·#16,475,947·view on Etherscan
function roundPatch(e,n=v_rel(.5,.5),t){let a=[];return a=getEllipse(e*R.random(.8,1.2)*threadSize,e*R.random(.8,1.2)*threadSize,45),a.forEach(e=>e.mult(R.random(.8,2))),a.forEach(e=>e.add(n)),a=toCrv(a),makePatch(a,t)}function rectPatch(e,n){const t=R.random(100,700),a=R.random(100,700),i=new SquarePatternShape(e.x-t/2,e.y-a/2,t,a);return i.fillet(R.random(50)),i.rotate(R.random(-15,15)),ps=i.ps,makePatch(ps,n)}function makePatch(e,n){const t=new LayoutPattern2(e),a=new Denim(t,n,0).rotate(R.random(360)).calc();a.warpExtensions=[5,20],a.extendChance=R.random(.2,.4),applyPatchShadow(a);const i=patchStitches(a).filter(e=>R.random_dec()>globalAge),o=R.random_dec()<.3;return{denim:a,stitches:i,fringe:o}}function applyPatchShadow(e){innerPattern=new LayoutPattern2(e.lp.getOffset(-3*globalScale)),innerPattern.ps.forEach(e=>e.add(5*globalScale,5*globalScale)),innerPattern.toCrv();const n=createGraphics(width,height);n.background(255),n.noStroke(),n.fill(0),n.beginShape(),innerPattern.crv().forEach(e=>n.vertex(e.x,e.y)),n.endShape(),n.filter(BLUR,10*globalScale),e.weft.forEach(e=>{e.forEach(e=>{if(e.ps.length>0){const t=e.ps[0],a=n.get(t.x,t.y);brightness(a)<360&&(e.darkness=brightness(a)/1500)}})})}function applyPatch3dEffect(e,n){innerPattern=new LayoutPattern2(e.lp.getOffset(0)),innerPattern.ps.forEach(e=>e.add(5,5)),innerPattern.toCrv();const t=createGraphics(width,height);t.background(0),t.noStroke(),t.fill(255,20),innerPattern.crv().forEach(e=>t.circle(e.x,e.y,R.random(50))),innerPattern.crv().forEach(e=>t.circle(e.x,e.y,R.random(30))),innerPattern.crv().forEach(e=>t.circle(e.x,e.y,R.random(10))),n.weft.forEach(e=>{e.forEach(e=>{if(e.ps.length>0){const n=e.ps[0],a=t.get(n.x,n.y);brightness(a)<360&&(e.age=brightness(a)/1500)}})})}function patchStitches(e,n){threadSize=initialThreadSize;let t=[];const a=n||R.random_choice([1,2,3]);if(1==a)t=crossStitches(e.lp);else if(2==a){if(t=e.lp.stitches(6,5,5,!0),R.random_dec()<.5&&(t=t.concat(e.lp.stitches(7,5,5,!0))),R.random_dec()<.4)for(let n=1;n<R.random(3);n++)t=t.concat(e.lp.stitches(6+R.random(5,40),5,5,!0))}else 3==a&&(t=e.lp.stitches(-6,5,5,!0),R.random_dec()<.5&&(t=t.concat(e.lp.stitches(-7,5,5,!0))),R.random_dec()<.7&&(t=t.concat(e.lp.stitches(-3,5,5,!0))));return t}async function drawStitches(e){for(const n of e){const e=n.slice(0,2),t=vsub(e[1],e[0]).rotate(-90).setMag(5*globalScale),a=toCrv(e).map(e=>e.mult(globalScale));for(const e of a)await burn(vsub(e,t),12*globalScale,4);for(const e of a)await dodge(vadd(e,t),12*globalScale,4);await new Loop(n.slice(0,2),n[2]?n[2]:patchStitchColor,1.3*initialThreadSize).wiggle().shadow().draw(),await timeout(0)}}function crossStitches(e){let n=e.stitches(1,R.random(5,15),R.random(5,10),!0).map(e=>{const n=round(R.random(1,2)),t=vdist(e[0],e[1]),a=vsub(e[1],e[0]),i=a.copy().rotate(90),o=[];for(let r=1;r<t;r+=t/n){const n=vsub(e[0],i.setMag(10)),t=vadd(n,a.setMag(r+.5)),d=vadd(t,i.setMag(30));o.push([t,d])}return o}).flat();return n}async function simple(){denim=new Denim(fullPattern,denimColor).rotate(R.random(360)),denim.calc().makeRips(),background(BG),await denim.draw({colorFunc:dyePattern1}),await denim.finishDraw()}async function patches(){denim=new Denim(fullPattern,denimColor).rotate(R.random(360)),denim.ripThreshold=.1,denim.calc().makeRips(),background(BG),await denim.draw({colorFunc:dyePattern1}),R.reset(100);const e=R.random_dec()<.3?1:R.random(3),n=[];for(let t=0;t<e;t++){const e=R.random()<.5?v_rel(.5,.5):v_rel(R.random(.2,.8),R.random(.2,.8));R.random_dec()<.5?n.push(roundPatch(baseWidth*R.random(.1,.25),e,denimColor)):n.push(rectPatch(e,denimColor))}for(let e=0;e<n.length;e++)denim.ripExtendMasks.push(n[e].denim);threadSize=1.5*initialThreadSize;for(let e=0;e<n.length;e++)await n[e].denim.draw({dontFringe:1-n[e].fringe}),await drawStitches(n[e].stitches),await n[e].denim.finishDraw();await denim.finishDraw()}async function singleHole(){denim_bg=new Denim(fullPattern,denimColor).rotate(R.random(360)),denim_bg.visibleWhite=1,denim_bg.darkness=.7,denim_bg.calc(),background(BG),await denim_bg.draw({dontFringe:!0}),R.reset(100),denim=new Denim(fullPattern,denimColor).rotate(R.random(360));const e=R.random(2,4)-3*globalAge;denim.pointInRip=(n=>{const t=e*n.dist(v_rel(.5,.5))/baseHeight;return noise(ripNoiseScale[0]*n.x/baseWidth,ripNoiseScale[1]*n.y/baseHeight,denim.ripNoiseZ)>t}),R.random()<.5&&(denim.ripMin=0,denim.ripMax=0),denim.calc().makeRips(),R.reset(100);const n=R.random(5);if(denim.warpRips.forEach(e=>e.len*=R.random(.2)*n),await denim.draw({colorFunc:dyePattern1}),await denim.finishDraw(),R.reset(100),R.random()<.3){const e=findCurve(denim.weftRips.map(e=>e.pos)),n=[];for(let t=0;t<e.length-1;t++){const a=e[t],i=e[t+1],o=vsub(i,a).rotate(-90).setMag(R.random(20,150)),r=vadd(a,i).mult(.5).add(o);n.push([a,r]),n.push([r,i])}let t=[];for(let e=0;e<n.length;e++){const a=n[e][0],i=n[e][1],o=vdist(a,i),r=vsub(i,a);for(let e=0;e<o;e+=25){const n=vadd(a,r.copy().setMag(e)),i=vadd(a,r.copy().setMag(e+15));t.push([n,i,color(0)])}}t=filter(e=>R.random_dec()>globalAge),await drawStitches(t)}}function findCurve(e){const n=v_rel(.5,.5),t=[];for(let a=0;a<360;a+=10){const i=e.reduce((e,t)=>abs(getAngle(e,n)-a)<abs(getAngle(t,n)-a)?e:t);t.push(i)}return t.push(t[0]),t}function getAngle(e,n){return(vsub(e,n).heading()+360)%360}async function mending(){denim=new Denim(fullPattern,denimColor).rotate(R.random(360));const e=R.random()<.5;let n;const t=R.random()<.5?v_rel(.5,.5):v_rel(R.random(.2,.8),R.random(.2,.8));n=R.random_dec()<.5?roundPatch(baseWidth*R.random(.1,.25),t,denimColor):rectPatch(t,denimColor),n.stitches=patchStitches(n.denim,3);const a=R.random()<.3;stitches=[];const i=R.random_choice([1,2,3]);let o=R.random_choice([color(255,0,0),color(0),color(255)]);const r=n.denim.lp.bounds(),d=1==i?15:0,s=R.random(),c=R.random(),m=R.random()<.8?0:R.random()<.8?1:2;for(let e=r.left-100;e<r.right+100;e+=R.random(20,30)){1==m&&(o=R.random_choice([color(255,0,0),color(0),color(255)]));for(let n=r.top-R.random(100);n<r.bottom+R.random(100);n+=R.random(20,30)){2==m&&(o=R.random_choice([color(255,0,0),color(0),color(255)]));const t=R.random(20,30);let a=!0,i=!0;R.random()<s&&(R.random()<c?a=!1:i=!1),R.random()>globalAge&&(a&&stitches.push([v(e+d,n),v(e-d,n+t),o]),i&&stitches.push([v(e+t/2,n+t/2+d),v(e-t/2,n+t/2-d),o])),n+=t}e+=R.random(30,40)}stitches=stitches.filter(e=>R.random_dec()>globalAge),denim.ripThreshold=R.random(.1),denim.calc().makeRips(),stitches=stitches.filter(e=>denim.hasWeftOn(e[0])&&denim.hasWeftOn(e[1])||n.denim.hasWeftOn(e[0])&&n.denim.hasWeftOn(e[1])),denim.ripExtendMasks.push(n.denim),applyPatch3dEffect(n.denim,denim),background(BG),await denim.draw({dontFringe:!e,colorFunc:dyePattern1}),threadSize=1.5*initialThreadSize,await n.denim.draw({dontFringe:n.fringe}),a&&await drawStitches(n.stitches),await n.denim.finishDraw(),await drawStitches(stitches),await denim.finishDraw()}async function largeRips(){denim=new Denim(fullPattern,neighborColor(denimColor,0,0,-150)).rotate(R.random(360)),denim.visibleWhite=1,denim.darkness=.3,denim.calc(),denim2=new Denim(fullPattern,denimColor).rotate(R.random(360)),ripNoiseScale=[R.random(4,8),R.random(4,8)],denim2.ripThreshold=R.random(.3,.5),denim2.ripMax*=R.random(2),denim2.calc().makeRips(),denim2.dropShadowOn([denim]),background(BG),await denim.draw({dontFringe:!0}),await denim2.draw({colorFunc:dyePattern1}),await denim2.finishDraw()}async function fringeComp(){withFringe=!0,await withDivide()}async function withDivide(){const e=!!withFringe||R.random()<.5;flipped=R.random()<.5,pos1=R.random_choice(["left","right","top","bottom"]),pos2=R.random()<.15&&R.random_choice(["left","right","top","bottom"]),pos2&&R.random()<.5&&("left"==pos1?pos2="right":"right"==pos1?pos2="left":"top"==pos1?pos2="bottom":"bottom"==pos1&&(pos2="top")),denim_bg=new Denim(fullPattern,denimColor).rotate(R.random(360)).calc(),denim_top1=divideTopDenim(pos1),denim_bg.ripExtendMasks.push(denim_top1),pos2&&(denim_top2=divideTopDenim(pos2),denim_top1.ripExtendMasks.push(denim_top2),denim_bg.ripExtendMasks.push(denim_top2)),background(BG),await denim_bg.draw({dontFringe:!0,colorFunc:dyePattern1}),await denim_bg.finishDraw(),await denim_top1.draw({dontFringe:!e}),await denim_top1.finishDraw(),pos2&&(await denim_top2.draw({dontFringe:!e,colorFunc:dyePattern2}),await denim_top2.finishDraw())}function divideTopDenim(e){let n,t;["left","right"].includes(e)?(n=v(.2*-baseWidth,baseHeight*R.random(.25,.75)),t=v(1.2*baseWidth,baseHeight*R.random(.25,.75))):(n=v(baseWidth*R.random(.25,.75),.2*-baseHeight),t=v(baseWidth*R.random(.25,.75),1.2*baseHeight));const a=[n,t];let i,o;"left"==e?(i=v(.2*-baseWidth,.2*-baseHeight),o=v(1.2*baseWidth,.2*-baseHeight)):"right"==e?(a.reverse(),i=v(1.2*baseWidth,1.2*baseHeight),o=v(.2*-baseWidth,1.2*baseHeight)):"top"==e?(a.reverse(),i=v(.2*-baseWidth,1.2*baseHeight),o=v(.2*-baseWidth,.2*-baseHeight)):(i=v(1.2*baseWidth,.2*-baseHeight),o=v(1.2*baseWidth,1.2*baseHeight));const r=[i,...a,o];return pattern_top=new LayoutPattern2(r).fillet(80),newDenim=new Denim(pattern_top,denimColor).rotate(R.random(-360)),flipped&&(newDenim.visibleWhite=1),newDenim.age=.2,newDenim.ripThreshold=R.random(.1,.45),withFringe||newDenim.lp.prepareFoldedStitchings(),newDenim.calc().makeRips(),newDenim.dropShadowOn([denim_bg]),withFringe?(newDenim.warpExtensions=[R.random(120,250),R.random(250,540)],newDenim.extendChance=R.random(.7,1)):newDenim.foldedStitchings(),newDenim}function initFeatures(){composition=R.random_choice([withDivide,patches,largeRips,simple,mending,singleHole,fringeComp]),getBaseColor(),dyePattern1=getColorFunc(),dyePattern2=R.random()<.5?dyePattern1:getColorFunc()}function setup(){initFeatures(),noiseSeed(R.random_int(2e4)),1.4*windowWidth>windowHeight?canvas=createCanvas(windowHeight/1.4,windowHeight):canvas=createCanvas(windowWidth,1.4*windowWidth),globalScale=width/baseWidth,initialThreadSize=R.random(1.3,2),threadSize=initialThreadSize,dyePattern1=initColorFunc(dyePattern1),dyePattern2=initColorFunc(dyePattern2),initBaseColor(),ripNoiseScale=[R.random(5,10),R.random(5,10)],angleMode(DEGREES),noLoop(),noStroke(),noFill();const e=new Date,n=e.getFullYear()-2023,t=n+e.getMonth()/12;globalAge=constrain(t/10,0,1),fullPattern=new SquarePatternShape(0,0,baseWidth,baseHeight),makeImage()}async function makeImage(){background(BG),fill(255),textSize(10),textAlign(CENTER,CENTER),text("Loading Jenim",width/2,height/2),noFill(),await timeout(30),await composition(),print("done")}let withFringe=!1;const warpColors=natural;let stitchColor;const BG="#666",baseWidth=1e3,baseHeight=1.4*baseWidth;let globalScale;