mirror of
https://github.com/Haskell-Things/ImplicitCAD.git
synced 2024-09-11 04:55:41 +03:00
compile more examples, refer to them in documentationw and clean up the .gitignore.
This commit is contained in:
parent
f866eb3b8f
commit
af0c5b30b9
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,6 +1,10 @@
|
||||
*~
|
||||
*.o
|
||||
*.hi
|
||||
*.svg
|
||||
*.png
|
||||
*.ps
|
||||
*.stl
|
||||
dist/
|
||||
extopenscad
|
||||
Setup
|
||||
|
9
Examples/example11.hs
Normal file
9
Examples/example11.hs
Normal 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
8
Examples/example12.hs
Normal 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
8
Examples/example13.hs
Normal 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
|
1
Makefile
1
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
|
||||
|
@ -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!
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user