forked from cory/tildefriends
All of the changes that have been sitting on tildepi for ages. For posterity.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3530 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
34
packages/cory/blink/blink.js
Normal file
34
packages/cory/blink/blink.js
Normal file
@ -0,0 +1,34 @@
|
||||
//! {"require": ["libiframe"]}
|
||||
|
||||
// Server-side blink! Woo!
|
||||
|
||||
require("libiframe").iframe({
|
||||
source: `
|
||||
document.body.style.color = '#fff';
|
||||
document.body.style.backgroundColor = '#000';
|
||||
var canvas = document.createElement("canvas");
|
||||
document.body.append(canvas);
|
||||
canvas.width = 640;
|
||||
canvas.height = 480;
|
||||
var context = canvas.getContext("2d");
|
||||
rpc.export({
|
||||
setFillStyle: function(style) { context.fillStyle = style; },
|
||||
fillRect: context.fillRect.bind(context),
|
||||
fillText: context.fillText.bind(context),
|
||||
});`,
|
||||
style: `
|
||||
border: 0;
|
||||
`}).then(draw).catch(terminal.print);
|
||||
|
||||
var blink = true;
|
||||
|
||||
function draw(iframe) {
|
||||
iframe.setFillStyle('#222');
|
||||
iframe.fillRect(0, 0, 640, 480);
|
||||
if (blink) {
|
||||
iframe.setFillStyle('#fff');
|
||||
iframe.fillText("Hello, world!", 50, 50);
|
||||
}
|
||||
blink = !blink;
|
||||
setTimeout(function() { draw(iframe); }, 500);
|
||||
}
|
Reference in New Issue
Block a user