Lab 1
Lab 1
LAB 1
Canvas <html>
HTML CANVAS
• The HTML <canvas> element is used to draw graphics, on the fly,
via scripting (usually JavaScript).
• The <canvas> element is only a container for graphics. You must
use a script to actually draw the graphics.
• Canvas has several methods for drawing paths, boxes, circles, text,
and adding images.
MORE ABOUT CANVAS
• Can be Animated
• Can be Interactive
• Can be Used in Games
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
alert(1);
</script>
JS FUNCTIONS
• Line
• moveTo(x,y)
• lineTo(x,y)
• Stroke()
• Circle
• beginPath()
• arc(x,y,r,d)
• Stroke()
• Styling
• strokeStyle=#HHHHHH;
• linewidth=n
• Transformation
• translate(x,y)
• scale(x,y)
• rotate(Math.PI*N)
• transform(hsc,hsk,vsk,vsc,hm,vm)