- Author:
- Peter Braden
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- peterbraden.co.uk
- Compo:
- classic
- Demo link:
- https://js1k.com/2012-love/demo/1010
- Shortlink:
- https://js1k.com/1010
- Blog post:
- please update here!
- Bytes:
- 1012
- Chars:
- 1012
- Submission
var x=y=0,
p1 = -2.25, p2 = 0.75,
q1 = -1.5, q2 = 1.5,
w = c.width, h=c.height
wd = (p2-p1)/h,
ht = (q2-q1)/w,
mc = 100
var mcol = function(x, y){
var p = x * wd + p1,
q= y * ht +q1,
prev_i = prev_r = 0;
for (var n =0; n < 255; n++){
var r = prev_r * prev_r - prev_i * prev_i +p
var i = 2 * prev_r * prev_i +q;
if ((r*r + i*i) < mc){
prev_r = r
prev_i = i
}
else{
return n
}
}
return n;
}
a.fillStyle = "#555";
a.fillRect (0, 0, c.width, c.height);
a.strokeStyle = "#000";
var l = function(){
for (var chunk=0; chunk <500; chunk++){
a.fillStyle = "hsl(20,100%,"+ (mcol(x,y))%100 + "%)";
a.fillRect (y,c.height-x,1,1);//a.fillRect (x,c.height-y,1,1);
if (x >=c.height){
continue;
}
if (y >= c.width){
x+=1;
y=0;
continue;
}
y++;
}
}
var q = setInterval(l, 2);
- Description
- Mandelbrot Heart
- Base64 encoded
dmFyIHg9eT0wLCANCiAgcDEgPSAtMi4yNSwgcDIgPSAwLjc1LA0KICBxMSA9IC0xLjUsIHEyID0gMS41LA0KICB3ID0gYy53aWR0aCwgaD1jLmhlaWdodA0KICB3ZCA9IChwMi1wMSkvaCwNCiAgaHQgPSAocTItcTEpL3csDQogIG1jID0gMTAwDQoNCnZhciBtY29sID0gZnVuY3Rpb24oeCwgeSl7DQoJdmFyIHAgPSB4ICogd2QgKyBwMSwNCiAgICAgICAgICBxPSB5ICogaHQgK3ExLA0KICAJCXByZXZfaSA9IHByZXZfciA9IDA7DQogIAkJDQogICAgICBmb3IgKHZhciBuID0wOyBuIDwgMjU1OyBuKyspeyAgIAkJDQogICAgICAJCXZhciByID0gcHJldl9yICogcHJldl9yIC0gcHJldl9pICogcHJldl9pICtwDQogICAgICAJCXZhciBpID0gMiAqIHByZXZfciAqIHByZXZfaSArcTsNCiAgICAgIAkJaWYgKChyKnIgKyBpKmkpIDwgbWMpew0KCQkJCXByZXZfciA9IHINCgkJCQlwcmV2X2kgPSBpDQoJCQl9CQ0KICAgICAgCQllbHNlew0KCQkJCXJldHVybiBuDQoJCQl9CQ0KICAgICAgfQ0KCXJldHVybiBuOw0KfQ0KDQphLmZpbGxTdHlsZSA9ICIjNTU1IjsNCmEuZmlsbFJlY3QgKDAsIDAsIGMud2lkdGgsIGMuaGVpZ2h0KTsNCmEuc3Ryb2tlU3R5bGUgPSAiIzAwMCI7DQoNCnZhciBsID0gZnVuY3Rpb24oKXsNCiAgIGZvciAodmFyIGNodW5rPTA7IGNodW5rIDw1MDA7IGNodW5rKyspew0KICAJICAgYS5maWxsU3R5bGUgPSAiaHNsKDIwLDEwMCUsIisgKG1jb2woeCx5KSklMTAwICsgIiUpIjsNCiAgCSAgIGEuZmlsbFJlY3QgKHksYy5oZWlnaHQteCwxLDEpOy8vYS5maWxsUmVjdCAoeCxjLmhlaWdodC15LDEsMSk7DQogIAkgICBpZiAoeCA+PWMuaGVpZ2h0KXsNCiAgCSAgICAgICBjb250aW51ZTsNCiAgCSAgIH0NCiAgCSAgIGlmICh5ID49IGMud2lkdGgpew0KICAJICAgICAgIHgrPTE7DQogIAkgICAgICAgeT0wOw0KICAJICAgICAgIGNvbnRpbnVlOw0KICAJICAgfSAgDQogIAkgICB5Kys7DQogICAgICB9IAkgICAgIA0KfQ0KDQp2YXIgcSA9IHNldEludGVydmFsKGwsIDIpOw==
- Original source
var x=y=0,
p1 = -2.25, p2 = 0.75,
q1 = -1.5, q2 = 1.5,
w = c.width, h=c.height
wd = (p2-p1)/h,
ht = (q2-q1)/w,
mc = 100
var mcol = function(x, y){
var p = x * wd + p1,
q= y * ht +q1,
prev_i = prev_r = 0;
for (var n =0; n < 255; n++){
var r = prev_r * prev_r - prev_i * prev_i +p
var i = 2 * prev_r * prev_i +q;
if ((r*r + i*i) < mc){
prev_r = r
prev_i = i
}
else{
return n
}
}
return n;
}
a.fillStyle = "#555";
a.fillRect (0, 0, c.width, c.height);
a.strokeStyle = "#000";
var l = function(){
for (var chunk=0; chunk <500; chunk++){
a.fillStyle = "hsl(20,100%,"+ (mcol(x,y))%100 + "%)";
a.fillRect (y,c.height-x,1,1);//a.fillRect (x,c.height-y,1,1);
if (x >=c.height){
continue;
}
if (y >= c.width){
x+=1;
y=0;
continue;
}
y++;
}
}
var q = setInterval(l, 2);