github.com/rajveermalviya/gamen@v0.1.2-0.20220930195403-9be15877c1aa/dpi/physical.go (about) 1 package dpi 2 3 import "golang.org/x/exp/constraints" 4 5 type PhysicalPosition[T constraints.Integer | constraints.Float] struct { 6 X, Y T 7 } 8 9 type PhysicalSize[T constraints.Integer | constraints.Float] struct { 10 Width, Height T 11 } 12 13 func (s PhysicalSize[T]) ToLogical(scaleFactor float64) LogicalSize[T] { 14 return LogicalSize[T]{ 15 Width: T(float64(s.Width) / scaleFactor), 16 Height: T(float64(s.Height) / scaleFactor), 17 } 18 } 19 20 func (s PhysicalSize[T]) ToPhysical(scaleFactor float64) PhysicalSize[T] { 21 return s 22 }