diff --git a/CHANGELOG.md b/CHANGELOG.md index 23585f56..558a9e34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Preference category labels now use sentence case + ### Fixed - Editing images from other apps now works as expected ([#76]) +- Fixed broken bucket fill when zoomed in ([#20]) ## [1.1.0] - 2025-05-05 @@ -32,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release. +[#20]: https://github.com/FossifyOrg/Paint/issues/20 [#76]: https://github.com/FossifyOrg/Paint/issues/76 [Unreleased]: https://github.com/FossifyOrg/Paint/compare/1.1.0...HEAD diff --git a/app/src/main/kotlin/org/fossify/paint/views/MyCanvas.kt b/app/src/main/kotlin/org/fossify/paint/views/MyCanvas.kt index 673e41ba..2f571bc2 100644 --- a/app/src/main/kotlin/org/fossify/paint/views/MyCanvas.kt +++ b/app/src/main/kotlin/org/fossify/paint/views/MyCanvas.kt @@ -5,6 +5,7 @@ import android.content.Context import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Color +import android.graphics.Matrix import android.graphics.Paint import android.graphics.Point import android.graphics.PointF @@ -394,23 +395,36 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { } private fun bucketFill() { - val touchedX = mCurX.toInt() - val touchedY = mCurY.toInt() - if (contains(touchedX, touchedY)) { - val bitmap = getBitmap() - val color = mPaintOptions.color - - ensureBackgroundThread { - val path = bitmap.vectorFloodFill( - color = color, - x = touchedX, - y = touchedY, - tolerance = FLOOD_FILL_TOLERANCE - ) - val paintOpts = PaintOptions(color = color, strokeWidth = 5f) - addOperation(path, paintOpts) - post { invalidate() } - } + if (mCenter == null) { + mCenter = PointF(width / 2f, height / 2f) + } + + val touchedX = mLastTouchX.toInt() + val touchedY = mLastTouchY.toInt() + if (!contains(touchedX, touchedY)) return + + // apply same transformation as in onDraw() + val toScreen = Matrix().apply { + preTranslate(mPosX, mPosY) + preScale(mScaleFactor, mScaleFactor, mCenter!!.x, mCenter!!.y) + } + + val fromScreen = Matrix().apply { toScreen.invert(this) } + + val bitmap = getBitmap() + val color = mPaintOptions.color + ensureBackgroundThread { + val path = bitmap.vectorFloodFill( + color = color, + x = touchedX, + y = touchedY, + tolerance = FLOOD_FILL_TOLERANCE + ) + + path.transform(fromScreen) + val paintOpts = PaintOptions(color = color, strokeWidth = 5f) + addOperation(path, paintOpts) + post { invalidate() } } }