MCPcopy Create free account
hub / github.com/cogentcore/core / Config

Method Config

plot/text.go:71–89  ·  view source on GitHub ↗

config is called during the layout of the plot, prior to drawing

(pt *Plot)

Source from the content-addressed store, hash-verified

69
70// config is called during the layout of the plot, prior to drawing
71func (tx *Text) Config(pt *Plot) {
72 uc := &pt.Paint.UnitContext
73 fs := &tx.Style.FontRender
74 if math32.Abs(tx.Style.Rotation) > 10 {
75 tx.Style.Align = styles.End
76 }
77 fs.ToDots(uc)
78 tx.Style.Padding.ToDots(uc)
79 txln := float32(len(tx.Text))
80 fht := fs.Size.Dots
81 hsz := float32(12) * txln
82 txs := &pt.StandardTextStyle
83 tx.PaintText.SetHTML(tx.Text, fs, txs, uc, nil)
84 tx.PaintText.Layout(txs, fs, uc, math32.Vector2{X: hsz, Y: fht})
85 if tx.Style.Rotation != 0 {
86 rotx := math32.Rotate2D(math32.DegToRad(tx.Style.Rotation))
87 tx.PaintText.Transform(rotx, fs, uc)
88 }
89}
90
91// PosX returns the starting position for a horizontally-aligned text element,
92// based on given width. Text must have been config'd already.

Callers 2

drawMethod · 0.95
PlotMethod · 0.95

Calls 7

AbsFunction · 0.92
Rotate2DFunction · 0.92
DegToRadFunction · 0.92
SetHTMLMethod · 0.80
LayoutMethod · 0.80
ToDotsMethod · 0.45
TransformMethod · 0.45

Tested by

no test coverage detected