|
From: <sm...@us...> - 2009-01-19 09:22:30
|
Revision: 9343
http://plplot.svn.sourceforge.net/plplot/?rev=9343&view=rev
Author: smekal
Date: 2009-01-19 09:22:19 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
Added some Lua examples, some of them work, others are not finished porting at all
Added Paths:
-----------
trunk/examples/lua/
trunk/examples/lua/x01.lua
trunk/examples/lua/x05.lua
trunk/examples/lua/x09.lua
trunk/examples/lua/x10.lua
trunk/examples/lua/x11.lua
trunk/examples/lua/x12.lua
trunk/examples/lua/x13.lua
trunk/examples/lua/x19.lua
trunk/examples/lua/x24.lua
trunk/examples/lua/x25.lua
trunk/examples/lua/x30.lua
Added: trunk/examples/lua/x01.lua
===================================================================
--- trunk/examples/lua/x01.lua (rev 0)
+++ trunk/examples/lua/x01.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,349 @@
+--[[ $Id: $
+
+ Simple line plot and multiple windows demo.
+
+ Copyright (C) 2004 Rafael Laboissiere
+
+ This file is part of PLplot.
+
+ PLplot is free software you can redistribute it and/or modify
+ it under the terms of the GNU General Library Public License as published
+ by the Free Software Foundation either version 2 of the License, or
+ (at your option) any later version.
+
+ PLplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with PLplot if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+--]]
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+
+-- Variables and data arrays used by plot generators
+
+x = {}
+y = {}
+xs = {}
+ys = {}
+--PLGraphicsIn gin
+
+fontset = 1
+-- Options data structure definition.
+
+static PLOptionTable options[] = {
+{
+ "locate", -- Turns on test of API locate function
+ NULL,
+ NULL,
+ &locate_mode,
+ PL_OPT_BOOL,
+ "-locate",
+ "Turns on test of API locate function" },
+{
+ "xor", -- Turns on test of xor function
+ NULL,
+ NULL,
+ &test_xor,
+ PL_OPT_BOOL,
+ "-xor",
+ "Turns on test of XOR" },
+{
+ "font", -- For switching between font set 1 & 2
+ NULL,
+ NULL,
+ &fontset,
+ PL_OPT_INT,
+ "-font number",
+ "Selects stroke font set (0 or 1, def:1)" },
+{
+ "save", -- For saving in postscript
+ NULL,
+ NULL,
+ &f_name,
+ PL_OPT_STRING,
+ "-save filename",
+ "Save plot in color postscript `file'" },
+{
+ NULL, -- option
+ NULL, -- handler
+ NULL, -- client data
+ NULL, -- address of variable to set
+ 0, -- mode flag
+ NULL, -- short syntax
+ NULL } -- long syntax
+}
+
+const char *notes[] = {"Make sure you get it right!", NULL}
+
+-- Function prototypes
+
+void plot1(int)
+void plot2(void)
+void plot3(void)
+
+----------------------------------------------------------------------------
+-- main
+--
+-- Generates several simple line plots. Demonstrates:
+-- - subwindow capability
+-- - setting up the window, drawing plot, and labelling
+-- - changing the color
+-- - automatic axis rescaling to exponential notation
+-- - placing the axes in the middle of the box
+-- - gridded coordinate axes
+----------------------------------------------------------------------------
+
+-- plplot initialization
+
+-- Parse and process command line arguments
+
+-- plMergeOpts(options, "x01c options", notes)
+-- plparseopts(&argc, argv, PL_PARSE_FULL)
+
+-- Get version number, just for kicks
+
+pl.plgver(ver)
+print("PLplot library version: " .. ver)
+
+-- Initialize plplot
+-- Divide page into 2x2 plots
+-- Note: calling plstar replaces separate calls to plssub and plinit
+pl.plstar(2,2)
+
+-- Select font set as per input flag
+
+if fontset != 0 then
+ pl.plfontld(1)
+else
+ pl.plfontld(0)
+end
+
+-- Set up the data
+-- Original case
+
+ xscale = 6.
+ yscale = 1.
+ xoff = 0.
+ yoff = 0.
+
+-- Do a plot
+
+ plot1(0)
+
+-- Set up the data
+
+ xscale = 1.
+ yscale = 0.0014
+ yoff = 0.0185
+
+-- Do a plot
+
+ digmax = 5
+ plsyax(digmax, 0)
+
+ plot1(1)
+
+ plot2()
+
+ plot3()
+
+ --
+ * Show how to save a plot:
+ * Open a new device, make it current, copy parameters,
+ * and replay the plot buffer
+
+
+ if (f_name) { -- command line option '-save filename'
+
+ printf("The current plot was saved in color Postscript under the name `%s'.\n", f_name)
+ plgstrm(&cur_strm) -- get current stream
+ plmkstrm(&new_strm) -- create a new one
+
+ plsfnam(f_name) -- file name
+ plsdev("psc") -- device type
+
+ plcpstrm(cur_strm, 0) -- copy old stream parameters to new stream
+ plreplot() -- do the save by replaying the plot buffer
+ plend1() -- finish the device
+
+ plsstrm(cur_strm) -- return to previous stream
+ }
+
+-- Let's get some user input
+
+ if (locate_mode) {
+ for () {
+ if (! plGetCursor(&gin)) break
+ if (gin.keysym == PLK_Escape) break
+
+ pltext()
+ if (gin.keysym < 0xFF && isprint(gin.keysym))
+ printf("subwin = %d, wx = %f, wy = %f, dx = %f, dy = %f, c = '%c'\n",
+ gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY, gin.keysym)
+ else
+ printf("subwin = %d, wx = %f, wy = %f, dx = %f, dy = %f, c = 0x%02x\n",
+ gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY, gin.keysym)
+
+ plgra()
+ }
+ }
+
+ plclear()
+-- Don't forget to call plend() to finish off!
+
+ plend()
+ exit(0)
+}
+
+ -- ===============================================================
+
+void
+plot1(int do_test)
+{
+ int i
+ PLFLT xmin, xmax, ymin, ymax
+
+ for (i = 0 i < 60 i++) {
+ x[i] = xoff + xscale * (i + 1) / 60.0
+ y[i] = yoff + yscale * pow(x[i], 2.)
+ }
+
+ xmin = x[0]
+ xmax = x[59]
+ ymin = y[0]
+ ymax = y[59]
+
+ for (i = 0 i < 6 i++) {
+ xs[i] = x[i * 10 + 3]
+ ys[i] = y[i * 10 + 3]
+ }
+
+-- Set up the viewport and window using PLENV. The range in X is
+ * 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
+ * scaled separately (just = 0), and we just draw a labelled
+ * box (axis = 0).
+
+ plcol0(1)
+ plenv(xmin, xmax, ymin, ymax, 0, 0)
+ plcol0(2)
+ pllab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2")
+
+-- Plot the data points
+
+ plcol0(4)
+ plpoin(6, xs, ys, 9)
+
+-- Draw the line through the data
+
+ plcol0(3)
+ plline(60, x, y)
+
+-- xor mode enable erasing a line/point/text by replotting it again
+-- it does not work in double buffering mode, however
+
+ if (do_test && test_xor) {
+#ifdef PL_HAVE_USLEEP
+ PLINT st
+ plxormod(1, &st) -- enter xor mode
+ if (st) {
+ for (i=0 i<60 i++) {
+ plpoin(1, x+i, y+i,9) -- draw a point
+ usleep(50000) -- wait a little
+ plflush() -- force an update of the tk driver
+ plpoin(1, x+i, y+i,9) -- erase point
+ }
+ plxormod(0, &st) -- leave xor mode
+ }
+#else
+ printf("The -xor command line option can only be exercised if your "
+ "system\nhas usleep(), which does not seem to happen.\n")
+#endif
+ }
+}
+
+ -- ===============================================================
+
+void
+plot2(void)
+{
+ int i
+
+-- Set up the viewport and window using PLENV. The range in X is -2.0 to
+ * 10.0, and the range in Y is -0.4 to 2.0. The axes are scaled separately
+ * (just = 0), and we draw a box with axes (axis = 1).
+
+ plcol0(1)
+ plenv(-2.0, 10.0, -0.4, 1.2, 0, 1)
+ plcol0(2)
+ pllab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function")
+
+-- Fill up the arrays
+
+ for (i = 0 i < 100 i++) {
+ x[i] = (i - 19.0) / 6.0
+ y[i] = 1.0
+ if (x[i] != 0.0)
+ y[i] = sin(x[i]) / x[i]
+ }
+
+-- Draw the line
+
+ plcol0(3)
+ plwid(2)
+ plline(100, x, y)
+ plwid(1)
+}
+
+ -- ===============================================================
+
+void
+plot3(void)
+{
+ PLINT space0 = 0, mark0 = 0, space1 = 1500, mark1 = 1500
+ int i
+
+-- For the final graph we wish to override the default tick intervals, and
+ * so do not use plenv().
+
+ pladv(0)
+
+-- Use standard viewport, and define X range from 0 to 360 degrees, Y range
+ * from -1.2 to 1.2.
+
+ plvsta()
+ plwind(0.0, 360.0, -1.2, 1.2)
+
+-- Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.
+
+ plcol0(1)
+ plbox("bcnst", 60.0, 2, "bcnstv", 0.2, 2)
+
+-- Superimpose a dashed line grid, with 1.5 mm marks and spaces.
+ * plstyl expects a pointer!
+
+ plstyl(1, &mark1, &space1)
+ plcol0(2)
+ plbox("g", 30.0, 0, "g", 0.2, 0)
+ plstyl(0, &mark0, &space0)
+
+ plcol0(3)
+ pllab("Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function")
+
+ for (i = 0 i < 101 i++) {
+ x[i] = 3.6 * i
+ y[i] = sin(x[i] * M_PI / 180.0)
+ }
+
+ plcol0(4)
+ plline(101, x, y)
+}
Property changes on: trunk/examples/lua/x01.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x05.lua
===================================================================
--- trunk/examples/lua/x05.lua (rev 0)
+++ trunk/examples/lua/x05.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,41 @@
+-- $Id: $
+
+-- Histogram demo.
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+pl=plplotluac
+
+--------------------------------------------------------------------------
+-- main
+--
+-- Draws a histogram from sample data.
+--------------------------------------------------------------------------
+
+NPTS=2047
+data = {}
+
+-- Parse and process command line arguments
+-- (void) plparseopts(&argc, argv, PL_PARSE_FULL);
+
+-- Initialize plplot
+pl.plinit()
+
+-- Fill up data points
+delta = 2.0*math.pi/NPTS
+for i=1, NPTS do
+ data[i] = math.sin((i-1)*delta)
+end
+
+pl.plcol0(1)
+pl.plhist(data, -1.1, 1.1, 44, 0)
+pl.plcol0(2)
+pl.pllab("#frValue", "#frFrequency",
+ "#frPLplot Example 5 - Probability function of Oscillator")
+
+pl.plend()
Property changes on: trunk/examples/lua/x05.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x09.lua
===================================================================
--- trunk/examples/lua/x09.lua (rev 0)
+++ trunk/examples/lua/x09.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,451 @@
+/* $Id: x09c.c 9117 2008-12-15 12:45:13Z andrewross $
+
+ Contour plot demo.
+
+ This file is part of PLplot.
+
+ PLplot is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Library Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ PLplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with PLplot; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('plplotluac.dll','luaopen_plplotluac') or loadlib('plplotluac.so','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('example')
+end
+pl=plplotluac
+
+#define XPTS 35 /* Data points in x */
+#define YPTS 46 /* Data points in y */
+
+#define XSPA 2./(XPTS-1)
+#define YSPA 2./(YPTS-1)
+
+/* polar plot data */
+#define PERIMETERPTS 100
+#define RPTS 40
+#define THETAPTS 40
+
+/* potential plot data */
+#define PPERIMETERPTS 100
+#define PRPTS 40
+#define PTHETAPTS 64
+#define PNLEVEL 20
+
+static PLFLT clevel[11] =
+{-1., -.8, -.6, -.4, -.2, 0, .2, .4, .6, .8, 1.};
+
+/* Transformation function */
+
+PLFLT tr[6] =
+{XSPA, 0.0, -1.0, 0.0, YSPA, -1.0};
+
+static void
+mypltr(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data)
+{
+ *tx = tr[0] * x + tr[1] * y + tr[2];
+ *ty = tr[3] * x + tr[4] * y + tr[5];
+}
+
+static void polar()
+/*polar contour plot example.*/
+{
+ int i,j;
+ PLcGrid2 cgrid2;
+ PLFLT **z;
+ PLFLT px[PERIMETERPTS], py[PERIMETERPTS];
+ PLFLT t, r, theta;
+ PLFLT lev[10];
+
+ plenv(-1., 1., -1., 1., 0, -2);
+ plcol0(1);
+
+/*Perimeter*/
+ for (i = 0; i < PERIMETERPTS; i++) {
+ t = (2.*M_PI/(PERIMETERPTS-1))*(double)i;
+ px[i] = cos(t);
+ py[i] = sin(t);
+ }
+ plline(PERIMETERPTS, px, py);
+
+/*create data to be contoured.*/
+ plAlloc2dGrid(&cgrid2.xg, RPTS, THETAPTS);
+ plAlloc2dGrid(&cgrid2.yg, RPTS, THETAPTS);
+ plAlloc2dGrid(&z, RPTS, THETAPTS);
+ cgrid2.nx = RPTS;
+ cgrid2.ny = THETAPTS;
+
+ for (i = 0; i < RPTS; i++) {
+ r = i/(double)(RPTS-1);
+ for (j = 0; j < THETAPTS; j++) {
+ theta = (2.*M_PI/(double)(THETAPTS-1))*(double)j;
+ cgrid2.xg[i][j] = r*cos(theta);
+ cgrid2.yg[i][j] = r*sin(theta);
+ z[i][j] = r;
+ }
+ }
+
+ for (i = 0; i < 10; i++) {
+ lev[i] = 0.05 + 0.10*(double) i;
+ }
+
+ plcol0(2);
+ plcont(z, RPTS, THETAPTS, 1, RPTS, 1, THETAPTS, lev, 10,
+ pltr2, (void *) &cgrid2);
+ plcol0(1);
+ pllab("", "", "Polar Contour Plot");
+ plFree2dGrid(z, RPTS, THETAPTS);
+ plFree2dGrid(cgrid2.xg, RPTS, THETAPTS);
+ plFree2dGrid(cgrid2.yg, RPTS, THETAPTS);
+}
+
+/*--------------------------------------------------------------------------*\
+ * f2mnmx
+ *
+ * Returns min & max of input 2d array.
+\*--------------------------------------------------------------------------*/
+
+static void
+f2mnmx(PLFLT **f, PLINT nx, PLINT ny, PLFLT *fmin, PLFLT *fmax)
+{
+ int i, j;
+
+ *fmax = f[0][0];
+ *fmin = *fmax;
+
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ *fmax = MAX(*fmax, f[i][j]);
+ *fmin = MIN(*fmin, f[i][j]);
+ }
+ }
+}
+
+static void potential()
+/*shielded potential contour plot example.*/
+{
+ int i,j;
+ PLcGrid2 cgrid2;
+ PLFLT rmax, xmin, xmax, x0, ymin, ymax, y0, zmin, zmax;
+ PLFLT peps, xpmin, xpmax, ypmin, ypmax;
+ PLFLT eps, q1, d1, q1i, d1i, q2, d2, q2i, d2i;
+ PLFLT div1, div1i, div2, div2i;
+ PLFLT **z;
+ PLINT nlevelneg, nlevelpos;
+ PLFLT dz, clevel, clevelneg[PNLEVEL], clevelpos[PNLEVEL];
+ PLINT ncollin, ncolbox, ncollab;
+ PLFLT px[PPERIMETERPTS], py[PPERIMETERPTS];
+ PLFLT t, r, theta;
+
+/*create data to be contoured.*/
+ plAlloc2dGrid(&cgrid2.xg, PRPTS, PTHETAPTS);
+ plAlloc2dGrid(&cgrid2.yg, PRPTS, PTHETAPTS);
+ plAlloc2dGrid(&z, PRPTS, PTHETAPTS);
+ cgrid2.nx = PRPTS;
+ cgrid2.ny = PTHETAPTS;
+
+ for (i = 0; i < PRPTS; i++) {
+ r = 0.5 + (double) i;
+ for (j = 0; j < PTHETAPTS; j++) {
+ theta = (2.*M_PI/(double)(PTHETAPTS-1))*(0.5 + (double) j);
+ cgrid2.xg[i][j] = r*cos(theta);
+ cgrid2.yg[i][j] = r*sin(theta);
+ }
+ }
+
+ rmax = r;
+ f2mnmx(cgrid2.xg, PRPTS, PTHETAPTS, &xmin, &xmax);
+ f2mnmx(cgrid2.yg, PRPTS, PTHETAPTS, &ymin, &ymax);
+ x0 = (xmin + xmax)/2.;
+ y0 = (ymin + ymax)/2.;
+
+ /* Expanded limits */
+ peps = 0.05;
+ xpmin = xmin - fabs(xmin)*peps;
+ xpmax = xmax + fabs(xmax)*peps;
+ ypmin = ymin - fabs(ymin)*peps;
+ ypmax = ymax + fabs(ymax)*peps;
+
+ /* Potential inside a conducting cylinder (or sphere) by method of images.
+ Charge 1 is placed at (d1, d1), with image charge at (d2, d2).
+ Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).
+ Also put in smoothing term at small distances.
+ */
+
+ eps = 2.;
+
+ q1 = 1.;
+ d1 = rmax/4.;
+
+ q1i = - q1*rmax/d1;
+ d1i = pow(rmax, 2.)/d1;
+
+ q2 = -1.;
+ d2 = rmax/4.;
+
+ q2i = - q2*rmax/d2;
+ d2i = pow(rmax, 2.)/d2;
+
+ for (i = 0; i < PRPTS; i++) {
+ for (j = 0; j < PTHETAPTS; j++) {
+ div1 = sqrt(pow(cgrid2.xg[i][j]-d1, 2.) + pow(cgrid2.yg[i][j]-d1, 2.) + pow(eps, 2.));
+ div1i = sqrt(pow(cgrid2.xg[i][j]-d1i, 2.) + pow(cgrid2.yg[i][j]-d1i, 2.) + pow(eps, 2.));
+ div2 = sqrt(pow(cgrid2.xg[i][j]-d2, 2.) + pow(cgrid2.yg[i][j]+d2, 2.) + pow(eps, 2.));
+ div2i = sqrt(pow(cgrid2.xg[i][j]-d2i, 2.) + pow(cgrid2.yg[i][j]+d2i, 2.) + pow(eps, 2.));
+ z[i][j] = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i;
+ }
+ }
+ f2mnmx(z, PRPTS, PTHETAPTS, &zmin, &zmax);
+/* printf("%.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g \n",
+ q1, d1, q1i, d1i, q2, d2, q2i, d2i);
+ printf("%.15g %.15g %.15g %.15g %.15g %.15g \n",
+ xmin, xmax, ymin, ymax, zmin, zmax); */
+
+ /* Positive and negative contour levels.*/
+ dz = (zmax-zmin)/(double) PNLEVEL;
+ nlevelneg = 0;
+ nlevelpos = 0;
+ for (i = 0; i < PNLEVEL; i++) {
+ clevel = zmin + ((double) i + 0.5)*dz;
+ if (clevel <= 0.)
+ clevelneg[nlevelneg++] = clevel;
+ else
+ clevelpos[nlevelpos++] = clevel;
+ }
+ /* Colours! */
+ ncollin = 11;
+ ncolbox = 1;
+ ncollab = 2;
+
+ /* Finally start plotting this page! */
+ pladv(0);
+ plcol0(ncolbox);
+
+ plvpas(0.1, 0.9, 0.1, 0.9, 1.0);
+ plwind(xpmin, xpmax, ypmin, ypmax);
+ plbox("", 0., 0, "", 0., 0);
+
+ plcol0(ncollin);
+ if(nlevelneg >0) {
+ /* Negative contours */
+ pllsty(2);
+ plcont(z, PRPTS, PTHETAPTS, 1, PRPTS, 1, PTHETAPTS,
+ clevelneg, nlevelneg, pltr2, (void *) &cgrid2);
+ }
+
+ if(nlevelpos >0) {
+ /* Positive contours */
+ pllsty(1);
+ plcont(z, PRPTS, PTHETAPTS, 1, PRPTS, 1, PTHETAPTS,
+ clevelpos, nlevelpos, pltr2, (void *) &cgrid2);
+ }
+
+ /* Draw outer boundary */
+ for (i = 0; i < PPERIMETERPTS; i++) {
+ t = (2.*M_PI/(PPERIMETERPTS-1))*(double)i;
+ px[i] = x0 + rmax*cos(t);
+ py[i] = y0 + rmax*sin(t);
+ }
+
+ plcol0(ncolbox);
+ plline(PPERIMETERPTS, px, py);
+
+ plcol0(ncollab);
+ pllab("", "", "Shielded potential of charges in a conducting sphere");
+
+ plFree2dGrid(z, PRPTS, PTHETAPTS);
+ plFree2dGrid(cgrid2.xg, PRPTS, PTHETAPTS);
+ plFree2dGrid(cgrid2.yg, PRPTS, PTHETAPTS);
+}
+
+
+/*--------------------------------------------------------------------------*\
+ * main
+ *
+ * Does several contour plots using different coordinate mappings.
+\*--------------------------------------------------------------------------*/
+
+int
+main(int argc, const char *argv[])
+{
+ int i, j;
+ PLFLT xx, yy, argx, argy, distort;
+ static PLINT mark = 1500, space = 1500;
+
+ PLFLT **z, **w;
+ PLFLT xg1[XPTS], yg1[YPTS];
+ PLcGrid cgrid1;
+ PLcGrid2 cgrid2;
+
+/* Parse and process command line arguments */
+
+ (void) plparseopts(&argc, argv, PL_PARSE_FULL);
+
+/* Initialize plplot */
+
+ plinit();
+
+/* Set up function arrays */
+
+ plAlloc2dGrid(&z, XPTS, YPTS);
+ plAlloc2dGrid(&w, XPTS, YPTS);
+
+ for (i = 0; i < XPTS; i++) {
+ xx = (double) (i - (XPTS / 2)) / (double) (XPTS / 2);
+ for (j = 0; j < YPTS; j++) {
+ yy = (double) (j - (YPTS / 2)) / (double) (YPTS / 2) - 1.0;
+ z[i][j] = xx * xx - yy * yy;
+ w[i][j] = 2 * xx * yy;
+ }
+ }
+
+/* Set up grids */
+
+ cgrid1.xg = xg1;
+ cgrid1.yg = yg1;
+ cgrid1.nx = XPTS;
+ cgrid1.ny = YPTS;
+
+ plAlloc2dGrid(&cgrid2.xg, XPTS, YPTS);
+ plAlloc2dGrid(&cgrid2.yg, XPTS, YPTS);
+ cgrid2.nx = XPTS;
+ cgrid2.ny = YPTS;
+
+ for (i = 0; i < XPTS; i++) {
+ for (j = 0; j < YPTS; j++) {
+ mypltr((PLFLT) i, (PLFLT) j, &xx, &yy, NULL);
+
+ argx = xx * M_PI/2;
+ argy = yy * M_PI/2;
+ distort = 0.4;
+
+ cgrid1.xg[i] = xx + distort * cos(argx);
+ cgrid1.yg[j] = yy - distort * cos(argy);
+
+ cgrid2.xg[i][j] = xx + distort * cos(argx) * cos(argy);
+ cgrid2.yg[i][j] = yy - distort * cos(argx) * cos(argy);
+ }
+ }
+
+/* Plot using identity transform */
+/*
+ plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
+ plcol0(2);
+ plcont(z, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11, mypltr, NULL);
+ plstyl(1, &mark, &space);
+ plcol0(3);
+ plcont(w, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11, mypltr, NULL);
+ plstyl(0, &mark, &space);
+ plcol0(1);
+ pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
+*/
+ pl_setcontlabelformat(4,3);
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
+ plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
+ plcol0(2);
+ plcont(z, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11, mypltr, NULL);
+ plstyl(1, &mark, &space);
+ plcol0(3);
+ plcont(w, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11, mypltr, NULL);
+ plstyl(0, &mark, &space);
+ plcol0(1);
+ pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
+
+/* Plot using 1d coordinate transform */
+
+ plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
+ plcol0(2);
+ plcont(z, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr1, (void *) &cgrid1);
+
+ plstyl(1, &mark, &space);
+ plcol0(3);
+ plcont(w, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr1, (void *) &cgrid1);
+ plstyl(0, &mark, &space);
+ plcol0(1);
+ pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
+ /*
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
+ plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
+ plcol0(2);
+ plcont(z, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr1, (void *) &cgrid1);
+
+ plstyl(1, &mark, &space);
+ plcol0(3);
+ plcont(w, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr1, (void *) &cgrid1);
+ plstyl(0, &mark, &space);
+ plcol0(1);
+ pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
+ */
+/* Plot using 2d coordinate transform */
+
+ plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
+ plcol0(2);
+ plcont(z, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr2, (void *) &cgrid2);
+
+ plstyl(1, &mark, &space);
+ plcol0(3);
+ plcont(w, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr2, (void *) &cgrid2);
+ plstyl(0, &mark, &space);
+ plcol0(1);
+ pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
+ /*
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
+ plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
+ plcol0(2);
+ plcont(z, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr2, (void *) &cgrid2);
+
+ plstyl(1, &mark, &space);
+ plcol0(3);
+ plcont(w, XPTS, YPTS, 1, XPTS, 1, YPTS, clevel, 11,
+ pltr2, (void *) &cgrid2);
+ plstyl(0, &mark, &space);
+ plcol0(1);
+ pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
+ */
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
+ polar();
+ /*
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
+ polar();
+ */
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
+ potential();
+ /*
+ pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
+ potential();
+ */
+
+/* Clean up */
+
+ plFree2dGrid(z, XPTS, YPTS);
+ plFree2dGrid(w, XPTS, YPTS);
+ plFree2dGrid(cgrid2.xg, XPTS, YPTS);
+ plFree2dGrid(cgrid2.yg, XPTS, YPTS);
+
+ plend();
+
+ exit(0);
+}
Property changes on: trunk/examples/lua/x09.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x10.lua
===================================================================
--- trunk/examples/lua/x10.lua (rev 0)
+++ trunk/examples/lua/x10.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,35 @@
+-- $Id: $
+
+-- Window positioning demo.
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+pl=plplotluac
+
+----------------------------------------------------------------------------
+-- main
+--
+-- Demonstrates absolute positioning of graphs on a page.
+----------------------------------------------------------------------------
+
+-- Parse and process command line arguments
+-- (void) plparseopts(&argc, argv, PL_PARSE_FULL);
+
+-- Initialize plplot
+pl.plinit()
+
+pl.pladv(0)
+pl.plvpor(0.0, 1.0, 0.0, 1.0)
+pl.plwind(0.0, 1.0, 0.0, 1.0)
+pl.plbox("bc", 0.0, 0, "bc", 0.0, 0)
+
+pl.plsvpa(50.0, 150.0, 50.0, 100.0)
+pl.plwind(0.0, 1.0, 0.0, 1.0)
+pl.plbox("bc", 0.0, 0, "bc", 0.0, 0)
+pl.plptex(0.5, 0.5, 1.0, 0.0, 0.5, "BOX at (50,150,50,100)")
+pl.plend()
Property changes on: trunk/examples/lua/x10.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x11.lua
===================================================================
--- trunk/examples/lua/x11.lua (rev 0)
+++ trunk/examples/lua/x11.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,163 @@
+/* $Id: x11c.c 8033 2007-11-23 15:28:09Z andrewross $
+
+ Mesh plot demo.
+
+ Copyright (C) 2004 Rafael Laboissiere
+
+ This file is part of PLplot.
+
+ PLplot is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Library Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ PLplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with PLplot; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "plcdemos.h"
+
+#define XPTS 35 /* Data points in x */
+#define YPTS 46 /* Data points in y */
+#define LEVELS 10
+
+static int opt[] = { DRAW_LINEXY, DRAW_LINEXY};
+
+static PLFLT alt[] = {33.0, 17.0};
+static PLFLT az[] = {24.0, 115.0};
+
+static char *title[4] =
+{
+ "#frPLplot Example 11 - Alt=33, Az=24, Opt=3",
+ "#frPLplot Example 11 - Alt=17, Az=115, Opt=3",
+};
+
+static void
+cmap1_init()
+{
+ PLFLT i[2], h[2], l[2], s[2];
+
+ i[0] = 0.0; /* left boundary */
+ i[1] = 1.0; /* right boundary */
+
+ h[0] = 240; /* blue -> green -> yellow -> */
+ h[1] = 0; /* -> red */
+
+ l[0] = 0.6;
+ l[1] = 0.6;
+
+ s[0] = 0.8;
+ s[1] = 0.8;
+
+ plscmap1n(256);
+ c_plscmap1l(0, 2, i, h, l, s, NULL);
+}
+
+/*--------------------------------------------------------------------------*\
+ * main
+ *
+ * Does a series of mesh plots for a given data set, with different
+ * viewing options in each plot.
+\*--------------------------------------------------------------------------*/
+
+int
+main(int argc, const char *argv[])
+{
+ int i, j, k;
+ PLFLT *x, *y, **z;
+ PLFLT xx, yy;
+ int nlevel = LEVELS;
+ PLFLT clevel[LEVELS];
+ PLFLT zmin, zmax, step;
+
+ /* Parse and process command line arguments */
+
+ (void) plparseopts(&argc, argv, PL_PARSE_FULL);
+
+ /* Initialize plplot */
+
+ plinit();
+
+ x = (PLFLT *) calloc(XPTS, sizeof(PLFLT));
+ y = (PLFLT *) calloc(YPTS, sizeof(PLFLT));
+
+ plAlloc2dGrid(&z, XPTS, YPTS);
+ for (i = 0; i < XPTS; i++) {
+ x[i] = 3. * (double) (i - (XPTS / 2)) / (double) (XPTS / 2);
+ }
+
+ for (i = 0; i < YPTS; i++)
+ y[i] = 3.* (double) (i - (YPTS / 2)) / (double) (YPTS / 2);
+
+ for (i = 0; i < XPTS; i++) {
+ xx = x[i];
+ for (j = 0; j < YPTS; j++) {
+ yy = y[j];
+ z[i][j] = 3. * (1.-xx)*(1.-xx) * exp(-(xx*xx) - (yy+1.)*(yy+1.)) -
+ 10. * (xx/5. - pow(xx,3.) - pow(yy,5.)) * exp(-xx*xx-yy*yy) -
+ 1./3. * exp(-(xx+1)*(xx+1) - (yy*yy));
+
+ if(0) { /* Jungfraujoch/Interlaken */
+ if (z[i][j] < -1.)
+ z[i][j] = -1.;
+ }
+ }
+ }
+
+ plMinMax2dGrid(z, XPTS, YPTS, &zmax, &zmin);
+ step = (zmax - zmin)/(nlevel+1);
+ for (i=0; i<nlevel; i++)
+ clevel[i] = zmin + step + step*i;
+
+ cmap1_init();
+ for (k = 0; k < 2; k++) {
+ for (i=0; i<4; i++) {
+ pladv(0);
+ plcol0(1);
+ plvpor(0.0, 1.0, 0.0, 0.9);
+ plwind(-1.0, 1.0, -1.0, 1.5);
+ plw3d(1.0, 1.0, 1.2, -3.0, 3.0, -3.0, 3.0, zmin, zmax, alt[k], az[k]);
+ plbox3("bnstu", "x axis", 0.0, 0,
+ "bnstu", "y axis", 0.0, 0,
+ "bcdmnstuv", "z axis", 0.0, 4);
+
+ plcol0(2);
+
+ /* wireframe plot */
+ if (i==0)
+ plmesh(x, y, z, XPTS, YPTS, opt[k]);
+
+ /* magnitude colored wireframe plot */
+ else if (i==1)
+ plmesh(x, y, z, XPTS, YPTS, opt[k] | MAG_COLOR);
+
+ /* magnitude colored wireframe plot with sides */
+ else if (i==2)
+ plot3d(x, y, z, XPTS, YPTS, opt[k] | MAG_COLOR, 1);
+
+ /* magnitude colored wireframe plot with base contour */
+ else if (i==3)
+ plmeshc(x, y, z, XPTS, YPTS, opt[k] | MAG_COLOR | BASE_CONT,
+ clevel, nlevel);
+
+ plcol0(3);
+ plmtex("t", 1.0, 0.5, 0.5, title[k]);
+ }
+ }
+
+/* Clean up */
+
+ free((void *) x);
+ free((void *) y);
+ plFree2dGrid(z, XPTS, YPTS);
+
+ plend();
+
+ exit(0);
+}
Property changes on: trunk/examples/lua/x11.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x12.lua
===================================================================
--- trunk/examples/lua/x12.lua (rev 0)
+++ trunk/examples/lua/x12.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,74 @@
+-- $Id: $
+
+-- Bar chart demo.
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+pl=plplotluac
+
+function plfbox(x0, y0)
+ x = {}
+ y = {}
+
+ x[1] = x0;
+ y[1] = 0.;
+ x[2] = x0;
+ y[2] = y0;
+ x[3] = x0 + 1.;
+ y[3] = y0;
+ x[4] = x0 + 1.;
+ y[4] = 0.;
+ pl.plfill(x, y);
+ pl.plcol0(1);
+ pl.pllsty(1);
+ pl.plline(x, y);
+end
+
+--------------------------------------------------------------------------
+-- main
+--
+-- Does a simple bar chart, using color fill. If color fill is
+-- unavailable, pattern fill is used instead (automatic).
+--------------------------------------------------------------------------
+
+y0 = {}
+
+-- Parse and process command line arguments
+
+-- (void) plparseopts(&argc, argv, PL_PARSE_FULL);
+
+-- Initialize plplot
+pl.plinit()
+
+pl.pladv(0)
+pl.plvsta()
+pl.plwind(1980.0, 1990.0, 0.0, 35.0)
+pl.plbox("bc", 1.0, 0, "bcnv", 10.0, 0)
+pl.plcol0(2)
+pl.pllab("Year", "Widget Sales (millions)", "#frPLplot Example 12")
+
+y0[1] = 5
+y0[2] = 15
+y0[3] = 12
+y0[4] = 24
+y0[5] = 28
+y0[6] = 30
+y0[7] = 20
+y0[8] = 8
+y0[9] = 12
+y0[10] = 3
+
+for i=1, 10 do
+ pl.plcol0(i);
+ pl.plpsty(0);
+ plfbox((1980. + i - 1), y0[i]);
+ pl.plptex((1980. + i - .5), (y0[i] + 1.), 1.0, 0.0, .5, tostring(y0[i]));
+ pl.plmtex("b", 1.0, (i * .1 - .05), 0.5, tostring(1980+i-1));
+end
+
+pl.plend();
Property changes on: trunk/examples/lua/x12.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x13.lua
===================================================================
--- trunk/examples/lua/x13.lua (rev 0)
+++ trunk/examples/lua/x13.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,82 @@
+-- $Id: $
+
+-- Pie chart demo.
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+pl=plplotluac
+
+text = { "Maurice", "Geoffrey", "Alan",
+ "Rafael", "Vince" }
+
+--------------------------------------------------------------------------
+-- main
+--
+-- Does a simple pie chart.
+--------------------------------------------------------------------------
+
+per = { 10, 32, 12, 30, 16 }
+
+-- Parse and process command line arguments
+
+-- (void) plparseopts(&argc, argv, PL_PARSE_FULL);
+
+-- Initialize plplot
+
+pl.plinit()
+
+pl.pladv(0)
+
+-- Ensure window has aspect ratio of one so circle is
+-- plotted as a circle.
+pl.plvasp(1)
+pl.plwind(0, 10, 0, 10)
+pl.plcol0(2)
+
+-- n.b. all theta quantities scaled by 2*M_PI/500 to be integers to avoid
+--floating point logic problems.
+theta0 = 0
+dthet = 1
+for i = 1, 5 do
+ x = { 5 }
+ y = { 5 }
+ j = 2
+ -- n.b. the theta quantities multiplied by 2*M_PI/500 afterward so
+ -- in fact per is interpreted as a percentage.
+ theta1 = theta0 + 5 * per[i]
+ if i == 5 then theta1 = 500 end
+
+ for theta = theta0, theta1, dthet do
+ x[j] = 5 + 3 * math.cos((2*math.pi/500)*theta)
+ y[j] = 5 + 3 * math.sin((2*math.pi/500)*theta)
+ j = j + 1
+ end
+ pl.plcol0(i)
+ pl.plpsty(math.mod((i + 2), 8) + 1)
+ pl.plfill(x, y)
+ pl.plcol0(1)
+ pl.plline(x, y)
+ just = (2*math.pi/500)*(theta0 + theta1)/2
+ dx = .25 * math.cos(just)
+ dy = .25 * math.sin(just)
+ if (theta0 + theta1)<250 or (theta0 + theta1)>750 then
+ just = 0
+ else
+ just = 1
+ end
+
+ pl.plptex((x[(j-1) / 2] + dx), (y[(j-1) / 2] + dy), 1.0, 0.0, just, text[i]);
+ theta0 = theta1 - dthet
+end
+
+pl.plfont(2)
+pl.plschr(0, 1.3)
+pl.plptex(5, 9, 1, 0, 0.5, "Percentage of Sales")
+
+pl.plend()
+
Property changes on: trunk/examples/lua/x13.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x19.lua
===================================================================
--- trunk/examples/lua/x19.lua (rev 0)
+++ trunk/examples/lua/x19.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,80 @@
+-- $Id: $
+
+-- Illustrates backdrop plotting of world, US maps.
+-- Contributed by Wesley Ebisuzaki.
+
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+pl=plplotluac
+
+--------------------------------------------------------------------------
+-- mapform19
+--
+-- Defines specific coordinate transformation for example 19.
+-- Not to be confused with mapform in src/plmap.c.
+-- x[], y[] are the coordinates to be plotted.
+--------------------------------------------------------------------------
+
+function mapform19(n, x, y)
+ for i = 1, n do
+ radius = 90 - y[i]
+ xp = radius * math.cos(x[i] * math.pi / 180)
+ yp = radius * math.sin(x[i] * math.pi / 180)
+ x[i] = xp
+ y[i] = yp
+ end
+end
+
+--------------------------------------------------------------------------
+-- main
+--
+-- Shows two views of the world map.
+--------------------------------------------------------------------------
+
+-- Parse and process command line arguments
+
+-- (void) plparseopts(&argc, argv, PL_PARSE_FULL)
+
+-- Longitude (x) and latitude (y)
+
+miny = -70
+maxy = 80
+
+pl.plinit()
+
+-- Cartesian plots
+-- Most of world
+
+minx = 190
+maxx = 190+360
+
+pl.plcol0(1)
+pl.plenv(minx, maxx, miny, maxy, 1, -1)
+pl.plmap(NULL, "usaglobe", minx, maxx, miny, maxy)
+
+-- The Americas
+
+minx = 190
+maxx = 340
+
+pl.plcol0(1)
+pl.plenv(minx, maxx, miny, maxy, 1, -1)
+pl.plmap(NULL, "usaglobe", minx, maxx, miny, maxy)
+
+-- Polar, Northern hemisphere
+
+minx = 0
+maxx = 360
+
+pl.plenv(-75., 75., -75., 75., 1, -1)
+pl.plmap(mapform19,"globe", minx, maxx, miny, maxy)
+
+pl.pllsty(2)
+pl.plmeridians(mapform19, 10, 10, 0, 360, -10, 80)
+pl.plend()
Property changes on: trunk/examples/lua/x19.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x24.lua
===================================================================
--- trunk/examples/lua/x24.lua (rev 0)
+++ trunk/examples/lua/x24.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,151 @@
+--[[
+ Unicode Pace Flag
+
+ Copyright (C) 2005 Rafael Laboissiere
+
+
+ This file is part of PLplot.
+
+ PLplot is free software you can redistribute it and/or modify
+ it under the terms of the GNU General Library Public License as published
+ by the Free Software Foundation either version 2 of the License, or
+ (at your option) any later version.
+
+ PLplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with PLplot if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+ In Debian, run like this:
+
+ ( TTFDIR=/usr/share/fonts/truetype \
+ PLPLOT_FREETYPE_SANS_FONT=$TTFDIR/arphic/bkai00mp.ttf \
+ PLPLOT_FREETYPE_SERIF_FONT=$TTFDIR/freefont/FreeSerif.ttf \
+ PLPLOT_FREETYPE_MONO_FONT=$TTFDIR/ttf-devanagari-fonts/lohit_hi.ttf \
+ PLPLOT_FREETYPE_SCRIPT_FONT=$TTFDIR/unfonts/UnBatang.ttf \
+ PLPLOT_FREETYPE_SYMBOL_FONT=$TTFDIR/ttf-bengali-fonts/JamrulNormal.ttf \
+ ./x24c -dev png -drvopt smooth=0 -o x24c.png )
+
+ Packages needed:
+
+ ttf-arphic-bkai00mp
+ ttf-freefont
+ ttf-devanagari-fonts
+ ttf-unfonts
+ ttf-bengali-fonts
+--]]
+
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+
+
+red = { 240, 204, 204, 204, 0, 39, 125 }
+green = { 240, 0, 125, 204, 204, 80, 0 }
+blue = { 240, 0, 0, 0, 0, 204, 125 }
+
+px = { 0, 0, 1, 1 }
+py = { 0, 0.25, 0.25, 0 }
+
+sx = {
+ 0.16374,
+ 0.15844,
+ 0.15255,
+ 0.17332,
+ 0.50436,
+ 0.51721,
+ 0.49520,
+ 0.48713,
+ 0.83976,
+ 0.81688,
+ 0.82231,
+ 0.82647
+}
+
+sy = {
+ 0.125,
+ 0.375,
+ 0.625,
+ 0.875,
+ 0.125,
+ 0.375,
+ 0.625,
+ 0.875,
+ 0.125,
+ 0.375,
+ 0.625,
+ 0.875
+}
+
+
+-- Taken from http://www.columbia.edu/~fdc/pace/
+
+peace = {
+ -- Mandarin
+ "#<0x00>和平",
+ -- Hindi
+ "#<0x20>शांति",
+ -- English
+ "#<0x10>Peace",
+ -- Hebrew
+ "#<0x10>שלום",
+ -- Russian
+ "#<0x10>Мир",
+ -- German
+ "#<0x10>Friede",
+ -- Korean
+ "#<0x30>평화",
+ -- French
+ "#<0x10>Paix",
+ -- Spanish
+ "#<0x10>Paz",
+ -- Arabic
+ "#<0x10>ﺳﻼم",
+ -- Turkish
+ "#<0x10>Barış",
+ -- Kurdish
+ "#<0x10>Hasîtî",
+}
+
+n=pl.parseopts(arg, pl.PL_PARSE_FULL)
+print(n)
+
+pl.plinit()
+
+pl.pladv(0)
+pl.plvpor(0, 1, 0, 1)
+pl.plwind(0, 1, 0, 1)
+pl.plcol0(0)
+pl.plbox("", 1, 0, "", 1, 0)
+
+pl.plscmap0n(7)
+pl.plscmap0(red, green, blue)
+
+pl.plschr(0, 4)
+pl.plfont(1)
+
+for i = 1, 4 do
+ pl.plcol0(i)
+ pl.plfill(px, py)
+
+ for j = 1, 4 do
+ py[j] = py[j] + 1/4
+ end
+end
+
+pl.plcol0(0)
+for i = 1, 12 do
+ pl.plptex(sx[i], sy[i], 1, 0, 0.5, peace[i])
+end
+
+pl.plend()
Property changes on: trunk/examples/lua/x24.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x25.lua
===================================================================
--- trunk/examples/lua/x25.lua (rev 0)
+++ trunk/examples/lua/x25.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,113 @@
+-- $Id: $
+
+-- Filling and clipping polygons.
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+pl=plplotluac
+
+--------------------------------------------------------------------------
+-- main
+--
+-- Test program for filling polygons and proper clipping
+--------------------------------------------------------------------------
+
+xextreme = {}
+yextreme ={}
+x0 = {}
+y0 = {}
+
+-- Parse and process command line arguments
+
+-- (void) plparseopts(&argc, argv, PL_PARSE_FULL)
+
+-- Initialize plplot
+
+pl.plssub(3,3)
+pl.plinit()
+
+xextreme[0][0] = -120.0 xextreme[0][1] = 120.0 yextreme[0][0] = -120.0 yextreme[0][1] = 120.0
+xextreme[1][0] = -120.0 xextreme[1][1] = 120.0 yextreme[1][0] = 20.0 yextreme[1][1] = 120.0
+xextreme[2][0] = -120.0 xextreme[2][1] = 120.0 yextreme[2][0] = -20.0 yextreme[2][1] = 120.0
+xextreme[3][0] = -80.0 xextreme[3][1] = 80.0 yextreme[3][0] = -20.0 yextreme[3][1] = 120.0
+xextreme[4][0] = -220.0 xextreme[4][1] = -120.0 yextreme[4][0] = -120.0 yextreme[4][1] = 120.0
+xextreme[5][0] = -20.0 xextreme[5][1] = 20.0 yextreme[5][0] = -120.0 yextreme[5][1] = 120.0
+xextreme[6][0] = -20.0 xextreme[6][1] = 20.0 yextreme[6][0] = -20.0 yextreme[6][1] = 20.0
+xextreme[7][0] = -80.0 xextreme[7][1] = 80.0 yextreme[7][0] = -80.0 yextreme[7][1] = 80.0
+xextreme[8][0] = 20.0 xextreme[8][1] = 120.0 yextreme[8][0] = -120.0 yextreme[8][1] = 120.0
+
+for ( j = 0 j < 4 j ++ )
+{
+ if ( j == 0 )
+ {
+-- Polygon 1: a diamond
+ x0[0] = 0 y0[0] = -100
+ x0[1] = -100 y0[1] = 0
+ x0[2] = 0 y0[2] = 100
+ x0[3] = 100 y0[3] = 0
+ npts = 4
+ }
+ if ( j == 1 )
+ {
+-- Polygon 1: a diamond - reverse direction
+ x0[3] = 0 y0[3] = -100
+ x0[2] = -100 y0[2] = 0
+ x0[1] = 0 y0[1] = 100
+ x0[0] = 100 y0[0] = 0
+ npts = 4
+ }
+ if ( j == 2 )
+ {
+-- Polygon 2: a square with punctures
+ x0[0] = -100 y0[0] = -100
+ x0[1] = -100 y0[1] = -80
+ x0[2] = 80 y0[2] = 0
+ x0[3] = -100 y0[3] = 80
+ x0[4] = -100 y0[4] = 100
+ x0[5] = -80 y0[5] = 100
+ x0[6] = 0 y0[6] = 80
+ x0[7] = 80 y0[7] = 100
+ x0[8] = 100 y0[8] = 100
+ x0[9] = 100 y0[9] = -100
+ npts = 10
+ }
+ if ( j == 3 )
+ {
+-- Polygon 2: a square with punctures - reversed direction
+ x0[9] = -100 y0[9] = -100
+ x0[8] = -100 y0[8] = -80
+ x0[7] = 80 y0[7] = 0
+ x0[6] = -100 y0[6] = 80
+ x0[5] = -100 y0[5] = 100
+ x0[4] = -80 y0[4] = 100
+ x0[3] = 0 y0[3] = 80
+ x0[2] = 80 y0[2] = 100
+ x0[1] = 100 y0[1] = 100
+ x0[0] = 100 y0[0] = -100
+ npts = 10
+ }
+
+ for ( i = 0 i < 9 i ++ )
+ {
+ pladv(0)
+ plvsta()
+ plwind(xextreme[i][0], xextreme[i][1], yextreme[i][0], yextreme[i][1])
+
+ plcol0(2)
+ plbox("bc", 1.0, 0, "bcnv", 10.0, 0)
+ plcol0(1)
+ plpsty(0)
+ plfill(npts,x0,y0)
+ plcol0(2)
+ pllsty(1)
+ plline(npts,x0,y0)
+ }
+}
+
+-- Don't forget to call plend() to finish off!
+pl.plend()
Property changes on: trunk/examples/lua/x25.lua
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/examples/lua/x30.lua
===================================================================
--- trunk/examples/lua/x30.lua (rev 0)
+++ trunk/examples/lua/x30.lua 2009-01-19 09:22:19 UTC (rev 9343)
@@ -0,0 +1,159 @@
+--[[
+ Alpha color values demonstration.
+
+ Copyright (C) 2008 Hazen Babcock
+
+
+ This file is part of PLplot.
+
+ PLplot is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Library Public License as published
+ by the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ PLplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with PLplot; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ This example will only really be interesting when used with devices that
+ support or alpha (or transparency) values, such as the cairo device family.
+--]]
+
+
+-- initialise Lua bindings to PLplot
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac')
+ assert(lib)()
+else
+ require('plplotluac')
+end
+pl=plplotluac
+
+red = { 0, 255, 0, 0 }
+green = { 0, 0, 255, 0 }
+blue = { 0, 0, 0, 255 }
+alpha = { 1, 1, 1, 1 }
+
+px = { 0.1, 0.5, 0.5, 0.1 }
+py = { 0.1, 0.1, 0.5, 0.5 }
+
+pos = { 0, 1 }
+rcoord = { 1, 1 }
+gcoord = { 0, 0 }
+bcoord = { 0, 0 }
+acoord = { 0, 1 }
+rev = { false, false }
+
+clevel = {}
+
+-- plparseopts (&argc, argv, PL_PARSE_FULL);
+
+pl.plinit()
+pl.plscmap0n(4)
+pl.plscmap0a(red, green, blue, alpha, 4)
+
+-- Page 1:
+--
+-- This is a series of red, green and blue rectangles overlaid
+-- on each other with gradually increasing transparency.
+
+-- Set up the window
+pl.pladv(0)
+pl.plvpor(0, 1, 0, 1)
+pl.plwind(0, 1, 0, 1)
+pl.plcol0(0)
+pl.plbox("", 1, 0, "", 1, 0)
+
+-- Draw the boxes
+for i = 0, 8 do
+ icol = math.mod(i, 3) + 1
+
+ -- Get a color, change its transparency and
+ -- set it as the current color.
+ r, g, b, a = pl.plgcol0a(icol)
+ pl.plscol0a(icol, r, g, b, 1-i/9)
+ pl.plcol0(icol)
+
+ -- Draw the rectangle
+ plfill(px, py)
+
+ -- Shift the rectangles coordinates
+ for j = 1, 4 do
+ px[j] = px[j] + 0.5/9
+ py[j] = py[j] + 0.5/9
+ end
+end
+
+-- Page 2:
+
+-- This is a bunch of boxes colored red, green or blue with a single
+-- large (red) box of linearly varying transparency overlaid. The
+-- overlaid box is completely transparent at the bottom and completely
+-- opaque at the top.
+
+-- Set up the window
+pladv(0)
+plvpor(0.1, 0.9, 0.1, 0.9)
+plwind(0.0, 1.0, 0.0, 1.0)
+
+-- Draw the boxes. There are 25 of them drawn on a 5 x 5 grid.
+for i = 0, 4 do
+ -- Set box X position
+ px[1] = 0.05 + 0.2 * i
+ px[2] = px[1] + 0.1
+ px[3] = px[2]
+ px[4] = px[1]
+
+ -- We don't want the boxes to be transparent, so since we changed
+ -- the colors transparencies in the first example we have to change
+ -- the transparencies back to completely opaque.
+ icol = mod(i, 3) + 1
+ r, g, b, a = plgcol0a(icol)
+ plscol0a(icol, r, g, b, 1)
+ plcol0(icol)
+
+ for j = 0, 4 do
+ -- Set box y position and draw the box.
+ py[1] = 0.05 + 0.2 * j
+ py[2] = py[1]
+ py[3] = py[1] + 0.1
+ py[4] = py[3]
+ plfill(px, py)
+ end
+end
+
+-- The overlaid box is drawn using plshades with a color map that is
+-- the same color but has a linearly varying transparency.
+
+-- Create the color map with 128 colors and use plscmap1la to initialize
+-- the color values with a linear varying transparency (or alpha)
+plscmap1n(128)
+plscmap1la(1, 2, pos, rcoord, gcoord, bcoord, acoord, rev)
+
+-- Create a 2 x 2 array that contains the z values (0.0 to 1.0) that will
+-- used for the shade plot. plshades will use linear interpolation to
+-- calculate the z values of all the intermediate points in this array.
+--[[plAlloc2dGrid(&z, 2, 2);
+z[0][0] = 0.0;
+z[1][0] = 0.0;
+z[0][1] = 1.0;
+z[1][1] = 1.0;
+
+/* Set the color levels array. These levels are also between 0.0 and 1.0 */
+for(i=0;i<101;i++){
+ clevel[i] = 0.01 * (PLFLT)i;
+}
+
+/* Draw the shade plot with zmin = 0.0, zmax = 1.0 and x and y coordinate ranges */
+/* such that it fills the entire plotting area. */
+plshades(z, 2, 2, NULL, 0.0, 1.0, 0.0, 1.0, clevel, 101, 0, -1, 2, plfill, 1, NULL, NULL);
+
+plFree2dGrid(z,2,2);--]]
+
+plend()
+
Property changes on: trunk/examples/lua/x30.lua
___________________________________________________________________
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|