need to be very specific about points vs. pixels.

This commit is contained in:
Will Charczuk 2016-07-09 09:04:30 -07:00
parent 8bc8b1087c
commit 80d6be9849
6 changed files with 60 additions and 25 deletions

View file

@ -9,6 +9,18 @@ import (
"github.com/golang/freetype/truetype"
)
// PixelsToPoints returns the points for a given number of pixels at a DPI.
func PixelsToPoints(dpi, pixels float64) (points float64) {
points = (pixels * 72.0) / dpi
return
}
// PointsToPixels returns the pixels for a given number of points at a DPI.
func PointsToPixels(dpi, points float64) (pixels float64) {
pixels = (points * dpi) / 72.0
return
}
func abs(i int) int {
if i < 0 {
return -i