Drawaria Geometric Pattern Generator (Fixed)

Dibuja patrones perfectos (Círculos, Espirales, Estrellas) sin errores

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Drawaria Geometric Pattern Generator (Fixed)
// @namespace    http://tampermonkey.net
// @version      1.3
// @description  Dibuja patrones perfectos (Círculos, Espirales, Estrellas) sin errores
// @author       User
// @match        https://drawaria.online/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let drawing = false;

    // --- Interfaz de Usuario (Ajustada para no chocar con tus otros botones) ---
    const menu = document.createElement('div');
    menu.style = "position: fixed; top: 300px; left: 15px; z-index: 1000000; background: #1a1a1a; color: white; padding: 15px; border-radius: 10px; border: 2px solid #333; font-family: sans-serif; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); width: 135px;";
    menu.innerHTML = `
        <div style="font-weight: bold; text-align: center; font-size: 10px; color: #00ffff; margin-bottom: 5px;">GEOMETRIC BOTS</div>
        <button id="btnCircle" style="cursor:pointer; background:#444; color:white; border:none; padding:5px; border-radius:4px;">Círculo</button>
        <button id="btnSpiral" style="cursor:pointer; background:#444; color:white; border:none; padding:5px; border-radius:4px;">Espiral</button>
        <button id="btnStar" style="cursor:pointer; background:#444; color:white; border:none; padding:5px; border-radius:4px;">Estrella</button>
        <button id="btnStop" style="cursor:pointer; background:#d9534f; color:white; border:none; padding:5px; margin-top:5px; border-radius:4px; font-weight:bold;">DETENER</button>
    `;
    document.body.appendChild(menu);

    // --- Lógica de Dibujo Mejorada ---
    async function simulateMouse(x, y, type = 'mousedown') {
        const canvas = document.querySelector('canvas') || document.querySelector('#game-canvas');
        if (!canvas) return;
        const rect = canvas.getBoundingClientRect();
        
        const ev = new MouseEvent(type, {
            bubbles: true,
            cancelable: true,
            view: window,
            clientX: rect.left + x,
            clientY: rect.top + y,
            button: 0,
            buttons: (type === 'mouseup') ? 0 : 1 // Importante para que el juego detecte el "click"
        });
        canvas.dispatchEvent(ev);
    }

    async function drawPattern(points) {
        if (drawing) return; // Evita solapar dibujos
        drawing = true;
        
        for (let i = 0; i < points.length; i++) {
            if (!drawing) break;
            let type = 'mousemove';
            if (i === 0) type = 'mousedown';
            if (i === points.length - 1) type = 'mouseup';
            
            simulateMouse(points[i].x, points[i].y, type);
            await new Promise(r => setTimeout(r, 25)); // Delay más estable
        }
        drawing = false;
        simulateMouse(0, 0, 'mouseup');
    }

    function getCenter() {
        const canvas = document.querySelector('canvas') || document.querySelector('#game-canvas');
        return { x: canvas.width / 2, y: canvas.height / 2 };
    }

    // --- Eventos ---
    document.getElementById('btnCircle').onclick = () => {
        let pts = [];
        const {x: cX, y: cY} = getCenter();
        let radius = 120;
        for (let i = 0; i <= 360; i += 10) {
            let rad = i * Math.PI / 180;
            pts.push({ x: cX + radius * Math.cos(rad), y: cY + radius * Math.sin(rad) });
        }
        drawPattern(pts);
    };

    document.getElementById('btnSpiral').onclick = () => {
        let pts = [];
        const {x: cX, y: cY} = getCenter();
        for (let i = 0; i < 500; i += 5) {
            let angle = 0.1 * i;
            let x = cX + (1 + angle) * Math.cos(angle) * 3;
            let y = cY + (1 + angle) * Math.sin(angle) * 3;
            pts.push({ x, y });
        }
        drawPattern(pts);
    };

    document.getElementById('btnStar').onclick = () => {
        let pts = [];
        const {x: cX, y: cY} = getCenter();
        let r = 150;
        for (let i = 0; i <= 5; i++) {
            let angle = (i * 144 - 90) * Math.PI / 180; 
            pts.push({ x: cX + r * Math.cos(angle), y: cY + r * Math.sin(angle) });
        }
        drawPattern(pts);
    };

    document.getElementById('btnStop').onclick = () => {
        drawing = false;
        console.log("Bot detenido.");
    };

})();