Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Snowflakes
#5
To make more realistic snowflakes, I changed n (points) to just 13 which is my favorite one. I also added background hills that change with the Space Bar and the Copy to Clipboard feature in case people want to make their own Christmas decorations or cards using another graphics program to paste it to. I also added the ability for the snowflakes to wiggle and the smaller ones move faster to simulate depth, as well as a blue sky. 


[Image: Snowflakes-with-hills.png]



Code: (Select All)
'Snowflakes - mod from B+'s Basic Polygon and Multiplier Mod
'b+ 2022-07-13, SierraKen 2022-07-13
'Changed n to only be 13 so I got rid of n.
'Added hills and clipboard.
'Added the snowflakes to wiggle and move at different speeds.

_Title "Snowflakes - Space Bar changes hills - C copies to clipboard - Esc quits" 'b+ 2022-07-13, SierraKen 2022-07-13

Dim xc(500), yc(500), r(500), x(500), y(500), fx(500), rr(500), hillx(100), sz3(100)
Dim img As Long

Screen _NewImage(800, 600, 32)
_ScreenMove 350, 100
start:
Cls
Randomize Timer
Paint (0, 50), _RGB32(0, 128, 255)
For hills = 3 To 20
    cl = 255
    hillx(hills) = Rnd * 800
    sz = (Rnd * 300) + 100
    For sz2 = .25 To sz Step .25
        cl = cl - .05
        sz3(hills) = sz2
        Circle (hillx(hills), 600), sz2, _RGB32(cl, cl, cl)
    Next sz2
Next hills


Do
    _Limit 2000
    Paint (0, 50), _RGB32(0, 128, 255)
    For hills = 3 To 20
        cl = 255
        For sz2 = .25 To sz3(hills) Step .25
            cl = cl - .075
            Circle (hillx(hills), 600), sz2, _RGB32(cl, cl, cl)
        Next sz2
    Next hills
    If Rnd > .75 Then
        t = t + 1
        If t > 495 Then t = 0
        xc(t) = Rnd * _Width
        yc(t) = -40
        r(t) = Rnd * 40
        rr(t) = 40 / r(t)
        fx(t) = (Rnd * 8) - 4
    End If
    For tt = 1 To t
        yc(tt) = yc(tt) + rr(tt)
        fx(tt) = fx(tt) + (Rnd * 8) - 4
        For m = 1 To 13 - 1
            For angle = 0 To 720 Step 360 / 13 ' 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) + fx(tt), y(tt)) Else Line -(x(tt) + fx(tt), y(tt)) ' outter edge edge
                Line (xc(tt) + fx(tt), yc(tt))-(x(tt) + fx(tt), y(tt)) ' slice from center of pie
            Next
        Next m
    Next tt
    a$ = InKey$
    If a$ = " " Then GoTo start:
    If a$ = Chr$(27) Then End
    If a$ = "c" Or a$ = "C" Then
        _AutoDisplay
        If img& <> 0 Then _FreeImage (img&)
        img& = _CopyImage(0)
        _ClipboardImage = img&
        _Delay .25
        Color _RGB32(0, 0, 0), _RGB32(0, 128, 255)
        Locate 1, 1: Print "Copied To Clipboard"
        Color _RGB32(255, 255, 255)
        _Delay 2
    End If
    _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)