Как нарисовать флаг Исландии - VB
Формулировка задачи:
помогите пожалуйста нарисовать флаг Исландии в Visual Basic задание №3
Решение задачи: «Как нарисовать флаг Исландии»
textual
Листинг программы
Option Explicit Dim W As Single, H As Single, p As Object Const PI = 3.14159265 Private Sub Form_Load() Picture1.AutoRedraw = True W = Picture1.Width: H = Picture1.Height Set p = Picture1 p.ScaleMode = 3 Call FlagRussia End Sub Private Sub Option1_Click(Index As Integer) p.Cls Select Case Index Case 1: Call FlagRussia Case 2: Call FlagGermany Case 3: Call FlagUSA Case 4: Call FlagFrance Case 5: Call FlagGreece Case 6: Call FlagUkraine Case 7: Call FlagIceLand End Select End Sub Sub FlagUkraine() p.Line (0, 0)-(W, H / 2), vbBlue, BF p.Line (0, H / 2)-(W, H), vbYellow, BF End Sub Sub FlagGreece() Dim i As Integer, strip As Single p.BackColor = vbWhite strip = H / 9 For i = 1 To 9 Step 2 p.Line (0, strip * (i - 1))-(W, strip * i), vbBlue, BF Next i p.Line (0, 0)-(W / 2, strip * 5), vbBlue, BF p.Line (W / 5, 0)-(W / 5 + strip, strip * 5), vbWhite, BF p.Line (0, strip * 2)-(W / 2, strip * 3), vbWhite, BF End Sub Sub FlagFrance() p.Line (0, 0)-(W / 3, H), vbBlue, BF p.Line (W / 3, 0)-(W - W / 3, H), vbWhite, BF p.Line (W - W / 3, 0)-(W, H), vbRed, BF End Sub Sub FlagRussia() p.Line (0, 0)-(W, H / 3), vbWhite, BF p.Line (0, H / 3)-(W, H - H / 3), vbBlue, BF p.Line (0, H - H / 3)-(W, H), vbRed, BF End Sub Sub FlagGermany() p.Line (0, 0)-(W, H / 3), vbBlack, BF p.Line (0, H / 3)-(W, H - H / 3), vbRed, BF p.Line (0, H - H / 3)-(W, H), vbYellow, BF End Sub Sub FlagIceLand() Dim i As Integer, StripW As Single, StripH As Single StripW = W / 9: StripH = H / 6 p.BackColor = vbBlue p.Line (StripW * 2.3, 0)-(StripW * 3.7, H), vbWhite, BF p.Line (0, StripH * 2.3)-(W, StripH * 3.7), vbWhite, BF p.Line (StripW * 2.5, 0)-(StripW * 3.5, H), vbRed, BF p.Line (0, StripH * 2.5)-(W, StripH * 3.5), vbRed, BF End Sub Sub FlagUSA() Dim px(1 To 11) As Single, py(1 To 11) As Single, x0 As Single, y0 As Single, r As Integer Dim a As Integer, i As Integer, j As Integer, k As Integer, strip As Single p.BackColor = vbWhite strip = H / 13 For i = 1 To 13 Step 2 p.Line (0, strip * (i - 1))-(W, strip * i), vbRed, BF Next i p.Line (0, 0)-(W / 2, strip * 7), vbBlue, BF p.DrawWidth = 2 For j = 1 To 6 For k = 1 To 5 a = 18 x0 = (j - 1) * (strip * 1.9) + strip / 2: y0 = (k - 1) * (strip * 1.5) + strip / 2: r = 5 For i = 1 To 10 If (i Mod 2 = 0) Then px(i) = x0 + Round(r / 2.75 * Cos(a * 2 * PI / 360)) py(i) = y0 - Round(r / 2.75 * Sin(a * 2 * PI / 360)) Else px(i) = x0 + Round(r * Cos(a * 2 * PI / 360)) py(i) = y0 - Round(r * Sin(a * 2 * PI / 360)) End If a = a + 36 Next i px(11) = px(1): py(11) = py(1) For i = 1 To 10 p.Line (px(i), py(i))-(px(i + 1), py(i + 1)), vbWhite Next i p.FillStyle = 0: p.FillColor = vbWhite p.Circle (x0, y0), r / 3, vbWhite Next k Next j For j = 1 To 5 For k = 1 To 4 a = 18 x0 = (j - 1) * (strip * 1.9) + strip * 1.3: y0 = (k - 1) * (strip * 1.5) + strip * 1.3: r = 5 For i = 1 To 10 If (i Mod 2 = 0) Then px(i) = x0 + Round(r / 2.75 * Cos(a * 2 * PI / 360)) py(i) = y0 - Round(r / 2.75 * Sin(a * 2 * PI / 360)) Else px(i) = x0 + Round(r * Cos(a * 2 * PI / 360)) py(i) = y0 - Round(r * Sin(a * 2 * PI / 360)) End If a = a + 36 Next i px(11) = px(1): py(11) = py(1) For i = 1 To 10 p.Line (px(i), py(i))-(px(i + 1), py(i + 1)), vbWhite Next i p.FillStyle = 0: p.FillColor = vbWhite p.Circle (x0, y0), r / 3, vbWhite Next k Next j End Sub
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д