[PORT] step 1
This commit is contained in:
parent
ef4e3be43f
commit
ad5b11151e
@ -19,7 +19,7 @@ esvg::PaintState::PaintState() :
|
|||||||
lineCap(esvg::cap_butt),
|
lineCap(esvg::cap_butt),
|
||||||
lineJoin(esvg::join_miter),
|
lineJoin(esvg::join_miter),
|
||||||
miterLimit(4.0f),
|
miterLimit(4.0f),
|
||||||
viewPort(vec2(0.0f,0.0f), vec2(0.0f,0.0f)),
|
viewPort(Vector2f(0.0f,0.0f), Vector2f(0.0f,0.0f)),
|
||||||
opacity(1.0) {
|
opacity(1.0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -108,10 +108,10 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
|||||||
if (data.size() != 0) {
|
if (data.size() != 0) {
|
||||||
float xxx, yyy;
|
float xxx, yyy;
|
||||||
if (sscanf(data.c_str(), "%f %f", &xxx, &yyy) == 2) {
|
if (sscanf(data.c_str(), "%f %f", &xxx, &yyy) == 2) {
|
||||||
m_transformMatrix *= etk::mat2x3Translate(vec2(xxx, yyy));
|
m_transformMatrix *= etk::mat2x3Translate(Vector2f(xxx, yyy));
|
||||||
Log.verbose("Translate : " << xxx << ", " << yyy);
|
Log.verbose("Translate : " << xxx << ", " << yyy);
|
||||||
} else if (sscanf(data.c_str(), "%f", &xxx) == 1) {
|
} else if (sscanf(data.c_str(), "%f", &xxx) == 1) {
|
||||||
m_transformMatrix *= etk::mat2x3Translate(vec2(xxx, 0));
|
m_transformMatrix *= etk::mat2x3Translate(Vector2f(xxx, 0));
|
||||||
Log.verbose("Translate : " << xxx << ", " << 0);
|
Log.verbose("Translate : " << xxx << ", " << 0);
|
||||||
} else {
|
} else {
|
||||||
Log.error("Parsing translate() with wrong data ... '" << data << "'");
|
Log.error("Parsing translate() with wrong data ... '" << data << "'");
|
||||||
@ -121,7 +121,7 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
|||||||
if (data.size() != 0) {
|
if (data.size() != 0) {
|
||||||
float xxx, yyy;
|
float xxx, yyy;
|
||||||
if (sscanf(data.c_str(), "%f %f", &xxx, &yyy) == 2) {
|
if (sscanf(data.c_str(), "%f %f", &xxx, &yyy) == 2) {
|
||||||
m_transformMatrix *= etk::mat2x3Scale(vec2(xxx, yyy));
|
m_transformMatrix *= etk::mat2x3Scale(Vector2f(xxx, yyy));
|
||||||
Log.verbose("Scale : " << xxx << ", " << yyy);
|
Log.verbose("Scale : " << xxx << ", " << yyy);
|
||||||
} else if (sscanf(data.c_str(), "%f", &xxx) == 1) {
|
} else if (sscanf(data.c_str(), "%f", &xxx) == 1) {
|
||||||
m_transformMatrix *= etk::mat2x3Scale(xxx);
|
m_transformMatrix *= etk::mat2x3Scale(xxx);
|
||||||
@ -135,9 +135,9 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
|||||||
float angle, xxx, yyy;
|
float angle, xxx, yyy;
|
||||||
if (sscanf(data.c_str(), "%f %f %f", &angle, &xxx, &yyy) == 3) {
|
if (sscanf(data.c_str(), "%f %f %f", &angle, &xxx, &yyy) == 3) {
|
||||||
angle = angle / 180 * M_PI;
|
angle = angle / 180 * M_PI;
|
||||||
m_transformMatrix *= etk::mat2x3Translate(vec2(-xxx, -yyy));
|
m_transformMatrix *= etk::mat2x3Translate(Vector2f(-xxx, -yyy));
|
||||||
m_transformMatrix *= etk::mat2x3Rotate(angle);
|
m_transformMatrix *= etk::mat2x3Rotate(angle);
|
||||||
m_transformMatrix *= etk::mat2x3Translate(vec2(xxx, yyy));
|
m_transformMatrix *= etk::mat2x3Translate(Vector2f(xxx, yyy));
|
||||||
} else if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
} else if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
||||||
angle = angle / 180 * M_PI;
|
angle = angle / 180 * M_PI;
|
||||||
Log.verbose("rotate : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
Log.verbose("rotate : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
||||||
@ -152,7 +152,7 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
|||||||
if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
||||||
angle = angle / 180 * M_PI;
|
angle = angle / 180 * M_PI;
|
||||||
Log.verbose("skewX : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
Log.verbose("skewX : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
||||||
m_transformMatrix *= etk::mat2x3Skew(vec2(angle, 0.0f));
|
m_transformMatrix *= etk::mat2x3Skew(Vector2f(angle, 0.0f));
|
||||||
} else {
|
} else {
|
||||||
Log.error("Parsing skewX() with wrong data ... '" << data << "'");
|
Log.error("Parsing skewX() with wrong data ... '" << data << "'");
|
||||||
}
|
}
|
||||||
@ -163,14 +163,14 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
|||||||
if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
||||||
angle = angle / 180 * M_PI;
|
angle = angle / 180 * M_PI;
|
||||||
Log.verbose("skewY : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
Log.verbose("skewY : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
||||||
m_transformMatrix *= etk::mat2x3Skew(vec2(0.0f, angle));
|
m_transformMatrix *= etk::mat2x3Skew(Vector2f(0.0f, angle));
|
||||||
} else {
|
} else {
|
||||||
Log.error("Parsing skewY() with wrong data ... '" << data << "'");
|
Log.error("Parsing skewY() with wrong data ... '" << data << "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Base::parsePosition(const exml::Element& _element, vec2 &_pos, vec2 &_size) {
|
void esvg::Base::parsePosition(const exml::Element& _element, Vector2f &_pos, Vector2f &_size) {
|
||||||
_pos.setValue(0,0);
|
_pos.setValue(0,0);
|
||||||
_size.setValue(0,0);
|
_size.setValue(0,0);
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ void esvg::Base::parsePaintAttr(const exml::Element& _element) {
|
|||||||
if (content == "none" ) {
|
if (content == "none" ) {
|
||||||
// OK, Nothing to do ...
|
// OK, Nothing to do ...
|
||||||
} else {
|
} else {
|
||||||
ESVG_TODO(" 'stroke-dasharray' not implemented ...");
|
Log.todo(" 'stroke-dasharray' not implemented ...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content = _element.attributes["stroke-linecap"];
|
content = _element.attributes["stroke-linecap"];
|
||||||
@ -396,11 +396,11 @@ etk::Pair<etk::Color<float,4>, etk::String> esvg::Base::parseColor(const etk::St
|
|||||||
return localColor;
|
return localColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Base::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Base::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
// TODO : UNDERSTAND why nothing is done here ...
|
// TODO : UNDERSTAND why nothing is done here ...
|
||||||
// Parse basic elements (ID...):
|
// Parse basic elements (ID...):
|
||||||
m_id = _element.attributes["id"];
|
m_id = _element.attributes["id"];
|
||||||
_sizeMax = vec2(0.0f, 0.0f);
|
_sizeMax = Vector2f(0.0f, 0.0f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ void esvg::Base::setId(const etk::String& _newId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Base::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Base::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -45,7 +45,7 @@ namespace esvg {
|
|||||||
enum esvg::cap lineCap;
|
enum esvg::cap lineCap;
|
||||||
enum esvg::join lineJoin;
|
enum esvg::join lineJoin;
|
||||||
float miterLimit;
|
float miterLimit;
|
||||||
etk::Pair<vec2, vec2> viewPort; //!< min pos, max pos
|
etk::Pair<Vector2f, Vector2f> viewPort; //!< min pos, max pos
|
||||||
float opacity;
|
float opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ namespace esvg {
|
|||||||
* @param[in] _element standart XML node
|
* @param[in] _element standart XML node
|
||||||
* @return true if no problem arrived
|
* @return true if no problem arrived
|
||||||
*/
|
*/
|
||||||
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax);
|
||||||
/**
|
/**
|
||||||
* @brief Draw the form in the renderer
|
* @brief Draw the form in the renderer
|
||||||
* @param[in] _myRenderer Renderer engine
|
* @param[in] _myRenderer Renderer engine
|
||||||
@ -79,7 +79,7 @@ namespace esvg {
|
|||||||
* @param[in] _basicTrans Parant transformation of the environement
|
* @param[in] _basicTrans Parant transformation of the environement
|
||||||
* @param[in] _level Level of the tree
|
* @param[in] _level Level of the tree
|
||||||
*/
|
*/
|
||||||
virtual void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
virtual void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -93,7 +93,7 @@ namespace esvg {
|
|||||||
* @param[out] _pos parsed position
|
* @param[out] _pos parsed position
|
||||||
* @param[out] _size parsed dimention
|
* @param[out] _size parsed dimention
|
||||||
*/
|
*/
|
||||||
void parsePosition(const exml::Element& _element, vec2 &_pos, vec2 &_size);
|
void parsePosition(const exml::Element& _element, Vector2f &_pos, Vector2f &_size);
|
||||||
/**
|
/**
|
||||||
* @brief parse a lenght of the xml element
|
* @brief parse a lenght of the xml element
|
||||||
* @param[in] _dataInput Data C String with the printed lenght
|
* @param[in] _dataInput Data C String with the printed lenght
|
||||||
|
@ -17,7 +17,7 @@ esvg::Circle::~Circle() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Circle::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Circle::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
m_radius = 0.0;
|
m_radius = 0.0;
|
||||||
m_position.setValue(0,0);
|
m_position.setValue(0,0);
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
@ -61,23 +61,23 @@ esvg::render::Path esvg::Circle::createPath() {
|
|||||||
esvg::render::Path out;
|
esvg::render::Path out;
|
||||||
|
|
||||||
out.clear();
|
out.clear();
|
||||||
out.moveTo(false, m_position + vec2(m_radius, 0.0f));
|
out.moveTo(false, m_position + Vector2f(m_radius, 0.0f));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_position + vec2(m_radius, m_radius*esvg::kappa90),
|
m_position + Vector2f(m_radius, m_radius*esvg::kappa90),
|
||||||
m_position + vec2(m_radius*esvg::kappa90, m_radius),
|
m_position + Vector2f(m_radius*esvg::kappa90, m_radius),
|
||||||
m_position + vec2(0.0f, m_radius));
|
m_position + Vector2f(0.0f, m_radius));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_position + vec2(-m_radius*esvg::kappa90, m_radius),
|
m_position + Vector2f(-m_radius*esvg::kappa90, m_radius),
|
||||||
m_position + vec2(-m_radius, m_radius*esvg::kappa90),
|
m_position + Vector2f(-m_radius, m_radius*esvg::kappa90),
|
||||||
m_position + vec2(-m_radius, 0.0f));
|
m_position + Vector2f(-m_radius, 0.0f));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_position + vec2(-m_radius, -m_radius*esvg::kappa90),
|
m_position + Vector2f(-m_radius, -m_radius*esvg::kappa90),
|
||||||
m_position + vec2(-m_radius*esvg::kappa90, -m_radius),
|
m_position + Vector2f(-m_radius*esvg::kappa90, -m_radius),
|
||||||
m_position + vec2(0.0f, -m_radius));
|
m_position + Vector2f(0.0f, -m_radius));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_position + vec2(m_radius*esvg::kappa90, -m_radius),
|
m_position + Vector2f(m_radius*esvg::kappa90, -m_radius),
|
||||||
m_position + vec2(m_radius, -m_radius*esvg::kappa90),
|
m_position + Vector2f(m_radius, -m_radius*esvg::kappa90),
|
||||||
m_position + vec2(m_radius, 0.0f));
|
m_position + Vector2f(m_radius, 0.0f));
|
||||||
out.close();
|
out.close();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Circle::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Circle::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -156,7 +156,7 @@ void esvg::Circle::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
|||||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||||
listPoints.applyMatrix(mtx);
|
listPoints.applyMatrix(mtx);
|
||||||
for (auto &it : listPoints.m_data) {
|
for (auto &it : listPoints.m_data) {
|
||||||
etk::Vector<vec2> listPoint;
|
List<Vector2f> listPoint;
|
||||||
for (auto &itDot : it) {
|
for (auto &itDot : it) {
|
||||||
listPoint.pushBack(itDot.m_pos);
|
listPoint.pushBack(itDot.m_pos);
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
namespace esvg {
|
namespace esvg {
|
||||||
class Circle : public esvg::Base {
|
class Circle : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
vec2 m_position; //!< Position of the Circle
|
Vector2f m_position; //!< Position of the Circle
|
||||||
float m_radius; //!< Radius of the Circle
|
float m_radius; //!< Radius of the Circle
|
||||||
public:
|
public:
|
||||||
Circle(PaintState _parentPaintState);
|
Circle(PaintState _parentPaintState);
|
||||||
~Circle();
|
~Circle();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -27,7 +27,7 @@ esvg::Dimension::Dimension() :
|
|||||||
// notinh to do ...
|
// notinh to do ...
|
||||||
}
|
}
|
||||||
|
|
||||||
esvg::Dimension::Dimension(const vec2& _size, enum esvg::distance _type) :
|
esvg::Dimension::Dimension(const Vector2f& _size, enum esvg::distance _type) :
|
||||||
m_data(0,0),
|
m_data(0,0),
|
||||||
m_type(esvg::distance_pixel) {
|
m_type(esvg::distance_pixel) {
|
||||||
set(_size, _type);
|
set(_size, _type);
|
||||||
@ -66,7 +66,7 @@ void esvg::Dimension::set(etk::String _config) {
|
|||||||
Log.verbose("default dimention type for: '" << _config << "' ==> pixel");
|
Log.verbose("default dimention type for: '" << _config << "' ==> pixel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vec2 tmp = _config;
|
Vector2f tmp = _config;
|
||||||
set(tmp, type);
|
set(tmp, type);
|
||||||
Log.verbose(" config dimention : \"" << _config << "\" == > " << *this );
|
Log.verbose(" config dimention : \"" << _config << "\" == > " << *this );
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ void esvg::Dimension::set(etk::String _configX, etk::String _configY) {
|
|||||||
enum distance typeY = parseType(_configY);
|
enum distance typeY = parseType(_configY);
|
||||||
float valueY = etk::string_to_float(_configY);
|
float valueY = etk::string_to_float(_configY);
|
||||||
// TODO : Check difference ...
|
// TODO : Check difference ...
|
||||||
set(vec2(valueX, valueY), typeX);
|
set(Vector2f(valueX, valueY), typeX);
|
||||||
Log.verbose(" config dimention : '" << _configX << "' '" << _configY << "' == > " << *this );
|
Log.verbose(" config dimention : '" << _configX << "' '" << _configY << "' == > " << *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ esvg::Dimension::operator etk::String() const {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Dimension::set(const vec2& _size, enum esvg::distance _type) {
|
void esvg::Dimension::set(const Vector2f& _size, enum esvg::distance _type) {
|
||||||
m_data = _size;
|
m_data = _size;
|
||||||
m_type = _type;
|
m_type = _type;
|
||||||
switch(_type) {
|
switch(_type) {
|
||||||
@ -192,26 +192,26 @@ void esvg::Dimension::set(const vec2& _size, enum esvg::distance _type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 esvg::Dimension::getPixel(const vec2& _upperSize) const {
|
Vector2f esvg::Dimension::getPixel(const Vector2f& _upperSize) const {
|
||||||
switch(m_type) {
|
switch(m_type) {
|
||||||
case esvg::distance_pourcent:
|
case esvg::distance_pourcent:
|
||||||
return vec2(_upperSize.x()*m_data.x()*0.01f, _upperSize.y()*m_data.y()*0.01f);
|
return Vector2f(_upperSize.x()*m_data.x()*0.01f, _upperSize.y()*m_data.y()*0.01f);
|
||||||
case esvg::distance_pixel:
|
case esvg::distance_pixel:
|
||||||
return m_data;
|
return m_data;
|
||||||
case esvg::distance_meter:
|
case esvg::distance_meter:
|
||||||
return vec2(m_data.x()*meterToMillimeter*basicRatio, m_data.y()*meterToMillimeter*basicRatio);
|
return Vector2f(m_data.x()*meterToMillimeter*basicRatio, m_data.y()*meterToMillimeter*basicRatio);
|
||||||
case esvg::distance_centimeter:
|
case esvg::distance_centimeter:
|
||||||
return vec2(m_data.x()*centimeterToMillimeter*basicRatio, m_data.y()*centimeterToMillimeter*basicRatio);
|
return Vector2f(m_data.x()*centimeterToMillimeter*basicRatio, m_data.y()*centimeterToMillimeter*basicRatio);
|
||||||
case esvg::distance_millimeter:
|
case esvg::distance_millimeter:
|
||||||
return vec2(m_data.x()*basicRatio, m_data.y()*basicRatio);
|
return Vector2f(m_data.x()*basicRatio, m_data.y()*basicRatio);
|
||||||
case esvg::distance_kilometer:
|
case esvg::distance_kilometer:
|
||||||
return vec2(m_data.x()*kilometerToMillimeter*basicRatio, m_data.y()*kilometerToMillimeter*basicRatio);
|
return Vector2f(m_data.x()*kilometerToMillimeter*basicRatio, m_data.y()*kilometerToMillimeter*basicRatio);
|
||||||
case esvg::distance_inch:
|
case esvg::distance_inch:
|
||||||
return vec2(m_data.x()*inchToMillimeter*basicRatio, m_data.y()*inchToMillimeter*basicRatio);
|
return Vector2f(m_data.x()*inchToMillimeter*basicRatio, m_data.y()*inchToMillimeter*basicRatio);
|
||||||
case esvg::distance_foot:
|
case esvg::distance_foot:
|
||||||
return vec2(m_data.x()*footToMillimeter*basicRatio, m_data.y()*footToMillimeter*basicRatio);
|
return Vector2f(m_data.x()*footToMillimeter*basicRatio, m_data.y()*footToMillimeter*basicRatio);
|
||||||
}
|
}
|
||||||
return vec2(128.0f, 128.0f);
|
return Vector2f(128.0f, 128.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::distance _obj) {
|
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::distance _obj) {
|
||||||
|
@ -29,7 +29,7 @@ namespace esvg {
|
|||||||
*/
|
*/
|
||||||
class Dimension {
|
class Dimension {
|
||||||
private:
|
private:
|
||||||
vec2 m_data;
|
Vector2f m_data;
|
||||||
enum distance m_type;
|
enum distance m_type;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ namespace esvg {
|
|||||||
* @param[in] _size Requested dimention
|
* @param[in] _size Requested dimention
|
||||||
* @param[in] _type Unit of the Dimention
|
* @param[in] _type Unit of the Dimention
|
||||||
*/
|
*/
|
||||||
Dimension(const vec2& _size, enum esvg::distance _type=esvg::distance_pixel);
|
Dimension(const Vector2f& _size, enum esvg::distance _type=esvg::distance_pixel);
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
* @param[in] _config dimension configuration.
|
* @param[in] _config dimension configuration.
|
||||||
@ -75,7 +75,7 @@ namespace esvg {
|
|||||||
* @brief get the current dimention.
|
* @brief get the current dimention.
|
||||||
* @return dimention requested.
|
* @return dimention requested.
|
||||||
*/
|
*/
|
||||||
const vec2& getValue() const {
|
const Vector2f& getValue() const {
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -90,7 +90,7 @@ namespace esvg {
|
|||||||
* @param[in] _size Dimention to set
|
* @param[in] _size Dimention to set
|
||||||
* @param[in] _type Type of unit requested.
|
* @param[in] _type Type of unit requested.
|
||||||
*/
|
*/
|
||||||
void set(const vec2& _size, enum distance _type);
|
void set(const Vector2f& _size, enum distance _type);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -110,7 +110,7 @@ namespace esvg {
|
|||||||
* @param[in] _upperSize Size in pixel of the upper value
|
* @param[in] _upperSize Size in pixel of the upper value
|
||||||
* @return dimention in Pixel
|
* @return dimention in Pixel
|
||||||
*/
|
*/
|
||||||
vec2 getPixel(const vec2& _upperSize) const;
|
Vector2f getPixel(const Vector2f& _upperSize) const;
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* = assigment
|
* = assigment
|
||||||
*****************************************************/
|
*****************************************************/
|
||||||
|
@ -17,7 +17,7 @@ esvg::Ellipse::~Ellipse() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Ellipse::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Ellipse::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -65,23 +65,23 @@ void esvg::Ellipse::display(int32_t _spacing) {
|
|||||||
esvg::render::Path esvg::Ellipse::createPath() {
|
esvg::render::Path esvg::Ellipse::createPath() {
|
||||||
esvg::render::Path out;
|
esvg::render::Path out;
|
||||||
out.clear();
|
out.clear();
|
||||||
out.moveTo(false, m_c + vec2(m_r.x(), 0.0f));
|
out.moveTo(false, m_c + Vector2f(m_r.x(), 0.0f));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_c + vec2(m_r.x(), m_r.y()*esvg::kappa90),
|
m_c + Vector2f(m_r.x(), m_r.y()*esvg::kappa90),
|
||||||
m_c + vec2(m_r.x()*esvg::kappa90, m_r.y()),
|
m_c + Vector2f(m_r.x()*esvg::kappa90, m_r.y()),
|
||||||
m_c + vec2(0.0f, m_r.y()));
|
m_c + Vector2f(0.0f, m_r.y()));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_c + vec2(-m_r.x()*esvg::kappa90, m_r.y()),
|
m_c + Vector2f(-m_r.x()*esvg::kappa90, m_r.y()),
|
||||||
m_c + vec2(-m_r.x(), m_r.y()*esvg::kappa90),
|
m_c + Vector2f(-m_r.x(), m_r.y()*esvg::kappa90),
|
||||||
m_c + vec2(-m_r.x(), 0.0f));
|
m_c + Vector2f(-m_r.x(), 0.0f));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_c + vec2(-m_r.x(), -m_r.y()*esvg::kappa90),
|
m_c + Vector2f(-m_r.x(), -m_r.y()*esvg::kappa90),
|
||||||
m_c + vec2(-m_r.x()*esvg::kappa90, -m_r.y()),
|
m_c + Vector2f(-m_r.x()*esvg::kappa90, -m_r.y()),
|
||||||
m_c + vec2(0.0f, -m_r.y()));
|
m_c + Vector2f(0.0f, -m_r.y()));
|
||||||
out.curveTo(false,
|
out.curveTo(false,
|
||||||
m_c + vec2(m_r.x()*esvg::kappa90, -m_r.y()),
|
m_c + Vector2f(m_r.x()*esvg::kappa90, -m_r.y()),
|
||||||
m_c + vec2(m_r.x(), -m_r.y()*esvg::kappa90),
|
m_c + Vector2f(m_r.x(), -m_r.y()*esvg::kappa90),
|
||||||
m_c + vec2(m_r.x(), 0.0f));
|
m_c + Vector2f(m_r.x(), 0.0f));
|
||||||
out.close();
|
out.close();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Ellipse::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Ellipse::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -162,7 +162,7 @@ void esvg::Ellipse::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
|||||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||||
listPoints.applyMatrix(mtx);
|
listPoints.applyMatrix(mtx);
|
||||||
for (auto &it : listPoints.m_data) {
|
for (auto &it : listPoints.m_data) {
|
||||||
etk::Vector<vec2> listPoint;
|
List<Vector2f> listPoint;
|
||||||
for (auto &itDot : it) {
|
for (auto &itDot : it) {
|
||||||
listPoint.pushBack(itDot.m_pos);
|
listPoint.pushBack(itDot.m_pos);
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
namespace esvg {
|
namespace esvg {
|
||||||
class Ellipse : public esvg::Base {
|
class Ellipse : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
vec2 m_c; //!< Center property of the ellipse
|
Vector2f m_c; //!< Center property of the ellipse
|
||||||
vec2 m_r; //!< Radius property of the ellipse
|
Vector2f m_r; //!< Radius property of the ellipse
|
||||||
public:
|
public:
|
||||||
Ellipse(PaintState _parentPaintState);
|
Ellipse(PaintState _parentPaintState);
|
||||||
~Ellipse();
|
~Ellipse();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -26,13 +26,13 @@ esvg::Group::~Group() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Group::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Group::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// parse ...
|
// parse ...
|
||||||
vec2 pos(0,0);
|
Vector2f pos(0,0);
|
||||||
vec2 size(0,0);
|
Vector2f size(0,0);
|
||||||
parseTransform(_element);
|
parseTransform(_element);
|
||||||
parsePosition(_element, pos, size);
|
parsePosition(_element, pos, size);
|
||||||
parsePaintAttr(_element);
|
parsePaintAttr(_element);
|
||||||
@ -44,7 +44,7 @@ bool esvg::Group::parseXML(const exml::Element& _element, mat2x3& _parentTrans,
|
|||||||
Log.verbose("parsed G2. trans : " << m_transformMatrix);
|
Log.verbose("parsed G2. trans : " << m_transformMatrix);
|
||||||
|
|
||||||
_sizeMax.setValue(0,0);
|
_sizeMax.setValue(0,0);
|
||||||
vec2 tmpPos(0,0);
|
Vector2f tmpPos(0,0);
|
||||||
// parse all sub node :
|
// parse all sub node :
|
||||||
for(const auto it : _element.nodes) {
|
for(const auto it : _element.nodes) {
|
||||||
exml::Element child = it.toElement();
|
exml::Element child = it.toElement();
|
||||||
@ -114,7 +114,7 @@ void esvg::Group::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Group::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Group::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
namespace esvg {
|
namespace esvg {
|
||||||
class Group : public esvg::Base {
|
class Group : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
etk::Vector<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub elements ...
|
List<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub elements ...
|
||||||
public:
|
public:
|
||||||
Group(PaintState _parentPaintState);
|
Group(PaintState _parentPaintState);
|
||||||
~Group();
|
~Group();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t spacing) override;
|
void display(int32_t spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -18,7 +18,7 @@ esvg::Line::~Line() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Line::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Line::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
// line must have a minimum size...
|
// line must have a minimum size...
|
||||||
m_paint.strokeWidth = 1;
|
m_paint.strokeWidth = 1;
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
@ -116,7 +116,7 @@ void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Line::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Line::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -129,7 +129,7 @@ void esvg::Line::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
|||||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||||
listPoints.applyMatrix(mtx);
|
listPoints.applyMatrix(mtx);
|
||||||
for (auto &it : listPoints.m_data) {
|
for (auto &it : listPoints.m_data) {
|
||||||
etk::Vector<vec2> listPoint;
|
List<Vector2f> listPoint;
|
||||||
for (auto &itDot : it) {
|
for (auto &itDot : it) {
|
||||||
listPoint.pushBack(itDot.m_pos);
|
listPoint.pushBack(itDot.m_pos);
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
namespace esvg {
|
namespace esvg {
|
||||||
class Line : public esvg::Base {
|
class Line : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
vec2 m_startPos; //!< Start line position
|
Vector2f m_startPos; //!< Start line position
|
||||||
vec2 m_stopPos; //!< Stop line position
|
Vector2f m_stopPos; //!< Stop line position
|
||||||
public:
|
public:
|
||||||
Line(PaintState _parentPaintState);
|
Line(PaintState _parentPaintState);
|
||||||
~Line();
|
~Line();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
esvg::LinearGradient::LinearGradient(PaintState _parentPaintState) :
|
esvg::LinearGradient::LinearGradient(PaintState _parentPaintState) :
|
||||||
esvg::Base(_parentPaintState),
|
esvg::Base(_parentPaintState),
|
||||||
m_pos1(vec2(50,50), esvg::distance_pourcent),
|
m_pos1(Vector2f(50,50), esvg::distance_pourcent),
|
||||||
m_pos2(vec2(50,50), esvg::distance_pourcent),
|
m_pos2(Vector2f(50,50), esvg::distance_pourcent),
|
||||||
m_unit(gradientUnits_objectBoundingBox),
|
m_unit(gradientUnits_objectBoundingBox),
|
||||||
m_spread(spreadMethod_pad) {
|
m_spread(spreadMethod_pad) {
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ esvg::LinearGradient::~LinearGradient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
// line must have a minimum size...
|
// line must have a minimum size...
|
||||||
//m_paint.strokeWidth = 1;
|
//m_paint.strokeWidth = 1;
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
@ -147,7 +147,7 @@ const esvg::Dimension& esvg::LinearGradient::getPosition2() {
|
|||||||
return m_pos2;
|
return m_pos2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& esvg::LinearGradient::getColors(esvg::Document* _document) {
|
const List<etk::Pair<float, etk::Color<float,4>>>& esvg::LinearGradient::getColors(esvg::Document* _document) {
|
||||||
if (m_href == "") {
|
if (m_href == "") {
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,17 @@ namespace esvg {
|
|||||||
enum spreadMethod m_spread;
|
enum spreadMethod m_spread;
|
||||||
private:
|
private:
|
||||||
etk::String m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
etk::String m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||||
etk::Vector<etk::Pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
List<etk::Pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
||||||
public:
|
public:
|
||||||
LinearGradient(PaintState _parentPaintState);
|
LinearGradient(PaintState _parentPaintState);
|
||||||
~LinearGradient();
|
~LinearGradient();
|
||||||
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax);
|
||||||
virtual void display(int32_t _spacing);
|
virtual void display(int32_t _spacing);
|
||||||
virtual void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level);
|
virtual void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level);
|
||||||
public:
|
public:
|
||||||
const esvg::Dimension& getPosition1();
|
const esvg::Dimension& getPosition1();
|
||||||
const esvg::Dimension& getPosition2();
|
const esvg::Dimension& getPosition2();
|
||||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
const List<etk::Pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ esvg::Path::~Path() {
|
|||||||
|
|
||||||
|
|
||||||
// return the next char position ... (after 'X' or NULL)
|
// return the next char position ... (after 'X' or NULL)
|
||||||
const char * extractCmd(const char* _input, char& _cmd, etk::Vector<float>& _outputList) {
|
const char * extractCmd(const char* _input, char& _cmd, List<float>& _outputList) {
|
||||||
if (*_input == '\0') {
|
if (*_input == '\0') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ etk::String cleanBadSpaces(const etk::String& _input) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
Log.verbose("Parse Path : \"" << elementXML1 << "\"");
|
Log.verbose("Parse Path : \"" << elementXML1 << "\"");
|
||||||
|
|
||||||
char command;
|
char command;
|
||||||
etk::Vector<float> listDot;
|
List<float> listDot;
|
||||||
elementXML1 = cleanBadSpaces(elementXML1);
|
elementXML1 = cleanBadSpaces(elementXML1);
|
||||||
const char* elementXML = elementXML1.c_str();
|
const char* elementXML = elementXML1.c_str();
|
||||||
|
|
||||||
@ -114,11 +114,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
}
|
}
|
||||||
if (listDot.size() >= 2) {
|
if (listDot.size() >= 2) {
|
||||||
m_listElement.moveTo(relative,
|
m_listElement.moveTo(relative,
|
||||||
vec2(listDot[0], listDot[1]));
|
Vector2f(listDot[0], listDot[1]));
|
||||||
}
|
}
|
||||||
for (size_t iii=2; iii<listDot.size(); iii+=2) {
|
for (size_t iii=2; iii<listDot.size(); iii+=2) {
|
||||||
m_listElement.lineTo(relative,
|
m_listElement.lineTo(relative,
|
||||||
vec2(listDot[iii], listDot[iii+1]));
|
Vector2f(listDot[iii], listDot[iii+1]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'l': // Line to (relative)
|
case 'l': // Line to (relative)
|
||||||
@ -131,7 +131,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
}
|
}
|
||||||
for (size_t iii=0; iii<listDot.size(); iii+=2) {
|
for (size_t iii=0; iii<listDot.size(); iii+=2) {
|
||||||
m_listElement.lineTo(relative,
|
m_listElement.lineTo(relative,
|
||||||
vec2(listDot[iii], listDot[iii+1]));
|
Vector2f(listDot[iii], listDot[iii+1]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -173,8 +173,8 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
}
|
}
|
||||||
for (size_t iii=0; iii<listDot.size(); iii+=4) {
|
for (size_t iii=0; iii<listDot.size(); iii+=4) {
|
||||||
m_listElement.bezierCurveTo(relative,
|
m_listElement.bezierCurveTo(relative,
|
||||||
vec2(listDot[iii],listDot[iii+1]),
|
Vector2f(listDot[iii],listDot[iii+1]),
|
||||||
vec2(listDot[iii+2],listDot[iii+3]));
|
Vector2f(listDot[iii+2],listDot[iii+3]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
}
|
}
|
||||||
for (size_t iii=0; iii<listDot.size(); iii+=2) {
|
for (size_t iii=0; iii<listDot.size(); iii+=2) {
|
||||||
m_listElement.bezierSmoothCurveTo(relative,
|
m_listElement.bezierSmoothCurveTo(relative,
|
||||||
vec2(listDot[iii],listDot[iii+1]));
|
Vector2f(listDot[iii],listDot[iii+1]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -202,9 +202,9 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
}
|
}
|
||||||
for (size_t iii=0; iii<listDot.size(); iii+=6) {
|
for (size_t iii=0; iii<listDot.size(); iii+=6) {
|
||||||
m_listElement.curveTo(relative,
|
m_listElement.curveTo(relative,
|
||||||
vec2(listDot[iii],listDot[iii+1]),
|
Vector2f(listDot[iii],listDot[iii+1]),
|
||||||
vec2(listDot[iii+2],listDot[iii+3]),
|
Vector2f(listDot[iii+2],listDot[iii+3]),
|
||||||
vec2(listDot[iii+4],listDot[iii+5]));
|
Vector2f(listDot[iii+4],listDot[iii+5]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -218,8 +218,8 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
}
|
}
|
||||||
for (size_t iii=0; iii<listDot.size(); iii+=4) {
|
for (size_t iii=0; iii<listDot.size(); iii+=4) {
|
||||||
m_listElement.smoothCurveTo(relative,
|
m_listElement.smoothCurveTo(relative,
|
||||||
vec2(listDot[iii],listDot[iii+1]),
|
Vector2f(listDot[iii],listDot[iii+1]),
|
||||||
vec2(listDot[iii+2],listDot[iii+3]));
|
Vector2f(listDot[iii+2],listDot[iii+3]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -241,11 +241,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, v
|
|||||||
sweepFlag = false;
|
sweepFlag = false;
|
||||||
}
|
}
|
||||||
m_listElement.ellipticTo(relative,
|
m_listElement.ellipticTo(relative,
|
||||||
vec2(listDot[iii], listDot[iii+1]),
|
Vector2f(listDot[iii], listDot[iii+1]),
|
||||||
listDot[iii+2],
|
listDot[iii+2],
|
||||||
largeArcFlag,
|
largeArcFlag,
|
||||||
sweepFlag,
|
sweepFlag,
|
||||||
vec2(listDot[iii+5], listDot[iii+6]) );
|
Vector2f(listDot[iii+5], listDot[iii+6]) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'z': // closepath (relative)
|
case 'z': // closepath (relative)
|
||||||
@ -325,7 +325,7 @@ void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Path::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Path::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -339,7 +339,7 @@ void esvg::Path::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
|||||||
listPoints = m_listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
listPoints = m_listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||||
listPoints.applyMatrix(mtx);
|
listPoints.applyMatrix(mtx);
|
||||||
for (auto &it : listPoints.m_data) {
|
for (auto &it : listPoints.m_data) {
|
||||||
etk::Vector<vec2> listPoint;
|
List<Vector2f> listPoint;
|
||||||
for (auto &itDot : it) {
|
for (auto &itDot : it) {
|
||||||
listPoint.pushBack(itDot.m_pos);
|
listPoint.pushBack(itDot.m_pos);
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ namespace esvg {
|
|||||||
public:
|
public:
|
||||||
Path(PaintState _parentPaintState);
|
Path(PaintState _parentPaintState);
|
||||||
~Path();
|
~Path();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -17,7 +17,7 @@ esvg::Polygon::~Polygon() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Polygon::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Polygon::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ bool esvg::Polygon::parseXML(const exml::Element& _element, mat2x3& _parentTrans
|
|||||||
_sizeMax.setValue(0,0);
|
_sizeMax.setValue(0,0);
|
||||||
Log.verbose("Parse polygon : \"" << sss << "\"");
|
Log.verbose("Parse polygon : \"" << sss << "\"");
|
||||||
while ('\0' != sss[0]) {
|
while ('\0' != sss[0]) {
|
||||||
vec2 pos(0,0);
|
Vector2f pos(0,0);
|
||||||
int32_t n;
|
int32_t n;
|
||||||
if (sscanf(sss, "%f,%f%n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
if (sscanf(sss, "%f,%f%n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
||||||
m_listPoint.pushBack(pos);
|
m_listPoint.pushBack(pos);
|
||||||
@ -130,7 +130,7 @@ void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Polygon::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Polygon::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -143,7 +143,7 @@ void esvg::Polygon::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
|||||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||||
listPoints.applyMatrix(mtx);
|
listPoints.applyMatrix(mtx);
|
||||||
for (auto &it : listPoints.m_data) {
|
for (auto &it : listPoints.m_data) {
|
||||||
etk::Vector<vec2> listPoint;
|
List<Vector2f> listPoint;
|
||||||
for (auto &itDot : it) {
|
for (auto &itDot : it) {
|
||||||
listPoint.pushBack(itDot.m_pos);
|
listPoint.pushBack(itDot.m_pos);
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,15 @@ namespace esvg {
|
|||||||
*/
|
*/
|
||||||
class Polygon : public esvg::Base {
|
class Polygon : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
etk::Vector<vec2 > m_listPoint; //!< list of all point of the polygone
|
List<Vector2f > m_listPoint; //!< list of all point of the polygone
|
||||||
//enum esvg::polygonMode m_diplayMode; //!< polygone specific display mode
|
//enum esvg::polygonMode m_diplayMode; //!< polygone specific display mode
|
||||||
public:
|
public:
|
||||||
Polygon(PaintState parentPaintState);
|
Polygon(PaintState parentPaintState);
|
||||||
~Polygon();
|
~Polygon();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -17,7 +17,7 @@ esvg::Polyline::~Polyline() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Polyline::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Polyline::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
// line must have a minimum size...
|
// line must have a minimum size...
|
||||||
m_paint.strokeWidth = 1;
|
m_paint.strokeWidth = 1;
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
@ -38,7 +38,7 @@ bool esvg::Polyline::parseXML(const exml::Element& _element, mat2x3& _parentTran
|
|||||||
Log.verbose("Parse polyline : \"" << sss1 << "\"");
|
Log.verbose("Parse polyline : \"" << sss1 << "\"");
|
||||||
const char* sss = sss1.c_str();
|
const char* sss = sss1.c_str();
|
||||||
while ('\0' != sss[0]) {
|
while ('\0' != sss[0]) {
|
||||||
vec2 pos;
|
Vector2f pos;
|
||||||
int32_t n;
|
int32_t n;
|
||||||
if (sscanf(sss, "%f,%f %n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
if (sscanf(sss, "%f,%f %n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
||||||
m_listPoint.pushBack(pos);
|
m_listPoint.pushBack(pos);
|
||||||
@ -127,7 +127,7 @@ void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int3
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Polyline::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Polyline::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -140,7 +140,7 @@ void esvg::Polyline::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
|||||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||||
listPoints.applyMatrix(mtx);
|
listPoints.applyMatrix(mtx);
|
||||||
for (auto &it : listPoints.m_data) {
|
for (auto &it : listPoints.m_data) {
|
||||||
etk::Vector<vec2> listPoint;
|
List<Vector2f> listPoint;
|
||||||
for (auto &itDot : it) {
|
for (auto &itDot : it) {
|
||||||
listPoint.pushBack(itDot.m_pos);
|
listPoint.pushBack(itDot.m_pos);
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
namespace esvg {
|
namespace esvg {
|
||||||
class Polyline : public esvg::Base {
|
class Polyline : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
etk::Vector<vec2 > m_listPoint; //!< list of all point of the polyline
|
List<Vector2f > m_listPoint; //!< list of all point of the polyline
|
||||||
public:
|
public:
|
||||||
Polyline(PaintState _parentPaintState);
|
Polyline(PaintState _parentPaintState);
|
||||||
~Polyline();
|
~Polyline();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
esvg::RadialGradient::RadialGradient(PaintState _parentPaintState) :
|
esvg::RadialGradient::RadialGradient(PaintState _parentPaintState) :
|
||||||
esvg::Base(_parentPaintState),
|
esvg::Base(_parentPaintState),
|
||||||
m_center(vec2(50,50), esvg::distance_pourcent),
|
m_center(Vector2f(50,50), esvg::distance_pourcent),
|
||||||
m_radius(50, esvg::distance_pourcent),
|
m_radius(50, esvg::distance_pourcent),
|
||||||
m_focal(vec2(50,50), esvg::distance_pourcent),
|
m_focal(Vector2f(50,50), esvg::distance_pourcent),
|
||||||
m_unit(gradientUnits_objectBoundingBox),
|
m_unit(gradientUnits_objectBoundingBox),
|
||||||
m_spread(spreadMethod_pad) {
|
m_spread(spreadMethod_pad) {
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ esvg::RadialGradient::~RadialGradient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
// line must have a minimum size...
|
// line must have a minimum size...
|
||||||
//m_paint.strokeWidth = 1;
|
//m_paint.strokeWidth = 1;
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
@ -156,7 +156,7 @@ const esvg::Dimension1D& esvg::RadialGradient::getRadius() {
|
|||||||
return m_radius;
|
return m_radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& esvg::RadialGradient::getColors(esvg::Document* _document) {
|
const List<etk::Pair<float, etk::Color<float,4>>>& esvg::RadialGradient::getColors(esvg::Document* _document) {
|
||||||
if (m_href == "") {
|
if (m_href == "") {
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
@ -21,18 +21,18 @@ namespace esvg {
|
|||||||
enum spreadMethod m_spread;
|
enum spreadMethod m_spread;
|
||||||
private:
|
private:
|
||||||
etk::String m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
etk::String m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||||
etk::Vector<etk::Pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
List<etk::Pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
||||||
public:
|
public:
|
||||||
RadialGradient(PaintState _parentPaintState);
|
RadialGradient(PaintState _parentPaintState);
|
||||||
~RadialGradient();
|
~RadialGradient();
|
||||||
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax);
|
||||||
virtual void display(int32_t _spacing);
|
virtual void display(int32_t _spacing);
|
||||||
virtual void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level);
|
virtual void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level);
|
||||||
public:
|
public:
|
||||||
const esvg::Dimension& getCenter();
|
const esvg::Dimension& getCenter();
|
||||||
const esvg::Dimension& getFocal();
|
const esvg::Dimension& getFocal();
|
||||||
const esvg::Dimension1D& getRadius();
|
const esvg::Dimension1D& getRadius();
|
||||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
const List<etk::Pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ esvg::Rectangle::~Rectangle() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Rectangle::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Rectangle::parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
if (_element.exist() == false) {
|
if (_element.exist() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -63,23 +63,23 @@ esvg::render::Path esvg::Rectangle::createPath() {
|
|||||||
out.lineToH(true, -m_size.x());
|
out.lineToH(true, -m_size.x());
|
||||||
} else {
|
} else {
|
||||||
// Rounded rectangle
|
// Rounded rectangle
|
||||||
out.moveTo(false, m_position + vec2(m_roundedCorner.x(), 0.0f));
|
out.moveTo(false, m_position + Vector2f(m_roundedCorner.x(), 0.0f));
|
||||||
out.lineToH(true, m_size.x()-m_roundedCorner.x()*2.0f);
|
out.lineToH(true, m_size.x()-m_roundedCorner.x()*2.0f);
|
||||||
out.curveTo(true, vec2(m_roundedCorner.x()*esvg::kappa90, 0.0f),
|
out.curveTo(true, Vector2f(m_roundedCorner.x()*esvg::kappa90, 0.0f),
|
||||||
vec2(m_roundedCorner.x(), m_roundedCorner.y() * (1.0f - esvg::kappa90)),
|
Vector2f(m_roundedCorner.x(), m_roundedCorner.y() * (1.0f - esvg::kappa90)),
|
||||||
vec2(m_roundedCorner.x(), m_roundedCorner.y()) );
|
Vector2f(m_roundedCorner.x(), m_roundedCorner.y()) );
|
||||||
out.lineToV(true, m_size.y()-m_roundedCorner.y()*2.0f);
|
out.lineToV(true, m_size.y()-m_roundedCorner.y()*2.0f);
|
||||||
out.curveTo(true, vec2(0.0f, m_roundedCorner.y() * esvg::kappa90),
|
out.curveTo(true, Vector2f(0.0f, m_roundedCorner.y() * esvg::kappa90),
|
||||||
vec2(-m_roundedCorner.x()* (1.0f - esvg::kappa90), m_roundedCorner.y()),
|
Vector2f(-m_roundedCorner.x()* (1.0f - esvg::kappa90), m_roundedCorner.y()),
|
||||||
vec2(-m_roundedCorner.x(), m_roundedCorner.y()) );
|
Vector2f(-m_roundedCorner.x(), m_roundedCorner.y()) );
|
||||||
out.lineToH(true, -(m_size.x()-m_roundedCorner.x()*2.0f));
|
out.lineToH(true, -(m_size.x()-m_roundedCorner.x()*2.0f));
|
||||||
out.curveTo(true, vec2(-m_roundedCorner.x()*esvg::kappa90, 0.0f),
|
out.curveTo(true, Vector2f(-m_roundedCorner.x()*esvg::kappa90, 0.0f),
|
||||||
vec2(-m_roundedCorner.x(), -m_roundedCorner.y() * (1.0f - esvg::kappa90)),
|
Vector2f(-m_roundedCorner.x(), -m_roundedCorner.y() * (1.0f - esvg::kappa90)),
|
||||||
vec2(-m_roundedCorner.x(), -m_roundedCorner.y()) );
|
Vector2f(-m_roundedCorner.x(), -m_roundedCorner.y()) );
|
||||||
out.lineToV(true, -(m_size.y()-m_roundedCorner.y()*2.0f));
|
out.lineToV(true, -(m_size.y()-m_roundedCorner.y()*2.0f));
|
||||||
out.curveTo(true, vec2(0.0f, -m_roundedCorner.y() * esvg::kappa90),
|
out.curveTo(true, Vector2f(0.0f, -m_roundedCorner.y() * esvg::kappa90),
|
||||||
vec2(m_roundedCorner.x()* (1.0f - esvg::kappa90), -m_roundedCorner.y()),
|
Vector2f(m_roundedCorner.x()* (1.0f - esvg::kappa90), -m_roundedCorner.y()),
|
||||||
vec2(m_roundedCorner.x(), -m_roundedCorner.y()) );
|
Vector2f(m_roundedCorner.x(), -m_roundedCorner.y()) );
|
||||||
}
|
}
|
||||||
out.close();
|
out.close();
|
||||||
return out;
|
return out;
|
||||||
@ -144,7 +144,7 @@ void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Rectangle::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Rectangle::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
@ -157,7 +157,7 @@ void esvg::Rectangle::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
|||||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||||
listPoints.applyMatrix(mtx);
|
listPoints.applyMatrix(mtx);
|
||||||
for (auto &it : listPoints.m_data) {
|
for (auto &it : listPoints.m_data) {
|
||||||
etk::Vector<vec2> listPoint;
|
List<Vector2f> listPoint;
|
||||||
for (auto &itDot : it) {
|
for (auto &itDot : it) {
|
||||||
listPoint.pushBack(itDot.m_pos);
|
listPoint.pushBack(itDot.m_pos);
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@
|
|||||||
namespace esvg {
|
namespace esvg {
|
||||||
class Rectangle : public esvg::Base {
|
class Rectangle : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
vec2 m_position; //!< position of the rectangle
|
Vector2f m_position; //!< position of the rectangle
|
||||||
vec2 m_size; //!< size of the rectangle
|
Vector2f m_size; //!< size of the rectangle
|
||||||
vec2 m_roundedCorner; //!< property of the rounded corner
|
Vector2f m_roundedCorner; //!< property of the rounded corner
|
||||||
public:
|
public:
|
||||||
Rectangle(PaintState _parentPaintState);
|
Rectangle(PaintState _parentPaintState);
|
||||||
~Rectangle();
|
~Rectangle();
|
||||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) override;
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <etk/uri/Uri.hpp>
|
#include <etk/uri/Uri.hpp>
|
||||||
#include <etk/uri/provider/provider.hpp>
|
#include <etk/uri/provider/provider.hpp>
|
||||||
|
|
||||||
esvg::Renderer::Renderer(const ivec2& _size, esvg::Document* _document, bool _visualDebug) :
|
esvg::Renderer::Renderer(const Vector2i& _size, esvg::Document* _document, bool _visualDebug) :
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_visualDebug(_visualDebug),
|
m_visualDebug(_visualDebug),
|
||||||
m_factor(1),
|
m_factor(1),
|
||||||
@ -28,7 +28,7 @@ esvg::Renderer::Renderer(const ivec2& _size, esvg::Document* _document, bool _vi
|
|||||||
|
|
||||||
esvg::Renderer::~Renderer() {
|
esvg::Renderer::~Renderer() {
|
||||||
m_buffer.clear();
|
m_buffer.clear();
|
||||||
m_size = ivec2(0,0);
|
m_size = Vector2i(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<float,4> esvg::Renderer::mergeColor(etk::Color<float,4> _base, etk::Color<float,4> _integration) {
|
etk::Color<float,4> esvg::Renderer::mergeColor(etk::Color<float,4> _base, etk::Color<float,4> _integration) {
|
||||||
@ -59,17 +59,17 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
ememory::SharedPtr<esvg::render::DynamicColor>& _colorStroke,
|
ememory::SharedPtr<esvg::render::DynamicColor>& _colorStroke,
|
||||||
float _opacity) {
|
float _opacity) {
|
||||||
if (_colorFill != null) {
|
if (_colorFill != null) {
|
||||||
//_colorFill->setViewPort(etk::Pair<vec2, vec2>(vec2(0,0), vec2(sizeX, sizeY)));
|
//_colorFill->setViewPort(etk::Pair<Vector2f, Vector2f>(Vector2f(0,0), Vector2f(sizeX, sizeY)));
|
||||||
_colorFill->generate(m_document);
|
_colorFill->generate(m_document);
|
||||||
}
|
}
|
||||||
if (_colorStroke != null) {
|
if (_colorStroke != null) {
|
||||||
//_colorStroke->setViewPort(etk::Pair<vec2, vec2>(vec2(0,0), vec2(sizeX, sizeY)));
|
//_colorStroke->setViewPort(etk::Pair<Vector2f, Vector2f>(Vector2f(0,0), Vector2f(sizeX, sizeY)));
|
||||||
_colorStroke->generate(m_document);
|
_colorStroke->generate(m_document);
|
||||||
}
|
}
|
||||||
// all together
|
// all together
|
||||||
for (int32_t yyy=0; yyy<m_size.y(); ++yyy) {
|
for (int32_t yyy=0; yyy<m_size.y(); ++yyy) {
|
||||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||||
ivec2 pos(xxx, yyy);
|
Vector2i pos(xxx, yyy);
|
||||||
float valueFill = _weightFill.get(pos);
|
float valueFill = _weightFill.get(pos);
|
||||||
float valueStroke = _weightStroke.get(pos);
|
float valueStroke = _weightStroke.get(pos);
|
||||||
// calculate merge of stroke and fill value:
|
// calculate merge of stroke and fill value:
|
||||||
@ -106,15 +106,15 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
esvg::render::SegmentList listSegment;
|
esvg::render::SegmentList listSegment;
|
||||||
// Display bounding box
|
// Display bounding box
|
||||||
listSegment.addSegment(esvg::render::Point(tmpColor->m_viewPort.first),
|
listSegment.addSegment(esvg::render::Point(tmpColor->m_viewPort.first),
|
||||||
esvg::render::Point(vec2(tmpColor->m_viewPort.first.x(), tmpColor->m_viewPort.second.y()) ),
|
esvg::render::Point(Vector2f(tmpColor->m_viewPort.first.x(), tmpColor->m_viewPort.second.y()) ),
|
||||||
false);
|
false);
|
||||||
listSegment.addSegment(esvg::render::Point(vec2(tmpColor->m_viewPort.first.x(), tmpColor->m_viewPort.second.y()) ),
|
listSegment.addSegment(esvg::render::Point(Vector2f(tmpColor->m_viewPort.first.x(), tmpColor->m_viewPort.second.y()) ),
|
||||||
esvg::render::Point(tmpColor->m_viewPort.second),
|
esvg::render::Point(tmpColor->m_viewPort.second),
|
||||||
false);
|
false);
|
||||||
listSegment.addSegment(esvg::render::Point(tmpColor->m_viewPort.second),
|
listSegment.addSegment(esvg::render::Point(tmpColor->m_viewPort.second),
|
||||||
esvg::render::Point(vec2(tmpColor->m_viewPort.second.x(), tmpColor->m_viewPort.first.y()) ),
|
esvg::render::Point(Vector2f(tmpColor->m_viewPort.second.x(), tmpColor->m_viewPort.first.y()) ),
|
||||||
false);
|
false);
|
||||||
listSegment.addSegment(esvg::render::Point(vec2(tmpColor->m_viewPort.second.x(), tmpColor->m_viewPort.first.y()) ),
|
listSegment.addSegment(esvg::render::Point(Vector2f(tmpColor->m_viewPort.second.x(), tmpColor->m_viewPort.first.y()) ),
|
||||||
esvg::render::Point(tmpColor->m_viewPort.first),
|
esvg::render::Point(tmpColor->m_viewPort.first),
|
||||||
false);
|
false);
|
||||||
listSegment.applyMatrix(tmpColor->m_matrix);
|
listSegment.applyMatrix(tmpColor->m_matrix);
|
||||||
@ -124,9 +124,9 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
false);
|
false);
|
||||||
/*
|
/*
|
||||||
mat2x3 m_matrix;
|
mat2x3 m_matrix;
|
||||||
etk::Pair<vec2, vec2> m_viewPort;
|
etk::Pair<Vector2f, Vector2f> m_viewPort;
|
||||||
vec2 m_pos1;
|
Vector2f m_pos1;
|
||||||
vec2 m_pos2;
|
Vector2f m_pos2;
|
||||||
*/
|
*/
|
||||||
addDebugSegment(listSegment);
|
addDebugSegment(listSegment);
|
||||||
}
|
}
|
||||||
@ -138,11 +138,11 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
if (m_visualDebug == false) {
|
if (m_visualDebug == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ivec2 dynamicSize = m_size * m_factor;
|
Vector2i dynamicSize = m_size * m_factor;
|
||||||
// for each lines:
|
// for each lines:
|
||||||
for (int32_t yyy=0; yyy<dynamicSize.y(); ++yyy) {
|
for (int32_t yyy=0; yyy<dynamicSize.y(); ++yyy) {
|
||||||
// Reduce the number of lines in the subsampling parsing:
|
// Reduce the number of lines in the subsampling parsing:
|
||||||
etk::Vector<esvg::render::Segment> availlableSegmentPixel;
|
List<esvg::render::Segment> availlableSegmentPixel;
|
||||||
for (auto &it : _listSegment.m_data) {
|
for (auto &it : _listSegment.m_data) {
|
||||||
if ( it.p0.y() * m_factor <= float(yyy+1)
|
if ( it.p0.y() * m_factor <= float(yyy+1)
|
||||||
&& it.p1.y() * m_factor >= float(yyy)) {
|
&& it.p1.y() * m_factor >= float(yyy)) {
|
||||||
@ -151,7 +151,7 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
}
|
}
|
||||||
//find all the segment that cross the middle of the line of the center of the pixel line:
|
//find all the segment that cross the middle of the line of the center of the pixel line:
|
||||||
float subSamplingCenterPos = yyy + 0.5f;
|
float subSamplingCenterPos = yyy + 0.5f;
|
||||||
etk::Vector<esvg::render::Segment> availlableSegment;
|
List<esvg::render::Segment> availlableSegment;
|
||||||
// find in the subList ...
|
// find in the subList ...
|
||||||
for (auto &it : availlableSegmentPixel) {
|
for (auto &it : availlableSegmentPixel) {
|
||||||
if ( it.p0.y() * m_factor <= subSamplingCenterPos
|
if ( it.p0.y() * m_factor <= subSamplingCenterPos
|
||||||
@ -160,9 +160,9 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// x position, angle
|
// x position, angle
|
||||||
etk::Vector<etk::Pair<float, float>> listPosition;
|
List<etk::Pair<float, float>> listPosition;
|
||||||
for (auto &it : availlableSegment) {
|
for (auto &it : availlableSegment) {
|
||||||
vec2 delta = it.p0 * m_factor - it.p1 * m_factor;
|
Vector2f delta = it.p0 * m_factor - it.p1 * m_factor;
|
||||||
// x = coefficent*y+bbb;
|
// x = coefficent*y+bbb;
|
||||||
float coefficient = delta.x()/delta.y();
|
float coefficient = delta.x()/delta.y();
|
||||||
float bbb = it.p0.x() * m_factor - coefficient*it.p0.y() * m_factor;
|
float bbb = it.p0.x() * m_factor - coefficient*it.p0.y() * m_factor;
|
||||||
@ -182,7 +182,7 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
// for each colomn:
|
// for each colomn:
|
||||||
for (int32_t xxx=0; xxx<dynamicSize.x(); ++xxx) {
|
for (int32_t xxx=0; xxx<dynamicSize.x(); ++xxx) {
|
||||||
// Reduce the number of lines in the subsampling parsing:
|
// Reduce the number of lines in the subsampling parsing:
|
||||||
etk::Vector<esvg::render::Segment> availlableSegmentPixel;
|
List<esvg::render::Segment> availlableSegmentPixel;
|
||||||
for (auto &it : _listSegment.m_data) {
|
for (auto &it : _listSegment.m_data) {
|
||||||
if ( ( it.p0.x() * m_factor <= float(xxx+1)
|
if ( ( it.p0.x() * m_factor <= float(xxx+1)
|
||||||
&& it.p1.x() * m_factor >= float(xxx) )
|
&& it.p1.x() * m_factor >= float(xxx) )
|
||||||
@ -193,7 +193,7 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
}
|
}
|
||||||
//find all the segment that cross the middle of the line of the center of the pixel line:
|
//find all the segment that cross the middle of the line of the center of the pixel line:
|
||||||
float subSamplingCenterPos = xxx + 0.5f;
|
float subSamplingCenterPos = xxx + 0.5f;
|
||||||
etk::Vector<esvg::render::Segment> availlableSegment;
|
List<esvg::render::Segment> availlableSegment;
|
||||||
// find in the subList ...
|
// find in the subList ...
|
||||||
for (auto &it : availlableSegmentPixel) {
|
for (auto &it : availlableSegmentPixel) {
|
||||||
if ( ( it.p0.x() * m_factor <= subSamplingCenterPos
|
if ( ( it.p0.x() * m_factor <= subSamplingCenterPos
|
||||||
@ -204,9 +204,9 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// x position, angle
|
// x position, angle
|
||||||
etk::Vector<etk::Pair<float, float>> listPosition;
|
List<etk::Pair<float, float>> listPosition;
|
||||||
for (auto &it : availlableSegment) {
|
for (auto &it : availlableSegment) {
|
||||||
vec2 delta = it.p0 * m_factor - it.p1 * m_factor;
|
Vector2f delta = it.p0 * m_factor - it.p1 * m_factor;
|
||||||
// x = coefficent*y+bbb;
|
// x = coefficent*y+bbb;
|
||||||
if (delta.x() == 0) {
|
if (delta.x() == 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -249,7 +249,7 @@ void esvg::Renderer::writePPM(const etk::Uri& _uri) {
|
|||||||
sizeX *= m_factor;
|
sizeX *= m_factor;
|
||||||
sizeY *= m_factor;
|
sizeY *= m_factor;
|
||||||
#endif
|
#endif
|
||||||
Log.debug("Generate ppm : " << m_size << " debug size=" << ivec2(sizeX,sizeY));
|
Log.debug("Generate ppm : " << m_size << " debug size=" << Vector2i(sizeX,sizeY));
|
||||||
char tmpValue[1024];
|
char tmpValue[1024];
|
||||||
sprintf(tmpValue, "P6 %d %d 255 ", sizeX, sizeY);
|
sprintf(tmpValue, "P6 %d %d 255 ", sizeX, sizeY);
|
||||||
fileIo->write(tmpValue,1,sizeof(tmpValue));
|
fileIo->write(tmpValue,1,sizeof(tmpValue));
|
||||||
@ -380,7 +380,7 @@ void esvg::Renderer::writeBMP(const etk::Uri& _uri) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Renderer::setSize(const ivec2& _size) {
|
void esvg::Renderer::setSize(const Vector2i& _size) {
|
||||||
m_size = _size;
|
m_size = _size;
|
||||||
m_buffer.resize(m_size.x() * m_size.y()
|
m_buffer.resize(m_size.x() * m_size.y()
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@ -389,11 +389,11 @@ void esvg::Renderer::setSize(const ivec2& _size) {
|
|||||||
, etk::color::none);
|
, etk::color::none);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ivec2& esvg::Renderer::getSize() const {
|
const Vector2i& esvg::Renderer::getSize() const {
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Vector<etk::Color<float,4>> esvg::Renderer::getData() {
|
List<etk::Color<float,4>> esvg::Renderer::getData() {
|
||||||
return m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,17 +21,17 @@ namespace esvg {
|
|||||||
int32_t m_factor;
|
int32_t m_factor;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
Renderer(const ivec2& _size, esvg::Document* _document, bool _visualDebug=false);
|
Renderer(const Vector2i& _size, esvg::Document* _document, bool _visualDebug=false);
|
||||||
~Renderer();
|
~Renderer();
|
||||||
protected:
|
protected:
|
||||||
ivec2 m_size;
|
Vector2i m_size;
|
||||||
public:
|
public:
|
||||||
void setSize(const ivec2& _size);
|
void setSize(const Vector2i& _size);
|
||||||
const ivec2& getSize() const;
|
const Vector2i& getSize() const;
|
||||||
protected:
|
protected:
|
||||||
etk::Vector<etk::Color<float,4>> m_buffer;
|
List<etk::Color<float,4>> m_buffer;
|
||||||
public:
|
public:
|
||||||
etk::Vector<etk::Color<float,4>> getData();
|
List<etk::Color<float,4>> getData();
|
||||||
protected:
|
protected:
|
||||||
int32_t m_interpolationRecurtionMax;
|
int32_t m_interpolationRecurtionMax;
|
||||||
public:
|
public:
|
||||||
@ -60,7 +60,7 @@ namespace esvg {
|
|||||||
float _opacity);
|
float _opacity);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void addDebugSegment(const esvg::render::SegmentList& _listSegment);
|
void addDebugSegment(const esvg::render::SegmentList& _listSegment);
|
||||||
void addDebug(const etk::Vector<etk::Pair<vec2,vec2>>& _info);
|
void addDebug(const List<etk::Pair<Vector2f,Vector2f>>& _info);
|
||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
esvg::Document* m_document;
|
esvg::Document* m_document;
|
||||||
|
@ -15,7 +15,7 @@ esvg::Text::~Text() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Text::parse(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
bool esvg::Text::parse(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax) {
|
||||||
_sizeMax.setValue(0,0);
|
_sizeMax.setValue(0,0);
|
||||||
Log.error("NOT IMPLEMENTED");
|
Log.error("NOT IMPLEMENTED");
|
||||||
return false;
|
return false;
|
||||||
|
@ -12,7 +12,7 @@ namespace esvg {
|
|||||||
public:
|
public:
|
||||||
Text(PaintState _parentPaintState);
|
Text(PaintState _parentPaintState);
|
||||||
~Text();
|
~Text();
|
||||||
bool parse(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
bool parse(const exml::Element& _element, mat2x3& _parentTrans, Vector2f& _sizeMax);
|
||||||
void display(int32_t _spacing) override;
|
void display(int32_t _spacing) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,8 @@ void esvg::Document::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int3
|
|||||||
void esvg::Document::generateAnImage(const etk::Uri& _uri, bool _visualDebug) {
|
void esvg::Document::generateAnImage(const etk::Uri& _uri, bool _visualDebug) {
|
||||||
generateAnImage(m_size, _uri, _visualDebug);
|
generateAnImage(m_size, _uri, _visualDebug);
|
||||||
}
|
}
|
||||||
void esvg::Document::generateAnImage(const ivec2& _size, const etk::Uri& _uri, bool _visualDebug) {
|
void esvg::Document::generateAnImage(const Vector2i& _size, const etk::Uri& _uri, bool _visualDebug) {
|
||||||
ivec2 sizeRender = _size;
|
Vector2i sizeRender = _size;
|
||||||
if (sizeRender.x() <= 0) {
|
if (sizeRender.x() <= 0) {
|
||||||
sizeRender.setX(m_size.x());
|
sizeRender.setX(m_size.x());
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ void esvg::Document::generateAnImage(const ivec2& _size, const etk::Uri& _uri, b
|
|||||||
ememory::SharedPtr<esvg::Renderer> renderedElement = ememory::makeShared<esvg::Renderer>(sizeRender, this, _visualDebug);
|
ememory::SharedPtr<esvg::Renderer> renderedElement = ememory::makeShared<esvg::Renderer>(sizeRender, this, _visualDebug);
|
||||||
// create the first element matrix modification ...
|
// create the first element matrix modification ...
|
||||||
mat2x3 basicTrans;
|
mat2x3 basicTrans;
|
||||||
basicTrans *= etk::mat2x3Scale(vec2(sizeRender.x()/m_size.x(), sizeRender.y()/m_size.y()));
|
basicTrans *= etk::mat2x3Scale(Vector2f(sizeRender.x()/m_size.x(), sizeRender.y()/m_size.y()));
|
||||||
|
|
||||||
draw(*renderedElement, basicTrans);
|
draw(*renderedElement, basicTrans);
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void esvg::Document::generateAnImage(const ivec2& _size, const etk::Uri& _uri, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::Vector<etk::Color<float,4>> esvg::Document::renderImageFloatRGBA(ivec2& _size) {
|
List<etk::Color<float,4>> esvg::Document::renderImageFloatRGBA(Vector2i& _size) {
|
||||||
if (_size.x() <= 0) {
|
if (_size.x() <= 0) {
|
||||||
_size.setX(m_size.x());
|
_size.setX(m_size.x());
|
||||||
}
|
}
|
||||||
@ -99,17 +99,17 @@ etk::Vector<etk::Color<float,4>> esvg::Document::renderImageFloatRGBA(ivec2& _si
|
|||||||
ememory::SharedPtr<esvg::Renderer> renderedElement = ememory::makeShared<esvg::Renderer>(_size, this);
|
ememory::SharedPtr<esvg::Renderer> renderedElement = ememory::makeShared<esvg::Renderer>(_size, this);
|
||||||
// create the first element matrix modification ...
|
// create the first element matrix modification ...
|
||||||
mat2x3 basicTrans;
|
mat2x3 basicTrans;
|
||||||
basicTrans *= etk::mat2x3Scale(vec2(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
basicTrans *= etk::mat2x3Scale(Vector2f(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
||||||
draw(*renderedElement, basicTrans);
|
draw(*renderedElement, basicTrans);
|
||||||
|
|
||||||
// direct return the generated data ...
|
// direct return the generated data ...
|
||||||
return renderedElement->getData();
|
return renderedElement->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Vector<etk::Color<float,3>> esvg::Document::renderImageFloatRGB(ivec2& _size) {
|
List<etk::Color<float,3>> esvg::Document::renderImageFloatRGB(Vector2i& _size) {
|
||||||
etk::Vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
List<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||||
// Reduce scope:
|
// Reduce scope:
|
||||||
etk::Vector<etk::Color<float,3>> out;
|
List<etk::Color<float,3>> out;
|
||||||
out.resize(data.size());
|
out.resize(data.size());
|
||||||
for (size_t iii=0; iii<data.size(); ++iii) {
|
for (size_t iii=0; iii<data.size(); ++iii) {
|
||||||
out[iii] = data[iii];
|
out[iii] = data[iii];
|
||||||
@ -117,10 +117,10 @@ etk::Vector<etk::Color<float,3>> esvg::Document::renderImageFloatRGB(ivec2& _siz
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Vector<etk::Color<uint8_t,4>> esvg::Document::renderImageU8RGBA(ivec2& _size) {
|
List<etk::Color<uint8_t,4>> esvg::Document::renderImageU8RGBA(Vector2i& _size) {
|
||||||
etk::Vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
List<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||||
// Reduce scope:
|
// Reduce scope:
|
||||||
etk::Vector<etk::Color<uint8_t,4>> out;
|
List<etk::Color<uint8_t,4>> out;
|
||||||
out.resize(data.size());
|
out.resize(data.size());
|
||||||
for (size_t iii=0; iii<data.size(); ++iii) {
|
for (size_t iii=0; iii<data.size(); ++iii) {
|
||||||
out[iii] = data[iii];
|
out[iii] = data[iii];
|
||||||
@ -128,10 +128,10 @@ etk::Vector<etk::Color<uint8_t,4>> esvg::Document::renderImageU8RGBA(ivec2& _siz
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Vector<etk::Color<uint8_t,3>> esvg::Document::renderImageU8RGB(ivec2& _size) {
|
List<etk::Color<uint8_t,3>> esvg::Document::renderImageU8RGB(Vector2i& _size) {
|
||||||
etk::Vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
List<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||||
// Reduce scope:
|
// Reduce scope:
|
||||||
etk::Vector<etk::Color<uint8_t,3>> out;
|
List<etk::Color<uint8_t,3>> out;
|
||||||
out.resize(data.size());
|
out.resize(data.size());
|
||||||
for (size_t iii=0; iii<data.size(); ++iii) {
|
for (size_t iii=0; iii<data.size(); ++iii) {
|
||||||
out[iii] = data[iii];
|
out[iii] = data[iii];
|
||||||
@ -202,7 +202,7 @@ bool esvg::Document::load(const etk::Uri& _uri) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool esvg::Document::store(const etk::Uri& _uri) {
|
bool esvg::Document::store(const etk::Uri& _uri) {
|
||||||
ESVG_TODO("not implemented store in SVG...");
|
Log.todo("not implemented store in SVG...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,9 +217,9 @@ bool esvg::Document::cleanStyleProperty(const exml::Element& _root) {
|
|||||||
if (child.attributes.exist("style") == true) {
|
if (child.attributes.exist("style") == true) {
|
||||||
etk::String content = child.attributes["style"];
|
etk::String content = child.attributes["style"];
|
||||||
if (content.size() != 0) {
|
if (content.size() != 0) {
|
||||||
etk::Vector<etk::String> listStyle = etk::split(content, ';');
|
List<etk::String> listStyle = etk::split(content, ';');
|
||||||
for (auto &it : listStyle) {
|
for (auto &it : listStyle) {
|
||||||
etk::Vector<etk::String> value = etk::split(it, ':');
|
List<etk::String> value = etk::split(it, ':');
|
||||||
if (value.size() != 2) {
|
if (value.size() != 2) {
|
||||||
Log.error("parsing style with a wrong patern : " << it << " missing ':'");
|
Log.error("parsing style with a wrong patern : " << it << " missing ':'");
|
||||||
continue;
|
continue;
|
||||||
@ -241,7 +241,7 @@ bool esvg::Document::parseXMLData(const exml::Element& _root, bool _isReference)
|
|||||||
// get the svg version :
|
// get the svg version :
|
||||||
m_version = _root.attributes["version"];
|
m_version = _root.attributes["version"];
|
||||||
// parse ...
|
// parse ...
|
||||||
vec2 pos(0,0);
|
Vector2f pos(0,0);
|
||||||
if (_isReference == false) {
|
if (_isReference == false) {
|
||||||
parseTransform(_root);
|
parseTransform(_root);
|
||||||
parsePosition(_root, pos, m_size);
|
parsePosition(_root, pos, m_size);
|
||||||
@ -250,8 +250,8 @@ bool esvg::Document::parseXMLData(const exml::Element& _root, bool _isReference)
|
|||||||
} else {
|
} else {
|
||||||
Log.verbose("Parse Reference section ... (no attibute)");
|
Log.verbose("Parse Reference section ... (no attibute)");
|
||||||
}
|
}
|
||||||
vec2 maxSize(0,0);
|
Vector2f maxSize(0,0);
|
||||||
vec2 size(0,0);
|
Vector2f size(0,0);
|
||||||
// parse all sub node:
|
// parse all sub node:
|
||||||
for(auto it : _root.nodes) {
|
for(auto it : _root.nodes) {
|
||||||
exml::Element child = it.toElement();
|
exml::Element child = it.toElement();
|
||||||
@ -369,8 +369,8 @@ ememory::SharedPtr<esvg::Base> esvg::Document::getReference(const etk::String& _
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Vector<etk::Vector<vec2>> esvg::Document::getLines(vec2 _size) {
|
List<etk::Vector<Vector2f>> esvg::Document::getLines(Vector2f _size) {
|
||||||
etk::Vector<etk::Vector<vec2>> out;
|
List<etk::Vector<Vector2f>> out;
|
||||||
if (_size.x() <= 0) {
|
if (_size.x() <= 0) {
|
||||||
_size.setX(m_size.x());
|
_size.setX(m_size.x());
|
||||||
}
|
}
|
||||||
@ -380,13 +380,13 @@ etk::Vector<etk::Vector<vec2>> esvg::Document::getLines(vec2 _size) {
|
|||||||
Log.debug("lineification size " << _size);
|
Log.debug("lineification size " << _size);
|
||||||
// create the first element matrix modification ...
|
// create the first element matrix modification ...
|
||||||
mat2x3 basicTrans;
|
mat2x3 basicTrans;
|
||||||
basicTrans *= etk::mat2x3Scale(vec2(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
basicTrans *= etk::mat2x3Scale(Vector2f(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
||||||
drawShapePoints(out, 10, 0.25f, basicTrans);
|
drawShapePoints(out, 10, 0.25f, basicTrans);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::Document::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void esvg::Document::drawShapePoints(List<etk::Vector<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -22,9 +22,9 @@ namespace esvg {
|
|||||||
bool m_loadOK;
|
bool m_loadOK;
|
||||||
etk::String m_version;
|
etk::String m_version;
|
||||||
etk::String m_title;
|
etk::String m_title;
|
||||||
etk::Vector<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub-element list
|
List<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub-element list
|
||||||
etk::Vector<ememory::SharedPtr<esvg::Base>> m_refList; //!< reference elements ...
|
List<ememory::SharedPtr<esvg::Base>> m_refList; //!< reference elements ...
|
||||||
vec2 m_size;
|
Vector2f m_size;
|
||||||
public:
|
public:
|
||||||
Document();
|
Document();
|
||||||
~Document();
|
~Document();
|
||||||
@ -73,29 +73,29 @@ namespace esvg {
|
|||||||
void displayDebug();
|
void displayDebug();
|
||||||
// TODO: remove this fucntion : use generic function ...
|
// TODO: remove this fucntion : use generic function ...
|
||||||
void generateAnImage(const etk::Uri& _uri, bool _visualDebug=false);
|
void generateAnImage(const etk::Uri& _uri, bool _visualDebug=false);
|
||||||
void generateAnImage(const ivec2& _size, const etk::Uri& _uri, bool _visualDebug=false);
|
void generateAnImage(const Vector2i& _size, const etk::Uri& _uri, bool _visualDebug=false);
|
||||||
/**
|
/**
|
||||||
* @brief Generate Image in a specific format.
|
* @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
|
* @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)
|
* @return Vector of the data used to display (simple vector: generic to transmit)
|
||||||
*/
|
*/
|
||||||
etk::Vector<etk::Color<float,4>> renderImageFloatRGBA(ivec2& _size);
|
List<etk::Color<float,4>> renderImageFloatRGBA(Vector2i& _size);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::Vector<etk::Color<float,3>> renderImageFloatRGB(ivec2& _size);
|
List<etk::Color<float,3>> renderImageFloatRGB(Vector2i& _size);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::Vector<etk::Color<uint8_t,4>> renderImageU8RGBA(ivec2& _size);
|
List<etk::Color<uint8_t,4>> renderImageU8RGBA(Vector2i& _size);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::Vector<etk::Color<uint8_t,3>> renderImageU8RGB(ivec2& _size);
|
List<etk::Color<uint8_t,3>> renderImageU8RGB(Vector2i& _size);
|
||||||
etk::Vector<etk::Vector<vec2>> getLines(vec2 _size=vec2(256,256));
|
List<List<Vector2f>> getLines(Vector2f _size=Vector2f(256,256));
|
||||||
protected:
|
protected:
|
||||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level=0) override;
|
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level=0) override;
|
||||||
public:
|
public:
|
||||||
vec2 getDefinedSize() {
|
Vector2f getDefinedSize() {
|
||||||
return m_size;
|
return m_size;
|
||||||
};
|
};
|
||||||
ememory::SharedPtr<esvg::Base> getReference(const etk::String& _name);
|
ememory::SharedPtr<esvg::Base> getReference(const etk::String& _name);
|
||||||
protected:
|
protected:
|
||||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
void drawShapePoints(List<List<Vector2f>>& _out,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
mat2x3& _basicTrans,
|
mat2x3& _basicTrans,
|
||||||
|
@ -14,19 +14,19 @@ esvg::render::DynamicColorSpecial::DynamicColorSpecial(const etk::String& _link,
|
|||||||
m_linear(true),
|
m_linear(true),
|
||||||
m_colorName(_link),
|
m_colorName(_link),
|
||||||
m_matrix(_mtx),
|
m_matrix(_mtx),
|
||||||
m_viewPort(vec2(9999999999.0,9999999999.0),vec2(-9999999999.0,-9999999999.0)) {
|
m_viewPort(Vector2f(9999999999.0,9999999999.0),Vector2f(-9999999999.0,-9999999999.0)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::DynamicColorSpecial::setViewPort(const etk::Pair<vec2, vec2>& _viewPort) {
|
void esvg::render::DynamicColorSpecial::setViewPort(const etk::Pair<Vector2f, Vector2f>& _viewPort) {
|
||||||
m_viewPort = _viewPort;
|
m_viewPort = _viewPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static vec2 getIntersect(const vec2& _point1,
|
static Vector2f getIntersect(const Vector2f& _point1,
|
||||||
const vec2& _vect1,
|
const Vector2f& _vect1,
|
||||||
const vec2& _point2,
|
const Vector2f& _point2,
|
||||||
const vec2& _vect2) {
|
const Vector2f& _vect2) {
|
||||||
float diviseur = _vect1.x() * _vect2.y() - _vect1.y() * _vect2.x();
|
float diviseur = _vect1.x() * _vect2.y() - _vect1.y() * _vect2.x();
|
||||||
if(diviseur != 0.0f) {
|
if(diviseur != 0.0f) {
|
||||||
float mmm = ( _vect1.x() * _point1.y()
|
float mmm = ( _vect1.x() * _point1.y()
|
||||||
@ -34,13 +34,13 @@ static vec2 getIntersect(const vec2& _point1,
|
|||||||
- _vect1.y() * _point1.x()
|
- _vect1.y() * _point1.x()
|
||||||
+ _vect1.y() * _point2.x()
|
+ _vect1.y() * _point2.x()
|
||||||
) / diviseur;
|
) / diviseur;
|
||||||
return vec2(_point2 + _vect2 * mmm);
|
return Vector2f(_point2 + _vect2 * mmm);
|
||||||
}
|
}
|
||||||
Log.error("Get divider / 0.0f");
|
Log.error("Get divider / 0.0f");
|
||||||
return _point2;
|
return _point2;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<float,4> esvg::render::DynamicColorSpecial::getColor(const ivec2& _pos) const {
|
etk::Color<float,4> esvg::render::DynamicColorSpecial::getColor(const Vector2i& _pos) const {
|
||||||
if (m_data.size() < 2) {
|
if (m_data.size() < 2) {
|
||||||
return etk::color::purple;
|
return etk::color::purple;
|
||||||
}
|
}
|
||||||
@ -52,15 +52,15 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColor(const ivec2& _po
|
|||||||
return etk::color::purple;
|
return etk::color::purple;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const ivec2& _pos) const {
|
etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const Vector2i& _pos) const {
|
||||||
float ratio = 0.0f;
|
float ratio = 0.0f;
|
||||||
if (m_unit == gradientUnits_userSpaceOnUse) {
|
if (m_unit == gradientUnits_userSpaceOnUse) {
|
||||||
vec2 vectorBase = m_pos2 - m_pos1;
|
Vector2f vectorBase = m_pos2 - m_pos1;
|
||||||
vec2 vectorOrtho(vectorBase.y(), -vectorBase.x());
|
Vector2f vectorOrtho(vectorBase.y(), -vectorBase.x());
|
||||||
vec2 intersec = getIntersect(m_pos1, vectorBase,
|
Vector2f intersec = getIntersect(m_pos1, vectorBase,
|
||||||
vec2(_pos.x(), _pos.y()), vectorOrtho);
|
Vector2f(_pos.x(), _pos.y()), vectorOrtho);
|
||||||
float baseSize = vectorBase.length();
|
float baseSize = vectorBase.length();
|
||||||
vec2 vectorBaseDraw = intersec - m_pos1;
|
Vector2f vectorBaseDraw = intersec - m_pos1;
|
||||||
float baseDraw = vectorBaseDraw.length();
|
float baseDraw = vectorBaseDraw.length();
|
||||||
ratio = baseDraw / baseSize;
|
ratio = baseDraw / baseSize;
|
||||||
switch(m_spread) {
|
switch(m_spread) {
|
||||||
@ -91,12 +91,12 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const ivec
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
||||||
vec2 intersecX = getIntersect(m_pos1, m_axeX,
|
Vector2f intersecX = getIntersect(m_pos1, m_axeX,
|
||||||
vec2(_pos.x(), _pos.y()), m_axeY);
|
Vector2f(_pos.x(), _pos.y()), m_axeY);
|
||||||
vec2 intersecY = getIntersect(m_pos1, m_axeY,
|
Vector2f intersecY = getIntersect(m_pos1, m_axeY,
|
||||||
vec2(_pos.x(), _pos.y()), m_axeX);
|
Vector2f(_pos.x(), _pos.y()), m_axeX);
|
||||||
vec2 vectorBaseDrawX = intersecX - m_pos1;
|
Vector2f vectorBaseDrawX = intersecX - m_pos1;
|
||||||
vec2 vectorBaseDrawY = intersecY - m_pos1;
|
Vector2f vectorBaseDrawY = intersecY - m_pos1;
|
||||||
float baseDrawX = vectorBaseDrawX.length();
|
float baseDrawX = vectorBaseDrawX.length();
|
||||||
float baseDrawY = vectorBaseDrawY.length();
|
float baseDrawY = vectorBaseDrawY.length();
|
||||||
if (m_axeX.dot(vectorBaseDrawX) < 0) {
|
if (m_axeX.dot(vectorBaseDrawX) < 0) {
|
||||||
@ -162,28 +162,28 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const ivec
|
|||||||
}
|
}
|
||||||
return etk::color::green;
|
return etk::color::green;
|
||||||
}
|
}
|
||||||
static etk::Pair<vec2,vec2> intersectLineToCircle(const vec2& _pos1,
|
static etk::Pair<Vector2f,Vector2f> intersectLineToCircle(const Vector2f& _pos1,
|
||||||
const vec2& _pos2,
|
const Vector2f& _pos2,
|
||||||
const vec2& _center = vec2(0.0f, 0.0f),
|
const Vector2f& _center = Vector2f(0.0f, 0.0f),
|
||||||
float _radius = 1.0f) {
|
float _radius = 1.0f) {
|
||||||
vec2 v1;
|
Vector2f v1;
|
||||||
vec2 v2;
|
Vector2f v2;
|
||||||
//vector2D from point 1 to point 2
|
//vector2D from point 1 to point 2
|
||||||
v1 = _pos2 - _pos1;
|
v1 = _pos2 - _pos1;
|
||||||
//vector2D from point 1 to the circle's center
|
//vector2D from point 1 to the circle's center
|
||||||
v2 = _center - _pos1;
|
v2 = _center - _pos1;
|
||||||
|
|
||||||
float dot = v1.dot(v2);
|
float dot = v1.dot(v2);
|
||||||
vec2 proj1 = vec2(((dot / (v1.length2())) * v1.x()),
|
Vector2f proj1 = Vector2f(((dot / (v1.length2())) * v1.x()),
|
||||||
((dot / (v1.length2())) * v1.y()));
|
((dot / (v1.length2())) * v1.y()));
|
||||||
vec2 midpt = _pos1 + proj1;
|
Vector2f midpt = _pos1 + proj1;
|
||||||
|
|
||||||
float distToCenter = (midpt - _center).length2();
|
float distToCenter = (midpt - _center).length2();
|
||||||
if (distToCenter > _radius * _radius) {
|
if (distToCenter > _radius * _radius) {
|
||||||
return etk::Pair<vec2,vec2>(vec2(0.0,0.0), vec2(0.0,0.0));
|
return etk::Pair<Vector2f,Vector2f>(Vector2f(0.0,0.0), Vector2f(0.0,0.0));
|
||||||
}
|
}
|
||||||
if (distToCenter == _radius * _radius) {
|
if (distToCenter == _radius * _radius) {
|
||||||
return etk::Pair<vec2,vec2>(midpt, midpt);
|
return etk::Pair<Vector2f,Vector2f>(midpt, midpt);
|
||||||
}
|
}
|
||||||
float distToIntersection;
|
float distToIntersection;
|
||||||
if (distToCenter == 0.0f) {
|
if (distToCenter == 0.0f) {
|
||||||
@ -200,27 +200,27 @@ static etk::Pair<vec2,vec2> intersectLineToCircle(const vec2& _pos1,
|
|||||||
// normalize...
|
// normalize...
|
||||||
v1.safeNormalize();
|
v1.safeNormalize();
|
||||||
v1 *= distToIntersection;
|
v1 *= distToIntersection;
|
||||||
return etk::Pair<vec2,vec2>(midpt + v1, midpt - v1);
|
return etk::Pair<Vector2f,Vector2f>(midpt + v1, midpt - v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorRadial(const ivec2& _pos) const {
|
etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorRadial(const Vector2i& _pos) const {
|
||||||
float ratio = 0.0f;
|
float ratio = 0.0f;
|
||||||
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object)..
|
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object)..
|
||||||
vec2 intersecX = getIntersect(m_pos1, m_axeX,
|
Vector2f intersecX = getIntersect(m_pos1, m_axeX,
|
||||||
vec2(_pos.x(), _pos.y()), m_axeY);
|
Vector2f(_pos.x(), _pos.y()), m_axeY);
|
||||||
vec2 intersecY = getIntersect(m_pos1, m_axeY,
|
Vector2f intersecY = getIntersect(m_pos1, m_axeY,
|
||||||
vec2(_pos.x(), _pos.y()), m_axeX);
|
Vector2f(_pos.x(), _pos.y()), m_axeX);
|
||||||
vec2 vectorBaseDrawX = intersecX - m_pos1;
|
Vector2f vectorBaseDrawX = intersecX - m_pos1;
|
||||||
vec2 vectorBaseDrawY = intersecY - m_pos1;
|
Vector2f vectorBaseDrawY = intersecY - m_pos1;
|
||||||
float baseDrawX = vectorBaseDrawX.length();
|
float baseDrawX = vectorBaseDrawX.length();
|
||||||
float baseDrawY = vectorBaseDrawY.length();
|
float baseDrawY = vectorBaseDrawY.length();
|
||||||
// specal case when focal == center (this is faster ...)
|
// specal case when focal == center (this is faster ...)
|
||||||
if (m_centerIsFocal == true) {
|
if (m_centerIsFocal == true) {
|
||||||
ratio = vec2(baseDrawX, baseDrawY).length();
|
ratio = Vector2f(baseDrawX, baseDrawY).length();
|
||||||
if (m_baseSize.x()+m_baseSize.y() != 0.0f) {
|
if (m_baseSize.x()+m_baseSize.y() != 0.0f) {
|
||||||
if ( m_baseSize.x() != 0.0f
|
if ( m_baseSize.x() != 0.0f
|
||||||
&& m_baseSize.y() != 0.0f) {
|
&& m_baseSize.y() != 0.0f) {
|
||||||
ratio = vec2(baseDrawX/m_baseSize.x(), baseDrawY/m_baseSize.y()).length();
|
ratio = Vector2f(baseDrawX/m_baseSize.x(), baseDrawY/m_baseSize.y()).length();
|
||||||
} else if (m_baseSize.x() != 0.0f) {
|
} else if (m_baseSize.x() != 0.0f) {
|
||||||
ratio = baseDrawX/m_baseSize.x();
|
ratio = baseDrawX/m_baseSize.x();
|
||||||
} else {
|
} else {
|
||||||
@ -247,12 +247,12 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorRadial(const ivec
|
|||||||
ratio = 1.0f;
|
ratio = 1.0f;
|
||||||
} else {
|
} else {
|
||||||
float tmpLength = -m_focalLength/m_baseSize.x();
|
float tmpLength = -m_focalLength/m_baseSize.x();
|
||||||
vec2 focalCenter = vec2(tmpLength, 0.0f);
|
Vector2f focalCenter = Vector2f(tmpLength, 0.0f);
|
||||||
vec2 currentPoint = vec2(baseDrawX, baseDrawY);
|
Vector2f currentPoint = Vector2f(baseDrawX, baseDrawY);
|
||||||
if (focalCenter == currentPoint) {
|
if (focalCenter == currentPoint) {
|
||||||
ratio = 0.0f;
|
ratio = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
etk::Pair<vec2,vec2> positions = intersectLineToCircle(focalCenter, currentPoint);
|
etk::Pair<Vector2f,Vector2f> positions = intersectLineToCircle(focalCenter, currentPoint);
|
||||||
float lenghtBase = (currentPoint - focalCenter).length();
|
float lenghtBase = (currentPoint - focalCenter).length();
|
||||||
float lenghtBorder1 = (positions.first - focalCenter).length();
|
float lenghtBorder1 = (positions.first - focalCenter).length();
|
||||||
float lenghtBorder2 = (positions.second - focalCenter).length();
|
float lenghtBorder2 = (positions.second - focalCenter).length();
|
||||||
@ -320,7 +320,7 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
|||||||
m_unit = gradient->m_unit;
|
m_unit = gradient->m_unit;
|
||||||
m_spread = gradient->m_spread;
|
m_spread = gradient->m_spread;
|
||||||
Log.verbose(" viewport = {" << m_viewPort.first << "," << m_viewPort.second << "}");
|
Log.verbose(" viewport = {" << m_viewPort.first << "," << m_viewPort.second << "}");
|
||||||
vec2 size = m_viewPort.second - m_viewPort.first;
|
Vector2f size = m_viewPort.second - m_viewPort.first;
|
||||||
|
|
||||||
esvg::Dimension dimPos1 = gradient->getPosition1();
|
esvg::Dimension dimPos1 = gradient->getPosition1();
|
||||||
m_pos1 = dimPos1.getPixel(size);
|
m_pos1 = dimPos1.getPixel(size);
|
||||||
@ -333,16 +333,16 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
|||||||
m_pos2 += m_viewPort.first;
|
m_pos2 += m_viewPort.first;
|
||||||
}
|
}
|
||||||
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
||||||
vec2 delta = m_pos2 - m_pos1;
|
Vector2f delta = m_pos2 - m_pos1;
|
||||||
if (delta.x() < 0.0f) {
|
if (delta.x() < 0.0f) {
|
||||||
m_axeX = vec2(-1.0f, 0.0f);
|
m_axeX = Vector2f(-1.0f, 0.0f);
|
||||||
} else {
|
} else {
|
||||||
m_axeX = vec2(1.0f, 0.0f);
|
m_axeX = Vector2f(1.0f, 0.0f);
|
||||||
}
|
}
|
||||||
if (delta.y() < 0.0f) {
|
if (delta.y() < 0.0f) {
|
||||||
m_axeY = vec2(0.0f, -1.0f);
|
m_axeY = Vector2f(0.0f, -1.0f);
|
||||||
} else {
|
} else {
|
||||||
m_axeY = vec2(0.0f, 1.0f);
|
m_axeY = Vector2f(0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
// Move the positions ...
|
// Move the positions ...
|
||||||
m_pos1 = m_matrix * m_pos1;
|
m_pos1 = m_matrix * m_pos1;
|
||||||
@ -350,11 +350,11 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
|||||||
m_axeX = m_matrix.applyScaleRotation(m_axeX);
|
m_axeX = m_matrix.applyScaleRotation(m_axeX);
|
||||||
m_axeY = m_matrix.applyScaleRotation(m_axeY);
|
m_axeY = m_matrix.applyScaleRotation(m_axeY);
|
||||||
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
||||||
vec2 intersecX = getIntersect(m_pos1, m_axeX,
|
Vector2f intersecX = getIntersect(m_pos1, m_axeX,
|
||||||
m_pos2, m_axeY);
|
m_pos2, m_axeY);
|
||||||
vec2 intersecY = getIntersect(m_pos1, m_axeY,
|
Vector2f intersecY = getIntersect(m_pos1, m_axeY,
|
||||||
m_pos2, m_axeX);
|
m_pos2, m_axeX);
|
||||||
m_baseSize = vec2((m_pos1 - intersecX).length(),
|
m_baseSize = Vector2f((m_pos1 - intersecX).length(),
|
||||||
(m_pos1 - intersecY).length());
|
(m_pos1 - intersecY).length());
|
||||||
// get all the colors
|
// get all the colors
|
||||||
m_data = gradient->getColors(_document);
|
m_data = gradient->getColors(_document);
|
||||||
@ -370,15 +370,15 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
|||||||
m_unit = gradient->m_unit;
|
m_unit = gradient->m_unit;
|
||||||
m_spread = gradient->m_spread;
|
m_spread = gradient->m_spread;
|
||||||
Log.verbose(" viewport = {" << m_viewPort.first << "," << m_viewPort.second << "}");
|
Log.verbose(" viewport = {" << m_viewPort.first << "," << m_viewPort.second << "}");
|
||||||
vec2 size = m_viewPort.second - m_viewPort.first;
|
Vector2f size = m_viewPort.second - m_viewPort.first;
|
||||||
|
|
||||||
esvg::Dimension dimCenter = gradient->getCenter();
|
esvg::Dimension dimCenter = gradient->getCenter();
|
||||||
vec2 center = dimCenter.getPixel(size);
|
Vector2f center = dimCenter.getPixel(size);
|
||||||
if (dimCenter.getType() == esvg::distance_pourcent) {
|
if (dimCenter.getType() == esvg::distance_pourcent) {
|
||||||
center += m_viewPort.first;
|
center += m_viewPort.first;
|
||||||
}
|
}
|
||||||
esvg::Dimension dimFocal = gradient->getFocal();
|
esvg::Dimension dimFocal = gradient->getFocal();
|
||||||
vec2 focal = dimFocal.getPixel(size);
|
Vector2f focal = dimFocal.getPixel(size);
|
||||||
if (dimFocal.getType() == esvg::distance_pourcent) {
|
if (dimFocal.getType() == esvg::distance_pourcent) {
|
||||||
focal += m_viewPort.first;
|
focal += m_viewPort.first;
|
||||||
}
|
}
|
||||||
@ -389,22 +389,22 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
|||||||
m_pos2.setX(dimRadius.getPixel(size.x()));
|
m_pos2.setX(dimRadius.getPixel(size.x()));
|
||||||
m_pos2.setY(dimRadius.getPixel(size.y()));
|
m_pos2.setY(dimRadius.getPixel(size.y()));
|
||||||
m_pos2 += center;
|
m_pos2 += center;
|
||||||
vec2 delta = center - m_pos2;
|
Vector2f delta = center - m_pos2;
|
||||||
if (delta.x() < 0.0f) {
|
if (delta.x() < 0.0f) {
|
||||||
m_axeX = vec2(-1.0f, 0.0f);
|
m_axeX = Vector2f(-1.0f, 0.0f);
|
||||||
} else {
|
} else {
|
||||||
m_axeX = vec2(1.0f, 0.0f);
|
m_axeX = Vector2f(1.0f, 0.0f);
|
||||||
}
|
}
|
||||||
if (delta.y() < 0.0f) {
|
if (delta.y() < 0.0f) {
|
||||||
m_axeY = vec2(0.0f, -1.0f);
|
m_axeY = Vector2f(0.0f, -1.0f);
|
||||||
} else {
|
} else {
|
||||||
m_axeY = vec2(0.0f, 1.0f);
|
m_axeY = Vector2f(0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
m_pos1 = center;
|
m_pos1 = center;
|
||||||
} else {
|
} else {
|
||||||
m_centerIsFocal = false;
|
m_centerIsFocal = false;
|
||||||
m_axeX = (center - focal).safeNormalize();
|
m_axeX = (center - focal).safeNormalize();
|
||||||
m_axeY = vec2(m_axeX.y(), -m_axeX.x());
|
m_axeY = Vector2f(m_axeX.y(), -m_axeX.x());
|
||||||
|
|
||||||
m_pos2 = m_axeX * dimRadius.getPixel(size.x()) + m_axeY * dimRadius.getPixel(size.y());
|
m_pos2 = m_axeX * dimRadius.getPixel(size.x()) + m_axeY * dimRadius.getPixel(size.y());
|
||||||
m_pos2 += center;
|
m_pos2 += center;
|
||||||
@ -417,11 +417,11 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
|||||||
m_axeX = m_matrix.applyScaleRotation(m_axeX);
|
m_axeX = m_matrix.applyScaleRotation(m_axeX);
|
||||||
m_axeY = m_matrix.applyScaleRotation(m_axeY);
|
m_axeY = m_matrix.applyScaleRotation(m_axeY);
|
||||||
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object..
|
||||||
vec2 intersecX = getIntersect(m_pos1, m_axeX,
|
Vector2f intersecX = getIntersect(m_pos1, m_axeX,
|
||||||
m_pos2, m_axeY);
|
m_pos2, m_axeY);
|
||||||
vec2 intersecY = getIntersect(m_pos1, m_axeY,
|
Vector2f intersecY = getIntersect(m_pos1, m_axeY,
|
||||||
m_pos2, m_axeX);
|
m_pos2, m_axeX);
|
||||||
m_baseSize = vec2((intersecX - m_pos1).length(),
|
m_baseSize = Vector2f((intersecX - m_pos1).length(),
|
||||||
(intersecY - m_pos1).length());
|
(intersecY - m_pos1).length());
|
||||||
if (m_centerIsFocal == false) {
|
if (m_centerIsFocal == false) {
|
||||||
m_focalLength = (center - m_matrix * focal).length();
|
m_focalLength = (center - m_matrix * focal).length();
|
||||||
|
@ -23,9 +23,9 @@ namespace esvg {
|
|||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
}
|
}
|
||||||
virtual ~DynamicColor() {};
|
virtual ~DynamicColor() {};
|
||||||
virtual etk::Color<float,4> getColor(const ivec2& _pos) const = 0;
|
virtual etk::Color<float,4> getColor(const Vector2i& _pos) const = 0;
|
||||||
virtual void generate(esvg::Document* _document) = 0;
|
virtual void generate(esvg::Document* _document) = 0;
|
||||||
virtual void setViewPort(const etk::Pair<vec2, vec2>& _viewPort) = 0;
|
virtual void setViewPort(const etk::Pair<Vector2f, Vector2f>& _viewPort) = 0;
|
||||||
};
|
};
|
||||||
class DynamicColorUni : public esvg::render::DynamicColor {
|
class DynamicColorUni : public esvg::render::DynamicColor {
|
||||||
public:
|
public:
|
||||||
@ -35,13 +35,13 @@ namespace esvg {
|
|||||||
m_color(_color) {
|
m_color(_color) {
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual etk::Color<float,4> getColor(const ivec2& _pos) const {
|
virtual etk::Color<float,4> getColor(const Vector2i& _pos) const {
|
||||||
return m_color;
|
return m_color;
|
||||||
}
|
}
|
||||||
virtual void generate(esvg::Document* _document) {
|
virtual void generate(esvg::Document* _document) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
}
|
}
|
||||||
virtual void setViewPort(const etk::Pair<vec2, vec2>& _viewPort) {
|
virtual void setViewPort(const etk::Pair<Vector2f, Vector2f>& _viewPort) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -52,26 +52,26 @@ namespace esvg {
|
|||||||
esvg::gradientUnits m_unit;
|
esvg::gradientUnits m_unit;
|
||||||
etk::String m_colorName;
|
etk::String m_colorName;
|
||||||
mat2x3 m_matrix;
|
mat2x3 m_matrix;
|
||||||
etk::Pair<vec2, vec2> m_viewPort;
|
etk::Pair<Vector2f, Vector2f> m_viewPort;
|
||||||
vec2 m_pos1; // in radius ==> center
|
Vector2f m_pos1; // in radius ==> center
|
||||||
vec2 m_pos2; // in radius ==> radius end position
|
Vector2f m_pos2; // in radius ==> radius end position
|
||||||
vec2 m_focal; // Specific radius
|
Vector2f m_focal; // Specific radius
|
||||||
vec2 m_axeX;
|
Vector2f m_axeX;
|
||||||
vec2 m_axeY;
|
Vector2f m_axeY;
|
||||||
vec2 m_baseSize;
|
Vector2f m_baseSize;
|
||||||
float m_focalLength;
|
float m_focalLength;
|
||||||
bool m_clipOut;
|
bool m_clipOut;
|
||||||
bool m_centerIsFocal;
|
bool m_centerIsFocal;
|
||||||
etk::Vector<etk::Pair<float, etk::Color<float,4>>> m_data;
|
List<etk::Pair<float, etk::Color<float,4>>> m_data;
|
||||||
public:
|
public:
|
||||||
DynamicColorSpecial(const etk::String& _link, const mat2x3& _mtx);
|
DynamicColorSpecial(const etk::String& _link, const mat2x3& _mtx);
|
||||||
virtual etk::Color<float,4> getColor(const ivec2& _pos) const;
|
virtual etk::Color<float,4> getColor(const Vector2i& _pos) const;
|
||||||
private:
|
private:
|
||||||
etk::Color<float,4> getColorLinear(const ivec2& _pos) const;
|
etk::Color<float,4> getColorLinear(const Vector2i& _pos) const;
|
||||||
etk::Color<float,4> getColorRadial(const ivec2& _pos) const;
|
etk::Color<float,4> getColorRadial(const Vector2i& _pos) const;
|
||||||
public:
|
public:
|
||||||
virtual void generate(esvg::Document* _document);
|
virtual void generate(esvg::Document* _document);
|
||||||
virtual void setViewPort(const etk::Pair<vec2, vec2>& _viewPort);
|
virtual void setViewPort(const etk::Pair<Vector2f, Vector2f>& _viewPort);
|
||||||
};
|
};
|
||||||
|
|
||||||
ememory::SharedPtr<DynamicColor> createColor(etk::Pair<etk::Color<float,4>, etk::String> _color, const mat2x3& _mtx);
|
ememory::SharedPtr<DynamicColor> createColor(etk::Pair<etk::Color<float,4>, etk::String> _color, const mat2x3& _mtx);
|
||||||
|
@ -47,30 +47,30 @@ namespace esvg {
|
|||||||
m_relative = _relative;
|
m_relative = _relative;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
vec2 m_pos;
|
Vector2f m_pos;
|
||||||
public:
|
public:
|
||||||
const vec2& getPos() const {
|
const Vector2f& getPos() const {
|
||||||
return m_pos;
|
return m_pos;
|
||||||
}
|
}
|
||||||
void setPos(const vec2& _val) {
|
void setPos(const Vector2f& _val) {
|
||||||
m_pos = _val;
|
m_pos = _val;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
vec2 m_pos1;
|
Vector2f m_pos1;
|
||||||
public:
|
public:
|
||||||
const vec2& getPos1() const {
|
const Vector2f& getPos1() const {
|
||||||
return m_pos1;
|
return m_pos1;
|
||||||
}
|
}
|
||||||
void setPos1(const vec2& _val) {
|
void setPos1(const Vector2f& _val) {
|
||||||
m_pos1 = _val;
|
m_pos1 = _val;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
vec2 m_pos2;
|
Vector2f m_pos2;
|
||||||
public:
|
public:
|
||||||
const vec2& getPos2() const {
|
const Vector2f& getPos2() const {
|
||||||
return m_pos2;
|
return m_pos2;
|
||||||
}
|
}
|
||||||
void setPos2(const vec2& _val) {
|
void setPos2(const Vector2f& _val) {
|
||||||
m_pos2 = _val;
|
m_pos2 = _val;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <esvg/render/Element.hpp>
|
#include <esvg/render/Element.hpp>
|
||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::ElementBezierCurveTo::ElementBezierCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos):
|
esvg::render::ElementBezierCurveTo::ElementBezierCurveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos):
|
||||||
Element(esvg::render::path_bezierCurveTo, _relative) {
|
Element(esvg::render::path_bezierCurveTo, _relative) {
|
||||||
m_pos = _pos;
|
m_pos = _pos;
|
||||||
m_pos1 = _pos1;
|
m_pos1 = _pos1;
|
||||||
|
@ -13,7 +13,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class ElementBezierCurveTo : public esvg::render::Element {
|
class ElementBezierCurveTo : public esvg::render::Element {
|
||||||
public:
|
public:
|
||||||
ElementBezierCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos);
|
ElementBezierCurveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos);
|
||||||
public:
|
public:
|
||||||
virtual etk::String display() const;
|
virtual etk::String display() const;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <esvg/render/Element.hpp>
|
#include <esvg/render/Element.hpp>
|
||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::ElementBezierSmoothCurveTo::ElementBezierSmoothCurveTo(bool _relative, const vec2& _pos):
|
esvg::render::ElementBezierSmoothCurveTo::ElementBezierSmoothCurveTo(bool _relative, const Vector2f& _pos):
|
||||||
Element(esvg::render::path_bezierSmoothCurveTo, _relative) {
|
Element(esvg::render::path_bezierSmoothCurveTo, _relative) {
|
||||||
m_pos = _pos;
|
m_pos = _pos;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class ElementBezierSmoothCurveTo : public esvg::render::Element {
|
class ElementBezierSmoothCurveTo : public esvg::render::Element {
|
||||||
public:
|
public:
|
||||||
ElementBezierSmoothCurveTo(bool _relative, const vec2& _pos);
|
ElementBezierSmoothCurveTo(bool _relative, const Vector2f& _pos);
|
||||||
public:
|
public:
|
||||||
virtual etk::String display() const;
|
virtual etk::String display() const;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <esvg/render/Element.hpp>
|
#include <esvg/render/Element.hpp>
|
||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::ElementCurveTo::ElementCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos2, const vec2& _pos):
|
esvg::render::ElementCurveTo::ElementCurveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos2, const Vector2f& _pos):
|
||||||
Element(esvg::render::path_curveTo, _relative) {
|
Element(esvg::render::path_curveTo, _relative) {
|
||||||
m_pos = _pos;
|
m_pos = _pos;
|
||||||
m_pos1 = _pos1;
|
m_pos1 = _pos1;
|
||||||
|
@ -12,7 +12,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class ElementCurveTo : public esvg::render::Element {
|
class ElementCurveTo : public esvg::render::Element {
|
||||||
public:
|
public:
|
||||||
ElementCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos2, const vec2& _pos);
|
ElementCurveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos2, const Vector2f& _pos);
|
||||||
public:
|
public:
|
||||||
virtual etk::String display() const;
|
virtual etk::String display() const;
|
||||||
};
|
};
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::ElementElliptic::ElementElliptic(bool _relative,
|
esvg::render::ElementElliptic::ElementElliptic(bool _relative,
|
||||||
const vec2& _radius, // in m_vec1
|
const Vector2f& _radius, // in m_vec1
|
||||||
float _angle,
|
float _angle,
|
||||||
bool _largeArcFlag,
|
bool _largeArcFlag,
|
||||||
bool _sweepFlag,
|
bool _sweepFlag,
|
||||||
const vec2& _pos):
|
const Vector2f& _pos):
|
||||||
Element(esvg::render::path_elliptic, _relative) {
|
Element(esvg::render::path_elliptic, _relative) {
|
||||||
m_pos1 = _radius;
|
m_pos1 = _radius;
|
||||||
m_pos = _pos;
|
m_pos = _pos;
|
||||||
|
@ -18,11 +18,11 @@ namespace esvg {
|
|||||||
bool m_sweepFlag;
|
bool m_sweepFlag;
|
||||||
public:
|
public:
|
||||||
ElementElliptic(bool _relative,
|
ElementElliptic(bool _relative,
|
||||||
const vec2& _radius, // in m_pos1
|
const Vector2f& _radius, // in m_pos1
|
||||||
float _angle,
|
float _angle,
|
||||||
bool _largeArcFlag,
|
bool _largeArcFlag,
|
||||||
bool _sweepFlag,
|
bool _sweepFlag,
|
||||||
const vec2& _pos);
|
const Vector2f& _pos);
|
||||||
public:
|
public:
|
||||||
virtual etk::String display() const;
|
virtual etk::String display() const;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <esvg/render/Element.hpp>
|
#include <esvg/render/Element.hpp>
|
||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::ElementLineTo::ElementLineTo(bool _relative, const vec2& _pos):
|
esvg::render::ElementLineTo::ElementLineTo(bool _relative, const Vector2f& _pos):
|
||||||
Element(esvg::render::path_lineTo, _relative) {
|
Element(esvg::render::path_lineTo, _relative) {
|
||||||
m_pos = _pos;
|
m_pos = _pos;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class ElementLineTo : public esvg::render::Element {
|
class ElementLineTo : public esvg::render::Element {
|
||||||
public:
|
public:
|
||||||
ElementLineTo(bool _relative, const vec2& _pos);
|
ElementLineTo(bool _relative, const Vector2f& _pos);
|
||||||
public:
|
public:
|
||||||
virtual etk::String display() const;
|
virtual etk::String display() const;
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
esvg::render::ElementLineToH::ElementLineToH(bool _relative, float _posX):
|
esvg::render::ElementLineToH::ElementLineToH(bool _relative, float _posX):
|
||||||
Element(esvg::render::path_lineToH, _relative) {
|
Element(esvg::render::path_lineToH, _relative) {
|
||||||
m_pos = vec2(_posX, 0.0f);
|
m_pos = Vector2f(_posX, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
esvg::render::ElementLineToV::ElementLineToV(bool _relative, float _posY):
|
esvg::render::ElementLineToV::ElementLineToV(bool _relative, float _posY):
|
||||||
Element(esvg::render::path_lineToV, _relative) {
|
Element(esvg::render::path_lineToV, _relative) {
|
||||||
m_pos = vec2(0.0f, _posY);
|
m_pos = Vector2f(0.0f, _posY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <esvg/render/Element.hpp>
|
#include <esvg/render/Element.hpp>
|
||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::ElementMoveTo::ElementMoveTo(bool _relative, const vec2& _pos):
|
esvg::render::ElementMoveTo::ElementMoveTo(bool _relative, const Vector2f& _pos):
|
||||||
Element(esvg::render::path_moveTo, _relative) {
|
Element(esvg::render::path_moveTo, _relative) {
|
||||||
m_pos = _pos;
|
m_pos = _pos;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class ElementMoveTo : public esvg::render::Element {
|
class ElementMoveTo : public esvg::render::Element {
|
||||||
public:
|
public:
|
||||||
ElementMoveTo(bool _relative, const vec2& _pos);
|
ElementMoveTo(bool _relative, const Vector2f& _pos);
|
||||||
public:
|
public:
|
||||||
virtual etk::String display() const;
|
virtual etk::String display() const;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <esvg/render/Element.hpp>
|
#include <esvg/render/Element.hpp>
|
||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::ElementSmoothCurveTo::ElementSmoothCurveTo(bool _relative, const vec2& _pos2, const vec2& _pos):
|
esvg::render::ElementSmoothCurveTo::ElementSmoothCurveTo(bool _relative, const Vector2f& _pos2, const Vector2f& _pos):
|
||||||
Element(esvg::render::path_smoothCurveTo, _relative) {
|
Element(esvg::render::path_smoothCurveTo, _relative) {
|
||||||
m_pos = _pos;
|
m_pos = _pos;
|
||||||
m_pos2 = _pos2;
|
m_pos2 = _pos2;
|
||||||
|
@ -13,7 +13,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class ElementSmoothCurveTo : public esvg::render::Element {
|
class ElementSmoothCurveTo : public esvg::render::Element {
|
||||||
public:
|
public:
|
||||||
ElementSmoothCurveTo(bool _relative, const vec2& _pos2, const vec2& _pos);
|
ElementSmoothCurveTo(bool _relative, const Vector2f& _pos2, const Vector2f& _pos);
|
||||||
public:
|
public:
|
||||||
virtual etk::String display() const;
|
virtual etk::String display() const;
|
||||||
};
|
};
|
||||||
|
@ -19,11 +19,11 @@ void esvg::render::Path::close(bool _relative) {
|
|||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementClose>(_relative));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementClose>(_relative));
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Path::moveTo(bool _relative, const vec2& _pos) {
|
void esvg::render::Path::moveTo(bool _relative, const Vector2f& _pos) {
|
||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementMoveTo>(_relative, _pos));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementMoveTo>(_relative, _pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Path::lineTo(bool _relative, const vec2& _pos) {
|
void esvg::render::Path::lineTo(bool _relative, const Vector2f& _pos) {
|
||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementLineTo>(_relative, _pos));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementLineTo>(_relative, _pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,28 +35,28 @@ void esvg::render::Path::lineToV(bool _relative, float _posY) {
|
|||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementLineToV>(_relative, _posY));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementLineToV>(_relative, _posY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Path::curveTo(bool _relative, const vec2& _pos1, const vec2& _pos2, const vec2& _pos) {
|
void esvg::render::Path::curveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos2, const Vector2f& _pos) {
|
||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementCurveTo>(_relative, _pos1, _pos2, _pos));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementCurveTo>(_relative, _pos1, _pos2, _pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Path::smoothCurveTo(bool _relative, const vec2& _pos2, const vec2& _pos) {
|
void esvg::render::Path::smoothCurveTo(bool _relative, const Vector2f& _pos2, const Vector2f& _pos) {
|
||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementSmoothCurveTo>(_relative, _pos2, _pos));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementSmoothCurveTo>(_relative, _pos2, _pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Path::bezierCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos) {
|
void esvg::render::Path::bezierCurveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos) {
|
||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementBezierCurveTo>(_relative, _pos1, _pos));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementBezierCurveTo>(_relative, _pos1, _pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Path::bezierSmoothCurveTo(bool _relative, const vec2& _pos) {
|
void esvg::render::Path::bezierSmoothCurveTo(bool _relative, const Vector2f& _pos) {
|
||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementBezierSmoothCurveTo>(_relative, _pos));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementBezierSmoothCurveTo>(_relative, _pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Path::ellipticTo(bool _relative,
|
void esvg::render::Path::ellipticTo(bool _relative,
|
||||||
const vec2& _radius,
|
const Vector2f& _radius,
|
||||||
float _angle,
|
float _angle,
|
||||||
bool _largeArcFlag,
|
bool _largeArcFlag,
|
||||||
bool _sweepFlag,
|
bool _sweepFlag,
|
||||||
const vec2& _pos) {
|
const Vector2f& _pos) {
|
||||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementElliptic>(_relative, _radius, _angle, _largeArcFlag, _sweepFlag, _pos));
|
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementElliptic>(_relative, _radius, _angle, _largeArcFlag, _sweepFlag, _pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,23 +79,23 @@ void esvg::render::Path::display(int32_t _spacing) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void interpolateCubicBezier(etk::Vector<esvg::render::Point>& _listPoint,
|
void interpolateCubicBezier(List<esvg::render::Point>& _listPoint,
|
||||||
int32_t _recurtionMax,
|
int32_t _recurtionMax,
|
||||||
float _threshold,
|
float _threshold,
|
||||||
vec2 _pos1,
|
Vector2f _pos1,
|
||||||
vec2 _pos2,
|
Vector2f _pos2,
|
||||||
vec2 _pos3,
|
Vector2f _pos3,
|
||||||
vec2 _pos4,
|
Vector2f _pos4,
|
||||||
int32_t _level,
|
int32_t _level,
|
||||||
enum esvg::render::Point::type _type) {
|
enum esvg::render::Point::type _type) {
|
||||||
if (_level > _recurtionMax) {
|
if (_level > _recurtionMax) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vec2 pos12 = (_pos1+_pos2)*0.5f;
|
Vector2f pos12 = (_pos1+_pos2)*0.5f;
|
||||||
vec2 pos23 = (_pos2+_pos3)*0.5f;
|
Vector2f pos23 = (_pos2+_pos3)*0.5f;
|
||||||
vec2 pos34 = (_pos3+_pos4)*0.5f;
|
Vector2f pos34 = (_pos3+_pos4)*0.5f;
|
||||||
|
|
||||||
vec2 delta = _pos4 - _pos1;
|
Vector2f delta = _pos4 - _pos1;
|
||||||
#ifndef __STDCPP_LLVM__
|
#ifndef __STDCPP_LLVM__
|
||||||
float distance2 = etk::abs(((_pos2.x() - _pos4.x()) * delta.y() - (_pos2.y() - _pos4.y()) * delta.x() ));
|
float distance2 = etk::abs(((_pos2.x() - _pos4.x()) * delta.y() - (_pos2.y() - _pos4.y()) * delta.x() ));
|
||||||
float distance3 = etk::abs(((_pos3.x() - _pos4.x()) * delta.y() - (_pos3.y() - _pos4.y()) * delta.x() ));
|
float distance3 = etk::abs(((_pos3.x() - _pos4.x()) * delta.y() - (_pos3.y() - _pos4.y()) * delta.x() ));
|
||||||
@ -108,15 +108,15 @@ void interpolateCubicBezier(etk::Vector<esvg::render::Point>& _listPoint,
|
|||||||
_listPoint.pushBack(esvg::render::Point(_pos4, _type) );
|
_listPoint.pushBack(esvg::render::Point(_pos4, _type) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vec2 pos123 = (pos12+pos23)*0.5f;
|
Vector2f pos123 = (pos12+pos23)*0.5f;
|
||||||
vec2 pos234 = (pos23+pos34)*0.5f;
|
Vector2f pos234 = (pos23+pos34)*0.5f;
|
||||||
vec2 pos1234 = (pos123+pos234)*0.5f;
|
Vector2f pos1234 = (pos123+pos234)*0.5f;
|
||||||
|
|
||||||
interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, _pos1, pos12, pos123, pos1234, _level+1, esvg::render::Point::type::interpolation);
|
interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, _pos1, pos12, pos123, pos1234, _level+1, esvg::render::Point::type::interpolation);
|
||||||
interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, pos1234, pos234, pos34, _pos4, _level+1, _type);
|
interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, pos1234, pos234, pos34, _pos4, _level+1, _type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float vectorAngle(vec2 _uuu, vec2 _vvv) {
|
static float vectorAngle(Vector2f _uuu, Vector2f _vvv) {
|
||||||
_uuu.safeNormalize();
|
_uuu.safeNormalize();
|
||||||
_vvv.safeNormalize();
|
_vvv.safeNormalize();
|
||||||
return atan2(_uuu.cross(_vvv), _uuu.dot(_vvv));
|
return atan2(_uuu.cross(_vvv), _uuu.dot(_vvv));
|
||||||
@ -125,9 +125,9 @@ static float vectorAngle(vec2 _uuu, vec2 _vvv) {
|
|||||||
esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, int32_t _recurtionMax, float _threshold) {
|
esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, int32_t _recurtionMax, float _threshold) {
|
||||||
Log.verbose(spacingDist(_level) << "Generate List Points ... from a path");
|
Log.verbose(spacingDist(_level) << "Generate List Points ... from a path");
|
||||||
esvg::render::PointList out;
|
esvg::render::PointList out;
|
||||||
etk::Vector<esvg::render::Point> tmpListPoint;
|
List<esvg::render::Point> tmpListPoint;
|
||||||
vec2 lastPosition(0.0f, 0.0f);
|
Vector2f lastPosition(0.0f, 0.0f);
|
||||||
vec2 lastAngle(0.0f, 0.0f);
|
Vector2f lastAngle(0.0f, 0.0f);
|
||||||
int32_t lastPointId = -1;
|
int32_t lastPointId = -1;
|
||||||
bool PathStart = false;
|
bool PathStart = false;
|
||||||
// Foreach element, we move in the path:
|
// Foreach element, we move in the path:
|
||||||
@ -147,7 +147,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.clear();
|
tmpListPoint.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastAngle = vec2(0.0f, 0.0f);
|
lastAngle = Vector2f(0.0f, 0.0f);
|
||||||
// nothing alse to do ...
|
// nothing alse to do ...
|
||||||
break;
|
break;
|
||||||
case esvg::render::path_close:
|
case esvg::render::path_close:
|
||||||
@ -158,7 +158,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
// find the previous tart of the path ...
|
// find the previous tart of the path ...
|
||||||
tmpListPoint.front().m_type = esvg::render::Point::type::join;
|
tmpListPoint.front().m_type = esvg::render::Point::type::join;
|
||||||
// Remove the last point if it is the same position...
|
// Remove the last point if it is the same position...
|
||||||
vec2 delta = (tmpListPoint.front().m_pos - tmpListPoint.back().m_pos).absolute();
|
Vector2f delta = (tmpListPoint.front().m_pos - tmpListPoint.back().m_pos).absolute();
|
||||||
if ( delta.x() <= 0.00001
|
if ( delta.x() <= 0.00001
|
||||||
&& delta.y() <= 0.00001) {
|
&& delta.y() <= 0.00001) {
|
||||||
tmpListPoint.popBack();
|
tmpListPoint.popBack();
|
||||||
@ -168,7 +168,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.clear();
|
tmpListPoint.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastAngle = vec2(0.0f, 0.0f);
|
lastAngle = Vector2f(0.0f, 0.0f);
|
||||||
// nothing alse to do ...
|
// nothing alse to do ...
|
||||||
break;
|
break;
|
||||||
case esvg::render::path_moveTo:
|
case esvg::render::path_moveTo:
|
||||||
@ -180,7 +180,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
}
|
}
|
||||||
// create a new one
|
// create a new one
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
lastPosition += it->getPos();
|
lastPosition += it->getPos();
|
||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||||
@ -192,7 +192,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||||
}
|
}
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
lastPosition += it->getPos();
|
lastPosition += it->getPos();
|
||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||||
@ -204,7 +204,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||||
}
|
}
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
lastPosition += it->getPos();
|
lastPosition += it->getPos();
|
||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||||
@ -216,7 +216,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||||
}
|
}
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
lastPosition += it->getPos();
|
lastPosition += it->getPos();
|
||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||||
@ -228,13 +228,13 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
vec2 lastPosStore(lastPosition);
|
Vector2f lastPosStore(lastPosition);
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
vec2 pos1 = lastPosition + it->getPos1();
|
Vector2f pos1 = lastPosition + it->getPos1();
|
||||||
vec2 pos2 = lastPosition + it->getPos2();
|
Vector2f pos2 = lastPosition + it->getPos2();
|
||||||
vec2 pos = lastPosition + it->getPos();
|
Vector2f pos = lastPosition + it->getPos();
|
||||||
interpolateCubicBezier(tmpListPoint,
|
interpolateCubicBezier(tmpListPoint,
|
||||||
_recurtionMax,
|
_recurtionMax,
|
||||||
_threshold,
|
_threshold,
|
||||||
@ -254,14 +254,14 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
vec2 lastPosStore(lastPosition);
|
Vector2f lastPosStore(lastPosition);
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
vec2 pos2 = lastPosition + it->getPos2();
|
Vector2f pos2 = lastPosition + it->getPos2();
|
||||||
vec2 pos = lastPosition + it->getPos();
|
Vector2f pos = lastPosition + it->getPos();
|
||||||
// generate Pos 1
|
// generate Pos 1
|
||||||
vec2 pos1 = lastPosStore*2.0f - lastAngle;
|
Vector2f pos1 = lastPosStore*2.0f - lastAngle;
|
||||||
interpolateCubicBezier(tmpListPoint,
|
interpolateCubicBezier(tmpListPoint,
|
||||||
_recurtionMax,
|
_recurtionMax,
|
||||||
_threshold,
|
_threshold,
|
||||||
@ -281,15 +281,15 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
vec2 lastPosStore(lastPosition);
|
Vector2f lastPosStore(lastPosition);
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
vec2 pos = lastPosition + it->getPos();
|
Vector2f pos = lastPosition + it->getPos();
|
||||||
vec2 tmp1 = lastPosition + it->getPos1();
|
Vector2f tmp1 = lastPosition + it->getPos1();
|
||||||
// generate pos1 and pos2
|
// generate pos1 and pos2
|
||||||
vec2 pos1 = lastPosStore + (tmp1 - lastPosStore)*0.666666666f;
|
Vector2f pos1 = lastPosStore + (tmp1 - lastPosStore)*0.666666666f;
|
||||||
vec2 pos2 = pos + (tmp1 - pos)*0.666666666f;
|
Vector2f pos2 = pos + (tmp1 - pos)*0.666666666f;
|
||||||
interpolateCubicBezier(tmpListPoint,
|
interpolateCubicBezier(tmpListPoint,
|
||||||
_recurtionMax,
|
_recurtionMax,
|
||||||
_threshold,
|
_threshold,
|
||||||
@ -309,15 +309,15 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
vec2 lastPosStore(lastPosition);
|
Vector2f lastPosStore(lastPosition);
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
vec2 pos = lastPosition + it->getPos();
|
Vector2f pos = lastPosition + it->getPos();
|
||||||
vec2 tmp1 = lastPosStore*2.0f - lastAngle;
|
Vector2f tmp1 = lastPosStore*2.0f - lastAngle;
|
||||||
// generate pos1 and pos2
|
// generate pos1 and pos2
|
||||||
vec2 pos1 = lastPosStore + (tmp1 - lastPosStore)*0.666666666f;
|
Vector2f pos1 = lastPosStore + (tmp1 - lastPosStore)*0.666666666f;
|
||||||
vec2 pos2 = pos + (tmp1 - pos)*0.66666666f;
|
Vector2f pos2 = pos + (tmp1 - pos)*0.66666666f;
|
||||||
interpolateCubicBezier(tmpListPoint,
|
interpolateCubicBezier(tmpListPoint,
|
||||||
_recurtionMax,
|
_recurtionMax,
|
||||||
_threshold,
|
_threshold,
|
||||||
@ -339,24 +339,24 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
{
|
{
|
||||||
ememory::SharedPtr<esvg::render::ElementElliptic> tmpIt(ememory::dynamicPointerCast<esvg::render::ElementElliptic>(it));
|
ememory::SharedPtr<esvg::render::ElementElliptic> tmpIt(ememory::dynamicPointerCast<esvg::render::ElementElliptic>(it));
|
||||||
float angle = tmpIt->m_angle * (M_PI / 180.0);
|
float angle = tmpIt->m_angle * (M_PI / 180.0);
|
||||||
ESVG_TODO(spacingDist(_level+1) << " Elliptic arc: radius=" << tmpIt->getPos1());
|
Log.todo(spacingDist(_level+1) << " Elliptic arc: radius=" << tmpIt->getPos1());
|
||||||
ESVG_TODO(spacingDist(_level+1) << " angle=" << tmpIt->m_angle);
|
Log.todo(spacingDist(_level+1) << " angle=" << tmpIt->m_angle);
|
||||||
ESVG_TODO(spacingDist(_level+1) << " m_largeArcFlag=" << tmpIt->m_largeArcFlag);
|
Log.todo(spacingDist(_level+1) << " m_largeArcFlag=" << tmpIt->m_largeArcFlag);
|
||||||
ESVG_TODO(spacingDist(_level+1) << " m_sweepFlag=" << tmpIt->m_sweepFlag);
|
Log.todo(spacingDist(_level+1) << " m_sweepFlag=" << tmpIt->m_sweepFlag);
|
||||||
|
|
||||||
|
|
||||||
vec2 lastPosStore(lastPosition);
|
Vector2f lastPosStore(lastPosition);
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
vec2 pos = lastPosition + it->getPos();
|
Vector2f pos = lastPosition + it->getPos();
|
||||||
float rotationX = tmpIt->m_angle * (M_PI / 180.0);
|
float rotationX = tmpIt->m_angle * (M_PI / 180.0);
|
||||||
vec2 radius = tmpIt->getPos1();
|
Vector2f radius = tmpIt->getPos1();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_debugInformation.addSegment(lastPosStore, pos);
|
m_debugInformation.addSegment(lastPosStore, pos);
|
||||||
#endif
|
#endif
|
||||||
vec2 delta = lastPosStore - pos;
|
Vector2f delta = lastPosStore - pos;
|
||||||
float ddd = delta.length();
|
float ddd = delta.length();
|
||||||
if ( ddd < 1e-6f
|
if ( ddd < 1e-6f
|
||||||
|| radius.x() < 1e-6f
|
|| radius.x() < 1e-6f
|
||||||
@ -372,7 +372,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
// procedure describe here : http://www.w3.org/TR/SVG11/implnote.html#ArcConversionCenterToEndpoint
|
// procedure describe here : http://www.w3.org/TR/SVG11/implnote.html#ArcConversionCenterToEndpoint
|
||||||
// Compute delta'
|
// Compute delta'
|
||||||
mat2x3 matrixRotationCenter = etk::mat2x3Rotate(-rotationX);
|
mat2x3 matrixRotationCenter = etk::mat2x3Rotate(-rotationX);
|
||||||
vec2 deltaPrim = matrixRotationCenter * (delta*0.5f);
|
Vector2f deltaPrim = matrixRotationCenter * (delta*0.5f);
|
||||||
ddd = (deltaPrim.x()*deltaPrim.x())/(radius.x()*radius.x())
|
ddd = (deltaPrim.x()*deltaPrim.x())/(radius.x()*radius.x())
|
||||||
+ (deltaPrim.y()*deltaPrim.y())/(radius.y()*radius.y());
|
+ (deltaPrim.y()*deltaPrim.y())/(radius.y()*radius.y());
|
||||||
if (ddd > 1.0f) {
|
if (ddd > 1.0f) {
|
||||||
@ -403,24 +403,24 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
if (tmpIt->m_largeArcFlag == tmpIt->m_sweepFlag) {
|
if (tmpIt->m_largeArcFlag == tmpIt->m_sweepFlag) {
|
||||||
sss *= -1.0f;
|
sss *= -1.0f;
|
||||||
}
|
}
|
||||||
vec2 centerPrime(sss * radius.x() * deltaPrim.y() / radius.y(),
|
Vector2f centerPrime(sss * radius.x() * deltaPrim.y() / radius.y(),
|
||||||
sss * -radius.y() * deltaPrim.x() / radius.x());
|
sss * -radius.y() * deltaPrim.x() / radius.x());
|
||||||
// Compute center from center'
|
// Compute center from center'
|
||||||
mat2x3 matrix = etk::mat2x3Rotate(rotationX);
|
mat2x3 matrix = etk::mat2x3Rotate(rotationX);
|
||||||
vec2 center = (lastPosStore + pos)*0.5f + matrix*centerPrime;
|
Vector2f center = (lastPosStore + pos)*0.5f + matrix*centerPrime;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_debugInformation.addSegment(center-vec2(3.0,3.0), center+vec2(3.0,3.0));
|
m_debugInformation.addSegment(center-Vector2f(3.0,3.0), center+Vector2f(3.0,3.0));
|
||||||
m_debugInformation.addSegment(center-vec2(3.0,-3.0), center+vec2(3.0,-3.0));
|
m_debugInformation.addSegment(center-Vector2f(3.0,-3.0), center+Vector2f(3.0,-3.0));
|
||||||
#endif
|
#endif
|
||||||
// Calculate theta1, and delta theta.
|
// Calculate theta1, and delta theta.
|
||||||
vec2 vectorA = (deltaPrim - centerPrime) / radius;
|
Vector2f vectorA = (deltaPrim - centerPrime) / radius;
|
||||||
vec2 vectorB = (deltaPrim + centerPrime) / radius * -1.0f;
|
Vector2f vectorB = (deltaPrim + centerPrime) / radius * -1.0f;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_debugInformation.addSegment(center, center+vectorA*radius.x());
|
m_debugInformation.addSegment(center, center+vectorA*radius.x());
|
||||||
m_debugInformation.addSegment(center, center+vectorB*radius.y());
|
m_debugInformation.addSegment(center, center+vectorB*radius.y());
|
||||||
#endif
|
#endif
|
||||||
// Initial angle
|
// Initial angle
|
||||||
float theta1 = vectorAngle(vec2(1.0f,0.0f), vectorA);
|
float theta1 = vectorAngle(Vector2f(1.0f,0.0f), vectorA);
|
||||||
// Delta angle
|
// Delta angle
|
||||||
float deltaTheta = vectorAngle(vectorA, vectorB);
|
float deltaTheta = vectorAngle(vectorA, vectorB);
|
||||||
// special case of invert angle...
|
// special case of invert angle...
|
||||||
@ -455,27 +455,27 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
|||||||
if (deltaTheta < 0.0f) {
|
if (deltaTheta < 0.0f) {
|
||||||
kappa = -kappa;
|
kappa = -kappa;
|
||||||
}
|
}
|
||||||
vec2 pointPosPrevious(0.0,0.0);
|
Vector2f pointPosPrevious(0.0,0.0);
|
||||||
vec2 tangentPrevious(0.0,0.0);
|
Vector2f tangentPrevious(0.0,0.0);
|
||||||
for (int32_t iii=0; iii<=ndivs; ++iii) {
|
for (int32_t iii=0; iii<=ndivs; ++iii) {
|
||||||
float a = theta1 + deltaTheta * (float(iii)/(float)ndivs);
|
float a = theta1 + deltaTheta * (float(iii)/(float)ndivs);
|
||||||
#ifndef __STDCPP_LLVM__
|
#ifndef __STDCPP_LLVM__
|
||||||
delta = vec2(etk::cos(a), etk::sin(a));
|
delta = Vector2f(etk::cos(a), etk::sin(a));
|
||||||
#else
|
#else
|
||||||
delta = vec2(cosf(a), sinf(a));
|
delta = Vector2f(cosf(a), sinf(a));
|
||||||
#endif
|
#endif
|
||||||
// position
|
// position
|
||||||
vec2 pointPos = matrix * vec2(delta.x()*radius.x(), delta.y()*radius.y());
|
Vector2f pointPos = matrix * Vector2f(delta.x()*radius.x(), delta.y()*radius.y());
|
||||||
// tangent
|
// tangent
|
||||||
vec2 tangent = matrix.applyScaleRotation(vec2(-delta.y()*radius.x() * kappa, delta.x()*radius.y() * kappa));
|
Vector2f tangent = matrix.applyScaleRotation(Vector2f(-delta.y()*radius.x() * kappa, delta.x()*radius.y() * kappa));
|
||||||
if (iii > 0) {
|
if (iii > 0) {
|
||||||
vec2 zlastPosStore(lastPosition);
|
Vector2f zlastPosStore(lastPosition);
|
||||||
if (it->getRelative() == false) {
|
if (it->getRelative() == false) {
|
||||||
lastPosition = vec2(0.0f, 0.0f);
|
lastPosition = Vector2f(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
vec2 zpos1 = pointPosPrevious + tangentPrevious;
|
Vector2f zpos1 = pointPosPrevious + tangentPrevious;
|
||||||
vec2 zpos2 = pointPos - tangent;
|
Vector2f zpos2 = pointPos - tangent;
|
||||||
vec2 zpos = pointPos;
|
Vector2f zpos = pointPos;
|
||||||
interpolateCubicBezier(tmpListPoint,
|
interpolateCubicBezier(tmpListPoint,
|
||||||
_recurtionMax,
|
_recurtionMax,
|
||||||
_threshold,
|
_threshold,
|
||||||
|
@ -18,7 +18,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class Path {
|
class Path {
|
||||||
public:
|
public:
|
||||||
etk::Vector<ememory::SharedPtr<esvg::render::Element>> m_listElement;
|
List<ememory::SharedPtr<esvg::render::Element>> m_listElement;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
esvg::render::SegmentList m_debugInformation;
|
esvg::render::SegmentList m_debugInformation;
|
||||||
#endif
|
#endif
|
||||||
@ -33,20 +33,20 @@ namespace esvg {
|
|||||||
void clear();
|
void clear();
|
||||||
void stop();
|
void stop();
|
||||||
void close(bool _relative=false);
|
void close(bool _relative=false);
|
||||||
void moveTo(bool _relative, const vec2& _pos);
|
void moveTo(bool _relative, const Vector2f& _pos);
|
||||||
void lineTo(bool _relative, const vec2& _pos);
|
void lineTo(bool _relative, const Vector2f& _pos);
|
||||||
void lineToH(bool _relative, float _posX);
|
void lineToH(bool _relative, float _posX);
|
||||||
void lineToV(bool _relative, float _posY);
|
void lineToV(bool _relative, float _posY);
|
||||||
void curveTo(bool _relative, const vec2& _pos1, const vec2& _pos2, const vec2& _pos);
|
void curveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos2, const Vector2f& _pos);
|
||||||
void smoothCurveTo(bool _relative, const vec2& _pos2, const vec2& _pos);
|
void smoothCurveTo(bool _relative, const Vector2f& _pos2, const Vector2f& _pos);
|
||||||
void bezierCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos);
|
void bezierCurveTo(bool _relative, const Vector2f& _pos1, const Vector2f& _pos);
|
||||||
void bezierSmoothCurveTo(bool _relative, const vec2& _pos);
|
void bezierSmoothCurveTo(bool _relative, const Vector2f& _pos);
|
||||||
void ellipticTo(bool _relative,
|
void ellipticTo(bool _relative,
|
||||||
const vec2& _radius,
|
const Vector2f& _radius,
|
||||||
float _angle,
|
float _angle,
|
||||||
bool _largeArcFlag,
|
bool _largeArcFlag,
|
||||||
bool _sweepFlag,
|
bool _sweepFlag,
|
||||||
const vec2& _pos);
|
const Vector2f& _pos);
|
||||||
void display(int32_t _spacing);
|
void display(int32_t _spacing);
|
||||||
esvg::render::PointList generateListPoints(int32_t _level, int32_t _recurtionMax = 10, float _threshold = 0.25f);
|
esvg::render::PointList generateListPoints(int32_t _level, int32_t _recurtionMax = 10, float _threshold = 0.25f);
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@ void esvg::render::Point::setEndPath() {
|
|||||||
m_type = esvg::render::Point::type::stop;
|
m_type = esvg::render::Point::type::stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Point::normalize(const vec2& _nextPoint) {
|
void esvg::render::Point::normalize(const Vector2f& _nextPoint) {
|
||||||
m_delta = _nextPoint - m_pos;
|
m_delta = _nextPoint - m_pos;
|
||||||
m_len = m_delta.length();
|
m_len = m_delta.length();
|
||||||
}
|
}
|
||||||
|
@ -22,28 +22,28 @@ namespace esvg {
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
// TODO : Clean all element here ...
|
// TODO : Clean all element here ...
|
||||||
vec2 m_pos; //!< position of the point
|
Vector2f m_pos; //!< position of the point
|
||||||
enum esvg::render::Point::type m_type;
|
enum esvg::render::Point::type m_type;
|
||||||
vec2 m_miterAxe;
|
Vector2f m_miterAxe;
|
||||||
vec2 m_orthoAxePrevious;
|
Vector2f m_orthoAxePrevious;
|
||||||
vec2 m_orthoAxeNext;
|
Vector2f m_orthoAxeNext;
|
||||||
vec2 m_posPrevious;
|
Vector2f m_posPrevious;
|
||||||
vec2 m_posNext;
|
Vector2f m_posNext;
|
||||||
vec2 m_delta;
|
Vector2f m_delta;
|
||||||
float m_len;
|
float m_len;
|
||||||
// TODO: Update etk::Vector to support not having it ...
|
// TODO: Update List to support not having it ...
|
||||||
Point() :
|
Point() :
|
||||||
m_pos(0,0),
|
m_pos(0,0),
|
||||||
m_type(esvg::render::Point::type::join) {
|
m_type(esvg::render::Point::type::join) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
}
|
}
|
||||||
Point(const vec2& _pos, enum esvg::render::Point::type _type = esvg::render::Point::type::join) :
|
Point(const Vector2f& _pos, enum esvg::render::Point::type _type = esvg::render::Point::type::join) :
|
||||||
m_pos(_pos),
|
m_pos(_pos),
|
||||||
m_type(_type) {
|
m_type(_type) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
}
|
}
|
||||||
void setEndPath();
|
void setEndPath();
|
||||||
void normalize(const vec2& _nextPoint);
|
void normalize(const Vector2f& _nextPoint);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ esvg::render::PointList::PointList() {
|
|||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::PointList::addList(etk::Vector<esvg::render::Point>& _list) {
|
void esvg::render::PointList::addList(List<esvg::render::Point>& _list) {
|
||||||
m_data.pushBack(_list);
|
m_data.pushBack(_list);
|
||||||
// TODO : Add a checker of correct list ...
|
// TODO : Add a checker of correct list ...
|
||||||
}
|
}
|
||||||
@ -24,8 +24,8 @@ void esvg::render::PointList::applyMatrix(const mat2x3& _transformationMatrix) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Pair<vec2, vec2> esvg::render::PointList::getViewPort() {
|
etk::Pair<Vector2f, Vector2f> esvg::render::PointList::getViewPort() {
|
||||||
etk::Pair<vec2, vec2> out(vec2(9999999999.0,9999999999.0),vec2(-9999999999.0,-9999999999.0));
|
etk::Pair<Vector2f, Vector2f> out(Vector2f(9999999999.0,9999999999.0),Vector2f(-9999999999.0,-9999999999.0));
|
||||||
for (auto &it : m_data) {
|
for (auto &it : m_data) {
|
||||||
for (auto &it2 : it) {
|
for (auto &it2 : it) {
|
||||||
out.first.setMin(it2.m_pos);
|
out.first.setMin(it2.m_pos);
|
||||||
|
@ -16,13 +16,13 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class PointList {
|
class PointList {
|
||||||
public:
|
public:
|
||||||
etk::Vector<etk::Vector<esvg::render::Point>> m_data;
|
List<List<esvg::render::Point>> m_data;
|
||||||
public:
|
public:
|
||||||
PointList();
|
PointList();
|
||||||
void addList(etk::Vector<esvg::render::Point>& _list);
|
void addList(List<esvg::render::Point>& _list);
|
||||||
void display();
|
void display();
|
||||||
void applyMatrix(const mat2x3& _transformationMatrix);
|
void applyMatrix(const mat2x3& _transformationMatrix);
|
||||||
etk::Pair<vec2, vec2> getViewPort();
|
etk::Pair<Vector2f, Vector2f> getViewPort();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class Scanline {
|
class Scanline {
|
||||||
private:
|
private:
|
||||||
etk::Vector<float> m_data;
|
List<float> m_data;
|
||||||
public:
|
public:
|
||||||
// constructor :
|
// constructor :
|
||||||
Scanline(size_t _size=32);
|
Scanline(size_t _size=32);
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
#include <esvg/debug.hpp>
|
#include <esvg/debug.hpp>
|
||||||
|
|
||||||
esvg::render::Segment::Segment() {
|
esvg::render::Segment::Segment() {
|
||||||
p0 = vec2(0,0);
|
p0 = Vector2f(0,0);
|
||||||
p1 = vec2(0,0);
|
p1 = Vector2f(0,0);
|
||||||
direction = 0;
|
direction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
esvg::render::Segment::Segment(const vec2& _p0, const vec2& _p1) {
|
esvg::render::Segment::Segment(const Vector2f& _p0, const Vector2f& _p1) {
|
||||||
// segment register all time the lower at P0n then we need to register the sens of the path
|
// segment register all time the lower at P0n then we need to register the sens of the path
|
||||||
p0 = _p0;
|
p0 = _p0;
|
||||||
p1 = _p1;
|
p1 = _p1;
|
||||||
@ -30,7 +30,7 @@ void esvg::render::Segment::createDirection() {
|
|||||||
if (p0.y() < p1.y()) {
|
if (p0.y() < p1.y()) {
|
||||||
direction = 1; // direction like clock
|
direction = 1; // direction like clock
|
||||||
} else {
|
} else {
|
||||||
vec2 tmp(p0);
|
Vector2f tmp(p0);
|
||||||
p0 = p1;
|
p0 = p1;
|
||||||
p1 = tmp;
|
p1 = tmp;
|
||||||
direction = -1; // direction like anti-clock
|
direction = -1; // direction like anti-clock
|
||||||
|
@ -13,11 +13,11 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class Segment {
|
class Segment {
|
||||||
public:
|
public:
|
||||||
// TODO: Update etk::Vector to support not having it ...
|
// TODO: Update List to support not having it ...
|
||||||
Segment();
|
Segment();
|
||||||
Segment(const vec2& _p0, const vec2& _p1);
|
Segment(const Vector2f& _p0, const Vector2f& _p1);
|
||||||
vec2 p0;
|
Vector2f p0;
|
||||||
vec2 p1;
|
Vector2f p1;
|
||||||
int32_t direction;
|
int32_t direction;
|
||||||
void applyMatrix(const mat2x3& _transformationMatrix);
|
void applyMatrix(const mat2x3& _transformationMatrix);
|
||||||
void createDirection();
|
void createDirection();
|
||||||
|
@ -12,7 +12,7 @@ esvg::render::SegmentList::SegmentList() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void esvg::render::SegmentList::addSegment(const vec2& _pos0, const vec2& _pos1) {
|
void esvg::render::SegmentList::addSegment(const Vector2f& _pos0, const Vector2f& _pos1) {
|
||||||
m_data.pushBack(Segment(_pos0, _pos1));
|
m_data.pushBack(Segment(_pos0, _pos1));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -36,8 +36,8 @@ void esvg::render::SegmentList::addSegment(const esvg::render::Point& _pos0, con
|
|||||||
m_data.pushBack(Segment(_pos0.m_pos, _pos1.m_pos));
|
m_data.pushBack(Segment(_pos0.m_pos, _pos1.m_pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Pair<vec2, vec2> esvg::render::SegmentList::getViewPort() {
|
etk::Pair<Vector2f, Vector2f> esvg::render::SegmentList::getViewPort() {
|
||||||
etk::Pair<vec2, vec2> out(vec2(9999999999.0,9999999999.0),vec2(-9999999999.0,-9999999999.0));
|
etk::Pair<Vector2f, Vector2f> out(Vector2f(9999999999.0,9999999999.0),Vector2f(-9999999999.0,-9999999999.0));
|
||||||
for (auto &it : m_data) {
|
for (auto &it : m_data) {
|
||||||
out.first.setMin(it.p0);
|
out.first.setMin(it.p0);
|
||||||
out.second.setMax(it.p0);
|
out.second.setMax(it.p0);
|
||||||
@ -57,10 +57,10 @@ void esvg::render::SegmentList::createSegmentList(const esvg::render::PointList&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static vec2 getIntersect(const vec2& _point1,
|
static Vector2f getIntersect(const Vector2f& _point1,
|
||||||
const vec2& _vect1,
|
const Vector2f& _vect1,
|
||||||
const vec2& _point2,
|
const Vector2f& _point2,
|
||||||
const vec2& _vect2) {
|
const Vector2f& _vect2) {
|
||||||
float diviseur = _vect1.x() * _vect2.y() - _vect1.y() * _vect2.x();
|
float diviseur = _vect1.x() * _vect2.y() - _vect1.y() * _vect2.x();
|
||||||
if(diviseur != 0.0f) {
|
if(diviseur != 0.0f) {
|
||||||
float mmm = ( _vect1.x() * _point1.y()
|
float mmm = ( _vect1.x() * _point1.y()
|
||||||
@ -68,15 +68,15 @@ static vec2 getIntersect(const vec2& _point1,
|
|||||||
- _vect1.y() * _point1.x()
|
- _vect1.y() * _point1.x()
|
||||||
+ _vect1.y() * _point2.x()
|
+ _vect1.y() * _point2.x()
|
||||||
) / diviseur;
|
) / diviseur;
|
||||||
return vec2(_point2 + _vect2 * mmm);
|
return Vector2f(_point2 + _vect2 * mmm);
|
||||||
}
|
}
|
||||||
Log.error("Get divider / 0.0f");
|
Log.error("Get divider / 0.0f");
|
||||||
return _point2;
|
return _point2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::SegmentList::createSegmentListStroke(const vec2& _point1,
|
void esvg::render::SegmentList::createSegmentListStroke(const Vector2f& _point1,
|
||||||
const vec2& _point2,
|
const Vector2f& _point2,
|
||||||
const vec2& _center,
|
const Vector2f& _center,
|
||||||
float _width,
|
float _width,
|
||||||
bool _isStart) {
|
bool _isStart) {
|
||||||
int32_t nbDot = int32_t(_width);
|
int32_t nbDot = int32_t(_width);
|
||||||
@ -86,9 +86,9 @@ void esvg::render::SegmentList::createSegmentListStroke(const vec2& _point1,
|
|||||||
float angleToDraw = acos((_point1 - _center).safeNormalize().dot((_point2 - _center).safeNormalize()));
|
float angleToDraw = acos((_point1 - _center).safeNormalize().dot((_point2 - _center).safeNormalize()));
|
||||||
float baseAngle = angleToDraw/float(nbDot);
|
float baseAngle = angleToDraw/float(nbDot);
|
||||||
float iii;
|
float iii;
|
||||||
vec2 axe = (_point1 - _center).safeNormalize();
|
Vector2f axe = (_point1 - _center).safeNormalize();
|
||||||
vec2 ppp1(_point1);
|
Vector2f ppp1(_point1);
|
||||||
vec2 ppp2(_point2);
|
Vector2f ppp2(_point2);
|
||||||
for (iii=baseAngle; iii<angleToDraw; iii+=baseAngle) {
|
for (iii=baseAngle; iii<angleToDraw; iii+=baseAngle) {
|
||||||
mat2x3 tmpMat;
|
mat2x3 tmpMat;
|
||||||
if (_isStart == true) {
|
if (_isStart == true) {
|
||||||
@ -96,7 +96,7 @@ void esvg::render::SegmentList::createSegmentListStroke(const vec2& _point1,
|
|||||||
} else {
|
} else {
|
||||||
tmpMat = etk::mat2x3Rotate(iii);
|
tmpMat = etk::mat2x3Rotate(iii);
|
||||||
}
|
}
|
||||||
vec2 axeRotate = tmpMat * axe;
|
Vector2f axeRotate = tmpMat * axe;
|
||||||
ppp2 = _center
|
ppp2 = _center
|
||||||
+ axeRotate*_width*0.5f;
|
+ axeRotate*_width*0.5f;
|
||||||
if (_isStart == true) {
|
if (_isStart == true) {
|
||||||
@ -155,17 +155,17 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
}
|
}
|
||||||
//Log.debug("JOIN : id : prev/curr/next : " << idPevious << "/" << idCurrent << "/" << idNext);
|
//Log.debug("JOIN : id : prev/curr/next : " << idPevious << "/" << idCurrent << "/" << idNext);
|
||||||
//Log.debug("JOIN : val : prev/curr/next : " << itListPoint[idPevious].m_pos << "/" << itListPoint[idCurrent].m_pos << "/" << itListPoint[idNext].m_pos);
|
//Log.debug("JOIN : val : prev/curr/next : " << itListPoint[idPevious].m_pos << "/" << itListPoint[idCurrent].m_pos << "/" << itListPoint[idNext].m_pos);
|
||||||
vec2 vecA = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
|
Vector2f vecA = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
|
||||||
//Log.debug("JOIN : vecA : " << vecA);
|
//Log.debug("JOIN : vecA : " << vecA);
|
||||||
vecA.safeNormalize();
|
vecA.safeNormalize();
|
||||||
vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
|
Vector2f vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
|
||||||
//Log.debug("JOIN : vecB : " << vecB);
|
//Log.debug("JOIN : vecB : " << vecB);
|
||||||
vecB.safeNormalize();
|
vecB.safeNormalize();
|
||||||
vec2 vecC = vecA - vecB;
|
Vector2f vecC = vecA - vecB;
|
||||||
//Log.debug("JOIN : vecC : " << vecC);
|
//Log.debug("JOIN : vecC : " << vecC);
|
||||||
if (vecC == vec2(0.0f, 0.0f)) {
|
if (vecC == Vector2f(0.0f, 0.0f)) {
|
||||||
// special case: 1 line ...
|
// special case: 1 line ...
|
||||||
itListPoint[idCurrent].m_miterAxe = vec2(vecA.y(), vecA.x());
|
itListPoint[idCurrent].m_miterAxe = Vector2f(vecA.y(), vecA.x());
|
||||||
} else {
|
} else {
|
||||||
vecC.safeNormalize();
|
vecC.safeNormalize();
|
||||||
itListPoint[idCurrent].m_miterAxe = vecC;
|
itListPoint[idCurrent].m_miterAxe = vecC;
|
||||||
@ -174,16 +174,16 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos;
|
itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos;
|
||||||
vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
|
vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
|
||||||
vecB.safeNormalize();
|
vecB.safeNormalize();
|
||||||
itListPoint[idCurrent].m_orthoAxeNext = vec2(vecB.y(), -vecB.x());
|
itListPoint[idCurrent].m_orthoAxeNext = Vector2f(vecB.y(), -vecB.x());
|
||||||
vecB = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
|
vecB = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
|
||||||
vecB.safeNormalize();
|
vecB.safeNormalize();
|
||||||
itListPoint[idCurrent].m_orthoAxePrevious = vec2(vecB.y(), -vecB.x());
|
itListPoint[idCurrent].m_orthoAxePrevious = Vector2f(vecB.y(), -vecB.x());
|
||||||
//Log.debug("JOIN : miterAxe " << itListPoint[idCurrent].m_miterAxe);
|
//Log.debug("JOIN : miterAxe " << itListPoint[idCurrent].m_miterAxe);
|
||||||
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type::start) {
|
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type::start) {
|
||||||
itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos;
|
itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos;
|
||||||
vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
|
Vector2f vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
|
||||||
vecB.safeNormalize();
|
vecB.safeNormalize();
|
||||||
itListPoint[idCurrent].m_miterAxe = vec2(vecB.y(), -vecB.x());
|
itListPoint[idCurrent].m_miterAxe = Vector2f(vecB.y(), -vecB.x());
|
||||||
itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe;
|
itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe;
|
||||||
itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
|
itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
|
||||||
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type::stop) {
|
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type::stop) {
|
||||||
@ -192,19 +192,19 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
itListPoint[idCurrent].m_posPrevious = itListPoint[idPevious].m_pos;
|
itListPoint[idCurrent].m_posPrevious = itListPoint[idPevious].m_pos;
|
||||||
vec2 vecA = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
|
Vector2f vecA = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
|
||||||
vecA.safeNormalize();
|
vecA.safeNormalize();
|
||||||
itListPoint[idCurrent].m_miterAxe = vec2(vecA.y(), -vecA.x());
|
itListPoint[idCurrent].m_miterAxe = Vector2f(vecA.y(), -vecA.x());
|
||||||
itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe;
|
itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe;
|
||||||
itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
|
itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
|
||||||
} else {
|
} else {
|
||||||
ESVG_TODO("Unsupported type of point ....");
|
Log.todo("Unsupported type of point ....");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create segment list:
|
// create segment list:
|
||||||
bool haveStartLine = false;
|
bool haveStartLine = false;
|
||||||
vec2 leftPoint(0,0);
|
Vector2f leftPoint(0,0);
|
||||||
vec2 rightPoint(0,0);
|
Vector2f rightPoint(0,0);
|
||||||
if (itListPoint.size() > 0) {
|
if (itListPoint.size() > 0) {
|
||||||
if (itListPoint.front().m_type == esvg::render::Point::type::join) {
|
if (itListPoint.front().m_type == esvg::render::Point::type::join) {
|
||||||
const esvg::render::Point& it = itListPoint.back();
|
const esvg::render::Point& it = itListPoint.back();
|
||||||
@ -227,8 +227,8 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
switch (_join) {
|
switch (_join) {
|
||||||
case esvg::join_miter:
|
case esvg::join_miter:
|
||||||
{
|
{
|
||||||
vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
vec2 right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
// Check the miter limit:
|
// Check the miter limit:
|
||||||
float limitRight = (left - it.m_pos).length() / _width * 2.0f;
|
float limitRight = (left - it.m_pos).length() / _width * 2.0f;
|
||||||
float limitLeft = (right - it.m_pos).length() / _width * 2.0f;
|
float limitLeft = (right - it.m_pos).length() / _width * 2.0f;
|
||||||
@ -245,8 +245,8 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
case esvg::join_round:
|
case esvg::join_round:
|
||||||
case esvg::join_bevel:
|
case esvg::join_bevel:
|
||||||
{
|
{
|
||||||
vec2 axePrevious = (it.m_pos-it.m_posPrevious).safeNormalize();
|
Vector2f axePrevious = (it.m_pos-it.m_posPrevious).safeNormalize();
|
||||||
vec2 axeNext = (it.m_posNext - it.m_pos).safeNormalize();
|
Vector2f axeNext = (it.m_posNext - it.m_pos).safeNormalize();
|
||||||
float cross = axePrevious.cross(axeNext);
|
float cross = axePrevious.cross(axeNext);
|
||||||
if (cross > 0.0f) {
|
if (cross > 0.0f) {
|
||||||
rightPoint = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
rightPoint = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
@ -293,8 +293,8 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
case esvg::render::Point::type::interpolation:
|
case esvg::render::Point::type::interpolation:
|
||||||
{
|
{
|
||||||
Log.verbose("Find interpolation " << it.m_pos);
|
Log.verbose("Find interpolation " << it.m_pos);
|
||||||
vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
vec2 right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
//Draw from previous point:
|
//Draw from previous point:
|
||||||
addSegment(leftPoint, left);
|
addSegment(leftPoint, left);
|
||||||
Log.verbose(" segment :" << leftPoint << " -> " << left);
|
Log.verbose(" segment :" << leftPoint << " -> " << left);
|
||||||
@ -309,8 +309,8 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
switch (_join) {
|
switch (_join) {
|
||||||
case esvg::join_miter:
|
case esvg::join_miter:
|
||||||
{
|
{
|
||||||
vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
vec2 right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
// Check the miter limit:
|
// Check the miter limit:
|
||||||
float limitRight = (left - it.m_pos).length() / _width * 2.0f;
|
float limitRight = (left - it.m_pos).length() / _width * 2.0f;
|
||||||
float limitLeft = (right - it.m_pos).length() / _width * 2.0f;
|
float limitLeft = (right - it.m_pos).length() / _width * 2.0f;
|
||||||
@ -333,14 +333,14 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
case esvg::join_round:
|
case esvg::join_round:
|
||||||
case esvg::join_bevel:
|
case esvg::join_bevel:
|
||||||
{
|
{
|
||||||
vec2 axePrevious = (it.m_pos-it.m_posPrevious).safeNormalize();
|
Vector2f axePrevious = (it.m_pos-it.m_posPrevious).safeNormalize();
|
||||||
vec2 axeNext = (it.m_posNext - it.m_pos).safeNormalize();
|
Vector2f axeNext = (it.m_posNext - it.m_pos).safeNormalize();
|
||||||
float cross = axePrevious.cross(axeNext);
|
float cross = axePrevious.cross(axeNext);
|
||||||
if (cross > 0.0f) {
|
if (cross > 0.0f) {
|
||||||
vec2 right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
vec2 left1 = it.m_pos
|
Vector2f left1 = it.m_pos
|
||||||
+ it.m_orthoAxePrevious*_width*0.5f;
|
+ it.m_orthoAxePrevious*_width*0.5f;
|
||||||
vec2 left2 = it.m_pos
|
Vector2f left2 = it.m_pos
|
||||||
+ it.m_orthoAxeNext*_width*0.5f;
|
+ it.m_orthoAxeNext*_width*0.5f;
|
||||||
//Draw from previous point:
|
//Draw from previous point:
|
||||||
addSegment(leftPoint, left1);
|
addSegment(leftPoint, left1);
|
||||||
@ -361,10 +361,10 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
leftPoint = left2;
|
leftPoint = left2;
|
||||||
rightPoint = right;
|
rightPoint = right;
|
||||||
} else {
|
} else {
|
||||||
vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
Vector2f left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||||
vec2 right1 = it.m_pos
|
Vector2f right1 = it.m_pos
|
||||||
- it.m_orthoAxePrevious*_width*0.5f;
|
- it.m_orthoAxePrevious*_width*0.5f;
|
||||||
vec2 right2 = it.m_pos
|
Vector2f right2 = it.m_pos
|
||||||
- it.m_orthoAxeNext*_width*0.5f;//Draw from previous point:
|
- it.m_orthoAxeNext*_width*0.5f;//Draw from previous point:
|
||||||
addSegment(leftPoint, left);
|
addSegment(leftPoint, left);
|
||||||
Log.verbose(" segment :" << leftPoint << " -> " << left);
|
Log.verbose(" segment :" << leftPoint << " -> " << left);
|
||||||
@ -393,8 +393,8 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
void esvg::render::SegmentList::startStopPoint(Vector2f& _leftPoint,
|
||||||
vec2& _rightPoint,
|
Vector2f& _rightPoint,
|
||||||
const esvg::render::Point& _point,
|
const esvg::render::Point& _point,
|
||||||
enum esvg::cap _cap,
|
enum esvg::cap _cap,
|
||||||
float _width,
|
float _width,
|
||||||
@ -402,9 +402,9 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
|||||||
switch (_cap) {
|
switch (_cap) {
|
||||||
case esvg::cap_butt:
|
case esvg::cap_butt:
|
||||||
{
|
{
|
||||||
vec2 left = _point.m_pos
|
Vector2f left = _point.m_pos
|
||||||
+ _point.m_miterAxe*_width*0.5f;
|
+ _point.m_miterAxe*_width*0.5f;
|
||||||
vec2 right = _point.m_pos
|
Vector2f right = _point.m_pos
|
||||||
- _point.m_miterAxe*_width*0.5f;
|
- _point.m_miterAxe*_width*0.5f;
|
||||||
if (_isStart == false) {
|
if (_isStart == false) {
|
||||||
//Draw from previous point:
|
//Draw from previous point:
|
||||||
@ -427,9 +427,9 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
|||||||
case esvg::cap_round:
|
case esvg::cap_round:
|
||||||
{
|
{
|
||||||
if (_isStart == false) {
|
if (_isStart == false) {
|
||||||
vec2 left = _point.m_pos
|
Vector2f left = _point.m_pos
|
||||||
+ _point.m_miterAxe*_width*0.5f;
|
+ _point.m_miterAxe*_width*0.5f;
|
||||||
vec2 right = _point.m_pos
|
Vector2f right = _point.m_pos
|
||||||
- _point.m_miterAxe*_width*0.5f;
|
- _point.m_miterAxe*_width*0.5f;
|
||||||
if (_isStart == false) {
|
if (_isStart == false) {
|
||||||
//Draw from previous point:
|
//Draw from previous point:
|
||||||
@ -460,15 +460,15 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
|||||||
break;
|
break;
|
||||||
case esvg::cap_square:
|
case esvg::cap_square:
|
||||||
{
|
{
|
||||||
vec2 nextAxe;
|
Vector2f nextAxe;
|
||||||
if (_isStart == true) {
|
if (_isStart == true) {
|
||||||
nextAxe = _point.m_posNext - _point.m_pos;
|
nextAxe = _point.m_posNext - _point.m_pos;
|
||||||
} else {
|
} else {
|
||||||
nextAxe = _point.m_posPrevious - _point.m_pos;
|
nextAxe = _point.m_posPrevious - _point.m_pos;
|
||||||
}
|
}
|
||||||
vec2 left = _point.m_pos
|
Vector2f left = _point.m_pos
|
||||||
+ _point.m_miterAxe*_width*0.5f;
|
+ _point.m_miterAxe*_width*0.5f;
|
||||||
vec2 right = _point.m_pos
|
Vector2f right = _point.m_pos
|
||||||
- _point.m_miterAxe*_width*0.5f;
|
- _point.m_miterAxe*_width*0.5f;
|
||||||
mat2x3 tmpMat = etk::mat2x3Translate(nextAxe.safeNormalize()*_width*-0.5f);
|
mat2x3 tmpMat = etk::mat2x3Translate(nextAxe.safeNormalize()*_width*-0.5f);
|
||||||
left = tmpMat*left;
|
left = tmpMat*left;
|
||||||
|
@ -16,11 +16,11 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class SegmentList {
|
class SegmentList {
|
||||||
public:
|
public:
|
||||||
etk::Vector<esvg::render::Segment> m_data;
|
List<esvg::render::Segment> m_data;
|
||||||
public:
|
public:
|
||||||
SegmentList();
|
SegmentList();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void addSegment(const vec2& _pos0, const vec2& _pos1);
|
void addSegment(const Vector2f& _pos0, const Vector2f& _pos1);
|
||||||
#endif
|
#endif
|
||||||
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 addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1, bool _disableHorizontal);
|
void addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1, bool _disableHorizontal);
|
||||||
@ -31,19 +31,19 @@ namespace esvg {
|
|||||||
enum esvg::join _join,
|
enum esvg::join _join,
|
||||||
float _miterLimit);
|
float _miterLimit);
|
||||||
private:
|
private:
|
||||||
void startStopPoint(vec2& _leftPoint,
|
void startStopPoint(Vector2f& _leftPoint,
|
||||||
vec2& _rightPoint,
|
Vector2f& _rightPoint,
|
||||||
const esvg::render::Point& _point,
|
const esvg::render::Point& _point,
|
||||||
enum esvg::cap _cap,
|
enum esvg::cap _cap,
|
||||||
float _width,
|
float _width,
|
||||||
bool _isStart);
|
bool _isStart);
|
||||||
void createSegmentListStroke(const vec2& _point1,
|
void createSegmentListStroke(const Vector2f& _point1,
|
||||||
const vec2& _point2,
|
const Vector2f& _point2,
|
||||||
const vec2& _center,
|
const Vector2f& _center,
|
||||||
float _width,
|
float _width,
|
||||||
bool _isStart);
|
bool _isStart);
|
||||||
public:
|
public:
|
||||||
etk::Pair<vec2, vec2> getViewPort();
|
etk::Pair<Vector2f, Vector2f> getViewPort();
|
||||||
void applyMatrix(const mat2x3& _transformationMatrix);
|
void applyMatrix(const mat2x3& _transformationMatrix);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ esvg::render::Weight::Weight() :
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
esvg::render::Weight::Weight(const ivec2& _size) :
|
esvg::render::Weight::Weight(const Vector2i& _size) :
|
||||||
m_size(_size) {
|
m_size(_size) {
|
||||||
resize(_size);
|
resize(_size);
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ esvg::render::Weight::~Weight() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Weight::resize(const ivec2& _size) {
|
void esvg::render::Weight::resize(const Vector2i& _size) {
|
||||||
m_size = _size;
|
m_size = _size;
|
||||||
float tmp(0);
|
float tmp(0);
|
||||||
m_data.resize(m_size.x()*m_size.y(), tmp);
|
m_data.resize(m_size.x()*m_size.y(), tmp);
|
||||||
@ -32,7 +32,7 @@ void esvg::render::Weight::resize(const ivec2& _size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ivec2& esvg::render::Weight::getSize() const {
|
const Vector2i& esvg::render::Weight::getSize() const {
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ void esvg::render::Weight::clear(float _fill) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float esvg::render::Weight::get(const ivec2& _pos) const {
|
float esvg::render::Weight::get(const Vector2i& _pos) const {
|
||||||
if ( _pos.x()>=0 && _pos.x()<m_size.x()
|
if ( _pos.x()>=0 && _pos.x()<m_size.x()
|
||||||
&& _pos.y()>=0 && _pos.y()<m_size.y()) {
|
&& _pos.y()>=0 && _pos.y()<m_size.y()) {
|
||||||
return m_data[_pos.x()+_pos.y()*m_size.x()];
|
return m_data[_pos.x()+_pos.y()*m_size.x()];
|
||||||
@ -58,7 +58,7 @@ float esvg::render::Weight::get(const ivec2& _pos) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::render::Weight::set(const ivec2& _pos, float _newColor) {
|
void esvg::render::Weight::set(const Vector2i& _pos, float _newColor) {
|
||||||
if ( _pos.x()>=0 && _pos.x()<m_size.x()
|
if ( _pos.x()>=0 && _pos.x()<m_size.x()
|
||||||
&& _pos.y()>=0 && _pos.y()<m_size.y()) {
|
&& _pos.y()>=0 && _pos.y()<m_size.y()) {
|
||||||
m_data[_pos.x()+_pos.y()*m_size.x()] = _newColor;
|
m_data[_pos.x()+_pos.y()*m_size.x()] = _newColor;
|
||||||
@ -88,13 +88,13 @@ bool sortXPosFunction(const etk::Pair<float,int32_t>& _e1, const etk::Pair<float
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, const esvg::render::SegmentList& _listSegment) {
|
void esvg::render::Weight::generate(Vector2i _size, int32_t _subSamplingCount, const esvg::render::SegmentList& _listSegment) {
|
||||||
resize(_size);
|
resize(_size);
|
||||||
// for each lines:
|
// for each lines:
|
||||||
for (int32_t yyy=0; yyy<_size.y(); ++yyy) {
|
for (int32_t yyy=0; yyy<_size.y(); ++yyy) {
|
||||||
Log.verbose("Weighting ... " << yyy << " / " << _size.y());
|
Log.verbose("Weighting ... " << yyy << " / " << _size.y());
|
||||||
// Reduce the number of lines in the subsampling parsing:
|
// Reduce the number of lines in the subsampling parsing:
|
||||||
etk::Vector<Segment> availlableSegmentPixel;
|
List<Segment> availlableSegmentPixel;
|
||||||
for (auto &it : _listSegment.m_data) {
|
for (auto &it : _listSegment.m_data) {
|
||||||
if ( it.p0.y() < float(yyy+1)
|
if ( it.p0.y() < float(yyy+1)
|
||||||
&& it.p1.y() > float(yyy)) {
|
&& it.p1.y() > float(yyy)) {
|
||||||
@ -112,7 +112,7 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
|||||||
Scanline scanline(_size.x());
|
Scanline scanline(_size.x());
|
||||||
//find all the segment that cross the middle of the line of the center of the pixel line:
|
//find all the segment that cross the middle of the line of the center of the pixel line:
|
||||||
float subSamplingCenterPos = yyy + deltaSize*0.5f + deltaSize*kkk;
|
float subSamplingCenterPos = yyy + deltaSize*0.5f + deltaSize*kkk;
|
||||||
etk::Vector<Segment> availlableSegment;
|
List<Segment> availlableSegment;
|
||||||
// find in the subList ...
|
// find in the subList ...
|
||||||
for (auto &it : availlableSegmentPixel) {
|
for (auto &it : availlableSegmentPixel) {
|
||||||
if ( it.p0.y() <= subSamplingCenterPos
|
if ( it.p0.y() <= subSamplingCenterPos
|
||||||
@ -135,9 +135,9 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
|||||||
Log.verbose(" Availlable Segment " << it.p0 << " -> " << it.p1 << " dir=" << it.direction);
|
Log.verbose(" Availlable Segment " << it.p0 << " -> " << it.p1 << " dir=" << it.direction);
|
||||||
}
|
}
|
||||||
// x position, angle
|
// x position, angle
|
||||||
etk::Vector<etk::Pair<float, int32_t>> listPosition;
|
List<etk::Pair<float, int32_t>> listPosition;
|
||||||
for (auto &it : availlableSegment) {
|
for (auto &it : availlableSegment) {
|
||||||
vec2 delta = it.p0 - it.p1;
|
Vector2f delta = it.p0 - it.p1;
|
||||||
// x = coefficent*y+bbb;
|
// x = coefficent*y+bbb;
|
||||||
float coefficient = delta.x()/delta.y();
|
float coefficient = delta.x()/delta.y();
|
||||||
float bbb = it.p0.x() - coefficient*it.p0.y();
|
float bbb = it.p0.x() - coefficient*it.p0.y();
|
||||||
|
@ -14,28 +14,28 @@ namespace esvg {
|
|||||||
namespace render {
|
namespace render {
|
||||||
class Weight {
|
class Weight {
|
||||||
private:
|
private:
|
||||||
ivec2 m_size;
|
Vector2i m_size;
|
||||||
etk::Vector<float> m_data;
|
List<float> m_data;
|
||||||
public:
|
public:
|
||||||
// constructor :
|
// constructor :
|
||||||
Weight();
|
Weight();
|
||||||
Weight(const ivec2& _size);
|
Weight(const Vector2i& _size);
|
||||||
// destructor
|
// destructor
|
||||||
~Weight();
|
~Weight();
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
// -- basic tools :
|
// -- basic tools :
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
public:
|
public:
|
||||||
void resize(const ivec2& _size);
|
void resize(const Vector2i& _size);
|
||||||
const ivec2& getSize() const;
|
const Vector2i& getSize() const;
|
||||||
int32_t getWidth() const;
|
int32_t getWidth() const;
|
||||||
int32_t getHeight() const;
|
int32_t getHeight() const;
|
||||||
void clear(float _fill);
|
void clear(float _fill);
|
||||||
float get(const ivec2& _pos) const;
|
float get(const Vector2i& _pos) const;
|
||||||
void set(const ivec2& _pos, float _newColor);
|
void set(const Vector2i& _pos, float _newColor);
|
||||||
void set(int32_t _posY, const esvg::render::Scanline& _data);
|
void set(int32_t _posY, const esvg::render::Scanline& _data);
|
||||||
void append(int32_t _posY, const esvg::render::Scanline& _data);
|
void append(int32_t _posY, const esvg::render::Scanline& _data);
|
||||||
void generate(ivec2 _size, int32_t _subSamplingCount, const esvg::render::SegmentList& _listSegment);
|
void generate(Vector2i _size, int32_t _subSamplingCount, const esvg::render::SegmentList& _listSegment);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user