Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

plot/palette: clean up API

Aperta
#352 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@kortschak ci sta già lavorando.

Dal 30/4/2017.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

I am troubled by the size of the ColorMap interface. It can be reduced in size to

// A ColorMap maps scalar values to colors.
type ColorMap interface {
	// At returns the color associated with the given value.
	// If the value is not between Max() and Min(), an error is returned.
	At(float64) (color.Color, error)

	// Min returns the current minimum value of the ColorMap.
	Min() float64

	// Max returns the current maximum value of the ColorMap.
	Max() float64

	// Palette returns a new Palette with the specified number of
	// colors from the ColorMap.
	Palette(colors int) Palette
}

and

// DivergingColorMap maps scalar values to colors that diverge from a central value.
type DivergingColorMap interface {
	ColorMap

	// ConvergePoint returns the value where the diverging colors meet.
	ConvergePoint() float64
}

The Set methods are required because the concrete types are not exported. This can be fixed with minor name juggling on the field names of the concrete types. For example:

// Luminance is a color palette that interpolates between control colors in a way that
// ensures a linear relationship between the luminance of a color and the value it represents.
// NewLuminance must be used to create a usable Luminance.
type Luminance struct {
	// colors are the control colors to be interpolated among.
	// The colors must be monotonically increasing in luminance.
	colors []cieLAB

	// scalars are the scalar control points associated with
	// each item in colors (above). They are monotonically
	// increasing values between zero and one that correspond
	// to the luminance of a given control color in relation
	// to the minimum and maximum luminance among all control
	// colors.
	scalars []float64

	// Alpha represents the opacity of the returned colors in
	// the range (0,1). NewLuminance sets Alpha to 1.
	Alpha float64

	// Range specifies the minimum and maximum values of the
	// range of scalars that can be mapped to colors using this
	// ColorMap.
	Range struct { Min, Max float64 }
}
Lingua principale
Go
Stelle
3k
Fork
202
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di gonum/plot

Tutte le issue di gonum/plot

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.