• 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
Re: erasing, redrawing NSBezierPath into and NSImage problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: erasing, redrawing NSBezierPath into and NSImage problem


  • Subject: Re: erasing, redrawing NSBezierPath into and NSImage problem
  • From: Wilhelm Phillips <email@hidden>
  • Date: Tue, 6 Jul 2004 00:28:02 -0700

Hi,

The drawing code uses 6 regular points and 8 control points which are
calculated to fit with cell height and width while creating my desired
shape.

// points and control points established

[bezierPath moveToPoint:p1];
[bezierPath curveToPoint:p2 controlPoint1:c1 controlPoint2:c2];
[bezierPath curveToPoint:p3 controlPoint1:c3 controlPoint2:c4];
[bezierPath lineToPoint:p4];
[bezierPath curveToPoint:p5 controlPoint1:c5 controlPoint2:c6];
[bezierPath curveToPoint:p6 controlPoint1:c7 controlPoint2:c8];
[bezierPath closePath];

// rest of code from below

I didn't include all of the drawing code because I know that it works
- at least once... ; )

When I launch the app awakeFromNib calls drawLabels and the path is
drawn correctly into each label image.

It's just the redrawing that seems to be a problem.

The erase image section below was from Louis' post. I was, at one
point trying to do the same thing, by filling my bezierPath with
clearColor. However, this did not have the effect of clearing the
image as I desired. Now, with the NSRectFill code below, I can clear
the image, but I cannot correctly draw a modified bezierPath into it.

I'm confused as to why this is. My Run Log shows that the control
points and regular points have been modified correctly but the new
modified path doesn't get drawn to the label images.

Will


On Jul 5, 2004, at 11:18 PM, Yann Bizeul wrote:

> Hi,
>> - (void)drawLabels
>> {
>> bezierPath = [NSBezierPath bezierPath];
>>
>> // here is where I draw theBezierPath
>> // based on cellHeight, cellWidth of labelMatrix, etc.
>>
>> someLabel = [[NSImage alloc] initWithSize:NSMakeSize(cellWidth,
>> cellHeight)];
>>
>> [someLabel lockFocus];
>>
>> // using clearColor to erase image
>> NSRect imageRect;
>> imageRect.origin = (NSPoint){0.0f,0.0f};
>> imageRect.size = [someLabel size];
>> [[NSColor clearColor] set];
>> NSRectFill(imageRect);
>>
>> // redraw modified bezierPath
>> someLabelColor = [NSColor colorWithCalibratedRed:0.0 green:0.5
>> blue:1.0 alpha:0.4];
>> [someLabelColor set];
>>
>> [bezierPath fill];
>>
>> [someLabel unlockFocus];
>>
>> [labelMatrix setNeedsDisplay: YES];
>> }
>
> Is that all you do ? Or did you forgot to mention how is defined your
> bezierPath ? It can be the key. maybe.
>
> --
> Yann Bizeul - yann at tynsoe.org
> http://projects.tynsoe.org/
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: erasing, redrawing NSBezierPath into and NSImage problem
      • From: Scott Thompson <email@hidden>
References: 
 >Re: erasing, redrawing NSBezierPath into and NSImage problem (From: Wilhelm Phillips <email@hidden>)
 >Re: erasing, redrawing NSBezierPath into and NSImage problem (From: Yann Bizeul <email@hidden>)

  • Prev by Date: Re: Kernel crash
  • Next by Date: Calling AppleScripts from Obj-C
  • Previous by thread: Re: erasing, redrawing NSBezierPath into and NSImage problem
  • Next by thread: Re: erasing, redrawing NSBezierPath into and NSImage problem
  • Index(es):
    • Date
    • Thread