'Pentacle Flux Capacitor 2.bas for QB64 fork 2017-08-23
'translated from: Pentacle Flux Capacitor 2.txt for JB (B+=MGA) 2017-08-23
' updated 2019-09-05 with cleaner more random blackouts, er..., ah, drama!
_TITLE "Pentacle Flux Capacitor #2: Dancing Man"
xc = xmax / 2
yc = ymax / 2 + 20
LINE (0, 0)-(xmax
, ymax
), &H99000000, BF
drawPFC
Lightning xc, yc - 90, xc, yc + 10, 135
xe = tp2(i, 0)
ye = tp2(i, 1)
d = rand(.1 * dist, .7 * dist)
Lightning xc, yc - 90, xe, ye, d
Lightning xc, yc - 90, xe, ye, d
Lightning xc, yc - 70, xe, ye, d
Lightning xc, yc + 10, xe, ye, d
'3 main points for array tp()
pRadius = 40: cRadius = 1.5 * pRadius
a3
= _PI(2 / 5): r
= ymax
/ 2 - cRadius
midInk 255, 255, 255, 0, 0, 128, rr / r
CircleFill xc, yc, rr
tp
(i
, 0) = xc
+ r
* COS(a
) tp
(i
, 1) = yc
+ r
* SIN(a
) COLOR _RGB((rr
- pRadius
) / (cRadius
- pRadius
) * 255 * (cRadius
- rr
+ pRadius
) / cRadius
, 0, 0) xx = tp(i, 0): yy = tp(i, 1)
CircleFill xx, yy, rr
a = a + a3
xx = tp(0, 0): yy = tp(0, 1)
dist = distance##(xx, yy, xc, yc)
dGray = 255 * dis / dist
xx = tp(pnt, 0): yy = tp(pnt, 1)
midpoint xx, yy, xc, yc, dis / dist, midx, midy
FOR r
= pRadius
* (dist
- dis
) / dist
TO 0 STEP -1 midInk dGray, dGray, dGray, 255, 255, 255, (pRadius - r) / pRadius
CircleFill midx, midy, r
tp2(pnt, 0) = midx
tp2(pnt, 1) = midy
SUB Lightning
(x1
, y1
, x2
, y2
, d
) mx = (x2 + x1) / 2
my = (y2 + y1) / 2
mx
= mx
+ -.5 * RND * d
* .4 * rand&&
(-2, 2) my
= my
+ -.5 * RND * d
* .4 * rand&&
(-2, 2) Lightning x1, y1, mx, my, d / 2
Lightning x2, y2, mx, my, d / 2
'Steve McNeil's
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
), , BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), , BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), , BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
LINE (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), , BF
LINE (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), , BF
SUB midpoint
(x1
, y1
, x2
, y2
, fraction
, midx
, midy
) midx = (x2 - x1) * fraction + x1
midy = (y2 - y1) * fraction + y1
SUB midInk
(r1
, g1
, b1
, r2
, g2
, b2
, fr
) COLOR _RGB(r1
+ (r2
- r1
) * fr
, g1
+ (g2
- g1
) * fr
, b1
+ (b2
- b1
) * fr
)
FUNCTION distance##
(x1##
, y1##
, x2##
, y2##
) distance## = ((x1## - x2##) ^ 2 + (y1## - y2##) ^ 2) ^ .5
rand&&
= INT(RND * (hi&&
- lo&&
+ 1)) + lo&&