Skip to content

ColorPane

Note

The pages in the Developer Guide are for plugin developers who want to integrate ColorPane in their projects. If you simply want to use the color tools, you're looking for the the user guide.

Types

ColorPromptOptions

type ColorPromptOptions = {
    PromptTitle: string?,
    InitialColor: (Color | Color3)?,
    ColorType: ("Color" | "Color3")?,
    OnColorChanged: (((Color) -> ()) | ((Color3) -> ()))?
}

ColorType determines the type of value the Promise will resolve with, and the type of value passed to OnColorChanged.

GradientPromptOptions

type GradientPromptOptions = {
    PromptTitle: string?,
    InitialGradient: (Gradient | ColorSequence)?,
    InitialColorSpace: MixableColorType?,
    InitialHueAdjustment: HueAdjustment?,
    InitialPrecision: number?,
    GradientType: ("Gradient" | "ColorSequence")?,
    OnGradientChanged: (((Gradient) -> ()) | ((ColorSequence) -> ()))?
}

GradientType determines the type of value the Promise will resolve with, and the type of value passed to OnGradientChanged.

Enums

PromptRejection

{
    InvalidPromptOptions,
    PromptAlreadyOpen,
    ReservationProblem,
    PromptCancelled,
    SameAsInitial
}
  • PromptRejection.InvalidPromptOptions: One or more of the prompt configuration options was invalid (bad value, wrong type, etc.)
  • PromptRejection.PromptAlreadyOpen: The prompt you were trying to open is already open
  • PromptRejection.ReservationProblem: If you were trying to open the color prompt, then the gradient prompt is currently open. If you were trying to open the gradient prompt, the color prompt is currently open.
  • PromptRejection.PromptCancelled: The user closed the prompt without confirming a color/gradient
  • PromptRejection.SameAsInitial: If you provided an initial color/gradient value, the user confirmed the exact same value

PromiseStatus

Same as Promise.Status.

{
    Started,
    Resolved,
    Rejected,
    Cancelled
}

Functions

IsColorPromptAvailable

ColorPane.IsColorPromptAvailable(): boolean

Returns if a request to prompt for a color will succeed instead of immediately rejecting.

IsGradientPromptAvailable

ColorPane.IsGradientPromptAvailable(): boolean

Returns if a request to prompt for a gradient will succeed instead of immediately rejecting.

PromptForColor

ColorPane.PromptForColor(options: ColorPromptOptions?): Promise

Prompts the user for a color.

local colorPromise = ColorPane.PromptForColor({
    PromptTitle = "Hello, world!",
    InitialColor = Color3.new(0.1, 0.2, 0.3),

    ColorType = "Color3",
    OnColorChanged = print,
})

OnColorChanged must not yield. The specified ColorType and the type parameter to OnColorChanged should match, i.e.

  • ColorType is "Color3", and OnColorChanged accepts a Color3, or
  • ColorType is "Color", and OnColorChanged accepts a Color

but not

  • ColorType is "Color3", and OnColorChanged accepts a Color, nor
  • ColorType is "Color", and OnColorChanged accepts a Color3

PromptForGradient

ColorPane.PromptForGradient(options: GradientPromptOptions?): Promise

Prompts the user for a gradient.

local gradientPromise = ColorPane.PromptForGradient({
    PromptTitle = "Hello, world!",
    InitialGradient = ColorSequence.new(Color3.new(0, 0, 0), Color3.new(1, 1, 1)),

    GradientType = "ColorSequence",
    OnGradientChanged = print,
})

OnGradientChanged must not yield. The specified GradientType and the type parameter to OnGradientChanged should match, i.e.

  • GradientType is "ColorSequence", and OnGradientChanged accepts a ColorSequence, or
  • GradientType is "Gradient", and OnGradientChanged accepts a Gradient

but not

  • GradientType is "ColorSequence", and OnGradientChanged accepts a Gradient, nor
  • GradientType is "Gradient", and OnGradientChanged accepts a ColorSequence.