1 /* Copyright 2011 The Dominion of Awesome
2 * See COPYING for licensing information */
6 style: "background-color: black",
10 {name: "phosphorColor", label: "Phosphor Color", kind: "ListSelector", items: [
11 {caption: "green", value: '#00FF00'},
12 {caption: "blue", value: '#3030FF'},
13 {caption: "red", value: '#FF2020'},
14 {caption: "magenta", value: '#FF20FF'},
15 {caption: "cyan", value: '#00FFFF'},
16 {caption: "yellow", value: '#FFFF00'},
17 {caption: "amber", value: '#9F9F00'}
19 {name: "displayStyle", label: "Style", kind: "ListSelector", items: [
20 {caption: "tiled", value: 0},
21 {caption: "centered", value: 1}
24 phosphorColor: '#00FF00',
28 {name: "display", nodeTag: "canvas"}
34 rendered: function() {
35 this.display = this.$.display.hasNode();
36 this.ctx = this.display.getContext('2d');
38 this.intermediate = document.createElement('canvas');
39 this.intermediate.width = 512;
40 this.intermediate.height = 512;
41 this.ictx = this.intermediate.getContext('2d');
42 this.ictx.fillStyle = 'black';
43 this.ictx.fillRect(0, 0, 255, 255);
44 this.ictx.fillStyle = 'rgba(0,0,0,0.075)';
45 this.ictx.strokeStyle = this.phosphorColor;
47 this.resize(window.innerWidth, window.innerHeight);
51 resize: function(w, h) {
52 if (this.displayStyle == 0) {
53 this.display.width = this.w = w;
54 this.display.height = this.h = h;
58 preferencesChanged: function() {
59 this.ictx.strokeStyle = this.phosphorColor;
60 if (this.displayStyle == 0) {
61 this.display.width = this.w;
62 this.display.height = this.h;
64 this.display.width = 512;
65 this.display.height = 512;
70 this.ictx.fillRect(0, 0, 512, 512);
71 this.ictx.beginPath();
72 for (var x = 0; x < 512; x++) {
74 this.ictx.moveTo(x, y);
75 this.ictx.lineTo(x+1, y+1);
78 this.t = (this.t + 1) % 512;
80 if (this.displayStyle == 0) {
81 for (var x = 0; x < this.w; x += 512) {
82 for (var y = 0; y < this.h; y += 512) {
83 this.ctx.drawImage(this.intermediate, 0, 0, 512, 512, x, y, 512, 512);
87 this.ctx.drawImage(this.intermediate, 0, 0);
92 if (this.timer) return;
93 this.timer = setInterval(this.draw.bind(this), 20);
97 clearInterval(this.timer);