Lively Kernel canvas
/*
b=new BuildCalendar();
allM = b.buildMonth(null, 2, pt(100,100));
allM = b.buildMonth(null, 3, pt(100,allM.last().getPosition().y+allM.last().getExtent().y + 5));
b=new BuildCalendar();
allM = b.buildMonth(null, 4, pt(100,allM.last().getPosition().y+allM.last().getExtent().y + 5));
allM.slice(14).invoke('remove');
allM.forEach(function(ea) { ea.moveBy(pt(100,0)) });
allM.forEach(function(ea) { ea.remove() });
allM.forEach(function(ea) { ea.setScale(0.8) });
// OOPSLA March 23, 2009
// Onward April 20, 2009
// Wikisym March 27, 2009
a=new HowMuchTime()
a.openInWorld()
a.start();
/////////////
dms = WorldMorph.current().submorphs.select(function(ea) { return ea instanceof DayMorph})
dms.forEach(function(ea) { ea.cross.submorphs.invoke('remove') })
dms[0].testIfTheDayHasCome()
*/
pointTo = function(morph, pos) {
var delta = pos.subPt(morph.getPosition());
morph.setRotation(delta.theta()+Math.PI/2);
}
scaleGradually = function(morph, scale, steps) {
var deltaS = scale - morph.getScale();
var scaleStep = deltaS/steps;
var stepTime = 10;
var actionWhenDone = function() { this.remove() };
var grow = function(remainingSteps) {
if (remainingSteps <= 0) return actionWhenDone.apply(morph);
morph.setScale(morph.getScale()+scaleStep);
Global.setTimeout(grow.curry(remainingSteps-1), stepTime);
}
Global.setTimeout(grow.curry(steps), stepTime);
}
bumm = function(morph) {
morph.remove();
var explosion = Morph.makeCircle(morph.getPosition(), 10, 0, null, Color.random());
explosion.openInWorld();
explosion.suppressHandles = true;
scaleGradually(explosion, getRandomNumber(20)+10, 10)
}
makeRocket = function(pos) {
var m = Morph.makeRectangle(new Rectangle(0,0,5,50));
var head = Morph.makePolygon([pt(0,-10), pt(-10,2), pt(10,2)], null, null, m.getFill());
head.moveBy(m.getExtent().scaleBy(0.5).withY(0));
m.addMorph(head);
m.setPosition(pos)
m.openInWorld();
return m;
}
getRandomNumber = function(max) { return Math.floor(Math.random()*max+1)-1};
getRandomPoint = function(maxX, maxY) { return pt(getRandomNumber(maxX), getRandomNumber(maxY)) };
getRandomPtFromRect = function(r) { return getRandomPoint(r.width, r.height).addPt(r.topLeft())}
w = WorldMorph.current();
createAndInitRocket = function() {
var width = w.getExtent().x*2/3;
var restWidth = w.getExtent().x - width;
var targetArea = pt(restWidth/2,0).extent(pt(width,300));
var start=getRandomPoint(5,5).addXY(w.getExtent().x/2, w.getExtent().y-100);
var x = makeRocket(start);
x.launch = function() {
var target = getRandomPtFromRect(targetArea);
pointTo(this, target);
var cb = function() {
this.stopStepping();
bumm(this);
};
this.animatedInterpolateTo(target, 10, 1, cb);
}
return x;
}
startLoop = function() {
Global.setTimeout(
function() {createAndInitRocket().launch(); startLoop() },
getRandomNumber(1000)+ 2000);
};
i=3
while(i>0) {
i--;
startLoop()
}5new Date(24*60*60*1000) - new Date(0)function(date) {
return new Date(date.valueOf() + this.day);
}function(monthName, monthNo, startPos) {
var pos = startPos;
var extent = DayMorph.prototype.initialExtent;
var margin = this.defaultMargin;
monthNo -= 1;
if (!this.morphs) this.morphs = [];
var date = new Date(2009, monthNo/*month-1*/, 1/*day*/, 0/*hour*/, 1/*minute*/);
do {
this.createDayMorph(date, pos);
pos = date.getDay() % 7 == 0 ? startPos.withY(pos.y + extent.y + margin) : pos.addXY(extent.x + margin, 0);
date = this.nextDay(date);
} while (date.getMonth() === monthNo);
return this.morphs;
}function(date, pos) {
var x = new DayMorph(date, pos);
this.morphs.push(x);
x.openInWorld();
x.start();
}pt(80, 40)function($super, date, optPos) {
if (!optPos) optPos = pt(100,100);
$super(optPos.extent(this.initialExtent));
this.dateMs = date.valueOf();
this.applyStyle({borderWidth: 0, fillOpacity: .5, fill: Color.veryLightGray});
this.buildDateText(date);
this.buildCrossMorph();
}function(date) {
var bnds = this.bounds().translatedBy(pt(0, this.getExtent().y/2+5));
var text = new TextMorph(bnds, date.toUTCString().slice(0,11));
text.beLabel();
text.setFontSize(10);
this.text = text;
this.addMorph(text);
}function() {
var length = this.getExtent().y/2;
var pos = pt(this.getExtent().x/2 - length/2, 4);
var cross = new BoxMorph(pos.extent(pt(length,length)));
cross.applyStyle({borderWidth: 2, fillOpacity: 0, borderColor: Color.black.lighter()});
this.cross = cross;
this.addMorph(cross);
}function() {
if (this.cross.hasSubmorphs()) return;
var b = this.cross.bounds().extent().extentAsRectangle();
var l1 = Morph.makePolygon([b.topLeft(), b.bottomRight()], 2, Color.black.lighter());
var l2 = Morph.makePolygon([b.topRight(), b.bottomLeft()], 2, Color.black.lighter());
this.cross.addMorph(l1);
this.cross.addMorph(l2);
}function() {
if (new Date(this.dateMs) > new Date()) return;
this.theDayHasCome();
}function() {
this.cross.withAllSubmorphsDo(function() {
this.applyStyle({borderColor: Color.red, strokeOpacity: 0.5});
});
}function() {
this.text.setTextColor(Color.red);
this.withAllSubmorphsDo(function(ea) {
this.applyStyle({borderColor: Color.red, strokeOpacity: 0.8});
});
this.startStepping(800, "blink");
}function() {
this.setBorderWidth(this.getBorderWidth() === 0 ? 3 : 0);
}function() {
this.startStepping(60 * 1000, "testIfTheDayHasCome");
}pt(80, 40)new Date(2009, 3, 14, 0, 1)function($super) {
$super(this.initialExtent.extentAsRectangle());
}function() {
this.startStepping(1000, "update");
}function() {
var now = new Date();
var ms=this.deadline - now;
var s = ms/1000;
var m = s/60;
var h = m/60;
var d = h/24;
var days = Math.floor(d);
var hours = Math.floor(h-days*24)
var min = Math.floor(m-days*24*60-hours*60)
var sec = Math.floor(s-days*24*60*60-hours*60*60-min*60)
// var s = Strings.format('Robert still has %s days, %s hours, %s minutes, and %s seconds before his deadline ends. Looooots of time!', days, hours, min, sec);
var s = 'It\'s done :-D';
this.setTextString(s);
}
null
Mon,02Feb
10
null
null
60000
0.005726500170984961
1233561660000
null
Tue,03Feb
10
null
null
60000
0.011452900425145502
1233648060000
null
Wed,04Feb
10
null
null
60000
0.01145290042514541
1233734460000
null
Thu,05Feb
10
null
null
60000
0.011452867109621975
1233820860000
null
Fri,06Feb
10
null
null
60000
0.011452883752430143
1233907260000
null
Sat,07Feb
10
null
null
60000
0.011452883782283598
1233993660000
null
Sun,08Feb
10
null
60000
0.011452867109622067
1234080060000
null
Mon,09Feb
10
null
null
60000
0.005726466855407692
1234166460000
null
Tue,10Feb
10
null
null
60000
0.005726450212599623
1234252860000
null
Wed,11Feb
10
null
60000
0.005726466855407692
1234339260000
null
Thu,12Feb
10
null
null
60000
0.011463174182575597
1234425660000
null
Fri,13Feb
10
null
60000
0.005726450242507018
1234512060000
null
Sat,14Feb
10
null
60000
0.005726450212599623
1234598460000
null
Sun,15Feb
10
null
60000
0.005726466855407692
1234684860000
null
Mon,16Feb
10
null
60000
0.005726450212599623
1234771260000
null
Tue,17Feb
10
null
null
60000
0.005726466855407692
1234857660000
null
Wed,18Feb
10
null
null
60000
0.011452867109621975
1234944060000
null
Thu,19Feb
10
null
null
60000
0.005726466885314989
1235030460000
null
Fri,20Feb
10
null
null
60000
0.005726450212599623
1235116860000
null
Sat,21Feb
10
null
null
60000
0.005726450212599526
1235203260000
null
Sun,22Feb
10
null
60000
0.005726466855407692
1235289660000
null
Mon,23Feb
10
null
null
60000
0.005726466885314989
1235376060000
null
Tue,24Feb
10
null
60000
0.005726450212599623
1235462460000
null
Wed,25Feb
10
null
null
60000
0.005726466855407692
1235548860000
null
Thu,26Feb
10
null
60000
0.005726450212599623
1235635260000
null
Fri,27Feb
10
null
null
60000
0.005726466855407692
1235721660000
null
Sat,28Feb
10
null
null
60000
0.005726450242506921
1235808060000
null
Sun,01Mar
10
null
null
60000
0.005726466855407692
1235894460000
null
Mon,02Mar
10
null
null
60000
0.005726450212599623
1235980860000
null
Tue,03Mar
10
null
null
60000
0.005726466855407692
1236067260000
null
Wed,04Mar
10
null
null
60000
0.005726483498269499
1236153660000
null
Thu,05Mar
10
null
60000
0.005726466855407692
1236240060000
null
Fri,06Mar
10
null
null
60000
0.005726450212599623
1236326460000
null
Sat,07Mar
10
null
null
60000
0.005726466885314989
1236412860000
null
Sun,08Mar
10
null
60000
0.005726450242506921
1236499260000
null
Mon,09Mar
10
null
60000
0.005736757285553247
1236585660000
null
Tue,10Mar
10
null
60000
0.005726450212599623
1236672060000
null
Wed,11Mar
10
null
60000
0.005726466885314989
1236758460000
null
Thu,12Mar
10
null
60000
0.005726450212599623
1236844860000
null
Fri,13Mar
10
null
null
60000
0.005726466855407692
1236931260000
null
Sat,14Mar
10
null
null
60000
0.005726450212599623
1237017660000
null
Sun,15Mar
10
null
60000
0.0057264668852612475
1237104060000
null
Mon,16Mar
10
null
null
60000
0.005726450212599623
1237190460000
null
Tue,17Mar
10
null
60000
0.005726466855407692
1237276860000
null
Wed,18Mar
10
null
null
60000
0.005726466885314989
1237363260000
null
Thu,19Mar
10
null
60000
3.33155772697839e-8
1237449660000
null
Fri,20Mar
10
null
null
60000
0.005726466855407692
1237536060000
null
Sat,21Mar
10
null
null
60000
0.005726450242506921
1237622460000
null
Sun,22Mar
10
null
60000
0.005726466855407692
1237708860000
null
Mon,23Mar
10
null
null
60000
0.005726450212599623
1237795260000
null
Tue,24Mar
10
null
60000
0.005726466855407692
1237881660000
null
Wed,25Mar
10
null
null
60000
0.005726466855407692
1237968060000
null
Thu,26Mar
10
null
60000
0.005726450242506921
1238054460000
null
Fri,27Mar
10
null
null
60000
0.005726466855407692
1238140860000
null
Sat,28Mar
10
null
null
60000
0.005726450242506921
1238227260000
null
Sun,29Mar
10
null
null
60000
0.005726466855407692
1238313660000
null
Mon,30Mar
10
null
null
60000
0.005726466855407692
1238400060000
null
Tue,31Mar
10
null
60000
0.005726450212599623
1238486460000
null
Wed,01Apr
10
null
null
60000
0.005726466855407692
1238569260000
null
Thu,02Apr
10
null
null
60000
0.005726450212599623
1238655660000
null
Fri,03Apr
10
null
null
60000
0.005736740672652475
1238742060000
null
Sat,04Apr
10
null
null
60000
0.005726466855407692
1238828460000
null
Sun,05Apr
10
null
null
60000
0.005726450212599623
1238914860000
null
Mon,06Apr
10
null
null
60000
0.005726466855407692
1239001260000
null
Tue,07Apr
10
null
60000
3.3315577269610395e-8
1239087660000
null
Wed,08Apr
10
null
null
60000
0.005726466855407692
1239174060000
null
Thu,09Apr
10
null
null
60000
0.005726450212599623
1239260460000
null
Fri,10Apr
10
null
null
60000
0.0057264502125458795
1239346860000
null
Sat,11Apr
10
null
null
60000
0.005726466885314989
1239433260000
null
Sun,12Apr
10
null
null
60000
0.005726450212599623
1239519660000
null
Mon,13Apr
10
null
null
60000
0.005726466885314989
1239606060000
null
Tue,14Apr
10
null
60000
0.005726450212599623
800
3.3376816617604583
1239692460000
null
Wed,15Apr
10
null
null
60000
0.005726466855407692
1239778860000
null
Thu,16Apr
10
null
null
60000
0.005726466855407692
1239865260000
null
Fri,17Apr
10
null
null
60000
0.005726466855407692
1239951660000
null
Sat,18Apr
10
null
null
60000
1.7355169921179214e-19
1240038060000
null
Sun,19Apr
10
null
null
60000
3.1187419105124216e-22
1240124460000
null
Mon,20Apr
10
null
null
60000
0
1240210860000
null
1000
43.976445262684294
Robertstillhas-4days,0hours,37minutes,and7secondsbeforehisdeadlineends.Lotsoftime!
null
94
false
null
null
null
1000
2.1899046567364393
Wikicontrol
true
null
1240003432393
164793
1
9
null
1240003432
null