xxxxxxxxxx
62
// Triangles
let ww,wh, TSize, TCount, ori, cp
function setup() {
// noLoop()
noStroke()
angleMode(DEGREES)
ww=windowWidth
wh=windowHeight
if (ww>wh){
createCanvas(wh, wh)
TSize=wh*0.02
TCount=wh/TSize
cp=wh/2
ori='wh'
} else {
createCanvas(ww, ww)
TSize=ww*0.02
TCount=ww/TSize
cp=ww/2
ori='ww'
}
print ('ww',ww, 'wh',wh, 'TSize',TSize, 'TCount', TCount, 'ori',ori, 'cp',cp)
}
let ro = -1
function draw() {
background(0)
fill('white')
push()
translate(cp,cp)
doTri()
pop()
ro+=0.5
push()
translate(cp,cp)
rotate(ro)
doTri()
pop()
}
function doTri(){
beginShape()
for(let y=0;y<TCount;y++){
let yPoz=y*TSize
for(let x=0;x<TCount;x++){
vertex(TSize*x - cp, yPoz+TSize - cp)
vertex(TSize/2+(TSize*x)- cp, yPoz - cp)
vertex(TSize+(TSize*x)- cp, yPoz+TSize - cp)
} // end x loop
vertex(TSize/2- cp,yPoz+TSize - cp) // set to start of next line
vertex(0- cp, yPoz+TSize - cp)
} // end y loop
endShape(CLOSE)
}