Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
48 changes: 31 additions & 17 deletions app/src/main/kotlin/org/fossify/paint/views/MyCanvas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() }
}
}

Expand Down
Loading