Skip to content

Conversation

@x15sr71
Copy link
Contributor

@x15sr71 x15sr71 commented Oct 4, 2025

Fix: PAINTROID-798 - Black line while using eraser

Reference: Jira ticket

Refactorings and Bug Fixes

  • Fixed black line artifact appearing during eraser tool usage by implementing canvas.saveLayer() to properly composite cached image with eraser stroke
  • Eraser now erases in real-time as finger moves across the screen without needing to lift finger

Summary

Problem: When using the eraser tool, a black line appeared while dragging. Content only appeared erased after lifting the finger from the screen.

Root Cause: BlendMode.clear was being applied without proper layer composition, causing the eraser stroke to render as black during the drawing operation. The erasing effect only became visible after the gesture ended.

Solution:

  • Modified CommandPainter to wrap cached image and current eraser stroke in canvas.saveLayer() when eraser is actively drawing
  • Modified CanvasPainter to pass cachedImage to the painter and conditionally hide it during active erasing to prevent double-rendering
  • This allows BlendMode.clear to erase against existing content within the same rendering layer, enabling real-time erasing as the finger moves without needing to lift it

Result:

  • No black line artifact
  • Real-time erasing feedback while dragging
  • Immediate visual response without lifting finger

Files Changed:

  • lib/core/commands/command_painter.dart
  • lib/ui/pages/workspace_page/components/drawing_surface/canvas_painter.dart

Testing: All 75 integration tests passed, including 5 eraser-specific tests

Checklist

  • Include the name of the Jira ticket in the PR's title
  • Add the link to the ticket in Jira in the description of the PR
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project's coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing tests pass locally (75/75 integration tests)
  • Check that the commits' message style matches the project's guideline
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Add new information to the Wiki (if applicable)

Note: I was unable to comment on the Jira ticket as I don't have commenting permissions yet. I've requested access to properly follow the contribution workflow for future PRs.

@juliajulie95
Copy link
Contributor

Could you please remove the comments? :)
Code should be clear enough

@x15sr71
Copy link
Contributor Author

x15sr71 commented Nov 2, 2025

Hi @juliajulie95,
I’ve removed the comments as suggested. Thank you for the feedback!

@juliajulie95
Copy link
Contributor

Thank you for the changes, I'll test and merge this in the next week :)

@juliajulie95
Copy link
Contributor

Thank you!

@juliajulie95 juliajulie95 merged commit 126f391 into Catrobat:develop Dec 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants