def generate_color_gradient(start_color, end_color, steps):
"""
Generates a list of HTML/HEX color codes transitioning between two colors.
Args:
start_color: The starting HTML/HEX color code (e.g., "#00FF00").
end_color: The ending HTML/HEX color code (e.g., "#FF0000").
steps: The number of colors to generate in the gradient (including start and end).
Returns:
A list of HTML/HEX color codes as strings.
"""
# Remove the "#" symbol from the color codes
start_color = start_color[1:]
end_color = end_color[1:]
# Convert hex values to integers (base 16)
start_red, start_green, start_blue = int(start_color[:2], 16), int(start_color[2:4], 16), int(start_color[4:], 16)
end_red, end_green, end_blue = int(end_color[:2], 16), int(end_color[2:4], 16), int(end_color[4:], 16)
# Calculate the step size for each color channel
red_step = (end_red - start_red) / (steps - 1)
green_step = (end_green - start_green) / (steps - 1)
blue_step = (end_blue - start_blue) / (steps - 1)
# Generate the color list
colors = []
for i in range(steps):
red = int(start_red + i * red_step)
green = int(start_green + i * green_step)
blue = int(start_blue + i * blue_step)
# Convert back to hex format with leading zeros (2 digits)
hex_color = "#" + format(red, '02x') + format(green, '02x') + format(blue, '02x')
colors.append(hex_color)
return colors