导入模块。
- import { hdsEffect } from '@kit.UIDesignKit';
设置双边边缘流光效果。
- @Entry
- @Component
- struct Index {
- @State controller: hdsEffect.ShaderEffectController = new hdsEffect.ShaderEffectController();
-
- build() {
- Column() {
- Stack() {
- }
- .visualEffect(new hdsEffect.HdsEffectBuilder()
- .shaderEffect({
- effectType: hdsEffect.EffectType.DUAL_EDGE_FLOW_LIGHT,
- animation: {
- duration: 4000,
- iterations: -1,
- autoPlay: true,
- onFinish: () => {
- console.info('Succeeded in finishing');
- }
- },
- controller: this.controller,
- params: {
- firstEdgeFlowLight: {
- startPos: 0,
- endPos: 1.0,
- color: '#1AD0F1',
- },
- secondEdgeFlowLight: {
- startPos: 0.5,
- endPos: 1.5,
- color: '#FFA4E5',
- }
- }
- })
- .buildEffect())
- .width(200)
- .borderRadius('50%')
- .clip(true)
- .height(200)
- .backgroundColor('#383838')
- }
- .justifyContent(FlexAlign.Center)
- .backgroundColor(Color.Black)
- .width('100%')
- .height('100%')
- }
- }
