Add native Bezier curve plot in SVG plotter.
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include <gr_text.h>
|
||||
#include <geometry/shape_line_chain.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
#include <bezier_curves.h>
|
||||
|
||||
PLOTTER::PLOTTER( )
|
||||
{
|
||||
@@ -198,6 +199,33 @@ void PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int r
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
|
||||
const wxPoint& aControl2, const wxPoint& aEnd,
|
||||
int aTolerance, int aLineThickness )
|
||||
{
|
||||
// Generic fallback: Quadratic Bezier curve plotted as a polyline
|
||||
int minSegLen = aLineThickness; // The segment min length to approximate a bezier curve
|
||||
|
||||
std::vector<wxPoint> ctrlPoints;
|
||||
ctrlPoints.push_back( aStart );
|
||||
ctrlPoints.push_back( aControl1 );
|
||||
ctrlPoints.push_back( aControl2 );
|
||||
ctrlPoints.push_back( aEnd );
|
||||
|
||||
BEZIER_POLY bezier_converter( ctrlPoints );
|
||||
|
||||
std::vector<wxPoint> approxPoints;
|
||||
bezier_converter.GetPoly( approxPoints, minSegLen );
|
||||
|
||||
MoveTo( aStart );
|
||||
|
||||
for( unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
|
||||
LineTo( approxPoints[ii] );
|
||||
|
||||
FinishTo( aEnd );
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::PlotImage(const wxImage & aImage, const wxPoint& aPos, double aScaleFactor )
|
||||
{
|
||||
wxSize size( aImage.GetWidth() * aScaleFactor,
|
||||
|
||||
Reference in New Issue
Block a user