[DEV] set stroke size in the all element

This commit is contained in:
Edouard DUPIN 2015-11-24 21:57:03 +01:00
parent fec137abfb
commit 3ddc118c4c
9 changed files with 26 additions and 21 deletions

View File

@ -112,7 +112,7 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
// check if we need to display stroke: // check if we need to display stroke:
if ( m_paint.strokeWidth > 0 if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) { && 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 // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(), tmpStroke.generate(_myRenderer.getSize(),
_myRenderer.getNumberSubScanLine(), _myRenderer.getNumberSubScanLine(),

View File

@ -117,7 +117,7 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
// check if we need to display stroke: // check if we need to display stroke:
if ( m_paint.strokeWidth > 0 if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) { && 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 // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(), tmpStroke.generate(_myRenderer.getSize(),
_myRenderer.getNumberSubScanLine(), _myRenderer.getNumberSubScanLine(),

View File

@ -85,7 +85,7 @@ void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l
// check if we need to display stroke: // check if we need to display stroke:
if ( m_paint.strokeWidth > 0 if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) { && 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 // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(), tmpStroke.generate(_myRenderer.getSize(),
_myRenderer.getNumberSubScanLine(), _myRenderer.getNumberSubScanLine(),

View File

@ -277,7 +277,7 @@ void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l
// check if we need to display stroke: // check if we need to display stroke:
if ( m_paint.strokeWidth > 0 if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) { && 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 // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), listSegmentStroke); tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), listSegmentStroke);
} }

View File

@ -98,7 +98,7 @@ void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
// check if we need to display stroke: // check if we need to display stroke:
if ( m_paint.strokeWidth > 0 if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) { && 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 // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(), tmpStroke.generate(_myRenderer.getSize(),
_myRenderer.getNumberSubScanLine(), _myRenderer.getNumberSubScanLine(),

View File

@ -85,11 +85,17 @@ void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_
esvg::render::Weight tmpFill; esvg::render::Weight tmpFill;
esvg::render::Weight tmpStroke; esvg::render::Weight tmpStroke;
// Check if we need to display background // 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: // check if we need to display stroke:
if ( m_paint.strokeWidth > 0 if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) { && 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 // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(), tmpStroke.generate(_myRenderer.getSize(),
_myRenderer.getNumberSubScanLine(), _myRenderer.getNumberSubScanLine(),

View File

@ -112,7 +112,7 @@ void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32
// check if we need to display stroke: // check if we need to display stroke:
if ( m_paint.strokeWidth > 0 if ( m_paint.strokeWidth > 0
&& m_paint.stroke.a() != 0x00) { && 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 // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
tmpStroke.generate(_myRenderer.getSize(), tmpStroke.generate(_myRenderer.getSize(),
_myRenderer.getNumberSubScanLine(), _myRenderer.getNumberSubScanLine(),

View File

@ -43,7 +43,7 @@ void esvg::render::SegmentList::createSegmentList(const esvg::render::PointList&
std::sort(m_data.begin(), m_data.end(), sortSegmentFunction); 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) { for (auto &itListPoint : _listPoint.m_data) {
// generate for every point all the orthogonal elements // generate for every point all the orthogonal elements
// //
@ -110,7 +110,6 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
SVG_TODO("lklklklklkl"); SVG_TODO("lklklklklkl");
} }
} }
float lineWidth = 5.0f;
// create segment list: // create segment list:
bool haveStartLine; bool haveStartLine;
vec2 leftPoint; vec2 leftPoint;
@ -121,9 +120,9 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
if ( itListPoint.back().m_type == esvg::render::Point::type_join if ( itListPoint.back().m_type == esvg::render::Point::type_join
|| itListPoint.back().m_type == esvg::render::Point::type_interpolation) { || itListPoint.back().m_type == esvg::render::Point::type_interpolation) {
leftPoint = itListPoint.back().m_pos leftPoint = itListPoint.back().m_pos
+ itListPoint.back().m_miterAxe*lineWidth*0.5f; + itListPoint.back().m_miterAxe*_width*0.5f;
rightPoint = itListPoint.back().m_pos rightPoint = itListPoint.back().m_pos
- itListPoint.back().m_miterAxe*lineWidth*0.5f; - itListPoint.back().m_miterAxe*_width*0.5f;
} else { } else {
SVG_ERROR("Start list point with a join, but last lement is not a join"); 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; haveStartLine = true;
// TODO : Calculate intersection ... (now we do a simple fast test of path display ...) // TODO : Calculate intersection ... (now we do a simple fast test of path display ...)
leftPoint = it.m_pos leftPoint = it.m_pos
+ it.m_miterAxe*lineWidth*0.5f; + it.m_miterAxe*_width*0.5f;
rightPoint = it.m_pos rightPoint = it.m_pos
- it.m_miterAxe*lineWidth*0.5f; - it.m_miterAxe*_width*0.5f;
addSegment(leftPoint, rightPoint); addSegment(leftPoint, rightPoint);
SVG_VERBOSE(" segment :" << leftPoint << " -> " << rightPoint); SVG_VERBOSE(" segment :" << leftPoint << " -> " << rightPoint);
} }
@ -163,9 +162,9 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
haveStartLine = false; haveStartLine = false;
// TODO : Calculate intersection ... (now we do a simple fast test of path display ...) // TODO : Calculate intersection ... (now we do a simple fast test of path display ...)
vec2 left = it.m_pos vec2 left = it.m_pos
+ it.m_miterAxe*lineWidth*0.5f; + it.m_miterAxe*_width*0.5f;
vec2 right = it.m_pos vec2 right = it.m_pos
- it.m_miterAxe*lineWidth*0.5f; - it.m_miterAxe*_width*0.5f;
//Draw from previous point: //Draw from previous point:
addSegment(leftPoint, left); addSegment(leftPoint, left);
SVG_VERBOSE(" segment :" << 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); SVG_VERBOSE("Find interpolation " << it.m_pos);
// TODO : Calculate intersection ... (now we do a simple fast test of path display ...) // TODO : Calculate intersection ... (now we do a simple fast test of path display ...)
vec2 left = it.m_pos vec2 left = it.m_pos
+ it.m_miterAxe*lineWidth*0.5f; + it.m_miterAxe*_width*0.5f;
vec2 right = it.m_pos vec2 right = it.m_pos
- it.m_miterAxe*lineWidth*0.5f; - it.m_miterAxe*_width*0.5f;
//Draw from previous point: //Draw from previous point:
addSegment(leftPoint, left); addSegment(leftPoint, left);
SVG_VERBOSE(" segment :" << 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); SVG_VERBOSE("Find Join " << it.m_pos);
// TODO : Calculate intersection ... (now we do a simple fast test of path display ...) // TODO : Calculate intersection ... (now we do a simple fast test of path display ...)
vec2 left = it.m_pos vec2 left = it.m_pos
+ it.m_miterAxe*lineWidth*0.5f; + it.m_miterAxe*_width*0.5f;
vec2 right = it.m_pos vec2 right = it.m_pos
- it.m_miterAxe*lineWidth*0.5f; - it.m_miterAxe*_width*0.5f;
//Draw from previous point: //Draw from previous point:
addSegment(leftPoint, left); addSegment(leftPoint, left);
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left); SVG_VERBOSE(" segment :" << leftPoint << " -> " << left);

View File

@ -23,7 +23,7 @@ namespace esvg {
SegmentList(); SegmentList();
void addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1); void addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1);
void createSegmentList(const esvg::render::PointList& _listPoint); void createSegmentList(const esvg::render::PointList& _listPoint);
void createSegmentListStroke(esvg::render::PointList& _listPoint); void createSegmentListStroke(esvg::render::PointList& _listPoint, float _width);
}; };
} }
} }