03-01-2018, 03:41 PM

Hey Pete, take a break from ball play, here is some recticularity.

Code:

`_TITLE " *** Screen Saver #3 - Mystic Rectangles *** by bplus 2018-03-01"`

' translated from

' Screen Saver #3 Mystic Rectangles.bas SmallBASIC 0.12.11 (B+=MGA) 2018-02-28

' instead of wire frame triangles try solid color rectangles

' arrays? we don't need no dang arrays!

' oh to share everything use GOSUBs instead of SUBs

RANDOMIZE TIMER

CONST xmax = 1200

CONST ymax = 700

SCREEN _NEWIMAGE(xmax, ymax, 32)

_SCREENMOVE 100, 20

nT = 150 'number of Things per screen

GOSUB newRect

savex1 = x1: savey1 = y1: savedx1 = dx1: savedy1 = dy1

savex2 = x2: savey2 = y2: savedx2 = dx2: savedy2 = dy2

cN = nT

GOSUB resetPlasma

WHILE 1

CLS

'reset color Number back to beginning + 1

cN = cN - nT + 1

'reset rect back to beginning and then update it once and save this for next round

x1 = savex1: y1 = savey1: dx1 = savedx1: dy1 = savedy1

x2 = savex2: y2 = savey2: dx2 = savedx2: dy2 = savedy2

GOSUB updateRect

savex1 = x1: savey1 = y1: savedx1 = dx1: savedy1 = dy1

savex2 = x2: savey2 = y2: savedx2 = dx2: savedy2 = dy2

FOR j = 1 TO nT

GOSUB updateRect

GOSUB changePlasma

LINE (x1 - 12, y1 - 7)-(x2, y2), , BF

'inverse image and color

xx1 = xmax - x1: yy1 = ymax - y1

xx2 = xmax - x2: yy2 = ymax - y2

IF xx1 > xx2 THEN SWAP xx1, xx2

IF yy1 > yy2 THEN SWAP yy1, yy2

LINE (xx1 - 12, yy1 - 7)-(xx2, yy2), invColor&&, BF

NEXT

_DISPLAY

_LIMIT 10

k$ = INKEY$

IF k$ = " " THEN GOSUB resetPlasma

WEND

newRect:

x1 = RND * xmax

y1 = RND * ymax

dx1 = (RND * 9 + 3) * rdir

dy1 = (RND * 5 + 2) * rdir

x2 = RND * xmax

y2 = RND * ymax

dx2 = (RND * 9 + 3) * rdir

dy2 = (RND * 5 + 2) * rdir

'keep x1, y1 the lesser corner and x2, y2 the greater

IF x1 > x2 THEN SWAP x1, x2: SWAP dx1, dx2

IF y1 > y2 THEN SWAP y1, y2: SWAP dy1, dy2

RETURN

updateRect:

IF x1 + dx1 < 0 THEN dx1 = -dx1

IF x1 + dx1 > xmax THEN dx1 = -dx1

x1 = x1 + dx1

IF y1 + dy1 < 0 THEN dy1 = -dy1

IF y1 + dy1 > ymax THEN dy1 = -dy1

y1 = y1 + dy1

IF x2 + dx2 < 0 THEN dx2 = -dx2

IF x2 + dx2 > xmax THEN dx2 = -dx2

x2 = x2 + dx2

IF y2 + dy2 < 0 THEN dy2 = -dy2

IF y2 + dy2 > ymax THEN dy2 = -dy2

y2 = y2 + dy2

'keep x1, y1 the lesser corner and x2, y2 the greater

IF x1 > x2 THEN SWAP x1, x2: SWAP dx1, dx2

IF y1 > y2 THEN SWAP y1, y2: SWAP dy1, dy2

RETURN

changePlasma:

cN = cN + 1

COLOR _RGB32(127 + 127 * SIN(pR * .2 * cN), 127 + 127 * SIN(pG * .2 * cN), 127 + 127 * SIN(pB * .2 * cN))

invColor&& = _RGB32(255 - (127 + 127 * SIN(pR * .2 * cN)), 255 - (127 + 127 * SIN(pG * .2 * cN)), 255 - (127 + 17 * SIN(pB * .2 * cN)))

RETURN

resetPlasma:

pR = RND ^ 2: pG = RND ^ 2: pB = RND ^ 2

RETURN

FUNCTION rdir ()

IF RND < .5 THEN rdir = -1 ELSE rdir = 1

END FUNCTION

B += x