VB:Flags with Stars Tutorial
From Progzoo
Drawing flags: reusing shapes.
Vietnam
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 100, it is centred on 0,0
which is the wrong place. We must translate to put it in the
right place.
test text
Panama
The flag of Panama requires two stars. We can draw the same star
twice.
.
Private Sub drawFlag(g as Graphics)
Dim star() as Point = {new Point(0,-50), _
new Point(11,-16),new Point(48,-16), new Point(18,6), _
new Point(30,42), new Point(0,19), new Point(-30,41), _
new Point(-18,6),new Point(-48,-16),new Point(-11,-16)}
g.FillRectangle(Brushes.White,0,0,600,400)
g.FillRectangle(Brushes.Blue,0,200,300,200)
g.TranslateTransform(150,100)
g.FillPolygon(Brushes.Blue,star)
g.TranslateTransform(150,0)
g.FillPolygon(Brushes.Blue,star)
End Sub
[Font ]
[Default ]
[Show ]
[Resize ]
[History ]
[Profile ]
test text
Bosnia and Herzegovina
The flag of Bosnia and Herzegovina includes 9 white stars.
Each star is 38 right and 38 below the previous star.
.
Private Sub drawFlag(g as Graphics)
g.FillRectangle(Brushes.Blue,0,0,600,304)
g.FillPolygon(Brushes.Yellow,new Point() { _
new Point(160,0),new Point(464,0),new Point(464,304)})
''Star with radius 25
Dim star() as Point = {new Point(0,-25), _
new Point(6,-8),new Point(24,-8), new Point(9,3), _
new Point(15,20), new Point(0,9), new Point(-15,20), _
new Point(-9,3),new Point(-24,-8),new Point(-6,-8)}
g.TranslateTransform(105,0)
g.FillPolygon(Brushes.Yellow,star)
End Sub
[Font ]
[Default ]
[Show ]
[Resize ]
[History ]
[Profile ]
test text
Democratic Republic of Congo (formerly Zaire)
The large star has a radius of 100, the 6 smaller stars have a radius
of 10.
.
Private Sub drawFlag(g as Graphics)
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
g.FillRectangle(Brushes.Blue,0,0,500,300)
Dim star() as Point = {new Point(0,-100), _
new Point(22,-31),new Point(95,-31), new Point(36,12), _
new Point(59,81), new Point(0,38), new Point(-59,81), _
new Point(-36,12),new Point(-95,-31),new Point(-22,-31)}
g.TranslateTransform(250,150)
g.FillPolygon(Brushes.Yellow,star)
g.TranslateTransform(-250,-150)
g.TranslateTransform(50,25)
g.ScaleTransform(0.5f,0.5f)
g.FillPolygon(Brushes.Yellow,star)
End Sub
[Font ]
[Default ]
[Show ]
[Resize ]
[History ]
[Profile ]
test text