Skip to main content
Version: v3+

STROKE_RECT

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

stroke_rect_sample

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

Create UI Widget

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

const strokeRect = createWidget(widget.STROKE_RECT, Param)

Type

Param: object

PropertyDescriptionRequiredTypeAPI_LEVEL
xThe x-axis coordinate of the widgetYESnumber2.0
yThe y-axis coordinate of the widgetYESnumber2.0
wThe width of the widgetYESnumber2.0
hThe height of the widgetYESnumber2.0
colorThe widget's colorYESnumber2.0
radiusThe rectangle's rounded cornersNOnumber2.0
line_widthThe width of strokeNOnumber2.0
angleRotation angleNOnumber2.0
pos_xDrawing area x offset (only effective when angle%360!=0)NOnumber4.0
pos_yDrawing area y offset (only effective when angle%360!=0)NOnumber4.0
rect_widthWidth of the drawing area (only effective when angle%360!=0)NOnumber4.0
rect_heightHeight of the drawing area (only effective when angle%360!=0)NOnumber4.0

Property Access Support List

Property NamesetPropertygetPropertysettergetter
xYYYY
yYYYY
wYYYY
hYYYY
colorYYYY
radiusYYYY
line_widthYYYY
angleYYYY
pos_xNYNY
pos_yNYNY
rect_widthNNNY
rect_heightNNNY

Code Example

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

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

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