[DEV] Change declaration position of the enums
This commit is contained in:
parent
d9f689ebc6
commit
063ae69628
@ -62,7 +62,19 @@ bool esvg::LinearGradient::parseXML(const std::shared_ptr<exml::Element>& _eleme
|
||||
// by default we will use "objectBoundingBox"
|
||||
m_unit = gradientUnits_objectBoundingBox;
|
||||
if (contentX.size() != 0) {
|
||||
ESVG_ERROR("Parsing error of 'gradientUnits' ==> not suported value: '" << contentX << "' not in : {userSpaceOnUse/objectBoundingBox}");
|
||||
ESVG_ERROR("Parsing error of 'gradientUnits' ==> not suported value: '" << contentX << "' not in : {userSpaceOnUse/objectBoundingBox} use objectBoundingBox");
|
||||
}
|
||||
}
|
||||
contentX = _element->getAttribute("spreadMethod");
|
||||
if (contentX == "reflect") {
|
||||
m_spread = spreadMethod_reflect;
|
||||
} else if (contentX == "repeate") {
|
||||
m_spread = spreadMethod_repeate;
|
||||
} else {
|
||||
// by default we will use "none"
|
||||
m_spread = spreadMethod_pad;
|
||||
if (contentX.size() != 0) {
|
||||
ESVG_ERROR("Parsing error of 'spreadMethod' ==> not suported value: '" << contentX << "' not in : {reflect/repeate/pad} use pad");
|
||||
}
|
||||
}
|
||||
// note: xlink:href is incompatible with subNode "stop"
|
||||
|
@ -10,19 +10,18 @@
|
||||
#define __ESVG_LINEAR_GRANDIENT_H__
|
||||
|
||||
#include <esvg/Base.h>
|
||||
#include <esvg/gradientUnits.h>
|
||||
#include <esvg/spreadMethod.h>
|
||||
|
||||
namespace esvg {
|
||||
class Document;
|
||||
enum gradientUnits {
|
||||
gradientUnits_userSpaceOnUse,
|
||||
gradientUnits_objectBoundingBox
|
||||
};
|
||||
class LinearGradient : public esvg::Base {
|
||||
private:
|
||||
esvg::Dimension m_pos1; //!< gradient position x1 y1
|
||||
esvg::Dimension m_pos2; //!< gradient position x2 y2
|
||||
public:
|
||||
enum gradientUnits m_unit;
|
||||
enum spreadMethod m_spread;
|
||||
private:
|
||||
std::string m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||
std::vector<std::pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
||||
|
22
esvg/cap.cpp
Normal file
22
esvg/cap.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/cap.h>
|
||||
#include <esvg/debug.h>
|
||||
|
||||
static const char* values[] = {
|
||||
"butt",
|
||||
"round",
|
||||
"square"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::cap _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
@ -10,12 +10,17 @@
|
||||
#define __ESVG_CAP_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace esvg {
|
||||
enum cap {
|
||||
cap_butt,
|
||||
cap_round,
|
||||
cap_square
|
||||
};
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::cap _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
21
esvg/gradientUnits.cpp
Normal file
21
esvg/gradientUnits.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/gradientUnits.h>
|
||||
#include <esvg/debug.h>
|
||||
|
||||
static const char* values[] = {
|
||||
"userSpaceOnUse",
|
||||
"objectBoundingBox"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::gradientUnits _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
26
esvg/gradientUnits.h
Normal file
26
esvg/gradientUnits.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ESVG_GRADIENT_UNIT_H__
|
||||
#define __ESVG_GRADIENT_UNIT_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace esvg {
|
||||
enum gradientUnits {
|
||||
gradientUnits_userSpaceOnUse,
|
||||
gradientUnits_objectBoundingBox
|
||||
};
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::gradientUnits _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
22
esvg/join.cpp
Normal file
22
esvg/join.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/join.h>
|
||||
#include <esvg/debug.h>
|
||||
|
||||
static const char* values[] = {
|
||||
"miter",
|
||||
"round",
|
||||
"bevel"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::join _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ namespace esvg {
|
||||
join_round,
|
||||
join_bevel
|
||||
};
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::join _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -49,7 +49,7 @@ etk::Color<float,4> esvg::render::DynamicColorLinear::getColor(const ivec2& _pos
|
||||
return etk::color::purple;
|
||||
}
|
||||
float ratio = 0.0f;
|
||||
if (m_boundingBoxMode == false) {
|
||||
if (m_unit == gradientUnits_userSpaceOnUse) {
|
||||
vec2 vectorBase = m_pos2 - m_pos1;
|
||||
vec2 vectorOrtho(vectorBase.y(), -vectorBase.x());
|
||||
vec2 intersec = getIntersect(m_pos1, vectorBase,
|
||||
@ -129,7 +129,8 @@ void esvg::render::DynamicColorLinear::generate(esvg::Document* _document) {
|
||||
}
|
||||
ESVG_INFO("get for color linear:");
|
||||
gradient->display(2);
|
||||
m_boundingBoxMode = gradient->m_unit == esvg::gradientUnits_objectBoundingBox;
|
||||
m_unit = gradient->m_unit;
|
||||
m_spread = gradient->m_spread;
|
||||
ESVG_INFO(" viewport = {" << m_viewPort.first << "," << m_viewPort.second << "}");
|
||||
vec2 size = m_viewPort.second - m_viewPort.first;
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <etk/Color.h>
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <etk/math/Matrix2.h>
|
||||
#include <esvg/gradientUnits.h>
|
||||
#include <esvg/spreadMethod.h>
|
||||
|
||||
namespace esvg {
|
||||
class Document;
|
||||
@ -48,7 +50,8 @@ namespace esvg {
|
||||
};
|
||||
class DynamicColorLinear : public esvg::render::DynamicColor {
|
||||
public:
|
||||
bool m_boundingBoxMode;
|
||||
esvg::spreadMethod m_spread;
|
||||
esvg::gradientUnits m_unit;
|
||||
std::string m_colorName;
|
||||
mat2 m_matrix;
|
||||
std::pair<vec2, vec2> m_viewPort;
|
||||
|
22
esvg/spreadMethod.cpp
Normal file
22
esvg/spreadMethod.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/spreadMethod.h>
|
||||
#include <esvg/debug.h>
|
||||
|
||||
static const char* values[] = {
|
||||
"pad",
|
||||
"reflect",
|
||||
"repeate"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::spreadMethod _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
27
esvg/spreadMethod.h
Normal file
27
esvg/spreadMethod.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ESVG_SPREAD_METHOD_H__
|
||||
#define __ESVG_SPREAD_METHOD_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace esvg {
|
||||
enum spreadMethod {
|
||||
spreadMethod_pad,
|
||||
spreadMethod_reflect,
|
||||
spreadMethod_repeate
|
||||
};
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::spreadMethod _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -42,6 +42,10 @@ def create(target, module_name):
|
||||
'esvg/Renderer.cpp',
|
||||
'esvg/Stroking.cpp',
|
||||
'esvg/Text.cpp',
|
||||
'esvg/cap.cpp',
|
||||
'esvg/join.cpp',
|
||||
'esvg/spreadMethod.cpp',
|
||||
'esvg/gradientUnits.cpp',
|
||||
'esvg/Dimension.cpp',
|
||||
'esvg/render/Path.cpp',
|
||||
'esvg/render/Element.cpp',
|
||||
@ -83,6 +87,8 @@ def create(target, module_name):
|
||||
'esvg/Text.h',
|
||||
'esvg/cap.h',
|
||||
'esvg/join.h',
|
||||
'esvg/spreadMethod.h',
|
||||
'esvg/gradientUnits.h',
|
||||
'esvg/Dimension.h',
|
||||
'esvg/render/Element.h',
|
||||
'esvg/render/ElementStop.h',
|
||||
|
Loading…
x
Reference in New Issue
Block a user