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

KHTML

  • 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
30using namespace KJS;
31using namespace WebCore;
32
33namespace khtml {
34
35JSValue* 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
43JSValue* 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
54JSValue* 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
64JSValue* 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
72JSValue* 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
82JSValue* 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
90JSValue* 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
105JSValue* 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
111JSValue* 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
117JSValue* 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
125JSValue* 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
AffineTransform.h
SVGException.h
WebCore::AffineTransform
Definition: AffineTransform.h:47
KJS
Definition: dom_node.h:37
WebCore
Definition: CSSHelper.h:7
khtml
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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