locked
Programming Graphics RRS feed

  • Question

  • Hello,

    I am mostly interested in writing programs to explore fractals. I find no help in any tutorial I have found to assist me. even worse, I cannot seem to get the procedure right for creating the simples program. In visual basic 4 or 6 for example I could write :

    Public Sub Main()
    '......... Lorenz Attractor according to Roger
    'Stevens Fractal Programming in C
    Cls
    ScaleMode = 3
    AutoRedraw = False
    '
    Do
    Cls
    Randomize Timer
    xangle = Rnd * 360
    yangle = Rnd * 360
    zangle = Rnd * 360

    txtX.Text = " x=" + Str$(xangle)
    txtY.Text = " y=" + Str$(yangle)
    txtZ.Text = " z=" + Str$(zangle)


    pi = 4 * Atn(1) / 180

    'Convert from Radians to Degrees
    xangle = xangle * pi
    yangle = yangle * pi
    zangle = zangle * pi
      

    sx = Sin(xangle)
    CX = Cos(xangle)

    sy = Sin(yangle)
    CY = Cos(yangle)

    sz = Sin(zangle)
    cz = Cos(zangle)

    x = 0
    y = 1
    z = 0

    dt = 0.01
    dt2 = dt / 2
    third = 0.333333333
    xscale = 75: yscale = 75
    Scale (-xscale, -yscale)-(xscale, yscale)

    For i = 0 To 32000
        
        DoEvents
        d0_x = 10 * (y - x) * dt2
        d0_y = (-x * z + 28 * x - y) * dt2
        d0_z = ((x * y) - 8 * z / 3) * dt2
       
        xt = x + d0_x
        yt = y + d0_y
        zt = z + d0_z
        d1_x = (10 * (yt - xt)) * dt2
        d1_y = (-xt * zt + 28 * xt - yt) * dt2
        d1_z = (xt * yt - 8 * zt / 3) * dt2
       
        xt = x + dt_x
        yt = y + d1_y
        zt = z + d1_z
       
        d2_x = (10 * (yt - xt)) * dt
        d2_y = (-xt * zt + 28 * xt - yt) * dt
        d2_z = (xt * yt - 8 * zt / 3) * dt
       
        xt = x + d2_x
        yt = y + d2_y
        zt = z + d2_z
       
        d3_x = (10 * (yt - xt)) * dt2
        d3_y = (-x * zt + 28 * xt - yt) * dt2
        d3_z = (xt * yt - 8 * zt / 3) * dt2
       
        old_y = y
        x = x + (d0_x + d1_x + d1_x + d2_x + d3_x) * third
        y = y + (d0_y + d1_y + d1_y + d2_y + d3_y) * third
        z = z + (d0_z + d1_z + d1_z + d2_z + d3_z) * third
       
       
        temp_x = x * CX + y * CY + z * cz
        temp_y = x * sx + y * sy + z * sz
       
        Col = temp_x
        Row = temp_y
       
        old_row = Row
        old_col = Col
       
        rx = Abs(Int(x * 15)) + 20 Mod 94 'x 255
        gx = Abs(Int(y * 60)) Mod 185 'x  190
        bx = Abs(Int(x + y * 90)) Mod 255 'x+y 64
       
       
        PSet (Col, Row), RGB(rx, gx, bx)
        Next i
    Loop
       
       
      

    End Sub

    I can't even find where/how to create a procedure.  I did find that Pset does not exist ion vb2005 express. Perhaps someone can inform me. I spent 13 hours downloading vb2005 express for free and would like to get started here <s>. I hope you can understand and be patient. If I can figure out the mechanics I'm sure I will like this language, but at teh moment I am extremely frustrated . Thanks

    Tuesday, March 14, 2006 7:27 PM

Answers

  • If you are familiar with VB4/5/6 then there's a bit of help for yo. Even if you aren't familiar with rpogramming, here's where you need to start:

    1. Open up Visual Basic 2005
    2. Click Help
    3. Select How Do I...

    There should be a list of items. Start off with the first one, 'Learn the Visual Basic Language'. No matter how clever a programmer anyone is, it's always a great place to start. One of the items in there is 'Drawing Pictures: Using Graphics'.

    That should get you going.

    p.s. I'll note that trying to 'replicate' what you did in previous VB languages (VB Classic) is probably an exersize in frustration: there are many, many, new methods properties, etc. that you can do what you want much easier than you could in VB6.

    There's a learning curve, of course, but the results are well worth going through the afformentioned help files.

    Tuesday, March 14, 2006 9:40 PM

All replies

  •  

    How to create a procedure

     

    Private Sub Todlin(Byval Username as string, Byval Description as string)

     

    textbox1.text = Username + " is " + description

     

    End Sub

     

    How to call a procedure:

    Todlin("Todlin", "cool")

     

    Have fun !

     

     

     

    Tuesday, March 14, 2006 8:41 PM
  • If you are familiar with VB4/5/6 then there's a bit of help for yo. Even if you aren't familiar with rpogramming, here's where you need to start:

    1. Open up Visual Basic 2005
    2. Click Help
    3. Select How Do I...

    There should be a list of items. Start off with the first one, 'Learn the Visual Basic Language'. No matter how clever a programmer anyone is, it's always a great place to start. One of the items in there is 'Drawing Pictures: Using Graphics'.

    That should get you going.

    p.s. I'll note that trying to 'replicate' what you did in previous VB languages (VB Classic) is probably an exersize in frustration: there are many, many, new methods properties, etc. that you can do what you want much easier than you could in VB6.

    There's a learning curve, of course, but the results are well worth going through the afformentioned help files.

    Tuesday, March 14, 2006 9:40 PM
  • I am also interested in fractals, mandelbrots and the like. Are there examples a person could follow in the MSDN Library once the mechanics of the language have been learned ? While no expert programmer I don't think my vb6 programs will run or can be converted to run in this version of visual basic so I'll have to create them fresh. THANKS.

     

    Saturday, January 12, 2008 4:51 AM