compile more examples, refer to them in documentationw and clean up the .gitignore.

This commit is contained in:
Julia Longtin 2016-03-04 01:36:17 +00:00
parent f866eb3b8f
commit af0c5b30b9
6 changed files with 36 additions and 3 deletions

4
.gitignore vendored
View File

@ -1,6 +1,10 @@
*~
*.o
*.hi
*.svg
*.png
*.ps
*.stl
dist/
extopenscad
Setup

9
Examples/example11.hs Normal file
View File

@ -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

8
Examples/example12.hs Normal file
View File

@ -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

8
Examples/example13.hs Normal file
View File

@ -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

View File

@ -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

View File

@ -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!