- Author:
- Cheeseum
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- classic
- Demo link:
- https://js1k.com/2013-spring/demo/1438
- Shortlink:
- https://js1k.com/1438
- Blog post:
- please update here!
- Bytes:
- 960
- Chars:
- 960
- Submission
r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(f){window.setTimeout(f,1E3/60)};var e=-0.5,g=4,h=0.005,k=0,m=100,n=50,p=0,q=0;colorIntv=1;phase=0;window.onload=function(){b.style.margin;c.style.backgroundColor="#222";s();t();c.focus()};window.onresize=s;function s(){c.width=window.innerWidth;c.height=window.innerHeight;p=c.width/2;q=c.height/2}
function t(){a.save();a.setTransform(1,0,0,1,0,0);a.clearRect(0,0,c.width,c.height);a.restore();a.lineWidth=1;for(var f=150*Math.sin(e)+50,d=-Math.PI;d<Math.PI;d+=0.05){var l=f*Math.sin(g*d)+f*Math.cos(g*d),u=5+5*Math.sin(f*d);a.strokeStyle="hsl("+k+","+m+"%,"+n+"%)";k+=colorIntv;if(255<k||0>k)colorIntv*=-1;a.beginPath();a.arc(l*Math.cos(d+phase)+p,l*Math.sin(d+phase)+q,u,0,2*Math.PI);a.stroke()}g+=h;if(6<g||3>g)h*=-1;e=e>2*Math.PI?0:e+0.005;phase=phase>2*Math.PI?0:phase+0.01;r(t)};
- Description
- A colorful, blooming, polar (as in graph) flower.
- Base64 encoded
cj13aW5kb3cucmVxdWVzdEFuaW1hdGlvbkZyYW1lfHx3aW5kb3cud2Via2l0UmVxdWVzdEFuaW1hdGlvbkZyYW1lfHx3aW5kb3cubW96UmVxdWVzdEFuaW1hdGlvbkZyYW1lfHx3aW5kb3cub1JlcXVlc3RBbmltYXRpb25GcmFtZXx8d2luZG93Lm1zUmVxdWVzdEFuaW1hdGlvbkZyYW1lfHxmdW5jdGlvbihmKXt3aW5kb3cuc2V0VGltZW91dCh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window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) {
window.setTimeout(callback, 1000 / 60);
};
})();
var ampt = -0.5, k = 4,
akIntv = 0.005,
color = { h: 0, s: 100, l: 50 },
offsetX = 0,
offsetY = 0;
colorIntv = 1,
phase = 0;
window.onload = function () {
b.style.margin
c.style.backgroundColor = "#222";
setDimensions();
drawLoop(c);
c.focus();
}
window.onresize = setDimensions;
function setDimensions () {
c.width = window.innerWidth;
c.height = window.innerHeight;
offsetX = c.width/2;
offsetY = c.height/2;
}
function drawLoop () {
// clear out the screen first
a.save();
a.setTransform(1, 0, 0, 1, 0, 0);
a.clearRect(0, 0, c.width, c.height);
a.restore();
// draw the flower
a.lineWidth = 1;
var amp = 150 * Math.sin(ampt) + 50;
for (var theta=-Math.PI; theta<Math.PI; theta+=0.05) {
var r = amp * Math.sin(k * (theta)) + amp * Math.cos(k * (theta));
var rad = 5 + Math.sin(amp * theta) * 5;
a.strokeStyle = 'hsl('+color.h+','+color.s+'%,'+color.l+'%'+')';
color.h += colorIntv;
if (color.h > 255 || color.h < 0)
colorIntv *= -1;
a.beginPath();
a.arc(r * Math.cos(theta + phase) + offsetX, r * Math.sin(theta + phase) + offsetY, rad, 0, 2*Math.PI);
a.stroke();
}
// increment and cycle variables if necessary
k += akIntv;
if (k > 6 || k < 3)
akIntv *= -1;
ampt = ampt > 2*Math.PI ? 0 : ampt + 0.005;
phase = phase > 2*Math.PI ? 0 : phase + 0.01;
// queue up for the next cycle
// closure compiler doesn't obfuscate this right so I just change it manually
r(drawLoop);
}