simplify code in Rect.Resized

This commit is contained in:
faiface 2017-04-13 15:26:48 +02:00
parent fcbc61c570
commit 939a76923d
1 changed files with 1 additions and 1 deletions

View File

@ -249,7 +249,7 @@ func (r Rect) Resized(anchor, size Vec) Rect {
if r.W()*r.H() == 0 || size.X()*size.Y() == 0 { if r.W()*r.H() == 0 || size.X()*size.Y() == 0 {
panic(fmt.Errorf("(%T).Resize: zero area", r)) panic(fmt.Errorf("(%T).Resize: zero area", r))
} }
fraction := size.ScaledXY(V(1/r.W(), 1/r.H())) fraction := V(size.X()/r.W(), size.Y()/r.H())
return Rect{ return Rect{
Min: anchor + (r.Min - anchor).ScaledXY(fraction), Min: anchor + (r.Min - anchor).ScaledXY(fraction),
Max: anchor + (r.Max - anchor).ScaledXY(fraction), Max: anchor + (r.Max - anchor).ScaledXY(fraction),