Skip to main content
Version: v3

FILL_RECT

fill_rect_sample

The Fill Rectangle widget is used to draw a solid color rectangular area.

caution

At this stage, if you change the properties of the widget by means of setProperty(hmUI.prop.MORE, Params), you must pass x, y, w, h properties, see the sample code for details.

Create UI widget

const fillRect = hmUI.createWidget(hmUI.widget.FILL_RECT, Param)

Type

Param: object

PropertiesDescriptionRequiredType
xThe x-coordinate of component.YESnumber
yThe y-coordinate of component.YESnumber
wThe width of component.YESnumber
hThe height of the component.YESnumber
colorThe color of component.YESnumber
radiusThe radius of component.NOnumber
angleThe angle of component.NOnumber

Code example

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

fill_rect.addEventListener(hmUI.event.CLICK_DOWN, (info) => {
fill_rect.setProperty(hmUI.prop.MORE, {
x: 125,
y: 200,
w: 230,
h: 150
})
})
}
})