8
8
"tinygo.org/x/drivers"
9
9
)
10
10
11
+ var errEmptyRectangle = errors .New ("tinydraw: empty rectangle" )
12
+
11
13
// Line draws a line between two points
12
14
func Line (display drivers.Displayer , x0 int16 , y0 int16 , x1 int16 , y1 int16 , color color.RGBA ) {
13
15
if x0 == x1 {
@@ -66,7 +68,7 @@ func Line(display drivers.Displayer, x0 int16, y0 int16, x1 int16, y1 int16, col
66
68
// Rectangle draws a rectangle given a point, width and height
67
69
func Rectangle (display drivers.Displayer , x int16 , y int16 , w int16 , h int16 , color color.RGBA ) error {
68
70
if w <= 0 || h <= 0 {
69
- return errors . New ( "empty rectangle" )
71
+ return errEmptyRectangle
70
72
}
71
73
Line (display , x , y , x + w - 1 , y , color )
72
74
Line (display , x , y , x , y + h - 1 , color )
@@ -78,7 +80,7 @@ func Rectangle(display drivers.Displayer, x int16, y int16, w int16, h int16, co
78
80
// FilledRectangle draws a filled rectangle given a point, width and height
79
81
func FilledRectangle (display drivers.Displayer , x int16 , y int16 , w int16 , h int16 , color color.RGBA ) error {
80
82
if w <= 0 || h <= 0 {
81
- return errors . New ( "empty rectangle" )
83
+ return errEmptyRectangle
82
84
}
83
85
for i := x ; i < x + w ; i ++ {
84
86
Line (display , i , y , i , y + h - 1 , color )
0 commit comments