User avatar
John Spikowski
Posts: 41
Joined: Sat Jul 20, 2019 5:34 pm
Location: Anacortes, WA USA
Contact: Website

UKB Extension Module

Mon Jul 22, 2019 3:52 am

The UKB extension module is a fork of the Brandy graphics primitives library. If you would like to take a maintainer role in this extension module please let me know.

Code: Select all

' Fern

IMPORT ukb.bas

UKB::OPEN "ScriptBasic UKB Fern"
t1 = UKB::TIME()
UKB::MODE 31
UKB::ORIGIN 200, 100
UKB::OFF
UKB::GCOL 0, 10
x = 0
y = 0
FOR i = 1 TO 80000
  r = UKB::RND(1)
  IF r <= 0.1 THEN SPLIT "0,0,0,.16,0,0" BY "," TO a,b,c,d,e,f
  IF r > 0.1 AND r <= 0.86 THEN SPLIT ".85,.04,-.04,.85,0,1.6" BY ","  TO a,b,c,d,e,f
  IF r > 0.86 AND r <= 0.93 THEN SPLIT ".2,-.26,.23,.22,0,1.6" BY ","  TO a,b,c,d,e,f
  IF r > 0.93 THEN SPLIT "-.15,.28,.26,.24,0,.44" BY ","  TO a,b,c,d,e,f
  newx = a * x + b * y + e
  newy = c * x + d * y + f
  x = newx
  y = newy
  UKB::MOVE 600 + 96 * x, 32 + 96 * y
  UKB::DRAW 600 + 96 * x, 32 + 96 * y
NEXT i
t2 = UKB::TIME()
t3 = (t2-t1)/1000
UKB::VDUSTR "Time: " & FORMAT("%.4f",t3) & " seconds"
UKB::WAITKEY
UKB::CLOSE
Attachments
UKB_Fern.png
UKB_Fern.png (29.31 KiB) Viewed 1600 times

User avatar
John Spikowski
Posts: 41
Joined: Sat Jul 20, 2019 5:34 pm
Location: Anacortes, WA USA
Contact: Website

Re: UKB Extension Module

Tue Jul 23, 2019 3:34 am

Attached is the UKB extension module for those that would like to try BBC / Brandy graphic based programs with ScriptBasic.

ukb.so - Install this in your ScriptBasic modules directory.

ukb.bas - Install this in your ScriptBasic include directory.

SDL 1.2 is a required dependency.
Attachments
UKB_RPi.zip
(31.15 KiB) Downloaded 45 times

User avatar
John Spikowski
Posts: 41
Joined: Sat Jul 20, 2019 5:34 pm
Location: Anacortes, WA USA
Contact: Website

Re: UKB Extension Module

Tue Jul 23, 2019 3:42 am

UKB UFO

Code: Select all

' UFO

IMPORT ukb.bas

UKB::OPEN "ScriptBasic UKB UFO - Raspberry PI"
t1 = UKB::TIME()
UKB::MODE 31
UKB::ORIGIN 800, 600
xs = 2
ys = 2
UKB::GCOL 0, 14
UKB::OFF
a = 700
b = A * A
c = 600
FOR x = 0 TO a STEP xs
  s = x * x
  p = SQR(b - s)
  FOR i = -p TO p STEP 6 * ys
    r = SQR(s + i * i) / a
    q = (r - 1) * SIN(24 * r)
    y = INT(i / 3 + q * c)
    IF i = -p THEN
      m = y
      n = y
    END IF
    IF y > m THEN m = y
    IF y < n THEN n = y
    IF m = y OR n = y THEN
      UKB::PLOT 69, NOT(x), y
      UKB::PLOT 69, x, y
    END IF
  NEXT
NEXT
t2 = UKB::TIME()
t3 = (t2 - t1) / 1000
UKB::OFF
UKB::VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds."
WHILE UKB::KEYNAME(1) <> "-escape"
WEND
UKB::CLOSE
Attachments
UKB_UFO.png
UKB_UFO.png (31.69 KiB) Viewed 1543 times

User avatar
John Spikowski
Posts: 41
Joined: Sat Jul 20, 2019 5:34 pm
Location: Anacortes, WA USA
Contact: Website

Re: UKB Extension Module

Tue Jul 23, 2019 3:49 am

UKB 3D Graph

Code: Select all

' 3D Graph Demo

IMPORT ukb.bas

CONST SDLK_ESCAPE = 27

UKB::OPEN "ScriptBasic UKB 3D Graph - Raspberry Pi"
t1 = UKB::TIME()
UKB::MODE 31
UKB::ORIGIN 800, 600
xlow = -10
xhigh = 10
ylow = -10
yhigh = 10
depth = 10
xscale = 30
yscale = 12
c = -4000

FOR x = xlow TO xhigh
  UKB::MOVE xscale * (x + ylow), yscale * (ylow - x) + c / (x * x + ylow * ylow + depth)
  FOR y = ylow TO yhigh
    UKB::DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth)
  NEXT
NEXT
FOR y = ylow TO yhigh
  UKB::MOVE xscale * (xlow + y), yscale * (y - xlow) + c / (xlow * xlow + y * y + depth)
  FOR x = xlow TO xhigh
    UKB::DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth)
  NEXT
NEXT
t2 = UKB::TIME()
t3 = (t2 - t1) / 1000
UKB::OFF
UKB::VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds."
WHILE UKB::GETKEY(1) <> SDLK_ESCAPE
WEND
UKB::CLOSE
Attachments
UKB_3D_Graph.png
UKB_3D_Graph.png (22.02 KiB) Viewed 1539 times

User avatar
John_Spikowski
Posts: 1614
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: UKB Extension Module

Fri Jul 26, 2019 3:52 am

It would be great if some of the UK BASIC enthusiast would convert a few Brandy /:BBC BASIC programs to ScriptBasic using the UKB extension module.

It will be interesting to see what might still be needed to add to the extension module.

Return to “Other programming languages”