Documentation ¶
Index ¶
Constants ¶
const MaxSP = ScaledPoint(math.MaxInt)
MaxSP is the largest dimension. Approx. 50,000,000 km on 64bit architecture. On 32bit architecture still about 11.5 meters.
Variables ¶
var ( // ErrConversion signals an error in unit conversion ErrConversion = errors.New("Conversion error") // Logger is initialized to write to io.Discard and the default log level is // math.MaxInt, so it should never write anything. To set, use the // SetLogger() function. Logger *slog.Logger )
Functions ¶
Types ¶
type ScaledPoint ¶
type ScaledPoint int
A ScaledPoint is a 65535th of a DTP point
const Factor ScaledPoint = 0xffff
Factor is the multiplier to get DTP points from scaled points.
func MultiplyFloat ¶
func MultiplyFloat(a ScaledPoint, f float64) ScaledPoint
MultiplyFloat returns a multiplied by f.
func MustSp ¶
func MustSp(unit string) ScaledPoint
MustSp converts the unit to ScaledPoints. In case of an error, the function panics.
func ScaledPointFromFloat ¶
func ScaledPointFromFloat(f float64) ScaledPoint
ScaledPointFromFloat converts the DTP point f to a ScaledPoint
func Sp ¶
func Sp(unit string) (ScaledPoint, error)
Sp return the unit converted to ScaledPoint. Unit can be a string like "1cm" or "12.5in". The units which are interpreted are pt, in, mm, cm, m, px and pc. A (wrapped) ErrConversion is returned in case of an error.
func (ScaledPoint) String ¶
func (s ScaledPoint) String() string
String converts the scaled point into a string, like Sprintf("%.3f") but with trailing zeroes (and possibly ".") removed.
func (ScaledPoint) ToPT ¶
func (s ScaledPoint) ToPT() float64
ToPT returns the unit as a float64 DTP point. 2 * 0xffff returns 2.0