_TITLE "Morph Curve Colorized and Balled" 'for QB64 B+ 2019-01-29 ' Morph Curve.bas SmallBASIC 0.12.8 [B+=MGA] 2017-04-11
'from SpecBAS version Paul Dunn Dec 2, 2015
'[youtube]https://www.youtube.com/watch?v=j2rmBRLEVms[/youtube]
'2019-01-29 add magic red meat balls to the plate
'prep
DIM SHARED plasmaN
, plasmaR
, plasmaG
, plasmaB
pts = 12000: interps = 20
REDIM p
(pts
+ 1, 1), q
(pts
+ 1, 1), s
(pts
+ 1, 1), i
(interps
) l
= 0: cx
= xmax
/ 2: cy
= ymax
/ 2: sc
= cy
* .5: st
= 2 * _PI / pts
i
(n
) = SIN(n
/ interps
* (_PI / 2))
'main
n = 0: m = 0: rmode = 0
resetPlasma
c = 0
n = n + 1
IF n
> 12 THEN n
= 0: m
= m
+ 1 IF rmode
THEN n
= rand
(1, 75): m
= rand
(-250, 250) q
(c
, 0) = cx
+ sc
* (COS(t
) + COS(n
* t
) / 2 + SIN(m
* t
) / 3) q
(c
, 1) = cy
+ sc
* (SIN(t
) + SIN(n
* t
) / 2 + COS(m
* t
) / 3) c = c + 1
q(c, 0) = q(0, 0): q(c, 1) = q(0, 1)
magicRedBalls
_TITLE "Morph Curve: m =" + STR$(m
) + ", n =" + STR$(n
) + ", spacebar skips to random mode." drawpoly q()
l = l + 1
magicRedBalls
s(nn, 0) = q(nn, 0) * i(t) + p(nn, 0) * (1 - i(t))
s(nn, 1) = q(nn, 1) * i(t) + p(nn, 1) * (1 - i(t))
s(nn, 0) = s(0, 0)
s(nn, 1) = s(0, 1)
drawpoly s()
'p() = q()
p(i, 0) = q(i, 0): p(i, 1) = q(i, 1)
rand
= (RND * (hi
- lo
+ 1)) \
1 + lo
kl~& = setPlasma~&
thic a(i, 0), a(i, 1), a(i + 1, 0), a(i + 1, 1), 4, kl~&
kl~& = setPlasma~&
'add filled circles at each end
t2 = thick / 2
fcirc x1, y1, t2, K
fcirc x2, y2, t2, K
x3
= x1
+ t2
* COS(a
+ _PI(.5)) y3
= y1
+ t2
* SIN(a
+ _PI(.5)) x4
= x1
+ t2
* COS(a
- _PI(.5)) y4
= y1
+ t2
* SIN(a
- _PI(.5)) x5
= x2
+ t2
* COS(a
+ _PI(.5)) y5
= y2
+ t2
* SIN(a
+ _PI(.5)) x6
= x2
+ t2
* COS(a
- _PI(.5)) y6
= y2
+ t2
* SIN(a
- _PI(.5)) filltri x6, y6, x4, y4, x3, y3, K
filltri x3, y3, x5, y5, x6, y6, K
' found at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]: http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
SUB resetPlasma
() 'all globals plasmaR
= RND ^ 2: plasmaG
= RND ^ 2: plasmaB
= RND ^ 2: plasmaN
= 0
plasmaN = plasmaN + .01
setPlasma~&
= _RGB32(120 + 84 * SIN(plasmaR
* plasmaN
), 120 + 84 * SIN(plasmaG
* plasmaN
), 120 + 84 * SIN(plasmaB
* plasmaN
))
'Steve McNeil's copied from his forum note: Radius is too common a name
RadiusError = -subRadius
X = subRadius
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
), K
, BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), K
, BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), K
, BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
LINE (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), K
, BF
LINE (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), K
, BF
LINE (i
, 0)-(i
+ 10, ymax
), , BF
LINE (0, i
)-(xmax
, i
+ 10), , BF
fcirc x
, y
, 10, _RGB32(128, 128, 128) CIRCLE (xmax
/ 2, ymax
/ 2), 330 + r
, _RGB32(100 + 5 * r
, 100 + 5 * r
, 100 + 5 * r
)