DISLIN Examples / FreeBASIC
Demonstration of CURVE / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 300
DIM AS SINGLE xray(n), y1ray(n), y2ray(n)
DIM AS SINGLE x, stp, fpi
DIM AS INTEGER i, ic
fpi = 3.1415926 / 180
stp = 360.0f / n
FOR i = 0 TO n
xray(i) = i * stp
x = xray(i) * fpi
y1ray(i) = sin (x)
y2ray(i) = cos (x)
NEXT i
Dislin.scrmod ("revers")
Dislin.metafl ("xwin")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.axspos (450, 1800)
Dislin.axslen (2200, 1200)
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.labdig (-1, "X")
Dislin.ticks (10, "Y")
Dislin.ticks (9, "X")
Dislin.titlin ("Demonstration of CURVE", 1)
Dislin.titlin ("SIN(X), COS(X)", 3)
ic = Dislin.intrgb (0.95, 0.95, 0.95)
Dislin.axsbgd (ic)
Dislin.graf (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 0.5)
Dislin.setrgb (0.7, 0.7, 0.7)
Dislin.grid (1, 1)
Dislin.color ("fore")
Dislin.height (50)
Dislin.title ()
Dislin.color ("red")
Dislin.curve (@xray(0), @y1ray(0), n + 1)
Dislin.color ("green")
Dislin.curve (@xray(0), @y2ray(0), n + 1)
Dislin.disfin ()
END
Polar Plots / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 300 - 1
DIM AS INTEGER m = 10 - 1
DIM AS SINGLE pi = 3.1415926
DIM AS SINGLE xray(n), x1(n), y1(n)
DIM AS SINGLE x2(m), y2(m)
DIM AS SINGLE a, x, f, stp
DIM AS INTEGER i, ic
f = pi / 180.0
stp = 360.0 / n
FOR i = 0 TO n
a = i * stp * f
xray(i) = i * stp
x = xray(i) * f
y1(i) = a
x1(i) = sin (5 * a)
NEXT i
FOR i = 0 TO m
x2(i) = i + 1
y2(i) = i + 1
NEXT i
Dislin.setpag ("da4p")
Dislin.metafl ("cons")
Dislin.scrmod ("revers")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.titlin ("Polar Plots", 2)
Dislin.ticks (3, "Y")
Dislin.axends ("NOENDS", "X")
Dislin.labdig (-1, "Y")
Dislin.axslen (1000, 1000)
Dislin.axsorg (1050, 900)
ic = Dislin.intrgb (0.95, 0.95, 0.95)
Dislin.axsbgd (ic)
Dislin.grafp (1.0, 0.0, 0.2, 0.0, 30.0)
Dislin.color ("blue")
Dislin.curve (@x1(0), @y1(0), n)
Dislin.color ("fore")
Dislin.htitle (50)
Dislin.title ()
Dislin.endgrf ()
Dislin.labdig (-1, "X")
Dislin.axsorg (1050, 2250)
Dislin.labtyp ("VERT", "Y")
Dislin.grafp (10.0, 0.0, 2.0, 0.0, 30.0)
Dislin.barwth (-5.0)
Dislin.polcrv ("FBARS")
Dislin.color ("blue")
Dislin.curve (@x2(0), @y2(0), m)
Dislin.disfin ()
END
Symbols / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS STRING ctit = "Symbols"
DIM AS INTEGER i, nl, ny, nxp
DIM AS SINGLE v
Dislin.scrmod ("revers")
Dislin.setpag ("da4p")
Dislin.metafl ("cons")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.height (60)
nl = Dislin.nlmess (ctit)
Dislin.messag (ctit, (2100 - nl)/2, 200)
Dislin.height (50)
Dislin.hsymbl (120)
ny = 150
FOR i = 0 TO 23
IF (i MOD 4) = 0 THEN
ny += 400
nxp = 550
ELSE
nxp += 350
END IF
v = i
nl = Dislin.nlnumb (v, -1)
Dislin.number (v, -1, nxp - nl/2, ny + 150)
Dislin.symbol (i, nxp, ny)
NEXT i
Dislin.disfin ()
END
Interpolation Methods / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS SINGLE xray(15) = {0., 1., 3., 4.5, 6., 8., 9., 11., 12., 12.5, _
13., 15., 16., 17., 19., 20.}
DIM AS SINGLE yray(15) = {2., 4., 4.5, 3., 1., 7., 2., 3., 5., 2., 2.5, _
2., 4., 6., 5.5, 4.}
DIM AS STRING ctit = "Interpolation Methods"
DIM AS STRING cpol(5) = {"SPLINE", "STEM", "BARS", "STAIRS", "STEP", "LINEAR"}
DIM AS INTEGER ic, i, nya, nx, ny
Dislin.setpag ("da4p")
Dislin.scrmod ("reverse")
Dislin.metafl ("xwin")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.incmrk (1)
Dislin.hsymbl (25)
Dislin.titlin (ctit, 1)
Dislin.axslen (1500, 350)
Dislin.setgrf ("LINE", "LINE", "LINE", "LINE")
ic = Dislin.intrgb (1.0, 1.0, 0.0)
Dislin.axsbgd (ic)
nya = 2700
FOR i = 0 TO 5
Dislin.axspos (350, nya - i * 350)
Dislin.polcrv (cpol(i))
Dislin.marker (0)
Dislin.graf (0., 20., 0., 5., 0., 10., 0., 5.)
nx = Dislin.nxposn (1.)
ny = Dislin.nyposn (8.)
Dislin.messag (cpol(i), nx, ny)
Dislin.color ("red")
Dislin.curve (@xray(0), @yray(0), 16)
Dislin.color ("fore")
IF i = 5 THEN
Dislin.height (50)
Dislin.title ()
END IF
Dislin.endgrf ()
NEXT i
Dislin.disfin ()
END
Bar Graphs / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS SINGLE x(8) = {1., 2., 3., 4., 5., 6., 7., 8., 9.}
DIM AS SINGLE y(8) = {0., 0., 0., 0., 0., 0., 0., 0., 0.}
DIM AS SINGLE y1(8) = {1., 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1}
DIM AS SINGLE y2(8) = {2., 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8}
DIM AS SINGLE y3(8) = {4., 3.5, 4.5, 3.7, 4., 2.9, 3.0, 3.2, 2.6}
DIM AS INTEGER nya = 2700, i
DIM AS STRING ctit = "Bar Graphs (BARS)"
DIM cbuf AS ZSTRING * 80
Dislin.setpag ("da4p")
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.ticks (1, "x")
Dislin.intax ()
Dislin.axslen (1600, 700)
Dislin.titlin (ctit, 3)
Dislin.legini (cbuf, 3, 8)
Dislin.leglin (cbuf, "FIRST", 1)
Dislin.leglin (cbuf, "SECOND", 2)
Dislin.leglin (cbuf, "THIRD", 3)
Dislin.legtit (" ")
Dislin.shdpat (5)
FOR i = 1 TO 3
IF i > 1 THEN
Dislin.labels ("none","x")
END IF
Dislin.axspos (300, nya-(i-1)*800)
Dislin.graf (0., 10., 0., 1., 0., 5., 0., 1.)
IF i = 1 THEN
Dislin.bargrp (3, 0.15)
Dislin.color ("red")
Dislin.bars (@x(0), @y(0), @y1(0), 9)
Dislin.color ("green")
Dislin.bars (@x(0), @y(0), @y2(0), 9)
Dislin.color ("blue")
Dislin.bars (@x(0), @y(0), @y3(0), 9)
Dislin.color ("fore")
Dislin.reset ("bargrp")
ELSEIF i = 2 THEN
Dislin.height (30)
Dislin.labels ("delta","bars")
Dislin.labpos ("center","bars")
Dislin.color ("red")
Dislin.bars (@x(0), @y(0), @y1(0), 9)
Dislin.color ("green")
Dislin.bars (@x(0), @y1(0), @y2(0), 9)
Dislin.color ("blue")
Dislin.bars (@x(0), @y2(0), @y3(0), 9)
Dislin.color ("fore")
Dislin.reset ("height")
ELSEIF i = 3 THEN
Dislin.labels ("second", "bars")
Dislin.labpos ("outside", "bars")
Dislin.color ("red")
Dislin.bars (@x(0), @y(0), @y1(0), 9)
Dislin.color ("fore")
END IF
IF i <> 3 THEN
Dislin.legend (cbuf, 7)
END IF
IF i = 3 THEN
Dislin.height (50)
Dislin.title ()
END IF
Dislin.endgrf ()
NEXT i
Dislin.disfin ()
END
Pie Charts / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS SINGLE xray(4) = {1., 2.5, 2., 2.7, 1.8}
DIM AS STRING ctit
DIM cbuf AS ZSTRING * 80
ctit = "Pie Charts (PIEGRF)"
Dislin.setpag ("da4p")
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.chnpie ("BOTH")
Dislin.axslen (1600, 1000)
Dislin.titlin (ctit, 2)
Dislin.legini (cbuf, 5, 8)
Dislin.leglin (cbuf, "FIRST", 1)
Dislin.leglin (cbuf, "SECOND", 2)
Dislin.leglin (cbuf, "THIRD", 3)
Dislin.leglin (cbuf, "FOURTH", 4)
Dislin.leglin (cbuf, "FIFTH", 5)
Dislin.patcyc (1, 7)
Dislin.patcyc (2, 4)
Dislin.patcyc (3, 13)
Dislin.patcyc (4, 3)
Dislin.patcyc (5, 5)
Dislin.axspos (250, 2800)
Dislin.piegrf (cbuf, 1, @xray(0), 5)
Dislin.endgrf ()
Dislin.axspos (250, 1600)
Dislin.labels ("DATA", "PIE")
Dislin.labpos ("EXTERNAL", "PIE")
Dislin.piegrf (cbuf, 1, @xray(0), 5)
Dislin.height (50)
Dislin.title ()
Dislin.disfin ()
END
3-D Bar Graph / 3-D Pie Chart / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS SINGLE xray(4) = {2., 4., 6., 8., 10.}
DIM AS SINGLE y1ray(4) = {0., 0., 0., 0., 0.}
DIM AS SINGLE y2ray(4) = {3.2, 1.5, 2.0, 1.0, 3.0}
DIM AS INTEGER ic1ray(4) = {50, 150, 100, 200, 175}
DIM AS INTEGER ic2ray(4) = {50, 150, 100, 200, 175}
DIM cbuf AS ZSTRING * 80
Dislin.metafl ("cons")
Dislin.setpag ("da4p")
Dislin.scrmod ("revers")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.titlin ("3-D Bar Graph / 3-D Pie Chart", 2)
Dislin.htitle (40)
Dislin.shdpat (16)
Dislin.axslen (1500, 1000)
Dislin.axspos (300, 1400)
Dislin.barwth (0.5)
Dislin.bartyp ("3dvert")
Dislin.labels ("second", "bars")
Dislin.labpos ("outside", "bars")
Dislin.labclr (255, "bars")
Dislin.graf (0., 12., 0., 2., 0., 5., 0., 1.)
Dislin.title ()
Dislin.color ("red")
Dislin.bars (@xray(0), @y1ray(0), @y2ray(0), 5)
Dislin.endgrf ()
Dislin.shdpat (16)
Dislin.labels ("data", "pie")
Dislin.labclr (255, "pie")
Dislin.chnpie ("none")
Dislin.pieclr (@ic1ray(0), @ic2ray(0), 5)
Dislin.pietyp ("3d")
Dislin.axspos (300, 2700)
Dislin.piegrf (cbuf, 0, @y2ray(0), 5)
Dislin.disfin ()
END
3-D Bars / BARS3D / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 17
DIM AS SINGLE xray(17) = {1., 3., 8., 1.5, 9., 6.3, 5.8, 2.3, 8.1, 3.5, _
2.2, 8.7, 9.2, 4.8, 3.4, 6.9, 7.5, 3.8}
DIM AS SINGLE yray(17) = {5., 8., 3.5, 2., 7., 1.,4.3, 7.2, 6.0, 8.5, _
4.1, 5.0, 7.3, 2.8, 1.6, 8.9, 9.5, 3.2}
DIM AS SINGLE z1ray(17) = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., _
0., 0., 0., 0., 0., 0., 0., 0.}
DIM AS SINGLE z2ray(17) = {4., 5., 3., 2., 3.5, 4.5, 2., 1.6, 3.8, 4.7, _
2.1, 3.5, 1.9, 4.2, 4.9, 2.8, 3.6, 4.3}
DIM AS INTEGER icray(17) = {30, 30, 30, 30, 30, 30, 100, 100, 100, 100, _
100, 100, 170, 170, 170, 170, 170, 170}
DIM AS SINGLE xwray(17), ywray(17)
DIM cbuf AS ZSTRING * 80
DIM AS INTEGER i
FOR i = 0 TO n
xwray(i) = 0.5
ywray(i) = 0.5
NEXT i
Dislin.metafl ("xwin")
Dislin.scrmod ("revers")
Dislin.setpag ("da4p")
Dislin.disini ()
Dislin.hwfont ()
Dislin.pagera ()
Dislin.axspos (200, 2600)
Dislin.axslen (1800, 1800)
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.name ("Z-axis", "Z")
Dislin.titlin ("3-D Bars / BARS3D",3)
Dislin.labl3d ("hori")
Dislin.graf3d (0.,10.,0.,2.,0.,10.,0.,2.,0.,5.,0.,1.)
Dislin.grid3d (1,1, "bottom")
Dislin.bars3d (@xray(0), @yray(0), @z1ray(0), @z2ray(0), @xwray(0), _
@ywray(0), @icray(0), n + 1)
Dislin.legini (cbuf, 3, 20)
Dislin.legtit (" ")
Dislin.legpos (1350, 1150)
Dislin.leglin (cbuf, "First", 1)
Dislin.leglin (cbuf, "Second", 2)
Dislin.leglin (cbuf, "Third", 3)
Dislin.legend (cbuf, 3)
Dislin.height (50)
Dislin.title ()
Dislin.disfin ()
END
Shading Patterns / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER ix(3) = {0, 300, 300, 0}
DIM AS INTEGER iy(3) = {0, 0, 400, 400}
DIM AS INTEGER ixp(3) = {0, 0, 0, 0}
DIM AS INTEGER iyp(3) = {0, 0, 0, 0}
DIM AS STRING ctit = "Shading patterns (AREAF)"
DIM AS INTEGER i, j, k, ii, nl, nx0, ny0, iclr, nx, ny
DIM AS SINGLE v
Dislin.metafl ("cons")
Dislin.scrmod ("revers")
Dislin.disini ()
Dislin.setvlt ("small")
Dislin.pagera ()
Dislin.complx ()
Dislin.height (50)
nl = Dislin.nlmess (ctit)
Dislin.messag (ctit, (2970 - nl)/2, 200)
nx0 = 335
ny0 = 350
iclr = 0
FOR i = 0 TO 2
ny = ny0 + i * 600
FOR j = 0 TO 5
nx = nx0 + j * 400
ii = i * 6 + j
Dislin.shdpat (ii)
iclr = iclr MOD 8
iclr = iclr + 1
Dislin.setclr (iclr)
FOR k = 0 TO 3
ixp(k) = ix(k) + nx
iyp(k) = iy(k) + ny
NEXT k
Dislin.areaf (@ixp(0), @iyp(0), 4)
nl = Dislin.nlnumb (ii, -1)
nx += (300 - nl) / 2
Dislin.color ("foreground")
v = ii
Dislin.number (v, -1, nx, ny + 460)
NEXT j
NEXT i
Dislin.disfin ()
END
3-D Colour Plot / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 100
DIM AS SINGLE zmat(n,n)
DIM AS SINGLE x, y, stp, fpi
DIM AS INTEGER i, j
fpi = 3.1415926 / 180
stp = 360.0f / n
FOR i = 0 TO n
x = i * stp
FOR j = 0 TO n
y = j * stp
zmat (i,j) = 2 * sin (x * fpi) * sin (y * fpi)
NEXT j
NEXT i
Dislin.scrmod ("revers")
Dislin.metafl ("xwin")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.titlin ("3-D Colour Plot of the Function", 1)
Dislin.titlin ("F(X,Y) = 2 * SIN(X) * SIN(Y)", 3)
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.name ("Z-axis", "Z")
Dislin.axspos (300, 1850)
Dislin.ax3len (2200, 1400, 1400)
Dislin.intax ()
Dislin.autres (n, n)
Dislin.graf3 (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0, _
-2.0, 2.0, -2.0, 1.0)
Dislin.crvmat (@zmat(0,0), n + 1, n + 1, 1, 1)
Dislin.height (50)
Dislin.title ()
Dislin.disfin ()
END
Surface Plot / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 50
DIM AS SINGLE zmat(n,n)
DIM AS SINGLE x, y, stp, fpi
DIM AS INTEGER i, j
fpi = 3.1415926 / 180
stp = 360.0f / n
FOR i = 0 TO n
x = i * stp
FOR j = 0 TO n
y = j * stp
zmat (i,j) = 2 * sin (x * fpi) * sin (y * fpi)
NEXT j
NEXT i
Dislin.scrmod ("revers")
Dislin.metafl ("xwin")
Dislin.setpag ("da4p")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.titlin ("Surface Plot of the Function", 2)
Dislin.titlin ("F(X,Y) = 2 * SIN(X) * SIN(Y)", 4)
Dislin.axspos (200, 2600)
Dislin.axslen (1800, 1800)
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.name ("Z-axis", "Z")
Dislin.view3d (-5.0, -5.0, 4.0, "ABS")
Dislin.graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0, _
-3.0, 3.0, -3.0, 1.0)
Dislin.height (50)
Dislin.title ()
Dislin.color ("green")
Dislin.surmat (@zmat(0,0), n + 1, n + 1, 1, 1)
Dislin.disfin ()
END
Shaded Surface Plot / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 50
DIM AS SINGLE zmat(n,n)
DIM AS SINGLE xray(n), yray (n)
DIM AS SINGLE x, y, stp, fpi
DIM AS INTEGER i, j
fpi = 3.1415926 / 180
stp = 360.0f / n
FOR i = 0 TO n
x = i * stp
xray(i) = x
FOR j = 0 TO n
y = j * stp
yray(j) = y
zmat (i,j) = 2 * sin (x * fpi) * sin (y * fpi)
NEXT j
NEXT i
Dislin.metafl ("xwin")
Dislin.setpag ("da4p")
Dislin.scrmod ("revers")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.titlin ("Shaded Surface Plot", 2)
Dislin.titlin ("F(X,Y) = 2 * SIN(X) * SIN(Y)", 4)
Dislin.axspos (200, 2600)
Dislin.axslen (1800, 1800)
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.name ("Z-axis", "Z")
Dislin.view3d (-5.0, -5.0, 4.0, "ABS")
Dislin.graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0, _
-3.0, 3.0, -3.0, 1.0)
Dislin.height (50)
Dislin.title ()
Dislin.shdmod ("smooth", "surface")
Dislin.surshd (@xray(0), n + 1, @yray(0), n + 1, @zmat(0,0))
Dislin.disfin ()
END
Contour Plot / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 60, m = 50
DIM AS SINGLE xray(n), yray(m),zmat(n,m)
DIM AS STRING ctit1 = "Contour Plot"
DIM AS STRING ctit2 = "F(X,Y) = 2 * SIN(X) * SIN (Y)"
DIM AS SINGLE fpi, stpx, stpy, zlev
DIM AS INTEGER i, j
fpi = 3.1415927 / 180.0
stpx = 360.0 / n
stpy = 360.0 / m
FOR i = 0 TO n
xray(i) = i * stpx
FOR j = 0 TO m
yray(j) = j * stpy
zmat(i,j) = 2 * sin(xray(i) * fpi) * sin(yray(j) * fpi)
NEXT j
NEXT i
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.setpag ("da4p")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.titlin (ctit1, 2)
Dislin.titlin (ctit2, 4)
Dislin.axspos (450, 2670)
Dislin.intax ()
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.graf (0., 360., 0., 90., 0., 360., 0., 90.)
Dislin.height (30)
FOR i = 0 TO 8
zlev = -2. + i * 0.5
IF i = 4 THEN
Dislin.labels ("NONE", "CONTUR")
ELSE
Dislin.labels ("FLOAT", "CONTUR")
END IF
Dislin.setclr ((i+1) * 28)
Dislin.contur (@xray(0), n + 1, @yray(0), m + 1, @zmat(0,0), zlev)
NEXT i
Dislin.color ("FORE")
Dislin.height (50)
Dislin.title ()
Dislin.disfin ()
END
Shaded Contour Plot / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 50, m = 80
DIM AS STRING ctit1 = "Shaded Contour Plot"
DIM AS STRING ctit2 = "F(X,Y) = (X[2$ - 1)[2$ + (Y[2$ - 1)[2$"
DIM AS SINGLE xray(n), yray(m), zmat(n,m), zlev(11)
DIM AS SINGLE stpx, stpy, x, x2, y, y2
DIM AS INTEGER i, j
stpx = 1.6 / n
stpy = 1.6 / n
FOR i = 0 TO n
xray(i) = i * stpx
x = xray(i) * xray(i) - 1.0
x2 = x * x
FOR j = 0 TO m
yray(j) = j * stpy
y = yray(j) * yray(j) - 1.0
y2 = y * y
zmat(i,j) = x2 + y2
NEXT j
NEXT i
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.setpag ("da4p")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.mixalf ()
Dislin.titlin (ctit1, 1)
Dislin.titlin (ctit2, 3)
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.axspos (450, 2670)
Dislin.shdmod ("poly", "contur")
Dislin.graf (0., 1.6, 0., 0.2, 0., 1.6, 0., 0.2)
FOR i = 0 TO 11
zlev(11-i) = 0.1 + i * 0.1
NEXT i
Dislin.conshd (@xray(0), n + 1, @yray(0), m + 1, @zmat(0,0), @zlev(0), 12)
Dislin.height (50)
Dislin.title ()
Dislin.disfin ()
END
Shaded Surface / Contour Plot / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER n = 50, m = 50, nlev = 19
DIM AS SINGLE x(n), y(m), zmat(n,m), zlev (nlev)
DIM AS STRING ctit1 = "Shaded Surface / Contour Plot"
DIM AS STRING ctit2 = "F(X,Y) = 2 * SIN(X) * SIN (Y)"
DIM AS SINGLE fpi, stpx, stpy, stp
DIM AS INTEGER i, j
fpi = 3.1415927 / 180.0
stpx = 360.0 / n
stpy = 360.0 / m
FOR i = 0 TO n
x(i) = i * stpx
FOR j = 0 TO m
y(j) = j * stpy
zmat(i,j) = 2 * sin(x(i) * fpi) * sin(y(j) * fpi)
NEXT j
NEXT i
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.setpag ("da4p")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.titlin (ctit1, 2)
Dislin.titlin (ctit2, 4)
Dislin.axspos (200, 2600)
Dislin.axslen (1800, 1800)
Dislin.name ("X-axis", "X")
Dislin.name ("Y-axis", "Y")
Dislin.name ("Z-axis", "Z")
Dislin.graf3d (0., 360., 0., 90., 0., 360., 0., 90., _
-2., 2., -2., 1.)
Dislin.height (50)
Dislin.title ()
Dislin.grfini (-1., -1., -1., 1., -1., -1., 1., 1., -1.)
Dislin.nograf ()
Dislin.graf (0., 360., 0., 90., 0., 360., 0., 90.)
stp = 4.0 / nlev
FOR i = 0 TO nlev
zlev(i) = -2.0 + i * stp
NEXT i
Dislin.conshd (@x(0), n + 1, @y(0), m + 1, @zmat(0,0), @zlev(0), nlev + 1)
Dislin.box2d ()
Dislin.reset ("nograf")
Dislin.grffin ()
Dislin.shdmod ("smooth", "surface")
Dislin.surshd (@x(0), n + 1, @y(0), m + 1, @zmat(0,0))
Dislin.disfin ()
END
Spheres and Tubes / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS SINGLE x(16) = {10., 20., 10., 20., 5., 15., 25., 5., 15., 25., _
5., 15., 25., 10., 20., 10., 20.}
DIM AS SINGLE y(16) = {10., 10., 20., 20., 5., 5., 5., 15., 15., 15., _
25., 25., 25., 10., 10., 20., 20.}
DIM AS SINGLE z(16) = {5., 5., 5., 5., 15., 15., 15., 15., 15., 15., _
15., 15., 15., 25., 25., 25., 25.}
DIM AS INTEGER idx(55) = {1, 2, 1, 3, 3, 4, 2, 4, 5, 6, 6, 7, 8, 9, 9, 10, _
11, 12, 12, 13, 5, 8, 8, 11, 6, 9, 9, 12, 7, 10, _
10, 13, 14, 15, 16, 17, 14, 16, 15, 17, _
1, 5, 2, 7, 3, 11, 4, 13, 5, 14, 7, 15, 11, 16, 13, 17}
DIM AS INTEGER iret, i, j1, j2
Dislin.setpag ("da4p")
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.light ("on")
Dislin.matop3 (0.02, 0.02, 0.02, "specular")
Dislin.clip3d ("none")
Dislin.axspos (0, 2500)
Dislin.axslen (2100, 2100)
Dislin.htitle (50)
Dislin.titlin ("Spheres and Tubes", 4)
Dislin.name ("X-axis", "x")
Dislin.name ("Y-axis", "y")
Dislin.name ("Z-axis", "z")
Dislin.labdig (-1, "xyz")
Dislin.labl3d ("hori")
Dislin.graf3d (0., 30., 0., 5., 0., 30., 0., 5., 0., 30., 0., 5.)
Dislin.title ()
Dislin.shdmod ("smooth", "surface")
iret = Dislin.zbfini()
Dislin.matop3 (1.0, 0.0, 0.0, "diffuse")
FOR i = 0 TO 16
Dislin.sphe3d (x(i), y(i), z(i), 2.0, 50, 25)
NEXT i
Dislin.matop3 (0.0, 1.0, 0.0, "diffuse")
FOR i = 0 TO 55 STEP 2
j1 = idx(i) - 1
j2 = idx(i+1) - 1
Dislin.tube3d (x(j1), y(j1), z(j1), _
x(j2), y(j2), z(j2), 0.5, 5, 5)
NEXT i
Dislin.zbffin ()
Dislin.disfin ()
END
Some Solids / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS INTEGER iret
Dislin.setpag ("da4p")
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.disini ()
Dislin.pagera ()
Dislin.hwfont ()
Dislin.light ("on")
Dislin.litop3(1,0.5,0.5,0.5,"ambient")
Dislin.clip3d ("none")
Dislin.axspos (0, 2500)
Dislin.axslen (2100, 2100)
Dislin.htitle (60)
Dislin.titlin ("Some Solids", 4)
Dislin.nograf ()
Dislin.graf3d (-5., 5., -5., 2., -5., 5., -5., 2., -5., 5., -5., 2.)
Dislin.title ()
Dislin.shdmod ("smooth", "surface")
iret = Dislin.zbfini()
Dislin.matop3 (1.0, 0.5, 0.0, "diffuse")
Dislin.tube3d (-3., -3., 8.0, 2., 3., 5.5, 1., 40, 20)
Dislin.rot3d (-60., 0., 0.)
Dislin.matop3 (1.0, 0.0, 1.0, "diffuse")
Dislin.setfce ("bottom")
Dislin.matop3 (1.0, 0.0, 0.0, "diffuse")
Dislin.cone3d (-3., -3., 3.5, 2., 3., 3., 40, 20)
Dislin.setfce ("top")
Dislin.rot3d (0., 0., 0.)
Dislin.matop3 (0.0, 1.0, 1.0, "diffuse")
Dislin.plat3d (4., 4., 3., 3., "icos")
Dislin.rot3d (0., 0., 0.)
Dislin.matop3 (1.0, 1.0, 0.0, "diffuse")
Dislin.sphe3d (0., 0., 0., 3., 40, 20)
Dislin.rot3d (0., 0., -20.)
Dislin.matop3 (0.0, 0.0, 1.0, "diffuse")
Dislin.quad3d (-4., -4., -3., 3., 3., 3.)
Dislin.rot3d (0., 0., 30.)
Dislin.matop3 (1.0, 0.3, 0.3, "diffuse")
Dislin.pyra3d (-2., -5., -10., 3., 5., 5., 4)
Dislin.rot3d (0., 0., 0.)
Dislin.matop3 (1.0, 0.0, 0.0, "diffuse")
Dislin.torus3d (7., -3., -2., 1.5, 3.5, 1.5, 0., 360., 40, 20)
Dislin.rot3d (0., 90., 0.)
Dislin.matop3 (0.0, 1.0, 0.0, "diffuse")
Dislin.torus3d (7., -5., -2., 1.5, 3.5, 1.5, 0., 360., 40, 20)
Dislin.zbffin ()
Dislin.disfin ()
END
Map Plot / FreeBASIC
#INCLUDE "dislin.bi"
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.axspos (400, 1850)
Dislin.axslen (2400, 1400)
Dislin.name ("Longitude", "X")
Dislin.name ("Latitude", "Y")
Dislin.titlin ("World Coastlines and Lakes", 3)
Dislin.labels ("MAP", "XY")
Dislin.labdig (-1, "XY")
Dislin.grafmp (-180.0, 180.0, -180.0, 90.0, _
-90.0, 90.0, -90.0, 30.0)
Dislin.gridmp (1,1)
Dislin.color ("green")
Dislin.world ()
Dislin.color ("fore")
Dislin.height (50)
Dislin.title ()
Dislin.disfin ()
END
TeX Instructions for Mathematical Formulas / FreeBASIC
#INCLUDE "dislin.bi"
DIM AS STRING cstr
DIM AS INTEGER nl
Dislin.setpag ("da4p")
Dislin.scrmod ("revers")
Dislin.metafl ("cons")
Dislin.disini ()
Dislin.pagera ()
Dislin.complx ()
Dislin.height (40)
cstr = "TeX Instructions for Mathematical Formulas"
nl = Dislin.nlmess (cstr)
Dislin.messag (cstr, (2100 - nl)/2, 100)
Dislin.texmod ("on")
Dislin.messag ("$\frac{1}{x+y}$", 150, 400)
Dislin.messag ("$\frac{a^2 - b^2}{a+b} = a - b$", 1200, 400)
Dislin.messag ("$r = \sqrt{x^2 + y^2}$", 150, 700)
Dislin.messag ("$\cos \phi = \frac{x}{\sqrt{x^2 + y^2}}$", 1200, 700)
Dislin.messag ("$\Gamma(x) = \int_0^\infty e^{-t}t^{x-1}dt$", 150, 1000)
Dislin.messag ("$\lim_{x \to \infty} (1 + \frac{1}{x})^x = e$", _
1200, 1000)
Dislin.messag ("$\mu = \sum_{i=1}^n x_i p_i$", 150, 1300)
Dislin.messag ("$\mu = \int_{-\infty}^ \infty x f(x) dx$", 1200, 1300)
Dislin.messag ("$\overline{x} = \frac{1}{n} \sum_{i=1}^n x_i$", 150, 1600)
Dislin.messag ("$s^2 = \frac{1}{n-1} \sum_{i=1}^n (x_i - \overline{x})^2$", _
1200, 1600)
Dislin.messag ("$\sqrt[n]{\frac{x^n - y^n}{1 + u^{2n}}}$", 150, 1900)
Dislin.messag ("$\sqrt[3]{-q + \sqrt{q^2 + p^3}}", 1200, 1900)
Dislin.messag ("$\int \frac{dx}{1+x^2} = \arctan x + C$", 150, 2200)
Dislin.messag ("$\int \frac{dx}{\sqrt{1+x^2}} = {\rm arsinh} x + C", _
1200, 2200)
Dislin.messag ("$\overline{P_1P_2} = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$", _
150,2500)
Dislin.messag ("$x = \frac{x_1 + \lambda x_2}{1 + \lambda}$", 1200, 2500)
Dislin.disfin ()