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
21 genericBrace: \ p0 p1 height aEnd rEndFactor aMid rMidFactor extendLimitFactor →
23 rEnd: height * rEndFactor
24 rMid: height * rMidFactor
25 extendLimit: height * extendLimitFactor
28 n: [[rotate ~90°] height * [normalized r]]
29 [if [abs r] < extendLimit
30 p0>(rEnd^a0-aEnd)--(rMid^180°+a0-aMid)<(p0+0.5*r+n)>(rMid^a0+aMid)--(rEnd^180°+a0+aEnd)<p1
32 r: [normalized ../r] * extendLimit
33 tmp: p0>(rEnd^a0-aEnd)--(rMid^180°+a0-aMid)<(p0+0.5*r+n)>(rMid^a0+aMid)--(rEnd^180°+a0+aEnd)<(p0+r)
34 tmp1: tmp.begin--[tmp 1]
35 slmid: [tmp1 0.5*[abs tmp1]]
36 l1: [maximizer tmp1.begin--slmid [normalized n]].length
37 l2: slmid.length + [maximizer slmid--tmp1.end ~[normalized n]].length
43 (tmp.begin--sl1>(stretchSeg.begin.v/3^))--[[shift 0.5*(../r - r)] (stretchSeg.end.v/3^)<sl2--sl3>(stretchSeg.end.v/3^)]--[[shift ../r - r] (stretchSeg.begin.v/3^)<sl4--tmp.end]
47 heightBrace: [genericBrace aEnd:70° rEndFactor:1.3 aMid:60° rMidFactor:1.6 extendLimitFactor:11 ...]
49 someBrace: [heightBrace height:4mm ...]
52 closedBrace: \ p0 p1 height width:void →
54 lowHeight: height - [if [typeof width]=§Void @width width]
55 lowBrace: [reverse [genericBrace p0 p1 aEnd:70° rEndFactor:1.3 aMid:55° rMidFactor:1.6 extendLimitFactor:11 height:lowHeight]]
56 highBrace: [genericBrace p0 p1 aEnd:80° rEndFactor:1.3 aMid:50° rMidFactor:1.6 extendLimitFactor:11 height:height]
57 lowBrace--highBrace--cycle
60 someClosedBrace: [closedBrace height:5mm ...]