def get_langolt(size, side): w, h = size img = np.zeros((h, w, 3), np.uint8) img[:, :] = (255, 255, 255) center = (int(w / 2), int(h / 2)) r_ext = int(min(w, h)* 5 / 14) r_int = int(min(w, h) * 3 / 14) if side.lower() == 'e': pt_1 = (center[0], int(center[1] - w / 14)) pt_2 = (int(w * 6 / 7), int(center[1] + w / 14)) if side.lower() == 'w': pt_1 = (int(w / 7), int(center[1] - w / 14)) pt_2 = (center[0], int(center[1] + w / 14)) if side.lower() == 'n': pt_1 = (int(center[0] - w/ 14), int(center[1] - w * 5 / 14)) pt_2 = (int(center[0] + w/ 14), center[1]) if side.lower() == 's': pt_1 = (int(center[0] - w/ 14), center[1]) pt_2 = (int(center[0] + w/ 14), int(center[1] + w * 5 / 14)) cv2.circle(img, center, r_ext, (0, 0, 0), -1) cv2.circle(img, center, r_int, (255, 255, 255), -1) cv2.rectangle(img, pt_1, pt_2, (255, 255, 255), -1) return img - Initial Deployment
c1b2a2a verified Download index.html from Alexheep/langolt: direct link, hf CLI and curl.
- Browser
- Download file 21 kB
-
https://huggingface.co/spaces/Alexheep/langolt/resolve/main/index.html
- Command line
-
hf download hf://spaces/Alexheep/langolt/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Alexheep/langolt/resolve/main/index.html
21 kB
| <html lang="ru"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Проверка остроты зрения - Кольца Ландольта</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet"> | |
| <style> | |
| body { | |
| font-family: 'Roboto', sans-serif; | |
| background-color: #f0f7ff; | |
| } | |
| .target-container { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| min-height: 400px; | |
| } | |
| .ring-container { | |
| position: relative; | |
| width: 300px; | |
| height: 300px; | |
| margin: 0 auto; | |
| transition: all 0.5s ease; | |
| } | |
| .ring { | |
| position: absolute; | |
| width: 100%; | |
| height: 100%; | |
| border-radius: 50%; | |
| border: 10px solid #2c5282; | |
| } | |
| .gap { | |
| position: absolute; | |
| width: 40%; | |
| height: 20px; | |
| background: #f0f7ff; | |
| z-index: 2; | |
| transform-origin: left center; | |
| } | |
| @media (max-width: 640px) { | |
| .ring-container { | |
| width: 200px; | |
| height: 200px; | |
| } | |
| .gap { | |
| width: 4px; | |
| height: 40%; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen flex flex-col"> | |
| <header class="bg-blue-800 text-white py-4 shadow-md"> | |
| <div class="container mx-auto px-4"> | |
| <h1 class="text-2xl font-bold text-center">Проверка остроты зрения</h1> | |
| <p class="text-center text-blue-200">Тест с кольцами Ландольта</p> | |
| </div> | |
| </header> | |
| <main class="flex-grow container mx-auto px-4 py-8"> | |
| <div class="max-w-3xl mx-auto bg-white rounded-xl shadow-lg p-6"> | |
| <div class="flex flex-col md:flex-row gap-8"> | |
| <div class="md:w-1/2"> | |
| <div class="ring-container mb-8"> | |
| <div class="ring"></div> | |
| <div class="gap" id="gap"></div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-4 mt-6"> | |
| <button onclick="handleButtonCommand('сверху')" class="px-4 py-2 bg-blue-100 hover:bg-blue-200 rounded-lg">↑ Сверху</button> | |
| <button onclick="handleButtonCommand('справа')" class="px-4 py-2 bg-blue-100 hover:bg-blue-200 rounded-lg">→ Справа</button> | |
| <button onclick="handleButtonCommand('снизу')" class="px-4 py-2 bg-blue-100 hover:bg-blue-200 rounded-lg">↓ Снизу</button> | |
| <button onclick="handleButtonCommand('слева')" class="px-4 py-2 bg-blue-100 hover:bg-blue-200 rounded-lg">← Слева</button> | |
| <button onclick="handleButtonCommand('повтори')" class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg col-span-2">🔄 Повтори</button> | |
| <button onclick="handleButtonCommand('другой')" class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg">🔄 Другой</button> | |
| <button onclick="handleButtonCommand('стоп')" class="px-4 py-2 bg-red-100 hover:bg-red-200 rounded-lg">⏹ Стоп</button> | |
| </div> | |
| </div> | |
| <div class="md:w-1/2"> | |
| <div class="bg-gray-50 p-6 rounded-lg border border-gray-200"> | |
| <h2 class="text-xl font-bold text-gray-800 mb-4">Инструкция</h2> | |
| <ol class="list-decimal pl-5 space-y-2 text-gray-700"> | |
| <li>Определите, где находится разрыв в кольце</li> | |
| <li>Скажите направление разрыва: "сверху", "справа", "снизу" или "слева"</li> | |
| <li>Доступные команды: | |
| <ul class="list-disc pl-5 mt-2"> | |
| <li>"повтори" - показать кольцо снова</li> | |
| <li>"стоп" - завершить тест</li> | |
| <li>"другой" - сменить ориентацию разреза</li> | |
| <li>"мельче" - уменьшить размер кольца</li> | |
| <li>"крупнее" - увеличить размер кольца</li> | |
| </ul> | |
| </li> | |
| <li>Тест автоматически начнется заново после завершения</li> | |
| </ol> | |
| </div> | |
| <div id="resultContainer" class="mt-6 hidden"> | |
| <div class="bg-green-50 border-l-4 border-green-500 p-4"> | |
| <h3 class="text-lg font-bold text-green-800">Результаты теста</h3> | |
| <p id="acuityResult" class="text-green-600 mt-2"></p> | |
| <p id="correctAnswers" class="text-green-600"></p> | |
| <button id="restartBtn" class="mt-4 px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition">Пройти тест снова</button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <footer class="bg-gray-800 text-white py-4"> | |
| <div class="container mx-auto px-4 text-center text-sm"> | |
| <p>Тест остроты зрения с использованием колец Ландольта © 2023</p> | |
| </div> | |
| </footer> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Конфигурация теста | |
| const testConfig = { | |
| minSize: 30, | |
| maxSize: 400, | |
| initialSize: 300, | |
| gapSizes: ['20%', '18%', '16%', '14%', '12%', '10%', '8%', '6%', '4%', '2%'], | |
| directions: ['top', 'right', 'bottom', 'left'], // 12, 3, 6, 9 o'clock | |
| maxLevels: 10 | |
| }; | |
| // Состояние теста | |
| let testState = { | |
| currentSize: testConfig.initialSize, | |
| currentGap: 0, | |
| correctAnswers: 0, | |
| incorrectAnswers: 0, | |
| currentDirection: testConfig.directions[Math.floor(Math.random() * testConfig.directions.length)], | |
| feedbackTimeout: null, | |
| completedLevels: 0, | |
| currentScale: 1.0, // Текущий масштаб (1.0 = 100%) | |
| minScale: 0.3, // Минимальный масштаб (30%) | |
| maxScale: 1.5 // Максимальный масштаб (150%) | |
| }; | |
| // Элементы DOM | |
| const squareContainer = document.querySelector('.square-container'); | |
| const square = document.querySelector('.square'); | |
| const gap = document.getElementById('gap'); | |
| const micBtn = document.getElementById('micBtn'); | |
| const progressBar = document.getElementById('progressBar'); | |
| const levelText = document.getElementById('levelText'); | |
| const resultContainer = document.getElementById('resultContainer'); | |
| const acuityResult = document.getElementById('acuityResult'); | |
| const correctAnswers = document.getElementById('correctAnswers'); | |
| const restartBtn = document.getElementById('restartBtn'); | |
| // Голосовое управление | |
| const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)(); | |
| recognition.lang = 'ru-RU'; | |
| recognition.interimResults = false; | |
| recognition.maxAlternatives = 1; | |
| recognition.start(); | |
| // Начало теста | |
| startTest(); | |
| // Обработчики | |
| restartBtn.addEventListener('click', restartTest); | |
| // Обработчики голосового управления | |
| recognition.onresult = function(event) { | |
| const command = event.results[0][0].transcript.toLowerCase().trim(); | |
| handleVoiceCommand(command); | |
| }; | |
| recognition.onerror = function(event) { | |
| console.error('Ошибка распознавания речи:', event.error); | |
| }; | |
| recognition.onend = function() { | |
| recognition.start(); | |
| }; | |
| // Функции | |
| function startTest() { | |
| testState.currentSize = testConfig.initialSize; | |
| testState.currentGap = 0; | |
| testState.correctAnswers = 0; | |
| testState.incorrectAnswers = 0; | |
| testState.currentDirection = testConfig.directions[Math.floor(Math.random() * testConfig.directions.length)]; | |
| generateRing(); | |
| resultContainer.classList.add('hidden'); | |
| } | |
| function generateRandomRing() { | |
| // Random direction but ensure it's different from current one | |
| const currentIndex = testConfig.directions.indexOf(testState.currentDirection); | |
| let newIndex; | |
| do { | |
| newIndex = Math.floor(Math.random() * testConfig.directions.length); | |
| } while (newIndex === currentIndex && testConfig.directions.length > 1); | |
| testState.currentDirection = testConfig.directions[newIndex]; | |
| generateRing(); | |
| } | |
| function generateRing() { | |
| const scaledSize = testState.currentSize * testState.currentScale; | |
| const ringContainer = document.querySelector('.ring-container'); | |
| ringContainer.style.width = `${scaledSize}px`; | |
| ringContainer.style.height = `${scaledSize}px`; | |
| const ring = document.querySelector('.ring'); | |
| const borderWidth = Math.max(5, Math.floor(scaledSize / 30)); | |
| ring.style.borderWidth = `${borderWidth}px`; | |
| // Calculate gap position based on direction | |
| let rotation = 0; | |
| switch(testState.currentDirection) { | |
| case 'top': rotation = 0; break; | |
| case 'right': rotation = 90; break; | |
| case 'bottom': rotation = 180; break; | |
| case 'left': rotation = 270; break; | |
| } | |
| // Create Landolt C gap (1/5th of diameter) | |
| const gapWidth = scaledSize / 5; | |
| const gapHeight = borderWidth * 2; | |
| gap.style.width = `${gapWidth}px`; | |
| gap.style.height = `${gapHeight}px`; | |
| gap.style.transform = `rotate(${rotation}deg) translate(${scaledSize/2 - gapWidth/2}px, 0)`; | |
| gap.style.display = 'block'; | |
| gap.style.borderRadius = '0'; // Ensure straight edges | |
| } | |
| function checkAnswer(answer) { | |
| clearTimeout(testState.feedbackTimeout); | |
| // Нормализуем ответ (на случай если пришло "слева" вместо "left") | |
| const normalizedAnswer = { | |
| 'слева': 'left', | |
| 'влево': 'left', | |
| 'справа': 'right', | |
| 'вправо': 'right', | |
| 'сверху': 'top', | |
| 'вверху': 'top', | |
| 'снизу': 'bottom', | |
| 'внизу': 'bottom' | |
| }[answer.toLowerCase()] || answer; | |
| const isCorrect = normalizedAnswer === testState.currentDirection; | |
| showFeedback(isCorrect); | |
| console.log(`Gap position: ${testState.currentDirection}, Answer: ${answer}, Correct: ${isCorrect}`); | |
| if (isCorrect) { | |
| testState.correctAnswers++; | |
| // Уменьшаем размер и выбираем случайное направление | |
| testState.currentSize = Math.max( | |
| testConfig.minSize, | |
| testState.currentSize * 0.9 | |
| ); | |
| testState.currentDirection = testConfig.directions[Math.floor(Math.random() * testConfig.directions.length)]; | |
| // Проверяем завершение теста | |
| if (testState.currentSize <= testConfig.minSize) { | |
| finishTest(); | |
| return; | |
| } | |
| // Generate new ring with smaller size and random direction | |
| generateRing(); | |
| } else { | |
| testState.incorrectAnswers++; | |
| // Show same ring again after delay | |
| testState.feedbackTimeout = setTimeout(generateRing, 1500); | |
| } | |
| } | |
| function showFeedback(isCorrect, commandType = 'answer') { | |
| const feedback = document.createElement('div'); | |
| feedback.className = `fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-6xl font-bold z-50 ${ | |
| isCorrect ? 'text-green-500' : 'text-red-500' | |
| }`; | |
| let feedbackText = ''; | |
| if (commandType === 'answer') { | |
| feedbackText = isCorrect ? 'ДА' : 'НЕТ'; | |
| } else if (commandType === 'repeat') { | |
| feedbackText = 'ПОВТОРЯЮ'; | |
| } else if (commandType === 'stop') { | |
| feedbackText = 'ТЕСТ ЗАВЕРШЁН'; | |
| } else if (commandType === 'change') { | |
| feedbackText = isCorrect ? 'ИЗМЕНЕНО' : 'НЕВОЗМОЖНО'; | |
| } else if (commandType === 'size') { | |
| feedbackText = isCorrect ? 'РАЗМЕР ИЗМЕНЁН' : 'ПРЕДЕЛ ДОСТИГНУТ'; | |
| } | |
| feedback.textContent = feedbackText; | |
| document.body.appendChild(feedback); | |
| setTimeout(() => { | |
| feedback.remove(); | |
| gap.style.display = 'block'; | |
| }, 1000); | |
| } | |
| function updateProgress() { | |
| const progress = (testState.completedRings / testState.totalRings) * 100; | |
| progressBar.style.width = `${progress}%`; | |
| } | |
| function updateLevelText() { | |
| const levelNames = ['Крупные кольца', 'Средние кольца', 'Мелкие кольца']; | |
| levelText.textContent = `Уровень: ${testState.currentLevel + 1}/3 (${levelNames[testState.currentLevel]})`; | |
| } | |
| function finishTest() { | |
| // Рассчитываем остроту зрения на основе минимального размера, который смог различить пациент | |
| const acuityScore = Math.min(1.0, (testConfig.initialSize / testState.currentSize).toFixed(1)); | |
| acuityResult.textContent = `Ваша острота зрения: ${acuityScore}`; | |
| correctAnswers.textContent = `Правильных ответов: ${testState.correctAnswers}, Ошибок: ${testState.incorrectAnswers}`; | |
| resultContainer.classList.remove('hidden'); | |
| // Auto-restart after 5 seconds | |
| setTimeout(() => { | |
| startTest(); | |
| }, 5000); | |
| } | |
| function restartTest() { | |
| startTest(); | |
| } | |
| // Test function to verify drawing | |
| function testRingDrawing() { | |
| // Test 1: Left gap | |
| testState.currentDirection = 'left'; | |
| generateRing(); | |
| // Test 2: Right gap after delay | |
| setTimeout(() => { | |
| testState.currentDirection = 'right'; | |
| generateRing(); | |
| // Test 3: Top gap after another delay | |
| setTimeout(() => { | |
| testState.currentDirection = 'top'; | |
| generateRing(); | |
| // Test 4: Bottom gap after another delay | |
| setTimeout(() => { | |
| testState.currentDirection = 'bottom'; | |
| generateRing(); | |
| }, 2000); | |
| }, 2000); | |
| }, 2000); | |
| } | |
| // Initialize with bottom direction | |
| startTest(); | |
| // Make handleVoiceCommand available globally for buttons | |
| window.handleButtonCommand = function(command) { | |
| console.log('Button command:', command); | |
| handleVoiceCommand(command); | |
| }; | |
| function handleVoiceCommand(command) { | |
| command = command.toLowerCase().trim(); | |
| console.log('Handling command:', command); | |
| switch(command) { | |
| case 'сверху': | |
| case 'вверху': | |
| checkAnswer('top'); | |
| break; | |
| case 'справа': | |
| case 'вправо': | |
| checkAnswer('right'); | |
| break; | |
| case 'снизу': | |
| case 'внизу': | |
| checkAnswer('bottom'); | |
| break; | |
| case 'слева': | |
| case 'влево': | |
| checkAnswer('left'); | |
| break; | |
| case 'повтори': | |
| generateRing(); | |
| showFeedback(true, 'repeat'); | |
| break; | |
| case 'стоп': | |
| finishTest(); | |
| showFeedback(true, 'stop'); | |
| break; | |
| case 'мельче': | |
| case 'меньше': | |
| if (testState.currentScale > testState.minScale) { | |
| testState.currentScale = Math.max(testState.minScale, testState.currentScale - 0.1); | |
| generateRing(); | |
| showFeedback(true, 'size'); | |
| } else { | |
| showFeedback(false, 'size'); | |
| } | |
| break; | |
| case 'крупнее': | |
| case 'больше': | |
| if (testState.currentScale < testState.maxScale) { | |
| testState.currentScale = Math.min(testState.maxScale, testState.currentScale + 0.1); | |
| generateRing(); | |
| showFeedback(true, 'size'); | |
| } else { | |
| showFeedback(false, 'size'); | |
| } | |
| break; | |
| default: | |
| console.log('Неизвестная команда:', command); | |
| } | |
| } | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Alexheep/langolt" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |