diff --git a/.gitignore b/.gitignore index 381d128..99ab19a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ *~ *.o *.hi +*.svg +*.png +*.ps +*.stl dist/ extopenscad Setup diff --git a/Examples/example11.hs b/Examples/example11.hs new file mode 100644 index 0000000..9573d95 --- /dev/null +++ b/Examples/example11.hs @@ -0,0 +1,9 @@ +-- Example 11 - the union of a square and a circle. +import Graphics.Implicit + +out = union [ + rectR 0 (-40,-40) (40,40), + translate (40,40) (circle 30) ] + +main = writeSVG 2 "example11.svg" out + diff --git a/Examples/example12.hs b/Examples/example12.hs new file mode 100644 index 0000000..c451867 --- /dev/null +++ b/Examples/example12.hs @@ -0,0 +1,8 @@ +-- Example 12 - the rounded union of a square and a circle. +import Graphics.Implicit + +out = unionR 14 [ + rectR 0 (-40,-40) (40,40), + translate (40,40) (circle 30) ] + +main = writeSVG 2 "example12.svg" out diff --git a/Examples/example13.hs b/Examples/example13.hs new file mode 100644 index 0000000..875147b --- /dev/null +++ b/Examples/example13.hs @@ -0,0 +1,8 @@ +-- Example 13 - the rounded union of a cube and a sphere. +import Graphics.Implicit + +out = union [ + rect3R 0 (0,0,0) (20,20,20), + translate (20,20,20) (sphere 15) ] + +main = writeSTL 1 "example13.stl" out diff --git a/Makefile b/Makefile index a26dd7c..325e220 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ test: $(EXTOPENSCAD) examples: $(EXTOPENSCAD) cd Examples && for each in `find ./ -name '*scad' -type f | sort`; do { time ../$(EXTOPENSCAD) $$each ${RTSOPTS}; } done + cd Examples && for each in `find ./ -name '*.hs' -type f | sort`; do { filename=$(basename "$$each"); filename="$${filename%.*}"; ghc $$filename.hs -o $$filename; $$filename; } done images: cd Examples && for each in `find ./ -name '*.stl' -type f | sort`; do { filename=$(basename "$$each"); filename="$${filename%.*}"; if [ -e $$filename.transform ] ; then echo ${stl2ps} $$each $$filename.ps `cat $$filename.transform`; else ${stl2ps} $$each $$filename.ps; fi; ${convert} $$filename.ps $$filename.png; } done diff --git a/README.md b/README.md index 4bd99b5..652d77c 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,7 @@ Haskell Examples Everything you saw above can be done with the Haskell API. For example, a simple 2D example, the same as our first ExtOpenSCAD one: ```haskell +-- Example 11 - the union of a square and a circle. import Graphics.Implicit out = union [ @@ -199,12 +200,13 @@ out = union [ main = writeSVG 2 "test.svg" out ``` -![A Union of a Square and Circle](http://faikvm.com/ImplicitCAD/SquareCircleUnion.png) +![A Union of a Square and a Circle](http://faikvm.com/ImplicitCAD/example11.png) A rounded union: ```haskell +-- Example 12 - the rounded union of a square and a circle. import Graphics.Implicit out = unionR 14 [ @@ -214,11 +216,12 @@ out = unionR 14 [ main = writeSVG 2 "test.svg" out ``` -![A Rounded Union of a Square and Circle](http://faikvm.com/ImplicitCAD/SquareCircleUnionR.png) +![A Rounded Union of a Square and a Circle](http://faikvm.com/ImplicitCAD/example12.png) A simple 3D example: ```haskell +-- Example 13 - the rounded union of a cube and a sphere. import Graphics.Implicit out = union [ @@ -228,7 +231,7 @@ out = union [ main = writeSTL 1 "test.stl" out ``` -![A Rounded Union of a Square and Circle](http://faikvm.com/ImplicitCAD/CubeSphereUnion.png) +![A Rounded Union of a Cube and a Sphere](http://faikvm.com/ImplicitCAD/example13.png) You can do a whole lot more!