v0.0.495
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m44s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m44s
This commit is contained in:
@@ -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()),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user