openharmony 鸿蒙 js-apis-uiEffect

2025-06-12 浏览 (1)

@ohos.graphics.uiEffect (Cascading Effect)

The uiEffect module provides basic capabilities to apply an effect, for example, blur, pixel stretch, and brightness, to a component. Effects are classified into filters and visual effects. Effects of the same category can be cascaded in an effect instance of the corresponding category. In actual development, the blur effect can be used for background blurring, and the brightness effect can be used for screen-on display.

  • Filter: applies a filter to a component.
  • VisualEffect: applies a visual effect to a component.

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.

Modules to Import

import { uiEffect } from "@kit.ArkGraphics2D";

uiEffect.createFilter

createFilter(): Filter

Creates a Filter instance, which can be used to apply multiple filters to a component.

System capability: SystemCapability.Graphics.Drawing

Return value

TypeDescription
FilterHead node of the filter.

Example

let filter : uiEffect.Filter = uiEffect.createFilter()

uiEffect.createEffect

createEffect(): VisualEffect

Creates a VisualEffect instance, which can be used to apply multiple visual effects to a component.

System capability: SystemCapability.Graphics.Drawing

Return value

TypeDescription
VisualEffectHead node of the visual effect.

Example

let visualEffect : uiEffect.VisualEffect = uiEffect.createEffect()

Filter

A class that can apply a filter to a component. Before calling any API in Filter, you must use createFilter to create a Filter instance.

blur

blur(blurRadius: number): Filter

Applies the blur effect to the component.

System capability: SystemCapability.Graphics.Drawing

Parameters

NameTypeMandatoryDescription
blurRadiusnumberYesBlur radius.
The value must be greater than or equal to 0. The larger the radius is, the more blurred the content is.
If the value is 0, the content is not blurred.

Return value

TypeDescription
FilterFilter instance with the blur effect.

Example

filter.blur(20)

VisualEffect

A class that can apply a visual effect to a component. Before calling any API in VisualEffect, you must use createEffect to create a VisualEffect instance.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkGraphics 2D

harmony 鸿蒙BufferHandle

harmony 鸿蒙ColorSpacePrimaries

harmony 鸿蒙DisplaySoloist_ExpectedRateRange

harmony 鸿蒙_drawing

harmony 鸿蒙NativeColorSpaceManager

harmony 鸿蒙NativeDisplaySoloist

harmony 鸿蒙NativeVsync

harmony 鸿蒙NativeWindow

harmony 鸿蒙OH_Drawing_BitmapFormat

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