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

Method Draw

gui.go:3925–4030  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3923}
3924
3925func (highlighter *Highlighter) Draw() {
3926
3927 if highlighter.Highlighting {
3928 highlighter.HighlightPercentage += (1 - highlighter.HighlightPercentage) * 0.2
3929 } else {
3930 highlighter.HighlightPercentage += (0 - highlighter.HighlightPercentage) * 0.2
3931 }
3932
3933 r := highlighter.Rect
3934
3935 softness := float32(0.1)
3936 r.X += (highlighter.TargetRect.X - r.X) * softness
3937 r.Y += (highlighter.TargetRect.Y - r.Y) * softness
3938 r.W += (highlighter.TargetRect.W - r.W) * softness
3939 r.H += (highlighter.TargetRect.H - r.H) * softness
3940
3941 if highlighter.WorldSpace {
3942 r = globals.Project.Camera.TranslateRect(r)
3943 }
3944
3945 rect := *r
3946
3947 padding := float32(0)
3948
3949 rect.X -= padding
3950 rect.Y -= padding
3951 rect.W += padding * 2
3952 rect.H += padding * 2
3953
3954 var highlightColor Color
3955
3956 if highlighter.Color == nil {
3957 highlightColor = getThemeColor(GUICompletedColor)
3958 highlightColor[3] = 255
3959 } else {
3960 highlightColor = highlighter.Color
3961 }
3962
3963 switch highlighter.HighlightMode {
3964
3965 case HighlightColor:
3966
3967 if highlighter.HighlightPercentage > 0.01 {
3968 highlightColor[3] = uint8(highlighter.HighlightPercentage * float32(highlightColor[3]) * 0.5)
3969 RoundedBoxColor(globals.Renderer, int32(rect.X), int32(rect.Y), int32(rect.X+rect.W), int32(rect.Y+rect.H), 4, highlightColor)
3970 }
3971
3972 case HighlightRing:
3973
3974 firstPerc := highlighter.HighlightPercentage * 2
3975 if firstPerc > 1 {
3976 firstPerc = 1
3977 }
3978 secondPerc := highlighter.HighlightPercentage*2 - 1
3979 if secondPerc < 0 {
3980 secondPerc = 0
3981 }
3982

Callers

nothing calls this directly

Calls 4

getThemeColorFunction · 0.85
RoundedBoxColorFunction · 0.85
ThickLineFunction · 0.85
TranslateRectMethod · 0.80

Tested by

no test coverage detected