2013-12-20 16:31:41 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Doodle3D project (http://doodle3d.com).
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013, Doodle3D
|
|
|
|
* This software is licensed under the terms of the GNU GPL v2 or later.
|
|
|
|
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
|
|
|
*/
|
|
|
|
|
2013-12-05 11:14:12 +01:00
|
|
|
function drawCircle(x0,y0,r,res) {
|
|
|
|
if (res==undefined) res = 50; //circle resolution
|
|
|
|
beginShape();
|
|
|
|
var step=Math.PI * 2.0 / res;
|
|
|
|
for (var a=0; a<=Math.PI*2; a+=step) {
|
|
|
|
var x = Math.sin(a) * r + x0;
|
|
|
|
var y = Math.cos(a) * r + y0;
|
|
|
|
if (a==0) shapeMoveTo(x,y);
|
|
|
|
else shapeLineTo(x,y);
|
|
|
|
}
|
|
|
|
endShape();
|
|
|
|
}
|
|
|
|
|
|
|
|
function beginShape(x,y) {
|
|
|
|
setSketchModified(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function shapeMoveTo(x,y) {
|
|
|
|
_points.push([x, y, true]);
|
|
|
|
adjustBounds(x, y)
|
|
|
|
adjustPreviewTransformation();
|
|
|
|
draw(x, y, .5);
|
|
|
|
}
|
|
|
|
|
|
|
|
function shapeLineTo(x,y) {
|
|
|
|
_points.push([x, y, false]);
|
|
|
|
adjustBounds(x, y)
|
|
|
|
adjustPreviewTransformation();
|
|
|
|
draw(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
function endShape() {
|
|
|
|
renderToImageDataPreview();
|
2013-12-20 16:31:41 +01:00
|
|
|
}
|