Skip to main content
Version: v3

FILL_RECT

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

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(prop.MORE, Params), you must pass x, y, w, h properties, see the sample code for details.

Create UI widget

import { createWidget, widget } from '@zos/ui'

const fillRect = createWidget(widget.FILL_RECT, Param)

Type

Param: object

PropertiesDescriptionRequiredTypeAPI_LEVEL
xThe x-coordinate of widget.YESnumber3.0
yThe y-coordinate of widget.YESnumber3.0
wThe width of widget.YESnumber3.0
hThe height of the widget.YESnumber3.0
colorThe color of widget.YESnumber3.0
radiusThe radius of widget.NOnumber3.0
angleThe angle of widget.NOnumber3.0
alphaTransparency, value 0 - 255, default value is 255 for opacity, 0 for full transparency.NOnumber3.0

Code example

import { createWidget, widget, prop } from '@zos/ui'

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

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