2 // Copyright (C) 2008, 2009, 2010 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 2 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.
14 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 // Test case for BitmapData ActionScript class
20 // compile this test case with Ming makeswf, and then
21 // execute it like this gnash -1 -r 0 -v out.swf
23 rcsid
="BitmapData.as";
28 #if OUTPUT_VERSION
< 8
30 check_equals
(typeof(flash
), 'undefined');
36 Bitmap = flash
.display
.BitmapData;
37 check_equals
(typeof(Bitmap), 'function');
38 check_equals
(typeof(Bitmap.prototype
), 'object');
39 check
(Bitmap.prototype
.hasOwnProperty
('applyFilter'));
40 check
(Bitmap.prototype
.hasOwnProperty
('clone'));
41 check
(Bitmap.prototype
.hasOwnProperty
('colorTransform'));
42 check
(Bitmap.prototype
.hasOwnProperty
('copyChannel'));
43 check
(Bitmap.prototype
.hasOwnProperty
('copyPixels'));
44 check
(Bitmap.prototype
.hasOwnProperty
('dispose'));
45 check
(Bitmap.prototype
.hasOwnProperty
('draw'));
46 check
(Bitmap.prototype
.hasOwnProperty
('fillRect'));
47 check
(Bitmap.prototype
.hasOwnProperty
('floodFill'));
48 check
(Bitmap.prototype
.hasOwnProperty
('generateFilterRect'));
49 check
(Bitmap.prototype
.hasOwnProperty
('getColorBoundsRect'));
50 check
(Bitmap.prototype
.hasOwnProperty
('getPixel'));
51 check
(Bitmap.prototype
.hasOwnProperty
('getPixel32'));
52 check
(Bitmap.prototype
.hasOwnProperty
('hitTest'));
53 check
(Bitmap.prototype
.hasOwnProperty
('merge'));
54 check
(Bitmap.prototype
.hasOwnProperty
('noise'));
55 check
(Bitmap.prototype
.hasOwnProperty
('paletteMap'));
56 check
(Bitmap.prototype
.hasOwnProperty
('perlinNoise'));
57 check
(Bitmap.prototype
.hasOwnProperty
('pixelDissolve'));
58 check
(Bitmap.prototype
.hasOwnProperty
('scroll'));
59 check
(Bitmap.prototype
.hasOwnProperty
('setPixel'));
60 check
(Bitmap.prototype
.hasOwnProperty
('setPixel32'));
61 check
(Bitmap.prototype
.hasOwnProperty
('threshold'));
62 check
(Bitmap.prototype
.hasOwnProperty
("height"));
63 check
(Bitmap.prototype
.hasOwnProperty
("width"));
64 check
(Bitmap.prototype
.hasOwnProperty
("rectangle"));
65 check
(Bitmap.prototype
.hasOwnProperty
("transparent"));
67 check
(Bitmap.hasOwnProperty
("RED_CHANNEL"));
68 check
(Bitmap.hasOwnProperty
("GREEN_CHANNEL"));
69 check
(Bitmap.hasOwnProperty
("BLUE_CHANNEL"));
70 check
(Bitmap.hasOwnProperty
("ALPHA_CHANNEL"));
72 check
(!Bitmap.prototype
.hasOwnProperty
('loadBitmap'));
73 check
(Bitmap.hasOwnProperty
('loadBitmap'));
75 Rectangle = flash
.geom
.Rectangle;
77 //-------------------------------------------------------------
79 //-------------------------------------------------------------
82 check_equals
(typeof(bmp
), "undefined");
84 bmp
= new Bitmap(10, 10);
85 check_equals
(typeof(bmp
), 'object');
86 check
(bmp
instanceof Bitmap);
87 check
(!bmp
.hasOwnProperty
("height"));
88 check
(!bmp
.hasOwnProperty
("width"));
89 check
(!bmp
.hasOwnProperty
("rectangle"));
90 check
(!bmp
.hasOwnProperty
("transparent"));
91 check_equals
(bmp
.height
, 10);
92 check_equals
(bmp
.width
, 10);
93 check_equals
(bmp
.transparent
, true);
94 check_equals
(bmp
.rectangle
.toString
(), "(x=0, y=0, w=10, h=10)");
95 check
(bmp
.rectangle instanceOf flash
.geom
.Rectangle);
96 check_equals
(bmp
.getPixel
(1, 1), 16777215);
97 check_equals
(bmp
.getPixel
(9, 9), 16777215);
98 check_equals
(bmp
.getPixel32
(1, 1), -1);
100 bmp
= new Bitmap(10, 10, true);
101 check_equals
(bmp
.getPixel32
(1, 1), -1);
102 bmp
= new Bitmap(10, 10, false);
103 check_equals
(bmp
.getPixel32
(1, 1), -1);
106 bmp
= new Bitmap(20, 30, false, 0xeeddee);
107 check_equals
(bmp
.height
, 30);
108 check_equals
(bmp
.width
, 20);
109 check_equals
(bmp
.transparent
, false);
110 check_equals
(bmp
.rectangle
.toString
(), "(x=0, y=0, w=20, h=30)");
111 check_equals
(bmp
.getPixel
(1, 1), 0xeeddee);
112 check_equals
(bmp
.getPixel32
(1, 1), -1122834);
116 check_equals
(bmp
.getPixel
(50, 1), 0);
117 check_equals
(bmp
.getPixel
(0, 0), 15654382);
118 check_equals
(bmp
.getPixel
(-2, -5), 0);
120 // 0,0 is inside, 20, 30 outside a 20x30 bitmap.
121 check_equals
(bmp
.getPixel
(20, 30), 0);
124 // 2880 is the maximum, 1 the minimum. Returns
125 // undefined if the dimensions are invalid.
126 bmp
= new Bitmap(10000, 3);
127 check_equals
(typeof(bmp
), "undefined");
128 check_equals
(bmp
.height
, undefined);
130 bmp
= new Bitmap(0, 10000);
131 check_equals
(bmp
, undefined);
132 check_equals
(bmp
.height
, undefined);
134 bmp
= new Bitmap(2880, 2880);
135 check_equals
(typeof(bmp
), "object");
136 check_equals
(bmp
.height
, 2880);
138 bmp
= new Bitmap(2880, 2881);
139 check_equals
(typeof(bmp
), "undefined");
140 check_equals
(bmp
.height
, undefined);
142 bmp
= new Bitmap(0, 2880);
143 check_equals
(bmp
, undefined);
144 check_equals
(bmp
.height
, undefined);
146 bmp
= new Bitmap(2879, 2879);
147 check_equals
(typeof(bmp
), "object");
148 check_equals
(bmp
.height
, 2879);
150 bmp
= new Bitmap(0, 2879);
151 check_equals
(bmp
, undefined);
152 check_equals
(bmp
.height
, undefined);
154 bmp
= new Bitmap(-1, 10, false, 0xff);
155 check_equals
(bmp
, undefined);
156 check_equals
(bmp
.height
, undefined);
158 // --------------------
159 // setPixel, setPixel32
160 // --------------------
162 tr
= new Bitmap(30, 30, true);
163 ntr
= new Bitmap(30, 30, false);
165 // Premultiplication?
166 tr
.setPixel32
(2, 2, 0x44);
167 xcheck_equals
(tr
.getPixel
(2, 2), 0x00);
168 xcheck_equals
(tr
.getPixel32
(2, 2), 0);
170 // Premultiplication?
171 tr
.setPixel32
(2, 2, 0x220000aa);
172 xcheck_equals
(tr
.getPixel
(2, 2), 0xac);
173 xcheck_equals
(tr
.getPixel32
(2, 2), 0x220000ac);
175 tr
.setPixel32
(2, 2, 0xff0000aa);
176 check_equals
(tr
.getPixel
(2, 2), 0xaa);
177 check_equals
(tr
.getPixel32
(2, 2), -16777046);
179 tr
.setPixel
(3, 3, 0xff);
180 check_equals
(tr
.getPixel
(3, 3), 0xff);
181 check_equals
(tr
.getPixel32
(3, 3), -16776961);
183 // Premultiplication?
184 tr
.setPixel32
(4, 4, 0x44444444);
185 xcheck_equals
(tr
.getPixel
(4, 4), 0x434343);
186 xcheck_equals
(tr
.getPixel32
(4, 4), 0x44434343);
188 tr
.setPixel32
(4, 4, 0x10101010);
189 check_equals
(tr
.getPixel
(4, 4), 0x101010);
190 check_equals
(tr
.getPixel32
(4, 4), 0x10101010);
192 // Premultiplication?
193 tr
.setPixel32
(4, 4, 0x43434343);
194 xcheck_equals
(tr
.getPixel
(4, 4), 0x444444);
195 xcheck_equals
(tr
.getPixel32
(4, 4), 0x43444444);
197 ntr
.setPixel
(5, 5, 0xff);
198 check_equals
(ntr
.getPixel
(5, 5), 0xff);
199 check_equals
(ntr
.getPixel32
(5, 5), -16776961);
201 ntr
.setPixel32
(6, 6, 0x44444444);
202 check_equals
(ntr
.getPixel
(6, 6), 0x444444);
203 check_equals
(ntr
.getPixel32
(6, 6), -12303292);
209 bmp
= new Bitmap(20, 20, false);
210 bmp
.floodFill
(10, 10, 0x0000ff00);
212 check_equals
(bmp
.getPixel
(10, 10), 0x0000ff00);
213 bmp
.floodFill
(5, 5, 0x000000ff);
214 check_equals
(bmp
.getPixel
(10, 0), 0x000000ff);
216 mc
= this.createEmptyMovieClip
("mc", this.getNextHighestDepth
());
217 mc
.attachBitmap
(bmp
, this.getNextHighestDepth
());
219 b
= new Bitmap(200, 200, false, 0xffffff);
220 b
.fillRect
(new Rectangle(10, 10, 10, 10), 0x00ff00);
221 b
.fillRect
(new Rectangle(50, 20, 10, 10), 0x00ff00);
222 b
.fillRect
(new Rectangle(50, 70, 20, 20), 0x00ff00);
223 b
.fillRect
(new Rectangle(50, 70, 20, 20), 0x00ff00);
225 b
.fillRect
(new Rectangle(120, 100, 10, 10), 0x0000ff);
226 b
.fillRect
(new Rectangle(130, 90, 10, 10), 0xffff00);
227 b
.fillRect
(new Rectangle(140, 100, 10, 10), 0x00ffff);
228 b
.fillRect
(new Rectangle(130, 110, 10, 10), 0xff00ff);
230 check_equals
(b
.getPixel
(1, 1), 0xffffff);
231 check_equals
(b
.getPixel
(135, 105), 0xffffff);
233 // This is done twice deliberately to make sure Gnash doesn't hang!
234 b
.floodFill
(0, 0, 0);
235 b
.floodFill
(0, 0, 0);
236 check_equals
(b
.getPixel
(1, 1), 0x0);
237 check_equals
(b
.getPixel
(190, 190), 0x0);
238 check_equals
(b
.getPixel
(135, 105), 0xffffff);
240 b
.floodFill
(135, 105, 0xee1111);
241 check_equals
(b
.getPixel
(1, 1), 0x0);
242 check_equals
(b
.getPixel
(190, 190), 0x0);
243 check_equals
(b
.getPixel
(135, 105), 0xee1111);
245 mc2
= this.createEmptyMovieClip
("mc2", this.getNextHighestDepth
());
246 mc2
.attachBitmap
(b
, this.getNextHighestDepth
());
252 bmp
= new Bitmap(20, 20, false);
253 r
= new Rectangle(2, 2, 5, 5);
254 bmp
.fillRect
(r
, 0xff1100);
255 check_equals
(bmp
.getPixel
(1, 1), 0xffffff);
256 check_equals
(bmp
.getPixel
(2, 2), 0xff1100);
257 check_equals
(bmp
.getPixel
(2, 5), 0xff1100);
258 check_equals
(bmp
.getPixel
(5, 2), 0xff1100);
259 check_equals
(bmp
.getPixel
(2, 6), 0xff1100);
260 check_equals
(bmp
.getPixel
(6, 6), 0xff1100);
261 check_equals
(bmp
.getPixel
(6, 7), 0xffffff);
262 check_equals
(bmp
.getPixel
(7, 6), 0xffffff);
264 r
= new Rectangle(-2, -2, 8, 8);
265 bmp
.fillRect
(r
, 0x00ff00);
266 check_equals
(bmp
.getPixel
(1, 1), 0x00ff00);
269 r
= new Rectangle(18, 18, -4, -4);
270 bmp
.fillRect
(r
, 0x0000ff);
271 check_equals
(bmp
.getPixel
(7, 6), 0xffffff);
273 r
= new Rectangle(18, 18, 200, 200);
274 bmp
.fillRect
(r
, 0x0000ff);
275 check_equals
(bmp
.getPixel
(19,19), 0x0000ff);
277 // Doesn't have to be a rectangle
278 g
= {x
: 15, y
: 15, width
: 2, height
: 2};
279 bmp
.fillRect
(g
, 0xff00ff);
280 check_equals
(bmp
.getPixel
(16, 16), 0xff00ff);
282 // Transparency (this bitmap is not transparent).
283 g
= {x
: 18, y
: 2, width
: 7, height
: 7};
284 bmp
.fillRect
(g
, 0xddff00ff);
285 check_equals
(bmp
.getPixel32
(18, 2), -65281);
287 mc
.attachBitmap
(bmp
, this.getNextHighestDepth
());
289 // Transparency (transparent bitmap). Fill just obliterates
290 // what was there, even if it's transparent.
291 bmp
= new Bitmap(20, 20, true);
292 r
= new Rectangle(1, 1, 10, 10);
293 bmp
.fillRect
(r
, 0xff00ff00);
294 r
= new Rectangle(2, 2, 9, 9);
295 bmp
.fillRect
(r
, 0x99ff1100);
296 check_equals
(bmp
.getPixel32
(3, 3), -1711337216);
298 mc
.attachBitmap
(bmp
, this.getNextHighestDepth
());
301 check_equals
(bmp
.height
, -1);
302 check_equals
(bmp
.width
, -1);
303 check_equals
(bmp
.transparent
, -1);
304 check_equals
(typeof(bmp
.rectangle
), "number");
305 check_equals
(bmp
.rectangle
, -1);
306 check_equals
(bmp
.rectangle
.toString
(), "-1");
308 check
(bmp instanceOf
Bitmap);
310 check_equals
(bmp
.height
, -1);
312 bmp
= new Bitmap(20, 10, true);
313 backup
= flash
.geom
.Rectangle;
314 flash
.geom
.Rectangle = 2;
315 check_equals
(bmp
.rectangle
, -1);
317 flash
.geom
.Rectangle = function (x
, y
, w
, h
)
324 check_equals
(bmp
.rectangle
.toString
(), "[object Object]");
326 flash
.geom
.Rectangle = function (x
, y
, w
, h
)
329 check_equals
(bmp
.rectangle
.toString
(), "[object Object]");
331 flash
.geom
.Rectangle = function ()
334 check_equals
(bmp
.rectangle
.toString
(), "[object Object]");
336 flash
.geom
.Rectangle = backup
;
337 check_equals
(bmp
.rectangle
.toString
(), "(x=0, y=0, w=20, h=10)");
343 // First we check that all user-defined transformations are ignored.
345 // Note: at the corners of these tests antialiasing makes a difference. The
346 // value can vary according to the transformation of the clip. We're not
347 // really interested in the exact values of anti-aliased pixels.
349 d
= _root
.createEmptyMovieClip
("tar", 600);
350 d
.beginFill
(0x00ff00);
358 d
.beginFill
(0xff0000);
365 // 100x100, no transparency
366 b
= new Bitmap(100, 100, false);
368 check_equals
(b
.getPixel
(1, 1), 0xffffff);
369 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
370 check_equals
(b
.getPixel
(19, 20), 0xffffff);
371 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
372 check_equals
(b
.getPixel
(50, 25), 0xffffff);
373 check_equals
(b
.getPixel
(55, 55), 0xff0000);
377 check_equals
(b
.getPixel
(1, 1), 0xffffff);
378 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
379 check_equals
(b
.getPixel
(19, 20), 0xffffff);
380 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
381 check_equals
(b
.getPixel
(50, 25), 0xffffff);
382 check_equals
(b
.getPixel
(55, 55), 0xff0000);
384 // User-defined translation makes no difference.
387 check_equals
(b
.getPixel
(1, 1), 0xffffff);
388 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
389 check_equals
(b
.getPixel
(19, 20), 0xffffff);
390 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
391 check_equals
(b
.getPixel
(50, 25), 0xffffff);
392 check_equals
(b
.getPixel
(55, 55), 0xff0000);
394 // User defined transform makes no difference.
397 check_equals
(b
.getPixel
(1, 1), 0xffffff);
398 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
399 check_equals
(b
.getPixel
(19, 20), 0xffffff);
400 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
401 check_equals
(b
.getPixel
(50, 25), 0xffffff);
402 check_equals
(b
.getPixel
(55, 55), 0xff0000);
404 // User defined transform makes no difference.
407 check_equals
(b
.getPixel
(1, 1), 0xffffff);
408 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
409 check_equals
(b
.getPixel
(19, 20), 0xffffff);
410 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
411 check_equals
(b
.getPixel
(50, 25), 0xffffff);
412 check_equals
(b
.getPixel
(55, 55), 0xff0000);
414 // Color transform the old way (no difference).
415 c
= new Color("_level0.tar");
417 check_equals
(b
.getPixel
(1, 1), 0xffffff);
418 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
419 check_equals
(b
.getPixel
(19, 20), 0xffffff);
420 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
421 check_equals
(b
.getPixel
(50, 25), 0xffffff);
422 check_equals
(b
.getPixel
(55, 55), 0xff0000);
424 // Color transform the new way.
425 var tr
= d
.transform
;
426 tr
.colorTransform
= new flash
.geom
.ColorTransform(0.5, 0.5, 0.5, 0.5, 34, 34, 34, 34);
428 check_equals
(b
.getPixel
(1, 1), 0xffffff);
429 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
430 check_equals
(b
.getPixel
(19, 20), 0xffffff);
431 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
432 check_equals
(b
.getPixel
(50, 25), 0xffffff);
433 check_equals
(b
.getPixel
(55, 55), 0xff0000);
435 dom
= new flash
.geom
.Matrix();
436 dom
.rotate
(Math.PI
/ 4);
439 check_equals
(b
.getPixel
(1, 1), 0xffffff);
440 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
441 check_equals
(b
.getPixel
(19, 20), 0xffffff);
442 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
443 check_equals
(b
.getPixel
(50, 25), 0xffffff);
444 check_equals
(b
.getPixel
(55, 55), 0xff0000);
446 // Test behaviour of BitmapData.draw with masks.
448 // 1. The MovieClip is drawn with the custom transform
449 // 2. The mask is drawn with its current transform
450 near
= function(bitmap
, x
, y
, val
) {
452 col
= bitmap
.getPixel
(x
, y
);
453 col_r
= (col
& 0xff0000) >> 16;
454 col_g
= (col
& 0xff00) >> 8;
455 col_b
= (col
& 0xff);
456 val_r
= (val
& 0xff0000) >> 16;
457 val_g
= (val
& 0xff00) >> 8;
458 val_b
= (val
& 0xff);
459 if (Math.abs
(col_r
- val_r
) > tol
) return false;
460 if (Math.abs
(col_b
- val_b
) > tol
) return false;
461 if (Math.abs
(col_g
- val_g
) > tol
) return false;
465 mc
= _root
.createEmptyMovieClip
("mc", 1009);
466 a
= mc
.createEmptyMovieClip
("a", 1090);
467 b
= mc
.createEmptyMovieClip
("b", 1091);
469 mask
= _root
.createEmptyMovieClip
("mask", 1150);
504 // Only for visual checking.
505 disp
= _root
.createEmptyMovieClip
("disp", 1300);
511 // Mask and MovieClip with neutral transform
512 bm
= new flash
.display
.BitmapData(50, 50, false);
515 // A square of the green stripe is visible.
516 check
(near
(bm
, 5, 5, 0xffffff));
517 check
(near
(bm
, 5, 15, 0xffffff));
518 check
(near
(bm
, 5, 25, 0xffffff));
519 check
(near
(bm
, 15, 5, 0xffffff));
520 check
(near
(bm
, 15, 15, 0x00ff00));
521 check
(near
(bm
, 15, 25, 0xffffff));
522 check
(near
(bm
, 25, 5, 0xffffff));
523 check
(near
(bm
, 25, 15, 0xffffff));
524 check
(near
(bm
, 25, 25, 0xffffff));
526 // Mask with neutral transform, MovieClip with different transform
530 bm
= new flash
.display
.BitmapData(50, 50, false);
533 // A square of the green stripe is visible.
534 check
(near
(bm
, 5, 5, 0xffffff));
535 check
(near
(bm
, 5, 15, 0xffffff));
536 check
(near
(bm
, 5, 25, 0xffffff));
537 check
(near
(bm
, 15, 5, 0xffffff));
538 check
(near
(bm
, 15, 15, 0x00ff00));
539 check
(near
(bm
, 15, 25, 0xffffff));
540 check
(near
(bm
, 25, 5, 0xffffff));
541 check
(near
(bm
, 25, 15, 0xffffff));
542 check
(near
(bm
, 25, 25, 0xffffff));
544 // Mask with different transform, MovieClip with different transform
546 bm
= new flash
.display
.BitmapData(50, 50, false);
549 // A square of the blue stripe is visible.
550 check
(near
(bm
, 5, 5, 0xffffff));
551 check
(near
(bm
, 5, 15, 0xffffff));
552 check
(near
(bm
, 5, 25, 0xffffff));
553 check
(near
(bm
, 15, 5, 0xffffff));
554 check
(near
(bm
, 15, 15, 0xffffff));
555 check
(near
(bm
, 15, 25, 0xffffff));
556 check
(near
(bm
, 25, 5, 0xffffff));
557 check
(near
(bm
, 25, 15, 0x0000ff));
558 check
(near
(bm
, 25, 25, 0xffffff));
560 bm
= new flash
.display
.BitmapData(50, 50, false);
561 bm
.draw
(mc
, new flash
.geom
.Matrix(1, 0, 0, 1, 5, 5));
563 // A bit of the green and blue stripe is visible.
564 check
(near
(bm
, 5, 5, 0xffffff));
565 check
(near
(bm
, 5, 15, 0xffffff));
566 check
(near
(bm
, 5, 25, 0xffffff));
567 check
(near
(bm
, 15, 5, 0xffffff));
568 check
(near
(bm
, 15, 15, 0xffffff));
569 check
(near
(bm
, 15, 25, 0xffffff));
570 check
(near
(bm
, 25, 5, 0xffffff));
571 check
(near
(bm
, 23, 15, 0x00ff00));
572 check
(near
(bm
, 24, 15, 0x00ff00));
573 xcheck
(near
(bm
, 25, 15, 0x0000ff)); // gnash: 0x0b0bfe
574 check
(near
(bm
, 26, 15, 0x0000ff));
575 check
(near
(bm
, 25, 25, 0xffffff));
577 bm
= new flash
.display
.BitmapData(50, 50, false);
578 bm
.draw
(mc
, new flash
.geom
.Matrix(2, 0, 0, 2, 5, 5));
580 // A bit of the red and green stripe is visible.
581 check
(near
(bm
, 5, 5, 0xffffff));
582 check
(near
(bm
, 5, 15, 0xffffff));
583 check
(near
(bm
, 5, 25, 0xffffff));
584 check
(near
(bm
, 15, 5, 0xffffff));
585 check
(near
(bm
, 15, 15, 0xffffff));
586 check
(near
(bm
, 15, 25, 0xffffff));
587 check
(near
(bm
, 25, 5, 0xffffff));
588 check
(near
(bm
, 23, 15, 0xff0000));
589 check
(near
(bm
, 24, 15, 0xff0000));
590 xcheck
(near
(bm
, 25, 15, 0x00ff00)); // gnash: 0x0bfe0b
591 check
(near
(bm
, 26, 15, 0x00ff00));
592 check
(near
(bm
, 25, 25, 0xffffff));
594 disp
.attachBitmap
(bm
, 400);
596 bm
= new flash
.display
.BitmapData(10, 10, true, 0x5010eeff);
597 xcheck_equals
(bm
.getPixel32
(5, 5), 0x5010efff);
599 bm
= new flash
.display
.BitmapData(10, 10, true, 0xee11efff);
600 check_equals
(bm
.getPixel32
(5, 5), -300814337);
602 bm
= new flash
.display
.BitmapData(10, 10, true, 0x00011010);
603 check_equals
(bm
.getPixel32
(5, 5), 0x00000000);
605 bm
= new flash
.display
.BitmapData(10, 10, true, 0x0000ffff);
606 check_equals
(bm
.getPixel32
(5, 5), 0x00000000);
608 bm
= new flash
.display
.BitmapData(10, 10, true, 0x000000ff);
609 check_equals
(bm
.getPixel32
(5, 5), 0x00000000);
611 bm
= new flash
.display
.BitmapData(10, 10, true, 0x010000ff);
612 check_equals
(bm
.getPixel32
(5, 5), 0x010000ff);
614 bm
= new flash
.display
.BitmapData(10, 10, true, 0x300000ff);
615 check_equals
(bm
.getPixel32
(5, 5), 0x300000ff);
617 bm
= new flash
.display
.BitmapData(10, 10, true, 0x30ffffff);
618 check_equals
(bm
.getPixel32
(5, 5), 0x30ffffff);
622 source
= new flash
.display
.BitmapData(100, 100, false, 0x0000ff);
626 Rect
= flash
.geom
.Rectangle;
627 Point = flash
.geom
.Point;
629 // These are identical:
630 // i.e. any part of the rect that is above or left of the source
631 // is added as an offset to the destination point.
633 dest
= new flash
.display
.BitmapData(100, 100, false, 0xff0000);
634 dest
.copyPixels
(source
, new Rect
(-50, -50, 100, 100), new Point(0, 0));
635 check_equals
(dest
.getPixel
(10, 10), 0xff0000);
636 check_equals
(dest
.getPixel
(52, 52), 0x0000ff);
637 check_equals
(dest
.getPixel
(52, 10), 0xff0000);
638 check_equals
(dest
.getPixel
(10, 52), 0xff0000);
640 // null copypixel argument: should be the same as Point(0,0)
641 dest
= new flash
.display
.BitmapData(100, 100, false, 0xff0000);
642 dest
.copyPixels
(source
, new Rect
(-50, -50, 100, 100), null);
643 check_equals
(dest
.getPixel
(10, 10), 0xff0000);
644 check_equals
(dest
.getPixel
(52, 52), 0x0000ff);
645 check_equals
(dest
.getPixel
(52, 10), 0xff0000);
646 check_equals
(dest
.getPixel
(10, 52), 0xff0000);
648 dest
= new flash
.display
.BitmapData(100, 100, false, 0xff0000);
649 dest
.copyPixels
(source
, new Rect
(0, 0, 100, 100), new Point(50, 50));
650 check_equals
(dest
.getPixel
(10, 10), 0xff0000);
651 check_equals
(dest
.getPixel
(52, 52), 0x0000ff);
652 check_equals
(dest
.getPixel
(52, 10), 0xff0000);
653 check_equals
(dest
.getPixel
(10, 52), 0xff0000);
655 // If the source rect is completely outside the source bitmap, nothing happens
656 dest
= new flash
.display
.BitmapData(100, 100, false, 0xff0000);
657 dest
.copyPixels
(source
, new Rect
(101, 40, 100, 100), new Point(50, 50));
658 check_equals
(dest
.getPixel
(10, 10), 0xff0000);
659 check_equals
(dest
.getPixel
(52, 52), 0xff0000);
660 check_equals
(dest
.getPixel
(52, 10), 0xff0000);
661 check_equals
(dest
.getPixel
(10, 52), 0xff0000);
662 check_equals
(dest
.getPixel
(90, 90), 0xff0000);
664 // If the dest point is right or below the dest bitmap, nothing happens
665 dest
= new flash
.display
.BitmapData(100, 100, false, 0xff0000);
666 dest
.copyPixels
(source
, new Rect
(0, 0, 100, 100), new Point(200, 50));
667 check_equals
(dest
.getPixel
(10, 10), 0xff0000);
668 check_equals
(dest
.getPixel
(52, 52), 0xff0000);
669 check_equals
(dest
.getPixel
(52, 10), 0xff0000);
670 check_equals
(dest
.getPixel
(10, 52), 0xff0000);
671 check_equals
(dest
.getPixel
(90, 90), 0xff0000);
673 // Check self copies!
675 source
= new flash
.display
.BitmapData(100, 100, false);
677 // Should be the same
678 source
.fillRect
(new Rect
(0, 0, 50, 50), 0x00ff00);
679 source
.copyPixels
(source
, new Rect
(35, 35, 20, 20), new Point(35, 35));
681 check_equals
(source
.getPixel
(55, 45), 0xffffff);
682 check_equals
(source
.getPixel
(60, 60), 0xffffff);
683 check_equals
(source
.getPixel
(45, 55), 0xffffff);
684 check_equals
(source
.getPixel
(45, 45), 0x00ff00);
686 source
.copyPixels
(source
, new Rect
(20, 20, 50, 50), new Point(45, 45));
687 // Bottom right corner is still white
688 check_equals
(source
.getPixel
(90, 90), 0xffffff);
689 check_equals
(source
.getPixel
(55, 42), 0xffffff);
690 check_equals
(source
.getPixel
(42, 55), 0xffffff);
691 check_equals
(source
.getPixel
(55, 55), 0x00ff00);
692 check_equals
(source
.getPixel
(55, 70), 0x00ff00);
693 check_equals
(source
.getPixel
(70, 55), 0x00ff00);
697 // This function seems to work as expected for single channel to single
699 // When the destination is a combination of channels, nothing happens. When
700 // it is a single channel and the source is a combination of channels, it
704 // ---------------------
709 // ---------------------
714 // ---------------------
716 // Copy one channel to another
717 src
= new flash
.display
.BitmapData(100, 100, true);
718 src
.fillRect
(new Rect
(0, 0, 50, 50), 0xffff0000); // Red channel
719 src
.fillRect
(new Rect
(50, 0, 50, 50), 0xff00ffff); // Blue and green channels
720 src
.fillRect
(new Rect
(0, 50, 50, 50), 0xffff00ff); // Red and Blue channels
721 src
.fillRect
(new Rect
(50, 50, 50, 50), 0xff007f00); // Green channel
723 // Copy red channel to green channel
724 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
725 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 1, 2);
726 check_equals
(dest
.getPixel
(25, 25), 0x00ff00); // Was red, now green
727 check_equals
(dest
.getPixel
(75, 25), 0x000000); // Nothing
728 check_equals
(dest
.getPixel
(25, 75), 0x00ff00); // Was red/blue, now green
729 check_equals
(dest
.getPixel
(75, 75), 0x000000); // Nothing
731 // Copy red channel to green and blue channels
733 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
734 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 1, 6);
735 check_equals
(dest
.getPixel
(25, 25), 0x000000); // Nothing
736 check_equals
(dest
.getPixel
(75, 25), 0x000000); // Nothing
737 check_equals
(dest
.getPixel
(25, 75), 0x000000); // Nothing
738 check_equals
(dest
.getPixel
(75, 75), 0x000000); // Nothing
740 // Copy red channel to green and blue channels
742 dest
= new flash
.display
.BitmapData(100, 100, true, 0xffffffff);
743 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 1, 6);
744 check_equals
(dest
.getPixel
(25, 25), 0xffffff); // Nothing
745 check_equals
(dest
.getPixel
(75, 25), 0xffffff); // Nothing
746 check_equals
(dest
.getPixel
(25, 75), 0xffffff); // Nothing
747 check_equals
(dest
.getPixel
(75, 75), 0xffffff); // Nothing
749 // Copy red and green channels to blue channel
750 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
751 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 3, 4);
752 check_equals
(dest
.getPixel
(25, 25), 0x000000); // Nothing
753 check_equals
(dest
.getPixel
(75, 25), 0x000000); // Nothing
754 check_equals
(dest
.getPixel
(25, 75), 0x000000); // Nothing
755 check_equals
(dest
.getPixel
(75, 75), 0x000000); // Nothing
757 // Copy red and blue channels to green channel
758 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
759 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 5, 2);
760 check_equals
(dest
.getPixel
(25, 25), 0x000000); // Nothing
761 check_equals
(dest
.getPixel
(75, 25), 0x000000); // Nothing
762 check_equals
(dest
.getPixel
(25, 75), 0x000000); // Nothing
763 check_equals
(dest
.getPixel
(75, 75), 0x000000); // Nothing
765 // Copy green channel to green and blue channels
767 dest
= new flash
.display
.BitmapData(100, 100, true, 0xffffffff);
768 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 2, 6);
769 check_equals
(dest
.getPixel
(25, 25), 0xffffff); // Nothing
770 check_equals
(dest
.getPixel
(75, 25), 0xffffff); // Nothing
771 check_equals
(dest
.getPixel
(25, 75), 0xffffff); // Nothing
772 check_equals
(dest
.getPixel
(75, 75), 0xffffff); // Nothing
774 // Copy red and green channels to blue and green channels
775 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
776 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 3, 6);
777 check_equals
(dest
.getPixel
(25, 25), 0x000000); // Nothing
778 check_equals
(dest
.getPixel
(75, 25), 0x000000); // Nothing
779 check_equals
(dest
.getPixel
(25, 75), 0x000000); // Nothing
780 check_equals
(dest
.getPixel
(75, 75), 0x000000); // Nothing
782 // Copy red and green to red and green.
783 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
784 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 3, 3);
785 check_equals
(dest
.getPixel
(25, 25), 0x000000); // Nothing
786 check_equals
(dest
.getPixel
(75, 25), 0x000000); // Nothing
787 check_equals
(dest
.getPixel
(25, 75), 0x000000); // Nothing
788 check_equals
(dest
.getPixel
(75, 75), 0x000000); // Nothing
790 // Copy green channel to red and green channels
791 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
792 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 2, 3);
793 check_equals
(dest
.getPixel
(25, 25), 0x000000); // Nothing
794 check_equals
(dest
.getPixel
(75, 25), 0x000000); // Nothing
795 check_equals
(dest
.getPixel
(25, 75), 0x000000); // Nothing
796 check_equals
(dest
.getPixel
(75, 75), 0x000000); // Nothing
798 // Copy green channel to blue channel
799 dest
= new flash
.display
.BitmapData(100, 100, true, 0xff000000);
800 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 2, 4);
801 check_equals
(dest
.getPixel
(25, 25), 0x000000); // Nothing
802 check_equals
(dest
.getPixel
(75, 25), 0x0000ff); // Blue
803 check_equals
(dest
.getPixel
(25, 75), 0x000000); // Nothing
804 check_equals
(dest
.getPixel
(75, 75), 0x00007f); // Half blue
806 // -------------------
808 // -------------------
810 src
= new flash
.display
.BitmapData(100, 100, false);
811 src
.fillRect
(new Rect
(0, 0, 50, 50), 0xff0000); // Red channel
812 src
.fillRect
(new Rect
(50, 0, 50, 50), 0x00ffff); // Blue and green channels
813 src
.fillRect
(new Rect
(0, 50, 50, 50), 0xff00ff); // Red and Blue channels
814 src
.fillRect
(new Rect
(50, 50, 50, 50), 0x007f00); // Green channel
816 // Copy red and green to red and green.
817 dest
= new flash
.display
.BitmapData(100, 100, false);
818 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 3, 3);
819 check_equals
(dest
.getPixel
(25, 25), 0xffffff); // Nothing
820 check_equals
(dest
.getPixel
(75, 25), 0xffffff); // Nothing
821 check_equals
(dest
.getPixel
(25, 75), 0xffffff); // Nothing
822 check_equals
(dest
.getPixel
(75, 75), 0xffffff); // Nothing
824 // Copy red and green to red
825 dest
= new flash
.display
.BitmapData(100, 100, false);
826 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 3, 1);
827 check_equals
(dest
.getPixel
(25, 25), 0x00ffff); // Cyan
828 check_equals
(dest
.getPixel
(75, 25), 0x00ffff); // Cyan
829 check_equals
(dest
.getPixel
(25, 75), 0x00ffff); // Cyan
830 check_equals
(dest
.getPixel
(75, 75), 0x00ffff); // Cyan
832 // Copy green to red and blue
833 dest
= new flash
.display
.BitmapData(100, 100, false);
834 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 2, 5);
835 check_equals
(dest
.getPixel
(25, 25), 0xffffff); // White
836 check_equals
(dest
.getPixel
(75, 25), 0xffffff); // White
837 check_equals
(dest
.getPixel
(25, 75), 0xffffff); // White
838 check_equals
(dest
.getPixel
(75, 75), 0xffffff); // White
840 // Copy red and blue to green
841 dest
= new flash
.display
.BitmapData(100, 100, false);
842 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 5, 2);
843 check_equals
(dest
.getPixel
(25, 25), 0xff00ff); // Magenta
844 check_equals
(dest
.getPixel
(75, 25), 0xff00ff); // Magenta
845 check_equals
(dest
.getPixel
(25, 75), 0xff00ff); // Magenta
846 check_equals
(dest
.getPixel
(75, 75), 0xff00ff); // Magenta
848 // Copy green and blue to blue
849 dest
= new flash
.display
.BitmapData(100, 100, false);
850 dest
.copyChannel
(src
, new Rect
(0, 0, 100, 100), new Point(0, 0), 6, 4);
851 check_equals
(dest
.getPixel
(25, 25), 0xffff00); // Yellow
852 check_equals
(dest
.getPixel
(75, 25), 0xffff00); // Yellow
853 check_equals
(dest
.getPixel
(25, 75), 0xffff00); // Yellow
854 check_equals
(dest
.getPixel
(75, 75), 0xffff00); // Yellow
856 // Copy same channel to source range
857 // As the source range is transformed while being processed,
858 // those transformations accumulate to give unexpected
860 dest
= new flash
.display
.BitmapData(100, 100, false, 0x000000);
861 dest
.fillRect
(new Rect
(0, 0, 50, 50), 0x0000ff);
862 dest
.copyChannel
(dest
, new Rect
(0, 0, 100, 100), new Point(4, 4), 4, 4);
863 check_equals
(dest
.getPixel
(52, 6), 0x0000ff);
864 check_equals
(dest
.getPixel
(56, 10), 0x0000ff);
865 check_equals
(dest
.getPixel
(60, 14), 0x0000ff);
866 check_equals
(dest
.getPixel
(96, 50), 0x0000ff);
867 check_equals
(dest
.getPixel
(96, 96), 0x0000ff);
868 check_equals
(dest
.getPixel
(6, 52), 0x0000ff);
869 check_equals
(dest
.getPixel
(10, 56), 0x0000ff);
870 check_equals
(dest
.getPixel
(14, 60), 0x0000ff);
871 check_equals
(dest
.getPixel
(50, 96), 0x0000ff);
872 check_equals
(dest
.getPixel
(96, 96), 0x0000ff);
876 // Tests that a particular color does not appear.
877 testNoColor
= function(bd
, mask
) {
878 var width
= bd
.width
;
879 var height
= bd
.height
;
880 for (var i
= 0; i
< height
; ++i
) {
881 for (var j
= 0; j
< width
; ++j
) {
882 if ( (bd
.getPixel32
(i
, j
) & mask
) != 0) return false;
888 // Get an object representing the range of colour values
890 getColorRange
= function(bd
, mask
) {
892 var width
= bd
.width
;
893 var height
= bd
.height
;
895 var o
= { min
:0xff, max
:0 };
898 if (mask
== 0xff00) shift
= 8;
899 if (mask
== 0xff0000) shift
= 16;
900 if (mask
== 0xff000000) shift
= 24;
902 for (var i
= 0; i
< height
; ++i
) {
903 for (var j
= 0; j
< width
; ++j
) {
904 var pix
= (bd
.getPixel32
(i
, j
) & mask
) >> shift
;
905 if (pix
< o
.min
) o
.min
= pix
;
906 if (pix
> o
.max
) o
.max
= pix
;
912 // Tests that a particular color is within a specified range
913 testColorRange
= function(bd
, mask
, low
, high
) {
914 var width
= bd
.width
;
915 var height
= bd
.height
;
918 if (mask
== 0xff00) shift
= 8;
919 if (mask
== 0xff0000) shift
= 16;
920 if (mask
== 0xff000000) shift
= 24;
922 for (var i
= 0; i
< height
; ++i
) {
923 for (var j
= 0; j
< width
; ++j
) {
924 var pix
= (bd
.getPixel32
(i
, j
) & mask
) >> shift
;
925 if (pix
< low
|| pix
> high
) {
933 // Tests that a particular color is within a specified range
934 testGreys
= function(bd
, low
, high
) {
935 var width
= bd
.width
;
936 var height
= bd
.height
;
938 for (var i
= 0; i
< height
; ++i
) {
939 for (var j
= 0; j
< width
; ++j
) {
940 var r
= (bd
.getPixel32
(i
, j
) & 0xff0000) >> 16;
941 var g
= (bd
.getPixel32
(i
, j
) & 0xff00) >> 8;
942 var b
= (bd
.getPixel32
(i
, j
) & 0xff);
943 if (r
!= g
|| g
!= b
) return false;
944 if (r
< low
|| r
> high
) return false;
950 ns
= new flash
.display
.BitmapData(15, 15, false);
952 // Noise on red and green channels from 0 to 255
953 ns
.noise
(203, 0, 255, 1 | 2);
954 check
(testNoColor
(ns
, 0xff));
956 ns
.noise
(203, 0, 255, 1 | 4);
957 check
(testNoColor
(ns
, 0xff00));
959 // Noise on green and blue from 25 to 150
960 ns
.noise
(203, 25, 150, 2 | 4);
961 check
(testNoColor
(ns
, 0xff0000));
962 // Green should be from 25 to 150
963 check
(testColorRange
(ns
, 0xff00, 25, 150));
964 check
(testColorRange
(ns
, 0xff, 25, 150));
966 // Noise on green from 200 to 201
967 ns
.noise
(203, 200, 201, 2);
968 check
(testColorRange
(ns
, 0xff00, 200, 201));
970 // Noise on blue from 200 to 200
971 ns
.noise
(203, 200, 200, 4);
972 check
(testColorRange
(ns
, 0xff, 200, 200));
974 // Noise on all from 70 to 80
975 ns
.noise
(203, 70, 80);
976 check
(testColorRange
(ns
, 0xff, 70, 80));
977 check
(testColorRange
(ns
, 0xff00, 70, 80));
978 check
(testColorRange
(ns
, 0xff0000, 70, 80));
980 // Equal noise on all from 70 to 80
981 ns
.noise
(203, 70, 80, 0, true);
982 check
(testGreys
(ns
, 70, 80));
984 // Equal noise on all from 0, 200
985 ns
.noise
(203, 0, 200, 0, true);
986 check
(testGreys
(ns
, 0, 200));
989 ns
.noise
(203, 60, 50, 0, true);
990 check
(testGreys
(ns
, 60, 60));
993 ns
.noise
(203, -10, 0, 0, true);
994 check
(testGreys
(ns
, 0, 0));
1000 // No octaves, all black.
1001 ns
.perlinNoise
(100, 100, 0, 1, false, false);
1002 check
(testColorRange
(ns
, 0xff, 0, 0));
1003 check
(testColorRange
(ns
, 0xff00, 0, 0));
1004 check
(testColorRange
(ns
, 0xff0000, 0, 0));
1006 // Same if it's greyscale and has no octaves.
1007 ns
.perlinNoise
(100, 100, 0, 1, false, false, 0, true);
1008 check
(testColorRange
(ns
, 0xff, 0, 0));
1009 check
(testColorRange
(ns
, 0xff00, 0, 0));
1010 check
(testColorRange
(ns
, 0xff0000, 0, 0));
1012 // A greyscale perlin noise should have its pixels all grey!
1013 ns
.perlinNoise
(100, 100, 1, 1, false, false, 0, true);
1014 check
(testGreys
(ns
, 0, 0xff));
1016 ns
= new flash
.display
.BitmapData(40, 40, false);
1018 // Check which pixel values are represented for each channels.
1020 // Note: for the pp the maximum value is only 50 here, but Gnash gets 81.
1021 // Limiting it to 50 makes it look much too dark.
1023 ns
.perlinNoise
(4, 4, 1, 1, false, false);
1025 // The maximum values depend on seed and above all the base values. The
1026 // smaller the base, the likelier we are to get high values. We always have
1027 // low ones. We won't set the bar very high here.
1029 var range
= getColorRange
(ns
, 0xff);
1030 check
(range
.min
< 10 && range
.max
> 40);
1031 trace
(range
.min
+ " " + range
.max
);
1032 range
= getColorRange
(ns
, 0xff00);
1033 check
(range
.min
< 10 && range
.max
> 40);
1034 range
= getColorRange
(ns
, 0xff0000);
1035 check
(range
.min
< 10 && range
.max
> 40);
1037 ns
.perlinNoise
(20, 20, 1, 200, false, false);
1038 // We can't necessarily expect the full range, but
1039 // it should be relatively wide.
1040 range
= getColorRange
(ns
, 0xff);
1041 check
(range
.min
< 10 && range
.max
> 40);
1042 range
= getColorRange
(ns
, 0xff00);
1043 check
(range
.min
< 10 && range
.max
> 40);
1044 range
= getColorRange
(ns
, 0xff0000);
1045 check
(range
.min
< 10 && range
.max
> 40);
1047 // Channel value 0: all black.
1048 ns
.perlinNoise
(50, 50, 1, 1, false, false, 0);
1049 check
(testColorRange
(ns
, 0xff, 0, 0));
1050 check
(testColorRange
(ns
, 0xff00, 0, 0));
1051 check
(testColorRange
(ns
, 0xff0000, 0, 0));
1054 ns
.perlinNoise
(50, 50, 1, 1, false, false, 1);
1055 check
(testColorRange
(ns
, 0xff, 0, 0));
1056 check
(testColorRange
(ns
, 0xff00, 0, 0));
1057 range
= getColorRange
(ns
, 0xff0000);
1058 check
(range
.min
< 10 && range
.max
> 40);
1061 ns
.perlinNoise
(50, 50, 1, 1, false, false, 2);
1062 check
(testColorRange
(ns
, 0xff, 0, 0));
1063 range
= getColorRange
(ns
, 0xff00);
1064 check
(range
.min
< 10 && range
.max
> 40);
1065 check
(testColorRange
(ns
, 0xff0000, 0, 0));
1068 ns
.perlinNoise
(50, 50, 1, 1, false, false, 5);
1069 range
= getColorRange
(ns
, 0xff);
1070 check
(range
.min
< 10 && range
.max
> 40);
1071 check
(testColorRange
(ns
, 0xff00, 0, 0));
1072 range
= getColorRange
(ns
, 0xff0000);
1073 check
(range
.min
< 10 && range
.max
> 40);
1075 // Transparent BitmapData
1077 // Here with no octaves again.
1078 nst
= new flash
.display
.BitmapData(15, 15, true);
1079 nst
.perlinNoise
(100, 100, 0, 1, false, false, 0, true);
1080 check
(testColorRange
(nst
, 0xff, 0, 0));
1081 check
(testColorRange
(nst
, 0xff00, 0, 0));
1082 check
(testColorRange
(nst
, 0xff0000, 0, 0));
1086 orig
= new flash
.display
.BitmapData(10, 10, false, 0x00ff10);
1088 orig
.setPixel
(5, 5, 0x0000ff);
1090 // Cloning doesn't clone non-native properties.
1092 check_equals
(cl
.a
, undefined);
1093 check_equals
(cl
.width
, 10);
1094 check_equals
(cl
.height
, 10);
1095 check_equals
(cl
.getPixel
(2, 2), 0x00ff10);
1096 check_equals
(cl
.getPixel
(5, 5), 0x0000ff);
1097 check_equals
(typeof(cl
.__proto__
), "object");
1098 check_equals
(cl
.__proto__
, orig
.__proto__
);
1099 check_equals
(typeof(cl
.constructor
), "function");
1100 check_equals
(cl
.constructor
, orig
.constructor
);
1102 // The constructor is irrelevant.
1103 orig
.constructor
= 10;
1104 check_equals
(orig
.constructor
, 10);
1106 check_equals
(typeof(cl
.__proto__
), "object");
1107 check_equals
(typeof(cl
.constructor
), "function");
1109 // The prototype is important.
1111 check_equals
(orig
.__proto__
, 8);
1113 check_equals
(cl
.__proto__
, undefined);
1114 check_equals
(cl
.constructor
, undefined);
1116 // What kind of prototype makes this work?
1119 o
.clone
= flash
.display
.BitmapData.prototype
.clone
;
1123 o
.getPixel
= flash
.display
.BitmapData.prototype
.getPixel
;
1126 check_equals
(cl
.__proto__
, o
);
1127 check_equals
(cl
.constructor
, 25);
1128 check_equals
(cl
.width
, 20);
1129 check_equals
(cl
.height
, 21);
1130 cl
.__proto__
= flash
.display
.BitmapData.prototype
;
1131 check_equals
(cl
.width
, 10);
1132 check_equals
(cl
.height
, 10);
1134 e
= flash
.display
.BitmapData.prototype
;
1136 flash
.display
.BitmapData.prototype
= 8;
1137 check_equals
(flash
.display
.BitmapData.prototype
, 8);
1139 check_equals
(typeof(cl
.__proto__
), "object");
1140 check_equals
(typeof(cl
.constructor
), "function");
1142 // The constructor property comes from the original __proto__.
1146 check_equals
(typeof(cl
.__proto__
), "object");
1147 check_equals
(cl
.constructor
, 98);
1149 // Restore to original state!
1151 flash
.display
.BitmapData.prototype
= e
;
1153 //-------------------------------------------------------------
1155 //-------------------------------------------------------------
1159 #endif
// OUTPUT_VERSION >= 8