HTML and CSS Reference
In-Depth Information
• Radius—thesizeofthecircle.
• startAngle—thestartpointofthearc.
• endAngle—theendpointofthearc.
• anticlockwise—aBooleanvaluethatdictatesthedirection
the circle is drawn.
The following code describes the structure of an arc:
Figure 3.33 shows the circle as it is drawn on the page.
The following code embeds the Arc method and instructions
into a CANVAS drawing.
Figure 3.33 The Arc method
allows you to draw circles.
<!DOCTYPE html>
<title>Canvas - Creating a Circle</title>
<script type=”text/javascript”>
window.onload = function() {
var drawingCanvas = document.getElementById
if(drawingCanvas && drawingCanvas.
getContext) {
var context = drawingCanvas.getContext('2d');
context.strokeStyle = “yellow”;
context.fillStyle = “red”;
context.lineWidth = 20;
<canvas id=”myCircle” width=”550” height=”550”>
Figure 3.34 illustrates how you can add color to your circles.
In addition to the Arc method you also can add Bezier and
quadratic curves, both of which are mathematical calcula-
tions for creating an image. Bezier curves were developed by
French mathematician Pierre Bezier in 1962. A Bezier curve
is calculated from a parametric curve describing a parabola.
Figure 3.35 shows the four points used to create a Bezier
Figure 3.34 The Arc method can
be controlled visually with the
same controls you use for other
CANVAS drawing methods.
Search WWH ::

Custom Search