1 // LineStyle.h Line style types.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
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.
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.
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
20 // Based on public domain work by Thatcher Ulrich <tu@tulrich.com> 2003
22 #ifndef GNASH_LINESTYLE_H
23 #define GNASH_LINESTYLE_H
30 class movie_definition
;
48 /// For the outside of outline shapes, or just bare lines.
53 /// Construct a default LineStyle.
56 /// Construct a line style with explicit values
58 /// @param width Thickness of line in twips.
59 /// Zero for hair line
61 /// @param color Line color
62 /// @param scaleThicknessVertically
63 /// @param scaleThicknessHorizontally
65 /// @param startCapStyle
66 /// @param endCapStyle
68 /// @param miterLimitFactor
69 LineStyle(boost::uint16_t width
, const rgba
& color
,
70 bool scaleThicknessVertically
=true,
71 bool scaleThicknessHorizontally
=true,
72 bool pixelHinting
=false,
74 CapStyle startCapStyle
=CAP_ROUND
,
75 CapStyle endCapStyle
=CAP_ROUND
,
76 JoinStyle joinStyle
=JOIN_ROUND
,
77 float miterLimitFactor
=1.0f
82 _scaleVertically(scaleThicknessVertically
),
83 _scaleHorizontally(scaleThicknessHorizontally
),
84 _pixelHinting(pixelHinting
),
86 _startCapStyle(startCapStyle
),
87 _endCapStyle(endCapStyle
),
88 _joinStyle(joinStyle
),
89 _miterLimitFactor(miterLimitFactor
)
93 /// Read the line style from an SWF stream
95 /// Stream is assumed to be positioned at
98 /// Throw a ParserException if there's no enough bytes in the
99 /// currently opened tag for reading. See stream::ensureBytes()
100 void read(SWFStream
& in
, SWF::TagType t
, movie_definition
& md
,
101 const RunResources
& r
);
103 /// Read two lines styles from the SWF stream
104 /// at the same time -- this is used in morphing.
105 void read_morph(SWFStream
& in
, SWF::TagType t
, movie_definition
& md
,
106 const RunResources
& r
, LineStyle
*pOther
);
108 /// Return thickness of the line, in TWIPS
109 boost::uint16_t getThickness() const {
113 /// Return true if line thickness should be scaled vertically
114 bool scaleThicknessVertically() const {
115 return _scaleVertically
;
118 /// Return true if line thickness should be scaled horizontally
119 bool scaleThicknessHorizontally() const {
120 return _scaleHorizontally
;
123 /// Return the start cap style
124 CapStyle
startCapStyle() const {
125 return _startCapStyle
;
128 /// Return the end cap style
129 CapStyle
endCapStyle() const {
133 /// Return the join style
134 JoinStyle
joinStyle() const {
138 /// Return the miter limit factor
139 float miterLimitFactor() const {
140 return _miterLimitFactor
;
143 /// Return true if stroke should not be closed if the stroke's last point
144 /// matches the first point. Caps should be applied instead of a join
145 bool noClose() const {
149 /// Return true if pixel hinting should be activated
150 bool doPixelHinting() const {
151 return _pixelHinting
;
154 /// Return line color and alpha
155 const rgba
& get_color() const { return m_color
; }
157 /// Set this style to the interpolation of the given one
159 /// @param ls1 First LineStyle to interpolate.
160 /// @param ls2 Second LineStyle to interpolate.
161 /// @ratio The interpolation factor (0..1).
162 /// When 0, this will be equal to ls1, when 1
163 /// this will be equal to ls2.
164 void set_lerp(const LineStyle
& ls1
, const LineStyle
& ls2
, float ratio
);
169 boost::uint16_t m_width
;
173 bool _scaleVertically
;
175 bool _scaleHorizontally
;
181 CapStyle _startCapStyle
;
183 CapStyle _endCapStyle
;
185 JoinStyle _joinStyle
;
187 float _miterLimitFactor
;
191 setLerp(LineStyle
& s
, const LineStyle
& ls1
, const LineStyle
& ls2
, double ratio
)
193 s
.set_lerp(ls1
, ls2
, ratio
);
202 // indent-tabs-mode: t