The flag of Vietnam has a yellow five pointed star on a red
background. This star is a popular device on many flags, we define
the star once and use it many times in later flags.
The given star has a radius of 50, it is centred on 0,0
which is the wrong place. We must translate to put it in the
right place.
We can use the translate method to move the star to the right location.
The translate call is to the wrong location (50,50) - it should be at
(100,75).
We use 10 points to define the five pointed star. We could use the
same method as previously:
We can construct a polygon with two arrays of integers.
The first array holds the x values, the second array hold the y values.
We also tell the constructor how big the array is (10 in this case).
We can give an array of integers using the phrase
You can copy the large star from the Vietnam example. To draw the smaller
stars we can translate to the right place, then scale to
the right size. The scale method makes following fill and
translate actions smaller of bigger depending on the value given.
For example the following draws the star half size.
g.scale(0.5, 0.5);
g.fillPolygon(star);
Beware that the scale operation effects accumulate and any translate
following a scale will be effected.