[DEV] add generation of polyline

This commit is contained in:
Edouard DUPIN 2015-11-23 22:08:22 +01:00
parent 1decd2893c
commit ae04bbcdbe

View File

@ -8,6 +8,8 @@
#include <esvg/debug.h> #include <esvg/debug.h>
#include <esvg/Polyline.h> #include <esvg/Polyline.h>
#include <esvg/render/Path.h>
#include <esvg/render/Weight.h>
#undef __class__ #undef __class__
#define __class__ "Polyline" #define __class__ "Polyline"
@ -63,54 +65,45 @@ void esvg::Polyline::display(int32_t _spacing) {
void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polyline"); SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polyline");
esvg::render::Path listElement;
#if 0 listElement.clear();
esvg::RenderPath path; listElement.moveTo(false, m_listPoint[0]);
path.start_new_path();
path.move_to(m_listPoint[0].x(), m_listPoint[0].y());
for( int32_t iii=1; iii< m_listPoint.size(); iii++) { for( int32_t iii=1; iii< m_listPoint.size(); iii++) {
path.line_to(m_listPoint[iii].x(), m_listPoint[iii].y()); listElement.lineTo(false, m_listPoint[iii]);
} }
/* listElement.stop();
// configure the end of the line :
switch (m_paint.lineCap) {
case esvg::LINECAP_SQUARE:
path.line_cap(agg::square_cap);
break;
case esvg::LINECAP_ROUND:
path.line_cap(agg::round_cap);
break;
default: // esvg::LINECAP_BUTT
path.line_cap(agg::butt_cap);
break;
}
switch (m_paint.lineJoin) {
case esvg::LINEJOIN_BEVEL:
path.line_join(agg::bevel_join);
break;
case esvg::LINEJOIN_ROUND:
path.line_join(agg::round_join);
break;
default: // esvg::LINEJOIN_MITER
path.line_join(agg::miter_join);
break;
}
*/
mat2 mtx = m_transformMatrix; mat2 mtx = m_transformMatrix;
mtx *= _basicTrans; mtx *= _basicTrans;
if (m_paint.strokeWidth > 0) { esvg::render::PointList listPoints;
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a)); listPoints = listElement.generateListPoints(_level,
// drawing as an outline _myRenderer.getInterpolationRecurtionMax(),
agg::conv_stroke<esvg::RenderPath> myPolygonStroke(path); _myRenderer.getInterpolationThreshold());
myPolygonStroke.width(m_paint.strokeWidth); esvg::render::SegmentList listSegmentFill;
agg::conv_transform<agg::conv_stroke<esvg::RenderPath>, mat2> transStroke(myPolygonStroke, mtx); esvg::render::SegmentList listSegmentStroke;
// set the filling mode : esvg::render::Weight tmpFill;
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero); esvg::render::Weight tmpStroke;
_myRenderer.m_rasterizer.add_path(transStroke); // Check if we need to display background
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea); // No background ...
// check if we need to display stroke:
if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) {
listSegmentStroke.createSegmentListStroke(listPoints);
// now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(),
_myRenderer.getNumberSubScanLine(),
listSegmentStroke);
} }
// add on images:
_myRenderer.print(tmpFill,
m_paint.fill,
tmpStroke,
m_paint.stroke,
m_paint.opacity);
#ifdef DEBUG
_myRenderer.addDebugSegment(listSegmentFill);
_myRenderer.addDebugSegment(listSegmentStroke);
#endif #endif
} }