示例代码如下:
@Entry
@Component
struct FacialContour {
build() {
Column() {
Stack() {
// 相机预览区域
Column() {
}
.width(300)
.height(300)
.borderRadius(150);
Ellipse({ width: '40.96', height: '71.56' })
.margin({
top: 112.68,
left: 29.38,
right: 171.13,
bottom: 87.68
})
.rotate({
angle: '-45.05'
})
.strokeWidth(3)
.stroke(Color.Red)
.strokeDashArray([1, 2])
.fill(Color.Transparent)
.blendMode(BlendMode.CLEAR);
Ellipse({ width: '40.96', height: '71.56' })
.margin({
top: 112.68,
left: 171.13,
right: 29.38,
bottom: 87.68
})
.rotate({
angle: '-134.95'
})
.strokeWidth(3)
.stroke(Color.Red)
.strokeDashArray([1, 2])
.fill(Color.Transparent)
.blendMode(BlendMode.CLEAR);
Ellipse({ width: '143', height: '190' })
.margin({
top: 63,
left: 68,
right: 69,
bottom: 27
})
.fill(Color.Transparent)
.strokeWidth(3)
.stroke(Color.Red)
.strokeDashArray([1, 2])
.blendMode(BlendMode.CLEAR);
Ellipse({ width: '168', height: '174' })
.margin({
top: 26,
left: 56,
right: 56,
bottom: 80
})
.fill(Color.Transparent)
.blendMode(BlendMode.CLEAR)
.strokeWidth(3)
.stroke(Color.Red)
.strokeDashArray([1, 2]);
Circle()
.width(280)
.height(280)
.fill('rgb(0, 0, 0)')
.opacity(0.2)
.strokeWidth(3)
.width(280)
.height(280);
Circle()
.width(300)
.height(300)
.fillOpacity(0)
.strokeWidth(2)
.stroke('#fc29b2e0');
Text('请面部正对摄像头')
.textAlign(TextAlign.Center)
.width(244)
.height(20)
.fontWeight(400)
.fontSize(20)
.lineHeight(20)
.fontColor('rgb(0, 0, 0)')
.offset({ y: 182 });
}
.width(300)
.height(300)
.margin({
top: 106,
left: 30,
right: 30,
bottom: 386
})
.alignContent(Alignment.Center);
}.height('100%').width('100%');
}
}