Skip to content

Instantly share code, notes, and snippets.

@inosik
Created August 2, 2021 15:38
Show Gist options
  • Save inosik/53bad32fd4447f7a3b14135cf79486a0 to your computer and use it in GitHub Desktop.
Save inosik/53bad32fd4447f7a3b14135cf79486a0 to your computer and use it in GitHub Desktop.
Bindings for Scriptable.app
namespace Fable.Import.Scriptable
// TODO: Check if the channels are 0-255 or 0-1.
/// _Stores color data including opacity._
///
/// A color can be created using a hex value, e.g. #FF0000 and optionally an alpha or it can be created using the provided system colors.
[<AllowNullLiteral; Global>]
type Color private () =
/// <summary>Constructs a color.
///
/// Constructs a new color with a hex value and optionally an alpha value. The hex value may specify the alpha value but this will be ignored if the alpha value parameter is provided.
/// Examples of valid hex values: #ff0000, #00ff0080 #00f and #ff. The hashtag is optional.</summary>
/// <param name="hex">Hex value.</param>
/// <param name="alpha">Alpha value.</param>
new (hex : string, ?alpha : float) = Color ()
/// HEX representation.
member val hex : string = jsNative
/// Amount of red in the color.
[<EmitProperty ("red")>]
member val r : float = jsNative
/// Amount of green in the color.
[<EmitProperty ("green")>]
member val g : float = jsNative
/// Amount of blue in the color.
[<EmitProperty ("blue")>]
member val b : float = jsNative
/// Alpha of the color.
[<EmitProperty ("alpha")>]
member val a : float = jsNative
/// Constructs a black color.
static member black () : Color = jsNative
/// Constructs a dark gray color.
static member darkGray () : Color = jsNative
/// Constructs a light gray color.
static member lightGray () : Color = jsNative
/// Constructs a white color.
static member white () : Color = jsNative
/// Constructs a gray color.
static member gray () : Color = jsNative
/// Constructs a red color.
static member red () : Color = jsNative
/// Constructs a green color.
static member green () : Color = jsNative
/// Constructs a blue color.
static member blue () : Color = jsNative
/// Constructs a cyan color.
static member cyan () : Color = jsNative
/// Constructs a yellow color.
static member yellow () : Color = jsNative
/// Constructs a magenta color.
static member magenta () : Color = jsNative
/// Constructs a orange color.
static member orange () : Color = jsNative
/// Constructs a purple color.
static member purple () : Color = jsNative
/// Constructs a brown color.
static member brown () : Color = jsNative
/// Constructs a transparent color.
static member clear () : Color = jsNative
/// <summary>Creates a dynamic color.
///
/// The dynamic color will use either its light or dark variant depending on the appearance of the system.
///
/// Dynamic colors are not supported when used with `DrawContext`.</summary>
/// <param name="lightColor">Color used in light appearance.</param>
/// <param name="darkColor">Color used in dark appearance.</param>
/// <returns>Dynamic color.</returns>
static member dynamic (lightColor : Color, darkColor : Color) : Color = jsNative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment