Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DNA Animation
#8
I DID IT!!!! I was able to make the closer balls overlap the other ones. It's not as hard as I thought. Thanks OldMoses! I used that one to brighten up the balls and I put both you and B+ in the credits in the code. I also slowed it down just a tad to be able to see the overlapping better.

Code: (Select All)
'DNA Animation by SierraKen
'Ball design by B+ and OldMoses
'July 31, 2022

_Title "DNA Animation by SierraKen"
Screen _NewImage(800, 600, 32)
Dim c As Long
t = 180
tt = 45
c = _RGB32(0, 127, 255)
Do
    _Limit 40
    x = (Sin(t) * 180) + 400
    y = (Cos(t) * 180) / _Pi / 10 + 100
    r = (Cos(t) * 180) / _Pi / 10 + 40

    x2 = (Sin(t + .7) * 180) + 400
    y2 = (Cos(t + .7) * 180) / _Pi / 10 + 165
    r2 = (Cos(t + .7) * 180) / _Pi / 10 + 40

    x3 = (Sin(t + 1.4) * 180) + 400
    y3 = (Cos(t + 1.4) * 180) / _Pi / 10 + 230
    r3 = (Cos(t + 1.4) * 180) / _Pi / 10 + 40

    x4 = (Sin(t + 2.1) * 180) + 400
    y4 = (Cos(t + 2.1) * 180) / _Pi / 10 + 295
    r4 = (Cos(t + 2.1) * 180) / _Pi / 10 + 40

    x5 = (Sin(t + 2.8) * 180) + 400
    y5 = (Cos(t + 2.8) * 180) / _Pi / 10 + 360
    r5 = (Cos(t + 2.8) * 180) / _Pi / 10 + 40

    x6 = (Sin(t + 3.5) * 180) + 400
    y6 = (Cos(t + 3.5) * 180) / _Pi / 10 + 425
    r6 = (Cos(t + 3.5) * 180) / _Pi / 10 + 40

    xx = (Sin(tt) * 180) + 400
    yy = (Cos(tt) * 180) / _Pi / 10 + 100
    rr = (Cos(tt) * 180) / _Pi / 10 + 40

    xx2 = (Sin(tt + .7) * 180) + 400
    yy2 = (Cos(tt + .7) * 180) / _Pi / 10 + 165
    rr2 = (Cos(tt + .7) * 180) / _Pi / 10 + 40

    xx3 = (Sin(tt + 1.4) * 180) + 400
    yy3 = (Cos(tt + 1.4) * 180) / _Pi / 10 + 230
    rr3 = (Cos(tt + 1.4) * 180) / _Pi / 10 + 40

    xx4 = (Sin(tt + 2.1) * 180) + 400
    yy4 = (Cos(tt + 2.1) * 180) / _Pi / 10 + 295
    rr4 = (Cos(tt + 2.1) * 180) / _Pi / 10 + 40

    xx5 = (Sin(tt + 2.8) * 180) + 400
    yy5 = (Cos(tt + 2.8) * 180) / _Pi / 10 + 360
    rr5 = (Cos(tt + 2.8) * 180) / _Pi / 10 + 40

    xx6 = (Sin(tt + 3.5) * 180) + 400
    yy6 = (Cos(tt + 3.5) * 180) / _Pi / 10 + 425
    rr6 = (Cos(tt + 3.5) * 180) / _Pi / 10 + 40

    t = t - .05
    tt = tt - .05

    If rr > r Then
        cx = x: cy = y
        drawBall cx, cy, r, c

        cx = xx: cy = yy
        drawBall cx, cy, rr, c
    End If

    If rr < r Then
        cx = xx: cy = yy
        drawBall cx, cy, rr, c
        cx = x: cy = y
        drawBall cx, cy, r, c

    End If

    If rr2 > r2 Then
        cx = x2: cy = y2
        drawBall cx, cy, r2, c

        cx = xx2: cy = yy2
        drawBall cx, cy, rr2, c
    End If

    If rr2 < r2 Then
        cx = xx2: cy = yy2
        drawBall cx, cy, rr2, c
        cx = x2: cy = y2
        drawBall cx, cy, r2, c
    End If

    If rr3 > r3 Then
        cx = x3: cy = y3
        drawBall cx, cy, r3, c
        cx = xx3: cy = yy3
        drawBall cx, cy, rr3, c
    End If
    If rr3 < r3 Then
        cx = xx3: cy = yy3
        drawBall cx, cy, rr3, c
        cx = x3: cy = y3
        drawBall cx, cy, r3, c
    End If

    If rr4 > r4 Then
        cx = x4: cy = y4
        drawBall cx, cy, r4, c
        cx = xx4: cy = yy4
        drawBall cx, cy, rr4, c
    End If
    If rr4 < r4 Then
        cx = xx4: cy = yy4
        drawBall cx, cy, rr4, c
        cx = x4: cy = y4
        drawBall cx, cy, r4, c
    End If

    If rr5 > r5 Then
        cx = x5: cy = y5
        drawBall cx, cy, r5, c

        cx = xx5: cy = yy5
        drawBall cx, cy, rr5, c
    End If

    If rr5 < r5 Then
        cx = xx5: cy = yy5
        drawBall cx, cy, rr5, c
        cx = x5: cy = y5
        drawBall cx, cy, r5, c
    End If


    If rr6 > r6 Then
        cx = x6: cy = y6
        drawBall cx, cy, r6, c

        cx = xx6: cy = yy6
        drawBall cx, cy, rr6, c
    End If

    If rr6 < r6 Then
        cx = xx6: cy = yy6
        drawBall cx, cy, rr6, c
        cx = x6: cy = y6
        drawBall cx, cy, r6, c
    End If

    _Display
    Cls
Loop Until InKey$ = Chr$(27)


Sub drawBall (x, y, r, c As _Unsigned Long)
    Dim rred As Long, grn As Long, blu As Long, rr As Long, f
    rred = _Red32(c): grn = _Green32(c): blu = _Blue32(c)
    For rr = r To 0 Step -1
        f = 1 - Sin(rr / r)
        fillCircle x, y, rr, _RGB32(rred * f, grn * f, blu * f)
    Next
End Sub


'from Steve Gold standard
Sub fillCircle (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub
Reply


Messages In This Thread
DNA Animation - by SierraKen - 07-31-2022, 01:28 AM
RE: DNA Animation - by bplus - 07-31-2022, 03:05 AM
RE: DNA Animation - by SierraKen - 07-31-2022, 03:13 AM
RE: DNA Animation - by OldMoses - 07-31-2022, 01:01 PM
RE: DNA Animation - by bplus - 07-31-2022, 02:51 PM
RE: DNA Animation - by SierraKen - 07-31-2022, 03:43 PM
RE: DNA Animation - by OldMoses - 07-31-2022, 04:12 PM
RE: DNA Animation - by SierraKen - 07-31-2022, 04:21 PM
RE: DNA Animation - by OldMoses - 07-31-2022, 04:47 PM
RE: DNA Animation - by Kernelpanic - 07-31-2022, 04:50 PM
RE: DNA Animation - by bplus - 07-31-2022, 05:05 PM
RE: DNA Animation - by OldMoses - 07-31-2022, 05:24 PM
RE: DNA Animation - by Kernelpanic - 07-31-2022, 06:07 PM
RE: DNA Animation - by SierraKen - 07-31-2022, 07:49 PM
RE: DNA Animation - by OldMoses - 07-31-2022, 08:42 PM
RE: DNA Animation - by SierraKen - 07-31-2022, 07:52 PM
RE: DNA Animation - by SierraKen - 07-31-2022, 09:51 PM
RE: DNA Animation - by OldMoses - 07-31-2022, 10:38 PM
RE: DNA Animation - by bplus - 07-31-2022, 11:10 PM
RE: DNA Animation - by OldMoses - 08-02-2022, 11:39 AM
RE: DNA Animation - by SierraKen - 08-01-2022, 01:03 AM
RE: DNA Animation - by OldMoses - 08-01-2022, 02:11 AM
RE: DNA Animation - by Kernelpanic - 08-01-2022, 12:09 PM
RE: DNA Animation - by James D Jarvis - 08-02-2022, 12:25 PM
RE: DNA Animation - by bplus - 08-02-2022, 03:21 PM
RE: DNA Animation - by SierraKen - 08-02-2022, 08:07 PM
RE: DNA Animation - by OldMoses - 08-02-2022, 09:53 PM



Users browsing this thread: 5 Guest(s)