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
|
||
3 years ago
|
canvas.width = window.innerWidth;
|
||
|
canvas.height = window.innerHeight;
|
||
4 years ago
|
|
||
3 years ago
|
// Setting up the letters
|
||
3 years ago
|
let letters =
|
||
|
'ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ';
|
||
|
letters = letters.split('');
|
||
4 years ago
|
|
||
3 years ago
|
// Setting up the columns
|
||
3 years ago
|
const fontSize = 10;
|
||
|
const columns = canvas.width / fontSize;
|
||
4 years ago
|
|
||
3 years ago
|
// Setting up the drops
|
||
3 years ago
|
const drops = [];
|
||
3 years ago
|
for (let i = 0; i < columns; i++) {
|
||
3 years ago
|
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);
|
||
3 years ago
|
for (let i = 0; i < drops.length; i++) {
|
||
3 years ago
|
const text = letters[Math.floor(Math.random() * letters.length)];
|
||
|
ctx.fillStyle = '#0f0';
|
||
|
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
|
||
|
drops[i]++;
|
||
3 years ago
|
if (drops[i] * fontSize > canvas.height && Math.random() > 0.95) {
|
||
3 years ago
|
drops[i] = 0;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
// Loop the animation
|
||
3 years ago
|
setInterval(draw, 33);
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
* {
|
||
|
margin: 0;
|
||
3 years ago
|
padding: 0;
|
||
4 years ago
|
}
|
||
|
|
||
|
.body {
|
||
|
background: #000;
|
||
|
position: fixed;
|
||
|
width: 100%;
|
||
|
height: 100vh;
|
||
|
top: 0;
|
||
|
left: 0;
|
||
|
z-index: 999999;
|
||
|
}
|
||
|
|
||
|
canvas {
|
||
|
display: block;
|
||
|
}
|
||
|
</style>
|