Question

Is there a pressure-sensitive, alternative Path implementation for drawing on a Canvas?

I want to be able to declare the stroke width or opacity of each point based on a MotionEvent.

For now, I just want to append straight line segments. However, the pressure-based parameter should be interpolated between the end points of each line segment.

If there is no ready-to-use solution, of course I appreciate any advices leading to a (performance optimized) self-implementation.

Was it helpful?

Solution

The approach I have chosen, can be described as followed:

  • Use multiple paths overlying
  • Each path contains only the line segments that are below a certain pressure threshold
  • The paths are drawn with alpha value transparency

Disadvantages / potential optimizations:

  • The alpha value is not been interpolated along the line segment; therefor the steps of the threshold values ​​are visible.

  • Non-transparent lines resulting from high pressure values now produce the most overlying lines, however, could also be represented by a single one

  • I wonder whether it is faster

    • to draw the whole paths on invalidation or
    • store the result in a bitmap and only add the new ones

What do you think of my approach? Any suggestions or comments?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top