Skip to content

Commit

Permalink
Actualizada guía de HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
argenisosorio committed Nov 28, 2024
1 parent f1ccc81 commit 192353b
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions html.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7045,3 +7045,114 @@ Fuente
======

ChatGPT

=======================
Partículas con css y js
=======================

<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Partículas</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
overflow: hidden;
height: 100vh;
background-color: #111;
}

canvas {
position: absolute;
top: 0;
left: 0;
}
</style>
</head>
<body>
<canvas id="particleCanvas"></canvas>

<script>
const canvas = document.getElementById('particleCanvas');
const ctx = canvas.getContext('2d');

// Ajustar tamaño del canvas para cubrir toda la página
function resizeCanvas() {
canvas.width = document.documentElement.scrollWidth;
canvas.height = document.documentElement.scrollHeight;
}

// Configuración de partículas
const particles = [];
const numParticles = 150;

class Particle {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.size = Math.random() * 5 + 1;
this.speedX = Math.random() * 3 - 1.5;
this.speedY = Math.random() * 3 - 1.5;
this.color = `rgba(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, 0.7)`;
}

update() {
this.x += this.speedX;
this.y += this.speedY;

// Rebotar en los bordes
if (this.x > canvas.width || this.x < 0) this.speedX *= -1;
if (this.y > canvas.height || this.y < 0) this.speedY *= -1;
}

draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = this.color;
ctx.fill();
}
}

function initParticles() {
particles.length = 0; // Vaciar partículas existentes
for (let i = 0; i < numParticles; i++) {
particles.push(new Particle());
}
}

function animateParticles() {
ctx.clearRect(0, 0, canvas.width, canvas.height);

for (let particle of particles) {
particle.update();
particle.draw();
}

requestAnimationFrame(animateParticles);
}

// Ajustar canvas y partículas al redimensionar
window.addEventListener('resize', () => {
resizeCanvas();
initParticles();
});

// Inicialización
resizeCanvas();
initParticles();
animateParticles();
</script>
</body>
</html>

Fuente
======

ChatGPT

0 comments on commit 192353b

Please sign in to comment.