Updating documentation and examples with new core namespaces
[shapes.git] / examples / applications / spacebase.shape
blobefe36e0ba8b0c1331306d47af321645f23d0dbab
1 /** This file is part of Shapes.
2  **
3  ** Shapes is free software: you can redistribute it and/or modify
4  ** it under the terms of the GNU General Public License as published by
5  ** the Free Software Foundation, either version 3 of the License, or
6  ** any later version.
7  **
8  ** Shapes is distributed in the hope that it will be useful,
9  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  ** GNU General Public License for more details.
12  **
13  ** You should have received a copy of the GNU General Public License
14  ** along with Shapes.  If not, see <http://www.gnu.org/licenses/>.
15  **
16  ** Copyright 2008, 2010, 2014 Henrik Tidefelt
17  **/
19 ##lookin ..Shapes
20 ##lookin ..Shapes..Geometry3D
22 rot: [Geometry3D..rotate (1,1,1) 30°]
24 screwSeg: (~1cm,1cm,~1cm)<(~1cm,0cm,~1cm)>(~1cm,~1cm,~1cm)--(1cm,~1cm,~2cm)<(1cm,0cm,~2cm)>(1cm,1cm,~2cm)
25 deeper: \ n → [shift (0cm,0cm,n*~2cm)]
26 screw: [Geometry3D..scale 1.5] [] (1cm,~1cm,0cm)<(1cm,0cm,0cm)>(1cm,1cm,0cm)--screwSeg--[[deeper 1] screwSeg]--[[deeper 2] screwSeg]--cycle
28 •world: Graphics3D..newGroup
30 •world << @width:0.3bp & @stroking:[gray 0.5] | [Graphics..stroke screw]
32 markStart: 0.15
33 markCount: '5
35 paintLeg: \ pth → ( [Graphics..stroke pth] & ( @nonstroking:Traits..RGB..BLACK | [Graphics..fill [shift pth.end.p][][immerse [Geometry..circle 1.5bp]]] ) )
37 •world <<
38   [[Data..range '0 markCount-'1].foldl
39     \ p i →
40     {
41       sl: [screw (markStart + i*(1/markCount))*[Numeric..Math..abs screw]]
42       len: 2.5cm
43       p &
44       ( Graphics3D..newGroup
45         << @stroking:Traits..RGB..RED   | [paintLeg sl.p--(+(len*sl.T))]
46         << @stroking:Traits..RGB..GREEN | [paintLeg sl.p--(+(len*sl.N))]
47         << @stroking:Traits..RGB..BLUE  | [paintLeg sl.p--(+([if i = '0 ~1 1]*len*sl.B))]
48         << [shift sl.p+(~2mm,3mm,0mm)] [] [facing [Layout..center_x [Graphics..TeX [String..sprintf `\textbf{%d}´ i+'1]]]] )
49     }
50     Graphics3D..null]
52 •world << [shift (~1.5cm,~1.5cm,0cm)] [] [facing [Layout..center_x [Graphics..TeX `Odd one out!´]]]
54 world: •world;
57   world: [Geometry3D..rotate (1,1,1) 30°] [] ../world
58   eyew: 5.0cm
59   IO..•page << view [] world
60   IO..•page << world >> [shift (~eyew,0cm,0cm)] >> view >> [shift (2*eyew,0cm)]