We show a animated draw of a four corners Sierpinski polygon. It generalizes the usual Sierspinki triangle of fractal theory.
var t=document.body.style;
t.border="0";
t.margin="0";
t.padding="0";
t.overflow="hidden";
t.outline="none";
t.backgroundColor="#000";
var c=document.getElementById("c");
t=window;
var w=t.innerWidth;
var h=t.innerHeight;
c.width=w;
c.height=h;
c=c.getContext("2d");
c.translate(w=Math.round(w/2.0),h=Math.round(h/2.0));
function R(ni,nf)
{
return (nf-=ni),(ni + (Math.floor(Math.random()*nf)%nf));
}
t=[[w,R(-h,h)],[R(-w,w),-h],[-w,R(-h,h)],[R(-w,w),h]];
var drawArc
=
(function()
{
var pi2=2.0*Math.PI,r=R(0,t.length);
var p=[t[r][0],t[r][1]];
return function()
{
c.beginPath();
c.fillStyle="rgb(" + R(0,256) + "," + R(0,256) + "," + R(0,256) + ")";
r=R(0,t.length);
p[0]=Math.round((p[0] + t[r][0])/2.0);
p[1]=Math.round((p[1] + t[r][1])/2.0);
c.arc(p[0],p[1],1,0,pi2,true);
c.fill();
};
})();
(function serpinski4()
{
for ( var i=0 ; i<100 ; ++i ) drawArc();
setTimeout(serpinski4,46);
})();
dmFyIHQ9ZG9jdW1lbnQuYm9keS5zdHlsZTsNCnQuYm9yZGVyPSIwIjsNCnQubWFyZ2luPSIwIjsNCnQucGFkZGluZz0iMCI7DQp0Lm92ZXJmbG93PSJoaWRkZW4iOw0KdC5vdXRsaW5lPSJub25lIjsNCnQuYmFja2dyb3VuZENvbG9yPSIjMDAwIjsNCnZhciBjPWRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJjIik7DQp0PXdpbmRvdzsNCnZhciB3PXQuaW5uZXJXaWR0aDsNCnZhciBoPXQuaW5uZXJIZWlnaHQ7DQpjLndpZHRoPXc7DQpjLmhlaWdodD1oOw0KYz1jLmdldENvbnRleHQoIjJkIik7DQpjLnRyYW5zbGF0ZSh3PU1hdGgucm91bmQody8yLjApLGg9TWF0aC5yb3VuZChoLzIuMCkpOw0KDQpmdW5jdGlvbiBS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