efixed

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Floor

func Floor(value fixed.Int26_6) fixed.Int26_6

Like fixed.Floor(), but returning the fixed.Int26_6 value instead of an int.

func FromFloat64

func FromFloat64(value float64) (fixed.Int26_6, fixed.Int26_6)

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

func FromFloat64RoundAwayZero(value float64) fixed.Int26_6

Same as FromFloat64(), but returning a single value. In case of ties, the result furthest away from zero is selected.

func FromFloat64RoundToZero

func FromFloat64RoundToZero(value float64) fixed.Int26_6

Same as FromFloat64(), but returning a single value. In case of ties, the result closest to zero is selected.

func FromInt

func FromInt(value int) fixed.Int26_6

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

func QuantizeFractDown(value fixed.Int26_6, step uint8) fixed.Int26_6

Quantizes the fractional part of the given value with the given step, rounding down.

func QuantizeFractUp

func QuantizeFractUp(value fixed.Int26_6, step uint8) fixed.Int26_6

Quantizes the fractional part of the given value with the given step, rounding up.

func RoundHalfAwayZero

func RoundHalfAwayZero(value fixed.Int26_6) fixed.Int26_6

Like RoundHalfUp(), but rounding away from zero. For the int result, see ToIntHalfAwayZero() instead.

func RoundHalfDown

func RoundHalfDown(value fixed.Int26_6) fixed.Int26_6

Like RoundHalfUp(), but rounding down. For the int result, see ToIntHalfDown() instead.

func RoundHalfUp

func RoundHalfUp(value fixed.Int26_6) fixed.Int26_6

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

func ToFloat64(value fixed.Int26_6) float64

Converts a value from its fixed.Int26_6 representation to its float64 representation. Conversion is always exact.

func ToIntHalfAwayZero

func ToIntHalfAwayZero(value fixed.Int26_6) int

Like RoundHalfAwayZero(), but directly converting to int.

func ToIntHalfDown

func ToIntHalfDown(value fixed.Int26_6) int

Like RoundHalfDown(), but directly converting to int.

func ToIntHalfUp

func ToIntHalfUp(value fixed.Int26_6) int

Like RoundHalfUp(), but directly converting to int.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL