- Author:
- Felipe Alfonso
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- shin.cl
- Compo:
- classic
- Demo link:
- https://js1k.com/2013-spring/demo/1311
- Shortlink:
- https://js1k.com/1311
- Blog post:
- please update here!
- Bytes:
- 709
- Chars:
- 709
- Submission
var tc=document.createElement("canvas").getContext("2d");c.width=860,c.height=480;tc.canvas.width=43,tc.canvas.height=30;tc.fillText("SPRING",2,16);c.style.cursor="none";c.addEventListener("mousemove",function(e){var t=(e.pageX-c.offsetLeft)/20|0,n=(e.pageY-c.offsetTop)/20|0;a.webkitImageSmoothingEnabled=a.mozImageSmoothingEnabled=false;a.clearRect(0,0,860,480);a.save();a.scale(20,20);var r=Math.PI/180;a.fillStyle="rgba(0,0,0,.02)";var i=[];for(var s=0;s<360;s++){var o=0;while(o<=15){var u=Math.floor(t+Math.cos(s*r)*o),f=Math.floor(n+Math.sin(s*r)*o);if(tc.getImageData(u,f,1,1).data[3]>50)break;i.push({x:u,y:f});o++}}for(var l=0;l<i.length;l++){a.fillRect(i[l].x,i[l].y,1,1)}i=null;a.restore()},false)
- Description
- Reveal the secret word!
- Base64 encoded
dmFyIHRjPWRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImNhbnZhcyIpLmdldENvbnRleHQoIjJkIik7Yy53aWR0aD04NjAsYy5oZWlnaHQ9NDgwO3RjLmNhbnZhcy53aWR0aD00Myx0Yy5jYW52YXMuaGVpZ2h0PTMwO3RjLmZpbGxUZXh0KCJTUFJJTkciLDIsMTYpO2Muc3R5bGUuY3Vyc29yPSJub25lIjtjLmFkZEV2ZW50TGlzdGVuZXIoIm1vdXNlbW92ZSIsZnVuY3Rpb24oZSl7dmFyIHQ9KGUucGFnZVgtYy5vZmZzZXRMZWZ0KS8yMHwwLG49KGUucGFnZVktYy5vZmZzZXRUb3ApLzIwfDA7YS53ZWJraXRJbWFnZVNtb290aGluZ0VuYWJsZWQ9YS5tb3pJbWFnZVNtb290aGluZ0VuYWJsZWQ9ZmFsc2U7YS5jbGVhclJlY3QoMCwwLDg2MCw0ODApO2Euc2F2ZSgpO2Euc2NhbGUoMjAsMjApO3ZhciByPU1hdGguUEkvMTgwO2EuZmlsbFN0eWxlPSJyZ2JhKDAsMCwwLC4wMikiO3ZhciBpPVtdO2Zvcih2YXIgcz0wO3M8MzYwO3MrKyl7dmFyIG89MDt3aGlsZShvPD0xNSl7dmFyIHU9TWF0aC5mbG9vcih0K01hdGguY29zKHMqcikqbyksZj1NYXRoLmZsb29yKG4rTWF0aC5zaW4ocypyKSpvKTtpZih0Yy5nZXRJbWFnZURhdGEodSxmLDEsMSkuZGF0YVszXT41MClicmVhaztpLnB1c2goe3g6dSx5OmZ9KTtvKyt9fWZvcih2YXIgbD0wO2w8aS5sZW5ndGg7bCsrKXthLmZpbGxSZWN0KGlbbF0ueCxpW2xdLnksMSwxKX1pPW51bGw7YS5yZXN0b3JlKCl9LGZhbHNlKQ==
- Original source
/**
* @author Felipe Alfonso
* Just a simple ray casting demo
* 709 bytes the compressed version
* 1487 bytes the uncompressed version
* http://shin.cl/
*/
// Make a canvas.
var tc=document.createElement("canvas").getContext("2d");
// Set main canvas size.
c.width=860,c.height=480;
// Set created canvas size.
tc.canvas.width=43,tc.canvas.height=30;
// Write the secret word, not so secret now.
tc.fillText("SPRING",2,16);
// Hide cursor.
c.style.cursor="none";
// Mouse move event.
c.addEventListener("mousemove",function(e){
var mx = ((e.pageX-c.offsetLeft)/20)|0,my = ((e.pageY-c.offsetTop)/20)|0; // Scaled mouse coords.
a.webkitImageSmoothingEnabled = a.mozImageSmoothingEnabled = false; // Makeing it look all pixeling.
a.clearRect(0,0,860,480);a.save();a.scale(20,20); // Clears, saves and scale main canvas.
var r = Math.PI/180;a.fillStyle="rgba(0,0,0,.02)"; // rad to deg and set fillStyle.
var pix=[]; // pixel position.
for(var i=0;i<360;i++){ // 360°
var rd=0; //initial radius.
while(rd<=15){ // max radius.
var x=Math.floor((mx)+Math.cos(i*r)*(rd)), y=Math.floor((my)+Math.sin(i*r)*(rd)); // ray's x & y position.
if(tc.getImageData(x,y,1,1).data[3]>50) break; // check if alpha of current position is > 50
pix.push({x:x,y:y}); // push coords to pixels position array.
rd++;
}
}
for(var w=0;w < pix.length;w++){a.fillRect(pix[w].x,pix[w].y,1,1);} // draw all pixels.
pix = null; // nullit.
a.restore(); // restore main canvas.
},false);