2 * Copyright (C) 2005, 2006, 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
20 * (1) Verify that shapes can not hold variables, but rather evaluates to their
21 * containing sprite when referenced by name.
23 * (2) See effects of inconsistent drawing
31 #include "ming_utils.h"
33 #define OUTPUT_VERSION 7
34 #define OUTPUT_FILENAME "shape_test.swf"
38 main(int argc
, char** argv
)
41 SWFMovieClip dejagnuclip
;
45 const char *srcdir
=".";
50 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
56 SWFMovie_setDimension(mo
, 800, 600);
57 //SWFMovie_setRate (mo, 1.0);
59 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
60 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
61 SWFMovie_nextFrame(mo
);
63 sh1
= make_fill_square (100, 300, 60, 60, 255, 0, 0, 255, 0, 0);
64 sh2
= make_fill_square (300, 300, 60, 60, 255, 0, 0, 0, 0, 0);
66 it
= SWFMovie_add(mo
, (SWFBlock
)sh1
);
67 SWFDisplayItem_setName(it
, "sh1");
68 SWFDisplayItem_setDepth(it
, 3); //place the sh1 DisplayObject at depth 3;
70 it
= SWFMovie_add(mo
, (SWFBlock
)sh2
);
71 SWFDisplayItem_setName(it
, "sh2");
72 SWFDisplayItem_setDepth(it
, 4); //place the sh2 DisplayObject at depth 4;
74 check(mo
, "sh1 != undefined");
75 check(mo
, "sh2 != undefined");
77 // Do these checks mean that shapes are movieclips?
79 check_equals(mo
, "typeof(sh1)", "'movieclip'");
80 check_equals(mo
, "typeof(sh2)", "'movieclip'");
81 check_equals(mo
, "typeof(_root)", "'movieclip'");
88 // Do these checks mean that we can add variables to shapes?
89 // seems not, variable are added to the _root, interesting.
90 check_equals(mo
, "sh1.var1", "10");
91 check_equals(mo
, "sh2.var2", "20");
92 check_equals(mo
, "_root.var1", "10");
93 check_equals(mo
, "_root.var2", "20");
95 check_equals(mo
, "sh1._x", "0");
96 check_equals(mo
, "sh2._x", "0");
103 check_equals(mo
, "sh1._x", "400");
104 check_equals(mo
, "sh2._x", "400");
105 check_equals(mo
, "_root._x", "400");
107 add_actions(mo
, "_root._x = 0;" ); /* cleanup */
109 // Do these checks mean that shapes are *not* movieclips?
110 check_equals(mo
, "typeof(sh1.getDepth())", "'undefined'");
111 check_equals(mo
, "typeof(sh2.getDepth())", "'undefined'");
113 // Do these checks mean that shapes are *not* movieclips?
114 check_equals(mo
, "typeof(getInstanceAtDepth(-16381))", "'undefined'");
115 check_equals(mo
, "typeof(getInstanceAtDepth(-16380))", "'undefined'");
117 SWFMovie_nextFrame(mo
);
122 * See DrawingApiTest.as (inv8)
125 { /* using left fill, non-closed paths */
126 SWFDisplayItem it1
, it2
;
127 SWFShape sh
= newSWFShape();
128 SWFMovieClip mc
= newSWFMovieClip();
129 SWFShape_setLineStyle(sh
, 1, 0, 0, 0, 255);
130 SWFShape_setLeftFillStyle(sh
, SWFShape_addSolidFillStyle(sh
, 0, 255, 0, 255));
131 SWFShape_movePenTo(sh
, 20, 10); /* 0 */
132 SWFShape_drawLineTo(sh
, 40, 10); /* 1 */
133 SWFShape_drawLineTo(sh
, 40, 40); /* 2 */
134 SWFShape_drawLineTo(sh
, 20, 40); /* 3 */
135 SWFShape_drawLineTo(sh
, 20, 10); /* 4 */
136 SWFShape_drawLineTo(sh
, 10, 10); /* 5 */
137 SWFShape_drawLineTo(sh
, 10, 20); /* 6 */
138 SWFShape_drawLineTo(sh
, 30, 20); /* 7 */
139 SWFShape_drawLineTo(sh
, 30, 30); /* 8 */
140 SWFShape_drawLineTo(sh
, 20, 30); /* 9 */
141 it1
= SWFMovieClip_add(mc
, (SWFBlock
)sh
);
143 // Test that clip events are not invoked for shapes
144 #if 0 // current Ming HEAD chokes if we add an onClipConstruct event...
145 SWFDisplayItem_addAction(it1
, newSWFAction(
146 "_root.check(false && 'clip event for shape should not be executed');"
147 SWFACTION_CONSTRUCT
);
149 SWFDisplayItem_addAction(it1
, newSWFAction(
150 "_root.check(false && 'clip event for shape should not be executed');"
151 ), SWFACTION_ENTERFRAME
);
152 SWFDisplayItem_addAction(it1
, newSWFAction(
153 "_root.check(false && 'clip event for shape should not be executed');"
154 ), SWFACTION_ONLOAD
);
155 SWFDisplayItem_addAction(it1
, newSWFAction(
156 "_root.check(false && 'clip event for shape should not be executed');"
157 ), SWFACTION_UNLOAD
);
158 SWFDisplayItem_addAction(it1
, newSWFAction(
159 "_root.check(false && 'clip event for shape should not be executed');"
160 ), SWFACTION_MOUSEMOVE
);
161 SWFDisplayItem_addAction(it1
, newSWFAction(
162 "_root.check(false && 'clip event for shape should not be executed');"
163 ), SWFACTION_MOUSEDOWN
);
164 // None of these should be executed
165 SWFDisplayItem_addAction(it1
, newSWFAction(
166 "_root.check(false && 'clip event for shape should not be executed');"
167 ), SWFACTION_ONLOAD
);
169 SWFDisplayItem_moveTo(it1
, 80, 120);
170 SWFDisplayItem_scale(it1
, 2, 2);
171 SWFMovieClip_nextFrame(mc
);
172 it2
= SWFMovie_add(mo
, (SWFBlock
)mc
);
174 { /* using right fill, non-closed paths */
176 SWFShape sh
= newSWFShape();
177 SWFMovieClip mc
= newSWFMovieClip();
178 SWFShape_setLineStyle(sh
, 1, 0, 0, 0, 255);
179 SWFShape_setLeftFillStyle(sh
, SWFShape_addSolidFillStyle(sh
, 0, 255, 0, 255));
180 SWFShape_movePenTo(sh
, 20, 10); /* 0 */
181 SWFShape_drawLineTo(sh
, 40, 10); /* 1 */
182 SWFShape_drawLineTo(sh
, 40, 40); /* 2 */
183 SWFShape_drawLineTo(sh
, 20, 40); /* 3 */
184 SWFShape_drawLineTo(sh
, 20, 10); /* 4 */
185 SWFShape_drawLineTo(sh
, 10, 10); /* 5 */
186 SWFShape_drawLineTo(sh
, 10, 20); /* 6 */
187 SWFShape_drawLineTo(sh
, 30, 20); /* 7 */
188 SWFShape_drawLineTo(sh
, 30, 30); /* 8 */
189 SWFShape_drawLineTo(sh
, 20, 30); /* 9 */
190 it
= SWFMovieClip_add(mc
, (SWFBlock
)sh
);
191 SWFDisplayItem_moveTo(it
, 200, 120);
192 SWFDisplayItem_scale(it
, 2, 2);
193 SWFMovieClip_nextFrame(mc
);
194 it
= SWFMovie_add(mo
, (SWFBlock
)mc
);
196 { /* using left fill, closed paths */
198 SWFShape sh
= newSWFShape();
199 SWFMovieClip mc
= newSWFMovieClip();
200 SWFShape_setLineStyle(sh
, 1, 0, 0, 0, 255);
201 SWFShape_setLeftFillStyle(sh
, SWFShape_addSolidFillStyle(sh
, 255, 0, 0, 255));
202 SWFShape_movePenTo(sh
, 20, 10); /* 0 */
203 SWFShape_drawLineTo(sh
, 40, 10); /* 1 */
204 SWFShape_drawLineTo(sh
, 40, 40); /* 2 */
205 SWFShape_drawLineTo(sh
, 20, 40); /* 3 */
206 SWFShape_drawLineTo(sh
, 20, 10); /* 4 */
207 SWFShape_drawLineTo(sh
, 10, 10); /* 5 */
208 SWFShape_drawLineTo(sh
, 10, 20); /* 6 */
209 SWFShape_drawLineTo(sh
, 30, 20); /* 7 */
210 SWFShape_drawLineTo(sh
, 30, 30); /* 8 */
211 SWFShape_drawLineTo(sh
, 20, 30); /* 9 */
212 SWFShape_drawLineTo(sh
, 20, 10); /* 0 */
213 it
= SWFMovieClip_add(mc
, (SWFBlock
)sh
);
214 SWFDisplayItem_moveTo(it
, 80, 200);
215 SWFDisplayItem_scale(it
, 2, 2);
216 SWFMovieClip_nextFrame(mc
);
217 it
= SWFMovie_add(mo
, (SWFBlock
)mc
);
219 { /* using right fill, closed paths */
221 SWFShape sh
= newSWFShape();
222 SWFMovieClip mc
= newSWFMovieClip();
223 SWFShape_setLineStyle(sh
, 1, 0, 0, 0, 255);
224 SWFShape_setRightFillStyle(sh
, SWFShape_addSolidFillStyle(sh
, 255, 0, 0, 255));
225 SWFShape_movePenTo(sh
, 20, 10); /* 0 */
226 SWFShape_drawLineTo(sh
, 40, 10); /* 1 */
227 SWFShape_drawLineTo(sh
, 40, 40); /* 2 */
228 SWFShape_drawLineTo(sh
, 20, 40); /* 3 */
229 SWFShape_drawLineTo(sh
, 20, 10); /* 4 */
230 SWFShape_drawLineTo(sh
, 10, 10); /* 5 */
231 SWFShape_drawLineTo(sh
, 10, 20); /* 6 */
232 SWFShape_drawLineTo(sh
, 30, 20); /* 7 */
233 SWFShape_drawLineTo(sh
, 30, 30); /* 8 */
234 SWFShape_drawLineTo(sh
, 20, 30); /* 9 */
235 SWFShape_drawLineTo(sh
, 20, 10); /* 0 */
236 it
= SWFMovieClip_add(mc
, (SWFBlock
)sh
);
237 SWFDisplayItem_moveTo(it
, 200, 200);
238 SWFDisplayItem_scale(it
, 2, 2);
239 SWFMovieClip_nextFrame(mc
);
240 it
= SWFMovie_add(mo
, (SWFBlock
)mc
);
243 add_actions(mo
, "_root.totals(); stop();");
245 SWFMovie_nextFrame(mo
);
248 puts("Saving " OUTPUT_FILENAME
);
249 SWFMovie_save(mo
, OUTPUT_FILENAME
);