{"id":24223,"date":"2016-08-19T03:01:35","date_gmt":"2016-08-18T17:01:35","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=24223"},"modified":"2019-11-09T18:47:13","modified_gmt":"2019-11-09T08:47:13","slug":"analogue-clock-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/analogue-clock-primer-tutorial\/","title":{"rendered":"Analogue Clock Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/analogue_clock.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Analogue Clock Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/analogue_clock.jpg\" title=\"Analogue Clock Primer Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">Analogue Clock Primer Tutorial<\/p><\/div>\n<p>Today we&#8217;re writing a web application with HTML and CSS3 and Javascript DOM functionality to write a fairly minimalist Greenwich Mean Time (GMT) analogue clock.  It&#8217;s early days with this project, and today&#8217;s work is just a &#8220;first draft&#8221;.<\/p>\n<p>Although we could, we decide against using the HTML5 <a target=_blank title='HTML Canvas element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'>canvas<\/a> element for this job, showing you a fairly pared down HTML solution relying on <a target=_blank title='Javascript DOM style.transform usage of CSS3 transform property information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/prop_style_transform.asp'>Javascript DOM<\/a> dynamic application of the principles of CSS3 <a target=_blank title='CSS3 transform property information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/css3_pr_transform.asp'>transform<\/a> property.<\/p>\n<p>This is one of those ironic situations where a computer program is more involved, with presenting an analogue view of something, rather than a digital view, which does not involve much more than the rearrangement of the characters of what the Javascript Date&#8217;s objects <a target=_blank title='Javascript Date object method toUTCString information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_toutcstring.asp'>toUTCString<\/a> method returns to you.  In fact, in today&#8217;s code we go &#8220;through&#8221; this toUTCString method&#8217;s return value, and work with that to derive the angle required for the &#8220;ourbrg&#8221; variable of the Javascript (DOM) code snippet below &#8230;<\/p>\n<p><code><br \/>\n    try { document.getElementById('compass_needle' + hands[i]).style.webkitTransform = (\" rotate(\" + (ourbrg) + \"deg)\"); } catch(e10) { }<br \/>\n    try { document.getElementById('compass_needle' + hands[i]).style.MozTransform = (\" rotate(\" + (ourbrg) + \"deg)\"); } catch(e10) { }<br \/>\n    try { document.getElementById('compass_needle' + hands[i]).style.msTransform = (\" rotate(\" + (ourbrg) + \"deg)\"); } catch(e10) { }<br \/>\n    try { document.getElementById('compass_needle' + hands[i]).style.OTransform = (\" rotate(\" + (ourbrg) + \"deg)\"); } catch(e10) { }<br \/>\n    try { document.getElementById('compass_needle' + hands[i]).style.transform = (\" rotate(\" + (ourbrg) + \"deg)\"); } catch(e10) { }<br \/>\n<\/code><\/p>\n<p>The rest of what makes the analogue clock tick &#8230; <font size=1>chortle, chortle<\/font> &#8230; channels what we so often channel around here at this blog relating to <a target=_blank title='Overlay blog postings here' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/overlay'>&#8220;overlay&#8221;<\/a> principles, and the usual list of &#8220;suspects&#8221;, shall we say, being &#8230;<\/p>\n<ul>\n<li><a target=_blank title='CSS position:absolute information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_class_position.asp'>position:absolute<\/a> property<\/li>\n<li><a target=_blank title='CSS z-index information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_pos_z-index.asp'>z-index<\/a><\/li>\n<li><a target=_blank title='CSS opacity property information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/css3_pr_opacity.asp'>opacity<\/a><\/li>\n<\/ul>\n<p> &#8230; with that last opacity one even being brought into play to differentiate the hour from the minute from the second hand.  Why do that?  Well, we&#8217;ve determined for this job to only use the one media resource, an image for a compass needle &#8230; <br \/><img title='Compass Needle' src='\/\/www.rjmprogramming.com.au\/HTMLCSS\/compass-needle.png'><\/img><!--img title='Compass Needle' src='http:\/\/marylandlearninglinks.org\/wp-content\/themes\/learning-links\/img\/compass-needle.png'><\/img--><br \/> &#8230; we first started using with <a target=_blank title='HTML5 Device Orientation Events Game Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/html5-device-orientation-events-game-tutorial\/'>HTML5 Device Orientation Events Game Tutorial<\/a> which we present tomorrow.<\/p>\n<p>We use it for everything and use the very useful CSS <a target=_blank title=\"CSS overflow:hidden idea information from w3schools ... thanks\" href=\"http:\/\/www.w3schools.com\/cssref\/pr_pos_overflow.asp\">overflow: hidden<\/a> style property that we find very helpful here and at a few other places too &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Trip Mobile Device Usage Clock Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/trip-mobile-device-usage-clock-tutorial'>Trip Mobile Device Usage Clock Tutorial<\/a><\/li>\n<li><a target=_blank title='HTML\/Javascript\/CSS Reveal Top Left to Bottom Right Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascriptcss-reveal-top-left-to-bottom-right-tutorial'>HTML\/Javascript\/CSS Reveal Top Left to Bottom Right Tutorial<\/a><\/li>\n<li><a target=_blank title='HTML\/Javascript\/CSS Reveal Left to Right Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascriptcss-reveal-left-to-right-primer-tutorial'>HTML\/Javascript\/CSS Reveal Left to Right Primer Tutorial<\/a><\/li>\n<li><a target=_blank title='HTML\/Javascript\/CSS Reveal Top to Bottom Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascriptcss-reveal-top-to-bottom-primer-tutorial'>HTML\/Javascript\/CSS Reveal Top to Bottom Primer Tutorial<\/a><\/li>\n<\/ul>\n<p>So here is the HTML and CSS and Javascript programming source code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/analogue_clock.html_GETME\" title=\"analogue_clock.html\">analogue_clock.html<\/a> that goes with this <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/analogue_clock.html\" title=\"Click picture\">live run<\/a> link.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d24223' onclick='var dv=document.getElementById(\"d24223\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/time\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d24223' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today we&#8217;re writing a web application with HTML and CSS3 and Javascript DOM functionality to write a fairly minimalist Greenwich Mean Time (GMT) analogue clock. It&#8217;s early days with this project, and today&#8217;s work is just a &#8220;first draft&#8221;. Although &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/analogue-clock-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[1933,281,282,354,576,652,894,997,1063,1072,1094,1279,1298,1299,1319],"class_list":["post-24223","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-clock","tag-css","tag-css3","tag-dom","tag-html","tag-javascript","tag-overlay","tag-programming","tag-reveal","tag-rotation","tag-scale","tag-time","tag-transform","tag-transformation","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/24223"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=24223"}],"version-history":[{"count":20,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/24223\/revisions"}],"predecessor-version":[{"id":47125,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/24223\/revisions\/47125"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=24223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=24223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=24223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}