be paranoid about empty buffers
[swfdec.git] / test / image / gradient-beginGradientFill.as
bloba30717e4584c8a50182e66fd285e4bd632ca2c84
1 // makeswf -v 7 -s 200x150 -r 1 -o gradient-beginGradientFill.swf gradient-beginGradientFill.as
3 x = 0;
4 y = 0;
6 function do_gradient (type, colors, alphas, ratios) {
7 var matrix = { a:0, b:-80, d:80, e:0, g: x * 100 + 50, h: y * 100 + 50 };
8 beginGradientFill (type, colors, alphas, ratios, matrix);
9 moveTo (x * 100 + 10, y * 100 + 10);
10 lineTo (x * 100 + 10, y * 100 + 90);
11 lineTo (x * 100 + 90, y * 100 + 90);
12 lineTo (x * 100 + 90, y * 100 + 10);
13 lineTo (x * 100 + 10, y * 100 + 10);
14 endFill ();
15 x++;
16 if (x > 3) {
17 x = 0;
18 y++;
22 // 1
23 foo = function (o, s) {
24 if (!o.x)
25 o.x = 7;
26 else
27 o.x--;
28 trace (s + " valueof: " + o.x);
29 return o.x;
31 c = { };
32 c.length = { valueOf: function () { return foo (this, "color"); } };
33 c[0] = c[2] = c[4] = c[6] = c[8] = 0xFF;
34 c[1] = c[3] = c[5] = c[7] = c[9] = 0xFF00;
35 a = { };
36 a.length = { valueOf: function () { return foo (this, "alpha"); } };
37 a[0] = a[2] = a[4] = a[6] = a[8] = 100;
38 a[1] = a[3] = a[5] = a[7] = a[9] = 50;
39 r = { };
40 r.length = { valueOf: function () { return foo (this, "ratios"); } };
41 for (i = 0; i < 10; i++)
42 r[i] = i / 9 * 255;
43 do_gradient ("linear", c, a, r);
45 // 2 - 4
46 o = { };
47 o.length = { valueOf: function () { trace ("length valueOf"); return 3; } };
48 do_gradient ("linear", [0x40, 0xFF0000, 0xFF00], o, [0, 127, 255]);
49 do_gradient ("linear", [0xFF, 0xFF0000, 0xFF00], [100, 100, 100], o);
50 do_gradient ("linear", o, [100, 50, 100], [0, 127, 255]);
52 // 5 - 12
53 do_gradient ("Radial", [0xFF, 0xFF0000, 0xFF00], [255, 255, 255], [0, 127, 255]);
54 do_gradient ("linear", ["255", {valueOf: function () { return 0xFF0000; }}, 0xFF00], [255, 255, 255], [0, 127, 255]);
55 do_gradient ("linear", [ 0xFF, 0xFF00 ], [ undefined, 127 ], [ 0, 255 ]);
56 do_gradient ("linear", [ ], [ ], [ ]);
57 do_gradient ("linear", [ 0xFF ], [ 100 ], [ -1 ]);
58 do_gradient ("linear", [ undefined ], [ 100 ], [ 255.8 ]);
59 do_gradient ("linear", [ 0xFF ], [ 100 ], [ 256 ]);
60 do_gradient ("radial", [0xFF, 0xFF0000, 0xFF00], [50, 100, 255], [undefined, 127, 255]);