Updating documentation and examples with new core namespaces
[shapes.git] / examples / features / zsorterdemo.shape
blobdf8fac3e346d6213bb1ef74feb34cdbc38dbed06
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, 2014 Henrik Tidefelt
17  **/
19 ##echo This example illustrates that a z sorter does a bad job with cyclic overlaps.
21 ##lookin ..Shapes
22 ##lookin ..Shapes..Geometry3D
24 leaf: \ a →
26   @nonstroking:[gray a / 360°]
27   |
28   [Geometry3D..rotate angle:a dir:(0,0,1)] [] [Graphics..fill (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)--cycle]
31 •zbuf: Graphics3D..newZSorter
33 •zbuf <<
34 [[Data..range 0° 359° 120°].foldl
35  \ p e → p & [leaf e]
36  Graphics3D..null]
38 •zbuf << @nonstroking:[gray 0.3] | [Graphics..fill (3cm,~2cm,0cm)--(3cm,2cm,0cm)--(7cm,0cm,2cm)--cycle]
39       << @nonstroking:[gray 0.7] | [Graphics..fill (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle]
41 zbuf: •zbuf;
44 tf: [Geometry3D..rotate (1,0,0) 60°]
45 |**tf: [Geometry3D..affinetransform (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)]
46 [view tf [] zbuf]