_TITLE "Rose Patterns with Coloring 3" 'started 2019-04-20 ' coding Challenge #55
' [youtube]https://www.youtube.com/watch?v=f5QBExMNB1I&list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH[/youtube]&index=72
' OK now try this without showing a k value twice, eg 1/2 = 2/4 = 3/6 = 4/8... just show .5 once!
'2019-04-20 with Coloring, by thic lines, well yuck so far trying to taper line back to xc,yc yuck 2
' try expanding / contracting multiplier, hell no!
'2019-04-20 with Coloring 2, OK alpha coloring is working well.
'2019-04-20 with Coloring 3, how about some yellow in center?
' don't show k values already shown, store k values shown in shownK() with nextKI for new K value
nextKI = 1
'review of equations
n = 1
d = 2
k = n / d
xc = xmax / 2
yc = ymax / 2
multiplier = 200
k = n / d
shownK(nextKI) = k
QSort 1, nextKI
nextKI = nextKI + 1
cnt = 0: dir = 1
'main equations, r, x, y updated with every new theta
cnt = cnt + dir
IF cnt
> 255 THEN cnt
= 254: dir
= -1 IF cnt
< 0 THEN cnt
= 1: dir
= 1 x
= xc
+ multiplier
* r
* COS(theta
) y
= yc
+ multiplier
* r
* SIN(theta
) thic2 xc
, yc
, x
, y
, 2, _RGBA32(185, 0, 50, 80) PRINT "n ="; n;
" d ="; d;
" n/d = K ="; k
n = n + 1
n = 1
d = d + 1
'check the values being stored, OK looks good!
'IF d = 9 THEN 'dump shownK to check all unique numbers
' CLS
' FOR i = 1 TO nextKI - 1
' PRINT i, shownK(i)
' IF i MOD 30 = 0 THEN
' INPUT "Peeking at shownK array, press enter to cont...", wate$
' CLS
' END IF
' NEXT
' INPUT "OK finished peek of shownK array, press enter to cont...", wate$
' CLS
'END IF
SUB QSort
(Start
, Finish
) 'shownK needs to be shared array i = Start
j = Finish
m
= shownK
(INT((i
+ j
) / 2)) i = i + 1
j = j - 1
l = shownK(i)
shownK(i) = shownK(j)
shownK(j) = l
i = i + 1
j = j - 1
IF j
> Start
THEN QSort Start
, j
IF i
< Finish
THEN QSort i
, Finish
low = 1: hi = nextKI - 1
test = (low + hi) \ 2
IF shownK
(test
) < x
THEN low
= test
+ 1 ELSE hi
= test
- 1
'x1, y1 is one endpoint of line
'x2, y2 is the other endpoint of the line
'rThick is the radius of the tiny circles that will be drawn
' from one end point to the other to create the thick line
'Yes, the line will then extend beyond the endpoints with circular ends.
rThick
= INT(rThick
/ 2): stepx
= x2
- x1: stepy
= y2
- y1
length
= INT((stepx
^ 2 + stepy
^ 2) ^ .5) dx = stepx / length: dy = stepy / length
fcirc x1 + dx * i, y1 + dy * i, 2, K
fcirc x1
+ dx
* i
, y1
+ dy
* i
, rThick
, _RGBA32(255, 255, 0, 3) fcirc x1
+ dx
* i
, y1
+ dy
* i
, rThick
, _RGBA32(235, 0, 110, 18) fcirc x1, y1, rThick, K
RadiusError = -Radius
X = Radius
Y = 0
' Draw the middle span here so we don't draw it twice in the main loop,
' which would be a problem with blending turned on.
LINE (CX
- X
, CY
)-(CX
+ X
, CY
), C
, BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), C
, BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), C
, BF
X = X - 1
RadiusError = RadiusError - X * 2
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