- Author:
- Gavin Suntop
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- promofunk.com
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-xmas/demo/852
- Shortlink:
- https://js1k.com/852
- Blog post:
- please update here!
- Bytes:
- 969
- Chars:
- 969
- Submission
for($ in a)a[$[0]+($[6]||$[2])]=a[$];c.width=960;c.height=600;B=[];P=0;function AB(b,d){cl=["rgba(255,99,240,.8)","rgba(182,255,27,.8)","rgba(255,195,9,.8)","rgba(66,255,255,.8)"];B.push({x:b,y:d,c:cl[P]});P<3?P++:(P=0)}function DB(b){a.ba();a.ac(b.x,b.y,10,0,360,0);a.ac(b.x,b.y-12,6,0,360,0);a.ac(b.x,b.y-17,5,0,360,0);a.fillStyle=b.c;a.fl();a.ca()}function DC(b){r=b.length;if(r>1)for(i=1;i<r;i++){a.ba();a.strokeStyle="#555";a.ca();a.mv(B[i-1].x,B[i-1].y-22);B[i].x>B[i-1].x?(q=(B[i].x-B[i-1].x)/2+B[i-1].x):(q=(B[i-1].x-B[i].x)/2+B[i].x);a.qt(q,600,B[i].x,B[i].y-22);a.mv(B[i].x,B[i].y-22);a.ca();a.sr()}}function R(){a.fillStyle="#000";a.fc(0,0,960,600);DC(B);for(k=0;k<B.length;k++)DB(B[k])}function X(b){return b.layerX||b.offsetX}function Y(b){return b.layerY||b.offsetY}c.a=c.addEventListener;c.a("mousemove",function(b){L=B.length;if(L>1){B[L-1].x=X(b);B[L-1].y=Y(b)}},1);c.a("click",function(b){AB(X(b),Y(b));B.length<2&&AB(X(b),Y(b))},1);setInterval(R,33);
- Description
- XMASS Light Hanger!
String up the lights!
- Base64 encoded
Zm9yKCQgaW4gYSlhWyRbMF0rKCRbNl18fCRbMl0pXT1hWyRdO2Mud2lkdGg9OTYwO2MuaGVpZ2h0PTYwMDtCPVtdO1A9MDtmdW5jdGlvbiBBQihiLGQpe2NsPVsicmdiYSgyNTUsOTksMjQwLC44KSIs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qi5sZW5ndGg8MiYmQUIoWChiKSxZKGIpKX0sMSk7c2V0SW50ZXJ2YWwoUiwzMyk7
- Original source
//
// X-MASS by Gavin Suntop [ promofunk.com ]
// for Xmas1k [ http://js1k.com/2010-xmas/ ]
//
//assign shortcodes to context properties
for($ in a){
a[$[0]+($[6]||$[2])]=a[$]
}
//console.log(a)
c.width = 960
c.height = 600
B = [] // bulB
P = 0 // colorPosition
function AB(x,y) { // addBulb
cl = [ // colors
'rgba(255,99,240,.8)', // pink
'rgba(182,255,27,.8)', // green
'rgba(255,195,9,.8)', // orange
'rgba(66,255,255,.8)' // blue
]
B.push({x:x,y:y,c:cl[P]})
P < 3 ? P++ : P = 0 // 1 is cl length - 1
}
function DB(p) { // drawBulb
a.ba()
a.ac(p.x,p.y,10,0,360,0)
a.ac(p.x,p.y-12,6,0,360,0)
a.ac(p.x,p.y-17,5,0,360,0)
a.fillStyle = p.c
//a.shadowColor = '#fff'
//a.shadowBlur = 25
a.fl()
//a.shadowBlur = 0
a.ca()
}
function DC(p) { // drawCords
r = p.length
if(r > 1) {
for(i=1;i<r;i++) {
a.ba()
a.strokeStyle = '#555'
a.ca()
a.mv(B[i-1].x, B[i-1].y-22)
B[i].x > B[i-1].x ? q = (B[i].x - B[i-1].x)/2 + B[i-1].x : q = (B[i-1].x - B[i].x)/2 + B[i].x
a.qt(q,600,B[i].x,B[i].y-22)
a.mv(B[i].x, B[i].y-22)
a.ca()
a.sr()
}
}
}
function R() { // draw
a.fillStyle = "#000"
a.fc(0,0,960,600) // clear canvas
DC(B)
for (k=0;k < B.length; k++) {
DB(B[k])
}
}
function X(e) { return e.layerX || e.offsetX }
function Y(e) { return e.layerY || e.offsetY }
c.a = c.addEventListener
c.a('mousemove',function(e) {
L = B.length
if(L > 1) {
B[L-1].x = X(e)
B[L-1].y = Y(e)
}
},1)
c.a('click',function(e) {
AB(X(e), Y(e))
B.length < 2 ? AB(X(e), Y(e)) : 0
},1)
setInterval(R,33)