diff --git a/toys/facelight/app.js b/toys/facelight/app.js index 46befc9..873f63e 100644 --- a/toys/facelight/app.js +++ b/toys/facelight/app.js @@ -1,3 +1,5 @@ +const defaultTemp = 5500 + function colorTemperatureToRGB(kelvin) { // https://gist.github.com/paulkaplan/5184275 @@ -42,7 +44,7 @@ function changeTemp(e) { let tempOut = document.querySelector("#tempOut") let temp if (!e) { - temp = localStorage.temp || 5500 + temp = localStorage.temp || defaultTemp } else if (e.target) { temp = Number(e.target.value) } else { @@ -56,8 +58,26 @@ function changeTemp(e) { localStorage.temp = temp } +function keydownEvent(event) { + let temp = Number(localStorage.temp || defaultTemp) + switch (event.key) { + case "ArrowLeft": + case "ArrowDown": + event.preventDefault() + changeTemp(temp - 100) + break + case "ArrowRight": + case "ArrowUp": + event.preventDefault() + changeTemp(temp + 100) + break + } + console.log("new temp is", temp) +} + function init() { - document.querySelector("#temp").addEventListener("input", changeTemp) + document.querySelector("#temp").addEventListener("input", changeTemp) + document.addEventListener("keydown", keydownEvent) changeTemp() if (navigator.serviceWorker) { navigator.serviceWorker.register("sw.js") diff --git a/toys/index.md b/toys/index.md index e8169d7..400eeae 100644 --- a/toys/index.md +++ b/toys/index.md @@ -14,5 +14,6 @@ Maybe you'll just wonder why I spend so much time on this garbage. * [Grep Dict](grepdict/) runs `grep` on `/usr/share/dict/words`; perfect for cheating on crossword puzzles * If you need to write someone a letter but really don't want to, try my [social letter generator](letter.html) +* [Pocket Mastermind PDF](mastermind.pdf) ([PostScript Source](mastermind.ps)) * [Crunt](crunt.html) * [Serpeński Gasket on Tektronix Terminal](serpenski.html) which amazed 4 whole people at my high school in 1991. diff --git a/toys/mastermind.pdf b/toys/mastermind.pdf new file mode 100644 index 0000000..ebc6648 Binary files /dev/null and b/toys/mastermind.pdf differ diff --git a/toys/mastermind.ps b/toys/mastermind.ps new file mode 100644 index 0000000..d5462a0 --- /dev/null +++ b/toys/mastermind.ps @@ -0,0 +1,109 @@ +%!PS-Adobe-3.0 +%%Title: Pocket Mastermind +%%Creator: Neale Pickett +%%Orientation: Landscape +%%DocumentMedia: US-Letter 612 792 80 ( ) ( ) +%%EndComments + +/pagewidth currentpagedevice /PageSize get 0 get def +/pageheight currentpagedevice /PageSize get 1 get def +/r 10 def + +/pie { + 1 dict begin + /r exch def + + gsave + currentpoint translate + + 0 60 360 { + gsave + dup rotate + 120 mod 60 div + 0.4 mul 0.0 add setgray + + 0 0 moveto + 0 r lineto stroke + grestore + } for + + r 0 moveto + 0 0 r 0 360 arc + closepath stroke + + grestore + end +} def + +/grid { + 1 dict begin + /r exch def + + % Big plus + r 2 mul 0 rlineto + r -1 mul r -1 mul rmoveto + 0 r 2 mul rlineto + + r -1 mul r -2 mul rmoveto + 0 r 2 mul rlineto + r 2 mul 0 rlineto + 0 r -2 mul rlineto + r -2 mul 0 rlineto + stroke + end +} def + +/pierow { + 2 dict begin + /gridp exch def + /r exch def + gsave + currentpoint translate + 0 1 3 { + r 2.5 mul mul + 0 moveto + r pie + } for + + gridp { + 4 r 2.6 mul mul + 0 moveto + r 0.7 mul grid + } if + grestore + end +} def + +/board { + 10 dict begin + /r exch def + gsave + r false pierow + 0 r 2.0 mul rmoveto + 0 1 9 { + pop + 0 r 2.2 mul rmoveto + r true pierow + } for + grestore + end +} def + +0 1 1 { + pop + 1 2 3 { + 10 dict begin + gsave + pagewidth 2 div pageheight 2 div translate + 90 mul rotate + pageheight -2 div pagewidth -2 div translate + 50 30 translate + 0 1 3 { + pageheight 4 div mul 0 moveto + r board + } for + grestore + end + } for + showpage +} for