Top.Mail.Ru
Ответы
Аватар пользователя

Фронтенд-разработка

Интерфейсы и пользовательский опыт: HTML/CSS, JavaScript-фреймворки, доступность, кросс-браузерность. Как ускорить загрузку страниц, или почему не рендерится React-компонент?
1K поста
•
347 участников
Полезные сервисы для разработчиков и не только

Добрый день! Запустили бесплатный небольшой набор сервисов: от генерации паролей и проверки доменов до песочниц JavaScript и PHP.

Пробуйте, сохраняйте в закладки: https://xn----7sbbafuqffehcie7cvgcl5a9h7d.xn--p1ai/mservices

Вот вам html скрипт что бы фоткать себя (сделано ИИ)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Фотобудка</title>
<style>
  body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background: #f0f2f5;
    padding: 20px;
  }
  h1 { color: #333; }
  video, canvas, img {
    max-width: 90%;
    border-radius: 12px;
    background: #000;
  }
  #countdown {
    font-size: 72px;
    font-weight: bold;
    color: #e63946;
    height: 90px;
    line-height: 90px;
  }
  button {
    padding: 14px 32px;
    font-size: 18px;
    border: none;
    border-radius: 30px;
    background: #1d7bf3;
    color: #fff;
    cursor: pointer;
    margin: 15px 0;
  }
  button:hover { background: #155fbf; }
  button:disabled { background: #9bb8d9; cursor: default; }
  a.download {
    display: none;
    margin-top: 10px;
    text-decoration: none;
    color: #fff;
    background: #2a9d8f;
    padding: 12px 28px;
    border-radius: 30px;
  }
</style>
</head>
<body>

<h1>📷 Фотобудка</h1>
<video id="video" autoplay playsinline muted></video>
<div id="countdown"></div>
<button id="startBtn">Сделать фото</button>
<canvas id="canvas" style="display:none;"></canvas>
<img id="photo" style="display:none;" alt="Ваше фото">
<a class="download" id="downloadLink" download="фото.png">Скачать фото</a>

<script>
  const video = document.getElementById('video');
  const canvas = document.getElementById('canvas');
  const photo = document.getElementById('photo');
  const countdown = document.getElementById('countdown');
  const startBtn = document.getElementById('startBtn');
  const downloadLink = document.getElementById('downloadLink');
  let stream = null;

  startBtn.addEventListener('click', async () => {
    try {
      // Запрашиваем доступ к камере
      stream = await navigator.mediaDevices.getUserMedia({
        video: { facingMode: 'user', width: { ideal: 1280 } },
        audio: false
      });
      video.srcObject = stream;
      video.style.display = 'block';
      startBtn.disabled = true;

      // Обратный отсчёт 5 секунд
      let seconds = 5;
      countdown.textContent = seconds;
      const timer = setInterval(() => {
        seconds--;
        if (seconds > 0) {
          countdown.textContent = seconds;
        } else {
          clearInterval(timer);
          countdown.textContent = '';
          takePhoto();
        }
      }, 1000);
    } catch (err) {
      alert('Не удалось включить камеру: ' + err.message);
      startBtn.disabled = false;
    }
  });

  function takePhoto() {
    // Размеры снимка берём из реального потока видео
    canvas.width = video.videoWidth;
    canvas.height = video.videoHeight;
    // Зеркалим, как в селфи — чтобы не смущало отражение
    const ctx = canvas.getContext('2d');
    ctx.translate(canvas.width, 0);
    ctx.scale(-1, 1);
    ctx.drawImage(video, 0, 0, canvas.width, canvas.height);

    // Показываем готовый снимок и выключаем камеру
    photo.src = canvas.toDataURL('image/png');
    photo.style.display = 'block';
    video.style.display = 'none';
    downloadLink.href = photo.src;
    downloadLink.style.display = 'inline-block';

    if (stream) {
      stream.getTracks().forEach(t => t.stop());
      stream = null;
    }
    startBtn.disabled = false;
    startBtn.textContent = 'Сделать ещё фото';
  }
</script>

</body>
</html>

Зацените я сделал html скрипт симулятор где надо бится головой об парту
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
<!DOCTYPE html>
<html lang="ru">
  <head>
    <meta charset="UTF-8" />
    <title>Удар головой об парту</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        background: #f0f2f5;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100vh;
        margin: 0;
      }
      #score-board {
        font-size: 24px;
        margin-bottom: 20px;
      }
      .scene {
        position: relative;
        width: 300px;
        height: 200px;
        border: 4px solid #333;
        background: #fff;
        overflow: hidden;
      }
      .character {
        position: absolute;
        bottom: 60px;
        left: 110px;
        width: 80px;
        height: 90px;
        background: #ffcccc;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        font-weight: bold;
        color: #333;
      }
      .desk {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: #8b4513;
        border-top: 4px solid #5c300d;
      }
      .hit-effect {
        position: absolute;
        top: 70px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 40px;
        background: red;
        border-radius: 50%;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s, transform 0.1s;
      }
      .shake {
        animation: shake 0.3s;
      }
      @keyframes shake {
        0%, 100% { transform: translateX(0); }
        25% { transform: translateX(-10px); }
        75% { transform: translateX(10px); }
      }
      .message {
        margin-top: 15px;
        padding: 10px 16px;
        background: #333;
        color: #fff;
        border-radius: 6px;
        display: none;
      }
    </style>
  </head>
  <body>
    <div id="score-board">Очки: 0</div>
    <div class="scene">
      <div class="hit-effect" id="hit-effect"></div>
      <div class="character" id="character">Голова</div>
      <div class="desk"></div>
    </div>
    <div class="message" id="message">Счёт сброшен! Начинаем заново.</div>

    <script>
      const scoreBoard = document.getElementById('score-board');
      const character = document.getElementById('character');
      const hitEffect = document.getElementById('hit-effect');
      const message = document.getElementById('message');

      let score = 0;
      const targetScore = 500;

      function handleKeyDown(event) {
        if (event.key.toLowerCase() === 'x') {
          score += 1;
          scoreBoard.textContent = `Очки: ${score}`;

          // Анимация удара
          character.classList.add('shake');
          setTimeout(() => character.classList.remove('shake'), 300);

          hitEffect.style.opacity = '1';
          setTimeout(() => hitEffect.style.opacity = '0', 200);

          if (score >= targetScore) {
            score = 0;
            scoreBoard.textContent = `Очки: ${score}`;
            message.style.display = 'block';
            setTimeout(() => message.style.display = 'none', 2000);
          }
        }
      }

      document.addEventListener('keydown', handleKeyDown);
    </script>
  </body>
</html>