# tk_rgba_color_wheel.py import tkinter as tk from PIL import Image, ImageTk import math, colorsys size = 250 radius = 100 center = (size // 2, size // 2) image = Image.new("RGBA", (size, size), (0, 0, 0, 0)) pixels = image.load() for y in range(size): for x in range(size): dx = x - center[0] dy = y - center[1] distance = math.hypot(dx, dy) if distance <= radius: angle = math.atan2(dy, dx) hue = (angle + math.pi) / (2 * math.pi) r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(hue, 1, 1)] alpha = int((1 - distance / radius) * 255) pixels[x, y] = (r, g, b, alpha) root = tk.Tk() root.title("tk RGBA Color Wheel") tk_image = ImageTk.PhotoImage(image) label = tk.Label(root, image=tk_image) label.pack() root.mainloop()