MCPcopy Create free account
hub / github.com/SolarLune/masterplan / DrawLabel

Function DrawLabel

utils.go:880–915  ·  view source on GitHub ↗

DrawLabel draws a small paper-like label of the specified text at the X and Y position specified.

(pos Vector, size float32, text string, menuColor Color)

Source from the content-addressed store, hash-verified

878
879// DrawLabel draws a small paper-like label of the specified text at the X and Y position specified.
880func DrawLabel(pos Vector, size float32, text string, menuColor Color) {
881
882 textSize := globals.TextRenderer.MeasureText([]rune(text), 0.5)
883 textSize.X += 16
884
885 if textSize.X < 16 {
886 textSize.X = 16
887 }
888
889 guiTexture := globals.GUITexture.Texture
890
891 guiTexture.SetColorMod(menuColor.RGB())
892 guiTexture.SetAlphaMod(menuColor[3])
893
894 src := &sdl.FRect{480, 48, 8, 24}
895 dst := &sdl.FRect{pos.X, pos.Y, float32(src.W) * size, float32(src.H) * size}
896 globals.Renderer.RenderTexture(guiTexture, src, dst)
897
898 src.X += 8
899
900 dst.X += float32(src.W * size)
901 dst.W = (textSize.X - 16) * size
902 if dst.W > 0 {
903 globals.Renderer.RenderTexture(guiTexture, src, dst)
904 }
905
906 src.X += 8
907 src.W = 16
908
909 dst.X += dst.W
910 dst.W = float32(src.W) * size
911 globals.Renderer.RenderTexture(guiTexture, src, dst)
912
913 globals.TextRenderer.QuickRenderText(text, Vector{pos.X + (textSize.X / 2 * size), pos.Y}, 0.5*size, getThemeColor(GUIFontColor), nil, AlignCenter)
914
915}
916
917// SortedSet represents a sorted set of elements.
918type SortedSet[E comparable] []E

Callers 6

DrawCardMethod · 0.85
PostDrawMethod · 0.85
DrawOnTopMethod · 0.85
DrawMethod · 0.85
DrawMethod · 0.85
DrawMethod · 0.85

Calls 4

getThemeColorFunction · 0.85
MeasureTextMethod · 0.80
RGBMethod · 0.80
QuickRenderTextMethod · 0.80

Tested by

no test coverage detected