Documentation ¶
Overview ¶
efixed is a utility subpackage containing functions for working with fixed point fixed.Int26_6 numbers. You most likely will never need to use this package, but if you are rolling your own emask.Rasterizer or ecache.GlyphCacheHandler maybe you find something useful here.
Index ¶
- func Floor(value fixed.Int26_6) fixed.Int26_6
- func FromFloat64(value float64) (fixed.Int26_6, fixed.Int26_6)
- func FromFloat64RoundAwayZero(value float64) fixed.Int26_6
- func FromFloat64RoundToZero(value float64) fixed.Int26_6
- func FromInt(value int) fixed.Int26_6
- func QuantizeFractDown(value fixed.Int26_6, step uint8) fixed.Int26_6
- func QuantizeFractUp(value fixed.Int26_6, step uint8) fixed.Int26_6
- func RoundHalfAwayZero(value fixed.Int26_6) fixed.Int26_6
- func RoundHalfDown(value fixed.Int26_6) fixed.Int26_6
- func RoundHalfUp(value fixed.Int26_6) fixed.Int26_6
- func ToFloat64(value fixed.Int26_6) float64
- func ToIntHalfAwayZero(value fixed.Int26_6) int
- func ToIntHalfDown(value fixed.Int26_6) int
- func ToIntHalfUp(value fixed.Int26_6) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Floor ¶
Like fixed.Floor(), but returning the fixed.Int26_6 value instead of an int.
func FromFloat64 ¶
Converts the given float64 to the nearest fixed.Int26_6. If there's a tie, returned values will be different, and the first will always be smaller than the second.
The function will panic if the given float64 is not closely representable by any fixed.Int26_6 (including Inf, -Inf and NaN).
func FromFloat64RoundAwayZero ¶
Same as FromFloat64(), but returning a single value. In case of ties, the result furthest away from zero is selected.
func FromFloat64RoundToZero ¶
Same as FromFloat64(), but returning a single value. In case of ties, the result closest to zero is selected.
func FromInt ¶
Handy method to convert int values to their exact fixed.Int26_6 representation. fixed.I() also does this, but this has bound checks, in case that's important for you.
func QuantizeFractDown ¶
Quantizes the fractional part of the given value with the given step, rounding down.
func QuantizeFractUp ¶
Quantizes the fractional part of the given value with the given step, rounding up.
func RoundHalfAwayZero ¶
Like RoundHalfUp(), but rounding away from zero. For the int result, see ToIntHalfAwayZero() instead.
func RoundHalfDown ¶
Like RoundHalfUp(), but rounding down. For the int result, see ToIntHalfDown() instead.
func RoundHalfUp ¶
Like fixed.Round(), but returns the fixed.Int26_6 instead of an int and is clearly named. For the int result, see ToIntHalfUp() instead.
func ToFloat64 ¶
Converts a value from its fixed.Int26_6 representation to its float64 representation. Conversion is always exact.
func ToIntHalfAwayZero ¶
Like RoundHalfAwayZero(), but directly converting to int.
func ToIntHalfDown ¶
Like RoundHalfDown(), but directly converting to int.
func ToIntHalfUp ¶
Like RoundHalfUp(), but directly converting to int.
Types ¶
This section is empty.