My Creative Computer Programming Practice: Introduction and First Work

 I first learned the computer programming language Processing in Fall 2021, my first quarter at the University of California, Santa Barbara. The class was ART 22: Computer Programming for the Arts. I had always been familiar with computer programming as my father is a programmer. Learning my first programming language opened up a new realm of opportunity for me.

Since learning Processing (an extension of Java that utilizes p5.js), I have learned JavaScript, Visual Basic, HTML/CSS, and p5.js. This post is focused on the executable file window as a canvas.

These projects feature the use of Processing and Visual Basic to create basic animations and bring my illustrations to life. Provided is a screenshot of the looping programs and the code.

The cat, named Ong (meow in Korean), belongs to one of my good friends in South Korea. Ong is quite an adventurer. He loves to run outside and gets dandelions stuck to his head.

The code shown is from Visual Studio/VB which is more verbose than Processing but also more consolidated and versatile, the WinForms app build ideal for these types of works.

Public Class Form1
    Private OngX() As Single
    Private OngY() As Single
    Private ongWidth As Single = 245
    Private OngHeight As Single = 499
    Private xSpeed() As Single
    Private ySpeed() As Single
    Private xDirection() As Single
    Private yDirection() As Single
    Private ong() As Image
    Private diameter As Single = 80
    Private dandelionSpeed() As Single
    Private GSX As Integer
    Private dandelionXPos() As Single
    Private dandelionYPos() As Single
    Private curveSlowerDowner() As Single
    Private frameCount = 60
    Private dandelion() As Image
    Private i As Integer = 0

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
        Timer1.Interval = 33
        Timer1.Start()
        ReDim dandelion(74)
        ReDim ong(4)
        ReDim dandelionXPos(74)
        ReDim dandelionYPos(74)
        ReDim dandelionSpeed(74)
        ReDim xDirection(4)
        ReDim yDirection(4)
        ReDim xSpeed(4)
        ReDim ySpeed(4)
        ReDim OngX(4)
        ReDim OngY(4)
        ReDim curveSlowerDowner(74)
        For n = 0 To 74
            dandelionXPos(n) = Rnd() * 1921
            dandelionYPos(n) = -40
            dandelionSpeed(n) = 2 * Rnd() - 2
            curveSlowerDowner(n) = (51 * Rnd() + 25)
            dandelion(n) = Bitmap.FromFile("C:\Users\genev\Pictures\arts\stickers\dandelion resized.png")
        Next
        For v = 0 To 4
            xDirection(v) = 2 * Rnd() + 3
            yDirection(v) = 2 * Rnd() + 3
            xSpeed(v) = 1.5 * Rnd() + 0.5
            ySpeed(v) = 1.5 * Rnd() + 0.5
            OngX(v) = (Label1.Width - ongWidth + 1) * Rnd()
            OngY(v) = (Label1.Height - OngHeight + 1) * Rnd()
            ong(v) = Bitmap.FromFile("C:\Users\genev\Pictures\arts\stickers\ong transparent small.png")
        Next
    End Sub


    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Label1.Invalidate()
    End Sub


    Private Sub Label1_Paint(sender As Object, e As PaintEventArgs) Handles Label1.Paint
        frameCount += 1
        Dim gr0 = e.Graphics
        For n = 0 To 74
            dandelionYPos(n) = dandelionYPos(n) - dandelionSpeed(n)
            dandelionXPos(n) = dandelionXPos(n) + Math.Sin(frameCount / curveSlowerDowner(n))
            If dandelionYPos(n) > Label1.Height Then
                dandelionYPos(n) = -80
            End If
            gr0.DrawImage(dandelion(n), dandelionXPos(n), dandelionYPos(n), diameter, diameter)
        Next

        For v = 0 To 4
            OngX(v) += (xSpeed(v) * xDirection(v))
            OngY(v) += (ySpeed(v) * yDirection(v))

            If (OngX(v) < 0) Or (OngX(v) > (Label1.Width - ongWidth)) Or (OngY(v) < 0) Or (OngY(v) > (Label1.Height - OngHeight)) Then
                '  xSpeed(v) = -xSpeed(v)
            End If
            If (OngY(v) > (Label1.Height - OngHeight)) Then
                yDirection(v) *= -1
                OngY(v) = Label1.Height - OngHeight
            End If
            If (OngY(v) < 0) Then
                yDirection(v) *= -1
                OngY(v) = 0
            End If
            If (OngX(v) > (Label1.Width - ongWidth)) Then
                OngX(v) = Label1.Width - ongWidth
                xDirection(v) *= -1
            End If
            If (OngX(v) < 0) Then
                OngX(v) = 0
                xDirection(v) *= -1
            End If

            gr0.DrawImage(ong(v), OngX(v), OngY(v), ongWidth, OngHeight)
        Next
    End Sub



    Private Sub Label1_DoubleClick(sender As Object, e As EventArgs) Handles Label1.DoubleClick
        Me.Close()
    End Sub
End Class


Popular Posts

Image

Bottle