setLineDash for grid lines
setLineDash for grid lines
- Subject: setLineDash for grid lines
- From: Lorenzo <email@hidden>
- Date: Thu, 16 Dec 2004 13:27:05 +0100
Hi,
in my view I would like to draw a serie of grid lines as dotted lines.
Originally, just to draw normal lines I used to draw the grid lines in the
drawRect call of my view using
[NSBezierPath strokeLineFromPoint:pointA toPoint:pointB];
it works well and it doesn't require I initialize and retain a bezierPath.
But now I would like to draw the lines as dotted lines so I tried to use
[gridLine setLineDash:pat count:2 phase:0.0];
I can see the dotted lines but this API requires I initialize the path with
gridLine = [[NSBezierPath bezierPath] retain];
[gridLine moveToPoint:pointA];
[gridLine lineToPoint:pointB];
[gridLine setLineDash:pat count:2 phase:0.0];
then, within the drawRect call, since the frame view can change its size, I
have to iterate though all the grid lines changing the associated points of
the 2 elements of each line. And this slows down the refresh speed
dramatically. I cannot use that.
- (void)drawRect:(NSRect)rect
{
for(i = 0; i < totHorizontalLines; i++){
gridLinePoints[0].x = rect.origin.x;
gridLinePoints[0].y = i + 0.5;
[gridLine setAssociatedPoints:gridLinePoints atIndex:0];
gridLinePoints[0].x = rect.size.width;
gridLinePoints[0].y = i + 0.5;
[gridLine setAssociatedPoints:gridLinePoints atIndex:1];
[gridLine stroke];
}
}
Do you know a faster way to draw grid dotted lines in my view?
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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