001package com.hfg.svg.filtereffect;
002
003import com.hfg.svg.AbstractSvgNode;
004import com.hfg.svg.SVG;
005import com.hfg.svg.SvgAttr;
006import com.hfg.xml.XMLTag;
007
008//------------------------------------------------------------------------------
009/**
010 Object representation of an SVG (Scalable Vector Graphics) 'feTurbulence' filter effect tag.
011 <div>
012 From <a href='http://www.w3.org/TR/2003/REC-SVG11-20030114/filters.html#feTurbulence'>
013 http://www.w3.org/TR/2003/REC-SVG11-20030114/filters.html#feTurbulence</a>:
014 </div>
015 <div style='font-style:italic'>
016 <p>
017 "This filter primitive creates an image using the Perlin turbulence function.
018 It allows the synthesis of artificial textures like clouds or marble. For a detailed
019 description the of the Perlin turbulence function, see "Texturing and Modeling",
020 Ebert et al, AP Professional, 1994. The resulting image will fill the entire filter
021 primitive subregion for this filter primitive.
022 </p>
023 <p>
024 It is possible to create bandwidth-limited noise by synthesizing only one octave.
025 </p>
026 <p>
027 For fractalSum, you get a turbFunctionResult that is aimed at a range of -1 to 1
028 (the actual result might exceed this range in some cases). To convert to a color value,
029 use the formula colorValue = ((turbFunctionResult * 255) + 255) / 2, then clamp to the range 0 to 255.
030 </p>
031 <p>
032 For turbulence, you get a turbFunctionResult that is aimed at a range of 0 to 1 (the actual
033 result might exceed this range in some cases). To convert to a color value, use the formula
034 colorValue = (turbFunctionResult * 255), then clamp to the range 0 to 255.
035 </p>
036 <p>
037 The following order is used for applying the pseudo random numbers. An initial seed value is
038 computed based on attribute seed. Then the implementation computes the lattice points for R,
039 then continues getting additional pseudo random numbers relative to the last generated pseudo
040 random number and computes the lattice points for G, and so on for B and A.
041 </p>
042 <p>
043 The generated color and alpha values are in the color space determined by the value of
044 property 'color-interpolation-filters'."
045 </p>
046 </div>
047 @author J. Alex Taylor, hairyfatguy.com
048 */
049//------------------------------------------------------------------------------
050// com.hfg XML/HTML Coding Library
051//
052// This library is free software; you can redistribute it and/or
053// modify it under the terms of the GNU Lesser General Public
054// License as published by the Free Software Foundation; either
055// version 2.1 of the License, or (at your option) any later version.
056//
057// This library is distributed in the hope that it will be useful,
058// but WITHOUT ANY WARRANTY; without even the implied warranty of
059// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
060// Lesser General Public License for more details.
061//
062// You should have received a copy of the GNU Lesser General Public
063// License along with this library; if not, write to the Free Software
064// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
065//
066// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
067// jataylor@hairyfatguy.com
068//------------------------------------------------------------------------------
069
070public class SvgFeTurbulence extends AbstractSvgNode
071{
072   //###########################################################################
073   // CONSTRUCTORS
074   //###########################################################################
075
076   //---------------------------------------------------------------------------
077   public SvgFeTurbulence()
078   {
079      super(SVG.feTurbulence);
080   }
081
082   //---------------------------------------------------------------------------
083   public SvgFeTurbulence(XMLTag inXMLTag)
084   {
085      this();
086      initFromXMLTag(inXMLTag);
087   }
088
089   //###########################################################################
090   // PUBLIC METHODS
091   //###########################################################################
092
093   //---------------------------------------------------------------------------
094   public SvgFeTurbulence setBaseFrequency(String inValue)
095   {
096      setAttribute(SvgAttr.baseFrequency, inValue);
097      return this;
098   }
099
100   //---------------------------------------------------------------------------
101   public SvgFeTurbulence setColorInterpolationFilters(ColorInterpolationFilters inValue)
102   {
103      setAttribute(SvgAttr.colorInterpolationFilters, inValue);
104      return this;
105   }
106
107   //---------------------------------------------------------------------------
108   public SvgFeTurbulence setNumOctaves(int inValue)
109   {
110      setAttribute(SvgAttr.numOctaves, inValue);
111      return this;
112   }
113
114   //---------------------------------------------------------------------------
115   public SvgFeTurbulence setSeed(int inValue)
116   {
117      setAttribute(SvgAttr.seed, inValue);
118      return this;
119   }
120
121   //---------------------------------------------------------------------------
122   public SvgFeTurbulence setStitchTiles(boolean inValue)
123   {
124      setAttribute(SvgAttr.stitchTiles, inValue ? "stitch" : "noStitch");
125      return this;
126   }
127
128   //---------------------------------------------------------------------------
129   public SvgFeTurbulence setType(TurbulenceType inValue)
130   {
131      setAttribute(SvgAttr.type, inValue);
132      return this;
133   }
134
135
136   //---------------------------------------------------------------------------
137   public SvgFeTurbulence setHeight(int inValue)
138   {
139      setAttribute(SvgAttr.height, inValue);
140      return this;
141   }
142
143   //---------------------------------------------------------------------------
144   public SvgFeTurbulence setHeight(String inValue)
145   {
146      setAttribute(SvgAttr.height, inValue);
147      return this;
148   }
149
150   //---------------------------------------------------------------------------
151   public SvgFeTurbulence setResult(String inValue)
152   {
153      setAttribute(SvgAttr.result, inValue);
154      return this;
155   }
156
157   //---------------------------------------------------------------------------
158   public SvgFeTurbulence setWidth(int inValue)
159   {
160      setAttribute(SvgAttr.width, inValue);
161      return this;
162   }
163
164   //---------------------------------------------------------------------------
165   public SvgFeTurbulence setWidth(String inValue)
166   {
167      setAttribute(SvgAttr.width, inValue);
168      return this;
169   }
170
171   //---------------------------------------------------------------------------
172   public SvgFeTurbulence setX(int inValue)
173   {
174      setAttribute(SvgAttr.x, inValue);
175      return this;
176   }
177
178   //---------------------------------------------------------------------------
179   public SvgFeTurbulence setX(String inValue)
180   {
181      setAttribute(SvgAttr.x, inValue);
182      return this;
183   }
184
185
186   //---------------------------------------------------------------------------
187   public SvgFeTurbulence setY(int inValue)
188   {
189      setAttribute(SvgAttr.y, inValue);
190      return this;
191   }
192
193   //---------------------------------------------------------------------------
194   public SvgFeTurbulence setY(String inValue)
195   {
196      setAttribute(SvgAttr.y, inValue);
197      return this;
198   }
199
200
201}