Gnash  0.8.11dev
LineStyle.h
Go to the documentation of this file.
1 // LineStyle.h Line style types.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 // Based on public domain work by Thatcher Ulrich <tu@tulrich.com> 2003
21 
22 #ifndef GNASH_LINESTYLE_H
23 #define GNASH_LINESTYLE_H
24 
25 #include "RGBA.h"
26 #include "SWF.h"
27 
28 namespace gnash {
29  class SWFStream;
30  class movie_definition;
31  class RunResources;
32 }
33 
34 namespace gnash {
35 
36 enum CapStyle {
37  CAP_ROUND = 0,
38  CAP_NONE = 1,
40 };
41 
42 enum JoinStyle {
46 };
47 
49 class LineStyle
50 {
51 public:
52 
54  LineStyle();
55 
69  LineStyle(boost::uint16_t width, const rgba& color,
70  bool scaleThicknessVertically=true,
72  bool pixelHinting=false,
73  bool noClose=false,
77  float miterLimitFactor=1.0f
78  )
79  :
80  m_width(width),
81  m_color(color),
82  _scaleVertically(scaleThicknessVertically),
83  _scaleHorizontally(scaleThicknessHorizontally),
84  _pixelHinting(pixelHinting),
85  _noClose(noClose),
86  _startCapStyle(startCapStyle),
87  _endCapStyle(endCapStyle),
88  _joinStyle(joinStyle),
89  _miterLimitFactor(miterLimitFactor)
90  {
91  }
92 
94  //
101  const RunResources& r);
102 
106  const RunResources& r, LineStyle *pOther);
107 
109  boost::uint16_t getThickness() const {
110  return m_width;
111  }
112 
115  return _scaleVertically;
116  }
117 
120  return _scaleHorizontally;
121  }
122 
125  return _startCapStyle;
126  }
127 
130  return _endCapStyle;
131  }
132 
135  return _joinStyle;
136  }
137 
139  float miterLimitFactor() const {
140  return _miterLimitFactor;
141  }
142 
145  bool noClose() const {
146  return _noClose;
147  }
148 
150  bool doPixelHinting() const {
151  return _pixelHinting;
152  }
153 
155  const rgba& get_color() const { return m_color; }
156 
158  //
164  void set_lerp(const LineStyle& ls1, const LineStyle& ls2, float ratio);
165 
166 private:
167 
169  boost::uint16_t m_width;
170 
171  rgba m_color;
172 
173  bool _scaleVertically;
174 
175  bool _scaleHorizontally;
176 
177  bool _pixelHinting;
178 
179  bool _noClose;
180 
181  CapStyle _startCapStyle;
182 
183  CapStyle _endCapStyle;
184 
185  JoinStyle _joinStyle;
186 
187  float _miterLimitFactor;
188 };
189 
190 inline void
191 setLerp(LineStyle& s, const LineStyle& ls1, const LineStyle& ls2, double ratio)
192 {
193  s.set_lerp(ls1, ls2, ratio);
194 }
195 
196 } // namespace gnash
197 
198 #endif
199 
200 // Local Variables:
201 // mode: C++
202 // indent-tabs-mode: t
203 // End:
bool doPixelHinting() const
Return true if pixel hinting should be activated.
Definition: LineStyle.h:150
JoinStyle joinStyle() const
Return the join style.
Definition: LineStyle.h:134
Client program&#39;s interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
LineStyle(boost::uint16_t width, const rgba &color, bool scaleThicknessVertically=true, bool scaleThicknessHorizontally=true, bool pixelHinting=false, bool noClose=false, CapStyle startCapStyle=CAP_ROUND, CapStyle endCapStyle=CAP_ROUND, JoinStyle joinStyle=JOIN_ROUND, float miterLimitFactor=1.0f)
Definition: LineStyle.h:69
SWFStream & s
Definition: DefineBitsTag.cpp:73
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
void read(SWFStream &in, SWF::TagType t, movie_definition &md, const RunResources &r)
Read the line style from an SWF stream.
Definition: LineStyle.cpp:123
boost::uint16_t getThickness() const
Return thickness of the line, in TWIPS.
Definition: LineStyle.h:109
Definition: LineStyle.h:38
bool scaleThicknessVertically() const
Return true if line thickness should be scaled vertically.
Definition: LineStyle.h:114
bool noClose() const
Definition: LineStyle.h:145
CapStyle endCapStyle() const
Return the end cap style.
Definition: LineStyle.h:129
Definition: klash_part.cpp:329
Definition: GnashKey.h:152
const rgba & get_color() const
Return line color and alpha.
Definition: LineStyle.h:155
const VGfloat color[4]
Definition: testr_gtk.cpp:82
Definition: GnashKey.h:164
void set_lerp(const LineStyle &ls1, const LineStyle &ls2, float ratio)
Set this style to the interpolation of the given one.
Definition: LineStyle.cpp:179
Definition: GnashKey.h:166
Definition: LineStyle.h:39
Definition: LineStyle.h:44
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:43
void read_morph(SWFStream &in, SWF::TagType t, movie_definition &md, const RunResources &r, LineStyle *pOther)
Definition: LineStyle.cpp:71
LineStyle()
Construct a default LineStyle.
Definition: LineStyle.cpp:55
Definition: LineStyle.h:43
float miterLimitFactor() const
Return the miter limit factor.
Definition: LineStyle.h:139
For the outside of outline shapes, or just bare lines.
Definition: LineStyle.h:49
JoinStyle
Definition: LineStyle.h:42
CapStyle startCapStyle() const
Return the start cap style.
Definition: LineStyle.h:124
Definition: LineStyle.h:45
bool scaleThicknessHorizontally() const
Return true if line thickness should be scaled horizontally.
Definition: LineStyle.h:119
void setLerp(FillStyle &f, const FillStyle &a, const FillStyle &b, double t)
Set the FillStyle to a lerp of a and b.
Definition: FillStyle.cpp:221
CapStyle
Definition: LineStyle.h:36
Definition: LineStyle.h:37
SWF stream wrapper class.
Definition: SWFStream.h:58
A basic RGBA type.
Definition: RGBA.h:35