summaryrefslogtreecommitdiff
path: root/Examples/GIFPlot/Chicken/simple
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2009-08-18 20:56:02 +0000
committerLorry <lorry@roadtrain.codethink.co.uk>2012-09-25 16:59:08 +0000
commit9f8a09ed743cedd9547bf0661d518647966ab114 (patch)
tree9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/GIFPlot/Chicken/simple
downloadswig-tarball-master.tar.gz
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/GIFPlot/Chicken/simple')
-rw-r--r--Examples/GIFPlot/Chicken/simple/Makefile28
-rw-r--r--Examples/GIFPlot/Chicken/simple/README5
-rw-r--r--Examples/GIFPlot/Chicken/simple/simple.i34
-rw-r--r--Examples/GIFPlot/Chicken/simple/test-simple.scm29
4 files changed, 96 insertions, 0 deletions
diff --git a/Examples/GIFPlot/Chicken/simple/Makefile b/Examples/GIFPlot/Chicken/simple/Makefile
new file mode 100644
index 0000000..484e583
--- /dev/null
+++ b/Examples/GIFPlot/Chicken/simple/Makefile
@@ -0,0 +1,28 @@
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+INTERFACE = simple.i
+SRCS =
+CXXSRCS =
+TARGET = simple
+INCLUDE = -I. -I../../Include
+SWIGOPT = -I../../Include
+CFLAGS =
+VARIANT =
+LIBS = -L../.. -lgifplot -lm
+
+# comment the following two lines to build a dynamic so file
+CHICKEN_MAIN = test-simple.scm
+VARIANT = _static
+
+all:: $(TARGET)
+
+$(TARGET): $(INTERFACE) $(SRCS)
+ $(MAKE) -f $(TOP)/Makefile \
+ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
+ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \
+ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile chicken_clean
+ rm -f simple.scm image.gif
+ rm -f $(TARGET)
diff --git a/Examples/GIFPlot/Chicken/simple/README b/Examples/GIFPlot/Chicken/simple/README
new file mode 100644
index 0000000..3b138f3
--- /dev/null
+++ b/Examples/GIFPlot/Chicken/simple/README
@@ -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.
+
+`make' will build an exe. Run ./simple to test it.
diff --git a/Examples/GIFPlot/Chicken/simple/simple.i b/Examples/GIFPlot/Chicken/simple/simple.i
new file mode 100644
index 0000000..23ac8a8
--- /dev/null
+++ b/Examples/GIFPlot/Chicken/simple/simple.i
@@ -0,0 +1,34 @@
+/* This example shows a very simple interface wrapping a few
+ primitive declarations */
+
+%module simple
+%{
+#include "gifplot.h"
+%}
+
+typedef unsigned 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, which we redefine (from gifplot.h) so
+ that SWIG sees them */
+#define BLACK 0
+#define WHITE 1
+#define RED 2
+#define GREEN 3
+#define BLUE 4
+#define YELLOW 5
+#define CYAN 6
+#define MAGENTA 7
+
diff --git a/Examples/GIFPlot/Chicken/simple/test-simple.scm b/Examples/GIFPlot/Chicken/simple/test-simple.scm
new file mode 100644
index 0000000..43250d8
--- /dev/null
+++ b/Examples/GIFPlot/Chicken/simple/test-simple.scm
@@ -0,0 +1,29 @@
+;;; Draw some simple shapes
+
+(declare (uses simple))
+
+(display "Drawing some basic shapes\n")
+
+(define cmap (simple:new-ColorMap #f))
+(define 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")
+(display "Wrote image.gif\n")
+
+(simple:delete-FrameBuffer f)
+(simple:delete-ColorMap cmap)
+