DISLIN Examples / Rust
Demonstration of CURVE / Rust
pub mod dislin;
fn main () {
unsafe {
const N: usize = 101;
let f = 3.1415926 / 180.0;
let mut x: [f64; N] = [0.0; N];
let mut y1: [f64; N] = [0.0; N];
let mut y2: [f64; N] = [0.0; N];
for i in 0_usize..N {
x[i] = i as f64 * 3.6;
let v = i as f64 * 3.6 * f;
y1[i] = f64::sin (v);
y2[i] = f64::cos (v);
}
dislin::scrmod ("reverse");
dislin::metafl ("xwin");
dislin::disini ();
dislin::hwfont ();
dislin::pagera ();
dislin::axspos (450, 1800);
dislin::axslen (2200, 1200);
dislin::name ("X-axis", "X");
dislin::name ("Y-axis", "Y");
dislin::labdig (-1, "X");
dislin::ticks (9, "X");
dislin::ticks (10, "Y");
dislin::titlin ("Demonstration of CURVE", 1);
dislin::titlin ("SIN (X), COS (X)", 3);
let 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 (x.as_ptr (), y1.as_ptr (), N as i32);
dislin::color ("green");
dislin::curve (x.as_ptr (), y2.as_ptr (), N as i32);
dislin::disfin ();
}
}
Polar Plots / Rust
pub mod dislin;
fn main () {
unsafe {
const N: usize = 300;
const M: usize = 10;
let f = 3.1415927/180.0;
let mut x1: [f64; N] = [0.0; N];
let mut y1: [f64; N] = [0.0; N];
let mut x2: [f64; M] = [0.0; M];
let mut y2: [f64; M] = [0.0; M];
let step = 360.0 / (N as f64 - 1.0);
for i in 0_usize..N {
let a = (i as f64 * step) * f;
y1[i] = a;
x1[i] = f64::sin (5.0 * a);
}
for i in 0_usize..M {
x2[i] = i as f64 + 1.0;
y2[i] = i as f64 + 1.0;
}
dislin::setpag ("da4p");
dislin::metafl ("cons");
dislin::scrmod ("reverse");
dislin::disini ();
dislin::hwfont ();
dislin::pagera ();
dislin::axspos (450,1800);
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);
let 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.as_ptr(), y1.as_ptr(), N as i32);
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.as_ptr(), y2.as_ptr(), M as i32);
dislin::disfin ();
}
}
Symbols / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit = "Symbols";
dislin::setpag ("da4p");
dislin::scrmod ("reverse");
dislin::metafl ("cons");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
dislin::height (60);
let nl = dislin::nlmess (ctit);
dislin::messag (ctit, (2100 - nl)/2, 200);
dislin::height (50);
dislin::hsymbl (120);
let mut ny = 150;
let mut nxp = 550;
for i in 0..24 {
if (i % 4) == 0 {
ny = ny + 400;
nxp = 550;
}
else {
nxp = nxp + 350;
}
let nl = dislin::nlnumb (i as f64, -1);
dislin::number (i as f64, -1, nxp - nl/2, ny + 150);
dislin::symbol (i, nxp, ny);
}
dislin::disfin ();
}
}
Interpolation Methods / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit = "Interpolation Methods";
let xray: [f64; 16] = [0., 1., 3., 4.5, 6., 8., 9., 11., 12., 12.5,
13., 15., 16., 17., 19., 20.];
let yray: [f64; 16] = [2., 4., 4.5, 3., 1., 7., 2., 3., 5., 2., 2.5,
2., 4., 6., 5.5, 4.];
let cpol: [&str; 6] = ["SPLINE", "STEM", "BARS", "STAIRS", "STEP",
"LINEAR"];
dislin::setpag ("da4p");
dislin::metafl ("cons");
dislin::scrmod ("reverse");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
dislin::incmrk (1);
dislin::hsymbl (25);
dislin::titlin (ctit, 2);
dislin::axslen (1500, 350);
dislin::setgrf ("line", "line", "line", "line");
let ic = dislin::intrgb (1.0, 1.0, 0.0);
dislin::axsbgd (ic);
let nya = 2700;
for i in 0..6 {
dislin::axspos (350, nya - i * 350);
dislin::polcrv (cpol[i as usize]);
dislin::marker (16);
dislin::graf (0.0, 20.0, 0.0, 5.0, 0.0, 10.0, 0.0, 5.0);
let nx = dislin::nxposn (1.0);
let ny = dislin::nyposn (8.0);
dislin::messag (cpol[i as usize], nx, ny);
dislin::color ("red");
dislin::curve (xray.as_ptr(), yray.as_ptr(), 16);
dislin::color ("fore");
if i == 5 {
dislin::height (50);
dislin::title ();
}
dislin::endgrf ();
}
dislin::disfin ();
}
}
Bar Graphs / Rust
pub mod dislin;
fn main () {
unsafe {
let mut x: [f64; 9] = [1., 2., 3., 4., 5., 6., 7., 8., 9.];
let mut y: [f64; 9] = [0., 0., 0., 0., 0., 0., 0., 0., 0.];
let mut y1: [f64; 9] = [1., 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1];
let mut y2: [f64; 9] = [2., 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8];
let mut y3: [f64; 9] = [4., 3.5, 4.5, 3.7, 4., 2.9, 3.0, 3.2, 2.6];
let nya = 2700;
let ctit = "Bar Graphs (BARS)";
dislin::scrmod ("reverse");
dislin::setpag ("da4p");
dislin::metafl ("cons");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
dislin::ticks (1, "x");
dislin::intax ();
dislin::axslen (1600, 700);
dislin::titlin (ctit, 3);
let mut cbuf = [0_u8; 24];
dislin::legini (cbuf.as_mut_ptr(), 3, 8);
dislin::leglin (cbuf.as_mut_ptr(), "FIRST", 1);
dislin::leglin (cbuf.as_mut_ptr(), "SECOND", 2);
dislin::leglin (cbuf.as_mut_ptr(), "THIRD", 3);
dislin::legtit (" ");
dislin::shdpat (5);
for i in 0..3 {
if i > 0 {
dislin::labels ("none", "X");
}
dislin::axspos (300, nya - i * 800);
dislin::graf (0., 10., 0., 1., 0., 5., 0., 1.);
if i == 0 {
dislin::bargrp (3, 0.15);
dislin::color ("red");
dislin::bars (x.as_mut_ptr(), y.as_mut_ptr(), y1.as_mut_ptr(), 9);
dislin::color ("green");
dislin::bars (x.as_mut_ptr(), y.as_mut_ptr(), y2.as_mut_ptr(), 9);
dislin::color ("blue");
dislin::bars (x.as_mut_ptr(), y.as_mut_ptr(), y3.as_mut_ptr(), 9);
dislin::color ("fore");
dislin::reset ("bargrp");
}
else if i == 1 {
dislin::height (30);
dislin::labels ("delta", "bars");
dislin::labpos ("center", "bars");
dislin::color ("red");
dislin::bars (x.as_mut_ptr(), y.as_mut_ptr(), y1.as_mut_ptr(), 9);
dislin::color ("green");
dislin::bars (x.as_mut_ptr(), y1.as_mut_ptr(), y2.as_mut_ptr(), 9);
dislin::color ("blue");
dislin::bars (x.as_mut_ptr(), y2.as_mut_ptr(), y3.as_mut_ptr(), 9);
dislin::color ("fore");
dislin::reset ("height");
}
else if i == 2 {
dislin::labels ("second", "bars");
dislin::labpos ("outside", "bars");
dislin::color ("red");
dislin::bars (x.as_mut_ptr(), y.as_mut_ptr(), y1.as_mut_ptr(), 9);
dislin::color ("fore");
}
if i != 2 {
dislin::legend (cbuf.as_mut_ptr(), 7);
}
if i == 2 {
dislin::height (50);
dislin::title ();
}
dislin::endgrf ();
}
dislin::disfin ();
}
}
Pie Charts / Rust
pub mod dislin;
fn main () {
unsafe {
let xray: [f64; 5] = [1., 2.5, 2., 2.7, 1.8];
let ctit = "Pie Charts (PIEGRF)";
dislin::scrmod ("reverse");
dislin::setpag ("da4p");
dislin::metafl ("cons");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
dislin::chnpie ("both");
dislin::axslen (1600, 1000);
dislin::titlin (ctit, 2);
let mut cbuf = [0_u8; 40];
dislin::legini (cbuf.as_mut_ptr(), 5, 8);
dislin::leglin (cbuf.as_mut_ptr(), "FIRST", 1);
dislin::leglin (cbuf.as_mut_ptr(), "SECOND", 2);
dislin::leglin (cbuf.as_mut_ptr(), "THIRD", 3);
dislin::leglin (cbuf.as_mut_ptr(), "FOURTH", 4);
dislin::leglin (cbuf.as_mut_ptr(), "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.as_mut_ptr(), 1, xray.as_ptr(), 5);
dislin::endgrf ();
dislin::axspos (250, 1600);
dislin::labels ("data", "pie");
dislin::labpos ("external", "pie");
dislin::piegrf (cbuf.as_mut_ptr(), 1, xray.as_ptr(), 5);
dislin::height (50);
dislin::title ();
dislin::disfin ();
}
}
3-D Bar Graph / 3-D Pie Chart / Rust
pub mod dislin;
fn main () {
unsafe {
let mut xray : [f64; 5] = [2., 4., 6., 8., 10.];
let mut y1ray : [f64; 5] = [0., 0., 0., 0., 0.];
let mut y2ray : [f64; 5] = [3.2, 1.5, 2.0, 1.0, 3.0];
let ic1ray: [i32; 5] = [50, 150, 100, 200, 175];
let ic2ray: [i32; 5] = [50, 150, 100, 200, 175];
dislin::scrmod ("reverse");
dislin::metafl ("cons");
dislin::setpag ("da4p");
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.0, 12.0, 0.0, 2.0, 0.0, 5.0, 0.0, 1.0);
dislin::title ();
dislin::color ("red");
dislin::bars (xray.as_mut_ptr(), y1ray.as_mut_ptr(),
y2ray.as_mut_ptr(), 5);
dislin::endgrf ();
dislin::shdpat (16);
dislin::labels ("data", "pie");
dislin::labclr (255, "pie");
dislin::chnpie ("none");
dislin::pieclr (ic1ray.as_ptr(), ic2ray.as_ptr(), 5);
dislin::pietyp ("3d");
dislin::axspos (300, 2700);
let mut cbuf = [0_u8; 1];
dislin::piegrf (cbuf.as_mut_ptr(), 0, y2ray.as_ptr(), 5);
dislin::disfin ();
}
}
3-D Bars / BARS3D / Rust
pub mod dislin;
fn main () {
unsafe {
const N: usize = 18;
let xray : [f64; N] = [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];
let yray : [f64; N] = [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];
let z1ray: [f64; N] = [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0.];
let z2ray: [f64; N] = [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];
let icray: [i32; N] = [30, 30, 30, 30, 30, 30, 100, 100, 100, 100,
100, 100, 170, 170, 170, 170, 170, 170];
let xwray: [f64; N] = [0.5; N];
let ywray: [f64; N] = [0.5; N];
dislin::scrmod ("reverse");
dislin::metafl ("cons");
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.as_ptr(), yray.as_ptr(), z1ray.as_ptr(),
z2ray.as_ptr(), xwray.as_ptr(), ywray.as_ptr(),
icray.as_ptr(), N as i32);
let mut cbuf = [0_u8; 60];
dislin::legini (cbuf.as_mut_ptr(), 3, 20);
dislin::legtit (" ");
dislin::legpos (1350, 1150);
dislin::leglin (cbuf.as_mut_ptr(), "First", 1);
dislin::leglin (cbuf.as_mut_ptr(), "Second", 2);
dislin::leglin (cbuf.as_mut_ptr(), "Third", 3);
dislin::legend (cbuf.as_ptr(), 3);
dislin::height (50);
dislin::title ();
dislin::disfin ();
}
}
Shading Patterns / Rust
pub mod dislin;
fn main () {
unsafe {
let ix: [i32; 4] = [0, 300, 300, 0];
let iy: [i32; 4] = [0, 0, 400, 400];
let mut ixp: [i32; 4] = [0, 0, 0, 0];
let mut iyp: [i32; 4] = [0, 0, 0, 0];
let ctit = "Shading Patterns (AREAF)";
dislin::scrmod ("reverse");
dislin::metafl ("cons");
dislin::disini ();
dislin::setvlt ("small");
dislin::pagera ();
dislin::hwfont ();
dislin::height (50);
let mut nl = dislin::nlmess (ctit);
dislin::messag (ctit, (2970 - nl)/2, 200);
let nx0 = 335;
let ny0 = 350;
let mut iclr = 0;
for i in 0..3 {
let ny = ny0 + i * 600;
for j in 0..6 {
let mut nx = nx0 + j * 400;
let ii = i * 6 + j;
dislin::shdpat (ii);
iclr = iclr % 8;
iclr = iclr + 1;
dislin::setclr (iclr);
for k in 0..4 {
ixp[k] = ix[k] + nx;
iyp[k] = iy[k] + ny;
}
dislin::areaf (ixp.as_ptr(), iyp.as_ptr(), 4);
nl = dislin::nlnumb (ii as f64, -1);
nx = nx + (300 - nl) / 2;
dislin::number (ii as f64, -1, nx, ny + 460);
}
}
dislin::disfin ();
}
}
3-D Colour Plot / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit1 = "3-D Colour Plot of the Function";
let ctit2 = "F(X,Y) = 2 * SIN(X) * SIN (Y)";
const N: usize = 100;
const M: usize = 100;
let mut zmat: [f64; N*M] = [0.0; N*M];
let fpi = 3.1415927 / 180.0;
let stepx = 360.0 / (N as f64 - 1.0);
let stepy = 360.0 / (M as f64 - 1.0);
for i in 0..N {
let x = i as f64 * stepx;
for j in 0..M {
let y = j as f64 * stepy;
zmat[i*M+j] = 2.0 * f64::sin(x * fpi) * f64::sin(y * fpi);
}
}
dislin::scrmod ("reverse");
dislin::metafl ("cons");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
dislin::titlin (ctit1, 2);
dislin::titlin (ctit2, 4);
dislin::name ("X-axis", "X");
dislin::name ("Y-axis", "Y");
dislin::name ("Z-axis", "Z");
dislin::intax ();
dislin::autres (N as i32, M as i32);
dislin::axspos (300, 1850);
dislin::ax3len (2200, 1400, 1400);
dislin::graf3 (0., 360., 0., 90., 0., 360., 0., 90.,
-2., 2., -2., 1.);
dislin::crvmat (zmat.as_ptr(), N as i32, M as i32, 1, 1);
dislin::height (50);
dislin::title ();
dislin::disfin ();
}
}
Surface Plot / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit1 = "Surface Plot of the Function";
let ctit2 = "F(X,Y) = 2 * SIN(X) * SIN (Y)";
const N: usize = 50;
const M: usize = 50;
let mut zmat: [f64; N*M] = [0.0; N*M];
let fpi = 3.1415927 / 180.0;
let stepx = 360.0 / (N as f64 - 1.0);
let stepy = 360.0 / (M as f64 - 1.0);
for i in 0..N {
let x = i as f64 * stepx;
for j in 0..M {
let y = j as f64 * stepy;
zmat[i*M+j] = 2.0 * f64::sin(x * fpi) * f64::sin(y * fpi);
}
}
dislin::scrmod ("reverse");
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::view3d (-5., -5., 4., "ABS");
dislin::graf3d (0., 360., 0., 90., 0., 360., 0., 90.,
-3., 3., -3., 1.);
dislin::height (50);
dislin::title ();
dislin::color ("green");
dislin::surmat (zmat.as_ptr(), N as i32, M as i32, 1, 1);
dislin::disfin ();
}
}
Shaded Surface Plot / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit1 = "Shaded Surface Plot";
let ctit2 = "F(X,Y) = 2*SIN(X)*SIN(Y)";
const N: usize = 50;
const M: usize = 50;
let mut xray: [f64; N] = [0.0; N];
let mut yray: [f64; M] = [0.0; M];
let mut zmat: [f64; N*M] = [0.0; N*M];
let fpi = 3.1415927 / 180.0;
let stepx = 360.0 / (N as f64 - 1.0);
let stepy = 360.0 / (M as f64 - 1.0);
for i in 0..N {
let x = i as f64 * stepx;
xray[i] = x;
for j in 0..M {
let y = j as f64 * stepy;
yray[j] = y;
zmat[i*M+j] = 2.0 * f64::sin(x * fpi) * f64::sin(y * fpi);
}
}
dislin::scrmod ("reverse");
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::view3d (-5., -5., 4., "abs");
dislin::graf3d (0., 360., 0., 90., 0., 360., 0., 90.,
-3., 3., -3., 1.);
dislin::height (50);
dislin::title ();
dislin::shdmod ("smooth", "surface");
dislin::surshd (xray.as_ptr(), N as i32, yray.as_ptr(), M as i32,
zmat.as_ptr());
dislin::disfin ();
}
}
Contour Plot / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit1 = "Contour Plot";
let ctit2 = "F(X,Y) = 2 * SIN(X) * SIN (Y)";
const N: usize = 50;
const M: usize = 50;
let mut xray: [f64; N] = [0.0; N];
let mut yray: [f64; M] = [0.0; M];
let mut zmat: [f64; N*M] = [0.0; N*M];
let fpi = 3.1415927 / 180.0;
let stepx = 360.0 / (N as f64 - 1.0);
let stepy = 360.0 / (M as f64 - 1.0);
for i in 0..N {
xray[i] = i as f64 * stepx;
}
for i in 0..M {
yray[i] = i as f64 * stepy;
}
for i in 0..N {
let x = xray[i] * fpi;
for j in 0..M {
let y = yray[j] * fpi;
zmat[i*M+j] = 2.0 * f64::sin(x) * f64::sin(y);
}
}
dislin::scrmod ("reverse");
dislin::metafl ("cons");
dislin::setpag ("da4p");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
dislin::titlin (ctit1, 1);
dislin::titlin (ctit2, 3);
dislin::intax ();
dislin::axspos (450, 2650);
dislin::name ("X-axis", "x");
dislin::name ("Y-axis", "y");
dislin::graf (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0);
dislin::height (50);
dislin::title ();
dislin::height (30);
for i in 0..9 {
let zlev = -2.0 + i as f64 * 0.5;
if i == 4 {
dislin::labels ("none", "contur");
}
else {
dislin::labels ("float", "contur");
}
dislin::setclr ((i as i32 + 1) * 28);
dislin::contur (xray.as_ptr(), N as i32, yray.as_ptr(), M as i32,
zmat.as_ptr(), zlev);
}
dislin::disfin ();
}
}
Shaded Contour Plot / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit1 = "Shaded Contour Plot";
let ctit2 = "F(X,Y) = (X[2$ - 1)[2$ + (Y[2$ - 1)[2$";
const N: usize = 50;
const M: usize = 50;
let mut xray: [f64; N] = [0.0; N];
let mut yray: [f64; M] = [0.0; M];
let mut zmat: [f64; N*M] = [0.0; N*M];
let mut zlev: [f64; 12] = [0.0; 12];
let stepx = 1.6 / (N as f64 - 1.0);
let stepy = 1.6 / (M as f64 - 1.0);
for i in 0..N {
xray[i] = i as f64 * stepx;
}
for i in 0..M {
yray[i] = i as f64 * stepy;
}
for i in 0..N {
let x = xray[i] * xray[i] - 1.0;
let x2 = x * x;
for j in 0..M {
let y = yray[j] * yray[j] - 1.0;
zmat[i*M+j] = x2 + y * y
}
}
dislin::scrmod ("reverse");
dislin::metafl ("cons");
dislin::setpag ("da4p");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
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 in 0..12 {
zlev[11-i] = 0.1 + i as f64 * 0.1;
dislin::conshd (xray.as_ptr(), N as i32, yray.as_ptr(), M as i32,
zmat.as_ptr(), zlev.as_ptr(), 12);
}
dislin::height (50);
dislin::title ();
dislin::disfin ();
}
}
Shaded Surface / Contour Plot / Rust
pub mod dislin;
fn main () {
unsafe {
let ctit1 = "Shaded Surface / Contour Plot";
let ctit2 = "F(X,Y) = 2 * SIN(X) * SIN (Y)";
const N: usize = 50;
const M: usize = 50;
const NLEV: usize = 20;
let mut xray: [f64; N] = [0.0; N];
let mut yray: [f64; M] = [0.0; M];
let mut zmat: [f64; N*M] = [0.0; N*M];
let mut zlev: [f64; NLEV] = [0.0; NLEV];
let fpi = 3.1415927 / 180.0;
let stepx = 360.0 / (N as f64 - 1.0);
let stepy = 360.0 / (M as f64 - 1.0);
for i in 0..N {
let x = i as f64 * stepx;
xray[i] = x;
for j in 0..M {
let y = j as f64 * stepy;
yray[j] = y;
zmat[i*M+j] = 2.0 * f64::sin(x * fpi) * f64::sin(y * fpi);
}
}
dislin::scrmod ("reverse");
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.);
let step = 4.0 / NLEV as f64;
for i in 0..NLEV {
zlev[i] = -2.0 + i as f64 * step;
}
dislin::conshd (xray.as_ptr(), N as i32, yray.as_ptr(), M as i32,
zmat.as_ptr(), zlev.as_ptr(), NLEV as i32);
dislin::box2d ();
dislin::reset ("nograf");
dislin::grffin ();
dislin::shdmod ("smooth", "surface");
dislin::surshd (xray.as_ptr(), N as i32, yray.as_ptr(), M as i32,
zmat.as_ptr());
dislin::disfin ();
}
}
Spheres and Tubes / Rust
pub mod dislin;
fn main () {
unsafe {
let x: [f64; 17] = [10., 20., 10., 20., 5., 15., 25., 5., 15., 25.,
5., 15., 25., 10., 20., 10., 20.];
let y: [f64; 17] = [10., 10., 20., 20., 5., 5., 5., 15., 15., 15.,
25., 25., 25., 10., 10., 20., 20.];
let z: [f64; 17] = [5., 5., 5., 5., 15., 15., 15., 15., 15., 15.,
15., 15., 15., 25., 25., 25., 25.];
let idx: [usize; 56] = [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];
dislin::setpag ("da4p");
dislin::scrmod ("reverse");
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");
let _iret = dislin::zbfini();
dislin::matop3 (1.0, 0.0, 0.0, "diffuse");
for i in 0..17 {
dislin::sphe3d (x[i], y[i], z[i], 2.0, 50, 25);
}
dislin::matop3 (0.0, 1.0, 0.0, "diffuse");
for i in 0..28 {
let j = 2 * i;
let j1 = idx[j] - 1;
let j2 = idx[j+1] - 1;
dislin::tube3d (x[j1], y[j1], z[j1],
x[j2], y[j2], z[j2], 0.5, 5, 5);
}
dislin::zbffin ();
dislin::disfin ();
}
}
Some Solids / Rust
pub mod dislin;
fn main () {
unsafe {
dislin::setpag ("da4p");
dislin::scrmod ("reverse");
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");
let _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 ();
}
}
Map Plot / Rust
pub mod dislin;
fn main () {
unsafe {
dislin::scrmod ("reverse");
dislin::metafl ("cons");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
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::digits (-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 ("foreground");
dislin::height (50);
dislin::title ();
dislin::disfin ();
}
}
Tex Instructions for Mathematical Formulas / Rust
pub mod dislin;
fn main () {
unsafe {
dislin::metafl ("cons");
dislin::setpag ("da4p");
dislin::scrmod ("reverse");
dislin::disini ();
dislin::pagera ();
dislin::hwfont ();
dislin::height (40);
let cstr = "TeX Instructions for Mathematical Formulas";
let 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 ();
}
}
News
Update 11.6.1
21. Juni 2026
Release 11.6
30. April 2026
DISLIN-Handbuch als eBook von Amazon
5. April 2025
Support für OpenBSD 64-bit
17. Januar 2025
Support für Python 3.13 und Windows
17. Januar 2025
PDF-Handbuch der Version 11.5.2
8. Januar 2025
Update 11.5.2
8. April 2024
Support für Python 3.11 und Windows
28. Juli 2023
Bugfix für die X11-Distributionen
22. Juli 2023
Update 11.5.1
25. April 2023
21. Juni 2026
Release 11.6
30. April 2026
DISLIN-Handbuch als eBook von Amazon
5. April 2025
Support für OpenBSD 64-bit
17. Januar 2025
Support für Python 3.13 und Windows
17. Januar 2025
PDF-Handbuch der Version 11.5.2
8. Januar 2025
Update 11.5.2
8. April 2024
Support für Python 3.11 und Windows
28. Juli 2023
Bugfix für die X11-Distributionen
22. Juli 2023
Update 11.5.1
25. April 2023