Stay organized with collections
Save and categorize content based on your preferences.
blockly > utils > colour
utils.colour namespace
Functions
Function |
Description |
blend(colour1, colour2, factor) |
Blend two colours together, using the specified factor to indicate the weight given to the first colour. |
hexToRgb(colour) |
Converts a colour to RGB. |
hsvToHex(h, s, v) |
Converts an HSV triplet to hex representation. |
hueToHex(hue) |
Convert a hue (HSV model) into an RGB hex triplet. |
parse(str) |
Parses a colour from a string. .parse('red') = '#ff0000' .parse('#f00') = '#ff0000' .parse('#ff0000') = '#ff0000' .parse('0xff0000') = '#ff0000' .parse('rgb(255, 0, 0)') = '#ff0000' |
rgbToHex(r, g, b) |
Converts a colour from RGB to hex representation. |
Variables
Variable |
Description |
names |
A map that contains the 16 basic colour keywords as defined by W3C: https://www.w3.org/TR/2018/REC-css-color-3-20180619/#html4 The keys of this map are the lowercase "readable" names of the colours, while the values are the "hex" values. |
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 2022-10-04 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]