Skip to main content
Version: v3

STROKE_RECT

stroke_rect_sample

The stroked rectangle widget adds a stroke on the basis of the filled rectangle component.

Create UI widget

const strokeRect = hmUI.createWidget(hmUI.widget.STROKE_RECT, Param)

Type

Param: object

PropertiesDescriptionRequiredType
xThe x-axis coordinate of the component.YESnumber
yThe y-axis coordinate of the component.YESnumber
wThe width of the component.YESnumber
hThe height of the component.YESnumber
colorThe component's color.YESnumber
radiusThe rectangle's rounded corners.NOnumber
line_widthThe width of stroke.NOnumber
angleRotation angle.NOnumber

Code example

Page({
build() {
const strokeRect = hmUI.createWidget(hmUI.widget.STROKE_RECT, {
x: 125,
y: 125,
w: 230,
h: 150,
radius: 20,
line_width: 4,
color: 0xfc6950
})

strokeRect.addEventListener(hmUI.event.CLICK_DOWN, (info) => {
strokeRect.setProperty(hmUI.prop.MORE, {
y: 200
})
})
}
})