{"id":11558,"date":"2015-01-17T05:04:17","date_gmt":"2015-01-16T18:04:17","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=11558"},"modified":"2015-01-17T05:04:17","modified_gmt":"2015-01-16T18:04:17","slug":"htmljavascriptphp-canvas-venn-diagram-email-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascriptphp-canvas-venn-diagram-email-tutorial\/","title":{"rendered":"HTML\/Javascript\/PHP Canvas Venn Diagram Email Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML\/Javascript\/PHP Canvas Venn Diagram Email Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/Venn_Diagram_Email.jpg\" title=\"HTML\/Javascript\/PHP Canvas Venn Diagram Email Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML\/Javascript\/PHP Canvas Venn Diagram Email Tutorial<\/p><\/div>\n<p>Was reminded about the previous <a target=_blank title='HTML\/Javascript Canvas Venn Diagram Tutorial' href='#hjcvdt'>HTML\/Javascript Canvas Venn Diagram Tutorial<\/a> as shown below because of a pleasant comment from a user making use of its functionality &#8230; thanks and yayyyyyyy team!<\/p>\n<p>Looking over it again, though, some functionality to allow a snapshot image of the canvas element be allowed to be accessible via an email link to this saved image on the rjmprogramming.com.au domain, would be useful methinks &#8230; forsooth?!<\/p>\n<p>Yet again we need PHP, because we are writing a file on to our web server, so we&#8217;ll just have to disappoint those without PHP &#8230; sorrrrrryyyy.<\/p>\n<p>At the client side, with Javascript, you&#8217;ll find the HTML5 Javascript&#8217;s canvas method <a target=_blank title='Javascript canvas toDataURL() method information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'><i>toDataURL()<\/i><\/a> useful.   How?<\/p>\n<ul>\n<li>onload arrange a good filename to be supplied via a Javascript <a target=_blank title='Javascript DOM information from w3schools' href='http:\/\/www.w3schools.com\/js\/js_htmldom.asp'>DOM<\/a> save to a <a target=_blank title='Form information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_form.asp'>form<\/a>&#8216;s hidden <a target=_blank title='Input information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_input.asp'>input<\/a> HTML field<\/li>\n<li>the user asks for an Email Snapshot to be emailed and the webpage uses Javascript DOM to save to its form&#8217;s hidden input HTML field the result of the canvas&#8217;s call to <i>toDataURL()<\/i><\/li>\n<li>programmatically post the form (by programmatically clicking the form&#8217;s submit button)  with a <a target=_blank title='Form href target property information from w3schools' href='http:\/\/www.w3schools.com\/tags\/att_form_target.asp'>target<\/a> pointing to id of an <a target=_blank title='Iframe information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>iframe<\/a> with a URL of our venn_diagram.php<\/li>\n<li>have venn_diagram.php (of that iframe) create a png image from the <a target=_blank title='Data URL (or Data URI) information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Data_URI_scheme'>data URL<\/a> and the file name posted across using PHP&#8217;s <a target=_blank title='PHP base64_decode() method information' href='http:\/\/php.net\/manual\/en\/function.base64-decode.php'>base64_decode<\/a> and <a target=_blank title='PHP file_put_contents() method information' href='http:\/\/php.net\/manual\/en\/function.file-put-contents.php'>file_put_contents()<\/a> methods (great to use with data URL data) &#8230; thanks to <a target=_blank title='Great ideas here' href='http:\/\/stackoverflow.com\/questions\/9771986\/fabric-js-canvas-todataurl-sent-to-php-by-ajax'>this link<\/a> for great ideas<\/li>\n<li>back at venn_diagram.html use Javascript DOM to update an HTML <a target=_blank title='a tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_a.asp'><i>a<\/i><\/a> tag&#8217;s <a target=_blank title='mailto information' href='http:\/\/www.w3schools.com\/tags\/tryit.asp?filename=tryhtml_link_mailto'>mailto:<\/a> (href property) link with the name of the png image file created in previous step being the email&#8217;s body, which, on arrival at the recipient, becomes a link to the snapshot image on the web, viewable with their default web browser<\/li>\n<li>programmatically click the HTML <i>a<\/i> tag to open your local client mail program with a primed email<\/li>\n<li>change the email address appropriately, and anything else you&#8217;d like to change<\/li>\n<li>click the Send button<\/li>\n<li>&#8230; sun goes down &#8230; sun comes up &#8230; (email) recipient wakes from a dream about pins, boulders and lemon curry (you had to be there) &#8230; reads email &#8230; is a little shocked &#8230; but &#8230; clicks link of email &#8230;<\/li>\n<li>recipient sees the Venn Diagram (snapshot) in their default web browser<\/li>\n<\/ul>\n<p>Here is a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/\" title=\"HTML\/Javascript Canvas Venn Diagram Tutorial\">live run<\/a> showing some client-side basics in HTML and Javascript that can be used to create your own Venn Diagrams.   Were Venn Diagrams something you learnt at school, to do with &#8220;set theory&#8221;?   It can be an interesting area of mathematics, and statistics, perhaps.    In today&#8217;s tutorial we do an example involving Geckoes &#8230; yes, <a target=_blank title='Gecko information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Gecko'>Geckoes<\/a> &#8230; not echoes &#8230; but, Geckoes &#8230; the inspiration for which came from this great <a target=_blank title='Venn diagram Geckoes problem' href='http:\/\/www.purplemath.com\/modules\/venndiag4.htm'>link<\/a> (thanks).   You can read about it from Wikipedia <a target=_blank title='Venn diagram information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Venn_diagram'>here<\/a>.<\/p>\n<p>This HTML\/Javascript solution uses an HTML canvas element, which you can first read about, at this blog, <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5539' title='HTML\/Javascript Canvas Primer Tutorial'>here<\/a>.<\/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>Here is a very useful <a target=_blank title='Circle intersection algorithm ... thanks' href='http:\/\/stackoverflow.com\/questions\/8367512\/algorithm-to-detect-if-a-circles-intersect-with-any-other-circle-in-the-same-pla'>link<\/a> that helped with an algorithm to determine if two circles intercept &#8230; thanks.<\/p>\n<p>Link to some downloadable HTML programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/venn_diagram.html-GETME' title='venn_diagram.html'>venn_diagram.html<\/a> (and how it changed &#8230; <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/venn_diagram.html-GETME' title='venn_diagram.html'>venn_diagram.html<\/a>)<br \/>\nLink to some new downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/venn_diagram.php-GETME' title='venn_diagram.php'>venn_diagram.php<\/a>\n<\/p>\n<hr \/>\n<p id='hjcvdt'>Previous relevant <a target=_blank title='HTML\/Javascript Canvas Venn Diagram Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5692'>HTML\/Javascript Canvas Venn Diagram 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\/VennDiagram\/VennDiagram.m4v\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML\/Javascript Canvas Venn Diagram Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/VennDiagram.jpg\" title=\"HTML\/Javascript Canvas Venn Diagram Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML\/Javascript Canvas Venn Diagram Tutorial<\/p><\/div>\n<p>Here is a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/\" title=\"HTML\/Javascript Canvas Venn Diagram Tutorial\">live run<\/a> showing some client-side basics in HTML and Javascript that can be used to create your own Venn Diagrams.   Were Venn Diagrams something you learnt at school, to do with &#8220;set theory&#8221;?   It can be an interesting area of mathematics, and statistics, perhaps.    In today&#8217;s tutorial we do an example involving Geckoes &#8230; yes, <a target=_blank title='Gecko information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Gecko'>Geckoes<\/a> &#8230; not echoes &#8230; but, Geckoes &#8230; the inspiration for which came from this great <a target=_blank title='Venn diagram Geckoes problem' href='http:\/\/www.purplemath.com\/modules\/venndiag4.htm'>link<\/a> (thanks).   You can read about it from Wikipedia <a target=_blank title='Venn diagram information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Venn_diagram'>here<\/a>.<\/p>\n<p>This HTML\/Javascript solution uses an HTML canvas element, which you can first read about, at this blog, <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5539' title='HTML\/Javascript Canvas Primer Tutorial'>here<\/a>.<\/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>Here is a very useful <a target=_blank title='Circle intersection algorithm ... thanks' href='http:\/\/stackoverflow.com\/questions\/8367512\/algorithm-to-detect-if-a-circles-intersect-with-any-other-circle-in-the-same-pla'>link<\/a> that helped with an algorithm to determine if two circles intercept &#8230; thanks.<\/p>\n<p>Link to some downloadable HTML programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Canvas\/VennDiagram\/venn_diagram.html_GETME' title='venn_diagram.html'>venn_diagram.html<\/a>\n<\/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='#d5692' onclick='var dv=document.getElementById(\"d5692\"); 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='d5692' 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='#d11558' onclick='var dv=document.getElementById(\"d11558\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=canvas\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d11558' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Was reminded about the previous HTML\/Javascript Canvas Venn Diagram Tutorial as shown below because of a pleasant comment from a user making use of its functionality &#8230; thanks and yayyyyyyy team! Looking over it again, though, some functionality to allow &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascriptphp-canvas-venn-diagram-email-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,17,37],"tags":[184,297,354,380,381,452,576,578,587,590,652,739,752,894,932,970,997,1124,1161,1319,1367],"class_list":["post-11558","post","type-post","status-publish","format-standard","hentry","category-elearning","category-gui","category-tutorials","tag-canvas","tag-data-url","tag-dom","tag-email","tag-email-client","tag-form","tag-html","tag-html5","tag-iframe","tag-image","tag-javascript","tag-mailto","tag-mathematics","tag-overlay","tag-php","tag-post","tag-programming","tag-set-theory","tag-snapshot","tag-tutorial","tag-venn-diagram"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/11558"}],"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=11558"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/11558\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=11558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=11558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=11558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}