Created
October 22, 2025 12:52
-
-
Save danielfalbo/68abcbcf734ac2eb2068c865cb6cff20 to your computer and use it in GitHub Desktop.
D circle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from PIL import Image, ImageDraw | |
| import math | |
| w = 3000 | |
| h = 3000 | |
| thickness = 25 | |
| padding = 300 | |
| black = (0, 0, 0) | |
| white = (255, 255, 255) | |
| img = Image.new('RGB', (w, h), black) | |
| draw = ImageDraw.Draw(img) | |
| cx = w // 2 | |
| cy = h // 2 | |
| radius = (w // 2) - padding | |
| bbox = [padding, padding,w - padding, h - padding] | |
| draw.ellipse(bbox, outline=white, width=thickness) | |
| x = int(cx - radius + (1/3 * 2 * radius)) | |
| dx = x - cx | |
| dy = math.sqrt(radius**2 - dx**2) - thickness // 2 | |
| y1 = int(cy - dy) | |
| y2 = int(cy + dy) | |
| draw.line([(x, y1), (x, y2)], fill=white, width=thickness) | |
| file_name = 'out.png' | |
| img.save(file_name) | |
| print(f"Image saved as {file_name}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pip install Pillow