- Author:
- Sean Seefried
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- classic
- Demo link:
- https://js1k.com/2012-love/demo/1182
- Shortlink:
- https://js1k.com/1182
- Blog post:
- please update here!
- Bytes:
- 992
- Chars:
- 976
- Submission
W=(w=c.width=400)/2;H=(h=c.height=360)/2;M=Math;F=!1;J=10;eval("@t(w,f){#@(x,y){#f(m(x,w*2)-w,m(y,w*2)-w);}}@m(x,m){#(x%m+m)%m}@q(f){#@(x,y){S=(y>0?1:-1);X=x*x;Y=y*y;d=X+Y-S*M.pow(X*Y*y*S,1/3);e=1/(1-M.pow(d,.01));p=M.atan(y/x);x<0?p+=M.PI:F;#(d<1)?f(e*M.cos(p),e*M.sin(p)):F}}@s(s,f){#@(x,y){#f(x*s,y*s)}}@P(i,j,f){#@(x,y){#f(x+i,y+j)}}O=1;Z=1;n=o=0;onkeydown=onkeypress=@(e){z=e.which;K=J*Z;z==37?n+=K:z==38?o-=K:z==39?n-=K:z==40?o+=K:z==46||z==62?(Z=1,o=n=0,O?(g.push(f),f=t(h/36,s(16,f)),O=!O):(g.push(f),A++,f=s(3/h,q(f)),O=!O)):z==44||z==60?(Z=1,o=n=0,O&&A>=0?(A--,f=g.pop(),O=F):!O&&A>=-1?(f=g.pop(),O=1):F):z==45?Z*=1.1:z==61||z==43?Z*=.9:F;R(s(Z,P(n,o,f)))};A=-1;@R(f){i=0;I=a.createImageData(w,h);v=I.data;for (j=0;j<h-40;j++)for(x=-W;x<W;x++,i+=4)f(x,H-j)?(v[i]=H,v[i+3]=255):F;a.putImageData(I,0,0);a.font='19pt a';a.fillText('Press:+-←↑↓→<> I♥U'+(A>=0?' ℵ'+A:'')+(O?'':'╳∞'),0,h-J);}g=[];f=s(3/h,q(t));R(f)".replace(/@/g,"function ").replace(/#/g,"return "));
- Description
- No description submitted
- Base64 encoded
Vz0odz1jLndpZHRoPTQwMCkvMjtIPShoPWMuaGVpZ2h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zczorLeKGkOKGkeKGk+KGkjw+ICAgICBJ4pmlVScrKEE+PTA/JyDihLUnK0E6JycpKyhPPycnOifilbPiiJ4nKSwwLGgtSik7fWc9W107Zj1zKDMvaCxxKHQpKTtSKGYpIi5yZXBsYWNlKC9AL2csImZ1bmN0aW9uICIpLnJlcGxhY2UoLyMvZywicmV0dXJuICIpKTs=
- Original source
W=(w=c.width=400)/2;
H=(h=c.height=360)/2;
M=Math;
F=!1; //shorter False
J=10;
eval(
"@tile(w,f){\
#@(x,y){\
#f(mod(x,w*2)-w,mod(y,w*2)-w);}\
}\
\
/* The correct (mathematical) mod function */
@mod(x,m){\
#(x%m+m)%m\
}\
\
/* heartMap takes another 'functional image' and maps it onto a heart shape\
// Used (X^2 + Y^2 - 1)^3 - X^2*Y^3 = 0\
// and rearranged it.\
// See http://mathworld.wolfram.com/HeartCurve.html */\
@heartMap(f){\
#@(x,y){\
sgn=(y>0?1:-1);\
X=x*x;Y=y*y;\
/* d == 1 precisely when (X^2 + Y^2 - 1)^3 - X^2*Y^3 = 0 */\
d=X+Y-sgn*M.pow(X*Y*y*sgn,1/3);\
/* Points closer to edge of heart (i.e. close to d == 1), get projected out\
// very far into the infinite plane*/\
e=1/(1-M.pow(d,.01));\
theta=M.atan(y/x);\
x<0?theta+=M.PI:F;\
#(d<1)?f(e*M.cos(theta),e*M.sin(theta)):F\
}\
}\
\
@scale(s,f){\
#@(x,y){\
#f(x*s,y*s)\
}\
}\
\
@pan(i,j,f){\
#@(x,y){\
#f(x+i,y+j)\
}\
}\
isOneHeart=1;\
zoom=1;\
xPan=yPan=0;\
onkeydown=onkeypress=@(e){\
z=e.which;\
K=J*zoom;\
z==37?xPan+=K:\
z==38?yPan-=K:\
z==39?xPan-=K:\
z==40?yPan+=K:\
z==46||z==62?\
(zoom=1,yPan=xPan=0,isOneHeart?(g.push(f),f=tile(h/36,scale(16,f)),isOneHeart=!isOneHeart):\
(g.push(f),aleph++,f=scale(3/h,heartMap(f)),isOneHeart=!isOneHeart)):\
z==44||z==60?\
(zoom=1,yPan=xPan=0,isOneHeart&&aleph>=0?(aleph--,f=g.pop(),isOneHeart=F):\
!isOneHeart&&aleph>=-1?(f=g.pop(),isOneHeart=1):F):\
z==45?zoom*=1.1:\
z==61||z==43?zoom*=.9:F;\
render(scale(zoom,pan(xPan,yPan,f)))\
};\
\
aleph=-1;\
\
@render(f){\
i=0;\
I=a.createImageData(w,h);\
pixBuf=I.data;\
for (j=0;j<h-40;j++)\
for(x=-W;x<W;x++,i+=4)\
f(x,H-j)?(pixBuf[i]=H,pixBuf[i+3]=255):F;\
a.putImageData(I,0,0);\
\
a.font='19pt a';\
a.fillText('Press:+-←↑↓→<> I♥U'+(aleph>=0?' ℵ'+aleph:'')+\
(isOneHeart?'':'╳∞'),0,h-J);\
}\
g=[];\
f=scale(3/h,heartMap(tile));/*putting 'tile' here is the biggest hack!\
// A function value is a truth value!*/\
render(f)".replace(/@/g,"function ").replace(/#/g,"return "));