scale

package
v0.0.0-...-7b712e5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	Of(x float64) float64
	Ticks(n int) (major, minor []float64)
}

A scale satisfies Interface if it maps from some input range to an output interval [0, 1].

type Linear

type Linear struct {
	// contains filtered or unexported fields
}

func NewLinear

func NewLinear(input []float64) Linear

NewLinear returns a new linear scale.

func (Linear) Of

func (s Linear) Of(x float64) float64

func (Linear) Ticks

func (s Linear) Ticks(n int) (major, minor []float64)

type Log

type Log struct {
	// contains filtered or unexported fields
}

func NewLog

func NewLog(input []float64, base float64) *Log

NewLog returns a new logarithmic scale.

base has no effect on the scaling. It is only used for computing tick marks.

func (*Log) Nice

func (s *Log) Nice(n int)

Nice expands the domain of s to "nice" values of the scale, which will translate into major tick marks.

n is the maximum number of major ticks. n must be >= 2.

func (*Log) Of

func (s *Log) Of(x float64) float64

func (*Log) Ticks

func (s *Log) Ticks(n int) (major, minor []float64)

type OutputScale

type OutputScale struct {
	// contains filtered or unexported fields
}

func NewOutputScale

func NewOutputScale(min, max float64) OutputScale

func (*OutputScale) Clamp

func (s *OutputScale) Clamp()

func (*OutputScale) Crop

func (s *OutputScale) Crop()

func (OutputScale) Of

func (s OutputScale) Of(x float64) (float64, bool)

func (*OutputScale) Unclamp

func (s *OutputScale) Unclamp()

type Power

type Power struct {
	// contains filtered or unexported fields
}

func NewPower

func NewPower(input []float64, exp float64) Power

NewPower returns a new power scale.

func (Power) Of

func (s Power) Of(x float64) float64

func (Power) Ticks

func (s Power) Ticks(n int) (major, minor []float64)

Jump to

Keyboard shortcuts

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