mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
43 lines
978 B
JavaScript
43 lines
978 B
JavaScript
/*
|
|
* 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.
|
|
*/
|
|
|
|
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();
|
|
}
|