Remove some error in the svg parser
This commit is contained in:
parent
ded1d04f55
commit
423fa82e2f
@ -291,27 +291,32 @@ void svg::Base::ParsePaintAttr(const TiXmlNode *node)
|
||||
for( const char *sss=extractPartOfStyle(content, outputType, outputValue, 1024);
|
||||
NULL != sss;
|
||||
sss=extractPartOfStyle(sss, outputType, outputValue, 1024) ) {
|
||||
//SVG_INFO(" style parse : \"" << outputType << "\" with value : \"" << outputValue << "\"");
|
||||
SVG_INFO(" style parse : \"" << outputType << "\" with value : \"" << outputValue << "\"");
|
||||
if (0 == strcmp(outputType, "fill") ) {
|
||||
m_paint.fill = ParseColor(outputValue);
|
||||
SVG_ERROR(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
|
||||
} else if (0 == strcmp(outputType, "stroke") ) {
|
||||
m_paint.stroke = ParseColor(outputValue);
|
||||
SVG_ERROR(" input : \"" << outputValue << "\" ==> " << m_paint.stroke);
|
||||
} else if (0 == strcmp(outputType, "stroke-width") ) {
|
||||
m_paint.strokeWidth = ParseLength(outputValue);
|
||||
//SVG_ERROR(" input : \"" << outputValue << "\" ==> " <<m_paint.strokeWidth);
|
||||
SVG_ERROR(" input : \"" << outputValue << "\" ==> " << m_paint.strokeWidth);
|
||||
} else if (0 == strcmp(outputType, "opacity") ) {
|
||||
etkFloat_t opacity = ParseLength(outputValue);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.alpha = opacity*0xFF;
|
||||
m_paint.stroke.alpha = opacity*0xFF;
|
||||
SVG_ERROR(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
|
||||
} else if (0 == strcmp(outputType, "fill-opacity") ) {
|
||||
etkFloat_t opacity = ParseLength(outputValue);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.alpha = opacity*0xFF;
|
||||
SVG_ERROR(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
|
||||
} else if (0 == strcmp(outputType, "stroke-opacity") ) {
|
||||
etkFloat_t opacity = ParseLength(outputValue);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.stroke.alpha = opacity*0xFF;
|
||||
SVG_ERROR(" input : \"" << outputValue << "\" ==> " << m_paint.stroke);
|
||||
} else if (0 == strcmp(outputType, "fill-rule") ) {
|
||||
if (0 == strcmp(outputValue, "nonzero") ) {
|
||||
m_paint.flagEvenOdd = false;
|
||||
|
@ -128,7 +128,13 @@ bool svg::Path::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, coord2D_
|
||||
break;
|
||||
}
|
||||
pathElement.cmd = svg::PATH_ENUM_MOVETO;
|
||||
for(int32_t iii=0; iii<listDot.Size(); iii+=2) {
|
||||
if (listDot.Size() >= 2) {
|
||||
pathElement.element[0] = listDot[0];
|
||||
pathElement.element[1] = listDot[1];
|
||||
m_listElement.PushBack(pathElement);
|
||||
}
|
||||
pathElement.cmd = svg::PATH_ENUM_LINETO;
|
||||
for(int32_t iii=2; iii<listDot.Size(); iii+=2) {
|
||||
pathElement.element[0] = listDot[iii];
|
||||
pathElement.element[1] = listDot[iii+1];
|
||||
m_listElement.PushBack(pathElement);
|
||||
@ -286,6 +292,54 @@ bool svg::Path::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, coord2D_
|
||||
void svg::Path::Display(int32_t spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Path");
|
||||
for(int32_t iii=0; iii<m_listElement.Size(); iii++) {
|
||||
switch (m_listElement[iii].cmd) {
|
||||
case PATH_ENUM_STOP:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "STOP");
|
||||
break;
|
||||
case PATH_ENUM_MOVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "MOVETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_LINETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "LINETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_LINETO_H:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "LINETO_H (" << m_listElement[iii].element[0] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_LINETO_V:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "LINETO_V (" << m_listElement[iii].element[0] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] <<
|
||||
"," << m_listElement[iii].element[4] <<
|
||||
"," << m_listElement[iii].element[5] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_SMOTH_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "SMOTH_CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_BEZIER_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "BEZIER_CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_BEZIER_SMOTH_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "BEZIER_SMOTH_CURVETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_ELLIPTIC:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "ELLIPTIC (TODO...)" );
|
||||
break;
|
||||
default:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "????" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,6 +198,7 @@ svg::Parser::Parser(etk::File fileName) : m_renderedElement(NULL)
|
||||
if (NULL != fileBuffer) {
|
||||
delete[] fileBuffer;
|
||||
}
|
||||
DisplayDebug();
|
||||
}
|
||||
|
||||
svg::Parser::~Parser(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user