_TITLE "Fall Foliage 2017-10-21 by bplus" 'fall foliage.bas SmallBASIC 0.12.9 (B+=MGA) 2017-10-21
'test landscape and portrait views for Android
'xmx = min(xmax, 400) : ymx = min(700, ymax) 'portrait
'OK it's just plain better in landscape view
'now for full viewing enjoyment
'xmx = xmax : ymx = ymax
_SCREENMOVE 100, 20 'adjust as needed _MIDDLE needs a delay .5 or more for me
n = 3
horizon = rand%(.8 * ymx, .9 * ymx)
midInk 0, 0, 128, 10, 120, 128, i / horizon
lien 0, i, xmx, i
midInk 70, 108, 30, 60, 10, 5, (i - horizon) / (ymx - horizon)
lien 0, i, xmx, i
FOR i
= 1 TO xmx
* ymx
* .00018 leaf rand%(0, xmx), rand%(horizon * 1.002, ymx)
IF n
< .01 * xmx
THEN trees
= n
ELSE trees
= rand%
(.002 * xmx
, .03 * xmx
) y = horizon + .04 * ymx + i / trees * (ymx - horizon - .1 * ymx)
r = .01 * y: h = rand%(y * .15, y * .18)
branch rand%(10, xmx - 10), y, r, 90, h, 0
fRect xmx, 0, xmax, ymax, 0
fRect 0, ymx, xmx, ymax, 0
SUB branch
(xx
, yy
, startrr
, angDD
, lengthh
, levv
) x = xx: y = yy
lev = levv
length = lengthh
angD = angDD
startr = startrr
x2
= x
+ COS(rad
* (angD
)) * length
y2
= y
- SIN(rad
* (angD
)) * length
dx = (x2 - x) / length
dy = (y2 - y) / length
bc&
= _RGB(30 + 6 * lev
, 15 + 3 * lev
, 5 + 2 * lev
) fCirc x + dx * i, y + dy * i, startr
lev = lev + 1
branch x2, y2, .8 * startr, angD + 22 + rand%(-10, 19), rand%(.75 * length, .9 * length), lev
branch x2, y2, .8 * startr, angD - 22 - rand%(-10, 19), rand%(.75 * length, .9 * length), lev
'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
SUB fRect
(x1
, y1
, x2
, y2
, c&
) LINE (x1
, y1
)-(x2
, y2
), c&
, BF
SUB fRectStep
(x1
, y1
, x2
, y2
)
SUB lien
(x1
, y1
, x2
, y2
)
sp = 15: leafs = rand%(xmx * ymx * .00001, xmx * ymx * .00002)
COLOR _RGB(rand%
(50, 250), rand%
(25, 255), rand%
(0, 40)) xoff
= x
+ RND * sp
- RND * sp
yoff
= y
+ RND * sp
- RND * sp
fRectStep xoff, yoff, woff, hoff
SUB midInk
(r1%
, g1%
, b1%
, r2%
, g2%
, b2%
, fr##
) COLOR _RGB(r1%
+ (r2%
- r1%
) * fr##
, g1%
+ (g2%
- g1%
) * fr##
, b1%
+ (b2%
- b1%
) * fr##
)
rand%
= INT(RND * (hi%
- lo%
+ 1)) + lo%