Skip to content

Commit e353686

Browse files
committed
Extend ofNode for easier transform maintenance
1 parent 648aeda commit e353686

8 files changed

Lines changed: 685 additions & 407 deletions

File tree

addons/ofxSvg/src/ofxSvg.cpp

Lines changed: 263 additions & 173 deletions
Large diffs are not rendered by default.

addons/ofxSvg/src/ofxSvg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ofxSvg : public ofxSvgGroup {
224224
void validateXmlSvgRoot( ofXml& aRootSvgNode );
225225
std::string cleanString( std::string aStr, std::string aReplace );
226226
void _parseXmlNode( ofXml& aParentNode, std::vector< std::shared_ptr<ofxSvgElement> >& aElements );
227-
bool _addElementFromXmlNode( ofXml& tnode, std::vector< std::shared_ptr<ofxSvgElement> >& aElements );
227+
std::shared_ptr<ofxSvgElement> _addElementFromXmlNode( ofXml& tnode, std::vector< std::shared_ptr<ofxSvgElement> >& aElements );
228228

229229
void _parsePolylinePolygon( ofXml& tnode, std::shared_ptr<ofxSvgPath> aSvgPath );
230230
// reference: https://www.w3.org/TR/SVG/paths.html
@@ -239,6 +239,8 @@ class ofxSvg : public ofxSvgGroup {
239239

240240
void _getTextSpanFromXmlNode( ofXml& anode, std::vector< std::shared_ptr<ofxSvgText::TextSpan> >& aspans );
241241

242+
void _setNodeParentGroupStack( std::shared_ptr<ofxSvgElement> aele );
243+
242244
ofxSvgGroup* _getPushedGroup();
243245
bool _hasPushedMatrix();
244246
void _applyModelMatrixToElement( std::shared_ptr<ofxSvgElement> aele, glm::vec2 aDefaultPos );

addons/ofxSvg/src/ofxSvgCss.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ bool ofxSvgCssClass::addProperty( const std::string& aName, const ofColor& acolo
248248
return addProperty(aName, prop );
249249
}
250250

251+
//--------------------------------------------------
252+
bool ofxSvgCssClass::setColor(const ofColor& acolor) {
253+
return addProperty("color", acolor);
254+
}
255+
251256
//--------------------------------------------------
252257
bool ofxSvgCssClass::setFillColor(const ofColor& acolor) {
253258
return addProperty("fill", acolor);
@@ -388,8 +393,13 @@ float ofxSvgCssClass::getFloatValue(const std::string& akey, const float& adefau
388393

389394
//--------------------------------------------------
390395
ofColor ofxSvgCssClass::getColor(const std::string& akey) {
396+
return getColor(akey, ofColor(0));
397+
}
398+
399+
//--------------------------------------------------
400+
ofColor ofxSvgCssClass::getColor(const std::string& akey, const ofColor& adefault) {
391401
if( properties.count(akey) < 1 ) {
392-
return ofColor(0);
402+
return adefault;
393403
}
394404
auto& prop = properties[akey];
395405
if( !prop.cvalue.has_value() ) {

addons/ofxSvg/src/ofxSvgCss.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class ofxSvgCssClass {
8585
bool addProperty( const std::string& aName, const float& avalue );
8686
bool addProperty( const std::string& aName, const ofColor& acolor );
8787

88+
bool setColor(const ofColor& acolor);
89+
8890
bool setFillColor(const ofColor& acolor);
8991
bool setNoFill();
9092
bool isFilled();
@@ -112,6 +114,7 @@ class ofxSvgCssClass {
112114
int getIntValue(const std::string& akey, const int& adefault);
113115
float getFloatValue(const std::string& akey, const float& adefault);
114116
ofColor getColor(const std::string& akey);
117+
ofColor getColor(const std::string& akey, const ofColor& adefault);
115118

116119
std::string toString(bool aBPrettyPrint=true);
117120

0 commit comments

Comments
 (0)