mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.6 KiB
75 lines
1.6 KiB
4 years ago
|
<template>
|
||
|
<div class="body">
|
||
3 years ago
|
<canvas />
|
||
4 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
3 years ago
|
name: 'Screensaver',
|
||
3 years ago
|
mounted() {
|
||
4 years ago
|
// Initialising the canvas
|
||
3 years ago
|
const canvas = this.$el.querySelector('canvas')
|
||
|
const ctx = canvas.getContext('2d')
|
||
4 years ago
|
|
||
3 years ago
|
// Setting the width and height of the canvas
|
||
|
canvas.width = window.innerWidth
|
||
|
canvas.height = window.innerHeight
|
||
4 years ago
|
|
||
3 years ago
|
// Setting up the letters
|
||
|
let letters = 'ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ'
|
||
|
letters = letters.split('')
|
||
4 years ago
|
|
||
3 years ago
|
// Setting up the columns
|
||
|
const fontSize = 10
|
||
|
const columns = canvas.width / fontSize
|
||
4 years ago
|
|
||
3 years ago
|
// Setting up the drops
|
||
|
const drops = []
|
||
|
for (let i = 0; i < columns; i++) {
|
||
|
drops[i] = 1
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
// Setting up the draw function
|
||
3 years ago
|
function draw() {
|
||
3 years ago
|
ctx.fillStyle = 'rgba(0, 0, 0, .1)'
|
||
|
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
||
|
for (let i = 0; i < drops.length; i++) {
|
||
|
const text = letters[Math.floor(Math.random() * letters.length)]
|
||
|
ctx.fillStyle = '#0f0'
|
||
|
ctx.fillText(text, i * fontSize, drops[i] * fontSize)
|
||
|
drops[i]++
|
||
|
if (drops[i] * fontSize > canvas.height && Math.random() > 0.95) {
|
||
|
drops[i] = 0
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
// Loop the animation
|
||
|
setInterval(draw, 33)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
* {
|
||
|
margin: 0;
|
||
|
padding: 0
|
||
|
}
|
||
|
|
||
|
.body {
|
||
|
background: #000;
|
||
|
position: fixed;
|
||
|
width: 100%;
|
||
|
height: 100vh;
|
||
|
top: 0;
|
||
|
left: 0;
|
||
|
z-index: 999999;
|
||
|
|
||
|
}
|
||
|
|
||
|
canvas {
|
||
|
display: block;
|
||
|
}
|
||
|
</style>
|