import numpy as np from color_conversions import hsv_to_rgb def generate_color_wheel(resolution=500) -> np.ndarray: """ Generate a color wheel image using HSV to RGB conversion. :param resolution: The width/height of the square image :return: RGB image of the color wheel """ # Create a 2D grid of indices (X, Y) to calculate the angle and radius x = np.linspace(-1, 1, resolution) y = np.linspace(-1, 1, resolution) xv, yv = np.meshgrid(x, y) # Calculate angle (hue) in degrees angle = np.arctan2(yv, xv) * (180 / np.pi) + 180 # Range from 0 to 360 # Calculate radius from the center (used for saturation) radius = np.sqrt(xv**2 + yv**2) # Normalize radius to range [0, 1] radius = np.clip(radius, 0, 1) # HSV components hue = angle # Hue is the angle saturation = radius # Saturation is proportional to the distance from the center # Value is constant (1) for maximum brightness value = np.ones_like(radius) # Stack the HSV components into a single array hsv_image = np.stack((hue, saturation, value), axis=-1) # Convert the HSV image to RGB rgb_image = hsv_to_rgb(hsv_image) return rgb_image