MCPcopy Create free account
hub / github.com/B33pBeeps/redthread / FontMenuRect

Function FontMenuRect

internal/app/menu.go:38–63  ·  view source on GitHub ↗

--- rendering --------------------------------------------------------

(w, h int)

Source from the content-addressed store, hash-verified

36// --- rendering --------------------------------------------------------
37
38func FontMenuRect(w, h int) Rect {
39 maxName := 0
40 maxSample := 0
41 for _, m := range TextModes {
42 if runeLen(m.Name()) > maxName {
43 maxName = runeLen(m.Name())
44 }
45 if runeLen(m.Sample()) > maxSample {
46 maxSample = runeLen(m.Sample())
47 }
48 }
49 mw := maxName + maxSample + 10
50 if mw < 32 {
51 mw = 32
52 }
53 mh := len(TextModes) + 4
54 mx := w - mw - 2
55 if mx < 2 {
56 mx = 2
57 }
58 my := (h - mh) / 2
59 if my < 1 {
60 my = 1
61 }
62 return Rect{X: mx, Y: my, W: mw, H: mh}
63}
64
65func drawFontMenu(c *Canvas, menu *FontMenu) {
66 rect := FontMenuRect(c.W, c.H)

Callers 2

drawFontMenuFunction · 0.85

Calls 3

runeLenFunction · 0.85
NameMethod · 0.80
SampleMethod · 0.80

Tested by

no test coverage detected