Skip to main content
Version: v3+

FILL_RECT

Supported from API_LEVEL 2.0. For API compatibility, please refer to API_LEVEL.

fill_rect_sample

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

Create UI Widget

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

const fillRect = createWidget(widget.FILL_RECT, Param)

Types

Param: object

PropertyDescriptionRequiredTypeAPI_LEVEL
xThe x-coordinate of the widgetYESnumber2.0
yThe y-coordinate of the widgetYESnumber2.0
wThe width of the widgetYESnumber2.0
hThe height of the widgetYESnumber2.0
colorThe color of the widgetYESnumber2.0
radiusThe corner radius of the rectangleNOnumber2.0
angleThe rotation angleNOnumber2.0
alphaOpacity, value range 0-255, default 255 (opaque), 0 (transparent)NOnumber3.0
pos_xDrawing area x offset (only works when angle%360!=0)NOnumber4.0
pos_yDrawing area y offset (only works when angle%360!=0)NOnumber4.0
rect_widthWidth of the drawing area (only works when angle%360!=0)NOnumber4.0
rect_heightHeight of the drawing area (only works when angle%360!=0)NOnumber4.0

Property Access Support List

PropertysetPropertygetPropertysettergetter
xYYYY
yYYYY
wYYYY
hYYYY
colorYYYY
radiusYYYY
angleYYYY
pos_xNYNY
pos_yNYNY
rect_widthNNNY
rect_heightNNNY
center_xYYYY
center_yYYYY
alphaYYYY

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
})
})
}
})