Updating documentation and examples with new core namespaces
[shapes.git] / examples / doc / tutorial-subpath-intersection.shape
blob4ba8bfdd0b9d16f3d5e1ef44f2384618b3d4bd72
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 ##lookin ..Shapes
21 a: (1.5cm,4.5cm)
23 pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm)
24 sl1: [pth 2cm]
25 sl2: [pth 4cm]
27 circMark: @width:0.5bp | [Graphics..stroke [Geometry..circle 4bp]]
28 crossMark: @width:0.5bp | [Graphics..stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)]
30 subpath_intersection: \ sl1 sl2 pth → (sl1+[Geometry..intersection sl1--sl2 pth].length)
32 helper: \ pth2 →
34   ( @width:0.5bp & @stroking:Traits..RGB..BLUE & @dash:[dashpattern 2bp 1bp] | [Graphics..stroke pth2] )
35   &
36   ( @width:0.5bp | [Graphics..stroke pth] )
37   &
38   ( @width:0.0bp | [Graphics..stroke [pth 0.5cm]--[pth 1cm] head:[Graphics..ShapesArrow width:2mm ...]] )
39   &
40   [[shift sl1.p] circMark]
41   &
42   [[shift sl2.p] circMark]
43   &
44   ( @width:5bp & @stroking:Traits..RGB..RED | [spot [subpath_intersection sl1 sl2 pth2].p] ) /** We know that there will be an intersection, so no error handler this time. **/
47 IO..•page << [helper (0cm,0.3cm)--(5cm,5cm)]