[DEV] start realviewport for gradient

This commit is contained in:
Edouard DUPIN 2015-12-09 22:06:56 +01:00
parent 8415109007
commit 5f6c4bab85
7 changed files with 32 additions and 8 deletions

View File

@ -24,7 +24,7 @@ esvg::PaintState::PaintState() :
lineCap(esvg::cap_butt),
lineJoin(esvg::join_miter),
miterLimit(4.0f),
viewPort(255,255),
viewPort(vec2(0.0f,0.0f), vec2(0.0f,0.0f)),
opacity(1.0) {
}
@ -33,7 +33,8 @@ void esvg::PaintState::clear() {
fill = std::pair<etk::Color<float,4>, std::string>(etk::color::black, "");
stroke = std::pair<etk::Color<float,4>, std::string>(etk::color::none, "");
strokeWidth = 1.0;
viewPort.setValue(255,255);
viewPort.first.setValue(0.0f,0.0f);
viewPort.first.setValue(0.0f,0.0f);
flagEvenOdd = false;
lineJoin = esvg::join_miter;
lineCap = esvg::cap_butt;
@ -190,7 +191,7 @@ float esvg::Base::parseLength(const std::string& _dataInput) {
float font_size = 20.0f;
switch (value.second) {
case esvg::distance_pourcent:
return value.first / 100.0 * m_paint.viewPort.x();
return value.first;// / 100.0 * m_paint.viewPort.x();
case esvg::distance_element:
return value.first * font_size;
case esvg::distance_ex:

View File

@ -47,7 +47,7 @@ namespace esvg {
enum esvg::cap lineCap;
enum esvg::join lineJoin;
float miterLimit;
vec2 viewPort;
std::pair<vec2, vec2> viewPort; //!< min pos, max pos
float opacity;
};

View File

@ -97,4 +97,17 @@ void esvg::LinearGradient::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans,
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::LinearGradient");
}
const esvg::Dimension& esvg::LinearGradient::getPosition1() {
return m_pos1;
}
const esvg::Dimension& esvg::LinearGradient::getPosition2() {
return m_pos2;
}
const std::vector<std::pair<float, etk::Color<float,4>>>& esvg::LinearGradient::getColors() {
return m_data;
}

View File

@ -23,6 +23,10 @@ namespace esvg {
virtual bool parseXML(const std::shared_ptr<exml::Element>& _element, mat2& _parentTrans, vec2& _sizeMax);
virtual void display(int32_t _spacing);
virtual void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level);
public:
const esvg::Dimension& getPosition1();
const esvg::Dimension& getPosition2();
const std::vector<std::pair<float, etk::Color<float,4>>>& getColors();
};
};

View File

@ -40,6 +40,12 @@ void esvg::render::DynamicColorLinear::generate(esvg::Document* _document) {
}
ESVG_INFO("get for color linear:");
gradient->display(2);
esvg::Dimension pos1 = gradient->getPosition1();
esvg::Dimension pos2 = gradient->getPosition2();
std::vector<std::pair<float, etk::Color<float,4>>> data = gradient->getColors();
// ROTATE and many things ...
}

View File

@ -22,7 +22,7 @@ TEST(TestGradientLinear, horizontal) {
" <stop offset='100%' style='stop-color:rgb(255,0,0);stop-opacity:1' />\n"
" </linearGradient>\n"
" </defs>\n"
" <ellipse cx='200' cy='70' rx='85' ry='55' fill='url(#grad1)' />\n"
" <ellipse cx='50' cy='50' rx='50' ry='20' fill='url(#grad1)' />\n"
"</svg>\n");
esvg::Document doc;
doc.parse(data);
@ -40,7 +40,7 @@ TEST(TestGradientLinear, vertical) {
" <stop offset='100%' style='stop-color:rgb(255,0,0);stop-opacity:1' />\n"
" </linearGradient>\n"
" </defs>\n"
" <ellipse cx='200' cy='70' rx='85' ry='55' fill='url(#grad2)' />\n"
" <ellipse cx='50' cy='50' rx='50' ry='20' fill='url(#grad2)' />\n"
"</svg>\n");
esvg::Document doc;
doc.parse(data);

View File

@ -22,7 +22,7 @@ TEST(TestGradientRadial, full) {
" <stop offset='100%' style='stop-color:rgb(0,0,255);stop-opacity:1' />\n"
" </radialGradient>\n"
" </defs>\n"
" <ellipse cx='200' cy='70' rx='85' ry='55' fill='url(#grad1)' />\n"
" <ellipse cx='50' cy='50' rx='50' ry='20' fill='url(#grad1)' />\n"
"</svg>\n");
esvg::Document doc;
doc.parse(data);
@ -40,7 +40,7 @@ TEST(TestGradientRadial, partial) {
" <stop offset='100%' style='stop-color:rgb(0,0,255);stop-opacity:1' />\n"
" </radialGradient>\n"
" </defs>\n"
" <ellipse cx='200' cy='70' rx='85' ry='55' fill='url(#grad2)' />\n"
" <ellipse cx='50' cy='50' rx='50' ry='20' fill='url(#grad2)' />\n"
"</svg>\n");
esvg::Document doc;
doc.parse(data);