Stay organized with collections
Save and categorize content based on your preferences.
blockly > blockRendering > ConstantProvider > getBlockStyleForColour
blockRendering.ConstantProvider.getBlockStyleForColour() method
Get or create a block style based on a single colour value. Generate a name for the style based on the colour.
Signature:
getBlockStyleForColour(colour: string): {
style: BlockStyle;
name: string;
};
Parameters
Parameter |
Type |
Description |
colour |
string |
#RRGGBB colour string. |
Returns:
{ style: BlockStyle; name: string; }
An object containing the style and an autogenerated name for that style.
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."],[[["The `blockRendering.ConstantProvider.getBlockStyleForColour()` method retrieves or generates a block style based on a specified color."],["This method accepts a hexadecimal color string (`#RRGGBB`) as input to determine the style."],["It returns an object containing the generated block style and an automatically assigned name for the style."]]],["The `getBlockStyleForColour()` method, part of `blockRendering.ConstantProvider`, creates or retrieves a block style using a provided color string. It accepts a single parameter, `colour`, which is a `#RRGGBB` color string. The method returns an object containing the generated `BlockStyle` and an auto-generated `name` for that style. This allows for dynamically creating and accessing block styles based on color values.\n"]]