Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // shit i should put in a lib
- function circle(x, y, radie, color) {
- let c = document.getElementById('canvas')
- let ctx = c.getContext('2d')
- ctx.beginPath()
- ctx.arc(x, y, radie, 0, 2 * Math.PI)
- ctx.fillStyle = color
- ctx.fill()
- }
- function clear() {
- let c = document.getElementById('canvas')
- let ctx = c.getContext('2d')
- ctx.clearRect(0, 0, canvas.width, canvas.height)
- }
- function randomInt(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- function fadeOut(target) {
- var fadeTarget = document.getElementById(target);
- var fadeEffect = setInterval(function () {
- if (!fadeTarget.style.opacity) {
- fadeTarget.style.opacity = 1;
- }
- if (fadeTarget.style.opacity > 0) {
- fadeTarget.style.opacity -= 0.05;
- } else {
- clearInterval(fadeEffect);
- }
- }, 10);
- }
- function randomColor() {
- var letters = '0123456789ABCDEF';
- var color = '#';
- for (var i = 0; i < 6; i++) {
- color += letters[Math.floor(Math.random() * 16)];
- }
- return color;
- }
- function redirect() {
- document.location.href = 'sida2'
- }
- let W = window.innerWidth
- let H = window.innerHeight
- document.getElementById('canvas').width = W
- document.getElementById('canvas').height = H
- // shid that does stuff
- let bubbles1 = []
- let bubbles2 = []
- let timer = 40
- let timer2 =
- function draw() {
- clear()
- timer++
- if (timer > 40 && bubbles1.length < 10) {
- let bubble1 = {
- x: randomInt(0, W),
- y: H+100,
- size: randomInt(50, 100),
- color: randomColor(),
- speed: randomInt(1, 3)
- }
- bubbles1.push(bubble1)
- timer = 0
- }
- if (timer > 40 && bubbles2.length < 10) {
- let bubble2 = {
- x: randomInt(0, W),
- y: H+100,
- size: randomInt(50, 100),
- color: randomColor(),
- speed: randomInt(1, 3)
- }
- bubbles2.push(bubble2)
- timer = 0
- }
- for (let i = bubbles1.length-1; i >= 0; i--){
- circle(bubbles1[i].x, bubbles[i].y, bubbles1[i].size, bubbles1[i].color)
- bubbles1[i].y -= bubbles1[i].speed
- if (bubbles1[i].y < -100) {
- bubbles1.splice(i, 1)
- }
- }
- for (let j = bubbles2.length-1; j >= 0; j--){
- circle(bubbles2[j].x, bubbles2[j].y, bubbles2[j].size, bubbles2[j].color)
- bubbles2[j].y += bubbles2[j].speed
- if (bubbles2[j].y < H + 100) {
- bubbles2.splice(j, 1)
- }
- }
- }
- setInterval(draw, 30)
- setTimeout(function showText() {
- document.getElementById('content').style.display = 'block'
- }, 500)
- let button = document.getElementById('button')
- button.onclick = () => {
- fadeOut('sida1')
- setTimeout(function redirect() {document.location.href = 'sida2.html'}, 200)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement