• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • svg
SVGTransform.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3  2004, 2005 Rob Buis <buis@kde.org>
4 
5  This file is part of the KDE project
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #include "config.h"
24 #include "wtf/Platform.h"
25 #if ENABLE(SVG)
26 
27 #include "FloatPoint.h"
28 #include "FloatSize.h"
29 #include "SVGAngle.h"
30 #include "SVGSVGElement.h"
31 #include "SVGTransform.h"
32 
33 #include <math.h>
34 
35 using namespace WebCore;
36 
37 SVGTransform::SVGTransform()
38  : m_type(SVG_TRANSFORM_UNKNOWN)
39  , m_angle(0)
40 {
41 }
42 
43 SVGTransform::SVGTransform(SVGTransformType type)
44  : m_type(type)
45  , m_angle(0)
46  , m_center(FloatPoint())
47  , m_matrix(AffineTransform())
48 {
49 }
50 
51 SVGTransform::SVGTransform(const AffineTransform& matrix)
52  : m_type(SVG_TRANSFORM_MATRIX)
53  , m_angle(0)
54  , m_matrix(matrix)
55 {
56 }
57 
58 SVGTransform::~SVGTransform()
59 {
60 }
61 
62 bool SVGTransform::isValid()
63 {
64  return (m_type != SVG_TRANSFORM_UNKNOWN);
65 }
66 
67 SVGTransform::SVGTransformType SVGTransform::type() const
68 {
69  return m_type;
70 }
71 
72 AffineTransform SVGTransform::matrix() const
73 {
74  return m_matrix;
75 }
76 
77 float SVGTransform::angle() const
78 {
79  return m_angle;
80 }
81 
82 FloatPoint SVGTransform::rotationCenter() const
83 {
84  return m_center;
85 }
86 
87 void SVGTransform::setMatrix(const AffineTransform& matrix)
88 {
89  m_type = SVG_TRANSFORM_MATRIX;
90  m_angle = 0;
91 
92  m_matrix = matrix;
93 }
94 
95 void SVGTransform::setTranslate(float tx, float ty)
96 {
97  m_type = SVG_TRANSFORM_TRANSLATE;
98  m_angle = 0;
99 
100  m_matrix.reset();
101  m_matrix.translate(tx, ty);
102 }
103 
104 FloatPoint SVGTransform::translate() const
105 {
106  return FloatPoint::narrowPrecision(m_matrix.e(), m_matrix.f());
107 }
108 
109 void SVGTransform::setScale(float sx, float sy)
110 {
111  m_type = SVG_TRANSFORM_SCALE;
112  m_angle = 0;
113  m_center = FloatPoint();
114 
115  m_matrix.reset();
116  m_matrix.scale(sx, sy);
117 }
118 
119 FloatSize SVGTransform::scale() const
120 {
121  return FloatSize::narrowPrecision(m_matrix.a(), m_matrix.d());
122 }
123 
124 void SVGTransform::setRotate(float angle, float cx, float cy)
125 {
126  m_type = SVG_TRANSFORM_ROTATE;
127  m_angle = angle;
128  m_center = FloatPoint(cx, cy);
129 
130  // TODO: toString() implementation, which can show cx, cy (need to be stored?)
131  m_matrix.reset();
132  m_matrix.translate(cx, cy);
133  m_matrix.rotate(angle);
134  m_matrix.translate(-cx, -cy);
135 }
136 
137 void SVGTransform::setSkewX(float angle)
138 {
139  m_type = SVG_TRANSFORM_SKEWX;
140  m_angle = angle;
141 
142  m_matrix.reset();
143  m_matrix.skewX(angle);
144 }
145 
146 void SVGTransform::setSkewY(float angle)
147 {
148  m_type = SVG_TRANSFORM_SKEWY;
149  m_angle = angle;
150 
151  m_matrix.reset();
152  m_matrix.skewY(angle);
153 }
154 
155 // vim:ts=4:noet
156 #endif // ENABLE(SVG)
157 
SVGAngle.h
WebCore::FloatSize
Definition: FloatSize.h:48
SVGSVGElement.h
WebCore::AffineTransform::reset
void reset()
Definition: AffineTransformQt.cpp:138
WebCore::FloatPoint
Definition: FloatPoint.h:61
WebCore::AffineTransform
Definition: AffineTransform.h:47
FloatPoint.h
SVGTransform.h
FloatSize.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal