brush widget UI: don't allow 0 width or height

This commit is contained in:
sheaf 2024-05-28 10:36:26 +02:00
parent 56939ce01a
commit 7bb28f8c96

View file

@ -122,13 +122,16 @@ widgetUpdate widget mode ( oldPt, newPt ) ( MkR oldFlds ) =
| 3 w h θ <- oldFlds | 3 w h θ <- oldFlds
-> case mode of -> case mode of
ScaleAction whatScale -> ScaleAction whatScale ->
let T ( 2 w' h' ) = rotate ( cos -θ ) ( sin -θ ) newPt let T ( 2 w0 h0 ) = rotate ( cos -θ ) ( sin -θ ) newPt
-- Don't allow width/height to become 0.
w' = max 1e-6 ( abs w0 )
h' = max 1e-6 ( abs h0 )
in case whatScale of in case whatScale of
ScaleXY -> MkR $ 3 ( abs w' ) ( abs h' ) θ ScaleXY -> MkR $ 3 w' h' θ
ScaleX -> MkR $ 3 ( abs w' ) h θ ScaleX -> MkR $ 3 w' h θ
ScaleY -> MkR $ 3 w ( abs h' ) θ ScaleY -> MkR $ 3 w h' θ
RotateAction {} RotateAction {}
| norm newPt < 1e-5 | norm newPt < 1e-6
-> MkR oldFlds -> MkR oldFlds
| otherwise | otherwise
-> ->