June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,32 @@
10 gosub 1500: rem setup clock digit strings
20 ti$ = "123456"
25 rem do some other stuff after this line
30 print x: x=x+1
40 for i=0 to 500: next
50 gosub 1000: rem display the time
60 goto 30
70 end
1000 t$ = ti$
1010 for i=1 to 6
1020 t(i) = val(mid$(t$,i,1))
1030 next
1040 print chr$(19);
1050 for j=1 to 5
1055 print tab(19);
1060 for i=1 to 6
1070 k=t(i)*3+1
1080 print mid$(z$(j),k,3);
1090 rem if j<5 then print" ";: goto 1130
1100 if i=2 then print" ";
1110 if i=4 then print" ";
1130 next
1140 print
1150 next
1160 return
1500 dim z$(5)
1510 z$(1) = "UCI I UCICCIB BCCCUCIUCIUCI"
1520 z$(2) = "B B B B BB BB B B BB B"
1530 z$(3) = "B B B UCK CBJCBJCIBCIBCIJCB"
1540 z$(4) = "B B B B B B BB BB B B"
1550 z$(5) = "JCKCCCJCCCCK BCCKJCKJCK CK"
1560 return

View file

@ -1,69 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
canvas {
background-color: black;
}
</style>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.querySelector("canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.addEventListener("click", function () {
colorIndex = (colorIndex + 1) % colors.length;
});
var g = canvas.getContext("2d");
var colors = [
{ on: "#00FF00", off: "#002200" },
{ on: "#FF0000", off: "#220000" },
{ on: "#0000FF", off: "#000033" }
];
// which leds are on or off for each digit
var masks = ["1110111", "0010010", "1011101", "1011011", "0111010",
"1101011", "1101111", "1010010", "1111111", "1111011"];
// 0, 0 is upper left; these relative units are multiplied by the size value later
var startingPoints = [
[0, 0], [0, 0], [8, 0], [0, 8], [0, 8], [8, 8], [0, 16]
];
var isHorizontal = [1, 0, 0, 1, 0, 0, 1]; // bool
// horizontal and vertical layouts in scalable units
var vertices = [
[
// horizontal
[0, 0], [1, 1], [7, 1], [8, 0], [7, -1], [1, -1]
],
[
// vertical
[0, 0], [-1, 1], [-1, 7], [0, 8], [1, 7], [1, 1]
]
];
// pixel values, to create small gaps between the elements (leds)
var offsets = [
[0, -1], [-1, 0], [1, 0], [0, 1], [-1, 2], [1, 2], [0, 3]
]
function Led(x, y, idx, ox, oy) {
// starting points in scalable units
this.x = x;
this.y = y;
var onColor, offColor, colorIndex = 0;
// horizontal or vertical layout
this.idx = idx;
function drawDigitalClock(x, y, size) {
// pixel values to create small gaps between the leds
this.offset_x = ox;
this.offset_y = oy;
}
onColor = colors[colorIndex].on;
offColor = colors[colorIndex].off;
var leds = [];
leds.push(new Led(0, 0, 0, 0, -1));
leds.push(new Led(0, 0, 1, -1, 0));
leds.push(new Led(8, 0, 1, 1, 0));
leds.push(new Led(0, 8, 0, 0, 1));
leds.push(new Led(0, 8, 1, -1, 2));
leds.push(new Led(8, 8, 1, 1, 2));
leds.push(new Led(0, 16, 0, 0, 3));
var onColor, offColor;
function drawDigitalClock(color1, color2, size) {
var clockWidth = (6 * 15 + 2 * 10) * size;
var clockHeight = 20 * size;
var x = (canvas.width - clockWidth) / 2;
var y = (canvas.height - clockHeight) / 2;
onColor = color1;
offColor = color2;
g.clearRect(0, 0, canvas.width, canvas.height);
@ -83,8 +83,8 @@
var digit1 = Math.floor(timeUnit / 10);
var digit2 = timeUnit % 10;
x = drawElements(x, y, size, masks[digit1]);
x = drawElements(x, y, size, masks[digit2]);
x = drawLeds(x, y, size, masks[digit1]);
x = drawLeds(x, y, size, masks[digit2]);
return x;
}
@ -98,23 +98,22 @@
return x + size * 10;
}
function drawElements(x, y, size, mask) {
function drawLeds(x, y, size, mask) {
startingPoints.forEach(function (point, i) {
leds.forEach(function (led, i) {
g.fillStyle = mask[i] == '1' ? onColor : offColor;
var xx = x + point[0] * size + offsets[i][0];
var yy = y + point[1] * size + offsets[i][1];
var idx = isHorizontal[i] ? 0 : 1;
var xx = x + led.x * size + led.offset_x;
var yy = y + led.y * size + led.offset_y;
drawElement(xx, yy, size, vertices[idx]);
drawLed(xx, yy, size, vertices[led.idx]);
});
return x + size * 15;
}
function drawElement(x, y, size, vertices) {
function drawLed(x, y, size, vertices) {
g.beginPath();
g.moveTo(x, y);
@ -127,9 +126,8 @@
g.fill();
}
setInterval(drawDigitalClock, 1000, 140, 200, 12);
setInterval(drawDigitalClock, 1000, "#00FF00", "#002200", 12);
</script>
</body>
</html>

View file

@ -1,9 +1,11 @@
// cargo-deps: time="0.1"
extern crate time;
use std::thread;
static TOP: &'static str = " ⡎⢉⢵ ⠀⢺⠀ ⠊⠉⡱ ⠊⣉⡱ ⢀⠔⡇ ⣏⣉⡉ ⣎⣉⡁ ⠊⢉⠝ ⢎⣉⡱ ⡎⠉⢱ ⠀⠶⠀";
static BOT: &'static str = " ⢗⣁⡸ ⢀⣸⣀ ⣔⣉⣀ ⢄⣀⡸ ⠉⠉⡏ ⢄⣀⡸ ⢇⣀⡸ ⢰⠁⠀ ⢇⣀⡸ ⢈⣉⡹ ⠀⠶⠀";
use std::thread;
use std::time::Duration;
const TOP: &str = " ⡎⢉⢵ ⠀⢺⠀ ⠊⠉⡱ ⠊⣉⡱ ⢀⠔⡇ ⣏⣉⡉ ⣎⣉⡁ ⠊⢉⠝ ⢎⣉⡱ ⡎⠉⢱ ⠀⠶⠀";
const BOT: &str = " ⢗⣁⡸ ⢀⣸⣀ ⣔⣉⣀ ⢄⣀⡸ ⠉⠉⡏ ⢄⣀⡸ ⢇⣀⡸ ⢰⠁⠀ ⢇⣀⡸ ⢈⣉⡹ ⠀⠶⠀";
fn main() {
let top: Vec<&str> = TOP.split_whitespace().collect();
@ -18,7 +20,7 @@ fn main() {
println!("{}", top_str);
println!("{}", bot_str);
thread::sleep(std::time::Duration::from_secs(1));
thread::sleep(Duration::from_secs(1));
}
}