Drag[en]gine Script Module DragonScript  1.21
Dragengine.Gui.Color Class Reference

Immutable 3-component double precision color. More...

Inheritance diagram for Dragengine.Gui.Color:

Public Member Functions

Management
float getRed ()
 Red intensity. More...
 
float getGreen ()
 Green intensity. More...
 
float getBlue ()
 Blue intensity. More...
 
float getAlpha ()
 Alpha value. More...
 
Color clamp ()
 Color with all intensities clamped to the range of 0 to 1. More...
 
Color invert ()
 Inverted color. More...
 
bool isEqual (Color c)
 Color is equal to another object.. More...
 
bool isEqual (Color c, float delta)
 Two colors are equal. More...
 
bool equals (Object other)
 Color is equal to another object. More...
 
int hashCode ()
 Hash code for use as dictionary keys. More...
 
String toString ()
 String representation of color. More...
 
String toString (int precision)
 String representation of color with precision. More...
 
Array toHSV ()
 Convert to HSV. More...
 
Array toHSL ()
 Convert to HSL. More...
 
Array toCMYK ()
 Convert to CMYK. More...
 
Operators
Color operator+ (Color v)
 Sum of two colors. More...
 
Color operator- (Color v)
 Difference of two colors. More...
 
Color operator* (float scalar)
 Color scaled by scalar. More...
 
Color operator/ (float scalar)
 Color with each component divided by a value. More...
 
Color operator* (Color v)
 Two colors intensity wise multiplied. More...
 

Static Public Attributes

Color constants
static final Color white = Color.new(1, 1, 1, 1)
 White. More...
 
static final Color lightGray = Color.new(0.75, 0.75, 0.75, 1)
 light gray. More...
 
static final Color gray = Color.new(0.5, 0.5, 0.5, 1)
 gray. More...
 
static final Color darkGray = Color.new(0.25, 0.25, 0.25, 1)
 Dark gray. More...
 
static final Color black = Color.new(0, 0, 0, 1)
 Black. More...
 
static final Color red = Color.new(1, 0, 0, 1)
 Red. More...
 
static final Color darkRed = Color.new(0.5, 0, 0, 1)
 Dark red. More...
 
static final Color green = Color.new(0, 1, 0, 1)
 Green. More...
 
static final Color darkGreen = Color.new(0, 0.5, 0, 1)
 Dark green. More...
 
static final Color blue = Color.new(0, 0, 1, 1)
 Blue. More...
 
static final Color darkBlue = Color.new(0, 0, 0.5, 1)
 Dark blue. More...
 
static final Color yellow = Color.new(1, 1, 0, 1)
 Yellow. More...
 
static final Color transparent = Color.new(0, 0, 0, 0)
 Transparent. More...
 

Constructors

Color new (float red, float green, float blue)
 Create color. More...
 
Color new (float red, float green, float blue, float alpha)
 Create color. More...
 
Color new (Color color, float alpha)
 Create color from another color with alpha replaced. More...
 
static Color newRGB (int red, int green, int blue)
 Create color from rgb values in the range from 0 to 1. More...
 
static Color newRGBA (int red, int green, int blue, int alpha)
 Create color from rgb values in the range from 0 to 1. More...
 
static Color newHSV (float hue, float saturation, float value)
 Create color from HSV. More...
 
static Color newHSL (float hue, float saturation, float lightness)
 Create color from HSL. More...
 
static Color newCMYK (float cyan, float magenta, float yellow, float black)
 Create color from CMYK. More...
 

File Handling

void writeToFile (FileWriter writer)
 Write color to a file writer. More...
 
static Color readFromFile (FileReader reader)
 Read color from a file reader. More...
 

Detailed Description

Immutable 3-component double precision color.

This is a native class. It can not be subclassed.

Member Function Documentation

◆ clamp()

Color Dragengine.Gui.Color.clamp ( )

Color with all intensities clamped to the range of 0 to 1.

◆ equals()

bool Dragengine.Gui.Color.equals ( Object  other)

Color is equal to another object.

Implements Object.equals(Object).

Returns
true if other is of type Color and components are equal.

◆ getAlpha()

float Dragengine.Gui.Color.getAlpha ( )

Alpha value.

◆ getBlue()

float Dragengine.Gui.Color.getBlue ( )

Blue intensity.

◆ getGreen()

float Dragengine.Gui.Color.getGreen ( )

Green intensity.

◆ getRed()

float Dragengine.Gui.Color.getRed ( )

Red intensity.

◆ hashCode()

int Dragengine.Gui.Color.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

◆ invert()

Color Dragengine.Gui.Color.invert ( )

Inverted color.

◆ isEqual() [1/2]

bool Dragengine.Gui.Color.isEqual ( Color  c)

Color is equal to another object..

◆ isEqual() [2/2]

bool Dragengine.Gui.Color.isEqual ( Color  c,
float  delta 
)

Two colors are equal.

◆ new() [1/3]

Color Dragengine.Gui.Color.new ( Color  color,
float  alpha 
)

Create color from another color with alpha replaced.

◆ new() [2/3]

Color Dragengine.Gui.Color.new ( float  red,
float  green,
float  blue 
)

Create color.

◆ new() [3/3]

Color Dragengine.Gui.Color.new ( float  red,
float  green,
float  blue,
float  alpha 
)

Create color.

◆ newCMYK()

static Color Dragengine.Gui.Color.newCMYK ( float  cyan,
float  magenta,
float  yellow,
float  black 
)
static

Create color from CMYK.

Version
1.8
Parameters
cyanCyan in the range from 0 to 1. Value is clamped.
magentaMagenta in the range from 0 to 1. Value is clamped.
yellowYellow in the range from 0 to 1. Value is clamped.
blackBlack in the range from 0 to 1. Value is clamped.

◆ newHSL()

static Color Dragengine.Gui.Color.newHSL ( float  hue,
float  saturation,
float  lightness 
)
static

Create color from HSL.

Version
1.8
Parameters
hueHue in the range from 0 (0 degrees) to 1 (360 degrees). Values outside this range are normalized hence -0.2 is used as 0.8 for the calculation.
saturationSaturation in the range from 0 to 1. Value is clamped.
lightnessLightness in the range from 0 to 1. Value is clamped.

◆ newHSV()

static Color Dragengine.Gui.Color.newHSV ( float  hue,
float  saturation,
float  value 
)
static

Create color from HSV.

Version
1.8
Parameters
hueHue in the range from 0 (0 degrees) to 1 (360 degrees). Values outside this range are normalized hence -0.2 is used as 0.8 for the calculation.
saturationSaturation in the range from 0 to 1. Value is clamped.
valueValue in the range from 0 to 1. Value is clamped.

◆ newRGB()

static Color Dragengine.Gui.Color.newRGB ( int  red,
int  green,
int  blue 
)
static

Create color from rgb values in the range from 0 to 1.

◆ newRGBA()

static Color Dragengine.Gui.Color.newRGBA ( int  red,
int  green,
int  blue,
int  alpha 
)
static

Create color from rgb values in the range from 0 to 1.

◆ operator*() [1/2]

Color Dragengine.Gui.Color.operator* ( Color  v)

Two colors intensity wise multiplied.

◆ operator*() [2/2]

Color Dragengine.Gui.Color.operator* ( float  scalar)

Color scaled by scalar.

◆ operator+()

Color Dragengine.Gui.Color.operator+ ( Color  v)

Sum of two colors.

◆ operator-()

Color Dragengine.Gui.Color.operator- ( Color  v)

Difference of two colors.

◆ operator/()

Color Dragengine.Gui.Color.operator/ ( float  scalar)

Color with each component divided by a value.

Exceptions
EDivisionByZeroscalar is 0.

◆ readFromFile()

static Color Dragengine.Gui.Color.readFromFile ( FileReader  reader)
static

Read color from a file reader.

◆ toCMYK()

Array Dragengine.Gui.Color.toCMYK ( )

Convert to CMYK.

Version
1.8

Returns Array with 4 floats in this order: cyan, magenta, yellow and black. Cyan in the range from 0 to 1. Magenta in the range from 0 to 1. Yellow in the range from 0 to 1. Black in the range from 0 to 1.

◆ toHSL()

Array Dragengine.Gui.Color.toHSL ( )

Convert to HSL.

Version
1.8

Returns Array with 3 floats in this order: hue, saturation and lightness. Hue in the range from 0 (0 degrees) to 1 (360 degrees). Saturation in the range from 0 to 1. Lightness in the range from 0 to 1.

◆ toHSV()

Array Dragengine.Gui.Color.toHSV ( )

Convert to HSV.

Version
1.8

Returns Array with 3 floats in this order: hue, saturation and value. Hue in the range from 0 (0 degrees) to 1 (360 degrees). Saturation in the range from 0 to 1. Value in the range from 0 to 1.

◆ toString() [1/2]

String Dragengine.Gui.Color.toString ( )

String representation of color.

Implements Object.toString()

◆ toString() [2/2]

String Dragengine.Gui.Color.toString ( int  precision)

String representation of color with precision.

Same as toString() except the count of digits of each component is precision.

Parameters
precisionPrecision in digits in the range from 0 to 9 inclusive.
Exceptions
EInvalidParamprecision is less than 0 or larger than 9.

◆ writeToFile()

void Dragengine.Gui.Color.writeToFile ( FileWriter  writer)

Write color to a file writer.

Member Data Documentation

◆ black

final Color Dragengine.Gui.Color.black = Color.new(0, 0, 0, 1)
static

Black.

◆ blue

final Color Dragengine.Gui.Color.blue = Color.new(0, 0, 1, 1)
static

Blue.

◆ darkBlue

final Color Dragengine.Gui.Color.darkBlue = Color.new(0, 0, 0.5, 1)
static

Dark blue.

◆ darkGray

final Color Dragengine.Gui.Color.darkGray = Color.new(0.25, 0.25, 0.25, 1)
static

Dark gray.

◆ darkGreen

final Color Dragengine.Gui.Color.darkGreen = Color.new(0, 0.5, 0, 1)
static

Dark green.

◆ darkRed

final Color Dragengine.Gui.Color.darkRed = Color.new(0.5, 0, 0, 1)
static

Dark red.

◆ gray

final Color Dragengine.Gui.Color.gray = Color.new(0.5, 0.5, 0.5, 1)
static

gray.

◆ green

final Color Dragengine.Gui.Color.green = Color.new(0, 1, 0, 1)
static

Green.

◆ lightGray

final Color Dragengine.Gui.Color.lightGray = Color.new(0.75, 0.75, 0.75, 1)
static

light gray.

◆ red

final Color Dragengine.Gui.Color.red = Color.new(1, 0, 0, 1)
static

Red.

◆ transparent

final Color Dragengine.Gui.Color.transparent = Color.new(0, 0, 0, 0)
static

Transparent.

◆ white

final Color Dragengine.Gui.Color.white = Color.new(1, 1, 1, 1)
static

White.

◆ yellow

final Color Dragengine.Gui.Color.yellow = Color.new(1, 1, 0, 1)
static

Yellow.


The documentation for this class was generated from the following file: