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 Henrik Tidefelt
19 ##needs ..Shapes..Graphics3D / revolutionbody
24 [Geometry..circle 1.5cm]
25 >> [shift (3cm,0cm)] >> immerse >> [rotate3D dir:(1,0,0) angle:~90°]
29 doubleDoughnutProfile:
32 [[range 0° 359° 10°].foldl
35 p--(^)<((0.5cm+1cm*[square [abs [cos e]]])*[dir e])>(^)
39 >> [shift (3cm,0cm)] >> immerse >> [rotate3D dir:(1,0,0) angle:~90°]
42 @nonstroking:[gray 0.8]
43 & @width:0.01bp |** used to fill in object edges
44 & @stroking:[gray 0.8] |** used to fill in object edges
46 & @reflections:0.7*[phong 25] + 0.3*[phong 0.5]
47 & @autointensity:[gray 0.3]
48 & @autoscattering:[phong 0.2]
49 & @facetresolution:1cm
50 & @shadeorder:'0 |** use '2 when targeting Adobe Reader or other viewers that can deal with gradient fills.
52 |** [revolutionBody doughnutProfile phiSteps:'25 thetaSteps:'37]
53 [revolutionBody doubleDoughnutProfile phiSteps:'36 thetaSteps:'37]
55 lights: ( newLights << [shift (6cm,8cm,10cm)] [] [specular_light [gray 0.9]]
56 |** << [ambient_light [gray 0.3]]
60 << [rotate3D dir:(1,0,0) angle:~70°] [] doughnut
63 •page << @nonstroking:GRAY_BLACK | [fill [rectangle (~5cm,~4cm) (5cm,4cm)]]
64 •page << view [] world