Updating documentation and examples with new core namespaces
[shapes.git] / examples / features / sidepaths.shape
bloba7e666079848830a1c417c1d6d604c2860991660
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 ##needs ..Shapes..Geometry / pathmapping
21 ##lookin ..Shapes
22 ##lookin ..Shapes..Geometry
24 pathpoints:
26   helper: \ sl → [if sl.looped [Data..list] [Data..cons sl [helper sl+1]]]
27   \ pth → [helper pth.begin]
31 sstroke: \ pth →
32 ( (@stroking:Traits..RGB..BLACK | [[pathpoints pth].foldl \ p sl → ( p & [Graphics..stroke [shift sl.p][]( (sl.N*6*@width)--(sl.N*~5*@width) )] )  null])
33    &
34    [Graphics..stroke pth]
37 cstroke: \ pth →
39   (@stroking:Traits..RGB..GREEN & @width:(2*@width) | [Graphics..stroke [Geometry..controlling pth]] )
40   &
41   [sstroke pth]
44 testPth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^~30°)--(^)<(2cm,3cm)>(^45°)--(^)<(5cm,2cm)>(^0°)--(6cm,2cm)--(8cm,4cm)
46 test: \ •dst pth method →
48 @width: 0.5bp
51   •dst << @stroking:Traits..RGB..RED | [cstroke pth]
52   •dst << [Debug..log_after `1´ ...][][Graphics..stroke [method pth 2mm]]
53   •dst << [Debug..log_after `1´ ...][][Graphics..stroke [method pth ~2mm]]
55   {
56     pth: [shift (0,~5cm)][][upsample_inflections ../pth]
57     •dst << @stroking:Traits..RGB..RED | [cstroke pth]
58     •dst << [Debug..log_after `2´ ...][][Graphics..stroke [method pth 2mm]]
59     •dst << [Debug..log_after `2´ ...][][Graphics..stroke [method pth ~2mm]]
60   }
62   {
63     pth: ../pth >> upsample_inflections >> upsample_balance >> [shift (0,~10cm)]
64     •dst << @stroking:Traits..RGB..RED | [cstroke pth]
65     •dst << [Debug..log_after `3´ ...][][Graphics..stroke [method pth 2mm]]
66     •dst << [Debug..log_after `3´ ...][][Graphics..stroke [method pth ~2mm]]
67   }
69   {
70     pth: [shift (0,~15cm)][][upsample_bends 20° ../pth]
71     •dst << @stroking:Traits..RGB..RED | [cstroke pth]
72     •dst << [Debug..log_after `4´ ...][][Graphics..stroke [method pth 2mm]]
73     •dst << [Debug..log_after `4´ ...][][Graphics..stroke [method pth ~2mm]]
74   }
78 [Debug..log_before `sidepath´+"{n} ...][][test IO..•page testPth sidepath]
79 |**[Debug..log_before `sidepath2´+"{n} ...][][test IO..•page [shift (9cm,0)][]testPth sidepath2]