openharmony 鸿蒙 js-apis-arkui-graphics-sys

2026-08-25 浏览 (1)

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

ParameterTypeMandatoryDescription
linearExposurenumberYesLinear 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.
colorSpaceColorSpaceYesColor 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.
rednumberYesRed component of the color. The value is a floating point number ranging from 0 to 1.
greennumberYesGreen component of the color. The value is a floating point number ranging from 0 to 1.
bluenumberYesBlue component of the color. The value is a floating point number ranging from 0 to 1.
alphanumberNoAlpha 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

TypeDescription
ColorMetricsInstance 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

ParameterTypeMandatoryDescription
exposurenumberYesExponential 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.
colorSpaceColorSpaceYesColor 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.
rednumberYesRed component of the color. The value is a floating point number ranging from 0 to 1.
greennumberYesGreen component of the color. The value is a floating point number ranging from 0 to 1.
bluenumberYesBlue component of the color. The value is a floating point number ranging from 0 to 1.
alphanumberNoAlpha 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

TypeDescription
ColorMetricsInstance 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

ParameterTypeMandatoryDescription
colorSpaceColorSpaceYesColor 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.
rednumberYesRed component of the color. The value range is [0, +∞). A value greater than 1.0 enables the HDR feature.
greennumberYesGreen component of the color. The value range is [0, +∞). A value greater than 1.0 enables the HDR feature.
bluenumberYesBlue component of the color. The value range is [0, +∞). A value greater than 1.0 enables the HDR feature.
alphanumberNoAlpha 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

TypeDescription
ColorMetricsInstance 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

TypeDescription
ColorSpaceColor 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

TypeDescription
booleanWhether 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

TypeDescription
numberRed 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

TypeDescription
numberGreen 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

TypeDescription
numberBlue 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

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/8Ba9JamH