- Author:
- Guillaume Bort
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- guillaume.bort.fr
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-first/demo/538
- Shortlink:
- https://js1k.com/538
- Blog post:
- please update here!
- Bytes:
- 1024
- Chars:
- 1024
- Submission
c=document.getElementById('c');g=[];c.width=c.height=500;d=c.getContext('2d');h=20;w=40;m=10;z=100;v=50;k=10;_=.9375;a=Math.ceil;e=function(a,b,c){d[c?'moveTo':'lineTo'](a,b)};u=function(t,b,c,n){p=2.75;q=p*p;return n?c*(t/=v)*t*t+b:((t/=v)<(1/p)?c*(q*t*t)+b:(t<(2/p)?c*(q*(t-=(1.5/p))*t+p-2)+b:(t<(2.5/p)?c*(q*(t-=(2.25/p))*t+_)+b:c*(q*(t-=1)*t+_)+b)))};$=function(){d.clearRect(0,0,500,500);for(j=0;j<9;j++){for(i=0;i<9;i++){x=i*w+((9-j)*h)-(i*h)+45;y=j*m+z+(i*m);try{l=g[i][j];if(l++){y=l<v?u(l,y,-v,1):u(l-v,y-v,v);g[i][j]=l==z?0:l}}catch(e){}d.beginPath();e(x+h,y+h,1);e(x+h,y+z);e(x+w,y+k,1);e(x+w,y+90);e(x+h,y+z);e(x,y+90);e(x,y+k);d.fillStyle='rgba(100,'+a(255-16*i)+','+a(255-16*j)+',.9)';d.fill();d.stroke();d.beginPath();e(x,y+k,1);e(x+h,y);e(x+w,y+k);e(x+h,y+h);e(x,y+k);d.fillStyle='rgba(35,'+a(190-16*i)+','+a(190-16*j)+',.9)';d.fill();d.stroke()}}};c.onmousemove=function(e){r=e.clientX-8;s=e.clientY-8;o=a((r+2*s-485)/w);p=a((r-2*s-85)/-w)-2;if(!g[o])g[o]=[];if(!g[o][p])g[o][p]=h};setInterval($,k)//~gbort~
- Description
- Colored isometric 3d objects that bounce on mouse over.
- Base64 encoded
Yz1kb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnYycpO2c9W107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JztkLmZpbGwoKTtkLnN0cm9rZSgpfX19O2Mub25tb3VzZW1vdmU9ZnVuY3Rpb24oZSl7cj1lLmNsaWVudFgtODtzPWUuY2xpZW50WS04O289YSgocisyKnMtNDg1KS93KTtwPWEoKHItMipzLTg1KS8tdyktMjtpZighZ1tvXSlnW29dPVtdO2lmKCFnW29dW3BdKWdbb11bcF09aH07c2V0SW50ZXJ2YWwoJCxrKS8vfmdib3J0fg==
- Original source
var c = document.getElementById('c')
var grid = []
c.width = 500; c.height = 500
var ctx = c.getContext('2d')
var easeInCubic= function (x, t, b, c, d) {
return c*(t/=d)*t*t + b
}
var easeOutBounce= function (x, t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b
}
}
var draw = function() {
ctx.clearRect(0,0,500,500)
for(var j=0; j<9; j++) {
for(var i=0; i<9; i++) {
var x = i*40+((9-j)*20)-(i*20), y = j*10 + 100 + (i*10)
if(grid[i] && grid[i][j]) {
t = grid[i][j]
if(t<50) {
t++
y = easeInCubic(0, t, y, -50, 50)
} else if(t<100) {
t++
y = easeOutBounce(0, t-50, y-50, 50, 50)
}
if(t==100) {
grid[i][j]=0
} else {
grid[i][j]=t
}
}
ctx.beginPath()
ctx.moveTo(x + 20, y + 20)
ctx.lineTo(x + 20, y + 100)
ctx.moveTo(x + 40, y + 10)
ctx.lineTo(x + 40, y + 90)
ctx.lineTo(x + 20, y + 100)
ctx.lineTo(x, y + 90)
ctx.lineTo(x, y + 10)
ctx.fillStyle = 'rgba(100,' + Math.floor(255-16.5*i) + ',' + Math.floor(255-16.5*j) + ',.9)'
ctx.fill()
ctx.stroke()
ctx.closePath()
ctx.beginPath()
ctx.moveTo(x, y + 10)
ctx.lineTo(x + 20, y)
ctx.lineTo(x + 40, y + 10)
ctx.lineTo(x + 20, y + 20)
ctx.lineTo(x, y + 10)
ctx.fillStyle = 'rgba(35,' + (Math.floor(255-16.5*i)-65) + ',' + (Math.floor(255-16.5*j)-65) + ',.9)'
ctx.fill()
ctx.stroke()
ctx.closePath()
}
}
}
c.onmousemove = function(e) {
xmap = Math.ceil((e.offsetX + 2 * (e.offsetY || e.layerX) - 240 - 200) / 40)
ymap = Math.ceil((e.offsetX - 2 * (e.offsetY || e.layerY) - 240 + 200) / -40) - 2
if(!grid[xmap]) {
grid[xmap] = []
}
if(!grid[xmap][ymap]) {
grid[xmap][ymap] = 20
}
}
// Run!
setInterval(draw, 10)