1 /** This file is part of Shapes.
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
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.
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/>.
16 ** Copyright 2008, 2014, 2015 Henrik Tidefelt
20 ##lookin Shapes..Layout
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]
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)]]] )
47 @reflections:[phong 1]
48 & @autointensity:[gray 0.15]
49 & @autoscattering:[phong 0.2]
51 & @facetresolution:1cm
53 [[range 0 0.9999-delta delta].foldl
55 y1: yMin + e * ( yMax - yMin )
56 y2: yMin + ( e + delta ) * ( yMax - yMin )
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)]]
65 [[range 10° 170° 10°].foldsl
68 •st << [rotate3D (0,1,0) ~e] [] obj
74 •zbuf << [shift (10cm,3cm,10cm)] [] [specular_light [gray 0.9]]
78 tmp: [bboxed_enlarge [view zbuf] (5mm,5mm)]
80 •page << @nonstroking:GRAY_BLACK | [fill [bbox tmp]]