Home | History | Annotate | Download | only in svg
      1 /*
      2     Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann (at) kde.org>
      3                   2004, 2005 Rob Buis <buis (at) kde.org>
      4 
      5     This library is free software; you can redistribute it and/or
      6     modify it under the terms of the GNU Library General Public
      7     License as published by the Free Software Foundation; either
      8     version 2 of the License, or (at your option) any later version.
      9 
     10     This library is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13     Library General Public License for more details.
     14 
     15     You should have received a copy of the GNU Library General Public License
     16     along with this library; see the file COPYING.LIB.  If not, write to
     17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18     Boston, MA 02110-1301, USA.
     19 */
     20 
     21 #ifndef SVGTransform_h
     22 #define SVGTransform_h
     23 
     24 #if ENABLE(SVG)
     25 #include "AffineTransform.h"
     26 #include "FloatPoint.h"
     27 #include "SVGNames.h"
     28 
     29 namespace WebCore {
     30 
     31     class FloatSize;
     32 
     33     class SVGTransform {
     34     public:
     35         enum SVGTransformType {
     36             SVG_TRANSFORM_UNKNOWN           = 0,
     37             SVG_TRANSFORM_MATRIX            = 1,
     38             SVG_TRANSFORM_TRANSLATE         = 2,
     39             SVG_TRANSFORM_SCALE             = 3,
     40             SVG_TRANSFORM_ROTATE            = 4,
     41             SVG_TRANSFORM_SKEWX             = 5,
     42             SVG_TRANSFORM_SKEWY             = 6
     43         };
     44 
     45         SVGTransform();
     46         SVGTransform(SVGTransformType);
     47         explicit SVGTransform(const AffineTransform&);
     48         virtual ~SVGTransform();
     49 
     50         SVGTransformType type() const;
     51 
     52         AffineTransform matrix() const;
     53 
     54         float angle() const;
     55         FloatPoint rotationCenter() const;
     56 
     57         void setMatrix(AffineTransform);
     58 
     59         void setTranslate(float tx, float ty);
     60         void setScale(float sx, float sy);
     61         void setRotate(float angle, float cx, float cy);
     62         void setSkewX(float angle);
     63         void setSkewY(float angle);
     64 
     65         // Internal use only (animation system)
     66         FloatPoint translate() const;
     67         FloatSize scale() const;
     68 
     69         bool isValid();
     70 
     71     private:
     72         SVGTransformType m_type;
     73         float m_angle;
     74         FloatPoint m_center;
     75         AffineTransform m_matrix;
     76     };
     77 
     78     inline bool operator==(const SVGTransform& a, const SVGTransform& b)
     79     {
     80         return a.type() == b.type() && a.angle() == b.angle() && a.matrix() == b.matrix();
     81     }
     82 
     83     inline bool operator!=(const SVGTransform& a, const SVGTransform& b)
     84     {
     85         return !(a == b);
     86     }
     87 
     88 } // namespace WebCore
     89 
     90 #endif // ENABLE(SVG)
     91 #endif
     92