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

2026-08-25 浏览 (1)

Graphics (系统接口)

自定义节点相关属性定义的详细信息。

说明:

  • 本模块首批接口从API version 12开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
  • 本文仅介绍当前模块的系统接口,其他公开接口参见Graphics

ColorMetrics

用于混合颜色。

createHDRColorWithLinearExposure24+

static createHDRColorWithLinearExposure(linearExposure: number, colorSpace: ColorSpace, red: number, green: number, blue: number, alpha?: number): ColorMetrics

使用ColorSpace、线性曝光系数和rgba格式颜色实例化支持HDR的ColorMetrics类。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

参数:

参数名类型必填说明
linearExposurenumber线性曝光系数,取值范围:[1, +∞)。1.0表示标准曝光系数,大于1.0的值表示线性增加的曝光程度。
colorSpaceColorSpace颜色空间,用于指定颜色的色彩空间。使用ColorSpace.DISPLAY_P3,需要对应窗口调用setWindowColorSpace接口,将当前窗口设置为广色域模式。
rednumber颜色的R分量(红色),值是0~1的浮动数值。
greennumber颜色的G分量(绿色),值是0~1的浮动数值。
bluenumber颜色的B分量(蓝色),值是0~1的浮动数值。
alphanumber颜色的A分量(透明度),值是0.0~1.0的浮点数,默认值为1.0,不透明。

返回值:

类型说明
ColorMetricsColorMetrics类的实例。

createHDRColorWithLogExposure24+

static createHDRColorWithLogExposure(exposure: number, colorSpace: ColorSpace, red: number, green: number, blue: number, alpha?: number): ColorMetrics

使用ColorSpace、指数型曝光系数和rgba格式颜色实例化支持HDR的ColorMetrics类。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

参数:

参数名类型必填说明
exposurenumber指数型曝光系数,取值范围:[0, +∞)。0.0表示标准曝光系数,大于0.0的值表示指数级增加的曝光程度。
colorSpaceColorSpace颜色空间,用于指定颜色的色彩空间。使用ColorSpace.DISPLAY_P3,需要对应窗口调用setWindowColorSpace接口,将当前窗口设置为广色域模式。
rednumber颜色的R分量(红色),值是0~1的浮动数值。
greennumber颜色的G分量(绿色),值是0~1的浮动数值。
bluenumber颜色的B分量(蓝色),值是0~1的浮动数值。
alphanumber颜色的A分量(透明度),值是0.0~1.0的浮点数,默认值为1.0,不透明。

返回值:

类型说明
ColorMetricsColorMetrics类的实例。

createHDRColor24+

static createHDRColorWithLogExposure(colorSpace: ColorSpace, red: number, green: number, blue: number, alpha?: number): ColorMetrics

使用ColorSpace和rgba格式颜色实例化支持HDR的ColorMetrics类。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

参数:

参数名类型必填说明
colorSpaceColorSpace颜色空间,用于指定颜色的色彩空间。使用ColorSpace.DISPLAY_P3,需要对应窗口调用setWindowColorSpace接口,将当前窗口设置为广色域模式。
rednumber颜色的R分量(红色),取值范围:[0, +∞)。大于1.0的值会使能HDR特性。
greennumber颜色的G分量(绿色),取值范围:[0, +∞)。大于1.0的值会使能HDR特性。
bluenumber颜色的B分量(蓝色),取值范围:[0, +∞)。大于1.0的值会使能HDR特性。
alphanumber颜色的A分量(透明度),值是0.0~1.0的浮点数,默认值为1.0,不透明。

返回值:

类型说明
ColorMetricsColorMetrics类的实例。

getColorSpace24+

getColorSpace(): ColorSpace

获取ColorMetrics的色彩空间。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

返回值:

类型说明
ColorSpace色彩空间。

isHDR24+

isHDR(): boolean

获取ColorMetrics是否呈现了HDR色彩。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

返回值:

类型说明
booleanColorMetrics是否呈现了HDR色彩。当色彩是通过createHDRColorWithXx方法,如createHDRColorWithLinearExposure创建,或任意RGB分量值大于1.0时,将返回true;否则返回false,表示ColorMetrics未呈现HDR色彩。

getRedValue24+

getRedValue(): number

获取ColorMetrics颜色的R分量(红色)。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

返回值:

类型说明
number颜色的R分量(红色),值是大于等于0的浮点数。

getGreenValue24+

getGreenValue(): number

获取ColorMetrics颜色的G分量(绿色)。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

返回值:

类型说明
number颜色的G分量(绿色),值是大于等于0的浮点数。

getBlueValue24+

getBlueValue(): number

获取ColorMetrics颜色的B分量(蓝色)。

系统能力: SystemCapability.ArkUI.ArkUI.Full

模型约束: 此接口仅可在Stage模型下使用。

返回值:

类型说明
number颜色的B分量(蓝色),值是大于等于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 鸿蒙 capi-native-node-h-nodeattributetype-layoutcomponent

openharmony 鸿蒙 js-apis-arkui-node

openharmony 鸿蒙 capi-native-node-h

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