{"id":300,"date":"2019-09-11T17:48:56","date_gmt":"2019-09-11T23:48:56","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=300"},"modified":"2019-09-11T22:13:26","modified_gmt":"2019-09-12T04:13:26","slug":"huh","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2019\/09\/11\/huh\/","title":{"rendered":"Huh !?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Something I never really gave much thought about made me do a bit of a double take today.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you assign a color literal to a color variable you get what might look like &#8220;funny&#8221; behaviour when compared to other types of variables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For instance, if you do<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dim c As Color = &amp;c12345<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">what you get in the color is the color value &amp;c12345000, a right zero fill, instead of &amp;c00012345, a left zero fill.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If however you do something like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dim i32 As Int32 = &amp;h12345<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">what you get is a 32 bit value that is analogous to &amp;h00012345 and its left zero filled.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So why does a color do a zero fill on the &#8220;right&#8221; and yet an integer, which is also a 32 bit value, you get what looks like a zero fill on the left ?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I suppose internally the compiler is actually doing something like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dim i32 As Int32 = Int32 (&amp;h12345)\nDim c As Color = Color(i32)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It first converts the &amp;c notation into an Int32 which is then recast as a color and since a color, in hex, is actually AARRGGBB where a color is RRGGBBAA this is why you get the apparent &#8220;right zero fill&#8221; for a color.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One of those things you just take for granted and never really think about.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now what got me even thinking about this ? The code editors display of a color literal.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"287\" height=\"37\" src=\"https:\/\/i0.wp.com\/www.great-white-software.com\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-11-at-10.07.45-PM.png?resize=287%2C37&#038;ssl=1\" alt=\"\" class=\"wp-image-302\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">It struck me that IF a color literal was left zero filled like you might assume it would be then this image SHOULD look like this<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"287\" height=\"37\" src=\"https:\/\/i0.wp.com\/www.great-white-software.com\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-11-at-10.07.45-PM-copy.png?resize=287%2C37&#038;ssl=1\" alt=\"\" class=\"wp-image-304\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">But, since I assume the compiler is doing the conversion of a color via an Int32. you get LEFT zero filling on the color constant and it shows up the way it does.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One of those things I just never really thought of in all the time I&#8217;ve used Xojo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Something I never really gave much thought about made me do a bit of a double take today. If you assign a color literal to a color variable you get what might look like &#8220;funny&#8221; behaviour when compared to other types of variables. For instance, if you do what you get in the color is &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2019\/09\/11\/huh\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Huh !?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-300","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":3,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/300\/revisions"}],"predecessor-version":[{"id":305,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/300\/revisions\/305"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}