+//matrices
+Matrix*
+Svg_parser::parser_transform(const String transform){
+ Matrix* a=NULL;
+ String tf(transform);
+ removeIntoS(&tf);
+ std::vector<String> tokens=tokenize(tf," ");
+ std::vector<String>::iterator aux=tokens.begin();
+ while(aux!=tokens.end()){
+ if((*aux).compare(0,9,"translate")==0){
+ float dx,dy;
+ int start,end;
+ start =(*aux).find_first_of("(")+1;
+ end =(*aux).find_first_of(",");
+ dx =atof((*aux).substr(start,end-start).data());
+ start =(*aux).find_first_of(",")+1;
+ end =(*aux).size()-1;
+ dy =atof((*aux).substr(start,end-start).data());
+ if(matrixIsNull(a))
+ a=newMatrix(1,0,0,1,dx,dy);
+ else
+ multiplyMatrix(&a,newMatrix(1,0,0,1,dx,dy));
+ }else if((*aux).compare(0,5,"scale")==0){
+ if(matrixIsNull(a))
+ a=newMatrix(1,0,0,1,0,0);
+ }else if((*aux).compare(0,6,"rotate")==0){
+ float angle,seno,coseno;
+ int start,end;
+ start =(*aux).find_first_of("(")+1;
+ end =(*aux).size()-1;
+ angle=getRadian (atof((*aux).substr(start,end-start).data()));
+ seno =sin(angle);
+ coseno =cos(angle);
+ if(matrixIsNull(a))
+ a=newMatrix(coseno,seno,-1*seno,coseno,0,0);
+ else
+ multiplyMatrix(&a,newMatrix(coseno,seno,-1*seno,coseno,0,0));
+ }else if((*aux).compare(0,6,"matrix")==0){
+ int start =(*aux).find_first_of('(')+1;
+ int end =(*aux).find_first_of(')');
+ if(matrixIsNull(a))
+ a=newMatrix((*aux).substr(start,end-start));
+ else
+ multiplyMatrix(&a,newMatrix((*aux).substr(start,end-start)));
+ }else{
+ a=newMatrix(1,0,0,1,0,0);
+ }
+ aux++;
+ }
+ return a;
+}
+
+Matrix*
+Svg_parser::newMatrix(Matrix *a){
+ Matrix* data;
+ data=(Matrix*)malloc(sizeof(Matrix));
+ data->a=a->a; data->b=a->b; data->c=a->c;
+ data->d=a->d; data->e=a->e; data->f=a->f;
+ return data;
+}
+Matrix*
+Svg_parser::newMatrix(float a,float b,float c,float d,float e,float f){
+ Matrix* data;
+ data=(Matrix*)malloc(sizeof(Matrix));
+ data->a=a; data->b=b; data->c=c;
+ data->d=d; data->e=e; data->f=f;
+ return data;
+}
+Matrix*
+Svg_parser::newMatrix(const String mvector){
+ if(!mvector.empty()){
+ Matrix* data=(Matrix*)malloc(sizeof(Matrix));
+ std::vector<String> tokens=tokenize(mvector,",");
+ if(tokens.size()!=6) return newMatrix(1,0,0,1,0,0);
+ data->a=atof(tokens.at(0).data());
+ data->b=atof(tokens.at(1).data());
+ data->c=atof(tokens.at(2).data());
+ data->d=atof(tokens.at(3).data());
+ data->e=atof(tokens.at(4).data());
+ data->f=atof(tokens.at(5).data());
+ return data;
+ }else{
+ return newMatrix(1,0,0,1,0,0);
+ }
+}
+void
+Svg_parser::transformPoint2D(Matrix *mtx,float *a,float *b){
+ float auxa,auxb;
+ auxa=0;
+ auxb=0;
+ auxa= (*a)*(mtx->a) + (*b)*(mtx->c) + (mtx->e);
+ auxb= (*a)*(mtx->b) + (*b)*(mtx->d) + (mtx->f);
+ *a=auxa;
+ *b=auxb;
+ return;
+}
+void
+Svg_parser::composeMatrix(Matrix **mtx,Matrix* mtx1,Matrix* mtx2){
+ Matrix* aux=newMatrix(0,0,0,0,0,0);
+ aux->a=(mtx1->a)*(mtx2->a)+(mtx1->c)*(mtx2->b);
+ aux->b=(mtx1->b)*(mtx2->a)+(mtx1->d)*(mtx2->b);
+ aux->c=(mtx1->a)*(mtx2->c)+(mtx1->c)*(mtx2->d);
+ aux->d=(mtx1->b)*(mtx2->c)+(mtx1->d)*(mtx2->d);
+ aux->e=(mtx1->a)*(mtx2->e)+(mtx1->c)*(mtx2->f)+(mtx1->e);
+ aux->f=(mtx1->b)*(mtx2->e)+(mtx1->d)*(mtx2->f)+(mtx1->f);
+ *mtx=aux;
+}
+void
+Svg_parser::multiplyMatrix(Matrix **mtx1,Matrix *mtx2){
+ Matrix* aux=newMatrix(0,0,0,0,0,0);
+ aux->a=((*mtx1)->a)*(mtx2->a)+((*mtx1)->c)*(mtx2->b);
+ aux->b=((*mtx1)->b)*(mtx2->a)+((*mtx1)->d)*(mtx2->b);
+ aux->c=((*mtx1)->a)*(mtx2->c)+((*mtx1)->c)*(mtx2->d);
+ aux->d=((*mtx1)->b)*(mtx2->c)+((*mtx1)->d)*(mtx2->d);
+ aux->e=((*mtx1)->a)*(mtx2->e)+((*mtx1)->c)*(mtx2->f)+((*mtx1)->e);
+ aux->f=((*mtx1)->b)*(mtx2->e)+((*mtx1)->d)*(mtx2->f)+((*mtx1)->f);
+ (*mtx1)->a=aux->a;
+ (*mtx1)->b=aux->b;
+ (*mtx1)->c=aux->c;
+ (*mtx1)->d=aux->d;
+ (*mtx1)->e=aux->e;
+ (*mtx1)->f=aux->f;
+}
+bool
+Svg_parser::matrixIsNull(Matrix *mtx){
+ if(mtx == NULL) return true;
+ return false;
+}
+
+/* === EXTRA METHODS ======================================================= */
+