From 3ddc118c4c013a386cae611bb44c1bebba4a82b1 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 24 Nov 2015 21:57:03 +0100 Subject: [PATCH] [DEV] set stroke size in the all element --- esvg/Circle.cpp | 2 +- esvg/Ellipse.cpp | 2 +- esvg/Line.cpp | 2 +- esvg/Path.cpp | 2 +- esvg/Polygon.cpp | 2 +- esvg/Polyline.cpp | 10 ++++++++-- esvg/Rectangle.cpp | 2 +- esvg/render/SegmentList.cpp | 23 +++++++++++------------ esvg/render/SegmentList.h | 2 +- 9 files changed, 26 insertions(+), 21 deletions(-) diff --git a/esvg/Circle.cpp b/esvg/Circle.cpp index e008e9d..09a86ca 100644 --- a/esvg/Circle.cpp +++ b/esvg/Circle.cpp @@ -112,7 +112,7 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t // check if we need to display stroke: if ( m_paint.strokeWidth > 0 && m_paint.stroke.a() != 0x00) { - listSegmentStroke.createSegmentListStroke(listPoints); + listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), diff --git a/esvg/Ellipse.cpp b/esvg/Ellipse.cpp index f1b7bc6..cce038e 100644 --- a/esvg/Ellipse.cpp +++ b/esvg/Ellipse.cpp @@ -117,7 +117,7 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t // check if we need to display stroke: if ( m_paint.strokeWidth > 0 && m_paint.stroke.a() != 0x00) { - listSegmentStroke.createSegmentListStroke(listPoints); + listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), diff --git a/esvg/Line.cpp b/esvg/Line.cpp index 2ec51d2..d18383a 100644 --- a/esvg/Line.cpp +++ b/esvg/Line.cpp @@ -85,7 +85,7 @@ void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l // check if we need to display stroke: if ( m_paint.strokeWidth > 0 && m_paint.stroke.a() != 0x00) { - listSegmentStroke.createSegmentListStroke(listPoints); + listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), diff --git a/esvg/Path.cpp b/esvg/Path.cpp index 56ad16a..364a7eb 100644 --- a/esvg/Path.cpp +++ b/esvg/Path.cpp @@ -277,7 +277,7 @@ void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l // check if we need to display stroke: if ( m_paint.strokeWidth > 0 && m_paint.stroke.a() != 0x00) { - listSegmentStroke.createSegmentListStroke(listPoints); + listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), listSegmentStroke); } diff --git a/esvg/Polygon.cpp b/esvg/Polygon.cpp index 9df6757..2a927b3 100644 --- a/esvg/Polygon.cpp +++ b/esvg/Polygon.cpp @@ -98,7 +98,7 @@ void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t // check if we need to display stroke: if ( m_paint.strokeWidth > 0 && m_paint.stroke.a() != 0x00) { - listSegmentStroke.createSegmentListStroke(listPoints); + listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), diff --git a/esvg/Polyline.cpp b/esvg/Polyline.cpp index 704a8e4..dd442b1 100644 --- a/esvg/Polyline.cpp +++ b/esvg/Polyline.cpp @@ -85,11 +85,17 @@ void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_ esvg::render::Weight tmpFill; esvg::render::Weight tmpStroke; // Check if we need to display background - // No background ... + if (m_paint.fill.a() != 0x00) { + listSegmentFill.createSegmentList(listPoints); + // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule + tmpFill.generate(_myRenderer.getSize(), + _myRenderer.getNumberSubScanLine(), + listSegmentFill); + } // check if we need to display stroke: if ( m_paint.strokeWidth > 0 && m_paint.stroke.a() != 0x00) { - listSegmentStroke.createSegmentListStroke(listPoints); + listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), diff --git a/esvg/Rectangle.cpp b/esvg/Rectangle.cpp index cbdd538..fb2c435 100644 --- a/esvg/Rectangle.cpp +++ b/esvg/Rectangle.cpp @@ -112,7 +112,7 @@ void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32 // check if we need to display stroke: if ( m_paint.strokeWidth > 0 && m_paint.stroke.a() != 0x00) { - listSegmentStroke.createSegmentListStroke(listPoints); + listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), diff --git a/esvg/render/SegmentList.cpp b/esvg/render/SegmentList.cpp index 21ba9fe..fcbabb8 100644 --- a/esvg/render/SegmentList.cpp +++ b/esvg/render/SegmentList.cpp @@ -43,7 +43,7 @@ void esvg::render::SegmentList::createSegmentList(const esvg::render::PointList& std::sort(m_data.begin(), m_data.end(), sortSegmentFunction); } -void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& _listPoint) { +void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& _listPoint, float _width) { for (auto &itListPoint : _listPoint.m_data) { // generate for every point all the orthogonal elements // @@ -110,7 +110,6 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& SVG_TODO("lklklklklkl"); } } - float lineWidth = 5.0f; // create segment list: bool haveStartLine; vec2 leftPoint; @@ -121,9 +120,9 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& if ( itListPoint.back().m_type == esvg::render::Point::type_join || itListPoint.back().m_type == esvg::render::Point::type_interpolation) { leftPoint = itListPoint.back().m_pos - + itListPoint.back().m_miterAxe*lineWidth*0.5f; + + itListPoint.back().m_miterAxe*_width*0.5f; rightPoint = itListPoint.back().m_pos - - itListPoint.back().m_miterAxe*lineWidth*0.5f; + - itListPoint.back().m_miterAxe*_width*0.5f; } else { SVG_ERROR("Start list point with a join, but last lement is not a join"); } @@ -146,9 +145,9 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& haveStartLine = true; // TODO : Calculate intersection ... (now we do a simple fast test of path display ...) leftPoint = it.m_pos - + it.m_miterAxe*lineWidth*0.5f; + + it.m_miterAxe*_width*0.5f; rightPoint = it.m_pos - - it.m_miterAxe*lineWidth*0.5f; + - it.m_miterAxe*_width*0.5f; addSegment(leftPoint, rightPoint); SVG_VERBOSE(" segment :" << leftPoint << " -> " << rightPoint); } @@ -163,9 +162,9 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& haveStartLine = false; // TODO : Calculate intersection ... (now we do a simple fast test of path display ...) vec2 left = it.m_pos - + it.m_miterAxe*lineWidth*0.5f; + + it.m_miterAxe*_width*0.5f; vec2 right = it.m_pos - - it.m_miterAxe*lineWidth*0.5f; + - it.m_miterAxe*_width*0.5f; //Draw from previous point: addSegment(leftPoint, left); SVG_VERBOSE(" segment :" << leftPoint << " -> " << left); @@ -183,9 +182,9 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& SVG_VERBOSE("Find interpolation " << it.m_pos); // TODO : Calculate intersection ... (now we do a simple fast test of path display ...) vec2 left = it.m_pos - + it.m_miterAxe*lineWidth*0.5f; + + it.m_miterAxe*_width*0.5f; vec2 right = it.m_pos - - it.m_miterAxe*lineWidth*0.5f; + - it.m_miterAxe*_width*0.5f; //Draw from previous point: addSegment(leftPoint, left); SVG_VERBOSE(" segment :" << leftPoint << " -> " << left); @@ -200,9 +199,9 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList& SVG_VERBOSE("Find Join " << it.m_pos); // TODO : Calculate intersection ... (now we do a simple fast test of path display ...) vec2 left = it.m_pos - + it.m_miterAxe*lineWidth*0.5f; + + it.m_miterAxe*_width*0.5f; vec2 right = it.m_pos - - it.m_miterAxe*lineWidth*0.5f; + - it.m_miterAxe*_width*0.5f; //Draw from previous point: addSegment(leftPoint, left); SVG_VERBOSE(" segment :" << leftPoint << " -> " << left); diff --git a/esvg/render/SegmentList.h b/esvg/render/SegmentList.h index 4fbd008..c665b97 100644 --- a/esvg/render/SegmentList.h +++ b/esvg/render/SegmentList.h @@ -23,7 +23,7 @@ namespace esvg { SegmentList(); void addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1); void createSegmentList(const esvg::render::PointList& _listPoint); - void createSegmentListStroke(esvg::render::PointList& _listPoint); + void createSegmentListStroke(esvg::render::PointList& _listPoint, float _width); }; } }