Skip to content

Commit

Permalink
Add support for circle rendering. Fixes issue #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidtw committed Jan 10, 2021
1 parent 1023412 commit 4ce2a90
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions scripts/File/ShaperExport/ShaperExportWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,29 @@ function renderArcPath( arc ) {
}


/**
* Render the specified circle shape.
*
* @param circle the circle to render
*
* @return the path describing the circle
*/
function renderCirclePath( circle ) {
var dir = { 'sweep': 1,
'large': 0 };

var r = arc.getRadius();

var p1 = arc.getPointAtAngle(0);
var p2 = arc.getPointAtAngle(Math.PI);
var a1 = printAbsArcPath( r, r, 0, dir.large, dir.sweep, p2.getX(), p2.getY() );
var a2 = printAbsArcPath( r, r, 0, dir.large, dir.sweep, p1.getX(), p1.getY() );
a2 = a2.concat( " Z " );
return a1.concat( a2 );
}



/**
* Render the specified ellipse shape.
*
Expand Down Expand Up @@ -625,6 +648,9 @@ function renderUnknownShapePath( shape ) {
//EAction.handleUserMessage(qsTr("RShape.Arc\n"));
return renderArcPath( shape );

case RShape.Circle: // 3
return renderCirclePath( shape );

case RShape.Ellipse: // 4
//EAction.handleUserMessage(qsTr("RShape.Ellipse\n"));
return renderEllipsePath( shape );
Expand All @@ -637,11 +663,10 @@ function renderUnknownShapePath( shape ) {
//EAction.handleUserMessage(qsTr("RShape.Spline\n"));
return renderSplinePath( shape );

case RShape.Triangle: // 7
case RShape.Triangle: // 7
//EAction.handleUserMessage(qsTr("RShape.Triangle\n"));
return renderTrianglePath( shape );

//case RShape.Circle: // 3
default:
EAction.handleUserMessage(qsTr("RShape.Unknown: %1\n").arg(shape.getShapeType()));
}
Expand Down

0 comments on commit 4ce2a90

Please sign in to comment.