{"id":49252,"date":"2020-06-11T03:01:44","date_gmt":"2020-06-10T17:01:44","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=49252"},"modified":"2020-06-10T14:09:18","modified_gmt":"2020-06-10T04:09:18","slug":"canvas-annotations-and-datetime-or-number-or-emoji-sequences-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/canvas-annotations-and-datetime-or-number-or-emoji-sequences-tutorial\/","title":{"rendered":"Canvas Annotations and Datetime or Number or Emoji Sequences Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/feedback.htm\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Canvas Annotations and Datetime or Number or Emoji Sequences Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/htmlentity_emoji.jpg\" title=\"Canvas Annotations and Datetime or Number or Emoji Sequences Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Canvas Annotations and Datetime or Number or Emoji Sequences Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a title='Canvas Annotations and Datetime or Number Sequences Tutorial' href='#cadnst'>Canvas Annotations and Datetime or Number Sequences Tutorial<\/a> was a basis to launch into some Annotation Sequences that can go beyond the 0 to 127 ascii values, into the &#8220;Wooooorrrrrlllllddddd of Emoji&#8221; and &#8220;HTML Entities&#8221; and &#8220;Unicode Characters&#8221;.  So far with emoji work we&#8217;ve never tried to map &#8220;HTML Entity Names&#8221; to a &#8220;String <a target=_blank title='CodePoint information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Code_point'>CodePoint<\/a>&#8220;.  What do we mean here by &#8220;HTML Entity Names&#8221;?  We mean a classification noting how HTML Entities like &#8230;<\/p>\n<table>\n<tr>\n<th>Character<\/th>\n<th>Description<\/th>\n<th>Entity Number &#8230; can have an &#8230;<\/th>\n<th>Entity <b>Name<\/b> &#8230; sometimes<\/th>\n<\/tr>\n<tr>\n<td>&amp;<\/td>\n<td>Ampersand<\/td>\n<td>&amp;#38;<\/td>\n<td>&amp;<b>amp<\/b>;<\/td>\n<\/tr>\n<tr>\n<td>&gt;<\/td>\n<td>Greater than<\/td>\n<td>&amp;#62;<\/td>\n<td>&amp;<b>gt<\/b>;<\/td>\n<\/tr>\n<tr>\n<td>&lt;<\/td>\n<td>Less than<\/td>\n<td>&amp;#60;<\/td>\n<td>&amp;<b>lt<\/b>;<\/td>\n<\/tr>\n<\/table>\n<p> &#8230; just to name some of the really commonly used ones, at least around here.  But there are lots of them and we thank the great Freeformatter website for <a target=_blank title='Useful link, thanks' href='https:\/\/www.freeformatter.com\/html-entities.html'>Complete list of HTML entities &#8211; FreeFormatter.com<\/a> as a great resource.<\/p>\n<p>As you might imagine, not every HTML Entity you can think of has a corresponding HTML Entity Name like this, so in <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/world.js--------------------------GETME' title='world.js'>our extension of external Javascript logic<\/a> of <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/world.js--------------------------GETME'>world.js<\/a> (again used in Annotations part of <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/feedback.htm\" title=\"Click picture\">feedback web application<\/a>) we allow the user to enter the integer of the String CodePoint (the function <a target=_blank title='String.fromCodePoint() information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/String\/fromCodePoint'>String.fromCodePoint<\/a>() references <font size=1>(and just quietly you can compose your own composite emoji type by including a decimal place like &#8220;127462.127482&#8221; for the Australian flag &#127462;&#127482; as an example)<\/font>) that can be used to display in the Feedback <a target=_blank title='HTML Canvas element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'>canvas<\/a> your emoji characters.<\/p>\n<p>The conduit by which we make the HTML Entity Name parts of the new <i>&#8220;c&#8221; format<\/i> functionality happen is via some new <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/html_entity_name_to_codepoint.php' title='html_entity_name_to_codepoint.php'>html_entity_name_to_codepoint.php<\/a> which is contacted by our external Javascript via new <a target=_blank title='Ajax information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Ajax_%28programming%29'>Ajax<\/a> and <a target=_blank title='FormData object information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/FormData'>FormData<\/a> object logic you can see two new Javascript functions for below &#8230;<\/p>\n<p><code><br \/>\nfunction ajaxEntityIt(inval) {<br \/>\n    if (inval != '') {<br \/>\n      ourfdstart=inval;<br \/>\n    }<br \/>\n    var lastxinc=eval(eval(x - lastx) \/ eval(-1 + eval(ourfdnumber)));<br \/>\n    var lastyinc=eval(eval(y - lasty) \/ eval(-1 + eval(ourfdnumber)));<br \/>\n    if (('' + ourfdstart).trim() != '') {<br \/>\n    for (var thisij=1; thisij&lt;ourfdnumber; thisij++) {<br \/>\n  context.font = document.getElementById('myfont').value;<br \/>\n  storecanvascommands(\"context.font = '\" + document.getElementById('myfont').value + \"';\", false);<br \/>\n  context.strokeStyle=document.getElementById('mycolour').value;<br \/>\n  storecanvascommands(\"context.strokeStyle='\" + document.getElementById('mycolour').value + \"';\", false);<br \/>\n  if (('' + ourfdstart).indexOf('.') != -1) {<br \/>\n  storecanvascommands(\"context.strokeText(String.fromCodePoint(\" + ('' + ourfdstart).replace(\/\\.\/g,',') + \"),\" + lastx + \",\" + lasty + \");\", false);<br \/>\n  eval(canvascommands[eval(-1 + canvascommands.length)]);<br \/>\n  } else {<br \/>\n  context.strokeText(String.fromCodePoint(eval('' + ourfdstart)),lastx,lasty);<br \/>\n  storecanvascommands(\"context.strokeText(String.fromCodePoint(\" + ourfdstart + \"),\" + lastx + \",\" + lasty + \");\", false);<br \/>\n  }<br \/>\n  lastx+=lastxinc;<br \/>\n  lasty+=lastyinc;<br \/>\n  if (('' + ourfdinc).replace('0','') != '') {<br \/>\n  ourfdstart=eval('' + ourfdstart);<br \/>\n  ourfdstart+=eval('' + ourfdinc);<br \/>\n  }<br \/>\n    }<br \/>\n  context.font = document.getElementById('myfont').value;<br \/>\n  storecanvascommands(\"context.font = '\" + document.getElementById('myfont').value + \"';\", false);<br \/>\n  context.strokeStyle=document.getElementById('mycolour').value;<br \/>\n  storecanvascommands(\"context.strokeStyle='\" + document.getElementById('mycolour').value + \"';\", false);<br \/>\n  if (('' + ourfdstart).indexOf('.') != -1) {<br \/>\n  storecanvascommands(\"context.strokeText(String.fromCodePoint(\" + ('' + ourfdstart).replace(\/\\.\/g,',') + \"),\" + lastx + \",\" + lasty + \");\", false);<br \/>\n  eval(canvascommands[eval(-1 + canvascommands.length)]);<br \/>\n  } else {<br \/>\n  context.strokeText(String.fromCodePoint(eval('' + ourfdstart)),lastx,lasty);<br \/>\n  storecanvascommands(\"context.strokeText(String.fromCodePoint(\" + ourfdstart + \"),\" + lastx + \",\" + lasty + \");\", false);<br \/>\n  }<br \/>\n  }<br \/>\n}<br \/>\n<br \/>\nfunction ajaxEntityNameIt() {<br \/>\n  if (ourzhr != null) {<br \/>\n  if (ourzhr.readyState == 4) {<br \/>\n    if (ourzhr.status == 200) {<br \/>\n    ourfdstart=ourzhr.responseText;<br \/>\n    ajaxEntityIt('');<br \/>\n    }<br \/>\n    ourzhr=null;<br \/>\n    ourzform=null;<br \/>\n  }<br \/>\n  }<br \/>\n}<br \/>\n<\/code><\/p>\n<p>Today&#8217;s <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/htmlentity_emoji.jpg\" title=\"Tutorial picture\">tutorial picture<\/a> shows us using this new emoji creation capability for &#8230;<\/p>\n<ul>\n<li>Greek Uppercase via &#8220;Alpha,24,1,c&#8221;<\/li>\n<li>Greek Lowercase via &#8220;alpha,24,1,c&#8221;<\/li>\n<li>ISO-8859-1 Characters via &#8220;192,64,1,c&#8221;<\/li>\n<\/ul>\n<p> &#8230; as a <i>sequencing sequence<\/i> you might say, but the third value can easily be zero (ie. 0) to create a <i>static (ie. repeated) sequence<\/i> for timesheet requirements like a &#8220;tick&#8221; (alas, the closest &#8220;HTML Entity Name&#8221; to tick is &#8220;radic&#8221; (&radic;) (though &#8220;10004&#8221; (&#10004;) will look more apt as a &#8220;tick&#8221;)).<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/new-canvas-annotations-and-datetime-or-number-or-emoji-sequences-tutorial\/'>Canvas Annotations and Datetime or Number or Emoji Sequences Tutorial<\/a>.<\/p-->\n<hr>\n<p id='cadnst'>Previous relevant <a target=_blank title='Canvas Annotations and Datetime or Number Sequences Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/canvas-annotations-and-datetime-or-number-sequences-tutorial\/'>Canvas Annotations and Datetime or Number Sequences Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/feedback.htm\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Canvas Annotations and Datetime or Number Sequences Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/dosequence.jpg\" title=\"Canvas Annotations and Datetime or Number Sequences Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Canvas Annotations and Datetime or Number Sequences Tutorial<\/p><\/div>\n<p>Today we&#8217;ve added some &#8230;<\/p>\n<ul>\n<li>two <a target=_blank title='HTML Canvas element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'>canvas<\/a> click based &#8230;\n<ol>\n<li>number &#8230; or &#8230;<\/li>\n<li>datetime<\/li>\n<\/ol>\n<\/li>\n<li>sequenced text annotation canvas placements<\/li>\n<\/ul>\n<p> &#8230; and you&#8217;ll probably guess the nature of our interest if we direct you to <a title='HTML Square Horizontal Rule Image Map Jigsaw Timesheet Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/html-square-horizontal-rule-image-map-jigsaw-timesheet-tutorial\/'>HTML Square Horizontal Rule Image Map Jigsaw Timesheet Tutorial<\/a> as background reading.<\/p>\n<p>Sequences are that predictable and pleasing thing to many people in mathematics whereby, just as with popular music, somehow you can work out what is coming next.  After all, music is all about sequences, with its scales and arpeggios and double stops etcetera.<\/p>\n<p>Requirements of the user are &#8230;<\/p>\n<ul>\n<li>two discrete clicks &#8230;<\/li>\n<li>click new button <img style='display:inline-block;' src='\/\/www.rjmprogramming.com.au\/MarkItUp\/sequence.png'><\/img> &#8230; and &#8230;<\/li>\n<li>filling out the 4 comma separated fields of a Javascript prompt window as per &#8230;\n<ol>\n<li>start date or number (latter is format &#8220;n&#8221; below)<\/li>\n<li>number of annotations<\/li>\n<li>increment of annotation values (note in example below how we allowed for <a target=_blank href='http:\/\/www.w3schools.com\/jsref\/jsref_eval.asp' title='Javascript eval'>eval<\/a> and added mins (for minutes) units)<\/li>\n<li>format of annotation that matches format of start date or &#8220;n&#8221; if number<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p>Try thinking how tedious it would have been to space nicely and write out the 5 annotation texts of today&#8217;s <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/dosequence.jpg\" title=\"Tutorial picture\">tutorial picture<\/a> as opposed to the Javascript prompt answer (after the two positional canvas clicks) &#8230;<\/p>\n<p><code><br \/>\n09\/June\/2020 10:00:00,5,-213 * 24 * 60 -23 * 60 -23 mins,DD\/Month\/YYYY HH24:MI:SS<br \/>\n<\/code><\/p>\n<p>To add this new functionality into the <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/world.js-------------------------GETME' title='world.js'>changed external Javascript<\/a> <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/world.js-------------------------GETME'>world.js<\/a> (used in Annotations part of <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/feedback.htm\" title=\"Click picture\">feedback web application<\/a>) what was needed?<\/p>\n<ul>\n<li>add new button via Javascript codeline &#8230;<br \/>\n<code><br \/>\n    hstuff+=\"&amp;nbsp;&lt;img src='\/\/www.rjmprogramming.com.au\/MarkItUp\/sequence.png' onclick=' dosequence(); ' alt='Sequence' title='Sequence'&gt;&lt;\/img&gt;\";<br \/>\n<\/code>\n<\/li>\n<li>add one new Javascript &#8220;function dosequence()&#8221; as you can glean via the &#8220;changed external Javascript&#8221; link above<\/li>\n<\/ul>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/canvas-annotations-and-datetime-or-number-sequences-tutorial\/'>Canvas Annotations and Datetime or Number Sequences Tutorial<\/a>.<\/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='#d49245' onclick='var dv=document.getElementById(\"d49245\"); dv.innerHTML = \"&amp;lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/sequence\" + \"&amp;gt;&amp;lt;\/iframe&amp;gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d49245' 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='#d49252' onclick='var dv=document.getElementById(\"d49252\"); dv.innerHTML = \"&amp;lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/emoji\" + \"&amp;gt;&amp;lt;\/iframe&amp;gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d49252' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday&#8217;s Canvas Annotations and Datetime or Number Sequences Tutorial was a basis to launch into some Annotation Sequences that can go beyond the 0 to 127 ascii values, into the &#8220;Wooooorrrrrlllllddddd of Emoji&#8221; and &#8220;HTML Entities&#8221; and &#8220;Unicode Characters&#8221;. So &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/canvas-annotations-and-datetime-or-number-or-emoji-sequences-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":[2,12,14,37],"tags":[69,1832,184,1824,2022,385,3192,409,1847,2242,2730,2399,3324,576,2658,3322,3323,578,3321,652,752,932,997,1895,1626,1254,1319,1333],"class_list":["post-49252","post","type-post","status-publish","format-standard","hentry","category-ajax","category-elearning","category-event-driven-programming","category-tutorials","tag-ajax","tag-annotation","tag-canvas","tag-character","tag-codepoint","tag-emoji","tag-emoji-flag","tag-external-javascript","tag-feedback","tag-flag","tag-formdata","tag-freeformatter","tag-fromcodepoint","tag-html","tag-html-entity","tag-html-entity-name","tag-html-entity-number","tag-html5","tag-increment","tag-javascript","tag-mathematics","tag-php","tag-programming","tag-sequence","tag-string","tag-text","tag-tutorial","tag-unicode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/49252"}],"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=49252"}],"version-history":[{"count":9,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/49252\/revisions"}],"predecessor-version":[{"id":49261,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/49252\/revisions\/49261"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=49252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=49252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=49252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}