Move some drawing functionality into internal package

This commit is contained in:
2024-09-20 00:07:32 -04:00
parent 4be5154df0
commit de12ee6bcd
2 changed files with 34 additions and 27 deletions

27
internal/draw.go Normal file
View File

@@ -0,0 +1,27 @@
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())
}