The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
1508 changed files with 125983 additions and 44037 deletions
1
SWIG/Examples/GIFPlot/.cvsignore
Normal file
1
SWIG/Examples/GIFPlot/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
21
SWIG/Examples/GIFPlot/Common-Lisp/full/gifplot.i
Normal file
21
SWIG/Examples/GIFPlot/Common-Lisp/full/gifplot.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* Oh what the heck, let's just grab the whole darn header file
|
||||
and see what happens. */
|
||||
|
||||
%module gifplot
|
||||
%{
|
||||
|
||||
/* Note: You still need this part because the %include directive
|
||||
merely causes SWIG to interpret the contents of a file. It doesn't
|
||||
include the right include headers for the resulting C code */
|
||||
|
||||
#include "gifplot.h"
|
||||
|
||||
%}
|
||||
|
||||
/* Pixel is typedef'd to unsigned char, and SWIG will translate this
|
||||
type into Scheme characters. We would like to translate Pixels to
|
||||
Scheme integers instead, so: */
|
||||
|
||||
SIMPLE_MAP(Pixel, gh_scm2int, gh_int2scm, integer);
|
||||
|
||||
%include gifplot.h
|
||||
59
SWIG/Examples/GIFPlot/Common-Lisp/full/runme.lisp
Normal file
59
SWIG/Examples/GIFPlot/Common-Lisp/full/runme.lisp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
;;; Plot a 3D function
|
||||
|
||||
;; Here is the function to plot
|
||||
(defun func (x y)
|
||||
(* 5
|
||||
(cos (* 2 (sqrt (+ (* x x) (* y y)))))
|
||||
(exp (* -0.3 (sqrt (+ (* x x) (* y y)))))))
|
||||
|
||||
;; Here are some plotting parameters
|
||||
(defvar xmin -5D0)
|
||||
(defvar xmax 5D0)
|
||||
(defvar ymin -5D0)
|
||||
(defvar ymax 5D0)
|
||||
(defvar zmin -5D0)
|
||||
(defvar zmax 5D0)
|
||||
|
||||
;; Grid resolution
|
||||
(defvar nxpoints 60)
|
||||
(defvar nypoints 60)
|
||||
|
||||
(defun drawsolid (p3)
|
||||
(Plot3D-clear p3 0)
|
||||
(Plot3D-start p3)
|
||||
(let ((dx (/ (- xmax xmin) nxpoints))
|
||||
(dy (/ (- ymax ymin) nypoints))
|
||||
(cscale (/ 240 (- zmax zmin))))
|
||||
(loop for x from xmin by dx
|
||||
repeat nxpoints
|
||||
do (loop for y from ymin by dy
|
||||
repeat nypoints
|
||||
do (let* ((z1 (func x y))
|
||||
(z2 (func (+ x dx) y))
|
||||
(z3 (func (+ x dx) (+ y dy)))
|
||||
(z4 (func x (+ y dy)))
|
||||
(c1 (* cscale (- z1 zmin)))
|
||||
(c2 (* cscale (- z2 zmin)))
|
||||
(c3 (* cscale (- z3 zmin)))
|
||||
(c4 (* cscale (- z4 zmin)))
|
||||
(cc (/ (+ c1 c2 c3 c4) 4))
|
||||
(c (round (max (min cc 239) 0))))
|
||||
(Plot3D-solidquad p3 x y z1 (+ x dx) y z2 (+ x dx) (+ y dy)
|
||||
z3 x (+ y dy) z4 (+ c 16)))))))
|
||||
|
||||
(defun action (cmap-filename)
|
||||
(let ((cmap (new-ColorMap cmap-filename))
|
||||
(frame (new-FrameBuffer 500 500)))
|
||||
(format t "Making a nice 3D plot...~%")
|
||||
(FrameBuffer-clear frame 0)
|
||||
(let ((p3 (new-Plot3D frame xmin ymin zmin xmax ymax zmax)))
|
||||
(Plot3D-lookat p3 (* 2 (- zmax zmin)))
|
||||
(Plot3D-autoperspective p3 40D0)
|
||||
(Plot3D-rotu p3 60D0)
|
||||
(Plot3D-rotr p3 30D0)
|
||||
(Plot3D-rotd p3 10D0)
|
||||
(drawsolid p3))
|
||||
(FrameBuffer-writeGIF frame cmap "/tmp/image.gif")
|
||||
(format t "Wrote image.gif~%")))
|
||||
|
||||
|
||||
3
SWIG/Examples/GIFPlot/Guile/check.list
Normal file
3
SWIG/Examples/GIFPlot/Guile/check.list
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
simple
|
||||
3
SWIG/Examples/GIFPlot/Guile/full/.cvsignore
Normal file
3
SWIG/Examples/GIFPlot/Guile/full/.cvsignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
gifplot-guile
|
||||
gifplot_wrap.c
|
||||
image.gif
|
||||
|
|
@ -5,23 +5,24 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all:: static
|
||||
|
||||
dynamic::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so gifguile .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Guile/simple/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Guile/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
gifguile
|
||||
image.gif
|
||||
simple-guile
|
||||
simple_wrap.c
|
||||
|
|
@ -5,23 +5,24 @@ SRCS =
|
|||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all:: static
|
||||
|
||||
dynamic::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so gifguile .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
#ifndef GIFPLOT_H
|
||||
|
||||
#ifdef SWIG
|
||||
%pragma no_default
|
||||
#endif
|
||||
|
||||
/* Pixel is 8-bits */
|
||||
|
||||
typedef unsigned char Pixel;
|
||||
|
|
@ -125,9 +129,9 @@ extern void delete_PixMap(PixMap *pm);
|
|||
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
|
||||
extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor);
|
||||
|
||||
#define TRANSPARENT 0
|
||||
#define FOREGROUND 1
|
||||
#define BACKGROUND 2
|
||||
#define GIFPLOT_TRANSPARENT 0
|
||||
#define GIFPLOT_FOREGROUND 1
|
||||
#define GIFPLOT_BACKGROUND 2
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
Plot2D
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
typedef unsigned char Pixel;
|
||||
typedef float Zvalue;
|
||||
|
||||
%disabledoc
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
ColorMap
|
||||
|
||||
|
|
@ -23,14 +21,14 @@ typedef struct ColorMap {
|
|||
char *name;
|
||||
|
||||
//
|
||||
// %addmethods adds some C methods to this structure to make it
|
||||
// %extend adds some C methods to this structure to make it
|
||||
// look like a C++ class in Python.
|
||||
// These are really named things like ColorMap_default, ColorMap_assign, etc...
|
||||
|
||||
%addmethods {
|
||||
%extend {
|
||||
ColorMap(char *filename);
|
||||
~ColorMap();
|
||||
#ifdef SWIGJAVA
|
||||
#if defined(SWIGJAVA ) || defined(SWIGPHP4)
|
||||
%name(make_default) void default();
|
||||
#else
|
||||
void default();
|
||||
|
|
@ -44,16 +42,6 @@ typedef struct ColorMap {
|
|||
|
||||
/* Some default colors */
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
const Pixel BLACK = 0;
|
||||
const Pixel WHITE = 1;
|
||||
const Pixel RED = 2;
|
||||
const Pixel GREEN = 3;
|
||||
const Pixel BLUE = 4;
|
||||
const Pixel YELLOW = 5;
|
||||
const Pixel CYAN = 6;
|
||||
const Pixel MAGENTA = 7;
|
||||
#else
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define RED 2
|
||||
|
|
@ -62,7 +50,6 @@ const Pixel MAGENTA = 7;
|
|||
#define YELLOW 5
|
||||
#define CYAN 6
|
||||
#define MAGENTA 7
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
FrameBuffer
|
||||
|
|
@ -77,7 +64,7 @@ typedef struct FrameBuffer {
|
|||
int ymin;
|
||||
int xmax;
|
||||
int ymax;
|
||||
%addmethods {
|
||||
%extend {
|
||||
FrameBuffer(unsigned int width, unsigned int height);
|
||||
~FrameBuffer();
|
||||
void resize(int width, int height);
|
||||
|
|
@ -119,9 +106,9 @@ extern PixMap *new_PixMap(int width, int height, int centerx, int centery);
|
|||
extern void delete_PixMap(PixMap *pm);
|
||||
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
|
||||
|
||||
#define TRANSPARENT 0
|
||||
#define FOREGROUND 1
|
||||
#define BACKGROUND 2
|
||||
#define GIFPLOT_TRANSPARENT 0
|
||||
#define GIFPLOT_FOREGROUND 1
|
||||
#define GIFPLOT_BACKGROUND 2
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Plot2D
|
||||
|
|
@ -141,7 +128,7 @@ typedef struct Plot2D {
|
|||
double ymax;
|
||||
int xscale; /* Type of scaling (LINEAR, LOG, etc..) */
|
||||
int yscale;
|
||||
%addmethods {
|
||||
%extend {
|
||||
Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax);
|
||||
~Plot2D();
|
||||
Plot2D *copy();
|
||||
|
|
@ -203,7 +190,7 @@ typedef struct Plot3D {
|
|||
double lookatz; /* Where is the z-lookat point */
|
||||
double xshift; /* Used for translation and stuff */
|
||||
double yshift;
|
||||
%addmethods {
|
||||
%extend {
|
||||
Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax);
|
||||
~Plot3D();
|
||||
Plot3D *copy();
|
||||
|
|
@ -264,13 +251,11 @@ typedef struct Plot3D {
|
|||
/* These directives create constants of a specific type. They
|
||||
do not correspond to any C variable or declared constant in the
|
||||
header file */
|
||||
%constant(PixMap *) SQUARE = &PixMap_SQUARE;
|
||||
%constant(PixMap *) TRIANGLE = &PixMap_TRIANGLE;
|
||||
%constant(PixMap *) CROSS = &PixMap_CROSS;
|
||||
%constant PixMap * SQUARE = &PixMap_SQUARE;
|
||||
%constant PixMap * TRIANGLE = &PixMap_TRIANGLE;
|
||||
%constant PixMap * CROSS = &PixMap_CROSS;
|
||||
#endif
|
||||
|
||||
%enabledoc
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig -shadow
|
||||
SWIGOPT = -I../Include
|
||||
SRCS =
|
||||
TARGET = libjgifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L.. -lgifplot -lm
|
||||
INCLUDE = -I../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so .~* core *.gif *.class ColorMap.java FrameBuffer.java Plot2D.java Plot3D.java gifplot.java
|
||||
|
||||
check: all
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
The gifplot example does not work straight out of the box,
|
||||
I had to change ../Interface/gifplot.i slightly for java.
|
||||
|
||||
a)
|
||||
The colors (e.g. BLACK) where defined as:
|
||||
|
||||
#define BLACK 0
|
||||
|
||||
and the functions expect 'Pixel color' where Pixel is a unsigned char.
|
||||
#define constants contain no type information and are translated to integer
|
||||
constants. Because of that, you have to cast every Pixel to a byte in java.
|
||||
|
||||
Changing the definition to:
|
||||
const Pixel BLACK = 0;
|
||||
fixes this.
|
||||
|
||||
b)
|
||||
The definitions:
|
||||
|
||||
const PixMap *SQUARE = &PixMap_SQUARE;
|
||||
const PixMap *TRIANGLE = &PixMap_TRIANGLE;
|
||||
const PixMap *CROSS = &PixMap_CROSS;
|
||||
|
||||
don't work.
|
||||
The wrapper code expects actual variables SQUARE, etc. and they are not
|
||||
defined in gifplot.h.
|
||||
|
||||
c)
|
||||
In shadow mode the method ColorMap::default() clashes with the reserved name
|
||||
default.
|
||||
4
SWIG/Examples/GIFPlot/Java/check.list
Normal file
4
SWIG/Examples/GIFPlot/Java/check.list
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
shadow
|
||||
simple
|
||||
Binary file not shown.
7
SWIG/Examples/GIFPlot/Java/full/.cvsignore
Normal file
7
SWIG/Examples/GIFPlot/Java/full/.cvsignore
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
*.class
|
||||
*.java
|
||||
*_wrap.c
|
||||
*_wrap.cxx
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
20
SWIG/Examples/GIFPlot/Java/full/Makefile
Normal file
20
SWIG/Examples/GIFPlot/Java/full/Makefile
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Include -noproxy
|
||||
SRCS =
|
||||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
|
||||
javac *.java
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile java_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
8
SWIG/Examples/GIFPlot/Java/full/README
Normal file
8
SWIG/Examples/GIFPlot/Java/full/README
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
This example runs the entire gifplot.h header file through SWIG without
|
||||
any changes. The program 'main.java' does something a little more
|
||||
interesting. After doing a make, run it using 'java main'. You'll have to go
|
||||
look at the header file to get a complete listing of the functions.
|
||||
|
||||
Note the differences in the main.java files between this example and the
|
||||
'full' example. This example does not use shadow classes.
|
||||
|
||||
BIN
SWIG/Examples/GIFPlot/Java/full/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Java/full/cmap
Normal file
Binary file not shown.
15
SWIG/Examples/GIFPlot/Java/full/gifplot.i
Normal file
15
SWIG/Examples/GIFPlot/Java/full/gifplot.i
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Oh what the heck, let's just grab the whole darn header file
|
||||
and see what happens. */
|
||||
|
||||
%module gifplot
|
||||
%{
|
||||
|
||||
/* Note: You still need this part because the %include directive
|
||||
merely causes SWIG to interpret the contents of a file. It doesn't
|
||||
include the right include headers for the resulting C code */
|
||||
|
||||
#include "gifplot.h"
|
||||
|
||||
%}
|
||||
|
||||
%include gifplot.h
|
||||
75
SWIG/Examples/GIFPlot/Java/full/main.java
Normal file
75
SWIG/Examples/GIFPlot/Java/full/main.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// Plot a 3D function
|
||||
import java.lang.Math;
|
||||
|
||||
public class main {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("gifplot");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
// Here are some plotting parameters
|
||||
double xmin = -5.0;
|
||||
double xmax = 5.0;
|
||||
double ymin = -5.0;
|
||||
double ymax = 5.0;
|
||||
double zmin = -5.0;
|
||||
double zmax = 5.0;
|
||||
|
||||
// Grid resolution
|
||||
int nxpoints = 60;
|
||||
int nypoints = 60;
|
||||
|
||||
SWIGTYPE_p_ColorMap cmap = gifplot.new_ColorMap("cmap");
|
||||
SWIGTYPE_p_FrameBuffer frame = gifplot.new_FrameBuffer(500,500);
|
||||
gifplot.FrameBuffer_clear(frame,(short)gifplot.BLACK);
|
||||
|
||||
SWIGTYPE_p_Plot3D p3 = gifplot.new_Plot3D(frame,xmin,ymin,zmin,xmax,ymax,zmax);
|
||||
gifplot.Plot3D_lookat(p3,2*(zmax-zmin));
|
||||
gifplot.Plot3D_autoperspective(p3,40);
|
||||
gifplot.Plot3D_rotu(p3,60);
|
||||
gifplot.Plot3D_rotr(p3,30);
|
||||
gifplot.Plot3D_rotd(p3,10);
|
||||
|
||||
System.out.println( "Making a nice 3D plot..." );
|
||||
gifplot.Plot3D_clear(p3,(short)gifplot.BLACK);
|
||||
gifplot.Plot3D_start(p3);
|
||||
double dx = 1.0*(xmax-xmin)/nxpoints;
|
||||
double dy = 1.0*(ymax-ymin)/nypoints;
|
||||
double cscale = 240.0/(zmax-zmin);
|
||||
double x = xmin;
|
||||
for (int i = 0; i < nxpoints; i++) {
|
||||
double y = ymin;
|
||||
for (int j = 0; j < nypoints; j++) {
|
||||
double z1 = func(x,y);
|
||||
double z2 = func(x+dx,y);
|
||||
double z3 = func(x+dx,y+dy);
|
||||
double z4 = func(x,y+dy);
|
||||
double c1 = cscale*(z1-zmin);
|
||||
double c2 = cscale*(z2-zmin);
|
||||
double c3 = cscale*(z3-zmin);
|
||||
double c4 = cscale*(z4-zmin);
|
||||
double c = (c1+c2+c3+c4)/4;
|
||||
if (c < 0) c = 0;
|
||||
if (c > 239) c = 239;
|
||||
gifplot.Plot3D_solidquad(p3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16));
|
||||
y = y + dy;
|
||||
}
|
||||
x = x + dx;
|
||||
}
|
||||
|
||||
gifplot.FrameBuffer_writeGIF(frame,cmap,"image.gif");
|
||||
System.out.println( "Wrote image.gif" );
|
||||
}
|
||||
|
||||
// Here is the function to plot
|
||||
public static double func(double x, double y) {
|
||||
return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,273 +0,0 @@
|
|||
//
|
||||
// Graphics module
|
||||
//
|
||||
%module gifplot
|
||||
%{
|
||||
#include "gifplot.h"
|
||||
%}
|
||||
|
||||
/* Pixel is 8-bits */
|
||||
|
||||
typedef unsigned char Pixel;
|
||||
typedef float Zvalue;
|
||||
|
||||
%disabledoc
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
ColorMap
|
||||
|
||||
Definition and methods for colormaps
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
typedef struct ColorMap {
|
||||
char *name;
|
||||
|
||||
//
|
||||
// %addmethods adds some C methods to this structure to make it
|
||||
// look like a C++ class in Python.
|
||||
// These are really named things like ColorMap_default, ColorMap_assign, etc...
|
||||
|
||||
%addmethods {
|
||||
ColorMap(char *filename);
|
||||
~ColorMap();
|
||||
#ifdef SWIGJAVA
|
||||
%name(make_default) void default();
|
||||
#else
|
||||
void default();
|
||||
#endif
|
||||
void assign(int index,int r, int g, int b);
|
||||
%name(__getitem__) int getitem(int index);
|
||||
%name(__setitem__) void setitem(int index, int value);
|
||||
int write(char *filename);
|
||||
}
|
||||
} ColorMap;
|
||||
|
||||
/* Some default colors */
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
const Pixel BLACK = 0;
|
||||
const Pixel WHITE = 1;
|
||||
const Pixel RED = 2;
|
||||
const Pixel GREEN = 3;
|
||||
const Pixel BLUE = 4;
|
||||
const Pixel YELLOW = 5;
|
||||
const Pixel CYAN = 6;
|
||||
const Pixel MAGENTA = 7;
|
||||
#else
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define RED 2
|
||||
#define GREEN 3
|
||||
#define BLUE 4
|
||||
#define YELLOW 5
|
||||
#define CYAN 6
|
||||
#define MAGENTA 7
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
FrameBuffer
|
||||
|
||||
This structure defines a simple 8 bit framebuffer.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
typedef struct FrameBuffer {
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
int xmin; /* These are used for clipping */
|
||||
int ymin;
|
||||
int xmax;
|
||||
int ymax;
|
||||
%addmethods {
|
||||
FrameBuffer(unsigned int width, unsigned int height);
|
||||
~FrameBuffer();
|
||||
void resize(int width, int height);
|
||||
void clear(Pixel color);
|
||||
void plot(int x, int y, Pixel color);
|
||||
void horizontal(int xmin, int xmax, int y, Pixel color);
|
||||
void horizontalinterp(int xmin, int xmax, int y, Pixel c1, Pixel c2);
|
||||
void vertical(int ymin, int ymax, int x, Pixel color);
|
||||
void box(int x1, int y1, int x2, int y2, Pixel color);
|
||||
void solidbox(int x1, int y1, int x2, int y2, Pixel color);
|
||||
void interpbox(int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4);
|
||||
void circle(int x1, int y1, int radius, Pixel color);
|
||||
void solidcircle(int x1, int y1, int radius, Pixel color);
|
||||
void line(int x1, int y1, int x2, int y2, Pixel color);
|
||||
void setclip(int xmin, int ymin, int xmax, int ymax);
|
||||
void noclip();
|
||||
int makeGIF(ColorMap *cmap, void *buffer, unsigned int maxsize);
|
||||
void zresize(int width, int height);
|
||||
void zclear();
|
||||
void drawchar(int x, int y, int fgcolor, int bgcolor, char chr, int orientation);
|
||||
void drawstring(int x, int y, int fgcolor, int bgcolor, char *text, int orientation);
|
||||
void drawpixmap(PixMap *pm, int x, int y, int fgcolor, int bgcolor);
|
||||
int writeGIF(ColorMap *cmap, char *filename);
|
||||
}
|
||||
} FrameBuffer;
|
||||
|
||||
#define HORIZONTAL 1
|
||||
#define VERTICAL 2
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
PixMap
|
||||
|
||||
The equivalent of "bit-maps".
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
/* PIXMAP methods */
|
||||
|
||||
extern PixMap *new_PixMap(int width, int height, int centerx, int centery);
|
||||
extern void delete_PixMap(PixMap *pm);
|
||||
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
|
||||
|
||||
#define TRANSPARENT 0
|
||||
#define FOREGROUND 1
|
||||
#define BACKGROUND 2
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Plot2D
|
||||
|
||||
Definition and methods for 2D plots.
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
typedef struct Plot2D {
|
||||
FrameBuffer *frame;
|
||||
int view_xmin; /* Minimum coordinates of view region */
|
||||
int view_ymin;
|
||||
int view_xmax; /* Maximum coordinates of view region */
|
||||
int view_ymax;
|
||||
double xmin; /* Minimum coordinates of plot region */
|
||||
double ymin;
|
||||
double xmax; /* Maximum coordinates of plot region */
|
||||
double ymax;
|
||||
int xscale; /* Type of scaling (LINEAR, LOG, etc..) */
|
||||
int yscale;
|
||||
%addmethods {
|
||||
Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax);
|
||||
~Plot2D();
|
||||
Plot2D *copy();
|
||||
void clear(Pixel c);
|
||||
void setview(int vxmin, int vymin, int vxmax, int vymax);
|
||||
void setrange(double xmin, double ymin, double xmax, double ymax);
|
||||
void setscale(int xscale, int yscale);
|
||||
void plot(double x, double y, Pixel color);
|
||||
void box(double x1, double y1, double x2, double y2, Pixel color);
|
||||
void solidbox(double x1, double y1, double x2, double y2, Pixel color);
|
||||
void interpbox(double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4);
|
||||
|
||||
void circle(double x, double y, double radius, Pixel color);
|
||||
void solidcircle(double x, double y, double radius, Pixel color);
|
||||
void line(double x1, double y1, double x2, double y2, Pixel color);
|
||||
void start();
|
||||
void drawpixmap(PixMap *pm, double x, double y, Pixel color, Pixel bgcolor);
|
||||
void xaxis(double x, double y, double xtick, int ticklength, Pixel color);
|
||||
void yaxis(double x, double y, double ytick, int ticklength, Pixel color);
|
||||
void triangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c);
|
||||
|
||||
void solidtriangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c);
|
||||
|
||||
void interptriangle(double x1, double y1, Pixel c1,
|
||||
double x2, double y2, Pixel c2,
|
||||
double x3, double y3, Pixel c3);
|
||||
|
||||
}
|
||||
} Plot2D;
|
||||
|
||||
#define LINEAR 10
|
||||
#define LOG 11
|
||||
|
||||
/* ------------------------------------------------------------------------------
|
||||
Plot3D
|
||||
|
||||
Data Structure for 3-D plots
|
||||
------------------------------------------------------------------------------ */
|
||||
|
||||
typedef struct Plot3D {
|
||||
FrameBuffer *frame;
|
||||
int view_xmin; /* Viewing region */
|
||||
int view_ymin;
|
||||
int view_xmax;
|
||||
int view_ymax;
|
||||
double xmin; /* Bounding box */
|
||||
double ymin;
|
||||
double zmin;
|
||||
double xmax;
|
||||
double ymax;
|
||||
double zmax;
|
||||
double xcenter; /* Center point */
|
||||
double ycenter;
|
||||
double zcenter;
|
||||
double fovy; /* Field of view */
|
||||
double aspect; /* Aspect ratio */
|
||||
double znear; /* near "clipping" plane */
|
||||
double zfar; /* far "clipping" plane */
|
||||
double lookatz; /* Where is the z-lookat point */
|
||||
double xshift; /* Used for translation and stuff */
|
||||
double yshift;
|
||||
%addmethods {
|
||||
Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax);
|
||||
~Plot3D();
|
||||
Plot3D *copy();
|
||||
void clear(Pixel bgcolor);
|
||||
void perspective( double fovy, double znear, double zfar);
|
||||
void lookat( double z);
|
||||
void autoperspective( double fovy);
|
||||
void ortho(double left, double right, double bottom, double top);
|
||||
void autoortho();
|
||||
void rotx( double deg);
|
||||
void roty( double deg);
|
||||
void rotz( double deg);
|
||||
void rotl( double deg);
|
||||
void rotr( double deg);
|
||||
void rotd( double deg);
|
||||
void rotu( double deg);
|
||||
void rotc( double deg);
|
||||
void zoom( double percent);
|
||||
void left( double percent);
|
||||
void right( double percent);
|
||||
void down( double percent);
|
||||
void up( double percent);
|
||||
void center( double cx, double cy);
|
||||
void plot( double x, double y, double z, Pixel Color);
|
||||
void setview( int vxmin, int vymin, int vxmax, int vymax);
|
||||
void start();
|
||||
void line( double x1, double y1, double z1,
|
||||
double x2, double y2, double z2, Pixel color);
|
||||
void triangle( double x1, double y1, double z1,
|
||||
double x2, double y2, double z2,
|
||||
double x3, double y3, double z3, Pixel color);
|
||||
void solidtriangle( double x1, double y1, double z1,
|
||||
double x2, double y2, double z2,
|
||||
double x3, double y3, double z3, Pixel color);
|
||||
void interptriangle(double x1, double y1, double z1, Pixel c1,
|
||||
double x2, double y2, double z2, Pixel c2,
|
||||
double x3, double y3, double z3, Pixel c3);
|
||||
void quad( double x1, double y1, double z1,
|
||||
double x2, double y2, double z2,
|
||||
double x3, double y3, double z3,
|
||||
double x4, double y4, double z4,
|
||||
Pixel color);
|
||||
void solidquad( double x1, double y1, double z1,
|
||||
double x2, double y2, double z2,
|
||||
double x3, double y3, double z3,
|
||||
double x4, double y4, double z4,
|
||||
Pixel color);
|
||||
void interpquad( double x1, double y1, double z1, Pixel c1,
|
||||
double x2, double y2, double z2, Pixel c2,
|
||||
double x3, double y3, double z3, Pixel c3,
|
||||
double x4, double y4, double z4, Pixel c4);
|
||||
void solidsphere( double x, double y, double z, double radius,Pixel c);
|
||||
void outlinesphere( double x, double y, double z, double radius,Pixel c, Pixel bc);
|
||||
}
|
||||
} Plot3D;
|
||||
|
||||
#ifndef SWIGJAVA
|
||||
const PixMap *SQUARE = &PixMap_SQUARE;
|
||||
const PixMap *TRIANGLE = &PixMap_TRIANGLE;
|
||||
const PixMap *CROSS = &PixMap_CROSS;
|
||||
#endif
|
||||
|
||||
%enabledoc
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
import gifplot;
|
||||
|
||||
public class ortho {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jgifplot");
|
||||
};
|
||||
|
||||
public static double func(double x, double y) {
|
||||
double r;
|
||||
double f;
|
||||
r = Math.sqrt(x*x + y*y);
|
||||
|
||||
f = (Math.sin(0.30*r*x)+Math.cos(0.30*r*y))/(1.0+r);
|
||||
return f;
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
FrameBuffer f;
|
||||
Plot3D p3;
|
||||
ColorMap cm;
|
||||
|
||||
double x,y;
|
||||
double dx,dy;
|
||||
double z1,z2,z3,z4;
|
||||
int c1,c2,c3,c4;
|
||||
|
||||
/* Create a framebuffer */
|
||||
|
||||
f = new FrameBuffer(700,400);
|
||||
|
||||
/* Load a colormap */
|
||||
|
||||
cm = new ColorMap("cm15");
|
||||
|
||||
/* Create a new 2D image */
|
||||
|
||||
f.clear(gifplot.BLACK);
|
||||
p3 = new Plot3D(f,-6.3,-6.3,-1.5,6.3,6.3,1.5);
|
||||
|
||||
/* Set viewing region in 2D plot */
|
||||
|
||||
p3.setview(50,50,650,350);
|
||||
|
||||
/* Set how far away from the image we are */
|
||||
p3.lookat(20);
|
||||
|
||||
/* Set the field of view for the perspective */
|
||||
|
||||
|
||||
// Plot3D_autoperspective(p3,40);
|
||||
|
||||
p3.autoortho();
|
||||
|
||||
/* Now make a plot of a 3D function */
|
||||
|
||||
/* Make a frame */
|
||||
|
||||
f.noclip();
|
||||
f.box(49,49,650,350,gifplot.WHITE);
|
||||
p3.start(); /* Always call this prior to making an image */
|
||||
p3.clear(gifplot.BLACK);
|
||||
p3.rotu(60);
|
||||
p3.rotz(40);
|
||||
x = -6.3;
|
||||
dx = 0.25;
|
||||
while (x < 6.3) {
|
||||
y = -6.3;
|
||||
dy = 0.25;
|
||||
while (y < 6.3) {
|
||||
z1 = func(x,y);
|
||||
z2 = func(x+dx,y);
|
||||
z3 = func(x+dx,y+dy);
|
||||
z4 = func(x,y+dy);
|
||||
c1 = (int) ((z1 + 1.0)*120) + 16;
|
||||
if (c1 < 16) c1 = 16;
|
||||
if (c1 > 254) c1 = 254;
|
||||
|
||||
c2 = (int) ((z2 + 1.0)*120) + 16;
|
||||
if (c2 < 16) c2 = 16;
|
||||
if (c2 > 254) c2 = 254;
|
||||
|
||||
c3 = (int) ((z3 + 1.0)*120) + 16;
|
||||
if (c3 < 16) c3 = 16;
|
||||
if (c3 > 254) c3 = 254;
|
||||
|
||||
c4 = (int) ((z4 + 1.0)*120) + 16;
|
||||
if (c4 < 16) c4 = 16;
|
||||
if (c4 > 254) c4= 254;
|
||||
|
||||
p3.interpquad(x,y,z1,(byte) c1,
|
||||
x+dx,y,z2,(byte) c2,
|
||||
x+dx,y+dy,z3,(byte) c3,
|
||||
x,y+dy,z4,(byte) c4);
|
||||
y = y + dy;
|
||||
}
|
||||
x = x + dx;
|
||||
}
|
||||
|
||||
/* Make a GIF file */
|
||||
|
||||
f.writeGIF(cm,"plot.gif");
|
||||
|
||||
System.out.println("Image written to 'plot.gif'");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import gifplot;
|
||||
|
||||
public class shadow {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jgifplot");
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
FrameBuffer fb = new FrameBuffer(300, 300);
|
||||
ColorMap cm = new ColorMap("cmap");
|
||||
|
||||
fb.clear(gifplot.BLACK);
|
||||
fb.drawstring(50, 50, gifplot.WHITE, gifplot.BLACK, "Hello world", gifplot.VERTICAL);
|
||||
fb.solidbox(200, 200, 220, 240, gifplot.BLUE);
|
||||
fb.line(0, 290, 293, 50, gifplot.RED);
|
||||
fb.circle(100, 100, 10, gifplot.YELLOW);
|
||||
fb.writeGIF(cm, "plot.gif");
|
||||
|
||||
System.out.println("Image written to 'plot.gif'");
|
||||
}
|
||||
}
|
||||
7
SWIG/Examples/GIFPlot/Java/shadow/.cvsignore
Normal file
7
SWIG/Examples/GIFPlot/Java/shadow/.cvsignore
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
*.class
|
||||
*.java
|
||||
*_wrap.c
|
||||
*_wrap.cxx
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
20
SWIG/Examples/GIFPlot/Java/shadow/Makefile
Normal file
20
SWIG/Examples/GIFPlot/Java/shadow/Makefile
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Interface
|
||||
SRCS =
|
||||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
|
||||
javac *.java
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile java_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
5
SWIG/Examples/GIFPlot/Java/shadow/README
Normal file
5
SWIG/Examples/GIFPlot/Java/shadow/README
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
This example uses the file in ../../Interface/gifplot.i to build
|
||||
an interface with shadow classes. After doing a make, run the program main, ie: 'java main'.
|
||||
|
||||
Note the differences in the main.java files between this example and the
|
||||
'full' example. This example uses the shadow classes.
|
||||
BIN
SWIG/Examples/GIFPlot/Java/shadow/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Java/shadow/cmap
Normal file
Binary file not shown.
76
SWIG/Examples/GIFPlot/Java/shadow/main.java
Normal file
76
SWIG/Examples/GIFPlot/Java/shadow/main.java
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
// Plot a 3D function
|
||||
|
||||
import java.lang.Math;
|
||||
|
||||
public class main {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("gifplot");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
// Here are some plotting parameters
|
||||
double xmin = -5.0;
|
||||
double xmax = 5.0;
|
||||
double ymin = -5.0;
|
||||
double ymax = 5.0;
|
||||
double zmin = -5.0;
|
||||
double zmax = 5.0;
|
||||
|
||||
// Grid resolution
|
||||
int nxpoints = 60;
|
||||
int nypoints = 60;
|
||||
|
||||
ColorMap cmap = new ColorMap("cmap");
|
||||
FrameBuffer frame = new FrameBuffer(500,500);
|
||||
frame.clear((short)gifplot.BLACK);
|
||||
|
||||
Plot3D p3 = new Plot3D(frame,xmin,ymin,zmin,xmax,ymax,zmax);
|
||||
p3.lookat(2*(zmax-zmin));
|
||||
p3.autoperspective(40);
|
||||
p3.rotu(60);
|
||||
p3.rotr(30);
|
||||
p3.rotd(10);
|
||||
|
||||
System.out.println( "Making a nice 3D plot..." );
|
||||
p3.clear((short)gifplot.BLACK);
|
||||
p3.start();
|
||||
double dx = 1.0*(xmax-xmin)/nxpoints;
|
||||
double dy = 1.0*(ymax-ymin)/nypoints;
|
||||
double cscale = 240.0/(zmax-zmin);
|
||||
double x = xmin;
|
||||
for (int i = 0; i < nxpoints; i++) {
|
||||
double y = ymin;
|
||||
for (int j = 0; j < nypoints; j++) {
|
||||
double z1 = func(x,y);
|
||||
double z2 = func(x+dx,y);
|
||||
double z3 = func(x+dx,y+dy);
|
||||
double z4 = func(x,y+dy);
|
||||
double c1 = cscale*(z1-zmin);
|
||||
double c2 = cscale*(z2-zmin);
|
||||
double c3 = cscale*(z3-zmin);
|
||||
double c4 = cscale*(z4-zmin);
|
||||
double c = (c1+c2+c3+c4)/4;
|
||||
if (c < 0) c = 0;
|
||||
if (c > 239) c = 239;
|
||||
p3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16));
|
||||
y = y + dy;
|
||||
}
|
||||
x = x + dx;
|
||||
}
|
||||
|
||||
frame.writeGIF(cmap,"image.gif");
|
||||
System.out.println( "Wrote image.gif" );
|
||||
}
|
||||
|
||||
// Here is the function to plot
|
||||
public static double func(double x, double y) {
|
||||
return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import gifplot;
|
||||
|
||||
public class simple {
|
||||
|
||||
static {
|
||||
System.loadLibrary("jgifplot");
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
long f = gifplot.new_FrameBuffer(300, 300);
|
||||
long c = gifplot.new_ColorMap("cmap");
|
||||
|
||||
gifplot.FrameBuffer_clear(f, gifplot.BLACK);
|
||||
gifplot.FrameBuffer_drawstring(f, 50, 50, gifplot.WHITE, gifplot.BLACK, "Hello world", gifplot.HORIZONTAL);
|
||||
gifplot.FrameBuffer_solidbox(f, 200, 200, 220, 240, gifplot.BLUE);
|
||||
gifplot.FrameBuffer_line(f, 0, 290, 293, 50, gifplot.RED);
|
||||
gifplot.FrameBuffer_circle(f, 100, 100, 10, gifplot.YELLOW);
|
||||
gifplot.FrameBuffer_writeGIF(f, c, "plot.gif");
|
||||
|
||||
System.out.println("Image written to 'plot.gif'");
|
||||
}
|
||||
}
|
||||
7
SWIG/Examples/GIFPlot/Java/simple/.cvsignore
Normal file
7
SWIG/Examples/GIFPlot/Java/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
*.class
|
||||
*.java
|
||||
*_wrap.c
|
||||
*_wrap.cxx
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
21
SWIG/Examples/GIFPlot/Java/simple/Makefile
Normal file
21
SWIG/Examples/GIFPlot/Java/simple/Makefile
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -noproxy
|
||||
SRCS =
|
||||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
|
||||
javac *.java
|
||||
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile java_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
5
SWIG/Examples/GIFPlot/Java/simple/README
Normal file
5
SWIG/Examples/GIFPlot/Java/simple/README
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
This is a very minimalistic example in which just a few functions
|
||||
and constants from library are wrapped and used to draw some simple
|
||||
shapes. After doing a make, run the java program, ie 'java main'.
|
||||
|
||||
|
||||
41
SWIG/Examples/GIFPlot/Java/simple/main.java
Normal file
41
SWIG/Examples/GIFPlot/Java/simple/main.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
public class main {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("simple");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
// Draw some simple shapes
|
||||
System.out.println( "Drawing some basic shapes" );
|
||||
|
||||
SWIGTYPE_p_ColorMap cmap = simple.new_ColorMap(null);
|
||||
SWIGTYPE_p_FrameBuffer f = simple.new_FrameBuffer(400,400);
|
||||
|
||||
// Clear the picture
|
||||
simple.FrameBuffer_clear(f,(short)simple.BLACK);
|
||||
|
||||
// Make a red box
|
||||
simple.FrameBuffer_box(f,40,40,200,200,(short)simple.RED);
|
||||
|
||||
// Make a blue circle
|
||||
simple.FrameBuffer_circle(f,200,200,40,(short)simple.BLUE);
|
||||
|
||||
// Make green line
|
||||
simple.FrameBuffer_line(f,10,390,390,200, (short)simple.GREEN);
|
||||
|
||||
// Write an image out to disk
|
||||
|
||||
simple.FrameBuffer_writeGIF(f,cmap,"image.gif");
|
||||
System.out.println( "Wrote image.gif" );
|
||||
|
||||
simple.delete_FrameBuffer(f);
|
||||
simple.delete_ColorMap(cmap);
|
||||
}
|
||||
}
|
||||
38
SWIG/Examples/GIFPlot/Java/simple/simple.i
Normal file
38
SWIG/Examples/GIFPlot/Java/simple/simple.i
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* This example shows a very simple interface wrapping a few
|
||||
primitive declarations */
|
||||
|
||||
%module simple
|
||||
%{
|
||||
#include "gifplot.h"
|
||||
%}
|
||||
|
||||
typedef unsigned char Pixel;
|
||||
|
||||
/* Here are a few useful functions */
|
||||
|
||||
ColorMap *new_ColorMap(char *filename = 0);
|
||||
void delete_ColorMap(ColorMap *cmap);
|
||||
|
||||
FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height);
|
||||
void delete_FrameBuffer(FrameBuffer *frame);
|
||||
void FrameBuffer_clear(FrameBuffer *frame, Pixel color);
|
||||
void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color);
|
||||
int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename);
|
||||
|
||||
/* And some useful constants */
|
||||
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define RED 2
|
||||
#define GREEN 3
|
||||
#define BLUE 4
|
||||
#define YELLOW 5
|
||||
#define CYAN 6
|
||||
#define MAGENTA 7
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
/**********************************************************************
|
||||
* GIFPlot 0.0
|
||||
*
|
||||
* Dave Beazley
|
||||
*
|
||||
* Department of Computer Science Theoretical Division (T-11)
|
||||
* University of Utah Los Alamos National Laboratory
|
||||
* Salt Lake City, Utah 84112 Los Alamos, New Mexico 87545
|
||||
* beazley@cs.utah.edu beazley@lanl.gov
|
||||
*
|
||||
* Copyright (c) 1996
|
||||
* The Regents of the University of California and the University of Utah
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose, provided that
|
||||
* (1) The above copyright notice and the following two paragraphs
|
||||
* appear in all copies of the source code and (2) redistributions
|
||||
* including binaries reproduces these notices in the supporting
|
||||
* documentation. Substantial modifications to this software may be
|
||||
* copyrighted by their authors and need not follow the licensing terms
|
||||
* described here, provided that the new terms are clearly indicated in
|
||||
* all files where they apply.
|
||||
*
|
||||
* IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE
|
||||
* UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
|
||||
* PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
* DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
|
||||
* EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH
|
||||
* SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
|
||||
* THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
|
||||
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
**************************************************************************/
|
||||
1
SWIG/Examples/GIFPlot/Lib/.cvsignore
Normal file
1
SWIG/Examples/GIFPlot/Lib/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
CC = @CC@
|
||||
INCLUDE = -I../Include
|
||||
INCLUDES= -I../Include
|
||||
CFLAGS = -O
|
||||
SRCS = frame.c color.c plot2d.c plot3d.c font.c pixmap.c matrix.c gif.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
OBJS = $(SRCS:.c=.@OBJEXT@)
|
||||
AR = @AR@
|
||||
RANLIB = @RANLIB@
|
||||
TARGET = ../libgifplot.a
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
|
||||
.c.@OBJEXT@:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) -c -o $*.@OBJEXT@ $<
|
||||
|
||||
all: $(OBJS)
|
||||
@rm -f ../libgifplot.a
|
||||
|
|
@ -16,6 +16,6 @@ all: $(OBJS)
|
|||
$(RANLIB) $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ $(TARGET)
|
||||
|
||||
rm -f *.@OBJEXT@ *~ $(TARGET)
|
||||
|
||||
check: all
|
||||
|
|
|
|||
|
|
@ -99,10 +99,10 @@ FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, in
|
|||
for (i = startx; i < endx; i++) {
|
||||
c = pm->map[py*pm->width + px];
|
||||
switch (c) {
|
||||
case FOREGROUND:
|
||||
case GIFPLOT_FOREGROUND:
|
||||
f->pixels[j][i] = fgcolor;
|
||||
break;
|
||||
case BACKGROUND:
|
||||
case GIFPLOT_BACKGROUND:
|
||||
f->pixels[j][i] = bgcolor;
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ install:
|
|||
$(RANLIB) $(exec_prefix)/lib/libgifplot.a
|
||||
|
||||
clean::
|
||||
rm -f *.o *~ libgifplot.a *_wrap* *_man*
|
||||
rm -f *.@OBJEXT@ *~ libgifplot.a *_wrap* *_man*
|
||||
cd Lib; $(MAKE) clean
|
||||
rm -f config.log config.status config.cache
|
||||
|
||||
|
||||
check: all
|
||||
|
|
|
|||
3
SWIG/Examples/GIFPlot/Ocaml/check.list
Normal file
3
SWIG/Examples/GIFPlot/Ocaml/check.list
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
simple
|
||||
26
SWIG/Examples/GIFPlot/Ocaml/full/Makefile
Normal file
26
SWIG/Examples/GIFPlot/Ocaml/full/Makefile
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Include
|
||||
SRCS =
|
||||
TARGET = gifcaml
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDES = -I../../Include
|
||||
MLFILE = gifplot.ml
|
||||
IOBJS = runme.cmo
|
||||
PROGFILE = runme.ml
|
||||
|
||||
all:: static
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
8
SWIG/Examples/GIFPlot/Ocaml/full/README
Normal file
8
SWIG/Examples/GIFPlot/Ocaml/full/README
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
This example runs the entire gifplot.h header file through SWIG without
|
||||
any changes. The ocaml program 'runme.ml' does something a little more
|
||||
interesting. You'll have to go look at the header file to get a complete
|
||||
listing of the functions.
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
SWIG/Examples/GIFPlot/Ocaml/full/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Ocaml/full/cmap
Normal file
Binary file not shown.
15
SWIG/Examples/GIFPlot/Ocaml/full/gifplot.i
Normal file
15
SWIG/Examples/GIFPlot/Ocaml/full/gifplot.i
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Oh what the heck, let's just grab the whole darn header file
|
||||
and see what happens. */
|
||||
|
||||
%module gifplot
|
||||
%{
|
||||
|
||||
/* Note: You still need this part because the %include directive
|
||||
merely causes SWIG to interpret the contents of a file. It doesn't
|
||||
include the right include headers for the resulting C code */
|
||||
|
||||
#include "gifplot.h"
|
||||
%}
|
||||
|
||||
typedef int Pixel;
|
||||
%include gifplot.h
|
||||
86
SWIG/Examples/GIFPlot/Ocaml/full/runme.ml
Normal file
86
SWIG/Examples/GIFPlot/Ocaml/full/runme.ml
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
(* Plot a 3D Function *)
|
||||
|
||||
(* Use the wrapped GIFPlot library *)
|
||||
open Gifplot
|
||||
open Int32
|
||||
|
||||
(* Here is the function to plot *)
|
||||
let func x y =
|
||||
5.0 *.
|
||||
(cos (2.0 *. (sqrt (x *. x) +. (y *. y)))) *.
|
||||
(exp (-0.3 *. (sqrt (x *. x) +. (y *. y))))
|
||||
|
||||
(* Here are some plotting parameters *)
|
||||
|
||||
let xmin = -5.0
|
||||
let xmax = 5.0
|
||||
let ymin = -5.0
|
||||
let ymax = 5.0
|
||||
let zmin = -5.0
|
||||
let zmax = 5.0
|
||||
|
||||
(* Grid resolution *)
|
||||
let nxpoints = 60
|
||||
let nypoints = 60
|
||||
|
||||
let cmap = _new_ColorMap (C_string "cmap")
|
||||
let frame = _new_FrameBuffer (C_list [ C_int 500 ;
|
||||
C_int 500 ])
|
||||
let _ = _FrameBuffer_clear (C_list [ frame ; _BLACK ])
|
||||
|
||||
let p2 = _new_Plot3D (C_list [ frame ;
|
||||
C_float xmin ; C_float ymin ; C_float zmin ;
|
||||
C_float xmax ; C_float ymax ; C_float zmax ])
|
||||
let _ = _Plot3D_lookat (C_list [ p2 ; C_float (2.0 *. (zmax -. zmin)) ])
|
||||
let _ = _Plot3D_autoperspective (C_list [ p2 ; C_float 40.0 ])
|
||||
let _ = _Plot3D_rotu (C_list [ p2 ; C_float 60.0 ])
|
||||
let _ = _Plot3D_rotr (C_list [ p2 ; C_float 30.0 ])
|
||||
let _ = _Plot3D_rotd (C_list [ p2 ; C_float 10.0 ])
|
||||
|
||||
let drawsolid () =
|
||||
begin
|
||||
_Plot3D_clear (C_list [ p2 ; _BLACK ]) ;
|
||||
_Plot3D_start p2 ;
|
||||
let dx = ((xmax -. xmin) /. (float_of_int nxpoints))
|
||||
and dy = ((ymax -. ymin) /. (float_of_int nypoints))
|
||||
and cscale = (240.0 /. (zmax -. zmin)) in
|
||||
let rec x_loop x i =
|
||||
if i < nxpoints then
|
||||
begin
|
||||
let rec y_loop y j =
|
||||
begin
|
||||
if j < nypoints then
|
||||
let z1 = func x y
|
||||
and z2 = func (x +. dx) y
|
||||
and z3 = func (x +. dx) (y +. dy)
|
||||
and z4 = func x (y +. dy) in
|
||||
let c1 = cscale *. (z1 -. zmin)
|
||||
and c2 = cscale *. (z2 -. zmin)
|
||||
and c3 = cscale *. (z3 -. zmin)
|
||||
and c4 = cscale *. (z4 -. zmin) in
|
||||
let cc = (c1 +. c2 +. c3 +. c4) /. 4.0 in
|
||||
let c = (max (min (int_of_float cc) 239) 0) in
|
||||
_Plot3D_solidquad
|
||||
(C_list (p2 ::
|
||||
(List.map
|
||||
(fun x -> C_float x)
|
||||
[ x ; y ; z1 ;
|
||||
(x +. dx) ; y ; z2 ;
|
||||
(x +. dx) ; (y +. dy) ; z3 ;
|
||||
x ; (y +. dx) ; z4 ;
|
||||
(float_of_int (c + 16)) ]))) ;
|
||||
y_loop (y +. dy) (j + 1)
|
||||
end in
|
||||
begin
|
||||
y_loop ymin 0 ;
|
||||
x_loop (x +. dx) (i + 1)
|
||||
end
|
||||
end in
|
||||
x_loop xmin 0
|
||||
end
|
||||
|
||||
let _ = print_endline "Making a nice 3D plot..."
|
||||
let _ = drawsolid ()
|
||||
|
||||
let _ = _FrameBuffer_writeGIF (C_list [ frame ; cmap ; C_string "image.gif" ])
|
||||
let _ = print_endline "Write image.gif"
|
||||
26
SWIG/Examples/GIFPlot/Ocaml/simple/Makefile
Normal file
26
SWIG/Examples/GIFPlot/Ocaml/simple/Makefile
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Include
|
||||
SRCS =
|
||||
TARGET = gifsimple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDES = -I../../Include
|
||||
MLFILE = simple.ml
|
||||
IOBJS = simple_wrap.o simple.cmo runme.cmo
|
||||
PROGFILE = runme.ml
|
||||
|
||||
all:: static
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
BIN
SWIG/Examples/GIFPlot/Ocaml/simple/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Ocaml/simple/cmap
Normal file
Binary file not shown.
34
SWIG/Examples/GIFPlot/Ocaml/simple/runme.ml
Normal file
34
SWIG/Examples/GIFPlot/Ocaml/simple/runme.ml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
(* Draw some simple shapes *)
|
||||
|
||||
(* Use the wrapped GIFPlot library *)
|
||||
open Simple
|
||||
open Int32
|
||||
|
||||
let _ = print_endline "Drawing some basic shapes"
|
||||
|
||||
let cmap = _new_ColorMap (C_string "cmap")
|
||||
let f = _new_FrameBuffer (C_list [ C_int 400 ; C_int 400 ])
|
||||
|
||||
(* Clear the picture *)
|
||||
let _ = _FrameBuffer_clear (C_list [ f ; _BLACK ])
|
||||
|
||||
(* Make a red box *)
|
||||
let _ = _FrameBuffer_box
|
||||
(C_list [ f ; C_int 40 ; C_int 40 ; C_int 200 ; C_int 200 ; _RED ])
|
||||
|
||||
(* Make a blue circle *)
|
||||
let _ = _FrameBuffer_circle
|
||||
(C_list [ f ; C_int 200 ; C_int 200 ; C_int 40 ; _BLUE ])
|
||||
|
||||
(* Make green line *)
|
||||
let _ = _FrameBuffer_line
|
||||
(C_list [ f ; C_int 10 ; C_int 390 ; C_int 390 ; C_int 200 ; _GREEN ])
|
||||
|
||||
(* Write an image out to disk *)
|
||||
|
||||
let _ = _FrameBuffer_writeGIF (C_list [ f ; cmap ; C_string "image.gif" ])
|
||||
let _ = print_endline "Wrote image.gif"
|
||||
|
||||
let _ = _delete_FrameBuffer f
|
||||
let _ = _delete_ColorMap cmap
|
||||
|
||||
33
SWIG/Examples/GIFPlot/Ocaml/simple/simple.i
Normal file
33
SWIG/Examples/GIFPlot/Ocaml/simple/simple.i
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* This example shows a very simple interface wrapping a few
|
||||
primitive declarations */
|
||||
|
||||
%module simple
|
||||
%{
|
||||
#include "gifplot.h"
|
||||
%}
|
||||
|
||||
typedef int Pixel;
|
||||
|
||||
/* Here are a few useful functions */
|
||||
|
||||
ColorMap *new_ColorMap(char *filename = 0);
|
||||
void delete_ColorMap(ColorMap *cmap);
|
||||
|
||||
FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height);
|
||||
void delete_FrameBuffer(FrameBuffer *frame);
|
||||
void FrameBuffer_clear(FrameBuffer *frame, Pixel color);
|
||||
void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color);
|
||||
int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename);
|
||||
|
||||
/* And some useful constants */
|
||||
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define RED 2
|
||||
#define GREEN 3
|
||||
#define BLUE 4
|
||||
#define YELLOW 5
|
||||
#define CYAN 6
|
||||
#define MAGENTA 7
|
||||
4
SWIG/Examples/GIFPlot/Perl/check.list
Normal file
4
SWIG/Examples/GIFPlot/Perl/check.list
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
shadow
|
||||
simple
|
||||
5
SWIG/Examples/GIFPlot/Perl/full/.cvsignore
Normal file
5
SWIG/Examples/GIFPlot/Perl/full/.cvsignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
gifplot.pm
|
||||
gifplot_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so myperl *.pm .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile perl5_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
5
SWIG/Examples/GIFPlot/Perl/shadow/.cvsignore
Normal file
5
SWIG/Examples/GIFPlot/Perl/shadow/.cvsignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
gifplot.pm
|
||||
gifplot_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so myperl *.pm .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile perl5_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
5
SWIG/Examples/GIFPlot/Perl/simple/.cvsignore
Normal file
5
SWIG/Examples/GIFPlot/Perl/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
simple.pm
|
||||
simple_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so myperl *.pm .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile perl5_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
3
SWIG/Examples/GIFPlot/Php/check.list
Normal file
3
SWIG/Examples/GIFPlot/Php/check.list
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
simple
|
||||
19
SWIG/Examples/GIFPlot/Php/full/Makefile
Normal file
19
SWIG/Examples/GIFPlot/Php/full/Makefile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Include -noproxy
|
||||
SRCS =
|
||||
TARGET = php_gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile php4_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
4
SWIG/Examples/GIFPlot/Php/full/README
Normal file
4
SWIG/Examples/GIFPlot/Php/full/README
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
This example runs the entire gifplot.h header file through SWIG without
|
||||
any changes. The script 'runme.php3' does something a little more
|
||||
interesting. You'll have to go look at the header file to get a complete
|
||||
listing of the functions.
|
||||
BIN
SWIG/Examples/GIFPlot/Php/full/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Php/full/cmap
Normal file
Binary file not shown.
15
SWIG/Examples/GIFPlot/Php/full/gifplot.i
Normal file
15
SWIG/Examples/GIFPlot/Php/full/gifplot.i
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Oh what the heck, let's just grab the whole darn header file
|
||||
and see what happens. */
|
||||
|
||||
%module gifplot
|
||||
%{
|
||||
|
||||
/* Note: You still need this part because the %include directive
|
||||
merely causes SWIG to interpret the contents of a file. It doesn't
|
||||
include the right include headers for the resulting C code */
|
||||
|
||||
#include "gifplot.h"
|
||||
|
||||
%}
|
||||
|
||||
%include gifplot.h
|
||||
78
SWIG/Examples/GIFPlot/Php/full/runme.php4
Normal file
78
SWIG/Examples/GIFPlot/Php/full/runme.php4
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?
|
||||
|
||||
# Plot a 3D function
|
||||
require "gifplot.php";
|
||||
|
||||
# Here is the function to plot
|
||||
function func($x, $y) {
|
||||
return 5*cos(2*sqrt($x*$x+$y*$y))*exp(-0.3*sqrt($x*$x+$y*$y));
|
||||
}
|
||||
|
||||
# Here are some plotting parameters
|
||||
$xmin = -5.0;
|
||||
$xmax = 5.0;
|
||||
$ymin = -5.0;
|
||||
$ymax = 5.0;
|
||||
$zmin = -5.0;
|
||||
$zmax = 5.0;
|
||||
|
||||
# Grid resolution
|
||||
$nxpoints = 60;
|
||||
$nypoints = 60;
|
||||
|
||||
$cmap = new_ColorMap("cmap");
|
||||
$frame = new_FrameBuffer(500,500);
|
||||
FrameBuffer_clear($frame, BLACK);
|
||||
|
||||
$p3 = new_Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax);
|
||||
Plot3D_lookat($p3, 2*($zmax-$zmin));
|
||||
Plot3D_autoperspective($p3, 40);
|
||||
Plot3D_rotu($p3, 60);
|
||||
Plot3D_rotr($p3, 30);
|
||||
Plot3D_rotd($p3, 10);
|
||||
|
||||
function drawsolid() {
|
||||
global $p3;
|
||||
global $xmax;
|
||||
global $xmin;
|
||||
global $ymax;
|
||||
global $ymin;
|
||||
global $zmin;
|
||||
global $zmax;
|
||||
global $nxpoints;
|
||||
global $nypoints;
|
||||
|
||||
Plot3D_clear($p3, BLACK);
|
||||
Plot3D_start($p3);
|
||||
$dx = 1.0*($xmax-$xmin)/$nxpoints;
|
||||
$dy = 1.0*($ymax-$ymin)/$nypoints;
|
||||
$cscale = 240.0/($zmax-$zmin);
|
||||
$x = $xmin;
|
||||
for ($i = 0; $i < $nxpoints; $i++) {
|
||||
$y = $ymin;
|
||||
for ($j = 0; $j < $nypoints; $j++) {
|
||||
$z1 = func($x,$y);
|
||||
$z2 = func($x+$dx,$y);
|
||||
$z3 = func($x+$dx,$y+$dy);
|
||||
$z4 = func($x,$y+$dy);
|
||||
$c1 = $cscale*($z1-$zmin);
|
||||
$c2 = $cscale*($z2-$zmin);
|
||||
$c3 = $cscale*($z3-$zmin);
|
||||
$c4 = $cscale*($z4-$zmin);
|
||||
$c = ($c1+$c2+$c3+$c4)/4;
|
||||
if ($c < 0) { $c = 0; }
|
||||
if ($c > 239) { $c = 239; }
|
||||
Plot3D_solidquad($p3, $x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16);
|
||||
$y = $y + $dy;
|
||||
}
|
||||
$x = $x + $dx;
|
||||
}
|
||||
}
|
||||
|
||||
print "Making a nice 3D plot...\n";
|
||||
drawsolid();
|
||||
|
||||
FrameBuffer_writeGIF($frame, $cmap,"image.gif");
|
||||
print "Wrote image.gif\n";
|
||||
|
||||
?>
|
||||
19
SWIG/Examples/GIFPlot/Php/shadow/Makefile
Normal file
19
SWIG/Examples/GIFPlot/Php/shadow/Makefile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Interface
|
||||
SRCS =
|
||||
TARGET = php_gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile php4_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
2
SWIG/Examples/GIFPlot/Php/shadow/README
Normal file
2
SWIG/Examples/GIFPlot/Php/shadow/README
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
This example use the file in ../../Interface/gifplot.i to build
|
||||
an interface with shadow classes. Run the script 'runme.php3'.
|
||||
BIN
SWIG/Examples/GIFPlot/Php/shadow/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Php/shadow/cmap
Normal file
Binary file not shown.
79
SWIG/Examples/GIFPlot/Php/shadow/runme.php4
Normal file
79
SWIG/Examples/GIFPlot/Php/shadow/runme.php4
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?
|
||||
|
||||
# Plot a 3D function
|
||||
include("gifplot.php");
|
||||
|
||||
# Here is the function to plot
|
||||
function func($x, $y) {
|
||||
return 5*cos(2*sqrt($x*$x+$y*$y))*exp(-0.3*sqrt($x*$x+$y*$y));
|
||||
}
|
||||
|
||||
# Here are some plotting parameters
|
||||
$xmin = -5.0;
|
||||
$xmax = 5.0;
|
||||
$ymin = -5.0;
|
||||
$ymax = 5.0;
|
||||
$zmin = -5.0;
|
||||
$zmax = 5.0;
|
||||
|
||||
# Grid resolution
|
||||
$nxpoints = 60;
|
||||
$nypoints = 60;
|
||||
|
||||
$cmap = new ColorMap("cmap");
|
||||
$frame = new FrameBuffer(500,500);
|
||||
$frame->clear(BLACK);
|
||||
|
||||
|
||||
$p3 = new Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax);
|
||||
$p3->lookat(2*($zmax-$zmin));
|
||||
$p3->autoperspective(40);
|
||||
$p3->rotu(60);
|
||||
$p3->rotr(30);
|
||||
$p3->rotd(10);
|
||||
|
||||
function drawsolid() {
|
||||
global $xmax;
|
||||
global $xmin;
|
||||
global $ymax;
|
||||
global $ymin;
|
||||
global $zmin;
|
||||
global $zmax;
|
||||
global $nxpoints;
|
||||
global $nypoints;
|
||||
global $p3;
|
||||
|
||||
$p3->clear(BLACK);
|
||||
$p3->start();
|
||||
$dx = 1.0*($xmax-$xmin)/$nxpoints;
|
||||
$dy = 1.0*($ymax-$ymin)/$nypoints;
|
||||
$cscale = 240.0/($zmax-$zmin);
|
||||
$x = $xmin;
|
||||
for ($i = 0; $i < $nxpoints; $i++) {
|
||||
$y = $ymin;
|
||||
for ($j = 0; $j < $nypoints; $j++) {
|
||||
$z1 = func($x,$y);
|
||||
$z2 = func($x+$dx,$y);
|
||||
$z3 = func($x+$dx,$y+$dy);
|
||||
$z4 = func($x,$y+$dy);
|
||||
$c1 = $cscale*($z1-$zmin);
|
||||
$c2 = $cscale*($z2-$zmin);
|
||||
$c3 = $cscale*($z3-$zmin);
|
||||
$c4 = $cscale*($z4-$zmin);
|
||||
$c = ($c1+$c2+$c3+$c4)/4;
|
||||
if ($c < 0) { $c = 0; }
|
||||
if ($c > 239) { $c = 239; }
|
||||
$p3->solidquad($x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16);
|
||||
$y = $y + $dy;
|
||||
}
|
||||
$x = $x + $dx;
|
||||
}
|
||||
}
|
||||
|
||||
print "Making a nice 3D plot...\n";
|
||||
drawsolid();
|
||||
|
||||
$frame->writeGIF($cmap,"image.gif");
|
||||
print "Wrote image.gif\n";
|
||||
|
||||
?>
|
||||
19
SWIG/Examples/GIFPlot/Php/simple/Makefile
Normal file
19
SWIG/Examples/GIFPlot/Php/simple/Makefile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -noproxy
|
||||
SRCS =
|
||||
TARGET = php_simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile php4_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
5
SWIG/Examples/GIFPlot/Php/simple/README
Normal file
5
SWIG/Examples/GIFPlot/Php/simple/README
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
This is a very minimalistic example in which just a few functions
|
||||
and constants from library are wrapped and used to draw some simple
|
||||
shapes. The script 'runme.pl' runs the example.
|
||||
|
||||
|
||||
32
SWIG/Examples/GIFPlot/Php/simple/runme.php4
Normal file
32
SWIG/Examples/GIFPlot/Php/simple/runme.php4
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?
|
||||
|
||||
# Draw some simple shapes
|
||||
print "Drawing some basic shapes\n";
|
||||
|
||||
require "simple.php";
|
||||
|
||||
$cmap = new_ColorMap();
|
||||
$f = new_FrameBuffer(400,400);
|
||||
|
||||
# Clear the picture
|
||||
FrameBuffer_clear($f,BLACK);
|
||||
|
||||
# Make a red box
|
||||
FrameBuffer_box($f,40,40,200,200,RED);
|
||||
|
||||
# Make a blue circle
|
||||
FrameBuffer_circle($f,200,200,40,BLUE);
|
||||
|
||||
# Make green line
|
||||
FrameBuffer_line($f,10,390,390,200, GREEN);
|
||||
|
||||
# Write an image out to disk
|
||||
|
||||
FrameBuffer_writeGIF($f,$cmap,"image.gif");
|
||||
print "Wrote image.gif\n";
|
||||
|
||||
delete_FrameBuffer($f);
|
||||
delete_ColorMap($cmap);
|
||||
|
||||
?>
|
||||
|
||||
38
SWIG/Examples/GIFPlot/Php/simple/simple.i
Normal file
38
SWIG/Examples/GIFPlot/Php/simple/simple.i
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* This example shows a very simple interface wrapping a few
|
||||
primitive declarations */
|
||||
|
||||
%module simple
|
||||
%{
|
||||
#include "gifplot.h"
|
||||
%}
|
||||
|
||||
typedef unsigned char Pixel;
|
||||
|
||||
/* Here are a few useful functions */
|
||||
|
||||
ColorMap *new_ColorMap(char *filename = 0);
|
||||
void delete_ColorMap(ColorMap *cmap);
|
||||
|
||||
FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height);
|
||||
void delete_FrameBuffer(FrameBuffer *frame);
|
||||
void FrameBuffer_clear(FrameBuffer *frame, Pixel color);
|
||||
void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color);
|
||||
int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename);
|
||||
|
||||
/* And some useful constants */
|
||||
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define RED 2
|
||||
#define GREEN 3
|
||||
#define BLUE 4
|
||||
#define YELLOW 5
|
||||
#define CYAN 6
|
||||
#define MAGENTA 7
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2
SWIG/Examples/GIFPlot/Pike/check.list
Normal file
2
SWIG/Examples/GIFPlot/Pike/check.list
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# see top-level Makefile.in
|
||||
simple
|
||||
4
SWIG/Examples/GIFPlot/Pike/simple/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Pike/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
simple_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
24
SWIG/Examples/GIFPlot/Pike/simple/Makefile
Normal file
24
SWIG/Examples/GIFPlot/Pike/simple/Makefile
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT =
|
||||
SRCS =
|
||||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile pike_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
5
SWIG/Examples/GIFPlot/Pike/simple/README
Normal file
5
SWIG/Examples/GIFPlot/Pike/simple/README
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
This is a very minimalistic example in which just a few functions
|
||||
and constants from library are wrapped and used to draw some simple
|
||||
shapes. The script 'runme.pike' runs the example.
|
||||
|
||||
|
||||
30
SWIG/Examples/GIFPlot/Pike/simple/runme.pike
Normal file
30
SWIG/Examples/GIFPlot/Pike/simple/runme.pike
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
int main()
|
||||
{
|
||||
// Draw some simple shapes
|
||||
write("Drawing some basic shapes\n");
|
||||
|
||||
.simple.ColorMap cmap = .simple.new_ColorMap();
|
||||
.simple.FrameBuffer f = .simple.new_FrameBuffer(400, 400);
|
||||
|
||||
// Clear the picture
|
||||
.simple.FrameBuffer_clear(f, .simple.BLACK);
|
||||
|
||||
// Make a red box
|
||||
.simple.FrameBuffer_box(f, 40, 40, 200, 200, .simple.RED);
|
||||
|
||||
// Make a blue circle
|
||||
.simple.FrameBuffer_circle(f, 200, 200, 40, .simple.BLUE);
|
||||
|
||||
// Make green line
|
||||
.simple.FrameBuffer_line(f, 10, 390, 390, 200, .simple.GREEN);
|
||||
|
||||
// Write an image out to disk
|
||||
.simple.FrameBuffer_writeGIF(f, cmap, "image.gif");
|
||||
write("Wrote image.gif\n");
|
||||
|
||||
.simple.delete_FrameBuffer(f);
|
||||
.simple.delete_ColorMap(cmap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
38
SWIG/Examples/GIFPlot/Pike/simple/simple.i
Normal file
38
SWIG/Examples/GIFPlot/Pike/simple/simple.i
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* This example shows a very simple interface wrapping a few
|
||||
primitive declarations */
|
||||
|
||||
%module simple
|
||||
%{
|
||||
#include "gifplot.h"
|
||||
%}
|
||||
|
||||
typedef unsigned char Pixel;
|
||||
|
||||
/* Here are a few useful functions */
|
||||
|
||||
ColorMap *new_ColorMap(char *filename = 0);
|
||||
void delete_ColorMap(ColorMap *cmap);
|
||||
|
||||
FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height);
|
||||
void delete_FrameBuffer(FrameBuffer *frame);
|
||||
void FrameBuffer_clear(FrameBuffer *frame, Pixel color);
|
||||
void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
|
||||
void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color);
|
||||
int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename);
|
||||
|
||||
/* And some useful constants */
|
||||
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define RED 2
|
||||
#define GREEN 3
|
||||
#define BLUE 4
|
||||
#define YELLOW 5
|
||||
#define CYAN 6
|
||||
#define MAGENTA 7
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
4
SWIG/Examples/GIFPlot/Python/check.list
Normal file
4
SWIG/Examples/GIFPlot/Python/check.list
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
shadow
|
||||
simple
|
||||
4
SWIG/Examples/GIFPlot/Python/full/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Python/full/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
gifplot_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -1,23 +1,25 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Include
|
||||
SWIGOPT = -I../../Include
|
||||
SRCS =
|
||||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
# Plot a 3D function
|
||||
from gifplot import *
|
||||
# This example uses the low-level C interface.
|
||||
|
||||
from _gifplot import *
|
||||
from math import *
|
||||
|
||||
# Here is the function to plot
|
||||
|
|
|
|||
6
SWIG/Examples/GIFPlot/Python/shadow/.cvsignore
Normal file
6
SWIG/Examples/GIFPlot/Python/shadow/.cvsignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
gifplot.py
|
||||
gifplot.pyc
|
||||
gifplot_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -1,23 +1,25 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Interface -shadow
|
||||
SWIGOPT = -I../../Interface
|
||||
SRCS =
|
||||
TARGET = gifplotc
|
||||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Python/simple/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Python/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
simple_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,21 @@ SRCS =
|
|||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ GIFPlot
|
|||
To illustrate various SWIG features, the following examples involve
|
||||
building an interface to a small, but somewhat useful graphics library
|
||||
for creating 2D and 3D images in the form of GIF files. The Perl,
|
||||
Python, Tcl, and Ruby directories contain various examples specific to
|
||||
Python, Tcl, Java and Ruby directories contain various examples specific to
|
||||
those languages.
|
||||
|
||||
This library was originally developed as part of the SPaSM molecular
|
||||
|
|
@ -36,7 +36,7 @@ On Windows, you can probably just do this:
|
|||
Running the Examples
|
||||
====================
|
||||
|
||||
Once the library has been built, go the Perl, Python, Tcl, or Ruby directory
|
||||
Once the library has been built, go the Perl, Python, Tcl, Java or Ruby directory
|
||||
to see various SWIG examples. Each example should have a README file with a
|
||||
description.
|
||||
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Ruby/check.list
Normal file
4
SWIG/Examples/GIFPlot/Ruby/check.list
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
shadow
|
||||
simple
|
||||
4
SWIG/Examples/GIFPlot/Ruby/full/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Ruby/full/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
gifplot_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so myruby .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile ruby_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Ruby/shadow/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Ruby/shadow/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
gifplot_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so myruby .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile ruby_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Ruby/simple/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Ruby/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
simple_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so myruby .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile ruby_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Tcl/check.list
Normal file
4
SWIG/Examples/GIFPlot/Tcl/check.list
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
mandel
|
||||
simple
|
||||
4
SWIG/Examples/GIFPlot/Tcl/full/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Tcl/full/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
gifplot_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so mytclsh .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile tcl_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Tcl/mandel/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Tcl/mandel/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
mandel_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = mandel.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='mywish' INTERFACE='$(INTERFACE)' wish
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so mywish .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile tcl_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Tcl/simple/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Tcl/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
simple_wrap.c
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
|
|
@ -5,19 +5,20 @@ SRCS =
|
|||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so mytclsh .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile tcl_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue