X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=share%2Fextensions%2Fsimpletransform.py;h=ec224990b258af2943a635825de1a2e1f6422cda;hb=c978f17cd54294ccf4a3714c0bbda5924ecd6958;hp=983874f7c701e061dba624acd419a208905a6d4e;hpb=519331d368aba3d43cf2c121b14be130ed54ef35;p=inkscape.git diff --git a/share/extensions/simpletransform.py b/share/extensions/simpletransform.py index 983874f7c..ec224990b 100644 --- a/share/extensions/simpletransform.py +++ b/share/extensions/simpletransform.py @@ -1,164 +1,179 @@ -#!/usr/bin/env python -''' -Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -barraud@math.univ-lille1.fr - -This code defines several functions to make handling of transform -attribute easier. -''' -import inkex, cubicsuperpath, bezmisc, simplestyle -import copy, math, re - -def parseTransform(transf,mat=[[1.0,0.0,0.0],[0.0,1.0,0.0]]): - if transf=="" or transf==None: - return(mat) - result=re.match("(translate|scale|rotate|skewX|skewY|matrix)\(([^)]*)\)",transf) -#-- translate -- - if result.group(1)=="translate": - args=result.group(2).split(",") - dx=float(args[0]) - if len(args)==1: - dy=0.0 - else: - dy=float(args[1]) - matrix=[[1,0,dx],[0,1,dy]] -#-- scale -- - if result.groups(1)=="scale": - args=result.group(2).split(",") - sx=float(args[0]) - if len(args)==1: - sy=sx - else: - sy=float(args[1]) - matrix=[[sx,0,0],[0,sy,0]] -#-- rotate -- - if result.groups(1)=="rotate": - args=result.group(2).split(",") - a=float(args[0])*math.pi/180 - if len(args)==1: - cx,cy=(0.0,0.0) - else: - cx,cy=args[1:] - matrix=[[math.cos(a),-math.sin(a),cx],[math.sin(a),math.cos(a),cy]] -#-- skewX -- - if result.groups(1)=="skewX": - a=float(result.group(2))*math.pi/180 - matrix=[[1,math.tan(a),0],[0,1,0]] -#-- skewX -- - if result.groups(1)=="skewX": - a=float(result.group(2))*math.pi/180 - matrix=[[1,0,0],[math.tan(a),1,0]] -#-- matrix -- - if result.group(1)=="matrix": - a11,a21,a12,a22,v1,v2=result.group(2).split(",") - matrix=[[float(a11),float(a12),float(v1)],[float(a21),float(a22),float(v2)]] - - matrix=composeTransform(mat,matrix) - if result.end()