v0.0.495
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m44s

This commit is contained in:
2024-08-07 14:00:02 +02:00
parent b78a468632
commit 133aeb8374
3 changed files with 17 additions and 6 deletions

View File

@@ -1,5 +1,7 @@
package imageext
import "image"
type Rectangle struct {
X float64
Y float64
@@ -22,3 +24,12 @@ func (r PercentageRectangle) Of(ref Rectangle) Rectangle {
H: r.H * ref.H,
}
}
func calcRelativeRect(inner image.Rectangle, outer image.Rectangle) PercentageRectangle {
return PercentageRectangle{
X: float64(inner.Min.X-outer.Min.X) / float64(outer.Dx()),
Y: float64(inner.Min.Y-outer.Min.Y) / float64(outer.Dy()),
W: float64(inner.Dx()) / float64(outer.Dx()),
H: float64(inner.Dy()) / float64(outer.Dy()),
}
}