PaletteGenerator Extension for Kodular
The PaletteGenerator
extension provides a set of functions for color manipulation and palette generation in Kodular projects. It is particularly useful for developers who prefer to work with the block-based programming approach. Below is an overview of its public methods:
Public Methods
ScanColor
- Description: Initiates the camera to scan a color.
- Usage: Triggered by a block to start the camera for color scanning.
GeneratePalette
- Description: Creates a color palette based on a given base color in integer ARGB format.
-
Parameters:
baseColor
- Integer value of the base color. - Returns: A list of integer colors forming the palette.
GenerateRandomColorPalette
- Description: Generates a random color palette.
- Returns: A list of randomly generated colors.
GenerateMonochromaticPalette
- Description: Generates a monochromatic color palette based on a base color.
-
Parameters:
baseColor
- Integer value of the base color. - Returns: A list of colors in the monochromatic palette.
ColorToRGBList
- Description: Converts a color integer to an RGB list.
-
Parameters:
color
- Integer color value. - Returns: A list containing the RGB values.
GenerateGradientPalette
- Description: Generates a gradient palette between two colors.
-
Parameters:
colorStart
,colorEnd
- Start and end colors for the gradient;steps
- Number of colors in the gradient. - Returns: A list of colors forming the gradient.
GeneratePastelPalette
- Description: Generates a pastel color palette.
-
Parameters:
count
- Number of pastel colors to generate. - Returns: A list of pastel colors.
GenerateComplementaryColors
- Description: Generates complementary colors based on a base color.
-
Parameters:
baseColor
- Integer value of the base color. - Returns: A list containing the base and its complementary color.
ConvertColorToHex
- Description: Converts a color to its hexadecimal representation.
-
Parameters:
color
- Integer color value. - Returns: Hexadecimal color string.
ConvertHexToColor
- Description: Converts a hexadecimal color string to an integer color value.
-
Parameters:
hexColor
- Hexadecimal color string. - Returns: Integer color value.
RGBToColor
- Description: Converts RGB values to an integer color.
-
Parameters:
red
,green
,blue
- RGB values. - Returns: Integer color value.
RGBAToColor
- Description: Converts RGBA values to an integer color.
-
Parameters:
red
,green
,blue
,alpha
- RGBA values. - Returns: Integer color value.
HSLToColor
- Description: Converts HSL values to an integer color.
-
Parameters:
hue
,saturation
,lightness
- HSL values. - Returns: Integer color value.
HSLAToColor
- Description: Converts HSLA values to an integer color.
-
Parameters:
hue
,saturation
,lightness
,alpha
- HSLA values. - Returns: Integer color value.
HSVToColor
- Description: Converts HSV values to an integer color.
-
Parameters:
hue
,saturation
,value
- HSV values. - Returns: Integer color value.
ConvertToGrayscale
- Description: Converts a color to grayscale.
-
Parameters:
color
- Integer color value. - Returns: Grayscale color value.
CalculateContrastRatio
- Description: Calculates the contrast ratio between two colors.
-
Parameters:
color1
,color2
- Two integer color values. - Returns: Contrast ratio as a float.
MapColorToScale
- Description: Maps a color to a predefined scale.
-
Parameters:
color
- Integer color value;scaleColors
- List of scale colors. - Returns: Color from the scale closest to the input color.
GenerateTextColors
- Description: Generates readable text colors on a given background color.
-
Parameters:
backgroundColor
- Integer value of the background color. - Returns: A list of text colors providing good readability on the background.
Events
ScannedColorReceived
- Description: Triggered when a color is scanned using the camera.
-
Parameters:
colorScanned
- The scanned color.
ErrorOccurred
- Description: Triggered when an error occurs during any operation.
-
Parameters:
errorMessage
- Description of the error.
Demo
This extension offers a robust and comprehensive suite of tools for developers working with colors in their Kodular projects, enhancing the visual aspects of their applications.