多维表格
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.
 
 
 
 
 
 

76 lines
1.6 KiB

<template>
<div class="body">
<canvas>
</canvas>
</div>
</template>
<script>
export default {
name: "screensaver",
mounted() {
// Initialising the canvas
var canvas = this.$el.querySelector('canvas'),
ctx = canvas.getContext('2d');
// Setting the width and height of the canvas
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Setting up the letters
var letters = 'ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ';
letters = letters.split('');
// Setting up the columns
var fontSize = 10,
columns = canvas.width / fontSize;
// Setting up the drops
var drops = [];
for (var i = 0; i < columns; i++) {
drops[i] = 1;
}
// Setting up the draw function
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, .1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (var i = 0; i < drops.length; i++) {
var 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() > .95) {
drops[i] = 0;
}
}
}
// Loop the animation
setInterval(draw, 33);
}
}
</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>