From 160e539aee686d36d0fb6306037cea1e18b51e26 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 1 Apr 2018 21:10:50 -0400 Subject: Add absolute value versions of Ht and Wd methods --- grid.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'grid.go') diff --git a/grid.go b/grid.go index 8e0cdfb..2805297 100644 --- a/grid.go +++ b/grid.go @@ -1,6 +1,7 @@ package gofpdf import ( + "math" "strconv" ) @@ -142,6 +143,12 @@ func NewGrid(x, y, w, h float64) (grid GridType) { return } +// WdAbs returns the absolute value of dataWd, specified in logical data units, +// that has been converted to the unit of measure specified in New(). +func (g GridType) WdAbs(dataWd float64) float64 { + return math.Abs(g.xm * dataWd) +} + // Wd converts dataWd, specified in logical data units, to the unit of measure // specified in New(). func (g GridType) Wd(dataWd float64) float64 { @@ -154,6 +161,12 @@ func (g GridType) X(dataX float64) float64 { return g.xm*dataX + g.xb } +// HtAbs returns the absolute value of dataHt, specified in logical data units, +// that has been converted to the unit of measure specified in New(). +func (g GridType) HtAbs(dataHt float64) float64 { + return math.Abs(g.ym * dataHt) +} + // Ht converts dataHt, specified in logical data units, to the unit of measure // specified in New(). func (g GridType) Ht(dataHt float64) float64 { -- cgit v1.2.1-24-ge1ad