Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The Curve statement, an improved Circle
#1
Code: (Select All)

handle& = _NewImage(800, 600, 32)
Screen handle&

'-----------------------EXAMPLES------------------------------
curve 100, 100, 30, 1, 15, _RGB(250, 0, 0), 0, 90
curve 100, 100, 30, 1, 15, _RGB(0, 250, 0), 90, 180
curve 100, 100, 30, 1, 15, _RGB(0, 0, 250), 180, 270
curve 100, 100, 30, 1, 15, _RGB(250, 250, 0), 270, 360
curve 100, 100, 1, 1, 15, _RGB(250, 250, 250), 0, 360
curve 500, 400, 50, 1.5, 15, _RGB(250, 0, 0), 0, 60
curve 600, 250, 50, .5, 15, _RGB(250, 0, 0), 90, 210
curve 700, 400, 50, 1.5, 5, _RGB(0, 250, 0), 45, 135
curve 650, 400, 50, .5, 5, _RGB(0, 250, 0), 135, 270
curve 600, 200, 50, 1.5, 15, _RGB(0, 0, 250), 145, 235
curve 650, 290, 50, .5, 15, _RGB(0, 0, 250), 15, 170
curve 400, 150, 50, 1.5, 15, _RGB(50, 0, 150), 145, 160
curve 550, 270, 100, 1.8, 35, _RGB(50, 0, 150), 80, 270

curve 180, 400, 50, .5, 15, _RGB(0, 250, 0), 0, 180
curve 190, 400, 50, .8, 10, _RGB(0, 250, 0), 30, 180
curve 160, 410, 20, .8, 10, _RGB(0, 250, 0), 15, 140
curve 90, 395, 60, .7, 11, _RGB(0, 250, 0), 0, 120
curve 90, 400, 55, .6, 12, _RGB(0, 250, 0), 0, 160
curve 100, 415, 40, .8, 10, _RGB(0, 250, 0), 30, 140
curve 335, 400, 190, 1.5, 18, _RGB(80, 80, 0), 180, 230

curve 235, 500, 20, 1.5, 4, _RGB(230, 80, 0), 0, 360
curve 230, 540, 20, 1.5, 4, _RGB(230, 80, 0), 0, 45
curve 285, 482, 30, .55, 4, _RGB(230, 80, 0), 0, 90
curve 285, 482, 30, .55, 4, _RGB(230, 80, 0), 270, 360
curve 285, 518, 30, .55, 4, _RGB(230, 80, 0), 0, 90
curve 285, 518, 30, .55, 4, _RGB(230, 80, 0), 270, 360
curve 375, 502, 90, 2.55, 4, _RGB(230, 80, 0), 170, 188
curve 368, 515, 18, 1, 4, _RGB(230, 80, 0), 0, 360
curve 365, 500, 20, 1.5, 4, _RGB(230, 80, 0), 90, 230
curve 445, 480, 40, .6, 4, _RGB(230, 80, 0), 150, 290
curve 535, 505, 90, 2.55, 4, _RGB(230, 80, 0), 170, 188


k = 0
Do
    col1& = _RGB(0, 0, 0)
    curve 200, 200, 60, 1, 10, col1&, k, k + 10
    If k <= 350 Then k = k + 10 Else k = k - 350
    col1& = _RGB(Rnd * 150 + 100, 0, 0)
    curve 200, 200, 60, 1, 10, col1&, k, k + 10

    _Delay .02

    i = Int(Rnd * 36) * 10
    col1& = _RGB(Rnd * 150 + 100, 0, 0)
    curve 200, 200, 30, 1, 15, col1&, i, i + 10
    col1& = _RGB(0, Rnd * 150 + 100, 0)
    curve 200, 200, 14, 1, 14, col1&, i, i + 10
    col1& = _RGB(0, 0, Rnd * 150 + 100)
    curve 200, 200, 1, 1, 14, col1&, i, i + 10

Loop Until InKey$ <> ""
'--------------------END OF EXAMPLES------------------

End

' cleft, ctop : center of the circle/arc
' cRa : Radius
' caspect! : aspect, normal = 1
' cthick : thickness
' ccolor& : color
' cstart, cend : start/end of the arc in degrees, (from 3 o'clock - anticlockwise)
' cstart must be less than cend (0-360 degrees)
Sub curve (cleft, ctop, cRa, caspect!, cthick, ccolor&, cstart, cend)
    i = 90
    stars = 360
    ss = 1 'step
    sx = i * (360 / stars) 'x pos
    sy = i * (360 / stars) 'y pos
    For sr2 = cRa To cRa + cthick
        i2 = -1
        For k2 = 1 To 360
            sx = sx + ss: If sx >= 360 Then sx = 360 - sx
            sy = sy + ss: If sy >= 360 Then sy = 360 - sy
            sxf = Sin(_Pi * sx / 180) * sr2
            syf = Cos(_Pi * sy / 180) * sr2 * caspect!
            i2 = i2 + 1: If i2 > 360 Then i2 = i2 - 360 'i2:degrees
            If i2 >= cstart And i2 <= cend Then Line (cleft + sxf, ctop + syf)-(cleft + sxf + 1, ctop + syf + 1), ccolor&, BF
        Next k2
    Next sr2
End Sub
Reply
#2
Curious how people keep choosing circle arcs to go anti-clockwise while the trig functions go clockwise.

And swapping the assoc of x from Cos to Sin just to force the fit???

Can't seem to handle the upside nature of the Y axis increasing going down screen that BASIC was built around, and instead insist on forcing BASIC to conform to how we learn it in math class. Understandable but not easy to be consistent with BASIC Cos and Sin functions.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#3
(11-01-2025, 08:01 PM)bplus Wrote: Curious how people keep choosing circle arcs to go anti-clockwise while the trig functions go clockwise.

And swapping the assoc of x from Cos to Sin just to force the fit???

Can't seem to handle the upside nature of the Y axis increasing going down screen that BASIC was built around, and instead insist on forcing BASIC to conform to how we learn it in math class. Understandable but not easy to be consistent with BASIC Cos and Sin functions.
The angle in the circle statement goes anti-clockwise
and that's how we learn it in school.
I changed the radians to degrees for convenience.
Now I think that curves would make a nice font ...
Reply
#4
Quote:Now I think that curves would make a nice font ...

Yeah I did that years ago with SmallBASIC (with which you could not load fonts). Fun project and then I had scalable text!

A screen shot from that adventure:
   
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#5
BTW here is my version of the perfected Arc and PieSlices to boot!
https://qb64phoenix.com/forum/showthread...3#pid29203

These do follow the Basic trig functions start due East at 0 degrees and go Clockwise heading South then West then North and finally returning to due East 360 degrees or 2*pi radians later.

Also you dont have to worry if your end angle is less than your start angle eg start at 161 degrees and end at 84 as the screen shot demonstrates.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#6
(11-01-2025, 09:56 PM)bplus Wrote:
Quote:Now I think that curves would make a nice font ...

Yeah I did that years ago with SmallBASIC (with which you could not load fonts). Fun project and then I had scalable text!

A screen shot from that adventure:
Purdy! Care to convert that to QB64PE just for giggles?
Reply
#7
Actually, the same can be accomplished with any Font saving the background with allot less converting SB to QB64.

Here I have it coded already!
https://qb64phoenix.com/forum/showthread...9#pid36959
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Bright Circle Colors SierraKen 4 611 08-23-2025, 03:33 PM
Last Post: DANILIN
  Playing with dragon curve fractal Dav 11 2,472 10-09-2023, 12:23 AM
Last Post: Dav
  Improved my small Gradient Ball drawing SUB Dav 22 5,246 07-13-2023, 05:23 PM
Last Post: Dav
  Draw that Circle James D Jarvis 17 3,270 08-28-2022, 06:29 AM
Last Post: justsomeguy
  Rotating Circle CharlieJV 0 515 08-06-2022, 02:56 AM
Last Post: CharlieJV

Forum Jump:


Users browsing this thread: