func (t TreePalette) IndexNear(c color.Color) (i int) {
	if t.Root == nil {
		return -1
	}
	t.Search(c, func(leaf *Node) { i = leaf.Index })
	return
}
IndexNear returns the index of the nearest palette color.
package quant
import (
	"image"
	"image/color"
)
type Palette interface {
	Len() int
	IndexNear(color.Color) int
	ColorNear(color.Color) color.Color
	ColorPalette() color.Palette
}
var _ Palette = LinearPalette{}
var _ Palette = TreePalette{}
type LinearPalette struct {
	color.Palette
}
func (p LinearPalette) IndexNear(c color.Color) int {
	return p.Palette.Index(c)
}
func (p LinearPalette) ColorNear(c color.Color) color.Color {
	return p.Palette.Convert(c)
}
func (p LinearPalette) ColorPalette() color.Palette {
	return p.Palette
}
func (p LinearPalette) Len() int { return len(p.Palette) }
type TreePalette struct {
	Leaves int
	Root   *Node
}
func (p TreePalette) Len() int { return p.Leaves }
type Node struct {
	Type int
	Index int
	Color color.RGBA64
	Split     uint32
	Low, High *Node
}
const (
	TLeaf = iota
	TSplitR
	TSplitG
	TSplitB
)