function kustutamine(){
let k=document.getElementById(“kanva”).getContext(“2d”);
k.clearRect(0,0,400,300)
}
function kustutamine2(){
let k2=document.getElementById(“legoman”).getContext(“2d”);
k2.clearRect(0,0,400,300)
}
function joon(){
let k=document.getElementById(“kanva”).getContext(“2d”);
k.beginPath();
k.lineWidth=”3″;
k.strokeStyle=”red”;
k.moveTo(50,100);//alguspunk
k.lineTo(100,50);//kesk-punkt
k.lineTo(150,100);
k.lineTo(50,100);//lõppunkt
k.fill();
k.fillStyle=”white”
k.stroke();
}
function ristkulik(){
let l=document.getElementById(“laius”).value;
let ko=document.getElementById(“korgus”).value;
let k=document.getElementById(“kanva”).getContext(“2d”);
k.fillStyle=”lightblue”;
k.fillRect(50,50,l,ko); //x,y,laius,korgus
}
function ring(){
let ctx=document.getElementById(“kanva”).getContext(“2d”);
ctx.beginPath();
ctx.arc(100, 75, 50, 0, 2 * Math.PI);//x,y,alguspukt,raaduis
ctx.stroke();
ctx.fillStyle=”white”;
}
function legman()
{
tagaplaan();
body2();
jalad();
paremkai();
vasakkai();
pea();
vasaksilm();
paremsilm();
naeratus();
olad();
}
function jalad()
{
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”orange”;
k.fillRect(90,130,110,50);
k.fillStyle=”orange”;
k.fillRect(140,100,40,30);
k.fillRect(110,100,50,30);
k.fillStyle=”darkorange”;
k.fillRect(110,90,70,10);
}
function body2()
{let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”black”;
k.fillRect(100,40,90,50);
k.fillStyle=”darkorange”;
k.fillRect(110,60,7,7);
k.fillRect(120,70,6,4);
k.fillRect(134,74,3,5);
k.fillRect(173,60,7,7);
k.fillRect(164,70,6,4);
k.fillRect(153,74,3,5);
}
function paremkai(){
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”black”;
k.fillRect(190,60,20,20);
k.fillRect(210,60,20,30);
k.fillStyle=”darkorange”;
k.fillRect(210,90,20,10);
}
function vasakkai(){
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”black”;
k.fillRect(60,60,40,20);
k.fillRect(60,60,20,30);
k.fillStyle=”darkorange”;
k.fillRect(60,90,20,10);
}
function pea(){
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”black”;
k.fillRect(120,0,50,45)
}
function paremsilm()
{
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”darkorange”;
k.fillRect(148,10,12,5);
}
function vasaksilm()
{
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”darkorange”;
k.fillRect(130,10,12,5);
}
function naeratus()
{
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”darkorange”;
k.fillRect(130,30,30,5);
k.fillRect(140,35,10,5);
k.fillRect(125,25,5,5);
k.fillRect(160,25,5,5);
}
function olad()
{
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”black”;
k.fillRect(190,40,40,40);
k.fillRect(60,40,40,40);
k.fillStyle=”darkorange”;
}
function tagaplaan()
{
let k=document.getElementById(“legoman”).getContext(“2d”);
k.fillStyle=”#CC5500″;
k.fillRect(0,130,400,30);
k.fillRect(46,0,20,50);
k.fillRect(134,0,20,50);
}
Shadow Fiend
Näide:
