Closed Daltz333 closed 1 year ago
implement color picker in Python for 100 different shades
def rgb_to_hex(red, green, blue): return "#{:02X}{:02X}{:02X}".format(red, green, blue)
colors = [] for i in range(100):
red = int(255 * i / 100)
green = int(255 * i / 100)
blue = int(255 * i / 100)
hex_color = rgb_to_hex(red, green, blue)
colors.append(hex_color)
for color in colors: print(color)
function rgbToHex(red, green, blue) {
return #${red.toString(16).padStart(2, '0')}${green.toString(16).padStart(2, '0')}${blue.toString(16).padStart(2, '0')}
;
}
// Generate 100 different color shades const colors = []; for (let i = 0; i < 100; i++) { // Vary the red, green, and blue components independently const red = Math.floor((255 i) / 100); const green = Math.floor((255 i) / 100); const blue = Math.floor((255 * i) / 100); const hexColor = rgbToHex(red, green, blue); colors.push(hexColor); }
// Print the list of 100 different color shades for (const color of colors) { console.log(color); }
I pretty much have this implemented in-app.
Implementation for #5. We need the hexadecimal color code to send to the API/database.