[DEV] add line rendering

This commit is contained in:
Edouard DUPIN 2015-11-24 21:34:07 +01:00
parent 7a8cd38615
commit 332775ae72

View File

@ -8,6 +8,8 @@
#include <esvg/debug.h> #include <esvg/debug.h>
#include <esvg/Line.h> #include <esvg/Line.h>
#include <esvg/render/Path.h>
#include <esvg/render/Weight.h>
#undef __class__ #undef __class__
#define __class__ "Line" #define __class__ "Line"
@ -60,50 +62,44 @@ void esvg::Line::display(int32_t _spacing) {
void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Line"); SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Line");
# if 0
esvg::RenderPath path; esvg::render::Path listElement;
path.start_new_path(); listElement.clear();
path.move_to(m_startPos.x(), m_startPos.y()); listElement.moveTo(false, m_startPos);
path.line_to(m_stopPos.x(), m_stopPos.y()); listElement.lineTo(false, m_stopPos);
/* 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
} }