Compose-Drawing-App icon indicating copy to clipboard operation
Compose-Drawing-App copied to clipboard

Changing stroke width also changes all older eraser paths

Open ugre opened this issue 3 years ago • 5 comments
trafficstars

While drawing paths in Canvas, when eraseMode is true, it should also use property.strokeWidth (and others) but NOT currentPathProperty.* Simple bug and simple fix ;)

ugre avatar Sep 02 '22 10:09 ugre

Sure, i will add update it with this fix. I will probably rewrite drawing app from scratch when i have time with some Event logic to capture, time, properties and action to save them to database for persistence and undo/redo logic.

SmartToolFactory avatar Nov 06 '22 19:11 SmartToolFactory

Either way, thank you for this, it does the job for me now. Hopefully, you find the time to build it more robust and customizable. I will also try to find the time to do it myself meanwhile...

ugre avatar Nov 07 '22 11:11 ugre

Hello, @ugre and @SmartToolFactory i faced same issue, did you find the solution for this one?

myuksektepe avatar Jul 08 '24 11:07 myuksektepe

I find the solution. Just change "currentPathProperty" to "property" at 218, 219 and 220th lines in DrawingApp.kt

  paths.forEach {
      val path = it.first
      val property = it.second

      if (!property.eraseMode) {
          drawPath(
              color = property.color,
              path = path,
              style = Stroke(
                  width = property.strokeWidth,
                  cap = property.strokeCap,
                  join = property.strokeJoin
              )
          )
      } else {
          // Source
          drawPath(
              color = Color.Transparent,
              path = path,
              style = Stroke(
                  width = **property**.strokeWidth, // <--- 
                  cap = **property**.strokeCap, // <--- 
                  join = **property**.strokeJoin // <--- 
              ),
              blendMode = BlendMode.Clear
          )
      }
  }

myuksektepe avatar Jul 08 '24 12:07 myuksektepe