rhcad / vgios

A lightweight 2D vector drawing framework for iOS.
Other
81 stars 25 forks source link

Erase in splines mode #40

Open cyril94440 opened 9 years ago

cyril94440 commented 9 years ago

Hi,

thanks for your lib, it's awesome. We are using it in a real-time manner in our app : Shuff

We have however, one main issue, we would like to have an "erase splines" mode. We are currently doing so by using the splines mode in white, but we now are using image in background so it's no more possible.

Do you have any workaround in order to do so?

Thank you !

rhcad commented 9 years ago

Which feature do you need?

  1. Remove shapes with a curve boundary.
  2. Erase image content inside a curve boundary.

In addition, thank you for telling your application to use this lib, I hope your application becomes better!

cyril94440 commented 9 years ago

The image is behind the drawview, so what I need is remove content of the drawview like a rubber. So if you want to erase the whole screen you would have to "paint" the whole screen with your finger.

I hope you understand because it is not easy to describe !

On 10 Aug 2015, at 03:00, Zhang Yungui notifications@github.com wrote:

Which feature do you need?

  1. Remove shapes with a curve boundary.
  2. Erase image content inside a curve boundary.

In addition, thank you for telling your application to use this lib, I hope your application becomes better!

― Reply to this email directly or view it on GitHub.

rhcad commented 9 years ago

Do you want to draw white and opaque curves on the background image?

cyril94440 commented 9 years ago

I would like to draw "eraser" curve, a curve that remove the content. If the background is white , it's easy : splines mode with white color, but my background is transparent now, and drawing with clear color is not working.

On 10 Aug 2015, at 11:25, Zhang Yungui notifications@github.com wrote:

Do you want to draw white and opaque curves on the background image?

― Reply to this email directly or view it on GitHub.

rhcad commented 9 years ago

You can draw the background image with a clip area generated from outline curves and the view boundary.

cyril94440 commented 9 years ago

Thanks for your help! Could you help me with the step that returns an area according to a shape ?

Le 10 août 2015 à 13:14:30, Zhang Yungui (notifications@github.com) a écrit:

You can draw the background image with a clip area generated from outline curves and the view boundary.

— Reply to this email directly or view it on GitHub.

rhcad commented 9 years ago

I've add an example at SplinesEraser.

The following is the mainly code (CmdDrawSplinesEraser::touchEnded):

NSArray *paths = [[GiViewHelper sharedInstance] exportPathsForShape: dynshape()->toHandle()];
UIBezierPath *path = paths[0];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];

shapeLayer.path = path.CGPath;
[imageView.layer setMask:shapeLayer];

It's so difficult that I've taken about 10 hours. You can fork and change the example to make it better.