Note: You are on the beta version of our docs. This is a work in progress and may contain broken links and pages.
Classes
Color
Color
Represents a color object. Stores all color components (alpha (opacity), red, green, blue) in a [0..255] range.
Summary
Constructors
Constructors
constructor
new Color(knownColor: string): Color
defined in @nativescript/core/color/index.d.ts:5:1
Parameter | Default | Description |
knownColor |
| string |
Returns Color
new Color(hex: string): Color
defined in @nativescript/core/color/index.d.ts:6:1
Parameter | Default | Description |
hex |
| string |
Returns Color
new Color(argb: number): Color
defined in @nativescript/core/color/index.d.ts:7:1
Parameter | Default | Description |
argb |
| number |
Returns Color
new Color(alpha: number, red: number, green: number, blue: number, type?: "rgb" | "hsl" | "hsv"): Color
defined in @nativescript/core/color/index.d.ts:8:1
Parameter | Default | Description |
alpha |
| number |
red |
| number |
green |
| number |
blue |
| number |
type |
| "rgb" | "hsl" | "hsv" |
Returns Color
Properties
a
defined in @nativescript/core/color/index.d.ts:13:8
Gets the Alpha component (in the [0, 255] range) of this color. This is a read-only property.
android
defined in @nativescript/core/color/index.d.ts:48:1
Gets the android-specific integer value representation. Same as the Argb one. This is a read-only property.
argb
defined in @nativescript/core/color/index.d.ts:38:8
Gets the Argb Number representation of this color where each 8 bits represent a single color component. This is a read-only property.
b
defined in @nativescript/core/color/index.d.ts:28:8
Gets the Blue component (in the [0, 255] range) of this color. This is a read-only property.
g
defined in @nativescript/core/color/index.d.ts:23:8
Gets the Green component (in the [0, 255] range) of this color. This is a read-only property.
hex
defined in @nativescript/core/color/index.d.ts:33:8
Gets the Hexadecimal string representation of this color. This is a read-only property.
ios
defined in @nativescript/core/color/index.d.ts:53:1
Gets the iOS-specific UIColor value representation. This is a read-only property.
name
defined in @nativescript/core/color/index.d.ts:43:8
Gets the known name of this instance. Defined only if it has been constructed from a known color name - e.g. "red". This is a read-only property.
r
defined in @nativescript/core/color/index.d.ts:18:8
Gets the Red component (in the [0, 255] range) of this color. This is a read-only property.
Methods
brighten
brighten(amount: number): Color
defined in @nativescript/core/color/index.d.ts:172:1
Brighten the color a given amount, from 0 to 100.
Parameter | Default | Description |
amount |
| number (between 0 and 100) |
Returns Color
darken
darken(amount: number): Color
defined in @nativescript/core/color/index.d.ts:179:1
Darken the color a given amount, from 0 to 100. Providing 100 will always return black.
Parameter | Default | Description |
amount |
| number (between 0 and 100) |
Returns Color
desaturate
desaturate(amount: number): Color
defined in @nativescript/core/color/index.d.ts:143:1
Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling greyscale.
Parameter | Default | Description |
amount |
| number (between 0 and 100) |
Returns Color
equals
equals(value: Color): boolean
defined in @nativescript/core/color/index.d.ts:59:1
Specifies whether this Color is equal to the Color parameter.
Parameter | Default | Description |
value |
| The Color to test. |
Returns boolean
getBrightness
defined in @nativescript/core/color/index.d.ts:95:1
return the [brightness](http://www.w3.org/TR/AERT#color-contrast)
Returns number
getLuminance
defined in @nativescript/core/color/index.d.ts:100:1
return the [luminance](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef)
Returns number
greyscale
greyscale(): Color
defined in @nativescript/core/color/index.d.ts:157:1
Completely desaturates a color into greyscale. Same as calling desaturate(100).
Returns Color
isDark
isLight
lighten
lighten(amount: number): Color
defined in @nativescript/core/color/index.d.ts:165:1
Lighten the color a given amount, from 0 to 100. Providing 100 will always return white.
Parameter | Default | Description |
amount |
| number (between 0 and 100) |
Returns Color
saturate
saturate(amount: number): Color
defined in @nativescript/core/color/index.d.ts:150:1
Saturate the color a given amount, from 0 to 100.
Parameter | Default | Description |
amount |
| number (between 0 and 100) |
Returns Color
setAlpha
setAlpha(a: number): Color
defined in @nativescript/core/color/index.d.ts:107:1
Return this color (as a new Color instance) with the provided alpha
Parameter | Default | Description |
a |
| number |
Returns Color
spin
spin(amount: number): Color
defined in @nativescript/core/color/index.d.ts:186:1
Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing (since it sets the hue back to what it was before).
Parameter | Default | Description |
amount |
| number (between 0 and 100) |
Returns Color
toHsl
defined in @nativescript/core/color/index.d.ts:112:1
return the hsl representation of the color
Returns {
a: number
h: number
l: number
}
toHslString
defined in @nativescript/core/color/index.d.ts:118:1
return the [CSS hsv](https://www.w3schools.com/Css/css_colors_hsl.asp) representation of the color
Returns string
toHsv
defined in @nativescript/core/color/index.d.ts:124:1
return the hsv representation of the color
Returns {
a: number
h: number
s: number
}
toHsvString
defined in @nativescript/core/color/index.d.ts:130:1
return the [CSS hsv](https://www.w3schools.com/Css/css_colors_rgb.asp) representation of the color
Returns string
toRgbString
defined in @nativescript/core/color/index.d.ts:136:1
return the [CSS rgb](https://www.w3schools.com/Css/css_colors_rgb.asp) representation of the color
Returns string
equals
Static
fromHSL
Static
fromHSL(a: any, h: any, s: any, l: any): Color
defined in @nativescript/core/color/index.d.ts:204:1
returns a new Color from HSL
Parameter | Default | Description |
a |
| any |
h |
| any |
s |
| any |
l |
| any |
Returns Color
fromHSV
Static
fromHSV(a: any, h: any, s: any, l: any): Color
defined in @nativescript/core/color/index.d.ts:205:1
Parameter | Default | Description |
a |
| any |
h |
| any |
s |
| any |
l |
| any |
Returns Color
fromIosColor
Static
fromIosColor(value: any): Color
defined in @nativescript/core/color/index.d.ts:77:1
Creates color from iOS-specific UIColor value representation.
Parameter | Default | Description |
value |
| any |
Returns Color
isValid
Static
defined in @nativescript/core/color/index.d.ts:72:1
Validates if a value can be converted to color.
Parameter | Default | Description |
value |
| any Input string. |
Returns boolean
- Previous
- CoercibleProperty
- Next
- ContainerView