• 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
  • bindings
  • js
JSSVGMatrixCustom.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include "config.h"
21 #include "wtf/Platform.h"
22 
23 #if ENABLE(SVG)
24 
25 #include "JSSVGMatrix.h"
26 
27 #include "AffineTransform.h"
28 #include "SVGException.h"
29 
30 using namespace KJS;
31 using namespace WebCore;
32 
33 namespace khtml {
34 
35 JSValue* JSSVGMatrix::multiply(ExecState* exec, const List& args)
36 {
37  AffineTransform imp(*impl());
38 
39  AffineTransform secondMatrix = toSVGMatrix(args[0]);
40  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.multiply(secondMatrix)), m_context.get());
41 }
42 
43 JSValue* JSSVGMatrix::inverse(ExecState* exec, const List&)
44 {
45  AffineTransform imp(*impl());
46  KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.inverse()), m_context.get());
47 
48  if (!imp.isInvertible())
49  setDOMException(exec, SVGException::SVG_MATRIX_NOT_INVERTABLE);
50 
51  return result;
52 }
53 
54 JSValue* JSSVGMatrix::translate(ExecState* exec, const List& args)
55 {
56  AffineTransform imp(*impl());
57 
58  float x = args[0]->toFloat(exec);
59  float y = args[1]->toFloat(exec);
60 
61  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.translate(x, y)), m_context.get());
62 }
63 
64 JSValue* JSSVGMatrix::scale(ExecState* exec, const List& args)
65 {
66  AffineTransform imp(*impl());
67 
68  float scaleFactor = args[0]->toFloat(exec);
69  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.scale(scaleFactor)), m_context.get());
70 }
71 
72 JSValue* JSSVGMatrix::scaleNonUniform(ExecState* exec, const List& args)
73 {
74  AffineTransform imp(*impl());
75 
76  float scaleFactorX = args[0]->toFloat(exec);
77  float scaleFactorY = args[1]->toFloat(exec);
78 
79  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.scaleNonUniform(scaleFactorX, scaleFactorY)), m_context.get());
80 }
81 
82 JSValue* JSSVGMatrix::rotate(ExecState* exec, const List& args)
83 {
84  AffineTransform imp(*impl());
85 
86  float angle = args[0]->toFloat(exec);
87  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.rotate(angle)), m_context.get());
88 }
89 
90 JSValue* JSSVGMatrix::rotateFromVector(ExecState* exec, const List& args)
91 {
92  AffineTransform imp(*impl());
93 
94  float x = args[0]->toFloat(exec);
95  float y = args[1]->toFloat(exec);
96 
97  KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.rotateFromVector(x, y)), m_context.get());
98 
99  if (x == 0.0 || y == 0.0)
100  setDOMException(exec, SVGException::SVG_INVALID_VALUE_ERR);
101 
102  return result;
103 }
104 
105 JSValue* JSSVGMatrix::flipX(ExecState* exec, const List&)
106 {
107  AffineTransform imp(*impl());
108  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.flipX()), m_context.get());
109 }
110 
111 JSValue* JSSVGMatrix::flipY(ExecState* exec, const List&)
112 {
113  AffineTransform imp(*impl());
114  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.flipY()), m_context.get());
115 }
116 
117 JSValue* JSSVGMatrix::skewX(ExecState* exec, const List& args)
118 {
119  AffineTransform imp(*impl());
120 
121  float angle = args[0]->toFloat(exec);
122  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.skewX(angle)), m_context.get());
123 }
124 
125 JSValue* JSSVGMatrix::skewY(ExecState* exec, const List& args)
126 {
127  AffineTransform imp(*impl());
128 
129  float angle = args[0]->toFloat(exec);
130  return toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>(imp.skewY(angle)), m_context.get());
131 }
132 
133 }
134 
135 #endif // ENABLE(SVG)
136 
137 // vim:ts=4:noet
WebCore::AffineTransform
Definition: AffineTransform.h:47
AffineTransform.h
SVGException.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:21 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