CONST xmax
= 1200, ymax
= 700, xc
= 600, yc
= 350, nP
= 20
_TITLE "WuLine Circles on Left, Normal circles on right, hmm.... not bad" 'B+ 2020-03-08 _DELAY .25 '< after load before move .1 not always working
x(i) = .5 * xc: y(i) = yc: r(i) = i * 300 / nP - 1
c
(i
) = _RGBA32(255 * RND, 255 * RND, 255 * RND, 255) ' << opaque OK but transparent NOT
fcirc x(i) + xc, y(i), r(i), c(i)
'FOR a = 0 TO _PI(2.0) STEP .5 / r(i)
' 'draw circles with wulines
' x1 = x(i) + r(i) * COS(a)
' y1 = y(i) + r(i) * SIN(a)
' IF a > 0 THEN
' WuLine xlast, ylast, x1, y1, c(i)
' END IF
' xlast = x1: ylast = y1
'NEXT
fcircSmooth x(i), y(i), r(i), c(i) 'fill on to of wuLine
SUB plot
(x
, y
, c
AS _UNSIGNED LONG, opaque
) 'c is RGB color a level is opaqueness 0 to 1 transparent to solid
'// integer part of x
round = ipart(x + 0.5)
'// fractional part of x
rfpart = 1 - fpart(x)
'make copies since swapping values
x0 = xx0: y0 = yy0: x1 = xx1: y1 = yy1
steep
= ABS(y1
- y0
) > ABS(x1
- x0
)
dx = x1 - x0
dy = y1 - y0
gradient = 1.0
gradient = dy / dx
'// handle first endpoint
xend = round(x0)
yend = y0 + gradient * (xend - x0)
xgap = rfpart(x0 + 0.5)
xpxl1 = xend '// this will be used in the main loop
ypxl1 = ipart(yend)
plot ypxl1, xpxl1, c, rfpart(yend) * xgap
plot ypxl1 + 1, xpxl1, c, fpart(yend) * xgap
plot xpxl1, ypxl1, c, rfpart(yend) * xgap
plot xpxl1, ypxl1 + 1, c, fpart(yend) * xgap
intery = yend + gradient '// first y-intersection for the main loop
'// handle second endpoint
xend = round(x1)
yend = y1 + gradient * (xend - x1)
xgap = fpart(x1 + 0.5)
xpxl2 = xend '//this will be used in the main loop
ypxl2 = ipart(yend)
plot ypxl2, xpxl2, c, rfpart(yend) * xgap
plot ypxl2 + 1, xpxl2, c, fpart(yend) * xgap
plot xpxl2, ypxl2, c, rfpart(yend) * xgap
plot xpxl2, ypxl2 + 1, c, fpart(yend) * xgap
'// main loop
FOR x
= xpxl1
+ 1 TO xpxl2
- 1 plot ipart(intery), x, c, rfpart(intery)
plot ipart(intery) + 1, x, c, fpart(intery)
intery = intery + gradient
FOR x
= xpxl1
+ 1 TO xpxl2
- 1 plot x, ipart(intery), c, rfpart(intery)
plot x, ipart(intery) + 1, c, fpart(intery)
intery = intery + gradient
'draw circles with wulines
WuLine xlast, ylast, X, Y, C
xlast = X: ylast = Y
Radius
= ABS(R
): RadiusError
= -Radius: X
= Radius: Y
= 0 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
'from Steve Gold standard
Radius
= ABS(R
): RadiusError
= -Radius: X
= Radius: Y
= 0 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