{"id":153,"date":"2008-10-08T01:34:15","date_gmt":"2008-10-08T06:34:15","guid":{"rendered":"http:\/\/vgable.com\/blog\/2008\/10\/08\/drawing-the-floor\/"},"modified":"2009-05-25T03:11:05","modified_gmt":"2009-05-25T08:11:05","slug":"drawing-the-floor","status":"publish","type":"post","link":"https:\/\/vgable.com\/blog\/2008\/10\/08\/drawing-the-floor\/","title":{"rendered":"Drawing the floor()"},"content":{"rendered":"<p>So when drawing a custom-Cocoa-control, I had an issue where an <code>NSImage<\/code> (bitmap) and an <code>NSBezierPath<\/code> (vector-shape) didn&#8217;t move in sync with each other.<\/p>\n<p>Using <code>floor()<\/code> to force all pixel-coordinate to be a whole number fixed the problem.  There is probably a much better solution &#8212; after-all this was the first custom-control I have ever done in Cocoa.  But when a simple solution works&#8230;<\/p>\n<p>UPDATED: 2009-05-25: <a href=\"http:\/\/twitter.com\/cocoadevcentral\">@cocoadevcentral<\/a> tweets,<\/p>\n<blockquote><p><code>NSIntegralRect()<\/code> and <code> CGRectIntegral()<\/code> take a rect and return a copy which is aligned to integer coordinates. Good to avoid blurriness.<\/p><\/blockquote>\n<p>They sound like a better solution then calling <code>floor()<\/code> on each element of an image.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So when drawing a custom-Cocoa-control, I had an issue where an NSImage (bitmap) and an NSBezierPath (vector-shape) didn&#8217;t move in sync with each other. Using floor() to force all pixel-coordinate to be a whole number fixed the problem. There is probably a much better solution &#8212; after-all this was the first custom-control I have ever [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,6,12,3,5,4],"tags":[424,271,425,201,202,423],"class_list":["post-153","post","type-post","status-publish","format-standard","hentry","category-bug-bite","category-cocoa","category-design","category-macosx","category-objective-c","category-programming","tag-cgrect","tag-floating-point","tag-floor","tag-nsbezierpath","tag-nsimage","tag-nsrect"],"_links":{"self":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":0,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"wp:attachment":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}