Re: help with bezpath please...
Re: help with bezpath please...
- Subject: Re: help with bezpath please...
- From: Lorenzo <email@hidden>
- Date: Mon, 17 Oct 2005 23:17:12 +0200
Hi Brian,
to render your bezier paths, you have to draw them the drawRect method of
your NSView
[[NSColor whiteColor] set];
[theBp setLineWidth:1.0];
[theBp stroke];
you can create and draw some other bezier line on the fly, in the drawRect
method too:
[NSBezierPath strokeLineFromPoint:a toPoint:b];
in order to draw the control points and the end points of the path you have
to iterate through all the elements of the path and draw each endPoint and
control point (a curve has an end point and 2 control points, while a line
has just one end Point - the first point really belongs to the previous line
or "MoveTo" element). So If you need to create/draw other points you have to
do that by yourself.
NSPoint points[3], endPoint, contrPa, contrPb;
NSBezierPathElement elem;
NSRect pointRect;
int e, totElem = [theBp elementCount];
for(e = 0; e < totElem: e++){
elem = [theBp elementAtIndex:e associatedPoints:points];
// if the element is a curve
if(elem == NSCurveToBezierPathElement){
endPoint = points[2];
pointRect = NSMakeRect(endPoint.x - 1, endPoint.y - 1, 2, 2);
[[NSColor whiteColor] set];
NSFrameRect(pointRect);
contrPa = points[0];
pointRect = NSMakeRect(contrPa.x - 1, contrPa.y - 1, 2, 2);
[[NSColor redColor] set];
NSFrameRect(pointRect]);
contrPb = points[1];
pointRect = NSMakeRect(contrPb.x - 1, contrPb.y - 1, 2, 2);
[[NSColor redColor] set];
NSFrameRect(pointRect);
}
// if the element is a line or MoveToPoint
else{
endPoint = points[0];
pointRect = NSMakeRect(endPoint.x - 1, endPoint.y - 1, 2, 2);
[[NSColor whiteColor] set];
NSFrameRect(pointRect);
}
// check for the other cases (ClosePoint)
}
Best Regards
--
Lorenzo
email: email@hidden
> Message: 15
> Date: Mon, 17 Oct 2005 12:58:02 -0600
> From: "Brian O'Brien" <email@hidden>
> Subject: help with bezpath please...
> To: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> does anyone know how to render a bezier path and have the control
> points drawn for me?
> I saw this done in the sketch example...
> ie... A line has two control points (One at each end)
> A Rectangle / Square has 8 control points 4 at the corners and one on
> each side..
> A Circle / Oval has 4 points on the bounding box and one at each
> tangent...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden