{"version":"1.0","provider_name":"Merkulova portfoolio | eng","provider_url":"https:\/\/merkulova.thkit.ee\/wp\/eng","author_name":"admin","author_url":"https:\/\/merkulova.thkit.ee\/wp\/eng\/author\/admin\/","title":"JS: canvas drawing - Merkulova portfoolio | eng","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"NzhrzqxkUj\"><a href=\"https:\/\/merkulova.thkit.ee\/wp\/eng\/js-canvas-joonistamine\/\">JS: canvas drawing<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/merkulova.thkit.ee\/wp\/eng\/js-canvas-joonistamine\/embed\/#?secret=NzhrzqxkUj\" width=\"600\" height=\"338\" title=\"&#8220;JS: canvas drawing&#8221; &#8212; Merkulova portfoolio | eng\" data-secret=\"NzhrzqxkUj\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe><script type=\"text\/javascript\">\n\/* <![CDATA[ *\/\n\/*! This file is auto-generated *\/\n!function(d,l){\"use strict\";l.querySelector&&d.addEventListener&&\"undefined\"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!\/[^a-zA-Z0-9]\/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret=\"'+t.secret+'\"]'),o=l.querySelectorAll('blockquote[data-secret=\"'+t.secret+'\"]'),c=new RegExp(\"^https?:$\",\"i\"),i=0;i<o.length;i++)o[i].style.display=\"none\";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute(\"style\"),\"height\"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):\"link\"===t.message&&(r=new URL(s.getAttribute(\"src\")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener(\"message\",d.wp.receiveEmbedMessage,!1),l.addEventListener(\"DOMContentLoaded\",function(){for(var e,t,s=l.querySelectorAll(\"iframe.wp-embedded-content\"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute(\"data-secret\"))||(t=Math.random().toString(36).substring(2,12),e.src+=\"#?secret=\"+t,e.setAttribute(\"data-secret\",t)),e.contentWindow.postMessage({message:\"ready\",secret:t},\"*\")},!1)))}(window,document);\n\/\/# sourceURL=https:\/\/merkulova.thkit.ee\/wp\/eng\/wp-includes\/js\/wp-embed.min.js\n\/* ]]> *\/\n<\/script>\n","description":"Joonistamine JS-ga R: Laius K\u00f5rgus Lipud canvas#tahvel{ background-color: lightpink; border: 1px solid black; } canvas#lipp{ border: 1px solid gray; } h1{ font-size:22pt; } \/\/sirge joon function sirgeJoon(){ \/\/m\u00e4\u00e4rame tahvli const tahvel=document.getElementById(&#8220;tahvel&#8221;); if(tahvel.getContext){ let t=tahvel.getContext(&#8220;2d&#8221;); \/\/ anname tahvlinimi on t \/\/joon t.beginPath(); t.strokeStyle=&#8221;red&#8221;; t.lineWidth = 1; t.moveTo(20,80); \/\/alguspunkt t.lineTo(50,30); \/\/l\u00f5pppunkt t.stroke(); } } \/\/kolmnurk function kolmnurk(){ \/\/m\u00e4\u00e4rame tahvli const tahvel=document.getElementById(&#8220;tahvel&#8221;); if(tahvel.getContext){ let t=tahvel.getContext(&#8220;2d&#8221;); \/\/ anname tahvlinimi on t \/\/joon t.beginPath(); t.strokeStyle=&#8221;red&#8221;; t.fillStyle=&#8221;red&#8221;; \/\/taust t.lineWidth = 1; t.moveTo(50,100); \/\/alguspunkt t.lineTo(150,100); t.lineTo(150,200); t.lineTo(50,100); \/\/l\u00f5pppunkt t.stroke(); t.fill(); } } function puhasta(){ const tahvel=document.getElementById(&#8220;tahvel&#8221;); if(tahvel.getContext) { let t = tahvel.getContext(&#8220;2d&#8221;); t.clearRect(0,0,300,250); \/\/ 0,0 -vasak \u00fcleval tahvli nurk, 300-tahvli laius, 250- tahvli k\u00f5rgus } } \/\/ring function ring(){ \/\/m\u00e4\u00e4rame tahvli const tahvel=document.getElementById(&#8220;tahvel&#8221;); let r=document.getElementById(&#8220;raadius&#8221;); if(tahvel.getContext){ let t=tahvel.getContext(&#8220;2d&#8221;); \/\/ anname tahvlinimi on t \/\/\u00fcmberjoon t.beginPath(); t.strokeStyle=&#8221;green&#8221;; t.lineWidth = 1; t.arc(50,50, r.value, 0, 2*Math.PI, true); \/\/x, y-keskpunkt, R t.stroke(); \/\/ring t.beginPath(); t.fillStyle=&#8221;green&#8221;; t.lineWidth = 1; t.arc(50,120, r.value, 0, 2*Math.PI, true); \/\/x, y-keskpunkt, R t.fill(); } } function ristkylik(){ const tahvel=document.getElementById(&#8220;tahvel&#8221;); let laius=document.getElementById(&#8220;laius&#8221;); let korgus=document.getElementById(&#8220;korgus&#8221;); if(tahvel.getContext) { let t = tahvel.getContext(&#8220;2d&#8221;); t.fillStyle=&#8221;yellow&#8221;; t.fillRect(50,30,laius.value,korgus.value); \/\/ 0,0 -vasak \u00fcleval tahvli nurk, 300-tahvli laius, 250- tahvli k\u00f5rgus } } function pilt(){ const tahvel=document.getElementById(&#8220;tahvel&#8221;); if(tahvel.getContext) { let t = tahvel.getContext(&#8220;2d&#8221;); const fail=new Image(); fail.src=&#8221;https:\/\/picsum.photos\/100\/200?random=1&#8243;; fail.onload = () =&gt; { t.drawImage(fail, 50, 50, 100, 200); } } } function eestiLipp(){ const lipp=document.getElementById(&#8220;lipp&#8221;); if(lipp.getContext) { let l = lipp.getContext(&#8220;2d&#8221;); l.fillStyle=&#8221;blue&#8221;; l.fillRect(0,0,330,70); l.fillStyle=&#8221;black&#8221;; l.fillRect(0,70,330,70); l.fillStyle=&#8221;white&#8221;; l.fillRect(0,140,330,70); } } function prantsusmaa(){ const lipp=document.getElementById(&#8220;lipp&#8221;); if(lipp.getContext) { let l = lipp.getContext(&#8220;2d&#8221;); l.fillStyle=&#8221;blue&#8221;; l.fillRect(0,0,110,210); l.fillStyle=&#8221;white&#8221;; l.fillRect(110,0,220,210); l.fillStyle=&#8221;red&#8221;; l.fillRect(220,0,330,210); const fail=new Image(); fail.src=&#8221;https:\/\/merkulova.thkit.ee\/wp\/wp-content\/uploads\/2025\/10\/plankton.jpg&#8221;; fail.onload = () =&gt; { l.drawImage(fail, 50, 50, 100, 200); } } }"}