1# Image Effects 2 3Image effects include blur, shadow, spherical effect, and much more. 4 5> **NOTE** 6> 7> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8 9## blur 10 11blur(value: number, options?: BlurOptions) 12 13Applies a foreground blur effect to the component. 14 15**Widget capability**: This API can be used in ArkTS widgets since API version 9. 16 17**Atomic service API**: This API can be used in atomic services since API version 11. 18 19**System capability**: SystemCapability.ArkUI.ArkUI.Full 20 21**Parameters** 22 23| Name | Type | Mandatory| Description | 24| --------------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 25| value | number | Yes | Foreground blur effect to apply to the component. The input parameter is the blur radius. The larger the radius is, the more blurred the content is. If the value is **0**, the content is not blurred.| 26| options<sup>11+</sup> | [BlurOptions](ts-appendix-enums.md#bluroptions11) | No | Grayscale parameters. | 27 28## backdropBlur 29 30backdropBlur(value: number, options?: BlurOptions) 31 32Applies a background blur effect to the component. 33 34**Widget capability**: This API can be used in ArkTS widgets since API version 9. 35 36**Atomic service API**: This API can be used in atomic services since API version 11. 37 38**System capability**: SystemCapability.ArkUI.ArkUI.Full 39 40**Parameters** 41 42| Name | Type | Mandatory| Description | 43| --------------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 44| value | number | Yes | Background blur effect to apply to the component. The input parameter is the blur radius. The larger the radius is, the more blurred the background is. If the value is **0**, the background is not blurred.| 45| options<sup>11+</sup> | [BlurOptions](ts-appendix-enums.md#bluroptions11) | No | Grayscale parameters. | 46 47## shadow 48 49shadow(value: ShadowOptions | ShadowStyle) 50 51Applies a shadow effect to the component. 52 53**Widget capability**: Since API version 9, this API is supported in ArkTS widgets. Yet, the [ShadowStyle](ts-universal-attributes-image-effect.md#shadowstyle10) type is not supported in ArkTS widgets. 54 55**Atomic service API**: This API can be used in atomic services since API version 11. 56 57**System capability**: SystemCapability.ArkUI.ArkUI.Full 58 59**Parameters** 60 61| Name| Type | Mandatory| Description | 62| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 63| value | [ShadowOptions](#shadowoptions) \| [ShadowStyle](#shadowstyle10)<sup>10+</sup> | Yes | Shadow of the component.<br>When the value type is **ShadowOptions**, the blur radius, shadow color, and offset along the x-axis and y-axis can be specified.<br>When the value type is **ShadowStyle**, the shadow style can be specified.| 64 65## grayscale 66 67grayscale(value: number) 68 69Applies a grayscale effect to the component. 70 71**Widget capability**: This API can be used in ArkTS widgets since API version 9. 72 73**Atomic service API**: This API can be used in atomic services since API version 11. 74 75**System capability**: SystemCapability.ArkUI.ArkUI.Full 76 77**Parameters** 78 79| Name| Type | Mandatory| Description | 80| ------ | ------ | ---- | ------------------------------------------------------------ | 81| value | number | Yes | Grayscale conversion ratio of the component. If the value is **1.0**, the component is completely converted to grayscale. If the value is **0.0**, the component remains unchanged. Between **0** and **1**, the value applies a linear multiplier on the grayscale effect. The unit is percentage.<br>Default value: **0.0**<br>Value range: [0.0, 1.0]<br>**NOTE**<br>A value less than **0.0** evaluates to the value **0.0**. A value greater than **1.0** evaluates to the value **1.0**.| 82 83## brightness 84 85brightness(value: number) 86 87Applies a brightness effect to the component. 88 89**Widget capability**: This API can be used in ArkTS widgets since API version 9. 90 91**Atomic service API**: This API can be used in atomic services since API version 11. 92 93**System capability**: SystemCapability.ArkUI.ArkUI.Full 94 95**Parameters** 96 97| Name| Type | Mandatory| Description | 98| ------ | ------ | ---- | ------------------------------------------------------------ | 99| value | number | Yes | Brightness of the component. The value **1** indicates no effects. The value **0** indicates the complete darkness. If the value is less than 1, the brightness decreases. If the value is greater than 1, the brightness increases. A larger value indicates a higher brightness. However, if the value is greater than 2, the brightness does not change significantly with the value.<br>Default value: **1.0**<br>Recommended value range: [0, 2]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 9.| 100 101## saturate 102 103saturate(value: number) 104 105Applies a saturation effect to the component. 106 107**Widget capability**: This API can be used in ArkTS widgets since API version 9. 108 109**Atomic service API**: This API can be used in atomic services since API version 11. 110 111**System capability**: SystemCapability.ArkUI.ArkUI.Full 112 113**Parameters** 114 115| Name| Type | Mandatory| Description | 116| ------ | ------ | ---- | ------------------------------------------------------------ | 117| value | number | Yes | Saturation of the component. The saturation is the ratio of the chromatic component to the achromatic component (gray) in a color. If the value is **1**, the original image is displayed. If the value is greater than **1**, a higher percentage of the chromatic component indicates a higher saturation. If the value is less than **1**, a higher percentage of the achromatic component indicates a lower saturation. The unit is percentage.<br>Default value: **1.0**<br>Recommended value range: [0, 50)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.| 118 119## contrast 120 121contrast(value: number) 122 123Applies a contrast effect to the component. 124 125**Widget capability**: This API can be used in ArkTS widgets since API version 9. 126 127**Atomic service API**: This API can be used in atomic services since API version 11. 128 129**System capability**: SystemCapability.ArkUI.ArkUI.Full 130 131**Parameters** 132 133| Name| Type | Mandatory| Description | 134| ------ | ------ | ---- | ------------------------------------------------------------ | 135| value | number | Yes | Contrast of the component. The input parameter is a contrast value. If the value is **1**, the source image is displayed. If the value is greater than 1, a larger value indicates a higher contrast and a clearer image. If the value is less than 1, a smaller value indicates a lower contrast is. If the value is **0**, the image becomes all gray. The unit is percentage.<br>Default value: **1.0**<br>Recommended value range: [0, 10)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.| 136 137## invert 138 139invert(value: number | InvertOptions) 140 141Inverts the image. 142 143**Widget capability**: This API can be used in ArkTS widgets since API version 9. 144 145**Atomic service API**: This API can be used in atomic services since API version 11. 146 147**System capability**: SystemCapability.ArkUI.ArkUI.Full 148 149**Parameters** 150 151| Name| Type | Mandatory| Description | 152| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 153| value | number \| [InvertOptions](#invertoptions11)<sup>11+</sup> | Yes | How the image is inverted.<br>If the value is of the number type, it indicates the inversion ratio. If the value is **1**, the image is completely inverted. If the value is **0**, the image remains unchanged. The unit is percentage.<br>Value range: [0, 1]<br>A value less than 0 evaluates to the value **0**.<br>If the value is of the InvertOptions type, the grayscale value of the background color is compared with the threshold range. If the grayscale value is greater than the upper bound of the threshold range, the **high** value is used. If the grayscale value is less than the lower bound of the threshold range, the **low** value is used. If the grayscale value is within the threshold range, the background color changes linearly from high to low.| 154 155## sepia 156 157sepia(value: number) 158 159Sepia conversion ratio of the component. 160 161**Widget capability**: This API can be used in ArkTS widgets since API version 9. 162 163**Atomic service API**: This API can be used in atomic services since API version 11. 164 165**System capability**: SystemCapability.ArkUI.ArkUI.Full 166 167**Parameters** 168 169| Name| Type | Mandatory| Description | 170| ------ | ------ | ---- | ------------------------------------------------------------ | 171| value | number | Yes | Sepia conversion ratio of the component. If the value is **1**, the image is completely sepia. If the value is **0**, the component remains unchanged. The unit is percentage.| 172 173## hueRotate 174 175hueRotate(value: number | string) 176 177Rotates the hue of the component. 178 179**Widget capability**: This API can be used in ArkTS widgets since API version 9. 180 181**Atomic service API**: This API can be used in atomic services since API version 11. 182 183**System capability**: SystemCapability.ArkUI.ArkUI.Full 184 185**Parameters** 186 187| Name| Type | Mandatory| Description | 188| ------ | -------------------------- | ---- | ------------------------------------------------------------ | 189| value | number \| string | Yes | Hue rotation angle of the component.<br>Default value: **'0deg'**<br>Value range: (-∞, +∞)<br>**NOTE**<br>A rotation of 360 degrees leaves the color unchanged. A rotation of 180 degrees and then -180 degrees also leaves the color unchanged. When the data type is number, the value **90** is equivalent to **'90deg'**.| 190 191## colorBlend<sup>7+</sup> 192 193colorBlend(value: Color | string | Resource) 194 195Applies a color blend effect to the component. 196 197**System capability**: SystemCapability.ArkUI.ArkUI.Full 198 199**Atomic service API**: This API can be used in atomic services since API version 11. 200 201**Widget capability**: This API can be used in ArkTS widgets since API version 9. 202 203**Parameters** 204 205| Name| Type | Mandatory| Description | 206| ------ | ------------------------------------------------------------ | ---- | ---------------------------------------------- | 207| value | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | Yes | Color to blend with the component.| 208 209## linearGradientBlur<sup>12+</sup> 210 211linearGradientBlur(value: number, options: LinearGradientBlurOptions) 212 213Applies a linear gradient foreground blur effect to the component. 214 215**System capability**: SystemCapability.ArkUI.ArkUI.Full 216 217**Parameters** 218 219| Name | Type | Mandatory| Description | 220| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 221| value | number | Yes | Blur radius. A larger value indicates a higher blur degree. If the value is 0, the content is not blurred.<br>Value range: [0, 60]<br>Linear gradient blur consists of two parts: **fractionStops** and **direction**.| 222| options | [LinearGradientBlurOptions](#lineargradientbluroptions12) | Yes | Linear gradient blur effect. | 223 224## renderGroup<sup>10+</sup> 225 226renderGroup(value: boolean) 227 228Sets whether the component and its child components are rendered off the screen and then drawn together with its parent. 229 230**Atomic service API**: This API can be used in atomic services since API version 11. 231 232**System capability**: SystemCapability.ArkUI.ArkUI.Full 233 234**Parameters** 235 236| Name| Type | Mandatory| Description | 237| ------ | ------- | ---- | ------------------------------------------------------------ | 238| value | boolean | Yes | Whether the component and its child components are rendered off the screen and then drawn together with its parent. If the opacity of the component is not 1, the drawing effect may vary depending on the value.<br>Default value: **false**| 239 240## blendMode<sup>11+</sup> 241 242blendMode(value: BlendMode, type?: BlendApplyType) 243 244Defines how the component's content (including the content of it child components) is blended with the existing content on the canvas (possibly offscreen canvas) below. 245 246**Widget capability**: This API can be used in ArkTS widgets since API version 11. 247 248**System capability**: SystemCapability.ArkUI.ArkUI.Full 249 250**Parameters** 251 252| Name| Type | Mandatory| Description | 253| ------ | ------------------------------- | ---- | ------------------------------------------------------------ | 254| value | [BlendMode](#blendmode11) | Yes | Blend mode.<br>Default value: **BlendMode.NONE** | 255| type | [BlendApplyType](ts-appendix-enums.md#blendapplytype11) | No | Whether the blend mode is implemented offscreen.<br>Default value: **BlendApplyType.FAST**<br>**NOTE**<br>1. Available options:<br>**BlendApplyType.FAST**: The blend mode is not implemented offscreen.<br>2. **BlendApplyType.OFFSCREEN**: The component's content (including the content of it child components) is drawn on the offscreen canvas, and then blended with the existing content on the canvas in the specified blend mode. | 256 257## useShadowBatching<sup>11+</sup> 258 259useShadowBatching(value: boolean) 260 261Sets whether to draw shadows of child nodes in the component at the same layer, so that the shadows of elements at the same layer overlap. 262 263**Atomic service API**: This API can be used in atomic services since API version 12. 264 265**System capability**: SystemCapability.ArkUI.ArkUI.Full 266 267**Parameters** 268 269| Name| Type | Mandatory| Description | 270| ------ | ------- | ---- | ------------------------------------------------------------ | 271| value | boolean | Yes | Whether to draw shadows of child nodes in the component at the same layer, so that the shadows of elements at the same layer overlap.<br>Default value: **false**<br>**NOTE**<br>1. When this feature is disabled (default), if the shadow radius of a child node is large, the shadows of the child nodes may overlap. This overlap issue does not occur when the feature is enabled.<br>2. Avoid nesting **useShadowBatching**. When used in nested mode, **useShadowBatching** takes effect for the current child node only and cannot be recursively used.| 272 273## sphericalEffect<sup>12+</sup> 274 275sphericalEffect(value: number) 276 277Applies a spherical effect to the component. 278 279**System capability**: SystemCapability.ArkUI.ArkUI.Full 280 281**Parameters** 282 283| Name| Type | Mandatory| Description | 284| ------ | ------ | ---- | ------------------------------------------------------------ | 285| value | number | Yes | Spherical degree of the component.<br>The value ranges from 0 to 1.<br>**NOTE**<br>1. If the value is **0**, the component remains unchanged. If the value is 1, the component is completely spherical. Between **0** and **1**, a larger value indicates a higher spherical degree.<br>A value less than 0 is handled as the value **0**. A value greater than 1 is handled as the value **1**.<br>2. If a component image is loaded asynchronously, the spherical effect is not supported. For example, the **Image** component uses asynchronous loading by default, which means that **syncLoad** must be set to **true** to apply the spherical effect. However, this setting is not recommended. Asynchronous loading is also used for **backgroundImage**. Therefore, if **backgroundImage** is set, the spherical effect is not supported.<br>3. If the shadow effect is set for a component, the spherical effect is not supported.<br>4. If the value is greater than 0, the component is frozen and not updated, and its content is drawn to the transparent offscreen buffer. To update the component attributes, set the value to **0**.| 286 287## lightUpEffect<sup>12+</sup> 288 289lightUpEffect(value: number) 290 291Applies a light up effect to the component. 292 293**System capability**: SystemCapability.ArkUI.ArkUI.Full 294 295**Parameters** 296 297| Name| Type | Mandatory| Description | 298| ------ | ------ | ---- | ------------------------------------------------------------ | 299| value | number | Yes | Light up degree of the component.<br>The value ranges from 0 to 1.<br>If the value is **0**, the component is dark. If the value is **1**, the component is fully illuminated. Between **0** and **1**, a larger value indicates higher luminance. A value less than 0 is handled as the value **0**. A value greater than 1 is handled as the value **1**.| 300 301## pixelStretchEffect<sup>12+</sup> 302 303pixelStretchEffect(options: PixelStretchEffectOptions) 304 305Applies a pixel stretch effect to the component. 306 307**System capability**: SystemCapability.ArkUI.ArkUI.Full 308 309**Parameters** 310 311| Name | Type | Mandatory| Description | 312| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 313| options | [PixelStretchEffectOptions](ts-types.md#pixelstretcheffectoptions10) | Yes | Pixel stretch effect options.<br>The value includes the length by which a pixel is stretched toward the four edges.<br>**NOTE**<br>1. If the length is a positive value, the original image is stretched, and the image size increases. The edge pixels grow by the set length toward the top, bottom, left, and right edges.<br>2. If the length is a negative value, the original image shrinks as follows, but the image size remains unchanged:<br>Shrinking mode:<br>(1) The image shrinks from the four edges by the absolute value of length set through **options**.<br>(2) The image is stretched back to the original size with edge pixels.<br>3. Constraints on **options**:<br>(1) The length values for the four edges must be all positive or all negative. That is, the four edges are stretched or shrink at the same time in the same direction.<br>(2) The length values must all be a percentage or a specific value. Combined use of the percentage and specific value is not allowed.<br>(3) If the input value is invalid, the image is displayed as {0, 0, 0, 0}, that is, the image is the same as the original image.| 314 315## systemBarEffect<sup>12+</sup> 316 317systemBarEffect() 318 319Applies a system bar effect to the component, which means to invert colors based on the background and add a blur. 320 321**System capability**: SystemCapability.ArkUI.ArkUI.Full 322 323 324## ShadowOptions 325 326Provides the shadow attributes, including the blur radius, color, and offset along the x-axis and y-axis. 327 328 329**System capability**: SystemCapability.ArkUI.ArkUI.Full 330 331**Widget capability**: This API can be used in ArkTS widgets since API version 9. 332 333| Name | Type | Mandatory | Description | 334| ------- | ---------------------------------------- | ---- | ---------------------------------------- | 335| radius | number \| [Resource](ts-types.md#resource) | Yes | Blur radius of the shadow.<br>Value range: [0, +∞)<br>Unit: px<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>To use a value in the vp unit, call [vp2px](ts-pixel-units.md#pixel-unit-conversion) to convert it into px.<br>If **radius** is of the Resource type, its value must be of the number type.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 336| type<sup>10+</sup> | [ShadowType<sup>10+</sup>](ts-appendix-enums.md#shadowtype10) | No | Shadow type.<br>Default value: **COLOR**<br>**Atomic service API**: This API can be used in atomic services since API version 11. | 337| color | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource)\| [ColoringStrategy<sup>10+</sup> ](ts-types.md#coloringstrategy10) | No | Color of the shadow.<br>The default color is black.<br>**NOTE**<br>Since API version 11, this API supports **ColoringStrategy**, which cannot be used with ArkTS widgets or the [textShadow](ts-basic-components-text.md#attributes) attribute.<br>With **ColoringStrategy**, the average color or primary color can be obtained, and the obtained color is applied to the shadow drawing area.<br>The **'average'** string can be used to trigger the mode for obtaining the average color, and the **'primary'** string for obtaining the primary color.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 338| offsetX | number \| [Resource](ts-types.md#resource) | No | Offset of the shadow along the x-axis.<br>Default value: **0**<br>Unit: px<br>**NOTE**<br>To use a value in the vp unit, call [vp2px](ts-pixel-units.md#pixel-unit-conversion) to convert it into px.<br>If **offsetX** is of the Resource type, its value must be of the number type.<br> **Atomic service API**: This API can be used in atomic services since API version 11.| 339| offsetY | number \| [Resource](ts-types.md#resource) | No | Offset of the shadow along the y-axis.<br>Default value: **0**<br>Unit: px<br>**NOTE**<br>To use a value in the vp unit, call [vp2px](ts-pixel-units.md#pixel-unit-conversion) to convert it into px.<br>If **offsetY** is of the Resource type, its value must be of the number type.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 340| fill<sup>11+</sup> | boolean | No | Whether to fill the inside of the component with shadow.<br>The default value is **false**.<br>**NOTE**<br>This attribute does not take effect in [textShadow](ts-basic-components-text.md#attributes).<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 341 342## ShadowStyle<sup>10+</sup> 343 344**Atomic service API**: This API can be used in atomic services since API version 11. 345 346| Name | Description | 347| ----------------- | ------ | 348| OUTER_DEFAULT_XS | Mini shadow. | 349| OUTER_DEFAULT_SM | Small shadow. | 350| OUTER_DEFAULT_MD | Medium shadow. | 351| OUTER_DEFAULT_LG | Large shadow. | 352| OUTER_FLOATING_SM | Floating small shadow.| 353| OUTER_FLOATING_MD | Floating medium shadow.| 354 355## BlendMode<sup>11+</sup> 356 357> **NOTE** 358> 359> In the **blendMode** enums, **s** indicates the source pixel, **d** indicates the target pixel, **sa** indicates the opacity of the source pixel, **da** indicates the opacity of the target pixel, **r** indicates the pixel after blending, and **ra** indicates the opacity of the pixel after blending. 360 361**Widget capability**: This API can be used in ArkTS widgets since API version 11. 362 363| Name | Description | 364| ---------------| ------ | 365| NONE | The top image is superimposed on the bottom image without any blending. | 366| CLEAR | The target pixels covered by the source pixels are erased by being turned to completely transparent. | 367| SRC | r = s: Only the source pixels are displayed. | 368| DST | r = d: Only the target pixels are displayed. | 369| SRC_OVER | r = s + (1 - sa) * d: The source pixels are blended based on opacity and cover the target pixels. | 370| DST_OVER | r = d + (1 - da) * s: The target pixels are blended based on opacity and cover on the source pixels. | 371| SRC_IN | r = s * da: Only the part of the source pixels that overlap with the target pixels is displayed. | 372| DST_IN | r = d * sa: Only the part of the target pixels that overlap with the source pixels is displayed. | 373| SRC_OUT | r = s * (1 - da): Only the part of the source pixels that do not overlap with the target pixels is displayed. | 374| DST_OUT | r = d * (1 - sa): Only the part of the target pixels that do not overlap with the source pixels is displayed. | 375| SRC_ATOP | r = s * da + d * (1 - sa): The part of the source pixels that overlap with the target pixels is displayed and the part of the target pixels that do not overlap with the source pixels are displayed. | 376| DST_ATOP | r = d * sa + s * (1 - da): The part of the target pixels that overlap with the source pixels and the part of the source pixels that do not overlap with the target pixels are displayed. | 377| XOR | r = s * (1 - da) + d * (1 - sa): Only the non-overlapping part between the source pixels and the target pixels is displayed. | 378| PLUS | r = min(s + d, 1): New pixels resulting from adding the source pixels to the target pixels are displayed. | 379| MODULATE | r = s * d: New pixels resulting from multiplying the source pixels with the target pixels are displayed. | 380| SCREEN | r = s + d - s * d: Pixels are blended by adding the source pixels to the target pixels and subtracting the product of their multiplication. | 381| OVERLAY | The MULTIPLY or SCREEN mode is used based on the target pixels. | 382| DARKEN | rc = s + d - max(s * da, d * sa), ra = kSrcOver: When two colors overlap, whichever is darker is used. | 383| LIGHTEN | rc = s + d - min(s * da, d * sa), ra = kSrcOver: The darker of the pixels (source and target) is used. | 384| COLOR_DODGE | The colors of the target pixels are lightened to reflect the source pixels. | 385| COLOR_BURN | The colors of the target pixels are darkened to reflect the source pixels. | 386| HARD_LIGHT | The MULTIPLY or SCREEN mode is used, depending on the source pixels. | 387| SOFT_LIGHT | The LIGHTEN or DARKEN mode is used, depending on the source pixels. | 388| DIFFERENCE | rc = s + d - 2 * (min(s * da, d * sa)), ra = kSrcOver: The final pixel is the result of subtracting the darker of the two pixels (source and target) from the lighter one. | 389| EXCLUSION | rc = s + d - two(s * d), ra = kSrcOver: The final pixel is similar to <b>DIFFERENCE</b>, but with less contrast. | 390| MULTIPLY | r = s * (1 - da) + d * (1 - sa) + s * d: The final pixel is the result of multiplying the source pixel by the target pixel. | 391| HUE | The resultant image is created with the luminance and saturation of the source image and the hue of the target image. | 392| SATURATION | The resultant image is created with the luminance and hue of the target image and the saturation of the source image. | 393| COLOR | The resultant image is created with the saturation and hue of the source image and the luminance of the target image. | 394| LUMINOSITY | The resultant image is created with the saturation and hue of the target image and the luminance of the source image. | 395 396## LinearGradientBlurOptions<sup>12+</sup> 397 398| Name | Type | Mandatory | Description | 399| ------------- | ----------------------------------------------------------- | ----- | ------------------------------------------------------------ | 400| fractionStops | Array\<[FractionStop](#fractionstop12)> | Yes | Gradient blur stops. The value is a set of binary arrays, each of which indicates [blur degree, blur position] and consists of numbers ranging from 0 to 1 (those less than 0 evaluate to **0**, and those greater than 1 evaluate to **1**). The blur positions in the arrays must be in strict ascending order. Noncompliance will be logged. For the blur settings to take effect, the number of binary arrays must be greater than or equal to 2.| 401| direction | [GradientDirection](ts-appendix-enums.md#gradientdirection) | Yes | Gradient blur direction.<br>Default value:<br>GradientDirection.Bottom | 402 403## FractionStop<sup>12+</sup> 404 405FractionStop = [ number, number ] 406 407Defines a gradient blur stop. 408 409**System capability**: SystemCapability.ArkUI.ArkUI.Full 410 411| Value Range | Description | 412| ------------- | ---------------------------------------------------------- | 413| number | Blur degree, represented by a fraction. The value **1** means opaque, and **0** means completely transparent.<br>Value range: [0, 1] | 414| number | Stop position. The value **1** indicates the end position and **0** the end position.<br> Value range: [0, 1]| 415 416## InvertOptions<sup>11+</sup> 417 418Describes the options for inverting the foreground color. 419 420**Atomic service API**: This API can be used in atomic services since API version 12. 421 422| Name | Type | Mandatory | Description | 423| -------------- | ------ | ----- | ------------------------------------------ | 424| low | number | Yes | Value when the background color is greater than the grayscale threshold. | 425| high | number | Yes | Value when the background color is less than the grayscale threshold. | 426| threshold | number | Yes | Grayscale threshold. | 427| thresholdRange | number | Yes | Threshold value range.<br>**NOTE**<br>This range defines the upper and lower bounds of the grayscale threshold. The grayscale value changes linearly from high to low within the range.| 428 429## freeze<sup>12+</sup> 430 431freeze(value: boolean) 432 433Sets whether to freeze the component. A frozen component can no longer be changed once it and its child components are rendered off the screen: Its attributes cannot be updated across renders. 434 435**System capability**: SystemCapability.ArkUI.ArkUI.Full 436 437**Parameters** 438 439| Name| Type | Mandatory| Description | 440| ------ | ------- | ---- | ------------------------------------------------------------ | 441| value | boolean | Yes | Whether to freeze the component. A frozen component can no longer be changed once it and its child components are rendered off the screen: Its attributes cannot be updated across renders. If the opacity of the component is not 1, the drawing effect may vary depending on the value.<br>Default value: **false**| 442 443## Example 444 445### Example 1 446This example uses **blur** to apply a foreground blur effect and **backdropBlur** to apply a background blur effect. 447```ts 448// xxx.ets 449@Entry 450@Component 451struct BlurEffectsExample { 452 build() { 453 Column({ space: 10 }) { 454 // Blur the font. 455 Text('font blur').fontSize(15).fontColor(0xCCCCCC).width('90%') 456 Flex({ alignItems: ItemAlign.Center }) { 457 Text('original text').margin(10) 458 Text('blur text') 459 .blur(5).margin(10) 460 Text('blur text') 461 .blur(10).margin(10) 462 Text('blur text') 463 .blur(15).margin(10) 464 }.width('90%').height(40) 465 .backgroundColor(0xF9CF93) 466 467 468 // Blur the background. 469 Text('backdropBlur').fontSize(15).fontColor(0xCCCCCC).width('90%') 470 Text() 471 .width('90%') 472 .height(40) 473 .fontSize(16) 474 .backdropBlur(3) 475 .backgroundImage($r('app.media.image')) 476 .backgroundImageSize({ width: 1200, height: 160 }) 477 }.width('100%').margin({ top: 5 }) 478 } 479} 480``` 481 482 483 484### Example 2 485This example applies different image effects. 486```ts 487// xxx.ets 488@Entry 489@Component 490struct ImageEffectsExample { 491 build() { 492 Column({ space: 5 }) { 493 // Apply the shadow effect. 494 Text('shadow').fontSize(15).fontColor(0xCCCCCC).width('90%') 495 Image($r('app.media.image')) 496 .width('90%') 497 .height(30) 498 .shadow({ radius: 10, color: Color.Green, offsetX: 20, offsetY: 20 }) 499 500 // Add the internal shadow effect. 501 Text('shadow').fontSize(15).fontColor(0xCCCCCC).width('90%') 502 Image($r('app.media.image')) 503 .width('90%') 504 .height(30) 505 .shadow({ radius: 5, color: Color.Green, offsetX: 20, offsetY: 20,fill:true }).opacity(0.5) 506 507 // Apply the grayscale effect. The grayscale value ranges from 0 to 1. The closer the grayscale value is to 1, the more obvious the grayscale effect is. 508 Text('grayscale').fontSize(15).fontColor(0xCCCCCC).width('90%') 509 Image($r('app.media.image')).width('90%').height(30).grayscale(0.3) 510 Image($r('app.media.image')).width('90%').height(30).grayscale(0.8) 511 512 // Apply the brightness effect. The value 1 indicates no effects. If the value is less than 1, the brightness decreases. If the value is greater than 1, the brightness increases. 513 Text('brightness').fontSize(15).fontColor(0xCCCCCC).width('90%') 514 Image($r('app.media.image')).width('90%').height(30).brightness(1.2) 515 516 // Apply the saturation effect. If the value is 1, the source image is displayed. 517 Text('saturate').fontSize(15).fontColor(0xCCCCCC).width('90%') 518 Image($r('app.media.image')).width('90%').height(30).saturate(2.0) 519 Image($r('app.media.image')).width('90%').height(30).saturate(0.7) 520 521 // Apply the contrast effect. If the value is 1, the source image is displayed. If the value is greater than 1, a larger value indicates a higher contrast and a clearer image. If the value is less than 1, a smaller value indicates a lower contrast is. 522 Text('contrast').fontSize(15).fontColor(0xCCCCCC).width('90%') 523 Image($r('app.media.image')).width('90%').height(30).contrast(2.0) 524 Image($r('app.media.image')).width('90%').height(30).contrast(0.8) 525 526 // Invert the image. 527 Text('invert').fontSize(15).fontColor(0xCCCCCC).width('90%') 528 Image($r('app.media.image')).width('90%').height(30).invert(0.2) 529 Image($r('app.media.image')).width('90%').height(30).invert(0.8) 530 531 // Apply the color blend effect. 532 Text('colorBlend').fontSize(15).fontColor(0xCCCCCC).width('90%') 533 Image($r('app.media.image')).width('90%').height(30).colorBlend(Color.Green) 534 Image($r('app.media.image')).width('90%').height(30).colorBlend(Color.Blue) 535 536 // Convert the image color to sepia. 537 Text('sepia').fontSize(15).fontColor(0xCCCCCC).width('90%') 538 Image($r('app.media.image')).width('90%').height(30).sepia(0.8) 539 540 // Apply the hue rotation effect. 541 Text('hueRotate').fontSize(15).fontColor(0xCCCCCC).width('90%') 542 Image($r('app.media.image')).width('90%').height(30).hueRotate(90) 543 }.width('100%').margin({ top: 5 }) 544 } 545} 546``` 547 548 549 550 551### Example 3 552 553This example applies a linear gradient blur effect to a component. 554 555```ts 556// xxx.ets 557@Entry 558@Component 559struct ImageExample1 { 560 private_resource1:Resource = $r('app.media.testlinearGradientBlurOrigin') 561 @State image_src: Resource = this.private_resource1 562 build() { 563 Column() { 564 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { 565 Row({ space: 5 }) { 566 Image(this.image_src) 567 .linearGradientBlur(60, { fractionStops: [[0,0],[0,0.33],[1,0.66],[1,1]], direction: GradientDirection.Bottom }) 568 } 569 } 570 } 571 } 572} 573 574``` 575 576 577 578### Example 4 579This example shows how to use **renderGroup**: 580```ts 581// xxx.ets 582@Component 583struct Component1 { 584 @Prop renderGroupValue: boolean; 585 build() { 586 Row() { 587 Row() { 588 Row() 589 .backgroundColor(Color.Black) 590 .width(100) 591 .height(100) 592 .opacity(1) 593 } 594 .backgroundColor(Color.White) 595 .width(150) 596 .height(150) 597 .justifyContent(FlexAlign.Center) 598 .opacity(0.6) 599 .renderGroup(this.renderGroupValue) 600 } 601 .backgroundColor(Color.Black) 602 .width(200) 603 .height(200) 604 .justifyContent(FlexAlign.Center) 605 .opacity(1) 606 } 607} 608@Entry 609@Component 610struct RenderGroupExample { 611 build() { 612 Column() { 613 Component1({renderGroupValue: true}) 614 .margin(20) 615 Component1({renderGroupValue: false}) 616 .margin(20) 617 } 618 .width("100%") 619 .height("100%") 620 .alignItems(HorizontalAlign.Center) 621 } 622} 623``` 624 625 626 627### Example 5 628This example shows how to use **blendMode** alone: 629```ts 630// xxx.ets 631@Entry 632@Component 633struct Index { 634 build() { 635 Column() { 636 Text("blendMode") 637 .fontSize(20) 638 .fontWeight(FontWeight.Bold) 639 .fontColor('#ffff0101') 640 Row() { 641 Circle() 642 .width(200) 643 .height(200) 644 .fill(Color.Green) 645 .position({ x: 50, y: 50 }) 646 Circle() 647 .width(200) 648 .height(200) 649 .fill(Color.Blue) 650 .position({ x: 150, y: 50 }) 651 } 652 .blendMode(BlendMode.OVERLAY,BlendApplyType.OFFSCREEN) 653 .alignItems(VerticalAlign.Center) 654 .height(300) 655 .width('100%') 656 } 657 .height('100%') 658 .width('100%') 659 .backgroundImage($r('app.media.image')) 660 .backgroundImageSize(ImageSize.Cover) 661 } 662} 663``` 664 665<br>BlendMode.OVERLAY,BlendApplyType.OFFSCREEN<br> 666 667<br>**blendMode** can be used with offscreen rendering to produce different effects. 668 669### Example 6 670 671This example uses **blendMode** with **backgroundEffect** to implement the gradient effect of text and images.<br> 672If unwanted lines appear, make sure the sizes of the two owning components of **blendMode** are the same. If the issue persists, the component bounds may have fallen on the floating-point coordinates. In this case, set the universal attribute [pixelRound](ts-universal-attributes-layout-constraints.md#pixelRound11) to align the component bounds on both sides of the unwanted lines with the integer pixel coordinates. 673 674```ts 675// xxx.ets 676@Entry 677@Component 678struct Index { 679 @State shColor: Color = Color.White; 680 @State sizeDate: number = 20; 681 @State rVal: number = 255; 682 @State gVal: number = 255; 683 @State bVal: number = 255; 684 @State aVal: number = 0.1; 685 @State rad: number = 40; 686 @State satVal: number = 0.8; 687 @State briVal: number = 1.5; 688 build() { 689 Stack() { 690 Image($r('app.media.image')) 691 Column() { 692 Column({ space: 0 }) { 693 Column() { 694 Text('11') 695 .fontSize(144) 696 .fontWeight(FontWeight.Bold) 697 .fontColor('rgba(255,255,255,1)') 698 .fontFamily('HarmonyOS-Sans-Digit') 699 .maxLines(1) 700 .lineHeight(120 * 1.25) 701 .height(120 * 1.25) 702 .letterSpacing(4 * 1.25) 703 Text('42') 704 .fontSize(144) 705 .fontWeight(FontWeight.Bold) 706 .fontColor('rgba(255,255,255,1)') 707 .fontFamily('HarmonyOS-Sans-Digit') 708 .maxLines(1) 709 .lineHeight(120 * 1.25) 710 .height(120 * 1.25) 711 .letterSpacing(4 * 1.25) 712 .shadow({ 713 color: 'rgba(0,0,0,0)', 714 radius: 20, 715 offsetX: 0, 716 offsetY: 0 717 }) 718 Row() { 719 Text ('October 16') 720 .fontSize(this.sizeDate) 721 .height(22) 722 .fontWeight('medium') 723 .fontColor('rgba(255,255,255,1)') 724 Text('Monday') 725 .fontSize(this.sizeDate) 726 .height(22) 727 .fontWeight('medium') 728 .fontColor('rgba(255,255,255,1)') 729 } 730 } 731 .blendMode(BlendMode.DST_IN, BlendApplyType.OFFSCREEN) 732 .pixelRound({ 733 start: PixelRoundCalcPolicy.FORCE_FLOOR , 734 top: PixelRoundCalcPolicy.FORCE_FLOOR , 735 end: PixelRoundCalcPolicy.FORCE_CEIL, 736 bottom: PixelRoundCalcPolicy.FORCE_CEIL 737 }) 738 } 739 .blendMode(BlendMode.SRC_OVER, BlendApplyType.OFFSCREEN) 740 .backgroundEffect({ 741 radius: this.rad, 742 saturation: this.satVal, 743 brightness: this.briVal, 744 color: this.getVolumeDialogWindowColor() 745 }) 746 .justifyContent(FlexAlign.Center) 747 .pixelRound({ 748 start: PixelRoundCalcPolicy.FORCE_FLOOR , 749 top: PixelRoundCalcPolicy.FORCE_FLOOR , 750 end: PixelRoundCalcPolicy.FORCE_CEIL, 751 bottom: PixelRoundCalcPolicy.FORCE_CEIL 752 }) 753 } 754 } 755 } 756 getVolumeDialogWindowColor(): ResourceColor | string { 757 return `rgba(${this.rVal.toFixed(0)}, ${this.gVal.toFixed(0)}, ${this.bVal.toFixed(0)}, ${this.aVal.toFixed(0)})`; 758 } 759} 760``` 761 762 763 764### Example 7 765This example shows how to use **InvertOptions**: 766```ts 767// xxx.ets 768 @Entry 769 @Component 770 struct Index { 771 build() { 772 Stack() { 773 Column() 774 Stack(){ 775 Image($r('app.media.r')).width('100%') 776 Column(){ 777 Column().width("100%").height(30).invert({ 778 low:0, 779 high:1, 780 threshold:0.5, 781 thresholdRange:0.2 782 }) 783 Column().width("100%").height(30).invert({ 784 low:0.2, 785 high:0.5, 786 threshold:0.3, 787 thresholdRange:0.2 788 }) 789 } 790 } 791 .width('100%') 792 .height('100%') 793 } 794 } 795 } 796 797``` 798 799 800 801### Example 8 802This example shows how to use **UseShadowBatching** with **shadow** to ensure that shadows at the same layer do not overlap: 803```ts 804// xxx.ets 805@Entry 806@Component 807struct UseShadowBatchingExample { 808 build() { 809 Column() { 810 Column({ space: 10 }) { 811 Stack() { 812 813 }.width('90%').height(50).margin({ top: 5 }).backgroundColor(0xFFE4C4) 814 .shadow({ radius: 120, color: Color.Green, offsetX: 0, offsetY: 0 }) 815 .align(Alignment.TopStart).shadow({ radius: 120, color: Color.Green, offsetX: 0, offsetY: 0 }) 816 817 Stack() { 818 819 }.width('90%').height(50).margin({ top: 5 }).backgroundColor(0xFFE4C4) 820 .align(Alignment.TopStart).shadow({ radius: 120, color: Color.Red, offsetX: 0, offsetY: 0 }) 821 .width('90%') 822 .backgroundColor(Color.White) 823 824 Column() { 825 Text() 826 .fontWeight(FontWeight.Bold) 827 .fontSize(20) 828 .fontColor(Color.White) 829 } 830 .justifyContent(FlexAlign.Center) 831 .width(150) 832 .height(150) 833 .borderRadius(10) 834 .backgroundColor(0xf56c6c) 835 .shadow({ radius: 300, color: Color.Yellow, offsetX: 0, offsetY: 0 }) 836 837 Column() { 838 Text() 839 .fontWeight(FontWeight.Bold) 840 .fontSize(20) 841 .fontColor(Color.White) 842 } 843 .justifyContent(FlexAlign.Center) 844 .width(150) 845 .height(150) 846 .backgroundColor(0x67C23A) 847 .borderRadius(10) 848 .translate({ y: -50}) 849 .shadow({ radius: 220, color: Color.Blue, offsetX: 0, offsetY: 0 }) 850 } 851 .useShadowBatching(true) 852 } 853 .width('100%').margin({ top: 5 }) 854 } 855} 856``` 857 858 859 860### Example 9 861 862This example applies a spherical effect to a component. 863 864```ts 865// xxx.ets 866@Entry 867@Component 868struct SphericalEffectExample { 869 build() { 870 Stack() { 871 TextInput({placeholder: "Enter a percentage."}) 872 .width('50%') 873 .height(35) 874 .type(InputType.Number) 875 .enterKeyType(EnterKeyType.Done) 876 .caretColor(Color.Red) 877 .placeholderColor(Color.Blue) 878 .placeholderFont({ 879 size: 20, 880 style: FontStyle.Italic, 881 weight: FontWeight.Bold 882 }) 883 .sphericalEffect(0.5) 884 }.alignContent(Alignment.Center).width("100%").height("100%") 885 } 886} 887 888``` 889 890Below is how the component looks with the spherical effect applied. 891 892 893 894Below is how the component looks without the spherical effect applied. 895 896 897 898### Example 10 899 900This example applies a light up effect to a component. 901 902```ts 903// xxx.ets 904@Entry 905@Component 906struct LightUpExample { 907 build() { 908 Stack() { 909 Text('This is the text content with letterSpacing 0.') 910 .letterSpacing(0) 911 .fontSize(12) 912 .border({ width: 1 }) 913 .padding(10) 914 .width('50%') 915 .lightUpEffect(0.6) 916 }.alignContent(Alignment.Center).width("100%").height("100%") 917 } 918} 919 920``` 921 922Below is how the component looks with the light up effect applied. 923 924 925 926Below is how the component looks with **lightUpEffect** set to **0.2**: 927 928 929 930Below is how the component looks without the light up effect applied. 931 932 933 934### Example 11 935 936This example applies a pixel stretch effect to a component. 937 938```ts 939// xxx.ets 940@Entry 941@Component 942struct PixelStretchExample { 943 build() { 944 Stack() { 945 Text('This is the text content with letterSpacing 0.') 946 .letterSpacing(0) 947 .fontSize(12) 948 .border({ width: 1 }) 949 .padding(10) 950 .clip(false) 951 .width('50%') 952 .pixelStretchEffect({top:10,left:10,right:10,bottom:10 }) 953 }.alignContent(Alignment.Center).width("100%").height("100%") 954 } 955} 956 957``` 958 959Below is how the component looks with the pixel stretch effect applied. 960 961 962 963Below is how the component looks without the pixel stretch effect applied. 964 965 966 967 968### Example 12 969 970This example applies a system bar effect to a component. 971 972```ts 973// xxx.ets 974@Entry 975@Component 976struct Index { 977 build() { 978 Column() { 979 Stack(){ 980 Image($r('app.media.testImage')).width('100%').height('100%') 981 Column().width(150).height(10) 982 .systemBarEffect() 983 .border({radius:5}) 984 .margin({bottom:80}) 985 }.alignContent(Alignment.Center) 986 } 987 } 988} 989 990``` 991 992Below is how the component looks with the system bar effect applied. 993 994 995