Re: Drawing after CGContextClosePath() still appends line

2013-08-21 Thread zou tian
may be you can try CGContextSaveState and  CGContextRestoreState ~~
在 2013年8月20日,上午8:03,Rick Mann rm...@latencyzero.com 写道:

 I'm drawing a couple of arcs and then calling ClosePath() to close up the 
 shape I drew. This works great. But then I repeat the process in a different 
 place, and stroke the whole thing. Unfortunately, Core Graphics adds a line 
 from the last point in the closed path to the first point of the new arc I 
 add. From my reading of the docs, this line shouldn't happen.
 
 After closing the subpath, your application can begin a new subpath without 
 first calling CGContextMoveToPoint. In this case, a new subpath is implicitly 
 created with a starting and current point equal to the previous subpath’s 
 starting point.
 
 Now, the AddArc() docs do say it might be preceded by a straight line 
 segment, but when the context first starts, there is no starting position; I 
 wonder why the subpath doesn't behave the same way after ClosePath().
 
 iOS 6.1.3, iPad simulator or device.
 
 -- 
 Rick
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/zoutian62%40icloud.com
 
 This email sent to zoutia...@icloud.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing after CGContextClosePath() still appends line

2013-08-21 Thread Graham Cox

On 20/08/2013, at 2:51 AM, Rick Mann rm...@latencyzero.com wrote:

 Obviously, it can't be changed now, but AddArc() should never have drawn that 
 first line segment. It's inconsistent with what you probably want, and with 
 other methods like CGContextAddLines() or CGContextAddRect().

Depends. In some cases it's really handy that it adds the line - e.g. for 
drawing round-cornered rectangles where calculating the actual end point of the 
arc is tedious - instead just use a centre point and radius and it figures out 
the rest for you.

I guess the engineer decided that these useful cases outweigh those other cases 
when it's a nuisance.

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing after CGContextClosePath() still appends line

2013-08-21 Thread David Duncan
On Aug 19, 2013, at 6:08 PM, zou tian zoutia...@icloud.com wrote:

 may be you can try CGContextSaveState and  CGContextRestoreState ~~


These functions don’t save and restore the current path.
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Drawing after CGContextClosePath() still appends line

2013-08-19 Thread Rick Mann
I'm drawing a couple of arcs and then calling ClosePath() to close up the shape 
I drew. This works great. But then I repeat the process in a different place, 
and stroke the whole thing. Unfortunately, Core Graphics adds a line from the 
last point in the closed path to the first point of the new arc I add. From my 
reading of the docs, this line shouldn't happen.

After closing the subpath, your application can begin a new subpath without 
first calling CGContextMoveToPoint. In this case, a new subpath is implicitly 
created with a starting and current point equal to the previous subpath’s 
starting point.

Now, the AddArc() docs do say it might be preceded by a straight line segment, 
but when the context first starts, there is no starting position; I wonder why 
the subpath doesn't behave the same way after ClosePath().

iOS 6.1.3, iPad simulator or device.

-- 
Rick




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing after CGContextClosePath() still appends line

2013-08-19 Thread Roland King

On 20 Aug, 2013, at 8:03 AM, Rick Mann rm...@latencyzero.com wrote:

 I'm drawing a couple of arcs and then calling ClosePath() to close up the 
 shape I drew. This works great. But then I repeat the process in a different 
 place, and stroke the whole thing. Unfortunately, Core Graphics adds a line 
 from the last point in the closed path to the first point of the new arc I 
 add. From my reading of the docs, this line shouldn't happen.
 
 After closing the subpath, your application can begin a new subpath without 
 first calling CGContextMoveToPoint. In this case, a new subpath is implicitly 
 created with a starting and current point equal to the previous subpath’s 
 starting point.
 

From my reading that's exactly what should happen. You close the subpath then 
you implicitly start one because you didn't call CGContextMoveToPoint() when 
you add the next arc, that path starts from the original starting point of the 
old subpath (which is functionally exactly the same as the endpoint). So the 
new subpath starts with a line to the start of your new arc from the start of 
the previous path. If you don't want that, do the move. 

There's a difference between a context with no path at all and a context which 
already contains subpaths, closed or not. 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing after CGContextClosePath() still appends line

2013-08-19 Thread Rick Mann

On Aug 19, 2013, at 17:25 , Roland King r...@rols.org wrote:

 
 On 20 Aug, 2013, at 8:03 AM, Rick Mann rm...@latencyzero.com wrote:
 
 I'm drawing a couple of arcs and then calling ClosePath() to close up the 
 shape I drew. This works great. But then I repeat the process in a different 
 place, and stroke the whole thing. Unfortunately, Core Graphics adds a line 
 from the last point in the closed path to the first point of the new arc I 
 add. From my reading of the docs, this line shouldn't happen.
 
 After closing the subpath, your application can begin a new subpath without 
 first calling CGContextMoveToPoint. In this case, a new subpath is 
 implicitly created with a starting and current point equal to the previous 
 subpath’s starting point.
 
 
 From my reading that's exactly what should happen. You close the subpath then 
 you implicitly start one because you didn't call CGContextMoveToPoint() when 
 you add the next arc, that path starts from the original starting point of 
 the old subpath (which is functionally exactly the same as the endpoint). So 
 the new subpath starts with a line to the start of your new arc from the 
 start of the previous path. If you don't want that, do the move. 
 
 There's a difference between a context with no path at all and a context 
 which already contains subpaths, closed or not. 

Oh, I think you're right. Pity. It makes working with arcs a real pain. I have 
to compute the arc's starting point and move to it. Unless I'm missing 
something?


-- 
Rick




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing after CGContextClosePath() still appends line

2013-08-19 Thread Roland King

On 20 Aug, 2013, at 8:36 AM, Rick Mann rm...@latencyzero.com wrote:

 
 On Aug 19, 2013, at 17:25 , Roland King r...@rols.org wrote:
 
 
 On 20 Aug, 2013, at 8:03 AM, Rick Mann rm...@latencyzero.com wrote:
 
 I'm drawing a couple of arcs and then calling ClosePath() to close up the 
 shape I drew. This works great. But then I repeat the process in a 
 different place, and stroke the whole thing. Unfortunately, Core Graphics 
 adds a line from the last point in the closed path to the first point of 
 the new arc I add. From my reading of the docs, this line shouldn't happen.
 
 After closing the subpath, your application can begin a new subpath 
 without first calling CGContextMoveToPoint. In this case, a new subpath is 
 implicitly created with a starting and current point equal to the previous 
 subpath’s starting point.
 
 
 From my reading that's exactly what should happen. You close the subpath 
 then you implicitly start one because you didn't call CGContextMoveToPoint() 
 when you add the next arc, that path starts from the original starting point 
 of the old subpath (which is functionally exactly the same as the endpoint). 
 So the new subpath starts with a line to the start of your new arc from the 
 start of the previous path. If you don't want that, do the move. 
 
 There's a difference between a context with no path at all and a context 
 which already contains subpaths, closed or not. 
 
 Oh, I think you're right. Pity. It makes working with arcs a real pain. I 
 have to compute the arc's starting point and move to it. Unless I'm missing 
 something?
 


So many ways to attack that. Stroke the segments one-by-one. Or instead of 
going right to the context, create a CGMutablePathRef() for each arc , draw to 
that, then add it to the context path. Heck if you are drawing the same shape 
each time you can even reuse the path and change the CTM to move it around when 
you add then then you only even have to draw it once. 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing after CGContextClosePath() still appends line

2013-08-19 Thread Ken Thomases
On Aug 19, 2013, at 7:36 PM, Rick Mann wrote:

 On Aug 19, 2013, at 17:25 , Roland King r...@rols.org wrote:
 
 
 On 20 Aug, 2013, at 8:03 AM, Rick Mann rm...@latencyzero.com wrote:
 
 I'm drawing a couple of arcs and then calling ClosePath() to close up the 
 shape I drew. This works great. But then I repeat the process in a 
 different place, and stroke the whole thing. Unfortunately, Core Graphics 
 adds a line from the last point in the closed path to the first point of 
 the new arc I add. From my reading of the docs, this line shouldn't happen.
 
 After closing the subpath, your application can begin a new subpath 
 without first calling CGContextMoveToPoint. In this case, a new subpath is 
 implicitly created with a starting and current point equal to the previous 
 subpath’s starting point.
 
 
 From my reading that's exactly what should happen. You close the subpath 
 then you implicitly start one because you didn't call CGContextMoveToPoint() 
 when you add the next arc, that path starts from the original starting point 
 of the old subpath (which is functionally exactly the same as the endpoint). 
 So the new subpath starts with a line to the start of your new arc from the 
 start of the previous path. If you don't want that, do the move. 
 
 There's a difference between a context with no path at all and a context 
 which already contains subpaths, closed or not. 
 
 Oh, I think you're right. Pity. It makes working with arcs a real pain. I 
 have to compute the arc's starting point and move to it. Unless I'm missing 
 something?

You can begin a new path for each arc.  If you ultimately want one path with 
multiple disjoint subpaths, I think you can create the arc subpaths as 
individual CGPath objects and add them to either the context path or to a 
master CGPath object.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing after CGContextClosePath() still appends line

2013-08-19 Thread Rick Mann

On Aug 19, 2013, at 17:47 , Ken Thomases k...@codeweavers.com wrote:

 On Aug 19, 2013, at 7:36 PM, Rick Mann wrote:
 
 On Aug 19, 2013, at 17:25 , Roland King r...@rols.org wrote:
 
 
 On 20 Aug, 2013, at 8:03 AM, Rick Mann rm...@latencyzero.com wrote:
 
 I'm drawing a couple of arcs and then calling ClosePath() to close up the 
 shape I drew. This works great. But then I repeat the process in a 
 different place, and stroke the whole thing. Unfortunately, Core Graphics 
 adds a line from the last point in the closed path to the first point of 
 the new arc I add. From my reading of the docs, this line shouldn't happen.
 
 After closing the subpath, your application can begin a new subpath 
 without first calling CGContextMoveToPoint. In this case, a new subpath is 
 implicitly created with a starting and current point equal to the previous 
 subpath’s starting point.
 
 
 From my reading that's exactly what should happen. You close the subpath 
 then you implicitly start one because you didn't call 
 CGContextMoveToPoint() when you add the next arc, that path starts from the 
 original starting point of the old subpath (which is functionally exactly 
 the same as the endpoint). So the new subpath starts with a line to the 
 start of your new arc from the start of the previous path. If you don't 
 want that, do the move. 
 
 There's a difference between a context with no path at all and a context 
 which already contains subpaths, closed or not. 
 
 Oh, I think you're right. Pity. It makes working with arcs a real pain. I 
 have to compute the arc's starting point and move to it. Unless I'm missing 
 something?
 
 You can begin a new path for each arc.  If you ultimately want one path with 
 multiple disjoint subpaths, I think you can create the arc subpaths as 
 individual CGPath objects and add them to either the context path or to a 
 master CGPath object.

This is basically what I'm doing now.

Obviously, it can't be changed now, but AddArc() should never have drawn that 
first line segment. It's inconsistent with what you probably want, and with 
other methods like CGContextAddLines() or CGContextAddRect().



-- 
Rick




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com