mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 02:22:55 +08:00
fix divide by zero
This commit is contained in:
parent
2f924b3368
commit
78e87d379b
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
@ -79,7 +80,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
Vector2 scale = e.MousePosition - e.MouseDownPosition;
|
Vector2 scale = e.MousePosition - e.MouseDownPosition;
|
||||||
adjustScaleFromAnchor(ref scale);
|
adjustScaleFromAnchor(ref scale);
|
||||||
return Vector2.Divide(scale, scaleHandler!.OriginalSurroundingQuad!.Value.Size) + Vector2.One;
|
|
||||||
|
var surroundingQuad = scaleHandler!.OriginalSurroundingQuad!.Value;
|
||||||
|
scale.X = Precision.AlmostEquals(surroundingQuad.Width, 0) ? 0 : scale.X / surroundingQuad.Width;
|
||||||
|
scale.Y = Precision.AlmostEquals(surroundingQuad.Height, 0) ? 0 : scale.Y / surroundingQuad.Height;
|
||||||
|
|
||||||
|
return scale + Vector2.One;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustScaleFromAnchor(ref Vector2 scale)
|
private void adjustScaleFromAnchor(ref Vector2 scale)
|
||||||
|
Loading…
Reference in New Issue
Block a user