Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Happy Valentine's Day!
#11
Cardiac Conic Shape 1B FatLine
Code: (Select All)
_Title "Cardiac Conic Shape 1B Fat Line" 'b+ 2026-02-15
' inspired by CharlieJV BAM version of Richard Russle
' also inspired by today being Valentine's Day

Const xmax = 800, ymax = 600
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 150, 50
Dim Shared blades: blades = 48
Dim Shared hX(1 To blades), hY(1 To blades)
Dim Shared OCX(1 To blades), OCY(1 To blades)
Dim pal~&(1 To blades)
For i = 1 To blades
    pal~&(i) = _RGB32(255, (blades - i) / blades * 64 + 64, i / blades * 255)
Next
i = 0
' BIG outer circle map points from bottom of screen like heart is mapped
CX = xmax / 2
CY = ymax / 2
BigCircRadius = ymax / 2 - 10
'map the outer circle OCX, OCY points  once and for all time!
For a = _Pi(.5) To _Pi(2.5) - .001 Step _Pi(2 / blades)
    i = i + 1
    OCX(i) = CX + BigCircRadius * Cos(a)
    OCY(i) = CY + BigCircRadius * Sin(a)
Next

' heart
hCircRadius = .15 * BigCircRadius
a = -_Pi
While _KeyDown(27) = 0
    Cls
    ' recalc heart points from new position
    hOrigX = CX + hCircRadius * Cos(a)
    hOrigY = CY + hCircRadius * Sin(a)
    MapHeart hOrigX, hOrigY, 12
    ' draw line from center to heart point
    Color pal~&(1)
    For i = 1 To blades

        FatLine CX, CY, hX(i), hY(i), 5
        ' and line from heart point to outer circle
        FatLine hX(i), hY(i), OCX(i), OCY(i), 5
        If (i Mod 2 = 0) Then
            Color pal~&(i - 1)
            FatLine hX(i), hY(i), hX(i - 1), hY(i - 1), 5
            FatLine OCX(i), OCY(i), OCX(i - 1), OCY(i - 1), 5
        End If
    Next
    _Display
    _Limit 30
    a = a + _Pi(1 / 45)
    If a > _Pi Then a = -_Pi
Wend


'Reference and thanks to:
' http://mathworld.wolfram.com/HeartCurve.html
' find the 6th heart curve equations #7, 8
Function xCard (t)
    xCard = 16 * Sin(t) ^ 3
End Function

Function yCard (t)
    yCard = 13 * Cos(t) - 5 * Cos(2 * t) - 2 * Cos(3 * t) - Cos(4 * t)
End Function

Sub MapHeart (cx, cy, magnify)
    ' dim shared hX, hY 1 to blades
    For a = -_Pi To _Pi - .001 Step _Pi(2 / blades)
        i = i + 1
        hX(i) = cx + magnify * xCard(a)
        hY(i) = cy - magnify * yCard(a)
    Next
End Sub

' 2023-09-27 000Test/Graphics/FatLine test and demo
Sub FatLine (x, y, x2, y2, wide As Integer)
    ' this sub needs fcirc
    Dim dx, dy, distance, r
    dx = x2 - x
    dy = y2 - y
    distance = _Hypot(dx, dy)
    r = Int(wide / 2)
    If distance Then '  bullet proof
        dx = dx / distance
        dy = dy / distance
        If r = 0 Then
            Line (x, y)-(x2, y2), c
        Else
            Dim i As Long
            While i <= distance
                FCirc x + i * dx, y + i * dy, r
                i = i + 1
            Wend
        End If
    Else
        If r = 0 Then ' bullet proof
            PSet (x, y), c
        Else
            FCirc x, y, r
        End If
    End If
End Sub

Sub FCirc (CX As Long, CY As Long, R As Long)
    Dim Radius As Long, RadiusError As Long
    Dim X As Long, Y As Long
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY): Exit Sub
    Line (CX - X, CY)-(CX + X, CY), , 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), , BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), , BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), , BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), , BF
    Wend
End Sub

   
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Happy Valentine's Day! - by bplus - 02-15-2026, 02:56 AM
RE: Happy Valentine's Day! - by bplus - 02-15-2026, 03:58 AM
RE: Happy Valentine's Day! - by PhilOfPerth - 02-15-2026, 04:51 AM
RE: Happy Valentine's Day! - by Magdha - 02-15-2026, 10:05 AM
RE: Happy Valentine's Day! - by bplus - 02-15-2026, 03:31 PM
RE: Happy Valentine's Day! - by NakedApe - 02-15-2026, 04:51 PM
RE: Happy Valentine's Day! - by Dimster - 02-15-2026, 05:19 PM
RE: Happy Valentine's Day! - by bplus - 02-15-2026, 05:24 PM
RE: Happy Valentine's Day! - by bplus - 02-15-2026, 05:53 PM
RE: Happy Valentine's Day! - by SMcNeill - 02-15-2026, 05:58 PM
RE: Happy Valentine's Day! - by bplus - 02-15-2026, 07:56 PM
RE: Happy Valentine's Day! - by Kernelpanic - 02-15-2026, 08:38 PM
RE: Happy Valentine's Day! - by bplus - 02-15-2026, 08:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Happy Independence Day! bplus 3 841 07-07-2025, 10:54 PM
Last Post: bobalooie
  Happy New Year Globe! SierraKen 2 830 01-01-2025, 08:57 PM
Last Post: SierraKen
  Happy New Year! bplus 3 1,438 01-01-2023, 08:35 AM
Last Post: gaslouk
  Happy 4th of July! SierraKen 2 951 07-05-2022, 06:56 PM
Last Post: SierraKen
  DOW - Happy Birthday, Merry Christmas, When? TarotRedhand 5 1,240 05-24-2022, 09:25 PM
Last Post: dcromley

Forum Jump:


Users browsing this thread: 1 Guest(s)