• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
setLineDash for grid lines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: setLineDash for grid lines
      • From: glenn andreas <email@hidden>
  • Prev by Date: Variable looses it's value
  • Next by Date: Re: Variable looses it's value
  • Previous by thread: RE: Variable looses it's value
  • Next by thread: Re: setLineDash for grid lines
  • Index(es):
    • Date
    • Thread