Skip to content

Commit a0356a4

Browse files
committed
feat: borderRadius for Rectangle
1 parent 5e5d5c4 commit a0356a4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/shapes/rectangle.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import { Length, PercentLength, zeroLength } from '@nativescript/core/ui/styling/style-properties';
22
import { layout } from '@nativescript/core/utils/utils';
33
import { Canvas, Rect, RectF, createRectF } from '../canvas';
4-
import Shape, { lengthProperty, percentLengthProperty } from './shape';
4+
import Shape, { lengthProperty, numberProperty, percentLengthProperty } from './shape';
55

66
export { Rect, RectF };
77
export default class Rectangle extends Shape {
88
drawOnCanvas(canvas: Canvas) {
99
// console.log('Rectangle', 'drawOnCanvas');
10-
canvas.drawRect(this.getRect(canvas), this.paint);
10+
if (this.borderRadius) {
11+
canvas.drawRoundRect(this.getRect(canvas), this.borderRadius, this.borderRadius, this.paint);
12+
} else {
13+
canvas.drawRect(this.getRect(canvas), this.paint);
14+
}
1115
}
1216
@percentLengthProperty width: PercentLength;
1317
@percentLengthProperty height: PercentLength;
1418
@lengthProperty left: Length = zeroLength;
1519
@lengthProperty top: Length = zeroLength;
20+
@numberProperty borderRadius: number;
1621

1722
// getRect(canvas: Canvas) {
1823
// const availableWidth = layout.toDevicePixels(canvas.getWidth());

0 commit comments

Comments
 (0)