4Q-s-r-o / signature

Flutter plugin that creates a canvas for writing down a signature
MIT License
252 stars 83 forks source link

Update Pen Color #73

Closed Dr-Usman closed 1 year ago

Dr-Usman commented 1 year ago

In Signature Controller, Pen color is final. It should be able to update just color.

'penColor' can't be used as a setter because it's final. Try finding a different setter, or making 'penColor' non-final.

MartinHlavna commented 1 year ago

Hi, what is the use case for this? For me it seems more like "general drawing" rather than signature feature. If I understand correctly, you want to change pen color "mid-drawing" and have lines of different colors.

That would be be problematic, since we are saving now just the points with their type. If we would just change pen color, then all existing points could change color (for example when you export and import points for some reason).

Or you want change the color and have everything adapted to a new one (maybe when changing theme) ? We would need to recreate canvas and redraw anything in that case.

Dr-Usman commented 1 year ago

Thank you for replying. If it is possible to update color property and then create new color lines that would be good also but if it's possible to change the pen color and already lines can also adapted to that. Mean points will be remain same. I worked around like that which is re initialize the controller with existing points but different color.

h7x4 commented 1 year ago

Here are some use cases I can come up with for supporting this:

  1. Programatically drawing an underline in a different color, indicating that it is not part of the signature itself.
  2. Changing the color of the whole signature, indicating that it has changed state somehow (drawing/finished, activated/deactivated, accepted/rejected, etc.)
  3. This:
![image](https://user-images.githubusercontent.com/14929991/200080986-0f9c62ca-a0c2-404e-9d89-b08e873c4ef2.png)
h7x4 commented 1 year ago

If this is to be implemented, I feel like the SignatureController should switch from having a List<Point> as its main datastructure, to working with a List<Stroke>, where each Stroke internally would be a List<Point>. That way we can add metadata (like color) to every stroke, rather than every single point.

Features like redo/undo and svg export currently uses _latestActions as a replacement for strokes. This requires every Point to have a PointType, which in a sense just indicates which stroke it is part of. This could be removed, as it would be inherently stored.

The other methods that use a List<Point> can just flatten the list of strokes by doing this:

List<Point> get points => strokes.expand((s) => s.points).toList();

I think this would decrease both computation required and storage used.

Dr-Usman commented 1 year ago

The idea behind created a request is can draw signature and while on same canvas can update color of stroke and then write again different color. If it's possible i think it's be much helpful. But if can't then is there any possibility to just update all colors of drawing while having same points instead of re initialize the controller with same points and different color. oie_d5cl9q8JVvn1

ethael commented 1 year ago

this idea is going beyond the scope of this plugin. it would start to move towards something like a simple drawing canvas. we would like to keep the KISS principle in place here and do only one thing and do it well.