Created
January 23, 2023 21:50
-
-
Save emsesc/4169f80b1aae150cb45393ba1a06ec00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def lambda_handler(event, context): | |
# Get the RGB value from the event object (parameter) | |
rgb = event["queryStringParameters"]["rgb"] | |
# Split the RGB value into separate red, green, and blue values | |
split_rgb = rgb.split(',') | |
# Access each hex value by indexes | |
red = int(split_rgb[0]) | |
green = int(split_rgb[1]) | |
blue = int(split_rgb[2]) | |
# Convert the red, green, blue color values to hex representation | |
hex_red = f'{red:02x}' | |
hex_green = f'{green:02x}' | |
hex_blue = f'{blue:02x}' | |
# Concatenate hex values | |
hex_value = hex_red + hex_green + hex_blue | |
# Return the hex value | |
return { 'hex': hex_value} |
Author
emsesc
commented
Jan 23, 2023
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment