Add snow_mouse_mode

This commit is contained in:
Oliver Blanthorn 2018-12-20 22:32:24 +00:00
parent 3a59fe79e4
commit 056d881851
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
4 changed files with 24 additions and 8 deletions

View file

@ -7,6 +7,7 @@
- `no_mouse_mode` added to help users force themselves to use hints by preventing mouse clicks from reaching the page.
- What, we have 1337 stars on GitHub? I hadn't noticed ; )
- `snow_mouse_mode` also added to help people get into the Christmas spirit
## Release 1.14.6 / 2018-12-14

2
package-lock.json generated
View file

@ -13767,7 +13767,7 @@
}
},
"web-ext-types": {
"version": "github:kelseasy/web-ext-types#f029d61a2a5baa619a29bdaed12586377bbb92d3",
"version": "github:kelseasy/web-ext-types#5f6e888318984c185413f8943d2616915e2af88f",
"from": "github:kelseasy/web-ext-types",
"dev": true
},

View file

@ -8,6 +8,17 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
export function jack_in() {
//chinese characters - taken from the unicode charset
const chinese = "田由甲申甴电甶男甸甹町画甼甽甾甿畀畁畂畃畄畅畆畇畈畉畊畋界畍畎畏畐畑".split(
"",
)
const colour = "#0F0" //green text
rain(chinese,colour)
}
export let snow = () => rain(["❄"],"#FFF",0.15)
export function rain(characters: string[], colour, darkening=0.05){
let d = document.createElement("div")
d.style.position = "fixed"
d.style.display = "block"
@ -28,10 +39,6 @@ export function jack_in() {
c.height = window.innerHeight
c.width = window.innerWidth
//chinese characters - taken from the unicode charset
let chinese = "田由甲申甴电甶男甸甹町画甼甽甾甿畀畁畂畃畄畅畆畇畈畉畊畋界畍畎畏畐畑".split(
"",
)
//converting the string into an array of single characters
let font_size = 10
@ -46,15 +53,15 @@ export function jack_in() {
function draw() {
//Black BG for the canvas
//translucent BG to show trail
ctx.fillStyle = "rgba(0, 0, 0, 0.05)"
ctx.fillStyle = "rgba(0, 0, 0, "+darkening+")"
ctx.fillRect(0, 0, c.width, c.height)
ctx.fillStyle = "#0F0" //green text
ctx.fillStyle = colour
ctx.font = font_size + "px arial"
//looping over drops
for (let i = 0; i < drops.length; i++) {
//a random chinese character to print
let text = chinese[Math.floor(Math.random() * chinese.length)]
let text = characters[Math.floor(Math.random() * characters.length)]
//x = i*font_size, y = value of drops[i]*font_size
ctx.fillText(text, i * font_size, drops[i] * font_size)

View file

@ -1203,6 +1203,14 @@ export function no_mouse_mode() {
toys.jack_in()
}
/**
* Christmas variant of [[no_mouse_mode]] (if you live in $DEFAULT hemisphere).
*/
//#content
export function snow_mouse_mode() {
toys.snow()
}
/** @hidden */
// Find clickable next-page/previous-page links whose text matches the supplied pattern,
// and return the last such link.