Recent Posts

Pages: 1 ... 7 8 [9] 10
81
General questions and discussions / Re: BBC BASIC for SDL 2.0
« Last post by B+ on July 15, 2019, 01:10:01 PM »
My memory of BBC Basic was that is was rather complex process to get Mouse X, Y but that was some time ago.

BBC for Windows was OK too.
82
General questions and discussions / BBC BASIC for SDL 2.0
« Last post by Ed Davis on July 15, 2019, 11:43:31 AM »
Just curious - why doesn't BBC BASIC for SDL 2.0 get much love/use from this group?
It is Open Source (distribution on Github), it seems to run virtually everywhere - Windows, Linux (x86 CPU only), Mac OS-X, Raspberry Pi (Raspbian), Android and iOS.

Does anyone have opinions on it, pro's vs. con's, etc?
Thanks!
83
Other Languages / Logo - Turtle Academy
« Last post by Richly on July 13, 2019, 08:58:45 PM »
Great learning environment for kids making use of the Logo programming language

https://www.turtleacademy.com/
 
Its great fun  ;D
84
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 13, 2019, 01:53:56 AM »
And a JB version:
Code: [Select]
'Knot #3.txt for JB v2 bplus 2019-07-12  try fancy sin /cos equation for x, y coordinates
' To demo Celtic Knot mastery, attempt another one, no straight lines and no circular curves!

global pi, XMAX, YMAX
pi = 3.14159265
XMAX = 720 'full screen width
YMAX = 720
nomainwin
UpperLeftX = 300
UpperLeftY = 10
WindowWidth = XMAX + 8   'adjust +10 for screen frame plus slight white frame
WindowHeight = YMAX + 32  'add +32 for screen frame plus slight white frame
open "Knot #3" for graphics_nsb_nf as #gr '_nf =no full screen, _nsb =no scroll bars
#gr "trapclose [quit]"
#gr "down"
r = 135 : p = 35 * pi * r : s = 2 * pi / p 'stepper in all for loops
pm2d3 = pi * 2 / 3 '  all crucial points are 1/3 circle symmetric
xc = XMAX/2 : yc = YMAX/2

'outline whole design
#gr "color red"
#gr "size 40"
FOR t = 0 TO 2 * pi STEP s
    x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
    y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
    #gr "set ";x;" ";y
NEXT

'fill in design, same as above only smaller circle fills
#gr "color blue"
#gr "size 26"
FOR t = 0 TO 2 * pi STEP s
    x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
    y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
    #gr "set ";x;" ";y
NEXT

'another surprise fill!
#gr "color green"
#gr "size 12"
FOR t = 0 TO 2 * pi STEP s
    x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
    y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
    #gr "set ";x;" ";y
NEXT

'over bridges  borders, locate over the top passes and draw circles over the over pass
#gr "color red"
#gr "size 40"
FOR t = 0 TO 2 * pi STEP s
    x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
    y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

    IF ABS(t - pi * 51 / 384) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 51 / 384 - pm2d3) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .11 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 111 / 384) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 111 / 384 - pm2d3) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .11 THEN #gr "set ";x;" ";y


    IF ABS(t - pi * 424 / 384) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 424 / 384 - pm2d3) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .11 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 680 / 384) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .11 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .11 THEN #gr "set ";x;" ";y
NEXT

'over bridges fills , now draw farther up and down the bridge work the fill color
#gr "color blue"
#gr "size 26"
FOR t = 0 TO 2 * pi STEP s
    x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
    y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

    IF ABS(t - pi * 51 / 384) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 51 / 384 - pm2d3) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .13 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 111 / 384) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 111 / 384 - pm2d3) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .13 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 424 / 384) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 424 / 384 - pm2d3) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .13 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 680 / 384) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .13 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .13 THEN #gr "set ";x;" ";y
NEXT

'continue surprise fill over bridges still further than blue
#gr "color green"
#gr "size 12"
FOR t = 0 TO 2 * pi STEP s
    x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
    y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

    IF ABS(t - pi * 51 / 384) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 51 / 384 - pm2d3) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .16 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 111 / 384) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 111 / 384 - pm2d3) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .16 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 424 / 384) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 424 / 384 - pm2d3) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .16 THEN #gr "set ";x;" ";y

    IF ABS(t - pi * 680 / 384) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .16 THEN #gr "set ";x;" ";y
    IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .16 THEN #gr "set ";x;" ";y
NEXT
#gr "flush"
wait

[quit]
timer 0
close #gr
end
85
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 13, 2019, 01:52:11 AM »
Here is SmallBASIC version of Knot #3, almost identical to QB64:
Code: [Select]
'"Celtic Knot 3" ' B+ 2019-07-12 from QB64
' To demo Celtic Knot mastery, attempt another one!

borderColor = RGB(255, 255, 0)
fillColor = RGB(0, 128, 0)
moreColor = RGB(160, 160, 255)
FOR rr = 30 TO 350 STEP 20
    CLS
    Knot3 xmax / 2, ymax / 2, rr, .12 * rr, borderColor, fillColor, moreColor
    CIRCLE xmax / 2, ymax / 2, rr, 1, rgb(128, 128, 128)
    INPUT "OK ..."; w$
NEXT

'KnotR tested OK from 30 to 350, thick 1 to 13% knotR, at thick = 1 and 2 just see fillC.
SUB Knot3 (xc, yc, knotR, thick, borderC, fillC, middleC)
    'DIM p, r, s, t, br, fr, x, y
    pm2d3 = pi * 2 / 3 '  all crucial points are 1/3 circle symmetric
    r = knotR / 2.6: p = 35 * pi * r: s = 2 * pi / p
    br = thick / 2 'border radius
    fr = br - 4
    mr = fr - 4

    'outline whole design
    FOR t = 0 TO 2 * PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
        'PSET (x, y)
        fcirc x, y, br, borderC
        'code to help me find where in the 0 to 2*PI points are
        'IF t = 0 THEN fcirc x, y, 3, &HFF0000FF
        'IF ABS(t - pi) < .0025 THEN fcirc x, y, 3, &HFF000066
    NEXT
    'fill in design, same as above only smaller circle fills
    FOR t = 0 TO 2 * PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
        'PSET (x, y)
        fcirc x, y, fr, fillC
    NEXT
    FOR t = 0 TO 2 * PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
        'PSET (x, y)
        fcirc x, y, mr, middleC
    NEXT
    'over bridges  borders, locate over the top passes and draw circles over the over pass
    FOR t = 0 TO 2 * PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

        IF ABS(t - pi * 51 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 51 / 384 - pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .11 THEN fcirc x, y, br, borderC

        IF ABS(t - pi * 111 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 111 / 384 - pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .11 THEN fcirc x, y, br, borderC


        IF ABS(t - pi * 424 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 424 / 384 - pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .11 THEN fcirc x, y, br, borderC

        IF ABS(t - pi * 680 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .11 THEN fcirc x, y, br, borderC
    NEXT
    'over bridges fills , now draw farther up and down the bidge work the fill color
    FOR t = 0 TO 2 * PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

        IF ABS(t - pi * 51 / 384) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 51 / 384 - pm2d3) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .13 THEN fcirc x, y, fr, fillC

        IF ABS(t - pi * 111 / 384) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 111 / 384 - pm2d3) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .13 THEN fcirc x, y, fr, fillC

        IF ABS(t - pi * 424 / 384) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 424 / 384 - pm2d3) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .13 THEN fcirc x, y, fr, fillC

        IF ABS(t - pi * 680 / 384) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .13 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .13 THEN fcirc x, y, fr, fillC
    NEXT
    FOR t = 0 TO 2 * PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

        IF ABS(t - pi * 51 / 384) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 51 / 384 - pm2d3) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .15 THEN fcirc x, y, mr, middleC

        IF ABS(t - pi * 111 / 384) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 111 / 384 - pm2d3) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .15 THEN fcirc x, y, mr, middleC
       
        IF ABS(t - pi * 424 / 384) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 424 / 384 - pm2d3) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .15 THEN fcirc x, y, mr, middleC

        IF ABS(t - pi * 680 / 384) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .15 THEN fcirc x, y, mr, middleC
        IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .15 THEN fcirc x, y, mr, middleC
    NEXT
END SUB

SUB fcirc (cX, cY, R, C)
  circle cx, cy, r, 1, C filled
END SUB
86
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 12, 2019, 11:59:50 PM »
Applied easier method to a fancy sin/cos function for x, y coordinates st no straight lines nor circular arcs to use. It still took less time to eyeball bridges for overpasses than to apply intersect formulas or find exact pixel the arc ends are on (if we had circular arcs).

Code: [Select]
OPTION _EXPLICIT
_TITLE "Celtic Knot 3" ' B+ 2019-07-12
' To demo Celtic Knot mastery, attempt another one!

CONST xmax = 720, ymax = 720, pi = 3.14159265
SCREEN _NEWIMAGE(xmax, ymax, 32)
_SCREENMOVE 100, 20

DIM rr, w$
FOR rr = 30 TO 350 STEP 20
    CLS
    Knot3 xmax / 2, ymax / 2, rr, .12 * rr, &HFFFFFFFF, &HFFFF000088
    CIRCLE (xmax / 2, ymax / 2), rr, &HFFFFFF00
    INPUT "OK ..."; w$
NEXT
SLEEP

'KnotR tested OK from 30 to 350, thick 1 to 13% knotR, at thick = 1 and 2 just see fillC.
SUB Knot3 (xc, yc, knotR, thick, borderC AS _UNSIGNED LONG, fillC AS _UNSIGNED LONG)
    DIM p, r, s, t, br, fr, x, y
    CONST pm2d3 = pi * 2 / 3 '  all crucial points are 1/3 circle symmetric
    r = knotR / 2.6: p = 35 * pi * r: s = 2 * pi / p
    br = thick / 2 'border radius
    fr = br - 2

    'outline whole design
    FOR t = 0 TO 2 * _PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
        'PSET (x, y)
        fcirc x, y, br, borderC
        'code to help me find where in the 0 to 2*PI points are
        'IF t = 0 THEN fcirc x, y, 3, &HFF0000FF
        'IF ABS(t - pi) < .0025 THEN fcirc x, y, 3, &HFF000066
    NEXT
    'fill in design, same as above only smaller circle fills
    FOR t = 0 TO 2 * _PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)
        'PSET (x, y)
        fcirc x, y, fr, fillC
    NEXT
    'over bridges  borders, locate over the top passes and draw circles over the over pass
    FOR t = 0 TO 2 * _PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

        IF ABS(t - pi * 51 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 51 / 384 - pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .11 THEN fcirc x, y, br, borderC

        IF ABS(t - pi * 111 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 111 / 384 - pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .11 THEN fcirc x, y, br, borderC


        IF ABS(t - pi * 424 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 424 / 384 - pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .11 THEN fcirc x, y, br, borderC

        IF ABS(t - pi * 680 / 384) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .11 THEN fcirc x, y, br, borderC
        IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .11 THEN fcirc x, y, br, borderC
    NEXT
    'over bridges fills , now draw farther up and down the bidge work the fill color
    FOR t = 0 TO 2 * _PI STEP s
        x = xc + r * (COS(t) + COS(4 * t) / .7 + SIN(2 * t) / 12)
        y = yc + r * (SIN(t) + SIN(4 * t) / .7 + COS(2 * t) / 12)

        IF ABS(t - pi * 51 / 384) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 51 / 384 - pm2d3) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 51 / 384 - 2 * pm2d3) < .14 THEN fcirc x, y, fr, fillC

        IF ABS(t - pi * 111 / 384) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 111 / 384 - pm2d3) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 111 / 384 - 2 * pm2d3) < .14 THEN fcirc x, y, fr, fillC

        IF ABS(t - pi * 424 / 384) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 424 / 384 - pm2d3) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 424 / 384 + 1 * pm2d3) < .14 THEN fcirc x, y, fr, fillC

        IF ABS(t - pi * 680 / 384) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 680 / 384 + 2 * pm2d3) < .14 THEN fcirc x, y, fr, fillC
        IF ABS(t - pi * 680 / 384 + 1 * pm2d3) < .14 THEN fcirc x, y, fr, fillC
    NEXT
END SUB

SUB fcirc (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
87
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 12, 2019, 01:27:04 PM »
A much easier approach, you don't have to eye ball to the pixel the start and end of arcs nor the heavy math to get 2 circle intersect points. This approach lays out the design shape and then draws "bridges" where the under/over passes are. Probably closer to how a human artist might do a Celtic Knot. Also don't worry about the inner and outer circle radii, just one radius for center of rings.

Code: [Select]
OPTION _EXPLICIT
_TITLE "Celtic Knot 2" ' B+ developed in JB, translated to QB64 2019-07-11
' Instead of worrying about 2 circles (or arcs of them) for one ring, draw one circle with really wide pen!
' Draw shape twice with Outline color then Fill color (smaller width) then lay "Bridges"
' over sections for underpass/overpass. Thanks to tsh73 for demo of this method with another Celtic Knot.

CONST xmax = 720, ymax = 720, pi = 3.14159265, xc = xmax / 2, yc = ymax / 2
SCREEN _NEWIMAGE(xmax, ymax, 32)
_SCREENMOVE 100, 20
COLOR , &HFF888888: CLS
DIM r
r = 350
knot2 xc, yc, r, 30, &HFFFFFF00, &HFF008800
CIRCLE (xc, yc), r
SLEEP

'for best results: 50+ (pixels) and up for knotR to see details
'max thickness for knotR (impreceise overall radius) is about 10%
SUB knot2 (x, y, knotR, thick, outlineC AS _UNSIGNED LONG, fillC AS _UNSIGNED LONG)
    DIM hCenterX(6), hCenterY(6), hCX(6), hCY(6)
    DIM w, hexAngle, h, hexD2, PD96, tD2
    hexAngle = pi / 3: hexD2 = hexAngle / 2: PD96 = pi / 96 '<<<< all angles are refined to 96 parts of semicircle
    w = knotR / 15: tD2 = thick / 2
    FOR h = 1 TO 6
        hCenterX(h) = x + 8 * w * COS(h * hexAngle + pi / 6)
        hCenterY(h) = y + 8 * w * SIN(h * hexAngle + pi / 6)
        hCX(h) = x + 14 * w * COS(h * hexAngle)
        hCY(h) = y + 14 * w * SIN(h * hexAngle)
    NEXT
    FOR h = 1 TO 6
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + pi / 6 + PD96 * 7, h * hexAngle + pi / 6 + PD96 * 185, tD2, outlineC
        penArc hCX(h), hCY(h), 6 * w, h * hexAngle + PD96 * 55, h * hexAngle + PD96 * 137, tD2, outlineC
    NEXT
    FOR h = 1 TO 6
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + pi / 6 + PD96 * 7, h * hexAngle + pi / 6 + PD96 * 185, tD2 - 1, fillC
        penArc hCX(h), hCY(h), 6 * w, h * hexAngle + PD96 * 55, h * hexAngle + PD96 * 137, tD2 - 1, fillC
    NEXT
    'bridges
    FOR h = 1 TO 6
        'boarder color arc 7
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + PD96 * 51, h * hexAngle + PD96 * 58, tD2, outlineC
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + PD96 * 102, h * hexAngle + PD96 * 109, tD2, outlineC
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + PD96 * 148, h * hexAngle + PD96 * 155, tD2, outlineC
        penArc hCX(h), hCY(h), 6 * w, h * hexAngle + PD96 * 83, h * hexAngle + PD96 * 90, tD2, outlineC

        'fill color arc 2 before 3 after
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + PD96 * 49, h * hexAngle + PD96 * 61, tD2 - 1, fillC
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + PD96 * 99, h * hexAngle + PD96 * 111, tD2 - 1, fillC
        penArc hCenterX(h), hCenterY(h), 6 * w, h * hexAngle + PD96 * 145, h * hexAngle + PD96 * 158, tD2 - 1, fillC
        penArc hCX(h), hCY(h), 6 * w, h * hexAngle + PD96 * 80, h * hexAngle + PD96 * 92, tD2 - 1, fillC
    NEXT
END SUB

SUB penArc (x, y, r, raStart, raStop, penWidth, c AS _UNSIGNED LONG)
    'x, y origin, r = radius, c = color
    'raStart is first angle clockwise from due East = 0 degrees
    ' arc will start drawing there and clockwise until raStop angle reached
    DIM aStep, a
    IF raStop < raStart THEN
        penArc x, y, r, raStart, pi * 2, penWidth, c
        penArc x, y, r, 0, raStop, penWidth, c
    ELSE
        aStep = 1 / (pi * r * 2)
        FOR a = raStart TO raStop STEP aStep
            fcirc x + r * COS(a), y + r * SIN(a), penWidth, c
        NEXT
    END IF
END SUB

'no built in circle fill sub with QB64 but this one is good!
SUB fcirc (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


The corners are nice and round, more natural:
88
General questions and discussions / Re: Dir Walk Challenge
« Last post by jj2007 on July 11, 2019, 10:38:52 PM »
Wow! took awhile to give birth to an answer. ;-))

Apologies - I found your post by accident. I confess that I visit this forum only occasionally...
89
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 11, 2019, 08:20:00 PM »
OK here is code to screen shot at start of this thread:
Code: [Select]
OPTION _EXPLICIT
_TITLE "Vince Celtic Challenge Skeleton"
CONST xmax = 1200, ymax = 700, pi = 3.14159265
CONST xc = xmax / 2, yc = ymax / 2
SCREEN _NEWIMAGE(xmax, ymax, 32)
_SCREENMOVE 100, 20

celticKnot xc, yc, 30
SLEEP

SUB celticKnot (xc, yc, thick)
    DIM distr, r, r1, hex, hd2, nHex, x0, y0, c AS _UNSIGNED LONG

    distr = 5 * thick
    r = 4 * thick
    r1 = 3 * thick
    hex = pi * 2 / 6
    hd2 = hex / 2

    FOR nHex = 1 TO 6
        IF nHex <= 2 THEN c = &HFFFFFFFF ELSE c = &HFF444444
        'circles with origins in main circle
        x0 = xc + distr * COS(nHex * hex - hd2)
        y0 = yc + distr * SIN(nHex * hex - hd2)

        'outer radius
        CIRCLE (x0, y0), r, c
        'inner radius
        CIRCLE (x0, y0), r1, c


        ' circles with outside origins
        x0 = xc + (2 * distr - 1.5 * thick) * COS(nHex * hex)
        y0 = yc + (2 * distr - 1.5 * thick) * SIN(nHex * hex)
        IF nHex = 1 THEN c = &HFF0000FF ELSE c = &HFF444444
        'outer radius
        CIRCLE (x0, y0), r, c
        'inner radius
        CIRCLE (x0, y0), r1, c

    NEXT
END SUB

90
Pulsar2D / Re: Few quick questions
« Last post by Cybermonkey on July 08, 2019, 03:07:36 PM »
1. Pulsar2D is still being developed. The next release is PulsarBASIC.
2. Unfortunately, nope.
3. There are none at the moment. There will be a documentation for PulsarBASIC including tutorials.
Pages: 1 ... 7 8 [9] 10