Merge pull request #267 from CactiChameleon9/patch-1

Zoom towards the center of the screen
This commit is contained in:
Tibor Kaputa 2023-03-13 11:50:11 +01:00 committed by GitHub
commit 92a74c3b09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -22,8 +22,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
@ -439,10 +437,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