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

KHTML

  • khtml
  • svg
SVGFEDisplacementMapElement.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
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
21#include "config.h"
22
23#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
24#include "SVGFEDisplacementMapElement.h"
25
26#include "SVGResourceFilter.h"
27
28namespace WebCore {
29
30SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(const QualifiedName& tagName, Document* doc)
31 : SVGFilterPrimitiveStandardAttributes(tagName, doc)
32 , m_xChannelSelector(SVG_CHANNEL_A)
33 , m_yChannelSelector(SVG_CHANNEL_A)
34 , m_scale(0.0f)
35 , m_filterEffect(0)
36{
37}
38
39SVGFEDisplacementMapElement::~SVGFEDisplacementMapElement()
40{
41 delete m_filterEffect;
42}
43
44ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
45ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2)
46ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, XChannelSelector, xChannelSelector, SVGNames::xChannelSelectorAttr, m_xChannelSelector)
47ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, YChannelSelector, yChannelSelector, SVGNames::yChannelSelectorAttr, m_yChannelSelector)
48ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, float, Number, number, Scale, scale, SVGNames::scaleAttr, m_scale)
49
50SVGChannelSelectorType SVGFEDisplacementMapElement::stringToChannel(const String& key)
51{
52 if (key == "R")
53 return SVG_CHANNEL_R;
54 else if (key == "G")
55 return SVG_CHANNEL_G;
56 else if (key == "B")
57 return SVG_CHANNEL_B;
58 else if (key == "A")
59 return SVG_CHANNEL_A;
60
61 return SVG_CHANNEL_UNKNOWN;
62}
63
64void SVGFEDisplacementMapElement::parseMappedAttribute(MappedAttribute* attr)
65{
66 const String& value = attr->value();
67 if (attr->name() == SVGNames::xChannelSelectorAttr)
68 setXChannelSelectorBaseValue(stringToChannel(value));
69 else if (attr->name() == SVGNames::yChannelSelectorAttr)
70 setYChannelSelectorBaseValue(stringToChannel(value));
71 else if (attr->name() == SVGNames::inAttr)
72 setIn1BaseValue(value);
73 else if (attr->name() == SVGNames::in2Attr)
74 setIn2BaseValue(value);
75 else if (attr->name() == SVGNames::scaleAttr)
76 setScaleBaseValue(value.toFloat());
77 else
78 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
79}
80
81SVGFEDisplacementMap* SVGFEDisplacementMapElement::filterEffect(SVGResourceFilter* filter) const
82{
83 if (!m_filterEffect)
84 m_filterEffect = new SVGFEDisplacementMap(filter);
85
86 m_filterEffect->setXChannelSelector((SVGChannelSelectorType) xChannelSelector());
87 m_filterEffect->setYChannelSelector((SVGChannelSelectorType) yChannelSelector());
88 m_filterEffect->setIn(in1());
89 m_filterEffect->setIn2(in2());
90 m_filterEffect->setScale(scale());
91
92 setStandardAttributes(m_filterEffect);
93 return m_filterEffect;
94}
95
96}
97
98#endif // ENABLE(SVG)
99
100// vim:ts=4:noet
SVGFEDisplacementMapElement.h
SVGResourceFilter.h
WebCore
Definition: CSSHelper.h:7
WebCore::String
DOM::DOMString String
Definition: PlatformString.h:8
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