diff --git a/esvg/Circle.cpp b/esvg/Circle.cpp index 40a81a7..0d6c5eb 100644 --- a/esvg/Circle.cpp +++ b/esvg/Circle.cpp @@ -97,6 +97,7 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t listPoints = listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); + listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; diff --git a/esvg/Ellipse.cpp b/esvg/Ellipse.cpp index c59d693..d7b8cd1 100644 --- a/esvg/Ellipse.cpp +++ b/esvg/Ellipse.cpp @@ -102,6 +102,7 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t listPoints = listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); + listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; diff --git a/esvg/Line.cpp b/esvg/Line.cpp index 241334f..14f5617 100644 --- a/esvg/Line.cpp +++ b/esvg/Line.cpp @@ -76,6 +76,7 @@ void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l listPoints = listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); + listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; diff --git a/esvg/Path.cpp b/esvg/Path.cpp index 954ff29..32e4d3d 100644 --- a/esvg/Path.cpp +++ b/esvg/Path.cpp @@ -266,6 +266,7 @@ void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l listPoints = m_listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); + listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; diff --git a/esvg/Polygon.cpp b/esvg/Polygon.cpp index b78d13a..4b044c3 100644 --- a/esvg/Polygon.cpp +++ b/esvg/Polygon.cpp @@ -83,6 +83,7 @@ void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t listPoints = listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); + listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; diff --git a/esvg/Polyline.cpp b/esvg/Polyline.cpp index 680894b..7b98bf1 100644 --- a/esvg/Polyline.cpp +++ b/esvg/Polyline.cpp @@ -80,6 +80,7 @@ void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_ listPoints = listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); + listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; diff --git a/esvg/Rectangle.cpp b/esvg/Rectangle.cpp index e35418c..313edde 100644 --- a/esvg/Rectangle.cpp +++ b/esvg/Rectangle.cpp @@ -97,6 +97,7 @@ void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32 listPoints = listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); + listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; diff --git a/esvg/esvg.h b/esvg/esvg.h index f441936..d05ec63 100644 --- a/esvg/esvg.h +++ b/esvg/esvg.h @@ -15,7 +15,6 @@ #include #include -//#include namespace esvg { class Document : public esvg::Base { @@ -24,7 +23,7 @@ namespace esvg { bool m_loadOK; std::string m_version; std::string m_title; - std::vector m_subElementList; + std::vector m_subElementList; // TODO: LEAK ... vec2 m_size; public: Document(); @@ -59,18 +58,28 @@ namespace esvg { */ bool store(const std::string& _file); protected: - bool parseXMLData(const std::shared_ptr& _root); + virtual bool parseXMLData(const std::shared_ptr& _root); public: bool isLoadOk() { return m_loadOK; }; + /** + * @brief Display all the node in the svg file. + */ void displayDebug(); + // TODO: remove this fucntion : use generic function ... void generateAnImage(const ivec2& _size, const std::string& _fileName, bool _visualDebug=false); - //void generateAnImage(ivec2 _size, draw::Image& _output); - //void generateAnImage(draw::Image& _output); + /** + * @brief Generate Image in a specific format. + * @param[in,out] _size Size expected of the rendered image (value <=0 if it need to be automatic.) return the size generate + * @return Vector of the data used to display (simple vector: generic to transmit) + */ std::vector> renderImageFloatRGBA(ivec2& _size); + //! @previous std::vector> renderImageFloatRGB(ivec2& _size); + //! @previous std::vector> renderImageU8RGBA(ivec2& _size); + //! @previous std::vector> renderImageU8RGB(ivec2& _size); protected: virtual void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level=0); diff --git a/esvg/render/Point.h b/esvg/render/Point.h index 485091c..5c87313 100644 --- a/esvg/render/Point.h +++ b/esvg/render/Point.h @@ -25,6 +25,7 @@ namespace esvg { type_interpolation, //!< This point is dynamicly calculated to create an interpolation }; public: + // TODO : Clean all element here ... vec2 m_pos; //!< position of the point enum esvg::render::Point::type m_type; vec2 m_miterAxe; diff --git a/esvg/render/PointList.cpp b/esvg/render/PointList.cpp index 02ce058..90a28b2 100644 --- a/esvg/render/PointList.cpp +++ b/esvg/render/PointList.cpp @@ -18,6 +18,14 @@ void esvg::render::PointList::addList(std::vector& _list) { // TODO : Add a checker of correct list ... } +void esvg::render::PointList::applyMatrix(const mat2& _transformationMatrix) { + for (auto &it : m_data) { + for (auto &val : it) { + val.m_pos = _transformationMatrix * val.m_pos; + } + } +} + void esvg::render::PointList::display() { SVG_VERBOSE(" Display list of points : size=" << m_data.size()); diff --git a/esvg/render/PointList.h b/esvg/render/PointList.h index 000668e..e329c15 100644 --- a/esvg/render/PointList.h +++ b/esvg/render/PointList.h @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -23,6 +24,7 @@ namespace esvg { PointList(); void addList(std::vector& _list); void display(); + void applyMatrix(const mat2& _transformationMatrix); }; } }