Home | History | Annotate | Download | only in svg
      1 /*
      2     Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann (at) kde.org>
      3                   2004, 2005, 2006, 2008 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 SVGPathSegArc_h
     22 #define SVGPathSegArc_h
     23 
     24 #if ENABLE(SVG)
     25 
     26 #include "SVGPathSeg.h"
     27 
     28 namespace WebCore {
     29 
     30     class SVGPathSegArc : public SVGPathSeg {
     31     public:
     32         SVGPathSegArc(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
     33         : m_x(x), m_y(y), m_r1(r1), m_r2(r2), m_angle(angle), m_largeArcFlag(largeArcFlag), m_sweepFlag(sweepFlag) {}
     34 
     35         virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %d %d %.6lg %.6lg", m_r1, m_r2, m_angle, m_largeArcFlag, m_sweepFlag, m_x, m_y); }
     36 
     37         void setX(float x) { m_x = x; }
     38         float x() const { return m_x; }
     39 
     40         void setY(float y) { m_y = y; }
     41         float y() const { return m_y; }
     42 
     43         void setR1(float r1) { m_r1 = r1; }
     44         float r1() const { return m_r1; }
     45 
     46         void setR2(float r2) { m_r2 = r2; }
     47         float r2() const { return m_r2; }
     48 
     49         void setAngle(float angle) { m_angle = angle; }
     50         float angle() const { return m_angle; }
     51 
     52         void setLargeArcFlag(bool largeArcFlag) { m_largeArcFlag = largeArcFlag; }
     53         bool largeArcFlag() const { return m_largeArcFlag; }
     54 
     55         void setSweepFlag(bool sweepFlag) { m_sweepFlag = sweepFlag; }
     56         bool sweepFlag() const { return m_sweepFlag; }
     57 
     58     private:
     59         float m_x;
     60         float m_y;
     61         float m_r1;
     62         float m_r2;
     63         float m_angle;
     64 
     65         bool m_largeArcFlag    : 1;
     66         bool m_sweepFlag : 1;
     67     };
     68 
     69     class SVGPathSegArcAbs : public SVGPathSegArc {
     70     public:
     71         static PassRefPtr<SVGPathSegArcAbs> create(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
     72         {
     73             return adoptRef(new SVGPathSegArcAbs(x, y, r1, r2, angle, largeArcFlag, sweepFlag));
     74         }
     75 
     76         virtual unsigned short pathSegType() const { return PATHSEG_ARC_ABS; }
     77         virtual String pathSegTypeAsLetter() const { return "A"; }
     78 
     79     private:
     80         SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
     81     };
     82 
     83     class SVGPathSegArcRel : public SVGPathSegArc {
     84     public:
     85         static PassRefPtr<SVGPathSegArcRel> create(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
     86         {
     87             return adoptRef(new SVGPathSegArcRel(x, y, r1, r2, angle, largeArcFlag, sweepFlag));
     88         }
     89 
     90         virtual unsigned short pathSegType() const { return PATHSEG_ARC_REL; }
     91         virtual String pathSegTypeAsLetter() const { return "a"; }
     92 
     93     private:
     94         SVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
     95     };
     96 
     97 } // namespace WebCore
     98 
     99 #endif // ENABLE(SVG)
    100 #endif
    101 
    102 // vim:ts=4:noet
    103