28 lines
731 B
Go
28 lines
731 B
Go
package internal
|
|
|
|
import "image"
|
|
import "image/draw"
|
|
import "image/color"
|
|
import "golang.org/x/image/math/fixed"
|
|
|
|
func DrawRectangleOutline (destination draw.Image, bounds image.Rectangle, col color.Color) {
|
|
for x := bounds.Min.X; x < bounds.Max.X; x ++ {
|
|
destination.Set(x, bounds.Min.Y, col)
|
|
}
|
|
for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
|
|
destination.Set(bounds.Min.X, y, col)
|
|
destination.Set(bounds.Max.X - 1, y, col)
|
|
}
|
|
for x := bounds.Min.X; x < bounds.Max.X; x ++ {
|
|
destination.Set(x, bounds.Max.Y - 1, col)
|
|
}
|
|
}
|
|
|
|
func RoundRect (rectangle fixed.Rectangle26_6) image.Rectangle {
|
|
return image.Rect (
|
|
rectangle.Min.X.Round(),
|
|
rectangle.Min.Y.Round(),
|
|
rectangle.Max.X.Round(),
|
|
rectangle.Max.Y.Round())
|
|
}
|