/usr/share/doc/libghc-diagrams-lib-doc/html/src/Diagrams-TwoD-Model.html is in libghc-diagrams-lib-doc 1.3.1.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>src/Diagrams/TwoD/Model.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE FlexibleContexts #-}</span>
<a name="line-2"></a><span class='hs-comment'>{-# LANGUAGE MultiParamTypeClasses #-}</span>
<a name="line-3"></a><span class='hs-comment'>{-# LANGUAGE TemplateHaskell #-}</span>
<a name="line-4"></a><span class='hs-comment'>{-# LANGUAGE TypeFamilies #-}</span>
<a name="line-5"></a><span class='hs-comment'>-----------------------------------------------------------------------------</span>
<a name="line-6"></a><span class='hs-comment'>-- |</span>
<a name="line-7"></a><span class='hs-comment'>-- Module : Diagrams.TwoD.Model</span>
<a name="line-8"></a><span class='hs-comment'>-- Copyright : (c) 2011 diagrams-lib team (see LICENSE)</span>
<a name="line-9"></a><span class='hs-comment'>-- License : BSD-style (see LICENSE)</span>
<a name="line-10"></a><span class='hs-comment'>-- Maintainer : diagrams-discuss@googlegroups.com</span>
<a name="line-11"></a><span class='hs-comment'>--</span>
<a name="line-12"></a><span class='hs-comment'>-- Tools for visualizing diagrams' internal model: local origins,</span>
<a name="line-13"></a><span class='hs-comment'>-- envelopes, traces, /etc./</span>
<a name="line-14"></a><span class='hs-comment'>--</span>
<a name="line-15"></a><span class='hs-comment'>-----------------------------------------------------------------------------</span>
<a name="line-16"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Model</span>
<a name="line-17"></a> <span class='hs-layout'>(</span> <span class='hs-comment'>-- * Showing the local origin</span>
<a name="line-18"></a> <span class='hs-varid'>showOrigin</span>
<a name="line-19"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>showOrigin'</span>
<a name="line-20"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>OriginOpts</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>oColor</span><span class='hs-layout'>,</span> <span class='hs-varid'>oScale</span><span class='hs-layout'>,</span> <span class='hs-varid'>oMinSize</span>
<a name="line-21"></a>
<a name="line-22"></a> <span class='hs-comment'>-- * Showing an approximation of the envelope</span>
<a name="line-23"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>showEnvelope</span>
<a name="line-24"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>showEnvelope'</span>
<a name="line-25"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>EnvelopeOpts</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>eColor</span><span class='hs-layout'>,</span> <span class='hs-varid'>eLineWidth</span><span class='hs-layout'>,</span> <span class='hs-varid'>ePoints</span>
<a name="line-26"></a>
<a name="line-27"></a> <span class='hs-comment'>-- * Showing an approximation of the trace</span>
<a name="line-28"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>showTrace</span>
<a name="line-29"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>showTrace'</span>
<a name="line-30"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>TraceOpts</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>tColor</span><span class='hs-layout'>,</span> <span class='hs-varid'>tScale</span><span class='hs-layout'>,</span> <span class='hs-varid'>tMinSize</span><span class='hs-layout'>,</span> <span class='hs-varid'>tPoints</span>
<a name="line-31"></a>
<a name="line-32"></a> <span class='hs-comment'>-- * Showing labels of all named subdiagrams</span>
<a name="line-33"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>showLabels</span>
<a name="line-34"></a> <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-35"></a>
<a name="line-36"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Arrow</span> <span class='hs-layout'>(</span><span class='hs-varid'>second</span><span class='hs-layout'>)</span>
<a name="line-37"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Lens</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeLenses</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-varop'>^.</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-38"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Colour</span> <span class='hs-layout'>(</span><span class='hs-conid'>Colour</span><span class='hs-layout'>)</span>
<a name="line-39"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Colour</span><span class='hs-varop'>.</span><span class='hs-conid'>Names</span>
<a name="line-40"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Default</span><span class='hs-varop'>.</span><span class='hs-conid'>Class</span>
<a name="line-41"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>List</span> <span class='hs-layout'>(</span><span class='hs-varid'>intercalate</span><span class='hs-layout'>)</span>
<a name="line-42"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Map</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>M</span>
<a name="line-43"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-varid'>catMaybes</span><span class='hs-layout'>)</span>
<a name="line-44"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Semigroup</span>
<a name="line-45"></a>
<a name="line-46"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>Attributes</span>
<a name="line-47"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>Combinators</span> <span class='hs-layout'>(</span><span class='hs-varid'>atPoints</span><span class='hs-layout'>)</span>
<a name="line-48"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>Core</span>
<a name="line-49"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>Core</span><span class='hs-varop'>.</span><span class='hs-conid'>Names</span>
<a name="line-50"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>CubicSpline</span>
<a name="line-51"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>Path</span>
<a name="line-52"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Attributes</span>
<a name="line-53"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Ellipse</span>
<a name="line-54"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Path</span>
<a name="line-55"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Text</span>
<a name="line-56"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Transform</span> <span class='hs-layout'>(</span><span class='hs-varid'>rotateBy</span><span class='hs-layout'>)</span>
<a name="line-57"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
<a name="line-58"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>TwoD</span><span class='hs-varop'>.</span><span class='hs-conid'>Vector</span> <span class='hs-layout'>(</span><span class='hs-varid'>unitX</span><span class='hs-layout'>)</span>
<a name="line-59"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Diagrams</span><span class='hs-varop'>.</span><span class='hs-conid'>Util</span>
<a name="line-60"></a>
<a name="line-61"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Linear</span><span class='hs-varop'>.</span><span class='hs-conid'>Affine</span>
<a name="line-62"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Linear</span><span class='hs-varop'>.</span><span class='hs-conid'>Vector</span>
<a name="line-63"></a>
<a name="line-64"></a><span class='hs-comment'>------------------------------------------------------------</span>
<a name="line-65"></a><span class='hs-comment'>-- Marking the origin</span>
<a name="line-66"></a><span class='hs-comment'>------------------------------------------------------------</span>
<a name="line-67"></a>
<a name="line-68"></a><a name="OriginOpts"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>OriginOpts</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>OriginOpts</span>
<a name="line-69"></a> <span class='hs-layout'>{</span> <span class='hs-sel'>_oColor</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Colour</span> <span class='hs-conid'>Double</span>
<a name="line-70"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_oScale</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>n</span>
<a name="line-71"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_oMinSize</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>n</span>
<a name="line-72"></a> <span class='hs-layout'>}</span>
<a name="line-73"></a>
<a name="line-74"></a><a name="makeLenses"></a><span class='hs-definition'>makeLenses</span> <span class='hs-chr'>'</span><span class='hs-chr'>'</span><span class='hs-conid'>OriginOpts</span>
<a name="line-75"></a>
<a name="line-76"></a><a name="instance%20Default%20(OriginOpts%20n)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Fractional</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Default</span> <span class='hs-layout'>(</span><span class='hs-conid'>OriginOpts</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-77"></a> <span class='hs-varid'>def</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>OriginOpts</span> <span class='hs-varid'>red</span> <span class='hs-layout'>(</span><span class='hs-num'>1</span><span class='hs-varop'>/</span><span class='hs-num'>50</span><span class='hs-layout'>)</span> <span class='hs-num'>0.001</span>
<a name="line-78"></a>
<a name="line-79"></a><a name="EnvelopeOpts"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>EnvelopeOpts</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>EnvelopeOpts</span>
<a name="line-80"></a> <span class='hs-layout'>{</span> <span class='hs-sel'>_eColor</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Colour</span> <span class='hs-conid'>Double</span>
<a name="line-81"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_eLineWidth</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Measure</span> <span class='hs-varid'>n</span>
<a name="line-82"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_ePoints</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Int</span>
<a name="line-83"></a> <span class='hs-layout'>}</span>
<a name="line-84"></a>
<a name="line-85"></a><span class='hs-definition'>makeLenses</span> <span class='hs-chr'>'</span><span class='hs-chr'>'</span><span class='hs-conid'>EnvelopeOpts</span>
<a name="line-86"></a>
<a name="line-87"></a><a name="instance%20Default%20(EnvelopeOpts%20n)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>OrderedField</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Default</span> <span class='hs-layout'>(</span><span class='hs-conid'>EnvelopeOpts</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-88"></a> <span class='hs-varid'>def</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>EnvelopeOpts</span> <span class='hs-varid'>red</span> <span class='hs-varid'>medium</span> <span class='hs-num'>32</span>
<a name="line-89"></a>
<a name="line-90"></a><a name="TraceOpts"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>TraceOpts</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>TraceOpts</span>
<a name="line-91"></a> <span class='hs-layout'>{</span> <span class='hs-sel'>_tColor</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Colour</span> <span class='hs-conid'>Double</span>
<a name="line-92"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_tScale</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>n</span>
<a name="line-93"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_tMinSize</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>n</span>
<a name="line-94"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_tPoints</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Int</span>
<a name="line-95"></a> <span class='hs-layout'>}</span>
<a name="line-96"></a>
<a name="line-97"></a><span class='hs-definition'>makeLenses</span> <span class='hs-chr'>'</span><span class='hs-chr'>'</span><span class='hs-conid'>TraceOpts</span>
<a name="line-98"></a>
<a name="line-99"></a><a name="instance%20Default%20(TraceOpts%20n)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Floating</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Default</span> <span class='hs-layout'>(</span><span class='hs-conid'>TraceOpts</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-100"></a> <span class='hs-varid'>def</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>TraceOpts</span> <span class='hs-varid'>red</span> <span class='hs-layout'>(</span><span class='hs-num'>1</span><span class='hs-varop'>/</span><span class='hs-num'>100</span><span class='hs-layout'>)</span> <span class='hs-num'>0.001</span> <span class='hs-num'>64</span>
<a name="line-101"></a>
<a name="line-102"></a><a name="showOrigin"></a><span class='hs-comment'>-- | Mark the origin of a diagram by placing a red dot 1/50th its size.</span>
<a name="line-103"></a><span class='hs-definition'>showOrigin</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>TypeableFloat</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>Renderable</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>b</span><span class='hs-layout'>,</span> <span class='hs-conid'>Monoid'</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span>
<a name="line-104"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-varid'>m</span>
<a name="line-105"></a><span class='hs-definition'>showOrigin</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>showOrigin'</span> <span class='hs-varid'>def</span>
<a name="line-106"></a>
<a name="line-107"></a><a name="showOrigin'"></a><span class='hs-comment'>-- | Mark the origin of a diagram, with control over colour and scale</span>
<a name="line-108"></a><span class='hs-comment'>-- of marker dot.</span>
<a name="line-109"></a><span class='hs-definition'>showOrigin'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>TypeableFloat</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>Renderable</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>b</span><span class='hs-layout'>,</span> <span class='hs-conid'>Monoid'</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span>
<a name="line-110"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>OriginOpts</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-varid'>m</span>
<a name="line-111"></a><span class='hs-definition'>showOrigin'</span> <span class='hs-varid'>oo</span> <span class='hs-varid'>d</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>o</span> <span class='hs-varop'><></span> <span class='hs-varid'>d</span>
<a name="line-112"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>o</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>strokeP</span> <span class='hs-layout'>(</span><span class='hs-varid'>circle</span> <span class='hs-varid'>sz</span><span class='hs-layout'>)</span>
<a name="line-113"></a> <span class='hs-cpp'>#</span> <span class='hs-varid'>fc</span> <span class='hs-layout'>(</span><span class='hs-varid'>oo</span><span class='hs-varop'>^.</span><span class='hs-varid'>oColor</span><span class='hs-layout'>)</span>
<a name="line-114"></a> <span class='hs-cpp'>#</span> <span class='hs-varid'>lw</span> <span class='hs-varid'>none</span>
<a name="line-115"></a> <span class='hs-cpp'>#</span> <span class='hs-varid'>fmap</span> <span class='hs-layout'>(</span><span class='hs-varid'>const</span> <span class='hs-varid'>mempty</span><span class='hs-layout'>)</span>
<a name="line-116"></a> <span class='hs-conid'>V2</span> <span class='hs-varid'>w</span> <span class='hs-varid'>h</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>oo</span><span class='hs-varop'>^.</span><span class='hs-varid'>oScale</span> <span class='hs-varop'>*^</span> <span class='hs-varid'>size</span> <span class='hs-varid'>d</span>
<a name="line-117"></a> <span class='hs-varid'>sz</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>maximum</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>w</span><span class='hs-layout'>,</span> <span class='hs-varid'>h</span><span class='hs-layout'>,</span> <span class='hs-varid'>oo</span><span class='hs-varop'>^.</span><span class='hs-varid'>oMinSize</span><span class='hs-keyglyph'>]</span>
<a name="line-118"></a>
<a name="line-119"></a><a name="showEnvelope'"></a><span class='hs-comment'>-- | Mark the envelope with an approximating cubic spline with control </span>
<a name="line-120"></a><span class='hs-comment'>-- over the color, line width and number of points.</span>
<a name="line-121"></a><span class='hs-definition'>showEnvelope'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Enum</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>TypeableFloat</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>Renderable</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
<a name="line-122"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>EnvelopeOpts</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span>
<a name="line-123"></a><span class='hs-definition'>showEnvelope'</span> <span class='hs-varid'>opts</span> <span class='hs-varid'>d</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cubicSpline</span> <span class='hs-conid'>True</span> <span class='hs-varid'>pts</span> <span class='hs-cpp'>#</span> <span class='hs-varid'>lc</span> <span class='hs-layout'>(</span><span class='hs-varid'>opts</span><span class='hs-varop'>^.</span><span class='hs-varid'>eColor</span><span class='hs-layout'>)</span>
<a name="line-124"></a> <span class='hs-cpp'>#</span> <span class='hs-varid'>lw</span> <span class='hs-varid'>w</span> <span class='hs-varop'><></span> <span class='hs-varid'>d</span>
<a name="line-125"></a> <span class='hs-keyword'>where</span>
<a name="line-126"></a> <span class='hs-varid'>pts</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>catMaybes</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>envelopePMay</span> <span class='hs-varid'>v</span> <span class='hs-varid'>d</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varop'>`rotateBy`</span> <span class='hs-varid'>unitX</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>[</span><span class='hs-num'>0</span><span class='hs-layout'>,</span><span class='hs-varid'>inc</span><span class='hs-keyglyph'>..</span><span class='hs-varid'>top</span><span class='hs-keyglyph'>]</span><span class='hs-keyglyph'>]</span>
<a name="line-127"></a> <span class='hs-varid'>w</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>opts</span> <span class='hs-varop'>^.</span> <span class='hs-varid'>eLineWidth</span>
<a name="line-128"></a> <span class='hs-varid'>inc</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>1</span> <span class='hs-varop'>/</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-layout'>(</span><span class='hs-varid'>opts</span><span class='hs-varop'>^.</span><span class='hs-varid'>ePoints</span><span class='hs-layout'>)</span>
<a name="line-129"></a> <span class='hs-varid'>top</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>1</span> <span class='hs-comment'>-</span> <span class='hs-varid'>inc</span>
<a name="line-130"></a>
<a name="line-131"></a>
<a name="line-132"></a><a name="showEnvelope"></a><span class='hs-comment'>-- | Mark the envelope with an approximating cubic spline</span>
<a name="line-133"></a><span class='hs-comment'>-- using 32 points, medium line width and red line color.</span>
<a name="line-134"></a><span class='hs-definition'>showEnvelope</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Enum</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>TypeableFloat</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>Renderable</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
<a name="line-135"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span>
<a name="line-136"></a><span class='hs-definition'>showEnvelope</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>showEnvelope'</span> <span class='hs-varid'>def</span>
<a name="line-137"></a>
<a name="line-138"></a><a name="showTrace'"></a><span class='hs-comment'>-- | Mark the trace of a diagram, with control over colour and scale</span>
<a name="line-139"></a><span class='hs-comment'>-- of marker dot and the number of points on the trace.</span>
<a name="line-140"></a><span class='hs-definition'>showTrace'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Enum</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>TypeableFloat</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>Renderable</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
<a name="line-141"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TraceOpts</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span>
<a name="line-142"></a><span class='hs-definition'>showTrace'</span> <span class='hs-varid'>opts</span> <span class='hs-varid'>d</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>atPoints</span> <span class='hs-varid'>ps</span> <span class='hs-layout'>(</span><span class='hs-varid'>repeat</span> <span class='hs-varid'>pt</span><span class='hs-layout'>)</span> <span class='hs-varop'><></span> <span class='hs-varid'>d</span>
<a name="line-143"></a> <span class='hs-keyword'>where</span>
<a name="line-144"></a> <span class='hs-varid'>ps</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>concatMap</span> <span class='hs-varid'>p</span> <span class='hs-varid'>ts</span>
<a name="line-145"></a> <span class='hs-varid'>ts</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>zip</span> <span class='hs-varid'>rs</span> <span class='hs-varid'>vs</span>
<a name="line-146"></a> <span class='hs-varid'>p</span> <span class='hs-layout'>(</span><span class='hs-varid'>r</span><span class='hs-layout'>,</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>origin</span> <span class='hs-varop'>.+^</span> <span class='hs-layout'>(</span><span class='hs-varid'>s</span> <span class='hs-varop'>*^</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>r</span><span class='hs-keyglyph'>]</span>
<a name="line-147"></a> <span class='hs-varid'>vs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varop'>`rotateBy`</span> <span class='hs-varid'>unitX</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>[</span><span class='hs-num'>0</span><span class='hs-layout'>,</span> <span class='hs-varid'>inc</span><span class='hs-keyglyph'>..</span><span class='hs-varid'>top</span><span class='hs-keyglyph'>]</span>
<a name="line-148"></a> <span class='hs-varid'>rs</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>getSortedList</span> <span class='hs-varop'>$</span> <span class='hs-layout'>(</span><span class='hs-varid'>appTrace</span> <span class='hs-varop'>.</span> <span class='hs-varid'>getTrace</span><span class='hs-layout'>)</span> <span class='hs-varid'>d</span> <span class='hs-varid'>origin</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>vs</span><span class='hs-keyglyph'>]</span>
<a name="line-149"></a> <span class='hs-varid'>pt</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>circle</span> <span class='hs-varid'>sz</span> <span class='hs-cpp'>#</span> <span class='hs-varid'>fc</span> <span class='hs-layout'>(</span><span class='hs-varid'>opts</span><span class='hs-varop'>^.</span><span class='hs-varid'>tColor</span><span class='hs-layout'>)</span> <span class='hs-cpp'>#</span> <span class='hs-varid'>lw</span> <span class='hs-varid'>none</span>
<a name="line-150"></a> <span class='hs-conid'>V2</span> <span class='hs-varid'>w</span> <span class='hs-varid'>h</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>opts</span><span class='hs-varop'>^.</span><span class='hs-varid'>tScale</span> <span class='hs-varop'>*^</span> <span class='hs-varid'>size</span> <span class='hs-varid'>d</span>
<a name="line-151"></a> <span class='hs-varid'>sz</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>maximum</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>w</span><span class='hs-layout'>,</span> <span class='hs-varid'>h</span><span class='hs-layout'>,</span> <span class='hs-varid'>opts</span><span class='hs-varop'>^.</span><span class='hs-varid'>tMinSize</span><span class='hs-keyglyph'>]</span>
<a name="line-152"></a> <span class='hs-varid'>inc</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>1</span> <span class='hs-varop'>/</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-layout'>(</span><span class='hs-varid'>opts</span><span class='hs-varop'>^.</span><span class='hs-varid'>tPoints</span><span class='hs-layout'>)</span>
<a name="line-153"></a> <span class='hs-varid'>top</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>1</span> <span class='hs-comment'>-</span> <span class='hs-varid'>inc</span>
<a name="line-154"></a>
<a name="line-155"></a><a name="showTrace"></a><span class='hs-comment'>-- | Mark the trace of a diagram by placing 64 red dots 1/100th its size</span>
<a name="line-156"></a><span class='hs-comment'>-- along the trace.</span>
<a name="line-157"></a><span class='hs-definition'>showTrace</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Enum</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>TypeableFloat</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>Renderable</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
<a name="line-158"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span>
<a name="line-159"></a><span class='hs-definition'>showTrace</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>showTrace'</span> <span class='hs-varid'>def</span>
<a name="line-160"></a>
<a name="line-161"></a><span class='hs-comment'>------------------------------------------------------------</span>
<a name="line-162"></a><span class='hs-comment'>-- Labeling named points</span>
<a name="line-163"></a><span class='hs-comment'>------------------------------------------------------------</span>
<a name="line-164"></a>
<a name="line-165"></a><a name="showLabels"></a><span class='hs-definition'>showLabels</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>TypeableFloat</span> <span class='hs-varid'>n</span><span class='hs-layout'>,</span> <span class='hs-conid'>Renderable</span> <span class='hs-layout'>(</span><span class='hs-conid'>Text</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>b</span><span class='hs-layout'>,</span> <span class='hs-conid'>Semigroup</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span>
<a name="line-166"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>QDiagram</span> <span class='hs-varid'>b</span> <span class='hs-conid'>V2</span> <span class='hs-varid'>n</span> <span class='hs-conid'>Any</span>
<a name="line-167"></a><span class='hs-definition'>showLabels</span> <span class='hs-varid'>d</span> <span class='hs-keyglyph'>=</span>
<a name="line-168"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>mconcat</span>
<a name="line-169"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>n</span><span class='hs-layout'>,</span><span class='hs-varid'>p</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>text</span> <span class='hs-layout'>(</span><span class='hs-varid'>simpleName</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-cpp'>#</span> <span class='hs-varid'>translate</span> <span class='hs-layout'>(</span><span class='hs-varid'>p</span> <span class='hs-varop'>.-.</span> <span class='hs-varid'>origin</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-170"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>concatMap</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>n</span><span class='hs-layout'>,</span><span class='hs-varid'>ps</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>zip</span> <span class='hs-layout'>(</span><span class='hs-varid'>repeat</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-varid'>ps</span><span class='hs-layout'>)</span>
<a name="line-171"></a> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-varid'>map</span> <span class='hs-varop'>.</span> <span class='hs-varid'>second</span> <span class='hs-varop'>.</span> <span class='hs-varid'>map</span><span class='hs-layout'>)</span> <span class='hs-varid'>location</span>
<a name="line-172"></a> <span class='hs-varop'>.</span> <span class='hs-conid'>M</span><span class='hs-varop'>.</span><span class='hs-varid'>assocs</span>
<a name="line-173"></a> <span class='hs-varop'>$</span> <span class='hs-varid'>m</span>
<a name="line-174"></a> <span class='hs-layout'>)</span> <span class='hs-varop'><></span>
<a name="line-175"></a> <span class='hs-varid'>fmap</span> <span class='hs-layout'>(</span><span class='hs-varid'>const</span> <span class='hs-layout'>(</span><span class='hs-conid'>Any</span> <span class='hs-conid'>False</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varid'>d</span>
<a name="line-176"></a> <span class='hs-keyword'>where</span>
<a name="line-177"></a> <span class='hs-conid'>SubMap</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>d</span><span class='hs-varop'>^.</span><span class='hs-varid'>subMap</span>
<a name="line-178"></a> <span class='hs-varid'>simpleName</span> <span class='hs-layout'>(</span><span class='hs-conid'>Name</span> <span class='hs-varid'>ns</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>intercalate</span> <span class='hs-str'>" .> "</span> <span class='hs-varop'>$</span> <span class='hs-varid'>map</span> <span class='hs-varid'>simpleAName</span> <span class='hs-varid'>ns</span>
<a name="line-179"></a> <span class='hs-varid'>simpleAName</span> <span class='hs-layout'>(</span><span class='hs-conid'>AName</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>show</span> <span class='hs-varid'>n</span>
</pre></body>
</html>
|