• 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: Setting the origin of a GC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the origin of a GC


  • Subject: Re: Setting the origin of a GC
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Sun, 6 Jul 2003 23:00:17 +0100

On Sunday, July 6, 2003, at 10:13 pm, Jim Crafton wrote:

I notice that when drawing in Cocoa (or Quartz for that matter) the origin is set to bottom left (0,0). Somewhere I read, but I can't remember now, that there is an easy way to set it to be top, left. Is this true? If it is not, what is the best way to accomplish this? (Any samples of this would be great!)

The normal way to do this is to have your NSView subclass return YES in response to an isFlipped message. Since you're working outside of the normal view architecture, the right way to do it in your case would probably be to apply an NSAffineTransform to the graphics context; you probably want to do:

NSAffineTransform *myTransform = [[NSAffineTransform transform] scaleXBy:1.0 yBy:-1.0];

then with the relevant context selected (e.g. with lockFocus)

[myTransform concat];

You might also want to take account of the fact that co-ordinates fall on the grid *between pixels* (at least by default); by default Quartz will quite happily draw a two pixel wide line (50% in each side) if asked to render a one pixel wide line at integer co-ordinates. This is typically not what people expect if they're used to other systems, and to fix it you need to translate the co-ordinate system by 0.5 pixels in each direction (to line the grid up with the centres of the pixels).

Kind regards,

Alastair.
_______________________________________________
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: Setting the origin of a GC
      • From: Jim Crafton <email@hidden>
References: 
 >Setting the origin of a GC (From: Jim Crafton <email@hidden>)

  • Prev by Date: Re: Project Builder and scripting
  • Next by Date: SQLite problem
  • Previous by thread: Setting the origin of a GC
  • Next by thread: Re: Setting the origin of a GC
  • Index(es):
    • Date
    • Thread