A little Heart, lost in the dark, followed by weird things, is looking for an escape.
b.bgColor="#000";with(Math)Q=sqrt,A=abs,F=floor,P=pow,C=cos,S=sin,D=acos,R=round,Rd=random;L="♥",W=c.width=window.innerWidth,H=c.height=window.innerHeight,x=y=50,w=30,h=y,l=255,o=f=i=200,k=[],step=q=0,m=-w;while(m<W||q<H){k.push({x:m,y:q});m>W?(m=-w,q+=w*1.5):0;m+=h}j=q=130,s=function(){é();p=[];for(i=k.length;i--;){_=k[i],v=Q(A(P(x-_.x,2)+A(P(y-_.y,2)))),v<l+h&&v>w?p.push({d:v,x:_.x,y:_.y}):0}p.sort($);with(a){clearRect(0,0,W,H);for(i=p.length;i--;){save();_=p[i],r=D((y-_.y)/_.d),r*=x-_.x>0?-1:1,translate(_.x,_.y),rotate(r),g=-F(_.d-l),g=g>l?l:g<0?0:g;beginPath();lineWidth=w,lineCap="round",moveTo(0,0),lineTo(0,h),strokeStyle="rgba("+g+",0,0,1)",stroke();closePath();restore()}textAlign="center",font="42px a",fillStyle="red",fillText(L,x,y)}setTimeout(s,33)},$=function(a,b){return b.d-a.d},é=function(){j==q?q=R(Rd()*W/2):0,o==f?f=R(Rd()*H/2):0,j<q?j++:j--,o<f?o++:o--,i=step/30,step++,_=C(i)*j+W/2,v=S(i)*o+H/2,g=x-_,n=y-v,g!=0||n!=0?(g*=-1,n*=-1):0,x+=g,y+=n},s();
Yi5iZ0NvbG9yPSIjMDAwIjt3aXRoKE1hdGgpUT1zcXJ0LEE9YWJzLEY9Zmxvb3IsUD1wb3csQz1jb3MsUz1zaW4sRD1hY29zLFI9cm91bmQsUmQ9cmFuZG9tO0w9IuKZpSIsVz1jLndpZHRoPXdpbmRvdy5pbm5lcldpZHRoLEg9Yy5oZWlnaHQ9d2luZG93LmlubmVySGVpZ2h0LHg9eT01MCx3PTMwLGg9eSxsPTI1NSxvPWY9aT0yMDAsaz1bXSxzdGVwPXE9MCxtPS13O3doaWxlKG08V3x8cTxIKXtrLnB1c2goe3g6bSx5OnF9KTttPlc/KG09LXcscSs9dyoxLjUpOjA7bSs9aH1qPXE9MTMwLHM9ZnVuY3Rpb24oKXvDqSgpO3A9W107Zm9yKGk9ay5sZW5ndGg7aS0tOyl7Xz1rW2ldLHY9UShBKFAoeC1fLngsMikrQShQKHktXy55LDIpKSkpLHY8bCtoJiZ2Pnc/cC5wdXNoKHtkOnYseDpfLngseTpfLnl9KTowfXAuc29ydCgkKTt3aXRoKGEpe2NsZWFyUmVjdCgwLDAsVyxIKTtmb3IoaT1wLmxlbmd0aDtpLS07KXtzYXZlKCk7Xz1wW2ldLHI9RCgoeS1fLnkpL18uZCkscio9eC1fLng+MD8tMToxLHRyYW5zbGF0ZShfLngsXy55KSxyb3RhdGUociksZz0tRihfLmQtbCksZz1nPmw/bDpnPDA/MDpnO2JlZ2luUGF0aCgpO2xpbmVXaWR0aD13LGxpbmVDYXA9InJvdW5kIixtb3ZlVG8oMCwwKSxsaW5lVG8oMCxoKSxzdHJva2VTdHlsZT0icmdiYSgiK2crIiwwLDAsMSkiLHN0cm9rZSgpO2Nsb3NlUGF0aCgpO3Jlc3RvcmUoKX10ZXh0QWxpZ249ImNlbnRlciIsZm9udD0iNDJweCBhIixmaWxsU3R5bGU9InJlZCIsZmlsbFRleHQoTCx4LHkpfXNldFRpbWVvdXQocywzMyl9LCQ9ZnVuY3Rpb24oYSxiKXtyZXR1cm4gYi5kLWEuZH0sw6k9ZnVuY3Rpb24oKXtqPT1xP3E9UihSZCgpKlcvMik6MCxvPT1mP2Y9UihSZCgpKkgvMik6MCxqPHE/aisrOmotLSxvPGY/bysrOm8tLSxpPXN0ZXAvMzAsc3RlcCsrLF89QyhpKSpqK1cvMix2PVMoaSkqbytILzIsZz14LV8sbj15LXYsZyE9MHx8biE9MD8oZyo9LTEsbio9LTEpOjAseCs9Zyx5Kz1ufSxzKCk7
// inspired by a picwin ( mIRC ) contest i saw many years ago
// the contest was a 512b picwin snippet.
// source : http://scriptsdb.org/comments.php?id=1125
b.bgColor='#000';
var L="♥",
iWidth = c.width = window.innerWidth, // canvas width
iHeight=c.height=window.innerHeight, // canvas height
oPos = { x : 50, y : 50 }, // heart position
oSize = { w : 30, h : 50 }, // thing width and height
iLum = 255, // luminosity
aThings=[], // all things container
oCurrentEllipsis = { x: 130, y : 200},
oNextEllipsis = { x: 130, y : 200},
iStep=0;
// calc all things positions
var m = -oSize.w, q =0; // m and q are x and y pos for things
while(m<iWidth||q<iHeight)
{
aThings.push( { x : m, y : q } ); // add a thing
if (m>iWidth) { // if we are at the max right
m=-oSize.w; // return to left
q+=oSize.w*1.5; // next line
}
m+=oSize.h;
}
function process() {
// move the heart
fnMove();
// pick just visible things
var aVisible = [];
for(var i = aThings.length; i--; )
{
var oCurrent = aThings[i],
hypo = Math.sqrt(Math.abs(Math.pow(oPos.x-oCurrent.x,2)+Math.abs(Math.pow(oPos.y-oCurrent.y,2)))); // calc dist from thing to heart
if (hypo<iLum+oSize.h && hypo>oSize.w) { // if thing is not too far (255px+thingHeight) and not too close ( thig width )
aVisible.push({dist:hypo, x:oCurrent.x,y:oCurrent.y}); // set thing as visible
}
}
// sort thing by dist to have a "pretty" print
aVisible.sort(sortByDist);
with(a) { // use canvas
clearRect(0, 0, iWidth, iHeight); // clear canvas
for(i=aVisible.length;i--;){ // for all visible things
// save current canvas state to manipulate it
save();
var oVisible = aVisible[i],
radius = Math.acos((oPos.y-oVisible.y)/oVisible.dist); // calc horizontal radius between thing and heart
radius *= (oPos.x-oVisible.x>0) ? -1 : 1;
translate(oVisible.x,oVisible.y); // translate the canvas
rotate(radius); // rotate canvas
// calc luminosity for this thing
var iCurrentLum = -Math.floor(oVisible.dist-iLum);
if ( iCurrentLum > iLum ) { // avoid luminosity > 255
iCurrentLum = iLum;
} else if (iCurrentLum < 0 ) { // avoid luminosity < 0
iCurrentLum = 0;
}
// draw the thing
beginPath();
lineWidth=oSize.w;
lineCap='round';
moveTo(0,0);
lineTo(0,oSize.h);
strokeStyle='rgba('+iCurrentLum+',0,0,1)';
stroke();
closePath();
// restore state
restore();
}
//draw the heart
textAlign="center",
font="42px a",
fillStyle="red",
fillText(L,oPos.x,oPos.y);
}
//loop process
setTimeout(process, 33);
};
// function to sort thing by DESC dist
function sortByDist(a, b){
return b.dist-a.dist
};
// function which set new heart coord "randomly" around an elipse
function fnMove() {
// check if we are at the new coords
if (oCurrentEllipsis.x==oNextEllipsis.x) {
oNextEllipsis.x= Math.round(Math.random()*iWidth/2);
}
if ( oCurrentEllipsis.y==oNextEllipsis.y ) {
oNextEllipsis.y= Math.round(Math.random()*iHeight/2);
}
//set new dir.x
if ( oCurrentEllipsis.x < oNextEllipsis.x ) {
oCurrentEllipsis.x++;
} else {
oCurrentEllipsis.x--;
}
// set new dir.y
if ( oCurrentEllipsis.y<oNextEllipsis.y ) {
oCurrentEllipsis.y++;
} else {
oCurrentEllipsis.y--;
}
// we change the radius counting on steps
radius=iStep/30;
iStep++;
// the point where we are suppose to go next
var dir = {
x : Math.cos(radius)*oCurrentEllipsis.x+iWidth/2,
y : Math.sin(radius)*oCurrentEllipsis.y+iHeight/2
};
// check if we change direction
var oDiff = {
x : oPos.x-dir.x,
y : oPos.y-dir.y
};
if ( oDiff.x != 0 || oDiff.y !=0 ) {
oDiff.x*=-1;
oDiff.y*=-1;
}
oPos.x += oDiff.x;
oPos.y += oDiff.y;
};
process();