render

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DarkTextColor  color.Color = color.Black
	LightTextColor color.Color = color.White
)

Functions

func BoxSVG

func BoxSVG(q UIBox) string

func TextSVG

func TextSVG(t *UIText) string

func TreeHues

func TreeHues(tree treemap.Tree, offset float64) map[string]float64

Types

type Colorer

type Colorer interface {
	ColorBox(tree treemap.Tree, node string) color.Color
	ColorText(tree treemap.Tree, node string) color.Color
}

type ColorfulPalette

type ColorfulPalette []struct {
	Col colorful.Color
	Pos float64
}

This table contains the "keypoints" of the colorgradient you want to generate. The position of each keypoint has to live in the range [0,1] Ths is copied from go-colorful examples!!!

func GetPalette

func GetPalette(name string) (ColorfulPalette, bool)

func (ColorfulPalette) GetInterpolatedColorFor

func (gt ColorfulPalette) GetInterpolatedColorFor(t float64) color.Color

This is the meat of the gradient computation. It returns a HCL-blend between the two colors around `t`. Note: It relies heavily on the fact that the gradient keypoints are sorted.

type HeatColorer

type HeatColorer struct {
	Palette ColorfulPalette
}

HeatColorer will use heat field of nodes. If not present, then will pick midrange. This is proxy for go-colorful palette.

func (HeatColorer) ColorBox

func (s HeatColorer) ColorBox(tree treemap.Tree, node string) color.Color

func (HeatColorer) ColorText

func (s HeatColorer) ColorText(tree treemap.Tree, node string) color.Color

type NoneColorer

type NoneColorer struct{}

func (NoneColorer) ColorBox

func (s NoneColorer) ColorBox(tree treemap.Tree, node string) color.Color

func (NoneColorer) ColorText

func (s NoneColorer) ColorText(tree treemap.Tree, node string) color.Color

type SVGRenderer

type SVGRenderer struct{}

func (SVGRenderer) Render

func (r SVGRenderer) Render(root UIBox, w, h float64) []byte

type TreeHueColorer

type TreeHueColorer struct {
	Hues   map[string]float64 // memoized hues
	C      float64            // will be in all colors
	L      float64            // will be in all colors
	Offset float64            // 0 ~ 360 hue offset in HCL for tree
	DeltaH float64            // tolerance for approximate color
	DeltaC float64            // tolerance for approximate color
	DeltaL float64            // tolerance for approximate color
}

TreeHueColorer this algorithm will split Hue in NCL ranges such that deeper nodes have more specific hue. The advantage of this coloring is that nodes in that belong topologically close will have similar hue. Supposed to be run once on tree due to memoization. The challenge that not all HCL values are valid colors. Which is why we have to sample and look for value within range. For very deep trees, that require precise colors colors closer to leaves will get mixed due to sampling.

func (TreeHueColorer) ColorBox

func (s TreeHueColorer) ColorBox(tree treemap.Tree, node string) color.Color

func (TreeHueColorer) ColorText

func (s TreeHueColorer) ColorText(tree treemap.Tree, node string) color.Color

type UIBox

type UIBox struct {
	Title       *UIText
	X           float64
	Y           float64
	W           float64
	H           float64
	Children    []UIBox
	IsInvisible bool
	IsRoot      bool
	Color       color.Color
	BorderColor color.Color
}

UIBox is spec on how to render a box. Could be Root.

func (UIBox) IsEmpty

func (f UIBox) IsEmpty() bool

type UIText

type UIText struct {
	Text  string
	X     float64
	Y     float64
	H     float64
	W     float64
	Scale float64
	Color color.Color
}

UIText is spec on how to render text.

type UITreeMapBuilder

type UITreeMapBuilder struct {
	Colorer     Colorer
	BorderColor color.Color
}

func (UITreeMapBuilder) NewUIBox

func (s UITreeMapBuilder) NewUIBox(node string, tree treemap.Tree, x, y, w, h, margin float64, padding float64) UIBox

func (UITreeMapBuilder) NewUITreeMap

func (s UITreeMapBuilder) NewUITreeMap(tree treemap.Tree, w, h, margin, padding, paddingRoot float64) UIBox

Jump to

Keyboard shortcuts

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