I have a closed UIBezierpath and I want to expand it up (NOT SCALING UP) the same way we expand a sellection in photoshop via Select> Modify> Expand (As shown below in this image).
Is it possible to expand a path this way in objective c? I'd really appreciate it.
Is it possible to expand (not scale) a uibezierpath the same way we expand a selection in photoshop?
Asked
Active
Viewed 240 times
2

Reza.Ab
- 1,195
- 1
- 11
- 21
-
1Look at `applyTransform` with `CGAffineTransformMakeScale` and `CGAffineTransformMakeTranslation` (and other options). – DonMag Apr 10 '17 at 19:47
-
Hello, as far as im concerned, CGAffineTransformMakeScale scales things, but i want to expand it not scaling it up. – Reza.Ab Apr 10 '17 at 19:49
-
1Can you show me what you mean by the difference - using the path in your image - between expand and scale? – DonMag Apr 10 '17 at 19:50
-
the difference is that, imagine I have a triangle, if i scale it up using CGAffineTransformMakeScale, the angles will open up a bit and the sides will be bended a little bit but if i expand it, it's angles will have the same amount of degree and the sides will stay straight. – Reza.Ab Apr 10 '17 at 19:53
-
1I think the OP is trying to do a classic "expand stroke". So if the original is the key line, the new path is the outer bounds of a 2X wide path. – Warren Burton Apr 10 '17 at 20:00
-
2OK - I believe I understand it (sorry, should have clicked sooner)... Could setting a really thick stroke for the path do the job? – DonMag Apr 10 '17 at 20:02
-
1From a visual perspective yes, drawing the path at X wide would work but that doesn't give you the path. This answer may help http://stackoverflow.com/a/2951077/408390 – Warren Burton Apr 10 '17 at 20:07
-
Thank you all for answers but I dont want to draw anything, I need to expand a closed path which user draws ( and closes) as a selection which is gonna crop an image beneath it so I can apply feather effect on the cropped image by this path. I've got my feather effect working well. i only need to expand user's selection area ( bezierpath) up so the feather effect wouldnt remove any eccesive amount of Image.@DonMag @WarrenBurton – Reza.Ab Apr 10 '17 at 20:20
-
2@Reza.Ab - maybe..... http://stackoverflow.com/questions/42572434/get-uibezierpath-strokes-outline-path – DonMag Apr 10 '17 at 20:40
-
Thank you so much, Im gonna try this. @DonMag – Reza.Ab Apr 10 '17 at 20:51
-
Actually it didn't work, his code wasnt giving me the outlined path from his bezierpath's stroke, but thank you for sharing. Im still trying to make it work by this method. @DonMag – Reza.Ab Apr 10 '17 at 21:03
-
1OK - you might look at "Vector Boolean"... Obj-C here: https://bitbucket.org/andyfinnell/vectorboolean Swift here: https://github.com/lrtitze/Swift-VectorBoolean ... I don't know if it has an "expand" function (just took a really quick look), but I was able to *union* an original BezPath with an "expanded" one created with `CGPathCreateCopyByStrokingPath()` – DonMag Apr 10 '17 at 22:57
-
Thank you, I checked the code but nope, doesn't solve the problem unfotunately. I'm still wondering why "Get UIBezierPath Stroke's Outline" doesnt work either because theoratically it should but doesn't. @DonMag – Reza.Ab Apr 12 '17 at 16:02
-
@Reza.Ab - I played around with it and thought I was on the right track... Do you have a pre-generated UIBezierPath you could send me so I could try to replicate what you're looking at? – DonMag Apr 12 '17 at 16:05
-
Sure, my code is too long but what I do is actually based on this project in basics, user draws a uibezierpath and it has to be a closed path and then i just want the drawn path to be expanded and take that new path to do things with it. here is the project my drawing code is based on it. https://github.com/david2Coders/TestPlotPart1 @DonMag – Reza.Ab Apr 12 '17 at 17:17
-
@Reza.Ab - ah, I should have been explicit... When you run your app, set a breakpoint where you close the path. In the debug console, do a `po [thePath description]` ... that should give you a "readable" set of lines that I should be able to easily re-draw. – DonMag Apr 12 '17 at 17:21
-
1Ah - never mind ... I have a good bezier to play around with. – DonMag Apr 12 '17 at 17:46
-
sorry for asking, could you come up with any idea? @DonMag – Reza.Ab Apr 17 '17 at 16:57