Нарисовать 3 цветочка и как они растут - VB

Узнай цену своей работы

Формулировка задачи:

Народ помогите плз с заданием... Надо в Visual Basic нарисовать 3 цветочка и как они растут... Допустим красный растет быстрее... зеленый медленее..Крч скорость роста цветков разная и скорость контролируется Scrolllockom !!!Помогите плз!!!

Решение задачи: «Нарисовать 3 цветочка и как они растут»

textual
Листинг программы
Private Type POINTAPI
  X As Long
  Y As Long
End Type
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Const SizePetal = 50
Dim WithEvents tmrTimer As Timer
Private Sub Form_Load()
    Me.FillStyle = vbSolid: Me.ScaleMode = vbPixels: Me.AutoRedraw = True: Me.BackColor = &HFFFF90
    Set tmrTimer = Me.Controls.Add("vb.timer", "tmrtimer")
    tmrTimer.Enabled = True: tmrTimer.Interval = 32
End Sub
Private Sub DrawFlower(X As Long, Y As Long, Color As Long, Size As Single, S As Single, L As Single, _
                       aspect As Single, PetalCount As Long)
    Dim p As Long, d As Double, dat() As POINTAPI, dy As Long, dx As Long, detail As Long, of As Long
    of = SizePetal * 4
    detail = 20
    Me.DrawWidth = 4: Me.ForeColor = &H9020&: Me.FillColor = &H9020&
    d = 1.5707963267949 / detail
    For p = 0 To detail
        dy = -(p / detail) * of * Size + Y
        dx = Sin(d * p) * SizePetal * Size * S + X
        If p Then Me.Line -(dx, dy) Else Me.CurrentX = dx: Me.CurrentY = dy
        If p = Int(detail / L) Then
            CreatePetal dat(), dx, dy, 3.92699081698724, 4, 0.7 * Size, aspect, PetalCount
            Polygon Me.hdc, dat(0), 4
            CreatePetal dat(), dx, dy, 1.85619449019234, 4, 0.5 * Size, aspect, PetalCount
            Polygon Me.hdc, dat(0), 4
        End If
    Next
    Me.DrawWidth = 1: Me.FillColor = Color: Me.ForeColor = 0
    For p = 0 To PetalCount - 1
        CreatePetal dat(), dx, dy, (p / PetalCount) * 6.28318530717959, 40, Size, aspect, PetalCount
        Polygon Me.hdc, dat(0), 40
    Next
    Me.FillColor = vbYellow
    Me.Circle (dx, dy), SizePetal * Size / 2
End Sub
Private Sub CreatePetal(Data() As POINTAPI, X As Long, Y As Long, Angle As Double, detail As Long, _
                        Size As Single, aspect As Single, PetalCount As Long)
    Dim n As Long, d As Double, dx As Single, dy As Single, m As Single, nx As Long, ny As Long
    d = 6.28318530717959 / detail
    dy = SizePetal * Size: dx = dy / aspect
    ReDim Data(detail - 1)
    For n = 0 To detail - 1
        m = Abs((n / detail) * 2 - 1)
        nx = (Sin(d * n)) * dx * m
        ny = (Cos(d * n) + 1) * dy
        Data(n).X = nx * Cos(Angle) - ny * Sin(Angle) + X
        Data(n).Y = nx * Sin(Angle) + ny * Cos(Angle) + Y
    Next
End Sub
 
Private Sub tmrTimer_Timer()
    Static Size1 As Single, Size2 As Single, Size3 As Single
    Me.Cls
    DrawFlower SizePetal, Me.ScaleHeight, vbWhite, Size1, 1, 5, 1.5, 9
    DrawFlower Me.ScaleWidth / 3 + SizePetal, Me.ScaleHeight, &H8080FF, Size2, 0.7, 8, 1, 8
    DrawFlower Me.ScaleWidth / 3 * 2 + SizePetal * 2, Me.ScaleHeight, &HFF80FF, Size3, -0.8, 3, 3, 18
    Size1 = Size1 + Rnd * 0.01: If Size1 > 1 Then Size1 = 1
    Size2 = Size2 + Rnd * 0.01: If Size2 > 1 Then Size2 = 1
    Size3 = Size3 + Rnd * 0.01: If Size3 > 1 Then Size3 = 1
End Sub

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

6   голосов , оценка 3.667 из 5
Похожие ответы