• 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: "Louis C. Sacha" <email@hidden>
  • Date: Tue, 6 Jul 2004 22:42:10 -0700

Hello...

It definitely depends on the kind of path and the kind of calculations that need to be done.


It may or may not be an issue for the original poster, but this approach won't work corectly in some common situations, specifically instances where some "feature" of the path is intended to be at a contant size or aspect ratio and the path would need to be scaled to any arbitrary size.

One example would be the "rectangle with rounded corners" look and variations on that theme, where the rectangle can be any arbitrary size but the corners always use the same radius or arc. If you tried to do this with an affine transform, the curve at the corner would also be scaled and potentially be distorted if the aspect ratio of the new size is different from the original used to calculate the original path.


On the other hand, if all the features of the path need to be scaled identically and the aspect ratio doesn't matter, then the approach that Scott provided is significantly easier than recalculating the path for each size.

Louis


Depending on what kind of calculations you have to do to come up with your curve points, one option you might consider. Instead of recalculating the control points each time based on the new size of the label, calculate the points once and then, before you draw your label, use an NSAffineTransform to scale the drawing context to the size that is appropriate for the label.

That is to say, assume that your drawing is going to go to a label that is 100 x 100 and calculate the points for your bezier path. Then, instead of calculating a new set of points use an NSAffineTransform with a to scale the coordinate system by (actualWidth / 100, actualHeight / 100)

Is that clear as mud?

The point is that using this technique you should be able to eliminate the calculations of the coordinates because you only ever do them once. If they are right at one size then they should work at all sizes.

Scott
_______________________________________________
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: Wilhelm Phillips <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>)
 >Re: erasing, redrawing NSBezierPath into and NSImage problem (From: Wilhelm Phillips <email@hidden>)
 >Re: erasing, redrawing NSBezierPath into and NSImage problem (From: Scott Thompson <email@hidden>)

  • Prev by Date: Re: Custom view crashes app for some
  • Next by Date: Re: Custom view crashes app for some
  • 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