Monday 6 August 2018

Canvas Smiley Face Example

<html>
<body>
<center><h1>canvas  smiley face example</h2>
<canvas id="sample" height="230px" width="400px" style="border:1px solid black;background-color:black;"></canvas></center>
<script>
var demo=document.getElementById("sample");
var c=demo.getContext("2d");
c.beginPath();
c.arc(190,120,100,0,2*Math.PI);
c.fillStyle="yellow";
c.fill();
c.stroke();
c.beginPath();
c.arc(140,70,10,0,2*Math.PI);
c.fillStyle="white";
c.fill();
c.stroke();
c.beginPath();
c.arc(240,70,10,0,2*Math.PI);
c.fillStyle="white";
c.fill();
c.stroke();
c.beginPath();
c.arc(140,70,5,0,2*Math.PI);
c.fillStyle="black";
c.fill();
c.stroke();
c.beginPath();
c.arc(240,70,5,0,2*Math.PI);
c.fillStyle="black";
c.fill();
c.stroke();
c.beginPath();
c.arc(190,110,10,0,2*Math.PI);
c.fillStyle="yellow";
c.fill();
c.stroke();
//c.moveTo(150,140);
//c.lineTo(230,140);
//c.stroke();
c.beginPath();
c.arc(190,150,20,0,1*Math.PI);
c.fillStyle="yellow";
c.fill();
c.stroke();
</script>
</body>
</html>
Output:


1 comment:

  1. Python is an open-source, high level, interpreted programming language which offers great opportunities for object-oriented programming. Choosing a python training program from Red Prism Group, which is best training institute for python in noida.

    ReplyDelete

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...