@@ -84,7 +84,10 @@ func (c *Context) slider(value *int, low, high, step int, id widgetID, opt optio
8484 }, func (bounds image.Rectangle ) {
8585 c .drawWidgetFrame (id , bounds , colorBase , opt )
8686 w := c .style ().thumbSize
87- x := int ((v - low ) * (bounds .Dx () - w ) / (high - low ))
87+ var x int
88+ if low < high {
89+ x = int ((v - low ) * (bounds .Dx () - w ) / (high - low ))
90+ }
8891 thumb := image .Rect (bounds .Min .X + x , bounds .Min .Y , bounds .Min .X + x + w , bounds .Max .Y )
8992 c .drawWidgetFrame (id , thumb , colorButton , opt )
9093 text := fmt .Sprintf ("%d" , v )
@@ -127,7 +130,10 @@ func (c *Context) sliderF(value *float64, low, high, step float64, digits int, i
127130 }, func (bounds image.Rectangle ) {
128131 c .drawWidgetFrame (id , bounds , colorBase , opt )
129132 w := c .style ().thumbSize
130- x := int ((v - low ) * float64 (bounds .Dx ()- w ) / (high - low ))
133+ var x int
134+ if low < high {
135+ x = int ((v - low ) * float64 (bounds .Dx ()- w ) / (high - low ))
136+ }
131137 thumb := image .Rect (bounds .Min .X + x , bounds .Min .Y , bounds .Min .X + x + w , bounds .Max .Y )
132138 c .drawWidgetFrame (id , thumb , colorButton , opt )
133139 text := formatNumber (v , digits )
0 commit comments