# small basic graphic and animations and more (10)

• ### General discussion

• Continued from small basic graphic and animations and more (9)

binary adder and nand logic: SMK709

this is everything ur pc does! all those beautiful stuff, music , pics, web pages and so on are just result of this basic operation of adding 2 numbers together, repeated billion of times. incredible but true! and u thought ur pc was very smart...

a graphic representation of binary half-adder: (nand gates)

full adder is a combination of 2 half-adders

Thursday, June 7, 2018 3:59 AM

### All replies

• I rewrote your SMK709 for Fun Basic.  Fun Basic can't use extensions but Function.

```LogicOr["True"] = "True=True;False=True;"
LogicOr["False"] = "True=True;False=False;"
args=0
tr="True"
fl="False"
bin[tr]=1
bin[fl]=0
log="1=True;0=False;"

For q=1 To 28 '----------------------------------------max 30
nu1=Text.Append(nu1, Math.GetRandomNumber(2)-1)
nu2=Text.Append(nu2, Math.GetRandomNumber(2)-1)
EndFor

rz=""
For f=0 To Array.GetItemCount(vv)
rz=Text.Append(rz, vv[f])
EndFor

TextWindow.WriteLine(" "+nu1+": "+b2dc(nu1))
TextWindow.WriteLine(" "+nu2+"+ "+b2dc(nu2))
TextWindow.WriteLine(text.GetSubText("------------------------------------------------------------------------------------------------------------", 1, Text.GetLength(nu2)+20))
TextWindow.WriteLine(rz+"= "+b2dc(rz))

Function nand(a, b) '----------------------nand logic-------------------
If a and b Then
nand="False"
Else
nand="True"
EndIf
EndFunction

Function b2dc(aaa) '--------------bin2dec--------------------
dv=0
ev=1
For r= Text.GetLength(aaa) To 1 Step -1
dv=dv+Text.GetSubText(aaa, r, 1)*ev
ev=ev*2
EndFor
b2dc=dv
EndFunction

Function nmadd(n1, n2) '-------------adds 2 bin number------------
ts=0
For r=Text.GetLength(n1) To 1 Step -1
rss=fadd(log[Text.GetSubText(n1, r, 1)], log[Text.GetSubText(n2, r, 1)], log[ts])
EndFor
rs[0]=ts
EndFunction

xxx = r1[2] ' will be broken in hadd()
EndFunction

v1= nand(aa, bb)
v2= nand(aa, v1)
v3= nand(v1, bb)
o1= nand(v2, v3)
o2= nand(v1, v1)
EndFunction

Function l2bn(l) '-----------t/f To 1/0----------------
a1=bin[l[1]]
a2=bin[l[2]]
l2bn=Text.Append(a1, a2)
EndFunction

Sub test
TextWindow.WriteLine("fff: "+l2bn(fadd(fl, fl, fl)))
TextWindow.WriteLine("fft: "+l2bn(fadd(fl, tr, fl)))
TextWindow.WriteLine("ftf: "+l2bn(fadd(tr, fl, fl)))
TextWindow.WriteLine("ftt: "+l2bn(fadd(tr, tr, fl)))
TextWindow.WriteLine("tff: "+l2bn(fadd(fl, fl, tr)))
TextWindow.WriteLine("tft: "+l2bn(fadd(fl, tr, tr)))
TextWindow.WriteLine("ttf: "+l2bn(fadd(tr, fl, tr)))
TextWindow.WriteLine("ttt: "+l2bn(fadd(tr, tr, tr)))
EndSub```

Nonki Takahashi

Sunday, June 10, 2018 9:12 AM
• binary half adder scheme: SWW278

click on switches to get result

Wednesday, June 13, 2018 4:24 AM
• bin full adder: NKX738

lamps are C-Carry S=Sum T=test( used to test lamps C/S are ok. invalid states are 0-0-1 meaning lamps C/S are lit, or 1-1-0, 1-0-0, 0-1-0 meaning test lamp is lit

truth table

C B A >> C S T

0-0-0      0-0-0 (t blinking)

1-1-1      1-1-1

0 0 1       0 1 1

0 1 0       0 1 1

1 0 0       0 1 1

1 1 0       1 0 1

0 1 1       1 0 1

1 0 1       1 0 1

• Edited by Wednesday, June 13, 2018 7:42 PM
Wednesday, June 13, 2018 7:20 PM
• 4 bit adder with carry in/out bits: TBN736

Thursday, June 14, 2018 10:08 AM
• sb logo demo:rbw785

original funtion x^x result:

```GraphicsWindow .PenWidth =.1
GraphicsWindow.Height=500
GraphicsWindow.BackgroundColor="tan"
GraphicsWindow.PenColor ="red"
GraphicsWindow.DrawLine (0 300 900 300)
GraphicsWindow.DrawLine(300 0 300 666)
For x=2 To 0.00001 Step -.001
p=math.Power(x x)*100'*Math.sin(x/2)
q=math.Power(x, -x)*100
GraphicsWindow.SetPixel(x*100+300 300-p "green")
GraphicsWindow.SetPixel(300+x*100 300-q "red")
GraphicsWindow.SetPixel(-x*100+300 300-p "blue")
GraphicsWindow.SetPixel(-x*100+300 300-q "cyan")
EndFor```

transparent version:bsj487
• Edited by Friday, June 15, 2018 4:09 AM
Thursday, June 14, 2018 8:58 PM
• quintis game: QVZ298

(kinda tetris with 5-seg. blocks)

• made from sb tetris
• new feature: while falling down u can also nudge to left/right
• just 4 block types

Sunday, June 17, 2018 6:47 AM
• swiss flag quintis: VQG555
mission:compose swiss flag

Monday, June 18, 2018 10:27 AM
• WGH690

boxchars:

• v2: rounded chars SVC369

• Edited by Wednesday, June 20, 2018 7:15 AM
Wednesday, June 20, 2018 6:46 AM
• VFM200

• Edited by Wednesday, June 20, 2018 9:14 AM
Wednesday, June 20, 2018 9:14 AM
• DZS282

boxchar editor

• type chars a-z
• press esc after char to get it rounded
• press tab to remove all roundness
• press bs to delete chars

Wednesday, June 20, 2018 10:32 AM
• now in lowercase mode: HRT580

Thursday, June 21, 2018 6:12 AM
• combined to one font smoothed:

• XGC298

Friday, June 22, 2018 3:58 AM

• CXR208

Saturday, June 23, 2018 12:22 AM
• xtended small m: DTZ778

Sunday, June 24, 2018 5:31 AM
• brownian galaxies:

• RQP189

use mswheel to zoom in/out

Monday, June 25, 2018 4:50 AM
• zx screen inverse/true test:

• BKM742

Monday, June 25, 2018 7:19 AM
• aperture test:

• ZKF978

use mswheel to adjust aperture

Monday, June 25, 2018 10:28 AM
• ZX overlay & fill demo:

• CXB419

Wednesday, June 27, 2018 4:51 AM
• xor demo:

•  JZB171

Wednesday, June 27, 2018 10:11 AM
• zx sprite

• ZQZ108

Wednesday, June 27, 2018 9:38 PM
• turbomario demo:

• TPK325

click to run to selected location

rightclick to change bgimage

Thursday, June 28, 2018 6:38 AM
• turbo mario & crazy mushrooms game:

• DCX541
• click to jump and remove mushrooms

Saturday, June 30, 2018 6:38 AM
• real 3d ballCXX720

use mouse to spin it around in 3d

Thursday, July 5, 2018 11:20 PM
• color-me: GTL356

• rightclick color to select
• click zone to paint

Sunday, July 8, 2018 7:07 PM
• shadow illusion: FKW204

between the tentacles appears a virtual shadow when u look a bit longer

Wednesday, July 11, 2018 5:04 AM
• CKD051

star pattern generator

use mswheel to zoom, lmb+wheel to rotate

Wednesday, July 11, 2018 7:05 AM
• bin. half-adder: SPG402

the left num.  result is carry (C), and the right one is sum (S)
of lines L-1 and L-2
• Edited by Friday, July 13, 2018 6:02 AM
Friday, July 13, 2018 5:58 AM
• 3D animated drone v0.1

RSC028

Friday, July 13, 2018 7:24 AM
• oscillating drone: DSM891

update v0.2

8-loops: kmw030

• Edited by Tuesday, July 17, 2018 5:14 AM
Friday, July 13, 2018 10:29 AM
• 4 towers in 3D: MHN366

Tuesday, July 17, 2018 6:57 AM
• added drone flyby towers: HSG745

now around all 4 towers: QLT687
• Edited by Tuesday, July 17, 2018 11:18 AM
Tuesday, July 17, 2018 9:24 AM
• visual sorter: VTN252

• Edited by Wednesday, July 25, 2018 5:29 AM
Wednesday, July 25, 2018 5:28 AM
• road drive simulator v0.1: LTZ946

press lmb and drag mouse to speedup, release to brake

Thursday, July 26, 2018 7:22 AM
• eu traffic signs: XKK909

with tooltip description

Thursday, July 26, 2018 10:41 AM
• signs update: FGG068

Friday, July 27, 2018 8:15 PM
• pascal's triangle cross: BZK640

the dot radius is determined by pascal's triangle rule

Sunday, July 29, 2018 2:46 AM
• pascal's triangle lines: VXW977

Sunday, July 29, 2018 3:11 AM
• card game v0.1: RJS426

Thursday, August 2, 2018 10:38 AM
• flappy sine adaptation: GHP076

Friday, August 3, 2018 4:02 AM
• WVD549

cards v0.2

rules:

• from king to ace, regardless of suit, alternating colors
• start from king
• after ace u can start from king again
• make a string of all cards
• use rmb+wheel to zoom in/out

Friday, August 3, 2018 6:41 PM
• sb online soko v0.2
BMC418

• added player movement
• remember to click on right textwindow to start game
• sb online has different keymapping and no boolean eval for now, so every if clause containing and/or parts must be splitted into separate then/if parts
• there are also issues with drawtext, so use shapes.addtext to get correct results

• Edited by Monday, August 6, 2018 6:03 AM
Monday, August 6, 2018 5:44 AM
• balls for sb online: WWD023
Tuesday, August 7, 2018 3:49 AM
• a localhost version of SB online:

how to make it:

• install node/npm (v8, not v10!)
• download https://github.com/sb/SmallBasic-Online zip and extract it
• after install run the node.js command prompt and change cd to extracted dir
• `type: npm i` to install the required packages
• `type: npm run gulp watch-source` to start the webpack server.
• Point your browser to http://localhost:8080
• differences from online version: debug present,
missing graphicwindow, mouse, network, file, sound...

• Edited by Tuesday, August 7, 2018 6:56 PM
Tuesday, August 7, 2018 6:53 PM
• differences by array manipulation sb online vs sb localhost

```a[2]="c"
TextWindow.Write("a:")
TextWindow.WriteLine(a)```

online output:

localhost output:

also localhost sb has and/or evaluating in if clauses :)

• Edited by Tuesday, August 7, 2018 7:19 PM
Tuesday, August 7, 2018 7:16 PM
• Edited by Friday, August 10, 2018 6:12 PM
Thursday, August 9, 2018 7:23 AM
• version for localhost sb: VSS293

import it in normal sb, then paste into localhost sb

bcs localhost sb supports only shapes, and doesn't work shapes.move,all the rectangles&ellipses were replaced with triangles. also the colors are not implemented yet bcs no graphicwindow cmd works :(
• Edited by Thursday, August 9, 2018 9:51 AM
Thursday, August 9, 2018 9:39 AM
• same in sb online: FGX141

Thursday, August 9, 2018 9:46 AM
• various effects for castle town: NTX468

(only 4 sb1.2 desktop, ld xtension req.)

• Edited by Friday, August 10, 2018 3:49 AM
Friday, August 10, 2018 3:47 AM
• Abacus: GHB050

(only 4 sb1.2 desktop, ld xtension req.)

properties:

• shows all the result of multiplication a x b 1 to 32
• shows square roots of a number in color
• shows only integer square roots in number

Saturday, August 11, 2018 9:12 AM
• FULL squareroot spectrum: RWJ531

Saturday, August 11, 2018 11:35 AM
• OctaPulsar: RWJ531-0

Saturday, August 11, 2018 2:32 PM
• marble effect: RWJ531-1

Saturday, August 11, 2018 2:42 PM
• aurora effect: RWJ531-2

Saturday, August 11, 2018 2:54 PM
• zx inspired font: QQX638

• Edited by Sunday, August 12, 2018 9:42 PM
Sunday, August 12, 2018 9:42 PM
• hommage to sir sinclair: PCS222(sb online)

• Edited by Friday, August 17, 2018 9:46 AM
Friday, August 17, 2018 9:36 AM
• taylor polynom Cosine evaluator: VXS640

• evaluates cosine to 26! precision (sb maximum)
• rounds output to 16 decimals precision (TyF)

• Edited by Friday, August 17, 2018 10:10 AM
Friday, August 17, 2018 10:09 AM
• same for sine: LHF935

Friday, August 17, 2018 10:20 AM
• corel-like draw rectangles/ellipses: RCX329

press q/w/e to modify drawing before 2nd click

Thursday, August 30, 2018 11:33 AM
• zoom to infinity: PTS406

Thursday, August 30, 2018 8:49 PM
• sokocastle study: THX525

move by cursor keys

(for desktop sb only, with ld xtension)

images to use(1-4):

• Edited by Wednesday, September 5, 2018 6:11 AM
Wednesday, September 5, 2018 6:07 AM
• added position control: HMF026

bmp to include (on line 4)

Wednesday, September 5, 2018 9:44 AM
• update WNW908

• sliding door
• get diamond to open door
• img for door:

Friday, September 7, 2018 9:04 PM
• map of closed door added: PQK432

Saturday, September 8, 2018 4:50 AM
• list of zx spectrum errors: MCC913

Saturday, September 8, 2018 5:10 AM
• gb union-jack pattern: PPM651

Sunday, September 9, 2018 4:16 AM
• zx village updated: ZXF459

Thursday, September 13, 2018 7:36 PM
• msx2 demo: HZM419
Friday, September 14, 2018 10:24 AM
• 3d textwindow chars: JGT662

adjust txtwindow size to 160 chars on windows prior to run!
• Edited by Tuesday, September 18, 2018 4:14 AM
Monday, September 17, 2018 8:59 PM
• electrofractal with quickdraw: DLP089

Monday, October 1, 2018 4:48 AM
• sb online version: ZDT490

Monday, October 1, 2018 5:31 AM
• ray-tracing: DWV678

Thursday, October 11, 2018 3:44 AM
• added colors: RDH047

Thursday, October 11, 2018 5:53 AM
• added anim: ZGC181
Thursday, October 11, 2018 10:02 AM
• added colors: RDH047

This is super cool, especially since it is done almost all in standard Small Basic and it nice and fast.
Friday, October 12, 2018 5:16 PM
• added bouncing & color shifting: FSX672
Friday, October 12, 2018 6:14 PM
• sb online koch flakes: HNM254

Monday, October 15, 2018 4:09 AM
• bluefire fractal anim: LFJ422
Friday, October 19, 2018 7:19 PM
• sb horace game: WVJ306

image to use for sprites:

• Edited by Saturday, November 24, 2018 8:18 AM
Saturday, November 24, 2018 8:15 AM
• added guardian: RXH973

Monday, November 26, 2018 7:42 AM
• i need someone to teach me how to make an application.
Monday, November 26, 2018 8:44 AM
• explainer: BXF540

use cursors up/dwn to select word to explain (from dictionary)

then press Enter to display result

• Edited by Thursday, December 6, 2018 5:32 PM
Thursday, December 6, 2018 5:31 PM
• update: RBF204

• multicolumn
• multilanguage (eng, esp, fra)

Friday, December 7, 2018 7:11 AM
• NC-like file browser: ZHH208

Monday, December 10, 2018 8:21 PM
• nc update: QVC731

• opens subfolder
• displays filesize in bytes kb mb gb tb
• runs/displays pdf txt bas bat jpg ods files (req. manualy adjust directory to ur system)
• quickviews jpg by mswheel
• mswheel works only when cursor in gw, not in textwindow (sb issue)
• some bugs to solve still

• Edited by Tuesday, December 11, 2018 10:35 PM
Tuesday, December 11, 2018 10:34 PM
• flashing display v0.1: VXL763

Friday, December 14, 2018 5:05 AM
• error diffusion orange:

```cl=LDText.Split("orange red" " ")
GraphicsWindow.BackgroundColor="darkblue"
GraphicsWindow.BrushColor="yellow"
a=143
GraphicsWindow.FillEllipse(300-a 300-a a*2 a*2)
GraphicsWindow.Title="Orange"
For x=1 To 90000
cc=LDMath.Convert2Cartesian(300 300  math.Power(Math.GetRandomNumber(15000) .3)*8 Math.GetRandomNumber(720)/2)
GraphicsWindow.SetPixel(cc[1] cc[2] cl[Math.GetRandomNumber(2)])
EndFor
```

Sunday, December 16, 2018 5:18 AM
• sunflower zoom:

```GraphicsWindow.Width=400
GraphicsWindow.Height=400
GraphicsWindow.Title="Sunflower Zooming"
GraphicsWindow.BackgroundColor="darkblue"
c=(Math.SquareRoot(5)+1)/2
GraphicsWindow.PenWidth=.5
nss=9200
For n=90 To 5 Step -6
For i=0 To nss
r=Math.Power(i,c)/nss
angle=2*Math.Pi*c*i
x=r*Math.Sin(angle)+200
y=r*Math.Cos(angle)+200
GraphicsWindow.BrushColor=LDColours.HSLtoRGB(math.Remainder( 150+i/n 360) 1 .5)
GraphicsWindow.FillEllipse(x-7, y-7, i/nss*15, i/nss*15)
EndFor
ff[f]=LDGraphicsWindow.Capture("" "false")
Program.Delay(55)
f=f+1
EndFor
r=0
While 1=1
r=r+1
i=math.abs(Math.Remainder(r f*2)-f)
'GraphicsWindow.Title=i
GraphicsWindow.DrawImage(ff[i] 0 0)
Program.Delay(75)
EndWhile```

Monday, December 17, 2018 4:04 AM
• fluids anim: TFK171

Friday, December 21, 2018 5:27 AM
• simple julia set:

```creal=-0.8
cimag=0.156
GraphicsWindow.BackgroundColor="#006699"
cll="1=red;2=orange;3=brown;4=blue;5=black"
For v=-25 To 25 step .2
For h=-80 To 80 step .2
x=h/40
y=v/40
cc=Math.Floor(20*Math.Abs(v)*Math.Abs(h)/(80*16))+1
For i=1 To 50 step .6
zreal=x*x-y*y+creal
zimag=x*y*2+cimag
If zreal*zreal>1000 Then
Goto l150
EndIf
x=zreal
y=zimag
EndFor ' i
GraphicsWindow.SetPixel( h*4+350,v*4+250 cll[cc])
l150:
EndFor ' h
EndFor ' v```

Wednesday, December 26, 2018 6:23 PM
• fibonacci's sequence

```args=0
GraphicsWindow.BackgroundColor="teal"
GraphicsWindow.DrawRectangle(300 300 20 20)
GraphicsWindow.DrawRectangle(320 300 20 20)
GraphicsWindow.DrawRectangle(300 320 40 40)
LDCall.Function5("ccc" 90 180 340 320 40)
GraphicsWindow.DrawRectangle(340 300 60 60)
LDCall.Function5("ccc" 0 90 340 300 60)
GraphicsWindow.DrawRectangle(300 200 100 100)
LDCall.Function5("ccc" 270 360 300 300 100)
GraphicsWindow.DrawRectangle(140 200 160 160)
LDCall.Function5("ccc" 180 270 300 360 160)
LDGraphicsWindow.FloodFillTolerance=5
LDGraphicsWindow.FloodFill(145 205 "white")
LDGraphicsWindow.FloodFill(395 205 "white")
LDGraphicsWindow.FloodFill(395 355 "white")
LDGraphicsWindow.FloodFill(305 355 "white")
LDGraphicsWindow.FloodFill(5 5 "tan")
GraphicsWindow.Title="Fibbonacci's Sequence Squares"
Sub ccc
rr=args[5]
For f=args[1] To args[2] Step .1
GraphicsWindow.SetPixel(args[3]+LDMath.Cos(f)*rr args[4]+LDMath.Sin(f)*rr "red")
EndFor
EndSub```

it's the simplest aprox. of golden ratio 1.618

13/8=1.625 by error only 0.43%

golden ratio is exactly sqr(5)/2+0.5=

1.6180339887498948...

• Edited by Saturday, December 29, 2018 11:05 PM
Saturday, December 29, 2018 10:50 PM
• strandsort method: ZFJ299

(contains a small bug, one nr gets lost, why?)

Wednesday, January 2, 2019 8:52 AM
• The bug lies in the fact that you use the same variables in the sub Strandsort as in the sub Merge. As rhe variables in SmallBasic are global they interfere, especially i.

I changed i, j and k in "Merge" into im, jm and km (te be safe).

Then there will be no more missing values.

Jan [ WhTurner ] The Netherlands

Wednesday, January 2, 2019 12:26 PM
• tx jan) error corrected and added anim sort: GWQ577

Wednesday, January 2, 2019 3:32 PM
• very fast prime number seeker: (by ld xtension)

```TextWindow.Write("Enter number to search to: ")
flags=LDFastArray.CreateFromValues("")
For n = 2 To limit
LDFastArray.Set1D( flags n 0)
EndFor
For n = 2 To math.SquareRoot(limit)
If LDFastArray.Get1D( flags n) = 0 Then
For K = n * n To limit Step n
LDFastArray.Set1D( flags k 1)
EndFor
EndIf
EndFor
' Display the primes
If limit >= 2 Then
TextWindow.Write(2)
For n = 3 To limit
If LDFastArray.Get1D( flags n) = 0 Then
TextWindow.Write(", " + n)
EndIf
EndFor
TextWindow.WriteLine("")
EndIf```

fastarray is at least 1000x faster than sb arrays!

another method is ldlist, but is just 5x faster then sb array

```TextWindow.Write("Enter number To search To: ")
ll=LDList.CreateFromValues("")
For n = 2 To limit
EndFor
For n = 2 To math.SquareRoot(limit)
If  LDList.Contains(ll n)  Then
For K = n * n To limit Step n
LDList.Remove(ll k "true")
EndFor
EndIf
EndFor
flags=LDList.ToArray(ll)

For n = 1 To Array.GetItemCount(flags)

TextWindow.Write(flags[n]+", ")

EndFor
TextWindow.WriteLine("")
```

• Edited by Friday, January 4, 2019 8:46 AM
Friday, January 4, 2019 8:43 AM
• updated nonki's nice bear: FSX554

• 15 kb reduced filesize (-25%)
• 62% reduced lines (1085 to 405)
• some colors changed

• Edited by Monday, January 7, 2019 7:31 AM
Monday, January 7, 2019 7:07 AM
• turing machine: MSD374

Tuesday, January 8, 2019 6:01 AM
• now 3 state beaver turing mach.

FWV264

Tuesday, January 8, 2019 5:39 PM
• poem composer: DLF680

Tuesday, January 8, 2019 8:08 PM
• 8queens solutions browser: WRV663

Wednesday, January 9, 2019 4:59 AM
• rot13 chiper

• JTK461

Saturday, January 12, 2019 7:00 AM
• sine waves illusion: TCJ895

Monday, January 14, 2019 7:21 AM
• ```GraphicsWindow.Title="Recaman's sequence"
nn=500
recaman()
GraphicsWindow.Width=1300
GraphicsWindow.Left=5
GraphicsWindow.BackgroundColor="tan"
gg=LDGraph.AddGraph(0 0 GraphicsWindow.Width GraphicsWindow.Height "" "" "")
LDGraph.AddSeriesLine(gg "1" recam "red")

Sub recaman
a=""
b=""
dup=""
For n=0 To nn-1
ap=a[n-1]+n
If a[n-1]<=n Then
a[n]=ap
b[ap]=1
Else
am=a[n-1]-n
If b[am]=1 Then
a[n]=ap
b[ap]=1
Else
a[n]=am
b[am]=1
EndIf
EndIf

ii=ii+1
recam[ii]=a[n]
EndFor
EndSub```

Monday, January 14, 2019 6:32 PM
• This thread will be continued to small basic graphic and animations and more (11).

Nonki Takahashi

Thursday, January 17, 2019 7:35 AM