' Wavy Persian Carpets.bas SmallBASIC 0.12.9 (B+=MGA) 2017-09-27
' originally based on Anne M Burns Persian Carpet
_TITLE "Wavy Persian Carpets by bplus, press spacebar to wave another" xo = (xmax - W) / 2: yo = (ymax - H) / 2
lft = xo: rght = W + xo: top = yo: bot = H + yo
LINE (lft
, top
)-(rght
, top
), r&
LINE (lft
, bot
)-(rght
, bot
), r&
LINE (lft
, top
)-(lft
, bot
), r&
LINE (rght
, top
)-(rght
, bot
), r&
DetermineColor lft, rght, top, bot
carpet&
(x
, y
) = POINT(xo
+ x
, yo
+ y
) 'check point worked
PRINT "Check graphic, press any (except spacebar) to continue..." PSET (x
+ 100, y
+ 100), carpet&
(x
, y
)
da#
= _PI(2) / 30: aInc#
= _PI(2) / 50: a#
= 0 bOrbit! = .1: br! = 4: spacer = 5: walk! = 0: dir = 1
a# = a# + aInc#
bOrbit! = bOrbit! + .1 * dir
IF bOrbit!
>= 15.1 THEN bOrbit!
= 15.0: dir
= dir
* -1 IF bOrbit!
<= 0 THEN bOrbit!
= .1: dir
= dir
* -1 bAngle# = (x + y) * da# + a#
xBall
= (2 * SIN(bAngle#
) + COS(bAngle#
)) / 2 * bOrbit!
+ x
* spacer
yBall
= (COS(bAngle#
) + SIN(bAngle#
)) / 2 * bOrbit!
+ y
* spacer
fcirc
(xBall
+ 10 + walk!
) MOD (xmax
+ 640), (yBall
+ 10 + .12 * walk!
) MOD (ymax
+ 640), br!
walk! = walk! + .1 * bOrbit!
SUB DetermineColor
(lft
, rght
, top
, bot
) middlecol
= INT((lft
+ rght
) / 2) middlerow
= INT((top
+ bot
) / 2) c& = f&(lft, rght, top, bot)
LINE (lft
+ 1, middlerow
)-(rght
- 1, middlerow
), c&
LINE (middlecol
, top
+ 1)-(middlecol
, bot
- 1), c&
DetermineColor lft, middlecol, top, middlerow
DetermineColor middlecol, rght, top, middlerow
DetermineColor lft, middlecol, middlerow, bot
DetermineColor middlecol, rght, middlerow, bot
'create 4x4x4 very bright contrasting colors
r% = 0
r% = 128
r% = 192
r% = 255
g% = 0
g% = 128
g% = 192
g% = 255
b% = 0
b% = 128
b% = 192
b% = 255
'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
), , 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