{"id":202,"date":"2009-03-12T16:47:46","date_gmt":"2009-03-13T00:47:46","guid":{"rendered":"http:\/\/www.antunkarlovac.com\/blog\/?p=202"},"modified":"2009-03-12T16:47:46","modified_gmt":"2009-03-13T00:47:46","slug":"colors-in-42","status":"publish","type":"post","link":"https:\/\/www.antunkarlovac.com\/blog\/2009\/03\/12\/colors-in-42\/","title":{"rendered":"Where Have All the Colors Gone?"},"content":{"rendered":"<p>In OpenLaszlo you&#8217;ve always been able to specify colors in a variety of ways. In tags, you could use named colors, JavaScript hexadecimal notation and pound (hex) notation:<\/p>\n<pre>&lt;view bgcolor=\"red\" width=\"20\" height=\"20\" \/&gt;\r\n&lt;view bgcolor=\"0xff0000\" width=\"20\" height=\"20\" \/&gt;\r\n&lt;view bgcolor=\"#ff0000\" width=\"20\" height=\"20\" \/&gt;<\/pre>\n<p>In JavaScript, you could use either the hex notation or the named color:<\/p>\n<pre>myview.setAttribute(\"bgcolor\", 0xff0000);\r\nmyview.setAttribute(\"bgcolor\", red);<\/pre>\n<p>Note that in JavaScript, the color is a global variable; not a string. That&#8217;s important, because if you try to use the variable&#8217;s name in OpenLaszlo 4.2, you&#8217;ll get a Debugger warning:<\/p>\n<p>ERROR @colors.lzx#35: reference to undefined variable &#8216;red&#8217;<\/p>\n<p>That&#8217;s because all the colors are now neatly arranged in an array called lz.colors. So in 4.2 you would write:<\/p>\n<pre><span style=\"color: #ff0000;\">myview.setAttribute(\"bgcolor\", lz.colors.red);<\/span><\/pre>\n<p>Another benefit of the colors all being grouped in an array &#8211; as opposed to being global &#8211; is that you can loop through them. I wrote the following application to display the colors and color names available in OpenLaszlo 4.2.<\/p>\n\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n\t\t\tid=\"fm_colors_1444675076\"\n\t\t\tclass=\"flashmovie\"\n\t\t\twidth=\"460\"\n\t\t\theight=\"460\">\n\t<param name=\"movie\" value=\"\/blog\/wp-content\/uploads\/2009\/03\/colors.swf\" \/>\n\t<!--[if !IE]>-->\n\t<object\ttype=\"application\/x-shockwave-flash\"\n\t\t\tdata=\"\/blog\/wp-content\/uploads\/2009\/03\/colors.swf\"\n\t\t\tname=\"fm_colors_1444675076\"\n\t\t\twidth=\"460\"\n\t\t\theight=\"460\">\n\t<!--<![endif]-->\n\t\t\n\t<!--[if !IE]>-->\n\t<\/object>\n\t<!--<![endif]-->\n<\/object>\n<p>Click the button to render the color boxes. Move your mouse over the boxes to display the name of the color.<\/p>\n<p>The code is below:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;canvas width=&quot;460&quot; height=&quot;460&quot; proxied=&quot;false&quot;&gt;\r\n\r\n    &lt;class name=&quot;colorbox&quot; width=&quot;30&quot; height=&quot;30&quot; clickable=&quot;true&quot;&gt;\r\n        &lt;attribute name=&quot;colorname&quot; type=&quot;string&quot; \/&gt;\r\n    &lt;\/class&gt;\r\n\r\n    &lt;class name=&quot;colornameoutput&quot; extends=&quot;text&quot;\r\n           font=&quot;Helvetica, Arial, sans-serif&quot;\r\n           fontsize=&quot;24&quot; fontstyle=&quot;bold&quot;&gt;\r\n        &lt;attribute name=&quot;updateDel&quot; \r\n                   value=&quot;$once{new lz.Delegate(this, &#039;displayColor&#039;)}&quot; \/&gt;\r\n        &lt;method name=&quot;displayColor&quot; args=&quot;c&quot;&gt;\r\n            this.setAttribute(&quot;text&quot;, &quot;lz.colors.&quot; + c.colorname);\r\n        &lt;\/method&gt;\r\n    &lt;\/class&gt;\r\n\r\n    &lt;simplelayout axis=&quot;y&quot; spacing=&quot;10&quot; \/&gt;\r\n     \r\n    &lt;view name=&quot;colorboxes&quot; width=&quot;100%&quot;&gt;\r\n        &lt;wrappinglayout spacing=&quot;0&quot; \/&gt;\r\n    &lt;\/view&gt;\r\n\r\n    &lt;colornameoutput name=&quot;outputText&quot;&gt;\r\n    &lt;\/colornameoutput&gt;\r\n\r\n    &lt;button options=&quot;ignorelayout&quot; width=&quot;80%&quot; \r\n            height=&quot;80%&quot; align=&quot;center&quot; valign=&quot;middle&quot;\r\n            font=&quot;Helvetica, Arial, sans-serif&quot;\r\n            fontsize=&quot;13&quot; fontstyle=&quot;bold&quot;&gt;\r\n            Show Me The Colors!\r\n            (Be patient, it takes a moment).\r\n        &lt;handler name=&quot;onclick&quot;&gt;\r\n            this.setAttribute(&quot;visible&quot;, false);\r\n            for (var i in lz.colors) {\r\n                var colorValue = lz.colors[i];\r\n                var attrs = {bgcolor: colorValue, colorname: i}; \r\n                var v = new lz.colorbox(colorboxes, attrs);\r\n                outputText.updateDel.register(v, &quot;onmouseover&quot;);\r\n            }\r\n        &lt;\/handler&gt;\r\n    &lt;\/button&gt;\r\n\r\n&lt;\/canvas&gt;\r\n<\/pre>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>In OpenLaszlo you&#8217;ve always been able to specify colors in a variety of ways. In tags, you could use named colors, JavaScript hexadecimal notation and pound (hex) notation: &lt;view bgcolor=&#8221;red&#8221; width=&#8221;20&#8243; height=&#8221;20&#8243; \/&gt; &lt;view bgcolor=&#8221;0xff0000&#8243; width=&#8221;20&#8243; height=&#8221;20&#8243; \/&gt; &lt;view bgcolor=&#8221;#ff0000&#8243; width=&#8221;20&#8243; height=&#8221;20&#8243; \/&gt; In JavaScript, you could use either the hex notation or the named &hellip; <a href=\"https:\/\/www.antunkarlovac.com\/blog\/2009\/03\/12\/colors-in-42\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Where Have All the Colors Gone?<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/202"}],"collection":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/comments?post=202"}],"version-history":[{"count":6,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/202\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/202\/revisions\/218"}],"wp:attachment":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/media?parent=202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/categories?post=202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/tags?post=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}