@@ -25,7 +25,7 @@ func RectangleFromMinMax[T Number](min, max Point[T]) Rectangle[T] {
2525
2626// RectangleFromSize creates a Rectangle from zero point and size.
2727func RectangleFromSize [T Number ](size Size [T ]) Rectangle [T ] {
28- return Rectangle [ T ]{ P [T ](0 , 0 ), size }
28+ return RectangleFromMin ( P [T ](0 , 0 ), size )
2929}
3030
3131// Translate creates a new Rectangle translated by the given vector.
@@ -38,7 +38,7 @@ func (r Rectangle[T]) MoveTo(point Point[T]) Rectangle[T] {
3838 return Rectangle [T ]{point , r .Size }
3939}
4040
41- // Multiple creates a new Rectangle with size uniformly scaled by the factor.
41+ // Scale creates a new Rectangle with size uniformly scaled by the factor.
4242func (r Rectangle [T ]) Scale (factor float64 ) Rectangle [T ] {
4343 return Rectangle [T ]{r .Center , r .Size .Scale (factor )}
4444}
@@ -68,7 +68,7 @@ func (r Rectangle[T]) Shrink(amount T) Rectangle[T] {
6868 return Rectangle [T ]{r .Center , r .Size .Shrink (amount )}
6969}
7070
71- // Shrink creates a new Rectangle with size reduced by the given amounts along X and Y.
71+ // ShrinkXY creates a new Rectangle with size reduced by the given amounts along X and Y.
7272func (r Rectangle [T ]) ShrinkXY (amountX , amountY T ) Rectangle [T ] {
7373 return Rectangle [T ]{r .Center , r .Size .ShrinkXY (amountX , amountY )}
7474}
@@ -117,9 +117,19 @@ func (r Rectangle[T]) TopRight() Point[T] {
117117 return r .Max ()
118118}
119119
120- // Edges returns the rectangle edges as lines.
120+ // Edges returns the rectangle edges as lines in clockwise order starting from BottomLeft .
121121func (r Rectangle [T ]) Edges () []Line [T ] {
122- return []Line [T ]{}
122+ bl := r .BottomLeft ()
123+ br := r .BottomRight ()
124+ tr := r .TopRight ()
125+ tl := r .TopLeft ()
126+
127+ return []Line [T ]{
128+ L (bl , br ),
129+ L (br , tr ),
130+ L (tr , tl ),
131+ L (tl , bl ),
132+ }
123133}
124134
125135// Vertices returns the polygon vertices in order starting Min point, counter-clockwise.
0 commit comments