Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 2øªjÞ#ã@sŽdZddlmZddddgZdZdeZdeZd d „ZGd d„deƒZeƒZ dd d„Z ddd„Z e dkrŠdd l Z dd lZe jejƒjƒd S)aºAffine 2D transformation matrix class. The Transform class implements various transformation matrix operations, both on the matrix itself, as well as on 2D coordinates. Transform instances are effectively immutable: all methods that operate on the transformation itself always return a new instance. This has as the interesting side effect that Transform instances are hashable, ie. they can be used as dictionary keys. This module exports the following symbols: Transform -- this is the main class Identity -- Transform instance set to the identity transformation Offset -- Convenience function that returns a translating transformation Scale -- Convenience function that returns a scaling transformation Examples: >>> t = Transform(2, 0, 0, 3, 0, 0) >>> t.transformPoint((100, 100)) (200, 300) >>> t = Scale(2, 3) >>> t.transformPoint((100, 100)) (200, 300) >>> t.transformPoint((0, 0)) (0, 0) >>> t = Offset(2, 3) >>> t.transformPoint((100, 100)) (102, 103) >>> t.transformPoint((0, 0)) (2, 3) >>> t2 = t.scale(0.5) >>> t2.transformPoint((100, 100)) (52.0, 53.0) >>> import math >>> t3 = t2.rotate(math.pi / 2) >>> t3.transformPoint((0, 0)) (2.0, 3.0) >>> t3.transformPoint((100, 100)) (-48.0, 53.0) >>> t = Identity.scale(0.5).translate(100, 200).skew(0.1, 0.2) >>> t.transformPoints([(0, 0), (1, 1), (100, 100)]) [(50.0, 100.0), (50.550167336042726, 100.60135501775433), (105.01673360427253, 160.13550177543362)] >>> é)Ú NamedTupleÚ TransformÚIdentityÚOffsetÚScalegV瞯Ò<écCs0t|ƒtkrd}n|tkr d}n |tkr,d}|S)Nrréÿÿÿÿ)ÚabsÚ_EPSILONÚ _ONE_EPSILONÚ_MINUS_ONE_EPSILON)Úv©rú=/tmp/pip-build-_d5lkt3n/fonttools/fontTools/misc/transform.pyÚ _normSinCos;s rc@s¸eZdZUdZdZedZedZedZedZ e dZ e dd„Z dd„Z dd „Z d d „Zd!d d „Zd"dd„Zdd„Zd#dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „ZdS)$raw2x2 transformation matrix plus offset, a.k.a. Affine transform. Transform instances are immutable: all transforming methods, eg. rotate(), return a new Transform instance. Examples: >>> t = Transform() >>> t >>> t.scale(2) >>> t.scale(2.5, 5.5) >>> >>> t.scale(2, 3).transformPoint((100, 100)) (200, 300) Transform's constructor takes six arguments, all of which are optional, and can be used as keyword arguments: >>> Transform(12) >>> Transform(dx=12) >>> Transform(yx=12) Transform instances also behave like sequences of length 6: >>> len(Identity) 6 >>> list(Identity) [1, 0, 0, 1, 0, 0] >>> tuple(Identity) (1, 0, 0, 1, 0, 0) Transform instances are comparable: >>> t1 = Identity.scale(2, 3).translate(4, 6) >>> t2 = Identity.translate(8, 18).scale(2, 3) >>> t1 == t2 1 But beware of floating point rounding errors: >>> t1 = Identity.scale(0.2, 0.3).translate(0.4, 0.6) >>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3) >>> t1 >>> t2 >>> t1 == t2 0 Transform instances are hashable, meaning you can use them as keys in dictionaries: >>> d = {Scale(12, 13): None} >>> d {: None} But again, beware of floating point rounding errors: >>> t1 = Identity.scale(0.2, 0.3).translate(0.4, 0.6) >>> t2 = Identity.translate(0.08, 0.18).scale(0.2, 0.3) >>> t1 >>> t2 >>> d = {t1: None} >>> d {: None} >>> d[t2] Traceback (most recent call last): File "", line 1, in ? KeyError: rrc Cs@|\}}|\}}}}}} |||||||||| fS)z‹Transform a point. Example: >>> t = Transform() >>> t = t.scale(2.5, 5.5) >>> t.transformPoint((100, 100)) (250.0, 550.0) r) ÚselfÚpÚxÚyÚxxÚxyÚyxÚyyÚdxÚdyrrrÚtransformPoint•s zTransform.transformPointcs,|\‰‰‰‰‰‰‡‡‡‡‡‡fdd„|DƒS)z·Transform a list of points. Example: >>> t = Scale(2, 3) >>> t.transformPoints([(0, 0), (0, 100), (100, 100), (100, 0)]) [(0, 0), (0, 300), (200, 300), (200, 0)] >>> cs8g|]0\}}ˆ|ˆ|ˆˆ|ˆ|ˆf‘qSrr)Ú.0rr)rrrrrrrrú ¬sz-Transform.transformPoints..r)rZpointsr)rrrrrrrÚtransformPoints¢s zTransform.transformPointscCs<|\}}|dd…\}}}}||||||||fS)z§Transform an (dx, dy) vector, treating translation as zero. Example: >>> t = Transform(2, 0, 0, 2, 10, 20) >>> t.transformVector((3, -4)) (6, -8) >>> Nér)rr rrrrrrrrrÚtransformVector®s zTransform.transformVectorcs,|dd…\‰‰‰‰‡‡‡‡fdd„|DƒS)zÇTransform a list of (dx, dy) vector, treating translation as zero. Example: >>> t = Transform(2, 0, 0, 2, 10, 20) >>> t.transformVectors([(3, -4), (5, -6)]) [(6, -8), (10, -12)] >>> Nrcs0g|](\}}ˆ|ˆ|ˆ|ˆ|f‘qSrr)rrr)rrrrrrrÅsz.Transform.transformVectors..r)rZvectorsr)rrrrrÚtransformVectors»s zTransform.transformVectorscCs|jdddd||fƒS)z Return a new transformation, translated (offset) by x, y. Example: >>> t = Transform() >>> t.translate(20, 30) >>> rr)Ú transform)rrrrrrÚ translateÇs zTransform.translateNcCs"|dkr |}|j|dd|ddfƒS)a Return a new transformation, scaled by x, y. The 'y' argument may be None, which implies to use the x value for y as well. Example: >>> t = Transform() >>> t.scale(5) >>> t.scale(5, 6) >>> Nr)r")rrrrrrÚscaleÒs zTransform.scalecCs<ddl}t|j|ƒƒ}t|j|ƒƒ}|j||| |ddfƒS)zµReturn a new transformation, rotated by 'angle' (radians). Example: >>> import math >>> t = Transform() >>> t.rotate(math.pi / 2) >>> rN)ÚmathrÚcosÚsinr")rZangler%ÚcÚsrrrÚrotateâs zTransform.rotatecCs*ddl}|jd|j|ƒ|j|ƒdddfƒS)z§Return a new transformation, skewed by x and y. Example: >>> import math >>> t = Transform() >>> t.skew(math.pi / 4) >>> rNr)r%r"Útan)rrrr%rrrÚskewñs zTransform.skewc Cs„|\}}}}}}|\}} } } } } |j|||| || || |||| || || ||| || | || || ƒS)zÈReturn a new transformation, transformed by another transformation. Example: >>> t = Transform(2, 0, 0, 3, 1, 6) >>> t.transform((4, 3, 2, 1, 5, 6)) >>> )Ú __class__)rÚotherÚxx1Úxy1Úyx1Úyy1Údx1Údy1Úxx2Úxy2Úyx2Úyy2Údx2Údy2rrrr"þs zTransform.transformc Cs„|\}}}}}}|\}} } } } } |j|||| || || |||| || || ||| || | || || ƒS)a†Return a new transformation, which is the other transformation transformed by self. self.reverseTransform(other) is equivalent to other.transform(self). Example: >>> t = Transform(2, 0, 0, 3, 1, 6) >>> t.reverseTransform((4, 3, 2, 1, 5, 6)) >>> Transform(4, 3, 2, 1, 5, 6).transform((2, 0, 0, 3, 1, 6)) >>> )r-)rr.r/r0r1r2r3r4r5r6r7r8r9r:rrrÚreverseTransforms zTransform.reverseTransformcCsŽ|tkr |S|\}}}}}}||||}||| || |||f\}}}}| |||| |||}}|j||||||ƒS)zãReturn the inverse transformation. Example: >>> t = Identity.translate(2, 3).scale(4, 5) >>> t.transformPoint((10, 20)) (42, 103) >>> it = t.inverse() >>> it.transformPoint((42, 103)) (10.0, 20.0) >>> )rr-)rrrrrrrZdetrrrÚinverse)s (&zTransform.inversecCsd|S)z�Return a PostScript representation: >>> t = Identity.scale(2, 3).translate(4, 5) >>> t.toPS() '[2 0 0 3 8 15]' >>> z[%s %s %s %s %s %s]r)rrrrÚtoPS=szTransform.toPScCs|tkS)aReturns True if transform is not identity, False otherwise. >>> bool(Identity) False >>> bool(Transform()) False >>> bool(Scale(1.)) False >>> bool(Scale(2)) True >>> bool(Offset()) False >>> bool(Offset(0)) False >>> bool(Offset(2)) True )r)rrrrÚ__bool__FszTransform.__bool__cCsd|jjf|S)Nz<%s [%g %g %g %g %g %g]>)r-Ú__name__)rrrrÚ__repr__YszTransform.__repr__)rr)rN)rr)r?Ú __module__Ú __qualname__Ú__doc__rÚfloatrrrrrrrr r!r#r$r*r,r"r;r<r=r>r@rrrrrEs* G      cCstdddd||ƒS)ztReturn the identity transformation offset by x, y. Example: >>> Offset(2, 3) >>> rr)r)rrrrrr_sNcCs|dkr |}t|dd|ddƒS)zÂReturn the identity transformation scaled by x, y. The 'y' argument may be None, which implies to use the x value for y as well. Example: >>> Scale(2, 3) >>> Nr)r)rrrrrris Ú__main__r)rr)N)rCÚtypingrÚ__all__r r r rrrrrr?ÚsysÚdoctestÚexitÚtestmodÚfailedrrrrÚ.s