April 6, 2017
15:03
COOL GFX DEMO

Public Class Form1
    Public bm As New Bitmap(800, 640)
    Public gfx As Graphics = Graphics.FromImage(bm)

    Public Ray(10, 128)


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Visible = False
        ' plot points using a formula
       
        'xxyy1
        Ray(0, 0) = 0

        Ray(1, 0) = 0
        Ray(2, 0) = 0
        Ray(3, 0) = 100
        Ray(4, 0) = 100
        Ray(5, 0) = 200
        Ray(6, 0) = 1
        Ray(7, 0) = 1
        Ray(8, 0) = 1
        Ray(9, 0) = 1
        'xxyy2
        Ray(0, 1) = 100

        Ray(1, 1) = 100
        Ray(2, 1) = 100
        Ray(3, 1) = 200
        Ray(4, 1) = 200
        Ray(5, 1) = 300

        'xx1yy2
        Ray(0, 2) = 100
        Ray(1, 2) = 100
        Ray(2, 2) = 100
        Ray(3, 2) = 300
        Ray(4, 2) = 300
        Ray(5, 2) = 400
        'xxyy3
        Ray(0, 3) = 200

        Ray(1, 3) = 200
        Ray(2, 3) = 200
        Ray(3, 3) = 400
        Ray(4, 3) = 400
        Ray(5, 3) = 500
        'xxyy4
        Ray(0, 4) = 400

        Ray(1, 4) = 400
        Ray(2, 4) = 400
        Ray(3, 4) = 500
        Ray(4, 4) = 500
        Ray(5, 4) = 600
        'x3yy4
        Ray(0, 5) = 500

        Ray(1, 5) = 500
        Ray(2, 5) = 500
        Ray(3, 5) = 600
        Ray(4, 5) = 600
        Ray(5, 5) = 700

        Timer1.Start()
        Timer2.Start()

        ' do a series if statements
        ' for instance; IF x1 < 100 and y1 > 100 then plot x1 = 50 and y1 = 150
        ' calculate all possible combinations of plots scenarios
        ' there are 3 points to a triangle, and say, 5, points to plot in total
        ' when one point goes off screen, bring another in from the left to takes its place
        ' (xxyy1 xxyy2 xx1yy2)1 (xxyy3 xxyy4 xx3yy4)2

    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim AT00 As New AT(1)
        Dim AT01 As New AT(2)
        Dim AT11 As New AT(3)
        '      Dim AT10 As New AT
        '       Dim AT111 As New AT
        '        Dim AT000 As New AT
        AT00.x1 = Ray(0, 0)
        AT00.y1 = Ray(1, 0)
        AT00.x2 = Ray(2, 0)
        AT00.y2 = Ray(3, 0)
        AT00.x3 = Ray(4, 0)
        AT00.y3 = Ray(5, 0)
        Ray(0, 0) += 1
        AT01.x1 = Ray(0, 1)
        AT01.y1 = Ray(1, 1)
        AT01.x2 = Ray(2, 1)
        AT01.y2 = Ray(3, 1)
        AT01.x3 = Ray(4, 1)
        AT01.y3 = Ray(5, 1)

        AT00.AnimateTriangles(gfx, Ray(0, 0), Ray(1, 0), Ray(2, 0), Ray(3, 0), Ray(4, 0), Ray(5, 0), Ray(6, 0), Ray(7, 0), Ray(8, 0), Ray(9, 0))
        ' AT01.AnimateTriangles(gfx, Ray(0, 0), Ray(1, 4), Ray(2, 0), Ray(3, 4), Ray(4, 0), Ray(5, 4), Ray(6, 0), Ray(7, 0), Ray(8, 0), Ray(9, 0))
        'AT11.AnimateTriangles(gfx, Ray(0, 4), Ray(1, 4), Ray(2, 4), Ray(3, 4), Ray(4, 4), Ray(5, 4), Ray(6, 0), Ray(7, 0), Ray(8, 0), Ray(9, 0))
        'AT10.AnimateTriangles(gfx, Ray(0, 3), Ray(1, 3), Ray(2, 3), Ray(3, 3), Ray(4, 3), Ray(5, 3), Ray(6, 0), Ray(7, 0), Ray(8, 0), Ray(9, 0))
        'AT111.AnimateTriangles(gfx, Ray(0, 2), Ray(1, 2), Ray(2, 2), Ray(3, 2), Ray(4, 2), Ray(5, 2), Ray(6, 0), Ray(7, 0), Ray(8, 0), Ray(9, 0))
        'AT000.AnimateTriangles(gfx, Ray(0, 1), Ray(1, 1), Ray(2, 1), Ray(3, 1), Ray(4, 1), Ray(5, 1), Ray(6, 0), Ray(7, 0), Ray(8, 0), Ray(9, 0))


    End Sub
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

    End Sub
End Class
Class AT
    Public x1 As Integer
    Public y1 As Integer

    Public x2 As Integer
    Public y2 As Integer

    Public x3 As Integer
    Public y3 As Integer

    Sub New(ByVal area)
        If area = 1 Then
            x1 = x1 - 50
            y1 = y1 - 50

            x2 = x2 - 50
            y2 = y2

            x3 = x3
            y3 = y3 + 50


        End If
        If area = 2 Then
            x1 = x1 + 50
            y1 = y1 + 50

            x2 = x2 + 50
            y2 = y2

            x3 = x3
            y3 = y3 + 100


        End If
        If area = 3 Then
            x1 = x1
            y1 = y1

            x2 = x2
            y2 = y2 + 50

            x3 = x3 + 50
            y3 = y3 + 100


        End If
    End Sub
    Private Sub drawTriangle(ByRef gfx, ByVal pen)
        gfx.DrawLine(pen, x1, y1, x2, y2)
        gfx.DrawLine(pen, x2, y2, x3, y3)
        gfx.DrawLine(pen, x1, y1, x3, y3)

        gfx.DrawLine(pen, x1 - 50, y1 - 50, x2, y2)
        gfx.DrawLine(pen, x2, y2, x3, y3)
        gfx.DrawLine(pen, x1 - 50, y1 - 50, x3, y3)
    End Sub

    Public Sub AnimateTriangles(ByRef gfx, ByRef x1, ByRef y1, ByRef x2, ByRef y2, ByRef x3, ByRef y3, ByVal bounce1, ByVal bounce2, ByVal bounce3, ByVal motion)


        drawTriangle(gfx, New Pen(Color.Red))

        gfx.Flush()
        Form1.PictureBox1.Image = Form1.bm
        Application.DoEvents()
        drawTriangle(gfx, New Pen(Color.Gray))

        x1 += bounce1
        x2 += bounce2
        x3 += bounce3

        y1 += motion + bounce1
        y2 += motion + bounce2
        y3 += motion + bounce3

        bounce1 += motion
        bounce2 += motion
        bounce3 += motion

        If bounce1 > 10 Then
            motion = -motion
        End If
        If bounce1 < 1 Then
            motion = -motion
        End If

    End Sub

End Class