• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Datatypes

    Edit

    Color

    The Color datatype represents an RGBA (Red Green Blue Alpha) color. Colors are represented with numbers between 0 and 1, where 1 signifies the maximum intensity of a particular color component. RGB components define the color while the Alpha component defines the transparency.

    Provides various functions and predefined colors which ranges from common colors like red, green, blue, white, black, to more specific colors such as yellow, cyan, magenta, gray, etc. Further it also provides functionalities such as linear interpolation between two colors, conversion from/to HSV color model, and generating a grayscale color.

    Properties

    grayscale

    number

    The grayscale value of the color based on the intensities of the red, green, and blue components.

    The linear (gamma space) equivalent of this color object. Game graphics are usually rendered in a color space known as gamma space, but many computations are done in linear space, thus this property can be useful when such conversions are necessary.

    The gamma space equivalent of this color object. When the computations are done in linear space, this conversion can be useful to switch back to Gamma space for rendering.

    The maximum RGB component in the color. It can be useful when you want to identify the dominant color component.

    r

    number

    Access or change the red component value of the color.

    g

    number

    Access or change the green component value of the color.

    b

    number

    Access or change the blue component value of the color.

    a

    number

    Access or change the alpha (transparency) component of the color where '1' is fully opaque and '0' is fully transparent.

    Predefined Color object with red component set to maximum and all other components set to zero. It's a static property, accessible directly from the class.

    Predefined color object with green component at maximum while red, blue, and alpha components at zero. As a static property, it can be accessed directly from the class.

    Predefined color object with blue component set to maximum and all other components set to zero. One major use of this property can be for quick access to the pure blue color.

    Predefined color object with all components set to maximum, producing white color. It is a static property accessible directly from the class.

    Predefined black color object with all color components set to zero. As a static property, it can be accessed directly from the class.

    Predefined yellow color object, offering a quick way to use yellow in your game. It is a static property, accessible directly from the class.

    Predefined cyan color object. It provides a quick and convenient way to use cyan in your game.

    Predefined magenta color object. It allows quick access to the magenta color.

    Predefined gray color object, allowing for quick utilization of gray in a game scene or interface. As a static property, it's accessible directly from the class.

    Predefined grey color object. As a static property, it can be accessed directly from the class. This makes it convenient to use grey color quickly and easily.

    Predefined color object with all components set to zero, resulting in a fully transparent color. Quick access to a transparent color can provide utility in many situations.

    Methods

    Calculates and returns a color that is a certain percentage (defined by the third parameter) between two other colors. This can be used to smoothly transition between two colors.

    Parameters

    The color to transition from.

    The color to transition into.

    t

    number

    The percentage of the transition. 0 represents color 'a' and 1 represents color 'b'.

    Returns

    Color

    Returns the interpolated color.

    Works similarly to 'Lerp', but without clamping the percentage (third parameter) between 0 and 1. This allows for extrapolation beyond the two original colors.

    Parameters

    The color to transition from.

    The color to transition into.

    t

    number

    The percentage of the transition.

    Returns

    Color

    Returns the interpolated or extrapolated color.

    Convert a color from HSV (Hue, Saturation, Value) color model to RGB (Red, Green, Blue) model. This function can be quite useful whenever you're dealing with HSV colors and need to convert them for use in RGB format.

    Parameters

    H

    number

    The Hue component of the color, ranges between 0 to 1.

    S

    number

    The Saturation component of the color, ranges between 0 to 1.

    V

    number

    The Value component of the color, ranges between 0 to 1.

    Returns

    Color

    Returns a Color object in RGB color space.

    Updated 27 days ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.