{"id":5561,"date":"2013-12-12T05:06:45","date_gmt":"2013-12-11T18:06:45","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5561"},"modified":"2013-12-12T05:06:45","modified_gmt":"2013-12-11T18:06:45","slug":"phphtmljavascript-canvas-rotation-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/phphtmljavascript-canvas-rotation-tutorial\/","title":{"rendered":"PHP\/HTML\/Javascript Canvas Rotation Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Canvas\/\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP\/HTML\/Javascript Canvas Rotation Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Canvas\/canvas_angle.jpg\" title=\"PHP\/HTML\/Javascript Canvas Rotation Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP\/HTML\/Javascript Canvas Rotation Tutorial<\/p><\/div>\n<p>The Canvas HTML element tag can be used as the container to draw graphics on the fly usually via the use of Javascript functions for rendering and event management.   Today we build on the <a target=_blank title='HTML\/Javascript Canvas Primer Tutorial' href='#hjcpt'>HTML\/Javascript Canvas Primer Tutorial<\/a> as shown below by trying to introduce rotation as a concept.   Wanted to rotate the child HTML elements of the canvas on an individual basis, because wanted to design a new Australian flag &#8230; chortle, chortle &#8230; but this is not as easy as it might seem &#8230; have a read <a target=_blank title='Difficulties of canvas indivual element rotation ... bummer for flag-making idea' href='http:\/\/stackoverflow.com\/questions\/2677671\/how-do-i-rotate-a-single-object-on-an-html-5-canvas'>here<\/a>, and so, we will chip away at the problem over time.<\/p>\n<p>In any case, whether it works or not, thought the best thing to have a chance to achieve the aim would be to assign each child canvas HTML element a class, so that CSS could be part of the equation &#8230; nice thought (first mentioned at this blog regarding <a target=_blank title='HTML element rotation via CSS' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5353#lirotation'>PHP\/Javascript\/HTML Sun Angle Tutorial<\/a>), but only partially helpful &#8230; warts and all, try it in a <a target=_blank title='live run' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Canvas\/\">live run<\/a>, for yourself.   In order to do this, find complex HTML select tag element constructions are easier to manage by introducing a <i>&#8220;shell&#8221;<\/i> of PHP, but for the purposes of what is technically going on, you would not have to do this &#8230; and if you don&#8217;t have PHP, then do a <a target=_blank title='live run' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Canvas\/\">live run<\/a> and while it is on the screen in your browser get to View Source and copy\/paste code to get a starting point for your HTML\/Javascript[\/CSS] peregrinations &#8230; cute, huh! &#8230; peregrinations &#8230; yes, <strike>penguin<\/strike>ations &#8230; peregrinations.<\/p>\n<p>In today&#8217;s tutorial we touch on a couple of the two dimensional Javascript functions to draw a rectangle or arc, but in the two dimensional context, canvas HTML elements can be used to draw text, lines, boxes and circles as well.<\/p>\n<p>You may want to read more at <a target=_blank title='HTML Canvas Reference' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'>HTML Canvas Reference<\/a> as a generic reference, or here, at the tutorial <a target=_blank title='javascript - How do I add a simple onClick event handler to a canvas element? - Stack Overflow' href='http:\/\/stackoverflow.com\/questions\/9880279\/how-do-i-add-a-simple-onclick-event-handler-to-a-canvas-element'>javascript &#8211; How do I add a simple onClick event handler to a canvas element? &#8211; Stack Overflow<\/a>.<\/p>\n<p>As you can imagine, this HTML canvas element, new to HTML5, can be very useful for some practical client-side web functionality.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Canvas\/canvas.php_GETME' title='canvas.php'>canvas.php<\/a>\n<\/p>\n<p>You&#8217;ll notice heavy use of the Javascript <a target=_blank title='Javascript Math.random() information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_random.asp'>Math.random()<\/a> function.<\/p>\n<p>We hope you enjoy this tutorial as a <a target=_blank title='Canvas HTML element live run tutorial'  href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/\">live run<\/a>.<\/p>\n<p>Yes &#8230; you&#8217;ve reached the end &#8230; have a top supportive day!<\/p>\n<hr \/>\n<p id='hjcpt'>Previous <a target=_blank title='HTML\/Javascript Canvas Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5539'>HTML\/Javascript Canvas Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML\/Javascript Canvas Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/HTML_canvas.jpg\" title=\"HTML\/Javascript Canvas Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML\/Javascript Canvas Primer Tutorial<\/p><\/div>\n<p>The Canvas HTML element tag can be used as the container to draw graphics on the fly usually via the use of Javascript functions for rendering and event management.<\/p>\n<p>In today&#8217;s tutorial we touch on a couple of the two dimensional Javascript functions to draw a rectangle or arc, but in the two dimensional context, canvas HTML elements can be used to draw text, lines, boxes and circles as well.<\/p>\n<p>You may want to read more at <a target=_blank title='HTML Canvas Reference' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'>HTML Canvas Reference<\/a> as a generic reference, or here, at the tutorial <a target=_blank title='javascript - How do I add a simple onClick event handler to a canvas element? - Stack Overflow' href='http:\/\/stackoverflow.com\/questions\/9880279\/how-do-i-add-a-simple-onclick-event-handler-to-a-canvas-element'>javascript &#8211; How do I add a simple onClick event handler to a canvas element? &#8211; Stack Overflow<\/a>.<\/p>\n<p>As you can imagine, this HTML canvas element, new to HTML5, can be very useful for some practical client-side web functionality.<\/p>\n<p>Link to some downloadable HTML programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/canvas.html_GETME' title='canvas.html'>canvas.html<\/a>\n<\/p>\n<p>You&#8217;ll notice heavy use of the Javascript <a target=_blank title='Javascript Math.random() information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_random.asp'>Math.random()<\/a> function.<\/p>\n<p>We hope you enjoy this tutorial as a <a target=_blank title='Canvas HTML element live run tutorial'  href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/\">live run<\/a>.<\/p>\n<p>Yes &#8230; you&#8217;ve reached the end &#8230; have a top supportive day!<\/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='#d5539' onclick='var dv=document.getElementById(\"d5539\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=59\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d5539' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\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='#d5561' onclick='var dv=document.getElementById(\"d5561\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=59\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d5561' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Canvas HTML element tag can be used as the container to draw graphics on the fly usually via the use of Javascript functions for rendering and event management. Today we build on the HTML\/Javascript Canvas Primer Tutorial as shown &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/phphtmljavascript-canvas-rotation-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":[184,281,576,578,652,932,997,1072,1319],"class_list":["post-5561","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-canvas","tag-css","tag-html","tag-html5","tag-javascript","tag-php","tag-programming","tag-rotation","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/5561"}],"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=5561"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/5561\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=5561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=5561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=5561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}