Update examples after changing Shapes extension namespaces
[shapes.git] / examples / features / lightdemo3b.shape
blobede89313ab0149e6104af9a3b2b1824ac955a435
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, 2015 Henrik Tidefelt
17  **/
19 ##lookin Shapes
20 ##lookin Shapes..Layout
22 •zbuf: newZBuf
24 interp: ( newColorInterpolator
25  << 0.0 << [rgb 0.8 0 0]
26  << 0.1 << [rgb 1 0.8 0.8]
27  << 0.2 << [rgb 0 0 0.8]
28  << 0.3 << [rgb 1 0.8 0.8]
29  << 0.4 << [rgb 0.8 0 0]
30  << 0.5 << [rgb 1 0.8 0.8]
31  << 0.6 << [rgb 0.8 0 0]
32  << 0.7 << [rgb 1 0.8 0.8]
33  << 0.8 << [rgb 0 0.8 0]
34  << 0.9 << [rgb 1 0.8 0.8]
35  << 1.0 << [rgb 0.8 0 0]
36  )
38 yMin: ~5cm
39 yMax: 5cm
41 makeNormal: \ p → ( @nonstroking:[interp (p.y-yMin)/(yMax-yMin)] | [debuglog_before [sprintf `%g´+"{n} (p.y-yMin)/(yMax-yMin)] [facetnormal p [normalized (p.x,p.y,0bp)]]] )
43 r: 6cm
44 ##unit w = 1cm
45 delta: 0.03
46 obj:
47    @reflections:[phong 1]
48   & @autointensity:[gray 0.15]
49   & @autoscattering:[phong 0.2]
50   & @shadeorder:'2
51   & @facetresolution:1cm
52   |
53   [[range 0 0.9999-delta delta].foldl
54    \ p e → {
55      y1: yMin + e * ( yMax - yMin )
56      y2: yMin + ( e + delta ) * ( yMax - yMin )
57      p &
58      [facet (r,y1,~0.5w)--(r,y2,~0.5w)--(r,y2,0.5w)--(r,y1,0.5w)--cycle
59                      [makeNormal (r,y1,~1cm)]
60                      [makeNormal (r,y1,1cm)]
61                      [makeNormal (r,y2,0cm)]]
62     }
63    null3D]
65 [[range 10° 170° 10°].foldsl
66  \ p e •st →
67   !{
68     •st << [rotate3D (0,1,0) ~e] [] obj
69     p
70   }
71  void
72  •zbuf]
74 •zbuf << [shift (10cm,3cm,10cm)] [] [specular_light [gray 0.9]]
76 zbuf: •zbuf;
78 tmp: [bboxed_enlarge [view zbuf] (5mm,5mm)]
80 •page << @nonstroking:GRAY_BLACK | [fill [bbox tmp]]
81 •page << tmp