Perfect Circle Drawer

Draws a perfect circle

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

    // ==UserScript==
    // @name         Perfect Circle Drawer
    // @namespace    example.com
    // @version      1.0
    // @description  Draws a perfect circle
    // @author       You
    // @match        *://*/*  # Change this to match the desired website
    // @grant        GM_addStyle
    // @grant        none
    // ==/UserScript==

    function drawCircle(x, y, radius, color) {
        // Get the canvas element or create one dynamically
        let canvas = document.getElementById('myCanvas');
        if (!canvas) {
            canvas = document.createElement('canvas');
            canvas.id = 'myCanvas';
            canvas.width = 400; // Adjust as needed
            canvas.height = 400; // Adjust as needed
            document.body.appendChild(canvas); // Add to the page
        }

        let ctx = canvas.getContext('2d');

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

    // Add a button or use a keyboard shortcut
    const button = document.createElement('button');
    button.textContent = 'Draw Circle';
    button.addEventListener('click', function() {
        // Example: Draw a circle at (100, 100) with radius 50 and red color
        drawCircle(100, 100, 50, 'red');
    });

    document.body.appendChild(button);