<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<input id="input" title="Mandala" placeholder="Mandala" type="number" />
<script src="/content/b6a50f5ba932b0ea7f652d9d28e59eced47bc6f8376c25e02d8b3457bb60ac8fi0"></script>
<script id="preview" mint="MINT_INSCRIPTION_ID">
const mintText = document.getElementById('preview').getAttribute('mint')
const block = 291566;
const num = block/100;
strokeW = 1;
let overlap, beziers, sym, layers, alph, strokeYN, ang, a1x, a1y, a2x, a2y, x1, x2, y1, y2, hSize, cush,randOverl;
let noPetals = 12;
const size_param = 600;
const initialize = (result) => {
if (result) {
console.log('Result:', result)
data = JSON.parse(result)
blockNumber = data.blk;
console.log('blk: '+ blockNumber);
}
newArt();
}
const initializeView = () => {
if (mintText.includes('MINT_INSCRIPTION_ID'))
{
let input = document.getElementById('input')
input.style.display = 'block'
input.style.position = 'absolute'
input.style.fontSize = '20px'
input.style.margin = '20px'
input.style.top = '0'
input.value = blockNumber;
input.addEventListener('input', (event) => {
blockNumber = input.value;
newArt();
});
newArt();
}
else {
const request = new XMLHttpRequest()
try {
request.open('GET', '/content/' + mintText)
request.responseType = 'text'
request.addEventListener('load', () => initialize(request.response))
request.addEventListener('error', () => console.error('XHR error'))
request.send()
} catch (error) {
console.error(`XHR error ${request.status}`)
}
newArt();
}
}
let blockNumber = 291566;
function setup(){let $=createCanvas(size_param,size_param);hSize=size_param/2,angleMode(DEGREES),translate(width/2,height/2),colorMode(HSB,256,100,100,100),initializeView()}
function newArt(){background(0);var $=blockNumber.toString(),_=$.substring(3,5);sym=noPetals;var t=$.substring(4,6);ang=360/(sym=t>25?25:t>7?t:8),cush=hSize/layers*.9,layers=_>3?_:(_=$.substring(2,4))>3?_:3,alph=76,beziers=140,!0==randOverl&&(overlap=round(random(1)));let e;e=1==strokeYN?"yes":"no",e="yes";let s;s=0==(overlap=1)?"less":"more";for(let n=0;n<layers;n++){if(x1=random(.75*hSize-n*cush,.85*hSize-n*cush),y1=0,x2=random(.9*hSize-n*cush,hSize-n*cush),y2=0,a1x=random(1.2*x1,.4*x2),a2x=random(.5*x2,.9*x2),0==overlap){a1y=a1x*tan(ang);a2y=random(20/n,a2x*tan(ang))}else(a1y=random(20/n,100-n*cush))<1&&(a1y=a1x*tan(ang)),(a2y=random(20/n,150-n*cush))<1&&(a2y=random(20/n,a2x*tan(ang)));let r=random(256),i=random(70,100),o=random(75,100);fill(r,i,o,alph);for(let l=0;l<sym/2;l++)1==strokeYN?(stroke(0),strokeWeight(strokeW)):noStroke(),0==beziers?(beginShape(),curveVertex(x1,0),curveVertex(x1,0),curveVertex(a1x,a1y),curveVertex(a2x,a2y),curveVertex(x2,0),curveVertex(x2,0),endShape(),beginShape(),curveVertex(x1,0),curveVertex(x1,0),curveVertex(a1x,-a1y),curveVertex(a2x,-a2y),curveVertex(x2,0),curveVertex(x2,0),endShape(),1==strokeYN&&(stroke(r,i,o,alph),line(x1,0,x2,0))):(bezier(x1,y1,a1x,a1y,a2x,a2y,x2,y2),bezier(x1,y1,a1x,-a1y,a2x,-a2y,x2,y2)),rotate(2*ang);rotate(ang)}}
</script>
</body>
</html>