Root/nanonote-files/example-files/data/Examples/lua-plplot-examples/x06.lua

1--[[ $Id: x06.lua 11032 2010-05-27 22:34:40Z andrewross $
2
3    Font demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27----------------------------------------------------------------------------
28-- main
29--
30-- Displays the entire "plpoin" symbol (font) set.
31----------------------------------------------------------------------------
32
33-- Parse and process command line arguments
34pl.parseopts(arg, pl.PL_PARSE_FULL)
35
36-- Initialize plplot
37pl.init()
38
39for kind_font = 0,1 do
40  pl.fontld( kind_font )
41  if kind_font == 0 then
42    maxfont = 1
43  else
44    maxfont = 4
45  end
46
47  for font = 1,maxfont do
48    pl.font( font )
49    pl.adv(0)
50
51    -- Set up viewport and window
52    pl.col0(2)
53    pl.vpor(0.1, 1, 0.1, 0.9)
54    pl.wind(0, 1, 0, 1.3)
55
56    -- Draw the grid using plbox
57    pl.box("bcg", 0.1, 0, "bcg", 0.1, 0)
58
59    -- Write the digits below the frame
60    pl.col0(15)
61    for i=0, 9 do
62      pl.mtex("b", 1.5, (0.1 * i + 0.05), 0.5, tostring(i))
63    end
64
65    k = 0
66    x = {}
67    y ={}
68    for i = 0, 12 do
69      -- Write the digits to the left of the frame
70      pl.mtex("lv", 1, (1 - (2 * i + 1) / 26), 1, tostring(10*i))
71      for j = 0, 9 do
72        x[1] = 0.1 * j + 0.05
73        y[1] = 1.25 - 0.1 * i
74
75        -- Display the symbols
76        if k < 128 then
77          pl.poin(x, y, k)
78        end
79        k = k + 1
80      end
81    end
82  
83    if kind_font == 0 then
84      pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (compact)")
85    else
86      pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (extended)")
87    end
88  end
89end
90pl.plend()
91

Archive Download this file



interactive