@@ -868,53 +868,10 @@ shared_ptr<ofxSvgElement> ofxSvg::_addElementFromXmlNode( ofXml& tnode, vector<
868868// getTransformFromSvgMatrix( transAttr.getValue(), telement->pos, telement->scale.x, telement->scale.y, telement->rotation );
869869 setTransformFromSvgMatrixString ( transAttr.getValue (), telement );
870870 }
871-
872- // std::vector<ofxSvgType> typesToApplyTransformToPath = {
873- // OFXSVG_TYPE_RECTANGLE,
874- // OFXSVG_TYPE_CIRCLE,
875- // OFXSVG_TYPE_ELLIPSE
876- // };
877-
878- // bool bApplyTransformToPath = false;
879- // for( auto & etype : typesToApplyTransformToPath ) {
880- // if( etype == telement->getType() ) {
881- // bApplyTransformToPath = true;
882- // break;
883- // }
884- // }
885-
886- // if( bApplyTransformToPath ) {
887- // auto epath = std::dynamic_pointer_cast<ofxSvgPath>( telement );
888- // auto outlines = epath->path.getOutline();
889- // // auto transform = epath->getTransformMatrix();
890- // auto transform = epath->getGlobalTransformMatrix();
891- // for( auto& outline : outlines ) {
892- // for( auto& v : outline ) {
893- // v = transform * glm::vec4(v, 1.0f);
894- // }
895- // }
896- // // now we have new outlines, what do we do?
897- // epath->path.clear();
898- // bool bFirstOne = true;
899- // for( auto& outline : outlines ) {
900- // for( auto& v : outline ) {
901- // if(bFirstOne) {
902- // bFirstOne = false;
903- // epath->path.moveTo(v);
904- // } else {
905- // epath->path.lineTo(v);
906- // }
907- // }
908- // if( outline.isClosed() ) {
909- // epath->path.close();
910- // }
911- // }
912- // }
913871 }
914872
915873 if ( telement->getType () == OFXSVG_TYPE_TEXT ) {
916874 auto text = std::dynamic_pointer_cast<ofxSvgText>( telement );
917- // text->ogPos = text->pos;
918875 text->create ();
919876 }
920877
@@ -931,9 +888,7 @@ shared_ptr<ofxSvgElement> ofxSvg::_addElementFromXmlNode( ofXml& tnode, vector<
931888 if ( mGroupStack .size () > 0 ) {
932889 auto pgroup = mGroupStack .back ();
933890 ofLogVerbose (" ofxSvg::_addElementFromXmlNode" ) << " element: " << telement->getTypeAsString () << " -" << telement->getCleanName () << " - pos: " << telement->getPosition () << " - parent: " << pgroup->getCleanName ();
934- // telement->setParent(*pgroup.get(), false);
935891 telement->setParent (*_getPushedGroup (), false );
936- // ofLogNotice("");
937892 }
938893
939894 return telement;
@@ -959,21 +914,6 @@ std::vector<float> parseToFloats(const std::string& input) {
959914}
960915
961916std::vector<glm::vec3> parsePoints (const std::string& input) {
962- // std::vector<glm::vec3> points;
963- // std::regex regex("[-]?\\d*\\.?\\d+"); // Matches positive/negative floats
964- // std::sregex_iterator begin(input.begin(), input.end(), regex), end;
965- //
966- // std::vector<float> values;
967- //
968- // // Extract all floating-point values using regex
969- // for (std::sregex_iterator i = begin; i != end; ++i) {
970- // try {
971- // values.push_back(std::stof((*i).str()));
972- // } catch (const std::invalid_argument&) {
973- // std::cerr << "Invalid number found: " << (*i).str() << std::endl;
974- // }
975- // }
976-
977917 std::vector<glm::vec3> points;
978918 auto values = parseToFloats ( input );
979919
@@ -1739,19 +1679,12 @@ void ofxSvg::_parsePath( ofXml& tnode, std::shared_ptr<ofxSvgPath> aSvgPath ) {
17391679 ofLogWarning (" ofxSvg" ) << " unable to parse arc segment." ;
17401680 }
17411681 }
1742-
1743- // prevCmd = commandT;
1744- // mCenterPoints.push_back(currentPos);
1745- // mCPoints.insert( mCPoints.end(), npositions.begin(), npositions.end() );
17461682 }
17471683
17481684// ofLogNotice("ofxSvg") << "["<<cchar<<"]: " << currentString;
17491685
1750-
17511686 justInCase++;
17521687 }
1753-
1754- // mCurrentPathPos = currentPos;
17551688}
17561689
17571690// --------------------------------------------------------------
@@ -2029,23 +1962,6 @@ glm::mat4 ofxSvg::setTransformFromSvgMatrixString( string aStr, std::shared_ptr<
20291962// aele->pos.y = pos3.y;
20301963
20311964 ofLogVerbose (" ofxSvg::setTransformFromSvgMatrixString" ) << " pos: " << aele->getPosition () << " rotation: " << trotation << " scale: " << aele->getScale ();
2032-
2033- // apos.x = matrixF[4];
2034- // apos.y = matrixF[5];
2035- //
2036- // scaleX = std::sqrtf(matrixF[0] * matrixF[0] + matrixF[1] * matrixF[1]) * (float)ofSign(matrixF[0]);
2037- // scaleY = std::sqrtf(matrixF[2] * matrixF[2] + matrixF[3] * matrixF[3]) * (float)ofSign(matrixF[3]);
2038- //
2039- // arotation = glm::degrees( std::atan2f(matrixF[2],matrixF[3]) );
2040- // if( scaleX < 0 && scaleY < 0 ){
2041- //
2042- // }else{
2043- // arotation *= -1.0f;
2044- // }
2045- // cout << " rotation is " << arotation << endl;
2046- // std::cout << "matrix rotation is " << arotation << " ScaleX: " << scaleX << " scaleY: " << scaleY << " apos: " << apos << std::endl;
2047-
2048- // return true;
20491965 }
20501966 }
20511967
@@ -2339,6 +2255,8 @@ std::shared_ptr<ofxSvgRectangle> ofxSvg::add( const ofRectangle& arect ) {
23392255std::shared_ptr<ofxSvgRectangle> ofxSvg::add ( const ofRectangle& arect, float aRoundRadius ) {
23402256 auto rect = std::make_shared<ofxSvgRectangle>();
23412257 rect->setPosition (arect.x , arect.y , 0 .0f );
2258+ rect->width = arect.getWidth ();
2259+ rect->height = arect.getHeight ();
23422260 rect->roundRadius = -1 ; // force setting round
23432261 rect->setRoundRadius (std::max (0 .f ,aRoundRadius));
23442262 rect->applyStyle (mCurrentCss );
@@ -2853,7 +2771,6 @@ bool ofxSvg::_toXml( ofXml& aParentNode, std::shared_ptr<ofxSvgElement> aele ) {
28532771
28542772
28552773 } else if ( aele->getType () == OFXSVG_TYPE_TEXT ) {
2856- // TODO: Maybe at some point ;/
28572774 auto ttext = std::dynamic_pointer_cast<ofxSvgText>(aele);
28582775 for ( auto tspan : ttext->textSpans ) {
28592776 if ( auto spanXml = txml.appendChild (" tspan" )) {
@@ -2870,17 +2787,12 @@ bool ofxSvg::_toXml( ofXml& aParentNode, std::shared_ptr<ofxSvgElement> aele ) {
28702787 }
28712788
28722789 // figure out if we need a transform attribute
2873- // if( aele->getType() == OFXSVG_TYPE_IMAGE || aele->getRotationDeg() != 0.0f || aele->getScale().x != 1.0f || aele->getScale().y != 1.0f ) {
2874- auto matrixString = getSvgMatrixStringFromElement (aele);
2875- if ( !matrixString.empty () ) {
2876- if ( auto xattr = txml.appendAttribute (" transform" )) {
2877- xattr.set (matrixString);
2878- }
2790+ auto matrixString = getSvgMatrixStringFromElement (aele);
2791+ if ( !matrixString.empty () ) {
2792+ if ( auto xattr = txml.appendAttribute (" transform" )) {
2793+ xattr.set (matrixString);
28792794 }
2880- // if( auto xattr = txml.appendAttribute("transform")) {
2881- // xattr.set( getSvgMatrixStringFromElement(aele) );
2882- // }
2883- // }
2795+ }
28842796 return txml;
28852797}
28862798
0 commit comments