Daltz333 / COSC-481W

0 stars 0 forks source link

Implement color picker #14

Closed Daltz333 closed 1 year ago

Daltz333 commented 1 year ago

Implementation for #5. We need the hexadecimal color code to send to the API/database.

leemo3 commented 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)

Generate 100 different color shades

colors = [] for i in range(100):

Vary the red, green, and blue components proportionally

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)

Print the list of 100 different color shades

for color in colors: print(color)

leemo3 commented 1 year ago

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); }

Daltz333 commented 1 year ago

I pretty much have this implemented in-app.