mirror of
https://github.com/Gabi-Zar/Images-Scrapper-JS.git
synced 2026-04-17 05:36:06 +02:00
Add front-end
This commit is contained in:
28
public/index.html
Normal file
28
public/index.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Ma Web App</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="stars-canvas" class="stars-canvas"></canvas>
|
||||
<div class="app">
|
||||
<main class="content">
|
||||
<h1>Images Scrapper JS</h1>
|
||||
<div class="view">
|
||||
<div class="horizontal-div">
|
||||
<form class="horizontal-div input-form" id="search-form">
|
||||
<input id="search-input" type="text" placeholder="Search For Images..." />
|
||||
<button onclick="search()">Search</button>
|
||||
</form>
|
||||
<button onclick="download()">Download Images</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
74
public/script.js
Normal file
74
public/script.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const starsNumber = 1000;
|
||||
starsCanvas(starsNumber);
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
starsCanvas(starsNumber);
|
||||
});
|
||||
|
||||
function starsCanvas(number) {
|
||||
const canvas = document.getElementById("stars-canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
canvas.style.filter = "blur(2px)";
|
||||
|
||||
let width = (canvas.width = window.innerWidth);
|
||||
let height = (canvas.height = window.innerHeight);
|
||||
|
||||
const centerX = width / 2;
|
||||
const centerY = height / 2;
|
||||
|
||||
const stars = [];
|
||||
|
||||
for (let i = 0; i < number; i++) {
|
||||
stars.push(makeStar());
|
||||
}
|
||||
|
||||
function animate() {
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
for (let i = 0; i < number; i++) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(stars[i].position.x, stars[i].position.y);
|
||||
ctx.arc(stars[i].position.x, stars[i].position.y, stars[i].radius, 0, Math.PI * 2, true);
|
||||
ctx.fillStyle = `rgb(${stars[i].color}, ${stars[i].color}, ${stars[i].color})`;
|
||||
ctx.fill();
|
||||
|
||||
const velocity = Math.sqrt(stars[i].dx ** 2 + stars[i].dy ** 2);
|
||||
|
||||
stars[i].radius *= 1 + 0.001 * velocity;
|
||||
stars[i].position.x += stars[i].dx;
|
||||
stars[i].position.y += stars[i].dy;
|
||||
stars[i].dx *= 1 + 0.002 * velocity;
|
||||
stars[i].dy *= 1 + 0.002 * velocity;
|
||||
|
||||
if (stars[i].color <= 245) {
|
||||
Math.round((stars[i].color += 0.3 * velocity));
|
||||
}
|
||||
|
||||
if (stars[i].position.x < 0 || stars[i].position.x > width || stars[i].position.y < 0 || stars[i].position.y > height) {
|
||||
stars[i] = makeStar();
|
||||
}
|
||||
}
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
function makeStar() {
|
||||
const angle = Math.random() * 2 * Math.PI;
|
||||
const speed = Math.random() * 0.1 + 0.05;
|
||||
const initialTime = Math.random() * 5000;
|
||||
const dx = Math.cos(angle) * speed;
|
||||
const dy = Math.sin(angle) * speed;
|
||||
|
||||
const star = {
|
||||
position: { x: centerX + dx * initialTime, y: centerY + dy * initialTime },
|
||||
radius: Math.random() * 3,
|
||||
dx: dx,
|
||||
dy: dy,
|
||||
color: 0,
|
||||
};
|
||||
|
||||
return star;
|
||||
}
|
||||
|
||||
animate();
|
||||
}
|
||||
100
public/style.css
Normal file
100
public/style.css
Normal file
@@ -0,0 +1,100 @@
|
||||
* {
|
||||
margin: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
:root {
|
||||
--border-color: #ffffff;
|
||||
--text-color: #eee;
|
||||
--transparent-white: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
color: var(--text-color);
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
padding: 40px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.content h1 {
|
||||
font-size: 50px;
|
||||
margin-bottom: 20px;
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.content button {
|
||||
width: 200px;
|
||||
height: 50px;
|
||||
background: var(--transparent-white);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
color: var(--text-color);
|
||||
font-size: 20px;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.content input {
|
||||
flex: 1;
|
||||
height: 40px;
|
||||
padding: 0 12px;
|
||||
background: var(--transparent-white);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
color: var(--text-color);
|
||||
font-size: 17px;
|
||||
outline: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.content form {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.view {
|
||||
width: 100%;
|
||||
max-width: 1280px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 32px;
|
||||
padding: 40px;
|
||||
|
||||
z-index: 0;
|
||||
overflow: auto;
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
.horizontal-div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.stars-canvas {
|
||||
position: fixed;
|
||||
z-index: -1;
|
||||
}
|
||||
Reference in New Issue
Block a user