From 087fd1e2f840807071bd994bcba37ec93022cbb6 Mon Sep 17 00:00:00 2001 From: CactiChameleon9 <51231053+CactiChameleon9@users.noreply.github.com> Date: Sun, 5 Feb 2023 16:58:33 +0000 Subject: [PATCH] zoom towards the center of the screen --- .../com/simplemobiletools/draw/pro/views/MyCanvas.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/pro/views/MyCanvas.kt b/app/src/main/kotlin/com/simplemobiletools/draw/pro/views/MyCanvas.kt index da527dd..3b259ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/pro/views/MyCanvas.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/pro/views/MyCanvas.kt @@ -25,8 +25,6 @@ import com.simplemobiletools.draw.pro.models.MyPath import com.simplemobiletools.draw.pro.models.PaintOptions import java.util.concurrent.ExecutionException import kotlin.math.abs -import kotlin.math.max -import kotlin.math.min class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { private val MIN_ERASER_WIDTH = 20f @@ -474,10 +472,17 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { mPath.reset() } + if (mScaleFactor * detector.scaleFactor !in 0.1f..10.0f) { + return true + } + mIgnoreTouches = true mWasScalingInGesture = true mScaleFactor *= detector.scaleFactor - mScaleFactor = max(0.1f, min(mScaleFactor, 10.0f)) + + mPosX *= detector.scaleFactor + mPosY *= detector.scaleFactor + setBrushSize(mCurrBrushSize) invalidate() return true