{"id":86,"date":"2008-11-07T00:00:30","date_gmt":"2008-11-07T07:00:30","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=175"},"modified":"2008-11-07T00:00:30","modified_gmt":"2008-11-07T07:00:30","slug":"xor-color-invert","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=86","title":{"rendered":"XOR Color Invert"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar yellow:uint = 0xFFFF00;\r\n\r\n\/\/ draws yellow circle\r\nwith(graphics) beginFill(yellow), drawCircle(100,100,50);\r\n\r\n\/\/ invert the color using XOR assignment\r\n\/\/ yellow becomes 0x0000FF\r\nyellow ^= 0xFFFFFF;\r\n\r\n\/\/ draws blue  circle \r\nwith(graphics) beginFill(yellow), drawCircle(200,100,50);\r\n<\/pre>\n<p>Just a fun use for XOR. You could also do it without XOR assignment:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nwith(graphics) beginFill(yellow ^ 0xFFFFFF), drawCircle(200,100,50);\r\n<\/pre>\n<p>Playing a little with bitwise operators is a good way to make sure you understand them. Try tweaking this trace statement:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\ntrace((0x543210 ^ 0xFFFFFF).toString(16));\r\n<\/pre>\n<p>If you&#8217;d like to read about bitwise operators, I recommend <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bitwise_operation\">wikipedia&#8217;s article<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var yellow:uint = 0xFFFF00; \/\/ draws yellow circle with(graphics) beginFill(yellow), drawCircle(100,100,50); \/\/ invert the color using XOR assignment \/\/ yellow becomes 0x0000FF yellow ^= 0xFFFFFF; \/\/ draws blue circle with(graphics) beginFill(yellow), drawCircle(200,100,50); Just a fun use for XOR. You could also do it without XOR assignment: with(graphics) beginFill(yellow ^ 0xFFFFFF), drawCircle(200,100,50); Playing a little with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,36],"tags":[38,39,40],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-one-liners","category-operators","tag-binary","tag-bitwise","tag-color"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=86"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/86\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}