Thread: problem
View Single Post
Old 12-04-2012, 05:55 PM   PM User | #3
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
do you want to write it from scratch or use a library?
I have got the hang of canvas, line and arc so can make a small demo if u want?
Here's a starter which draws a segment of a pie chart

Code:
<!DOCTYPE HTML>
<html>
<body>
<canvas id="myCanvas" width="800" height="600">>Your browser does not support the canvas tag.</canvas>
<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');

function pieSeg(x,y,r,angleRad,col){
 ctx.fillStyle = col;
 ctx.beginPath();
 ctx.moveTo(x,y);
 ctx.arc(x,y,r,0,angleRad, true);
 ctx.lineTo(x,y); 
 ctx.closePath();
 ctx.fill();
}

pieSeg(300,300,200,4,"red");
</script>
</body>

Last edited by donna1; 12-04-2012 at 06:31 PM..
donna1 is offline   Reply With Quote