Task3: composition using loops
(Downloadable
.swf file
and
.fla file
)
Code
#
include
"Canvas.as"
var
C
=
new
Canvas
(
)
;
//set initial properties
C
.
setBackgroundColor
(
1
,
1
,
1
)
//ovals' width and height varible
var
width
=
0
,
height
=
0
;
//Pen setup
C
.
setPenWeight
(
.
04
)
;
// oval loop virables
var
i
=
0
;
var
numRings
=
8
;
var
inc
=
1
/
(
numRings
*
2
)
;
// pencolor varible
var
pc
=
0
;
while
(
(
i
<
numRings
)
&
&
(
pc
<
=
1
)
)
{
//draw ovals
// red ovals
C
.
drawOval
(
false
,
.
5
,
0
,
width
,
height
)
;
C
.
setPenColor
(
1
,
1
-
pc
,
1
-
pc
)
;
//orange ovals
C
.
drawOval
(
false
,
.
125
,
.
125
,
width
,
height
)
;
C
.
setPenColor
(
1
,
1
-
pc
,
0
)
;
//yellow ovals
C
.
drawOval
(
false
,
0
,
.
5
,
width
,
height
)
;
C
.
setPenColor
(
1
,
1
,
1
-
pc
)
;
//light green ovals
C
.
drawOval
(
false
,
.
125
,
.
875
,
width
,
height
)
;
C
.
setPenColor
(
1
-
pc
,
1
,
1
-
pc
)
;
//dark green ovals
C
.
drawOval
(
false
,
.
5
,
1
,
width
,
height
)
;
C
.
setPenColor
(
0
,
1
-
pc
,
0
)
;
//dark blue ovals
C
.
drawOval
(
false
,
.
875
,
.
875
,
width
,
height
)
;
C
.
setPenColor
(
1
-
pc
,
1
-
pc
,
1
)
;
// light blue ovals
C
.
drawOval
(
false
,
1
,
.
5
,
width
,
height
)
;
C
.
setPenColor
(
1
-
pc
,
1
,
1
)
;
//purple ovals
C
.
drawOval
(
false
,
.
875
,
.
125
,
width
,
height
)
;
C
.
setPenColor
(
1
,
1
-
pc
,
1
)
;
// oval width and height increasing
width
+
=
inc
;
height
+
=
inc
;
i
+
+
;
//pencolor getting dark from center to edge
pc
+
=
.
08
;
}