2 * Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "ming_utils.h"
25 #define OUTPUT_VERSION 8
26 #define OUTPUT_FILENAME "BeginBitmapFill.swf"
29 /// The beginBitmapFill test shows that:
31 /// 1. The fill always starts at 0, 0 of the MovieClip unless a matrix argument
33 /// 2. It repeats by default.
34 /// 3. If repeat is false, the edge colours are used for the fill.
35 /// 4. Changes to the BitmapData affect all fills.
36 const char* mediadir
=".";
39 main(int argc
, char** argv
)
42 SWFMovieClip dejagnuclip
;
44 if (argc
> 1) mediadir
=argv
[1];
46 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
51 Ming_useSWFVersion(OUTPUT_VERSION
);
54 SWFMovie_setDimension(mo
, 800, 600);
56 SWFMovie_setRate(mo
, 12);
57 dejagnuclip
= get_dejagnu_clip(
58 (SWFBlock
)get_default_font(mediadir
), 10, 10, 150, 800, 600);
59 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
61 SWFMovie_nextFrame(mo
);
64 "b = new flash.display.BitmapData(150, 150, false);"
65 "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 130), 0xff0000);"
66 "b.fillRect(new flash.geom.Rectangle(25, 10, 10, 130), 0x00ff00);"
67 "b.fillRect(new flash.geom.Rectangle(40, 10, 10, 130), 0x0000ff);"
68 "mc = _root.createEmptyMovieClip('mc1', 55);"
74 " moveTo(x + 0, y + 0);"
75 " beginBitmapFill(b);"
76 " lineTo(x + 0, y + 100);"
77 " lineTo(x + 100, y + 100);"
78 " lineTo(x + 100, y + 0);"
83 " moveTo(x + 0, y + 0);"
84 " beginBitmapFill(b);"
85 " lineTo(x + 100, y + 0);"
86 " lineTo(x + 100, y + 100);"
87 " lineTo(x + 0, y + 100);"
92 " moveTo(x + 0, y + 0);"
93 " beginBitmapFill(b);"
94 " lineTo(x + 100, y + 100);"
95 " lineTo(x + 0, y + 100);"
99 "b = new flash.display.BitmapData(150, 150, false);"
100 "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 130), 0xff00ff);"
101 "b.fillRect(new flash.geom.Rectangle(25, 10, 10, 130), 0xffff00);"
102 "b.fillRect(new flash.geom.Rectangle(40, 10, 10, 130), 0x00ffff);"
103 "mc = _root.createEmptyMovieClip('mc2', 66);"
107 " moveTo(x + 0, y + 0);"
108 " beginBitmapFill(b);"
109 " lineTo(x + 0, y + 100);"
110 " lineTo(x + 100, y + 100);"
111 " lineTo(x + 100, y + 0);"
112 " transform.matrix = new flash.geom.Matrix(2, -1.3, 2.4, 1, 20, 200);"
116 /// Now with matrix argument. Repeat is true by default
119 "b = new flash.display.BitmapData(150, 150, false);"
120 "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 130), 0x000000);"
121 "b.fillRect(new flash.geom.Rectangle(25, 10, 10, 130), 0xaaff00);"
122 "b.fillRect(new flash.geom.Rectangle(40, 10, 10, 130), 0x00ccff);"
123 "mc = _root.createEmptyMovieClip('mc3', 77);"
127 " moveTo(x + 0, y + 0);"
128 " matrix = new flash.geom.Matrix();"
129 " matrix.rotate(Math.PI / 2);"
130 " beginBitmapFill(b, matrix, true);"
131 " lineTo(x + 0, y + 100);"
132 " lineTo(x + 200, y + 100);"
133 " lineTo(x + 200, y + 0);"
137 // Now with repeat set to false
140 "b = new flash.display.BitmapData(20, 20, false);"
141 "b.fillRect(new flash.geom.Rectangle(0, 0, 10, 10), 0x000000);"
142 "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 10), 0xaaff00);"
143 "b.fillRect(new flash.geom.Rectangle(10, 0, 10, 10), 0xaaff00);"
144 "b.fillRect(new flash.geom.Rectangle(0, 10, 10, 10), 0xaaffaa);"
145 "mc = _root.createEmptyMovieClip('mc4', 88);"
149 " moveTo(x + 0, y + 0);"
150 " m = new flash.geom.Matrix();"
153 " beginBitmapFill(b, m, false);"
154 " lineTo(x + 0, y + 100);"
155 " lineTo(x + 150, y + 100);"
156 " lineTo(x + 150, y + 0);"
160 "mc = _root.createEmptyMovieClip('mc5', 99);"
164 " moveTo(x + 0, y + 0);"
165 " m = new flash.geom.Matrix();"
168 " beginBitmapFill(b, m, true);"
169 " lineTo(x + 0, y + 100);"
170 " lineTo(x + 150, y + 100);"
171 " lineTo(x + 150, y + 0);"
175 // Change the Bitmap afterwards
178 "b = new flash.display.BitmapData(20, 20, false);"
179 "b.fillRect(new flash.geom.Rectangle(0, 0, 10, 10), 0x000000);"
180 "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 10), 0xaaff00);"
181 "b.fillRect(new flash.geom.Rectangle(10, 0, 10, 10), 0xaaff00);"
182 "b.fillRect(new flash.geom.Rectangle(0, 10, 10, 10), 0xaaffaa);"
183 "mc = _root.createEmptyMovieClip('mc4', 111);"
187 " moveTo(x + 0, y + 0);"
188 " m = new flash.geom.Matrix();"
191 " beginBitmapFill(b, m, false);"
192 " lineTo(x + 0, y + 100);"
193 " lineTo(x + 150, y + 100);"
194 " lineTo(x + 150, y + 0);"
196 "b.fillRect(new flash.geom.Rectangle(0, 0, 20, 20), 0xff0000);"
199 // Dispose of the bitmap afterwards
202 "b = new flash.display.BitmapData(20, 20, false);"
203 "b.fillRect(new flash.geom.Rectangle(0, 0, 10, 10), 0x000000);"
204 "b.fillRect(new flash.geom.Rectangle(10, 10, 10, 10), 0xaaff00);"
205 "b.fillRect(new flash.geom.Rectangle(10, 0, 10, 10), 0xaaff00);"
206 "b.fillRect(new flash.geom.Rectangle(0, 10, 10, 10), 0xaaffaa);"
207 "mc = _root.createEmptyMovieClip('mc9', 222);"
211 " moveTo(x + 0, y + 0);"
212 " m = new flash.geom.Matrix();"
215 " beginBitmapFill(b, m, false);"
216 " lineTo(x + 0, y + 100);"
217 " lineTo(x + 150, y + 100);"
218 " lineTo(x + 150, y + 0);"
222 check_equals(mo
, "_root.mc9._width", "150");
224 add_actions(mo
, "stop();");
225 SWFMovie_nextFrame(mo
);
228 puts("Saving "OUTPUT_FILENAME
);
229 SWFMovie_save(mo
, OUTPUT_FILENAME
);