Skip to content

Commit

Permalink
Add default values for the 'size' and 'color' attributes of the Monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
JiepengTan committed Aug 15, 2024
1 parent 1994744 commit 74ad6f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/goplus/spx/internal/gdi"
xfont "github.com/goplus/spx/internal/gdi/font"
"github.com/goplus/spx/internal/tools"
"github.com/hajimehoshi/ebiten/v2"
"golang.org/x/image/font"
)
Expand Down Expand Up @@ -65,9 +66,9 @@ func newMonitor(g reflect.Value, v specsp) (*Monitor, error) {
target := v["target"].(string)
val := v["val"].(string)
name := v["name"].(string)
size := v["size"].(float64)
if size == 0 {
size = 1
size := 1.0
if v["size"] != nil {
size, _ = tools.GetFloat(v["size"])
}
eval := buildMonitorEval(g, target, val)
if eval == nil {
Expand All @@ -76,7 +77,7 @@ func newMonitor(g reflect.Value, v specsp) (*Monitor, error) {
mode := int(v["mode"].(float64))
color, err := parseColor(getSpcspVal(v, "color"))
if err != nil {
panic(err)
color = Color{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
}
label := v["label"].(string)
x := v["x"].(float64)
Expand Down

0 comments on commit 74ad6f4

Please sign in to comment.