_TITLE "Plasmatic 5.1 Speed Tests" ' b+ 2020-01-26 ' Try no SQR for distance
CONST xxmax
= 700, yymax
= 500, xmax
= 900, ymax
= 740, xoff
= (xmax
- xxmax
) \
2, yoff
= (ymax
- yymax
) \
2 DIM i
AS INTEGER, m
AS INTEGER, n
AS INTEGER, mode
AS INTEGER, cnt
AS INTEGER, k$
, t
, x
, y
, d
, dx
, dy
, dist
, s
, stepper
, tot
restart: 'select rgb1 and rgb2 based on mode of color mixing
IF mode
= 0 THEN 'new plasma option ANY color for border and ANY color for middle r1
= RND * 255: g1
= RND * 255: b1
= RND * 255: r2
= RND * 255: g2
= RND * 255: b2
= RND * 255ELSE ' traditional high contrast plasma black borders, white centers r1 = 0: g1 = 0: b1 = 0: r2 = 255: g2 = 255: b2 = 255 'regular Plasma
' create 6 x 60 bands of color palette based on coloring mode (rgb1 set and rgb2 set)
s = 1 - ((30 - m + .5) / 30) ^ 2
CASE IS < 15: c
(i
) = midInk
(s
* r1
, s
* g1
, s
* b1
, s
* r
, s
* g
, s
* b
, m
/ 15) ' 1st stage increase rgb1 towards rgb color in 15 steps CASE IS < 30: c
(i
) = midInk
(s
* r
, s
* g
, s
* b
, s
* r2
, s
* g2
, s
* b2
, (m
- 15) / 15) ' 2nd stage increase rgb color towards rgb2 set in 15 steps CASE IS < 45: c
(i
) = midInk
(s
* r2
, s
* g2
, s
* b2
, s
* r
, s
* g
, s
* b
, (m
- 30) / 15) ' 3rd stage decrease rgb2 color back to rgb color in 15 steps CASE IS < 60: c
(i
) = midInk
(s
* r
, s
* g
, s
* b
, s
* r1
, s
* g1
, s
* b1
, (m
- 45) / 15) ' 4th and finally decrease rgb back to starting rgb1 set in 15 steps
' behind the scenes variables for motion, weighting and shaping color mixing
p
(n
).x
= RND * xmax: p
(n
).y
= RND * yymax: p
(n
).dx
= RND * 2 - 1: p
(n
).dy
= RND * 2 - 1
'screen labeling 3 lines for title above, 1 line instructions below
yCP yoff - 60, "New Color Options for Plasma:"
yCP yoff - 60, "Traditional High Contrast Plasma: Black Borders and White Centers"
yCP yoff - 40, "Shaded Borders: RGB(" + TS$(r1 \ 1) + ", " + TS$(g1 \ 1) + ", " + TS$(b1 \ 1) + ")"
yCP yoff - 20, "Centers: RGB(" + TS$(r2 \ 1) + ", " + TS$(g2 \ 1) + ", " + TS$(b2 \ 1) + ")"
yCP yoff + yymax + 10, "Press t to toggle between Traditional and New Color Options Plasma"
yCP yoff + yymax + 30, "Press spacebar to get a new color set."
p(i).x = p(i).x + p(i).dx
IF p
(i
).x
> 2 * xxmax
THEN p
(i
).dx
= -p
(i
).dx: p
(i
).x
= 2 * xxmax
IF p
(i
).x
< -xxmax
THEN p
(i
).dx
= -p
(i
).dx: p
(i
).x
= -xxmax
p(i).y = p(i).y + p(i).dy
IF p
(i
).y
> 2 * yymax
THEN p
(i
).dy
= -p
(i
).dy: p
(i
).y
= 2 * yymax
IF p
(i
).y
< -yymax
THEN p
(i
).dy
= -p
(i
).dy: p
(i
).y
= -yymax
stepper = 3
d = 0
dx = x - p(n).x: dy = y - p(n).y
dist = .0005 * (dx * dx + dy * dy)
'dist = SQR(dx * dx + dy * dy)
'dist = _HYPOT(dx, dy) 'this may work faster on another system
d
= d
+ (SIN(dist
* f
(n
)) + 1) / 2 LINE (x
+ xoff
, y
+ yoff
)-STEP(stepper
, stepper
), c
(d
), BF
cnt = cnt + 1
tot
= tot
+ TIMER(.001) - t
yCP yoff
+ yymax
+ 50, SPACE$(50) yCP yoff
+ yymax
+ 50, RIGHT$(" " + TS$
(INT(1000 * tot
/ 100)), 4) + " ms per frame" cnt = 0: tot = 0
FUNCTION midInk~&
(r1%
, g1%
, b1%
, r2%
, g2%
, b2%
, fr##
) midInk~&
= _RGBA32(r1%
+ (r2%
- r1%
) * fr##
, g1%
+ (g2%
- g1%
) * fr##
, b1%
+ (b2%
- b1%
) * fr##
, 255)
SUB yCP
(y
, s$
) 'for xmax pixel wide graphics screen Center Print at pixel y row