Graphics (System API)
The Graphics module provides APIs for defining attributes of a custom node.
NOTE
- The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
- This topic describes only system APIs provided by the module. For details about other public APIs, see Graphics.
ColorMetrics
Mixes colors.
createHDRColorWithLinearExposure24+
static createHDRColorWithLinearExposure(linearExposure: number, colorSpace: ColorSpace, red: number, green: number, blue: number, alpha?: number): ColorMetrics
Instantiates the HDR-supported ColorMetrics class using the color space, linear exposure coefficient, and RGBA color.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| linearExposure | number | Yes | Linear exposure coefficient. Value range: [1, +∞). The value 1.0 indicates the standard exposure coefficient, and a value greater than 1.0 indicates the exposure degree that increases linearly. |
| colorSpace | ColorSpace | Yes | Color space used to specify the color. If ColorSpace.DISPLAY_P3 is used, the setWindowColorSpace API must be called to set the current window to the wide color gamut mode. |
| red | number | Yes | Red component of the color. The value is a floating point number ranging from 0 to 1. |
| green | number | Yes | Green component of the color. The value is a floating point number ranging from 0 to 1. |
| blue | number | Yes | Blue component of the color. The value is a floating point number ranging from 0 to 1. |
| alpha | number | No | Alpha component of the color. The value is a floating point number ranging from 0.0 to 1.0. The default value is 1.0 (fully opaque). |
Return value
| Type | Description |
|---|---|
| ColorMetrics | Instance of the ColorMetrics class. |
createHDRColorWithLogExposure24+
static createHDRColorWithLogExposure(exposure: number, colorSpace: ColorSpace, red: number, green: number, blue: number, alpha?: number): ColorMetrics
Instantiates the HDR-supported ColorMetrics class using the color space, exponential exposure coefficient, and RGBA color.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| exposure | number | Yes | Exponential exposure coefficient. Value range: [0, +∞). The value 0.0 indicates the standard exposure coefficient, and a value greater than 0.0 indicates the exposure degree that increases exponentially. |
| colorSpace | ColorSpace | Yes | Color space used to specify the color. If ColorSpace.DISPLAY_P3 is used, the setWindowColorSpace API must be called to set the current window to the wide color gamut mode. |
| red | number | Yes | Red component of the color. The value is a floating point number ranging from 0 to 1. |
| green | number | Yes | Green component of the color. The value is a floating point number ranging from 0 to 1. |
| blue | number | Yes | Blue component of the color. The value is a floating point number ranging from 0 to 1. |
| alpha | number | No | Alpha component of the color. The value is a floating point number ranging from 0.0 to 1.0. The default value is 1.0 (fully opaque). |
Return value
| Type | Description |
|---|---|
| ColorMetrics | Instance of the ColorMetrics class. |
createHDRColor24+
static createHDRColorWithLogExposure(colorSpace: ColorSpace, red: number, green: number, blue: number, alpha?: number): ColorMetrics
Instantiates the HDR-supported ColorMetrics class using the color space and RGBA color.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| colorSpace | ColorSpace | Yes | Color space used to specify the color. If ColorSpace.DISPLAY_P3 is used, the setWindowColorSpace API must be called to set the current window to the wide color gamut mode. |
| red | number | Yes | Red component of the color. The value range is [0, +∞). A value greater than 1.0 enables the HDR feature. |
| green | number | Yes | Green component of the color. The value range is [0, +∞). A value greater than 1.0 enables the HDR feature. |
| blue | number | Yes | Blue component of the color. The value range is [0, +∞). A value greater than 1.0 enables the HDR feature. |
| alpha | number | No | Alpha component of the color. The value is a floating point number ranging from 0.0 to 1.0. The default value is 1.0 (fully opaque). |
Return value
| Type | Description |
|---|---|
| ColorMetrics | Instance of the ColorMetrics class. |
getColorSpace24+
getColorSpace(): ColorSpace
Obtains the color space of the ColorMetrics object.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Return value
| Type | Description |
|---|---|
| ColorSpace | Color space. |
isHDR24+
isHDR(): boolean
Checks whether the HDR color is displayed for the ColorMetrics object.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Return value
| Type | Description |
|---|---|
| boolean | Whether the HDR color is displayed for the ColorMetrics object. If the color is created using the createHDRColorWithXx method, for example, createHDRColorWithLinearExposure, or any RGB component value is greater than 1.0, true is returned. Otherwise, false is returned, indicating that the HDR color is not displayed for the ColorMetrics object. |
getRedValue24+
getRedValue(): number
Obtains the red component of the ColorMetrics object.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Return value
| Type | Description |
|---|---|
| number | Red component of the color. The value is a floating point number greater than or equal to 0. |
getGreenValue24+
getGreenValue(): number
Obtains the green component of the ColorMetrics object.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Return value
| Type | Description |
|---|---|
| number | Green component of the color. The value is a floating point number greater than or equal to 0. |
getBlueValue24+
getBlueValue(): number
Obtains the blue component of the ColorMetrics object.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Return value
| Type | Description |
|---|---|
| number | Blue component of the color. The value is a floating point number greater than or equal to 0. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 arkts-apis-uicontext-contextmenucontroller
openharmony 鸿蒙 errorcode-canvas
openharmony 鸿蒙 capi-oh-nativexcomponent-native-xcomponent-oh-nativexcomponent
openharmony 鸿蒙 errorcode-bindSheet
openharmony 鸿蒙 js-apis-arkui-uiExtension-sys
openharmony 鸿蒙 capi-arkui-accessibility-arkui-accessibilityeventinfo
openharmony 鸿蒙 capi-arkui-rendernodeutils
openharmony 鸿蒙 js-apis-arkui-node
openharmony 鸿蒙 capi-native-node-h
openharmony 鸿蒙 capi-arkui-nativemodule-arkui-listitemswipeactionitem