title: Centering an NSRect with code
body: <p>Hey all, I have a project that I am working on and I have noticed that my NSRect that I draw at a certain x, y coordinate that would be the center for the resolution I am working on, is not the center if the resolution changes. I understand how it all works. </p>
  
  <p>The Issue is that my project is going to be displayed on multiple resolutions does anyone know of a possible solution to centering the NSrect regardless of what aspect or resolution the screen is in. I have my classes declared as NSPanels that have custom drawing. Any ideas on a possible solution would be helpful. Thanks all.</p>
  
  <p>This is the NSRect x, y, width, height </p>
  
  <pre><code>NSRect windowFrame = NSMakeRect(400, 500, 500, 100);
  </code></pre>
  
  <p>then </p>
  
  <pre><code>window = [[Mainbox alloc] initWithContentRect:windowFrame 
                                            styleMask:NSBorderlessWindowMask 
                                              backing:NSBackingStoreBuffered 
                                                defer:NO];
  </code></pre>