Announcement

Collapse
No announcement yet.

Amazingly small code but phenomenal effects

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Amazingly small code but phenomenal effects

    Ive been trying to port this over from VB to PB by modifying the cool.bas demo, but im not having much luck (havent figured out how to clear or update a picture, get its size/height etc yet), so if anyone else wants a crack id love to see it running under PB - it was very smooth under VB, but id be able to do more with it if it was in PB, and I realllly dont like intensive graphics in VB programs :-)
    Just start a new project in VB, add a picturebox (Picture1) thats the same size as the form, set it to Autoredraw=True, and copy this code across.. press F5 and youll be pleasantly surprised at the strange visual properties of relatively simple maths ... (i was anyway)
    Especially with a nice bitmap background, it looks quite stunning, especially considering the code behind it. Wish i understood maths a bit more

    Code:
    Private Sub Form_Load()
        Dim ang As Variant
        Dim x1 As Variant, y1 As Variant, x2 As Variant, y2 As Variant
        Dim q As Integer
        Dim lados As Integer
        Const Lads = 70
        y1 = Picture1.ScaleHeight / 2
        x1 = Picture1.ScaleWidth / 2
        y2 = Picture1.ScaleHeight / 2
        x2 = Picture1.ScaleWidth / 2
        Picture1.Cls
        ang = ((360 / Lads) / (180 / 3.14))
        For q = 0 To 25210 Step 10
            Picture1.Cls
            ang = ((q / Lads) / (180 / 3.14))
            y1 = Picture1.ScaleHeight / 2
            x1 = Picture1.ScaleWidth / 2
            y2 = Picture1.ScaleHeight / 2
            x2 = Picture1.ScaleWidth / 2
            For lados = 1 To Lads
                x1 = x1 + ((Sin(ang) * lados) * 30)
                y1 = y1 + ((Cos(ang) * lados) * 30)
                ang = ((q / Lads) / (180 / 3.14)) * lados + 5
                x2 = x2 + ((Sin(ang) * lados) * 30)
                y2 = y2 + ((Cos(ang) * lados) * 30)
                Picture1.Line (x1, y1)-(x2, y2), RGB(255 / Lads * lados, 0, 0)
                ang = ((q / Lads) / (180 / 3.14)) * lados - 5
            Next
            Picture1.Refresh
            DoEvents
        Next
    End Sub


    [This message has been edited by Wayne Diamond (edited December 02, 2000).]
    -
Working...
X