Patterns 2.bas

This is an update of Patterns.bas with more bells and whistles. Pause working fine here!

This topic is being discussed at:
http://retrogamecoding.org/board/index.php?topic=427.15
(Membership required for attached screenshots and downloads.)

This SmallBASIC version is better than what I have posted there, I think, more like the Naalaa version for which I have posted an exe.


' patterns 2.bas SmallBASIC 0.12.7 [B+=MGA] 2016-09-18
' from pattern.bas for SmallBASIC 0.12.0 2015-11-27 Peter W & MGA/B+
' probably Peter's source was (since uses all same variable names...):
' http://shawweb.myzen.co.uk/stephen/sdlbasic.htm

' 2016-09-18 modify (Fix!) to full range R OR G OR B coloring
' test new 0.12.7 update SmallBASIC (2016-09-17)
' add toggles for rectangles 1 to 8 with + for plus, - for minus
' add toggles c for color to B & W, on/off
' add keys u, d, h, e for like: page up, page down, home, end
' add label, extra code to speed B&W versions
' now modified to 6: 65 to 255 color ranges plus,
' 1/8th pure white and 1/8th pure black for contrast
' The more 0 to 1 is split the more exquisite the detail.

' hit spacebar or click screen to get the next screen sooner than 5 secs

definekey 43, plusPress ' + increase reactangle size up to 8x8 pixels
definekey 45, minusPress ' - decrease rectangle size to 1x1 = pixels
definekey 99, cPress 'color toggle B&W
definekey 98, bPress 'b for back 5, s back 5 = last s again
definekey 117, uPress 'u like page up, s + 100, also click right screen
definekey 100, dPress 'd like page down, s - 100, also click left screen
definekey 104, hPress 'h like home, s = 10 , also click top screen
definekey 101, ePress 'e like end, s = 900, also click bottom screen

colr = 1 'color is on
g = 2 'g controls f the rectangle size
u = 500 'u controls s that controls the d number that controls color
pen on
while 1
cls
f = g
s = u
if colr then
for i = 0 to xmax / f
for j = 0 to (ymax - 20) / f
x = i * s / 600
y = j * s / 600
d = (x * x + y * y) / 2
d = d - int(d)
if d < .125 then
cc = 0
elif d < .25
z = (d - .125) / .125 * 190 + 65
cc = rgb( z, 0, 0)
elif d < .375
z = (d - 0.25) / 0.125 * 190 + 65
cc = rgb(z, z, 0)
elif d < .5
z = (d - .375) / .125 * 190 + 65
cc = rgb(0, z, 0)
elif d < .625
z = (d - .5) / .125 * 190 + 65
cc = rgb(0, z, z)
elif d < .75
z = (d - .625) / .125 * 190 + 65
cc = rgb(0, 0, z)
elif d < .875
z = (d - .75) / .125 * 190 + 65
cc = rgb(z, 0, z)
else
cc = 15
fi
rect i * f,j * f + 21 step f, f, cc filled
'pset i,j,cc
next
next
else
for i = 0 to xmax / f
for j = 0 to (ymax - 20) / f
x = i * s / 600
y = j * s / 600
c = x * x + y * y
d = c / 2
d = d - int(d)
if d < 0.35 then rect i * f, j * f + 21 step f, f, 15 filled
next
next
end if
color 7, 0
ts = "Patterns 2: s = " + str(s) + ", " + str(f) + "x"
ts = ts + str(f) + " key: + - pixel magnification, c color on/off, b backup,"
ts = ts + " u d h e or click to naviagte s"
at (xmax -txtw(ts))/2, 1 : ? ts
showpage
pause 5 'for snapshot
if pen(3) then
mx = pen(4) : my = pen(5)
delay 100
if my > 100 and my < ymax - 100 then
if mx < 100 then dPress
if mx > xmax - 100 then uPress
elif my < 100 and my > -1
hPress
elif my > ymax - 100
ePress
end if
end if
u += 5
if u > 1000 then u = 5
wend

sub
plusPress()
g = iff(f + 1 < 9, f + 1, f)
end

sub
minusPress()
g = iff(f - 1 > 0, f - 1, f)
end

sub
cPress()
colr = (colr + 1) % 2
end

sub
bPress()
u = iff(u - 10 > 0, u - 10, 990)
end

sub
uPress()
u = iff(u + 100 < 1000, u + 100, 900)
end


sub
dPress()
u = iff(u - 100 > 0, u - 100, 5)
end

sub
hPress()
u = 5
end

sub
ePress()
u = 900
end
sub

Hi Johnno,

Thanks (don't understand "monochromatic"? but ) greetings!

Append/EDIT: Oh yeah! I forgot I had a B & W option! Apparently I had all kinds of options, all I remembered from 3 months ago was taking pains to emphasize primary and secondary colors.

Mono - One; Chroma - Colour

... and that concludes today's lesson in Jinglish... lol

But the effects really are quite cool....

J