Snowflakes
#1
[Image: Snowflakes.png]

Here is a modification (mod) of B+'s "Basic Polygon and Multiplier Mod" of snowflakes falling down. He probably has made this before but I thought I would try it myself. 
Thanks B+!

Code: (Select All)
'Snowflakes - mod from B+'s Basic Polygon and Multiplier Mod
'b+ 2022-07-13, SierraKen 2022-07-13

_Title "Snowflakes" 'b+ 2022-07-13, SierraKen 2022-07-13

Dim xc(500), yc(500), r(500), n(500), x(500), y(500)

' a circle is 360 degree
' a polyon of n side has central angles 360 / n  > think of a pie the central angle are the angle of slices in center
Screen _NewImage(800, 600, 32)
_ScreenMove 350, 100

Randomize Timer
Do
    _Limit 30
    If Rnd > .25 Then
        t = t + 1
        If t > 495 Then t = 0
        xc(t) = Rnd * _Width
        yc(t) = 1
        r(t) = Rnd * 20
        n(t) = Int(Rnd * 10) + 3
    End If
    For tt = 1 To t
        yc(tt) = yc(tt) + 1
        For m = 1 To n(tt) - 1
            For angle = 0 To 720 Step 360 / n(tt) ' step the size of pie angles
                ' let xC, yC be the coordinates at the center of the pie circle
                ' let r be the radius of the pie
                ' then the n outside points are
                x(tt) = xc(tt) + r(tt) * Cos(m * _D2R(angle) - _Pi / 2) ' x coordinate of outter edge point
                y(tt) = yc(tt) + r(tt) * Sin(m * _D2R(angle) - _Pi / 2) ' y coordinate of outter edge point
                If angle = 0 Then PSet (x(tt), y(tt)) Else Line -(x(tt), y(tt)) ' outter edge edge
                Line (xc(tt), yc(tt))-(x(tt), y(tt)) ' slice from center of pie
            Next
        Next m
    Next tt
    _Display
    Cls
Loop Until InKey$ = Chr$(27)
Reply


Messages In This Thread
Snowflakes - by SierraKen - 07-14-2022, 02:37 AM
RE: Snowflakes - by James D Jarvis - 07-14-2022, 01:47 PM
RE: Snowflakes - by bplus - 07-14-2022, 04:14 PM
RE: Snowflakes - by SierraKen - 07-14-2022, 05:38 PM
RE: Snowflakes - by SierraKen - 07-14-2022, 07:51 PM
RE: Snowflakes - by James D Jarvis - 07-15-2022, 11:54 AM
RE: Snowflakes - by SierraKen - 07-16-2022, 07:39 PM
RE: Snowflakes - by vinceg2022 - 07-19-2022, 06:14 AM
RE: Snowflakes - by James D Jarvis - 07-19-2022, 05:10 PM
RE: Snowflakes - by SierraKen - 07-19-2022, 11:34 PM



Users browsing this thread: 4 Guest(s)