85
« Last post by B+ on July 13, 2019, 01:52:11 AM »
Here is SmallBASIC version of Knot #3, almost identical to QB64:
'"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