openharmony 鸿蒙 ts-universal-attributes-point-light-style-sys

2025-06-12 浏览 (1)

Point Light Style (System API)

You can apply a point light style to components.

NOTE

The initial APIs of this module are supported since API version 11. Updates will be marked with a superscript to indicate their earliest API version.

The point light style is only available for the following components: Image, Column, Flex, Row, Stack

PointLightStyle

You apply a point light style by setting the light source that emits illumination and the components to be illuminated.

System API: This is a system API.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
lightSourceLightSourceNoLight source. The light source affects the surrounding components that are marked as illuminable and creates light effects on those components.
Default value: none
illuminatedIlluminatedTypeNoWhether the current component can be illuminated by the light source and the illuminated type.
Default value: IlluminatedType.NONE
bloomnumberNoLuminous intensity of the component. The recommended value range is 0-1.
Default value: 0

LightSource

Each component allows for one light source.

System API: This is a system API.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
positionXDimensionYesX-coordinate of the light source relative to the current component.
positionYDimensionYesY-coordinate of the light source relative to the current component.
positionZDimensionYesHeight of the light source. The higher the light source, the broader the light distribution.
intensitynumberYesIntensity of the light source. The recommended value range is 0-1. When the intensity is 0, the light source does not emit light.
color12+ResourceColorNoLight source color.
Default value: Color.White

Example

// xxx.ets
@Entry
@Component
struct Index {
  @State lightIntensity: number = 0;
  @State bloomValue: number = 0;

  build() {
    Row({ space: 20 }) {
      Flex()
        .pointLight({ illuminated: IlluminatedType.BORDER })
        .backgroundColor(0x307af7)
        .size({ width: 50, height: 50 })
        .borderRadius(25)

      Flex()
        .pointLight({
          lightSource: { intensity: this.lightIntensity, positionX: "50%", positionY: "50%", positionZ: 80 },
          bloom: this.bloomValue
        })
        .animation({ duration: 333 })
        .backgroundColor(0x307af7)
        .size({ width: 50, height: 50 })
        .borderRadius(25)
        .onTouch((event: TouchEvent) => {
          if (event.type === TouchType.Down) {
            this.lightIntensity = 2;
            this.bloomValue = 1;
          } else if (event.type === TouchType.Up||event.type === TouchType.Cancel) {
            this.lightIntensity = 0;
            this.bloomValue = 0;
          }
        })

      Flex()
        .pointLight({ illuminated: IlluminatedType.BORDER_CONTENT })
        .backgroundColor(0x307af7)
        .size({ width: 50, height: 50 })
        .borderRadius(25)
    }
    .justifyContent(FlexAlign.Center)
    .backgroundColor(Color.Black)
    .size({ width: '100%', height: '100%' })
  }
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArcButton

harmony 鸿蒙ArcSlider

harmony 鸿蒙Chip

harmony 鸿蒙ChipGroup

harmony 鸿蒙ComposeListItem

harmony 鸿蒙ComposeTitleBar

harmony 鸿蒙advanced.Counter

harmony 鸿蒙Dialog Box (Dialog)

harmony 鸿蒙DialogV2

harmony 鸿蒙DownloadFileButton

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