Stay organized with collections
Save and categorize content based on your preferences.
blockly > utils > colour > rgbToHex
utils.colour.rgbToHex() function
Converts a colour from RGB to hex representation.
Signature:
export declare function rgbToHex(r: number, g: number, b: number): string;
Parameters
Parameter |
Type |
Description |
r |
number |
Amount of red, int between 0 and 255. |
g |
number |
Amount of green, int between 0 and 255. |
b |
number |
Amount of blue, int between 0 and 255. |
Returns:
string
Hex representation of the colour.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["`utils.colour.rgbToHex()` is a function that converts colors from RGB format to hexadecimal representation."],["It takes three arguments: `r`, `g`, and `b`, representing the red, green, and blue color values respectively, ranging from 0 to 255."],["The function returns a string containing the hexadecimal color code."]]],["The `rgbToHex` function converts a color from RGB to its hexadecimal representation. It takes three numerical parameters: `r` (red), `g` (green), and `b` (blue), each representing the amount of their respective color components, ranging from 0 to 255. The function then returns a string representing the color in hexadecimal format. The function is found within the blockly.utils.colour namespace.\n"]]